From acfd6e28da98fb4ecde880b37d0e8bba20842cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be> Date: Mon, 26 Mar 2018 10:32:42 +0200 Subject: [PATCH] :ambulance: fix(templates) Fix ogroup special tab support in templates This should allow to activate group-specific tabs in template as long as there is one member of the corresponding type in the member list. issue #5798 --- include/class_template.inc | 12 ++++++------ include/simpleplugin/class_simpleTabs.inc | 13 ++++++++++++- plugins/admin/groups/tabs_ogroups.inc | 13 +++++++++++++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/include/class_template.inc b/include/class_template.inc index 12e49848a..0aaa6b6d3 100644 --- a/include/class_template.inc +++ b/include/class_template.inc @@ -83,13 +83,13 @@ class template } $tempTabObject = objects::open($this->dn, $this->type); /* Used to know which tab is activated */ $this->attributes = array(); - foreach ($tempTabObject->by_object as $class => $plugin) { - if ($plugin->is_account || $plugin->ignore_account) { - $this->tabObject->by_object[$class]->is_account = $plugin->is_account; + $tempTabObject->setActiveTabs($this->tabObject); + foreach ($this->tabObject->by_object as $class => $tab) { + if ($tab->is_account || $tab->ignore_account) { $this->attributes[$class] = array(); - $attrs = array_unique(array_merge($this->tabObject->by_object[$class]->getRequiredAttributes(), $this->needed)); - foreach (array_keys($this->tabObject->by_object[$class]->attributesAccess) as $attr) { - if (!$plugin->showInTemplate($attr, $this->attrs)) { + $attrs = array_unique(array_merge($tab->getRequiredAttributes(), $this->needed)); + foreach (array_keys($tab->attributesAccess) as $attr) { + if (!$tab->showInTemplate($attr, $this->attrs)) { continue; } if (in_array($attr, $attrs)) { diff --git a/include/simpleplugin/class_simpleTabs.inc b/include/simpleplugin/class_simpleTabs.inc index 22adc9f82..5f828a396 100644 --- a/include/simpleplugin/class_simpleTabs.inc +++ b/include/simpleplugin/class_simpleTabs.inc @@ -114,7 +114,6 @@ class simpleTabs } } - /*! * \brief Reinitializes the tab classes with fresh ldap values. * @@ -138,6 +137,18 @@ class simpleTabs } } + /*! + * \brief Sets the active tabs from this instance to an other one. Used by templates + */ + function setActiveTabs(&$tabObject) + { + foreach ($this->by_object as $class => $plugin) { + if ($plugin->is_account || $plugin->ignore_account) { + $tabObject->by_object[$class]->is_account = $plugin->is_account; + } + } + } + function resetCopyInfos() { $this->dn = 'new'; diff --git a/plugins/admin/groups/tabs_ogroups.inc b/plugins/admin/groups/tabs_ogroups.inc index b41aa85ce..64e63ce12 100644 --- a/plugins/admin/groups/tabs_ogroups.inc +++ b/plugins/admin/groups/tabs_ogroups.inc @@ -136,6 +136,19 @@ class ogrouptabs extends simpleTabs_noSpecial return parent::gen_tabs($disabled); } + /*! + * \brief Sets the active tabs from this instance to an other one. Used by templates + */ + function setActiveTabs(&$tabObject) + { + $tabObject->loadtabs($this->groupObjects); + foreach ($this->by_object as $class => $plugin) { + if ($plugin->is_account || $plugin->ignore_account) { + $tabObject->by_object[$class]->is_account = $plugin->is_account; + } + } + } + function check($ignore_account = FALSE) { return parent::check(FALSE); -- GitLab