Skip to content

Commit

Permalink
Add allow_files_filtered_by_circles option, to list or not circle i…
Browse files Browse the repository at this point in the history
…n the files app

Default is set to `1` to list them in the `files` application
To hide them, set it to `0`

Signed-off-by: Tortue Torche <tortuetorche@users.noreply.github.com>
  • Loading branch information
tortuetorche committed Apr 1, 2020
1 parent 6a6dd89 commit 0dff4ea
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ function() {
}

public function registerFilesPlugin() {
try {
/** @var ConfigService $configService */
$configService = $this->server->query(ConfigService::class);
if (!$configService->isFilesFilteredCirclesAllowed()) {
return;
}
} catch (QueryException $e) {
return;
}

$this->dispatcher->addListener(
'OCA\Files::loadAdditionalScripts',
function() {
Expand All @@ -148,6 +158,16 @@ function() {
*
*/
public function registerFilesNavigation() {
try {
/** @var ConfigService $configService */
$configService = $this->server->query(ConfigService::class);
if (!$configService->isFilesFilteredCirclesAllowed()) {
return;
}
} catch (QueryException $e) {
return;
}

$appManager = FilesApp::getNavigationManager();
$appManager->add(
function() {
Expand Down
19 changes: 19 additions & 0 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ConfigService {
const CIRCLES_ALLOW_FEDERATED_CIRCLES = 'allow_federated';
const CIRCLES_MEMBERS_LIMIT = 'members_limit';
const CIRCLES_ACCOUNTS_ONLY = 'accounts_only';
const CIRCLES_ALLOW_FILES_CIRCLES_FILTER = 'allow_files_filtered_by_circles';
const CIRCLES_ALLOW_LISTED_CIRCLES = 'allow_listed_circles';
const CIRCLES_ALLOW_ANY_GROUP_MEMBERS = 'allow_adding_any_group_members';
const CIRCLES_ALLOW_LINKED_GROUPS = 'allow_linked_groups';
Expand Down Expand Up @@ -68,6 +69,7 @@ class ConfigService {
self::CIRCLES_NON_SSL_LOCAL => '0',
self::CIRCLES_ACTIVITY_ON_CREATION => '1',
self::CIRCLES_SKIP_INVITATION_STEP => '0'
self::CIRCLES_ALLOW_FILES_CIRCLES_FILTER => '1',
self::CIRCLES_ALLOW_LISTED_CIRCLES => '1',
self::CIRCLES_ALLOW_ANY_GROUP_MEMBERS => '1',
];
Expand All @@ -90,6 +92,9 @@ class ConfigService {
/** @var int */
private $allowedCircle = -1;

/** @var int */
private $allowFilesFilteredByCircles = -1;

/** @var int */
private $allowedListedCircles = -1;

Expand Down Expand Up @@ -149,6 +154,20 @@ public function isCircleAllowed($type) {
return ((int)$type & (int)$this->allowedCircle);
}

/**
* returns if the files list could be filtered by circles
*
* @return bool
*/
public function isFilesFilteredCirclesAllowed() {
if ($this->allowFilesFilteredByCircles === -1) {
$this->allowFilesFilteredByCircles =
(int)$this->getAppValue(self::CIRCLES_ALLOW_FILES_CIRCLES_FILTER);
}

return ($this->allowFilesFilteredByCircles === 1);
}

/**
* returns if the circles are allowed to be listed outside the Circles application.
*
Expand Down

0 comments on commit 0dff4ea

Please sign in to comment.