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

Fixes #5357 Do not remove tabs when applying templates to existing objects

parent 0223b172
......@@ -142,7 +142,7 @@ class baseSelector {
{
global $config;
if (!isset($this->base) || ($this->base == "")) {
if (!isset($this->base) || ($this->base == '')) {
$this->lastState = FALSE;
return FALSE;
}
......@@ -179,7 +179,6 @@ class baseSelector {
}
}
}
}
/* Skip if there's no change */
......
......@@ -194,6 +194,11 @@ class template
{
if ($targetdn !== NULL) {
$this->tabObject = objects::open($targetdn, $this->type);
foreach ($this->tabObject->by_object as $class => &$plugin) {
if ($plugin->is_account || $plugin->ignore_account) {
$this->attrs['objectClass'] = $plugin->mergeObjectClasses($this->attrs['objectClass']);
}
}
} elseif ($this->applied) {
trigger_error('Templates can’t be applied twice without calling reset before');
return;
......
......@@ -1197,6 +1197,12 @@ class simplePlugin
return !empty($this->attrs);
}
/* Used by prepare_save and template::apply */
public function mergeObjectClasses(array $oc)
{
return array_merge_unique($oc, $this->objectclasses);
}
protected function prepare_save ()
{
global $config;
......@@ -1229,7 +1235,7 @@ class simplePlugin
}
}
$this->attrs['objectClass'] = array_merge_unique($oc, $this->objectclasses);
$this->attrs['objectClass'] = $this->mergeObjectClasses($oc);
/* Fill attributes LDAP values into the attrs array */
foreach ($this->attributesInfo as $section => $sectionInfo) {
......
Markdown is supported
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