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

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

Conflicts:
	include/simpleplugin/class_simplePlugin.inc
parent 4996946c
......@@ -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 */
......
......@@ -459,7 +459,7 @@ class plugin
$is_new = empty($oc);
/* Load (minimum) attributes, add missing ones */
$this->attrs['objectClass'] = array_merge_unique($oc, $this->objectclasses);
$this->attrs['objectClass'] = $this->mergeObjectClasses($oc);
/* Copy standard attributes */
foreach ($this->attributes as $val) {
......
......@@ -191,6 +191,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;
......
......@@ -657,6 +657,12 @@ class simplePlugin extends plugin
$this->post_save();
}
/* Used by prepare_save and template::apply */
public function mergeObjectClasses(array $oc)
{
return array_merge_unique($oc, $this->objectclasses);
}
protected function prepare_save ()
{
/* Call parents save to prepare $this->attrs */
......
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