Skip to content

Commit

Permalink
add disableForGroups setting - issue #154
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyMosin committed Mar 7, 2021
1 parent 20aa89b commit 1aae8fa
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/Backend/BackendUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class BackendUtils{
public const APPT_SES_TYPE_CHANGE = "4";

public const KEY_USE_DEF_EMAIL = 'useDefaultEmail';
public const KEY_NO_GROUPS = 'disableForGroups';
public const KEY_EMAIL_FIX = 'emailFixOpt';

public const KEY_ORG = 'org_info';
Expand Down
24 changes: 21 additions & 3 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,30 @@ public function __construct($AppName,
public function index() {
$t=new TemplateResponse($this->appName, 'index');

$csp=$t->getContentSecurityPolicy();
if($csp===null){
$csp=new ContentSecurityPolicy();
$noGroups=$this->c->getAppValue($this->appName,
BackendUtils::KEY_NO_GROUPS);
\OC::$server->getLogger()->error(var_export($noGroups,true));
if($noGroups!==''){
$nga = json_decode($noGroups,true);
\OC::$server->getLogger()->error(var_export($nga,true));
if ($nga !== null) {
$userGroups=\OC::$server->getGroupManager()->getUserIdGroups($this->userId);
foreach ($nga as $ng) {
if (array_key_exists($ng, $userGroups)) {
$t->setParams(['disabled'=>true]);
break;
}
}
}
}

$csp = $t->getContentSecurityPolicy();
if ($csp === null) {
$csp = new ContentSecurityPolicy();
$t->setContentSecurityPolicy($csp);
}
$csp->addAllowedFrameDomain('\'self\'');

return $t;// templates/index.php
}

Expand Down
6 changes: 6 additions & 0 deletions templates/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php
/** @var array $_ */
if(isset($_['disabled']) && $_['disabled']===true){
//occ config:app:set appointments disableForGroups --value '["group"]'
echo "<div style='width:100%; font-weight: bold; font-size:150%; opacity: .5; text-align: center;margin-top: 5em;'>This page is disabled by your sysadmin.</div>";
}else {
script('appointments', 'script');
style('appointments', 'style');
}
?>

0 comments on commit 1aae8fa

Please sign in to comment.