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

Showing with 13 additions and 3 deletions
+13 -3
...@@ -142,7 +142,7 @@ class baseSelector { ...@@ -142,7 +142,7 @@ class baseSelector {
{ {
global $config; global $config;
if (!isset($this->base) || ($this->base == "")) { if (!isset($this->base) || ($this->base == '')) {
$this->lastState = FALSE; $this->lastState = FALSE;
return FALSE; return FALSE;
} }
...@@ -179,7 +179,6 @@ class baseSelector { ...@@ -179,7 +179,6 @@ class baseSelector {
} }
} }
} }
} }
/* Skip if there's no change */ /* Skip if there's no change */
......
...@@ -194,6 +194,11 @@ class template ...@@ -194,6 +194,11 @@ class template
{ {
if ($targetdn !== NULL) { if ($targetdn !== NULL) {
$this->tabObject = objects::open($targetdn, $this->type); $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) { } elseif ($this->applied) {
trigger_error('Templates can’t be applied twice without calling reset before'); trigger_error('Templates can’t be applied twice without calling reset before');
return; return;
......
...@@ -1197,6 +1197,12 @@ class simplePlugin ...@@ -1197,6 +1197,12 @@ class simplePlugin
return !empty($this->attrs); 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 () protected function prepare_save ()
{ {
global $config; global $config;
...@@ -1229,7 +1235,7 @@ class simplePlugin ...@@ -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 */ /* Fill attributes LDAP values into the attrs array */
foreach ($this->attributesInfo as $section => $sectionInfo) { foreach ($this->attributesInfo as $section => $sectionInfo) {
......
  • bmortier @bmortier

    mentioned in issue #1707

    By Jonathan Swaelens on 2017-09-02T15:35:24 (imported from GitLab)

    ·

    mentioned in issue #1707

    By Jonathan Swaelens on 2017-09-02T15:35:24 (imported from GitLab)

    Toggle commit list
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