Skip to content

Commit

Permalink
disable grouplink on GS setup
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Jul 7, 2020
1 parent 6164c71 commit 719e416
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
18 changes: 5 additions & 13 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Service\MiscService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IRequest;


Expand All @@ -26,15 +25,6 @@ public function __construct(
}


/**
* @NoCSRFRequired
* @return TemplateResponse
*/
public function admin() {
return new TemplateResponse($this->appName, 'settings.admin', [], 'blank');
}


/**
* @NoCSRFRequired
*/
Expand All @@ -49,7 +39,7 @@ public function getSettings() {
'allowFederatedCircles' => $this->configService->getAppValue(
ConfigService::CIRCLES_ALLOW_FEDERATED_CIRCLES
),
'skipInvitationStep' => $this->configService->getAppValue(
'skipInvitationStep' => $this->configService->getAppValue(
ConfigService::CIRCLES_SKIP_INVITATION_STEP
)
];
Expand All @@ -58,7 +48,9 @@ public function getSettings() {
}


public function setSettings($members_limit, $allow_linked_groups, $allow_federated_circles, $skip_invitation_to_closed_circles) {
public function setSettings(
$members_limit, $allow_linked_groups, $allow_federated_circles, $skip_invitation_to_closed_circles
) {
$this->configService->setAppValue(
ConfigService::CIRCLES_MEMBERS_LIMIT, $members_limit
);
Expand All @@ -75,4 +67,4 @@ public function setSettings($members_limit, $allow_linked_groups, $allow_federat
return $this->getSettings();
}

}
}
6 changes: 4 additions & 2 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,13 @@ public function isCircleAllowed($type) {

/**
* @return bool
* @throws GSStatusException
*/
public function isLinkedGroupsAllowed() {
if ($this->allowedLinkedGroups === -1) {
$this->allowedLinkedGroups =
(int)$this->getAppValue(self::CIRCLES_ALLOW_LINKED_GROUPS);
$allowed = ($this->getAppValue(self::CIRCLES_ALLOW_LINKED_GROUPS) === '1'
&& !$this->getGSStatus(self::GS_ENABLED));
$this->allowedLinkedGroups = ($allowed) ? 1 : 0;
}

return ($this->allowedLinkedGroups === 1);
Expand Down
27 changes: 25 additions & 2 deletions lib/Settings/CirclesSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,67 @@
*
*/


namespace OCA\Circles\Settings;


use OCA\Circles\Exceptions\GSStatusException;
use OCA\Circles\Service\ConfigService;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\Settings\ISettings;


class CirclesSettings implements ISettings {


/** @var IConfig */
private $config;

/** @var ConfigService */
private $configService;


/**
* CirclesSettings constructor.
*
* @param IConfig $config
* @param ConfigService $configService
*/
public function __construct(IConfig $config) {
public function __construct(IConfig $config, ConfigService $configService) {
$this->config = $config;
$this->configService = $configService;
}


/**
* @return TemplateResponse
* @throws GSStatusException
*/
public function getForm() {
return new TemplateResponse('circles', 'settings.admin');
return new TemplateResponse(
'circles', 'settings.admin',
[
'gsEnabled' => $this->configService->getGSStatus(ConfigService::GS_ENABLED)
]
);
}


/**
* @return string
*/
public function getSection() {
return 'groupware';
}


/**
* @return int
*/
public function getPriority() {
return 90;
}

}

6 changes: 6 additions & 0 deletions templates/settings.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@
<label><?php p($l->t('Maximum number of members per circle')); ?></label><br />
<input type="text" id="members_limit" />
</p>
<?php
if (!$_['gsEnabled']) {
?>
<p>
<input type="checkbox" value="1" id="allow_linked_groups" class="checkbox" />
<label for="allow_linked_groups"><?php p($l->t('Allow linking of groups')); ?></label>
<em><?php p($l->t('Groups can be linked to circles.')); ?></em>
</p>
<?php
}
?>
<p>
<input type="checkbox" value="1" id="allow_federated_circles" class="checkbox"/>
<label for="allow_federated_circles"><?php p($l->t('Allow federated circles')); ?></label>
Expand Down

0 comments on commit 719e416

Please sign in to comment.