Commit acfd6e28 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

: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
Showing with 31 additions and 7 deletions
+31 -7
...@@ -83,13 +83,13 @@ class template ...@@ -83,13 +83,13 @@ class template
} }
$tempTabObject = objects::open($this->dn, $this->type); /* Used to know which tab is activated */ $tempTabObject = objects::open($this->dn, $this->type); /* Used to know which tab is activated */
$this->attributes = array(); $this->attributes = array();
foreach ($tempTabObject->by_object as $class => $plugin) { $tempTabObject->setActiveTabs($this->tabObject);
if ($plugin->is_account || $plugin->ignore_account) { foreach ($this->tabObject->by_object as $class => $tab) {
$this->tabObject->by_object[$class]->is_account = $plugin->is_account; if ($tab->is_account || $tab->ignore_account) {
$this->attributes[$class] = array(); $this->attributes[$class] = array();
$attrs = array_unique(array_merge($this->tabObject->by_object[$class]->getRequiredAttributes(), $this->needed)); $attrs = array_unique(array_merge($tab->getRequiredAttributes(), $this->needed));
foreach (array_keys($this->tabObject->by_object[$class]->attributesAccess) as $attr) { foreach (array_keys($tab->attributesAccess) as $attr) {
if (!$plugin->showInTemplate($attr, $this->attrs)) { if (!$tab->showInTemplate($attr, $this->attrs)) {
continue; continue;
} }
if (in_array($attr, $attrs)) { if (in_array($attr, $attrs)) {
......
...@@ -114,7 +114,6 @@ class simpleTabs ...@@ -114,7 +114,6 @@ class simpleTabs
} }
} }
/*! /*!
* \brief Reinitializes the tab classes with fresh ldap values. * \brief Reinitializes the tab classes with fresh ldap values.
* *
...@@ -138,6 +137,18 @@ class simpleTabs ...@@ -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() function resetCopyInfos()
{ {
$this->dn = 'new'; $this->dn = 'new';
......
...@@ -136,6 +136,19 @@ class ogrouptabs extends simpleTabs_noSpecial ...@@ -136,6 +136,19 @@ class ogrouptabs extends simpleTabs_noSpecial
return parent::gen_tabs($disabled); 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) function check($ignore_account = FALSE)
{ {
return parent::check(FALSE); return parent::check(FALSE);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment