From 9e0ce4d8e8e578d8e2cf0474d2c0d2daada45a80 Mon Sep 17 00:00:00 2001 From: cdujeu Date: Mon, 5 Sep 2016 17:40:43 +0200 Subject: [PATCH] Remove notifications from GLOBAL_TYPES, add an option to disable Activity panel. --- .../access.ajxp_conf/src/RolesManager.php | 2 +- .../core.notifications/NotificationCenter.php | 36 +++++++++++-------- .../plugins/core.notifications/manifest.xml | 3 +- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/core/src/plugins/access.ajxp_conf/src/RolesManager.php b/core/src/plugins/access.ajxp_conf/src/RolesManager.php index a9f1937d3d..db3af5cb6a 100644 --- a/core/src/plugins/access.ajxp_conf/src/RolesManager.php +++ b/core/src/plugins/access.ajxp_conf/src/RolesManager.php @@ -282,7 +282,7 @@ public function rolesActions(ServerRequestInterface $requestInterface, ResponseI // Make sure it's utf8 $data["ALL"] = array_merge((isSet($data["ALL"]) ? $data["ALL"]: []), [ "PLUGINS_SCOPES" => [ - "GLOBAL_TYPES" => ["conf", "auth", "authfront", "log", "mq", "notifications", "gui", "sec"], + "GLOBAL_TYPES" => ["conf", "auth", "authfront", "log", "mq", "gui", "sec"], "GLOBAL_PLUGINS" => ["action.avatar", "action.disclaimer", "action.scheduler", "action.skeleton", "action.updater"] ], "REPOSITORIES" => $repos, diff --git a/core/src/plugins/core.notifications/NotificationCenter.php b/core/src/plugins/core.notifications/NotificationCenter.php index f9888b073b..cdbc07a488 100644 --- a/core/src/plugins/core.notifications/NotificationCenter.php +++ b/core/src/plugins/core.notifications/NotificationCenter.php @@ -81,23 +81,29 @@ public function init(ContextInterface $ctx, $options = []) */ protected function parseSpecificContributions(ContextInterface $ctx, \DOMNode &$contribNode) { - parent::parseSpecificContributions($ctx, $contribNode); - - // DISABLE STUFF - if (empty($this->pluginConf["USER_EVENTS"])) { - if($contribNode->nodeName == "actions"){ - $actionXpath=new DOMXPath($contribNode->ownerDocument); - $publicUrlNodeList = $actionXpath->query('action[@name="get_my_feed"]', $contribNode); - $publicUrlNode = $publicUrlNodeList->item(0); - $contribNode->removeChild($publicUrlNode); - }else if($contribNode->nodeName == "client_configs"){ - $actionXpath=new DOMXPath($contribNode->ownerDocument); - $children = $actionXpath->query('component_config', $contribNode); - foreach($children as $child){ - $contribNode->removeChild($child); - } + parent::parseSpecificContributions($ctx, $contribNode); + $disableWsActivity = $this->getContextualOption($ctx, "SHOW_WORKSPACES_ACTIVITY") === false; + $disableUserEvents = $this->getContextualOption($ctx, "USER_EVENTS") === false; + if(!$disableUserEvents && !$disableWsActivity){ + return; + } + // DISABLE STUFF AS NEEDED + if($contribNode->nodeName == "actions" && $disableUserEvents){ + $actionXpath=new DOMXPath($contribNode->ownerDocument); + $publicUrlNodeList = $actionXpath->query('action[@name="get_my_feed"]', $contribNode); + $publicUrlNode = $publicUrlNodeList->item(0); + $contribNode->removeChild($publicUrlNode); + }else if($contribNode->nodeName == "client_configs"){ + $actionXpath=new DOMXPath($contribNode->ownerDocument); + $children = $actionXpath->query('component_config', $contribNode); + /** @var \DOMElement $child */ + foreach($children as $child){ + if($child->getAttribute("className") !== "InfoPanel" && !$disableUserEvents){ + continue; } + $contribNode->removeChild($child); } + } } /** diff --git a/core/src/plugins/core.notifications/manifest.xml b/core/src/plugins/core.notifications/manifest.xml index 65fbe145e6..fb547e8522 100644 --- a/core/src/plugins/core.notifications/manifest.xml +++ b/core/src/plugins/core.notifications/manifest.xml @@ -17,7 +17,8 @@ - + +