From c1cd284c67d237351e5adb04c860fa8eccc07500 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come.bernigaud@opensides.be>
Date: Mon, 9 May 2016 07:06:48 +0200
Subject: [PATCH] Fixes #2657 First pass of constructor reorganization

mainTab is now dynamic.
parent is now given in the constructor.
---
 include/class_CopyPasteHandler.inc            | 13 +--------
 include/class_SnapshotDialogs.inc             |  4 +--
 include/class_management.inc                  |  4 +--
 include/class_plugin.inc                      |  6 ++---
 .../class_password-methods.inc                |  2 +-
 include/simpleplugin/class_multiPlugin.inc    | 11 +++-----
 .../simpleplugin/class_simpleManagement.inc   |  4 +--
 include/simpleplugin/class_simplePlugin.inc   | 27 ++++++++++++-------
 include/simpleplugin/class_simpleService.inc  |  6 ++---
 include/simpleplugin/class_simpleTabs.inc     | 14 +++++-----
 plugins/addons/dashboard/class_dashBoard.inc  |  4 +--
 .../addons/dashboard/class_dashBoardUsers.inc |  4 +--
 plugins/admin/acl/class_aclAssignment.inc     | 12 ++++-----
 plugins/admin/aclrole/class_aclRole.inc       |  8 ------
 .../admin/departments/class_department.inc    |  5 ++--
 plugins/admin/groups/class_group.inc          |  5 ++--
 .../admin/groups/class_groupManagement.inc    |  2 +-
 plugins/admin/groups/class_ogroup.inc         |  5 ++--
 plugins/admin/groups/class_roleGeneric.inc    | 11 --------
 plugins/admin/groups/tabs_ogroups.inc         | 15 +++++------
 plugins/admin/users/class_userManagement.inc  |  2 +-
 plugins/config/class_configInLdap.inc         |  5 ++--
 plugins/config/class_mainPluginsConfig.inc    |  5 ----
 plugins/config/class_recoveryConfig.inc       |  4 +--
 plugins/config/main.inc                       |  2 +-
 .../generic/references/class_reference.inc    |  4 +--
 plugins/personal/generic/class_user.inc       |  5 ++--
 plugins/personal/posix/class_posixAccount.inc |  4 +--
 plugins/personal/roles/class_userRoles.inc    |  4 +--
 29 files changed, 77 insertions(+), 120 deletions(-)

diff --git a/include/class_CopyPasteHandler.inc b/include/class_CopyPasteHandler.inc
index fb0fb71c4..914e88f68 100644
--- a/include/class_CopyPasteHandler.inc
+++ b/include/class_CopyPasteHandler.inc
@@ -167,18 +167,7 @@ class CopyPasteHandler
       return array();
     }
 
-    if (isset($entry['type'])) {
-      $entry['object'] = objects::open($entry['dn'], $entry['type']);
-    } else {
-      trigger_error('Call to deprecated tabs constructor');
-      // old way
-      $tab_c  = $entry['tab_class'];
-      $tab_o  = $entry['tab_object'];
-      $tab_a  = $entry['tab_acl_category'];
-
-      // Deprecated
-      $entry['object'] = new $tab_c(NULL, $config->data['TABS'][$tab_o], $entry['dn'], $tab_a);
-    }
+    $entry['object'] = objects::open($entry['dn'], $entry['type']);
 
     $entry['object']->set_acl_base($base);
     if ($entry['parent'] !== NULL) {
diff --git a/include/class_SnapshotDialogs.inc b/include/class_SnapshotDialogs.inc
index 47e142f74..d21a770a3 100644
--- a/include/class_SnapshotDialogs.inc
+++ b/include/class_SnapshotDialogs.inc
@@ -46,7 +46,7 @@ class SnapshotCreateDialog extends simplePlugin
     );
   }
 
-  function __construct ($unused, $dn, $parent, $aclCategory)
+  function __construct ($dn, $parent, $aclCategory)
   {
     parent::__construct();
     $this->attributesAccess['description']->setInLdap(FALSE);
@@ -191,7 +191,7 @@ class SnapshotRestoreDialog extends simplePlugin
     );
   }
 
-  function __construct ($unused, $dn, $parent, $global, $aclCategory)
+  function __construct ($dn, $parent, $global, $aclCategory)
   {
     parent::__construct();
     $this->object_dn    = $dn;
diff --git a/include/class_management.inc b/include/class_management.inc
index 7d10d0766..db34df910 100644
--- a/include/class_management.inc
+++ b/include/class_management.inc
@@ -483,7 +483,7 @@ class management
       }
       $aclCategory = $this->aclCategory;
       if ($this->ui->allow_snapshot_create($this->dn, $aclCategory)) {
-        $this->dialogObject = new SnapshotCreateDialog(NULL, $this->dn, $this, $aclCategory);
+        $this->dialogObject = new SnapshotCreateDialog($this->dn, $this, $aclCategory);
         $this->dialogObject->set_acl_base($this->dn);
       } else {
         msg_dialog::display(_('Permission'), sprintf(_('You are not allowed to create a snapshot for %s.'), $this->dn),
@@ -566,7 +566,7 @@ class management
     if ($this->ui->allow_snapshot_restore($this->dn, $aclCategory)) {
       @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->dn, 'Snaptshot restoring initiated!');
       $this->snapHandler->setSnapshotBases($bases);
-      $this->dialogObject = new SnapshotRestoreDialog(NULL, $this->dn, $this, !count($target), $aclCategory);
+      $this->dialogObject = new SnapshotRestoreDialog($this->dn, $this, !count($target), $aclCategory);
       $this->dialogObject->set_acl_base($this->dn);
     } else {
       msg_dialog::display(_('Permission'), sprintf(_('You are not allowed to restore a snapshot for %s.'), $this->dn),
diff --git a/include/class_plugin.inc b/include/class_plugin.inc
index 91e874634..d782eacfe 100644
--- a/include/class_plugin.inc
+++ b/include/class_plugin.inc
@@ -35,7 +35,7 @@ class plugin
    *
    * \sa tab
    */
-  var $parent = NULL;
+  public $parent = NULL;
 
   /*!
     \brief Mark plugin as account
@@ -116,10 +116,10 @@ class plugin
    *
    * \sa plugin()
    */
-  function __construct ($unused, $dn = NULL, $object = NULL)
+  function __construct ($dn = NULL, $object = NULL)
   {
     global $config;
-    /* Configuration is fine, allways */
+
     $this->dn     = $dn;
 
     // Ensure that we've a valid acl_category set.
diff --git a/include/password-methods/class_password-methods.inc b/include/password-methods/class_password-methods.inc
index 1531a89be..fc3e484b2 100644
--- a/include/password-methods/class_password-methods.inc
+++ b/include/password-methods/class_password-methods.inc
@@ -173,7 +173,7 @@ class passwordMethod
       lock_ssh_account($mode, $attrs, $modify);
 
       // (Un)lock the account by modifying the password hash.
-      $pwdClass = new user(NULL, $dn);
+      $pwdClass = new user($dn);
       $pwdClass->callHook('PRE'.$mode, array(), $ret);
 
       if ($mode == 'LOCK') {
diff --git a/include/simpleplugin/class_multiPlugin.inc b/include/simpleplugin/class_multiPlugin.inc
index db93dbd18..d33427545 100644
--- a/include/simpleplugin/class_multiPlugin.inc
+++ b/include/simpleplugin/class_multiPlugin.inc
@@ -37,10 +37,10 @@ class multiPlugin extends simplePlugin
     return array();
   }
 
-  function __construct ($unused = NULL, $dn = NULL, $parent = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL)
   {
     global $config;
-    parent::__construct($unused, $dn, $parent);
+    parent::__construct($dn, $object, $parent, FALSE);
 
     $plInfos = pluglist::pluginInfos(get_class($this));
 
@@ -50,7 +50,7 @@ class multiPlugin extends simplePlugin
         continue;
       }
       $name = $plug['CLASS'];
-      $this->plugin[$name] = new $name($unused, $dn, $parent);
+      $this->plugin[$name] = new $name($dn, $object, $parent);
 
       /* Acl base && category configuration,
           these settings will be overloaded in main.inc,
@@ -80,11 +80,6 @@ class multiPlugin extends simplePlugin
         $display .= back_to_main();
         return $display;
       }
-    } else {
-      foreach ($this->plugin as &$plug) {
-        $plug->parent = $this->parent;
-      }
-      unset($plug);
     }
 
     /* Execude  objects */
diff --git a/include/simpleplugin/class_simpleManagement.inc b/include/simpleplugin/class_simpleManagement.inc
index 8bae70790..630a3ce94 100644
--- a/include/simpleplugin/class_simpleManagement.inc
+++ b/include/simpleplugin/class_simpleManagement.inc
@@ -745,7 +745,7 @@ class simpleManagement extends management
       }
       $aclCategory = $config->data['OBJECTS'][$this->getType($this->dn)]['aclCategory'];
       if ($this->ui->allow_snapshot_create($this->dn, $aclCategory)) {
-        $this->dialogObject = new SnapshotCreateDialog(NULL, $this->dn, $this, $aclCategory);
+        $this->dialogObject = new SnapshotCreateDialog($this->dn, $this, $aclCategory);
         $this->dialogObject->set_acl_base($this->dn);
       } else {
         msg_dialog::display(_('Permission'), sprintf(_('You are not allowed to create a snapshot for %s.'), $this->dn),
@@ -796,7 +796,7 @@ class simpleManagement extends management
     if ($this->ui->allow_snapshot_restore($this->dn, $aclCategory)) {
       @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->dn, 'Snaptshot restoring initiated!');
       $this->snapHandler->setSnapshotBases($bases);
-      $this->dialogObject = new SnapshotRestoreDialog(NULL, $this->dn, $this, !count($target), $aclCategory);
+      $this->dialogObject = new SnapshotRestoreDialog($this->dn, $this, !count($target), $aclCategory);
       $this->dialogObject->set_acl_base($this->dn);
     } else {
       msg_dialog::display(_('Permission'), sprintf(_('You are not allowed to restore a snapshot for %s.'), $this->dn),
diff --git a/include/simpleplugin/class_simplePlugin.inc b/include/simpleplugin/class_simplePlugin.inc
index 02f6f0c2e..9f7a2fd5a 100644
--- a/include/simpleplugin/class_simplePlugin.inc
+++ b/include/simpleplugin/class_simplePlugin.inc
@@ -78,9 +78,13 @@ class simplePlugin extends plugin
    *  \param array $attributesInfo An attributesInfo array, if NULL, getAttributesInfo will be used.
    *
    */
-  function __construct ($unused = NULL, $dn = NULL, $object = NULL, $attributesInfo = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE, $attributesInfo = NULL)
   {
     global $config;
+
+    $this->parent   = $parent;
+    $this->mainTab  = $mainTab;
+
     if ($attributesInfo === NULL) {
       $attributesInfo = $this->getAttributesInfo();
     }
@@ -115,7 +119,7 @@ class simplePlugin extends plugin
     }
 
     // We call plugin constructor
-    parent::__construct($unused, $dn, $object);
+    parent::__construct($dn, $object);
 
     $this->setTemplate($this->is_template);
 
@@ -476,7 +480,7 @@ class simplePlugin extends plugin
     $class = get_class($this);
     $attrsWrapper = new stdClass();
     $attrsWrapper->attrs = $this->group_attrs;
-    $group = new $class(NULL, $this->group_attrs['dn'], $attrsWrapper);
+    $group = new $class($this->group_attrs['dn'], $attrsWrapper, $this->parent, $this->mainTab);
     $smarty = get_smarty();
 
     $group->renderAttributes(TRUE);
@@ -747,7 +751,7 @@ class simplePlugin extends plugin
    *
    *  \param string $entry_dn the dn of the object to show/edit
    *
-   *  \param string $tabs the tab class to use (or TRUE to use tabs, FALSE to show directly the plugin class)
+   *  \param string $tabs TRUE to use tabs, FALSE to show directly the plugin class
    *
    *  \param boolean $edit_mode wether or not this plugin can be edited
    *
@@ -757,14 +761,11 @@ class simplePlugin extends plugin
   static function mainInc ($classname, $entry_dn, $tabs = FALSE, $edit_mode = TRUE, $objectType = FALSE)
   {
     global $remove_lock, $cleanup, $display, $config, $plug, $ui;
-    if ($tabs === TRUE) {
-      $tabs = 'tabs'; // Default tab class
-    }
 
     $plInfo     = pluglist::pluginInfos($classname);
     $plIcon     = (isset($plInfo['plIcon'])?$plInfo['plIcon']:'plugin.png');
     $plHeadline = $plInfo['plTitle'];
-    if (($tabs !== FALSE) && ($objectType === FALSE)) {
+    if ($objectType === FALSE) {
       $key = key($plInfo['plObjectType']);
       if (is_numeric($key)) {
         $key = $plInfo['plObjectType'][$key];
@@ -779,6 +780,12 @@ class simplePlugin extends plugin
       $plCategory = $key;
     }
 
+    $mainTab = FALSE;
+    if (!$tabs) {
+      $infos    = objects::infos($objectType);
+      $mainTab  = (reset($config->data['TABS'][$infos['tabGroup']])['CLASS'] == $classname);
+    }
+
     $lock_msg = "";
     if ($edit_mode) {
       /* Remove locks created by this plugin */
@@ -803,7 +810,7 @@ class simplePlugin extends plugin
       /* Create account object on demand */
       if (!session::is_set($classname) || (isset($_GET['reset']) && $_GET['reset'] == 1)) {
         if ($tabs) {
-          $account = new $tabs($objectType, $entry_dn);
+          $account = objects::open($entry_dn, $objectType);
           if ($edit_mode) {
             foreach ($account->by_object as &$obj) {
               $obj->setNeedEditMode(TRUE);
@@ -811,7 +818,7 @@ class simplePlugin extends plugin
             unset($obj);
           }
         } else {
-          $account = new $classname(NULL, $entry_dn);
+          $account = new $classname($entry_dn, NULL, NULL, $mainTab);
           $account->set_acl_category($plCategory);
           if ($edit_mode) {
             $account->setNeedEditMode(TRUE);
diff --git a/include/simpleplugin/class_simpleService.inc b/include/simpleplugin/class_simpleService.inc
index 044325e0f..c27bfb6c5 100644
--- a/include/simpleplugin/class_simpleService.inc
+++ b/include/simpleplugin/class_simpleService.inc
@@ -40,12 +40,12 @@ class simpleService extends simplePlugin {
    *  \param array $attributesInfo An attributesInfo array, if NULL, getAttributesInfo will be used.
    *
    */
-  function __construct($unused, $dn, $object = NULL, $attributesInfo = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $attributesInfo = NULL)
   {
-    parent::__construct($unused, $dn, $object, $attributesInfo);
+    /* $object is the instance of serverService in this case, we set it as parent */
+    parent::__construct($dn, $object, $object, FALSE, $attributesInfo);
     $plInfos = pluglist::pluginInfos(get_class($this));
     $this->DisplayName  = $plInfos['plShortName'];
-    $this->parent       = $object; /* $object is the instance of serverService in this case */
   }
 
   /*! \brief This function display the service and return the html code
diff --git a/include/simpleplugin/class_simpleTabs.inc b/include/simpleplugin/class_simpleTabs.inc
index 7cde64cbc..fab7190d4 100644
--- a/include/simpleplugin/class_simpleTabs.inc
+++ b/include/simpleplugin/class_simpleTabs.inc
@@ -70,6 +70,7 @@ class simpleTabs
       }
       $this->objectType = $type;
     } else {
+      trigger_error('deprecated call to old tabclass constructor');
       /* Deprecated, used by old management classes */
       //$config_object  = func_get_arg(0); // ignored
       $data           = func_get_arg(1);
@@ -100,15 +101,14 @@ class simpleTabs
       $this->by_name[$tab['CLASS']] = $tab['NAME'];
 
       if ($baseobject === NULL) {
-        $baseobject = new $tab['CLASS'](NULL, $this->dn, $attrs_object);
+        $baseobject = new $tab['CLASS']($this->dn, $attrs_object, $this, TRUE);
         $this->by_object[$tab['CLASS']] = $baseobject;
         $this->baseclass                = $tab['CLASS'];
       } else {
-        $this->by_object[$tab['CLASS']] = new $tab['CLASS'](NULL, $this->dn, $baseobject);
+        $this->by_object[$tab['CLASS']] = new $tab['CLASS']($this->dn, $baseobject, $this, FALSE);
       }
 
       $this->read_only |= $this->by_object[$tab['CLASS']]->read_only;
-      $this->by_object[$tab['CLASS']]->parent = &$this;
       $this->by_object[$tab['CLASS']]->set_acl_category($this->acl_category);
     }
     unset($tab);
@@ -145,12 +145,11 @@ class simpleTabs
         continue;
       }
       if ($baseobject === NULL) {
-        $baseobject = new $class(NULL, $this->dn);
+        $baseobject = new $class($this->dn, NULL, $this, TRUE);
         $this->by_object[$name] = $baseobject;
       } else {
-        $this->by_object[$name] = new $class(NULL, $this->dn, $baseobject);
+        $this->by_object[$name] = new $class($this->dn, $baseobject, $this, FALSE);
       }
-      $this->by_object[$name]->parent = &$this;
       $this->by_object[$name]->set_acl_category($this->acl_category);
     }
   }
@@ -459,8 +458,7 @@ class simpleTabs
       }
 
       $this->by_name[$tab['CLASS']] = $tab['NAME'];
-      $this->by_object[$tab['CLASS']] = new $tab['CLASS'](NULL, $this->dn, $baseobject);
-      $this->by_object[$tab['CLASS']]->parent = &$this;
+      $this->by_object[$tab['CLASS']] = new $tab['CLASS']($this->dn, $baseobject, $this, FALSE);
       $this->by_object[$tab['CLASS']]->set_acl_category($this->acl_category);
     }
   }
diff --git a/plugins/addons/dashboard/class_dashBoard.inc b/plugins/addons/dashboard/class_dashBoard.inc
index 28e4b6e2d..2aa0e7300 100644
--- a/plugins/addons/dashboard/class_dashBoard.inc
+++ b/plugins/addons/dashboard/class_dashBoard.inc
@@ -52,9 +52,9 @@ class dashboard extends simplePlugin
     );
   }
 
-  function __construct($unused, $dn = NULL, $object = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
   {
-    parent::__construct($unused, $dn, $object);
+    parent::__construct($dn, $object, $parent, $mainTab);
 
     $this->stats = $this->overview_stats();
   }
diff --git a/plugins/addons/dashboard/class_dashBoardUsers.inc b/plugins/addons/dashboard/class_dashBoardUsers.inc
index c8e6c2b2f..8efebea97 100644
--- a/plugins/addons/dashboard/class_dashBoardUsers.inc
+++ b/plugins/addons/dashboard/class_dashBoardUsers.inc
@@ -53,9 +53,9 @@ class dashboardUsers extends simplePlugin
     );
   }
 
-  function __construct($unused, $dn = NULL, $object = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
   {
-    parent::__construct($unused, $dn, $object);
+    parent::__construct($dn, $object, $parent, $mainTab);
 
     $this->users_stats  = $this->computeUsersStats();
     $this->groups_stats = $this->computeGroupsStats();
diff --git a/plugins/admin/acl/class_aclAssignment.inc b/plugins/admin/acl/class_aclAssignment.inc
index 033c27ada..36119d9c4 100644
--- a/plugins/admin/acl/class_aclAssignment.inc
+++ b/plugins/admin/acl/class_aclAssignment.inc
@@ -20,8 +20,6 @@
 
 class aclAssignmentDialogWindow extends simplePlugin
 {
-  protected $mainTab = TRUE;
-
   static function plInfo()
   {
     return array(
@@ -63,9 +61,9 @@ class aclAssignmentDialogWindow extends simplePlugin
     );
   }
 
-  function __construct ($unused, $value, $isContainer = FALSE)
+  function __construct ($value, $isContainer = FALSE)
   {
-    parent::__construct($unused);
+    parent::__construct(NULL, NULL, NULL, TRUE);
     if ($isContainer) {
       $this->attributesAccess['aclMode']->setDefaultValue('subtree');
     } else {
@@ -144,7 +142,7 @@ class ACLsAssignmentDialog extends GenericDialog
       $isContainer = TRUE;
     }
     $this->attribute        = $attribute;
-    $this->dialog           = new $this->dialogClass(NULL, $acl, $isContainer);
+    $this->dialog           = new $this->dialogClass($acl, $isContainer);
     $this->dialog->set_acl_base($simplePlugin->acl_base);
     $this->initialAclValue  = $acl;
   }
@@ -292,9 +290,9 @@ class aclAssignment extends simplePlugin
     );
   }
 
-  function __construct ($unused, $dn = NULL, $object = NULL, $attributesInfo = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
   {
-    parent::__construct ($unused, $dn, $object);
+    parent::__construct ($dn, $object, $parent, $mainTab);
     $this->attributesInfo['main']['name'] = sprintf(_('Assignments on object or subtree %s'), $this->dn);
   }
 
diff --git a/plugins/admin/aclrole/class_aclRole.inc b/plugins/admin/aclrole/class_aclRole.inc
index eeaa46d86..e5e8bafb7 100644
--- a/plugins/admin/aclrole/class_aclRole.inc
+++ b/plugins/admin/aclrole/class_aclRole.inc
@@ -70,7 +70,6 @@ class ACLsAttribute extends DialogOrderedArrayAttribute
 class aclRole extends simplePlugin
 {
   var $objectclasses  = array('top','gosaRole');
-  var $mainTab        = TRUE;
 
   static function plInfo()
   {
@@ -119,12 +118,5 @@ class aclRole extends simplePlugin
       ),
     );
   }
-
-  function __construct ($unused, $dn = NULL, $object = NULL)
-  {
-    parent::__construct($unused, $dn, $object);
-
-    $this->attributesAccess['cn']->setUnique(TRUE);
-  }
 }
 ?>
diff --git a/plugins/admin/departments/class_department.inc b/plugins/admin/departments/class_department.inc
index e391d218c..2966e4641 100644
--- a/plugins/admin/departments/class_department.inc
+++ b/plugins/admin/departments/class_department.inc
@@ -26,7 +26,6 @@ class department extends simplePlugin
   /* Do not append the structural object classes here, they are added dynamically in the constructor */
   var $objectclasses  = array("top", "gosaDepartment");
   var $structuralOC   = array("organizationalUnit");
-  var $mainTab        = TRUE;
 
   static function plInfo()
   {
@@ -120,7 +119,7 @@ class department extends simplePlugin
     return $attributesInfo;
   }
 
-  function __construct ($unused, $dn = NULL, $object = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
   {
     global $config;
     /* Add the default structural object class if this is a new entry */
@@ -143,7 +142,7 @@ class department extends simplePlugin
     }
     $this->objectclasses = array_unique($this->objectclasses);
 
-    parent::__construct($unused, $dn, $object);
+    parent::__construct($dn, $object, $parent, $mainTab);
 
     $categoriesList = $config->get_cfg_value('DepartmentCategories', array());
 
diff --git a/plugins/admin/groups/class_group.inc b/plugins/admin/groups/class_group.inc
index 0ee216b39..92e122ee5 100644
--- a/plugins/admin/groups/class_group.inc
+++ b/plugins/admin/groups/class_group.inc
@@ -22,7 +22,6 @@
 
 class group extends simplePlugin
 {
-  var $mainTab          = TRUE;
   var $objectclasses    = array('posixGroup');
 
   static function plInfo()
@@ -107,9 +106,9 @@ class group extends simplePlugin
     );
   }
 
-  function __construct ($unused, $dn = NULL, $object = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
   {
-    parent::__construct($unused, $dn, $object);
+    parent::__construct($dn, $object, $parent, $mainTab);
 
     $this->attributesAccess['trustMode']->setInLdap(FALSE);
     $this->attributesAccess['trustMode']->setManagedAttributes(
diff --git a/plugins/admin/groups/class_groupManagement.inc b/plugins/admin/groups/class_groupManagement.inc
index db31ef92b..fc08a87d2 100644
--- a/plugins/admin/groups/class_groupManagement.inc
+++ b/plugins/admin/groups/class_groupManagement.inc
@@ -79,7 +79,7 @@ class groupManagement extends simpleManagement
           if (class_available($plug['CLASS'])) {
             $name = $plug['CLASS'];
 
-            $grouptabs[$name] = new $name(NULL, $dn);
+            $grouptabs[$name] = new $name($dn);
           }
         }
       }
diff --git a/plugins/admin/groups/class_ogroup.inc b/plugins/admin/groups/class_ogroup.inc
index 11323322e..c6dc0dd5b 100644
--- a/plugins/admin/groups/class_ogroup.inc
+++ b/plugins/admin/groups/class_ogroup.inc
@@ -130,7 +130,6 @@ class ObjectSelectDialog extends GenericSelectDialog
 
 class ogroup extends simplePlugin
 {
-  var $mainTab        = TRUE;
   var $objectclasses  = array('groupOfNames', 'gosaGroupOfNames');
 
   var $used_workstations = array();
@@ -229,10 +228,10 @@ class ogroup extends simplePlugin
     );
   }
 
-  function __construct ($unused, $dn = NULL, $object = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
   {
     global $config;
-    parent::__construct($unused, $dn, $object);
+    parent::__construct($dn, $object, $parent, $mainTab);
 
     $this->attributesAccess['trustMode']->setInLdap(FALSE);
     $this->attributesAccess['trustMode']->setManagedAttributes(
diff --git a/plugins/admin/groups/class_roleGeneric.inc b/plugins/admin/groups/class_roleGeneric.inc
index ebf8189a0..14e671420 100644
--- a/plugins/admin/groups/class_roleGeneric.inc
+++ b/plugins/admin/groups/class_roleGeneric.inc
@@ -47,8 +47,6 @@ class RoleMembersAttribute extends UsersAttribute
 
 class roleGeneric extends simplePlugin
 {
-  var $mainTab = TRUE;
-
   var $objectclasses = array('organizationalRole');
 
   static function plInfo()
@@ -109,14 +107,5 @@ class roleGeneric extends simplePlugin
       )
     );
   }
-
-  /*!
-   * \brief Constructor
-   */
-  function __construct($unused, $dn = NULL, $object = NULL)
-  {
-    parent::__construct($unused, $dn, $object);
-    $this->attributesAccess['cn']->setUnique(TRUE);
-  }
 }
 ?>
diff --git a/plugins/admin/groups/tabs_ogroups.inc b/plugins/admin/groups/tabs_ogroups.inc
index 91481464f..5f658be1c 100644
--- a/plugins/admin/groups/tabs_ogroups.inc
+++ b/plugins/admin/groups/tabs_ogroups.inc
@@ -107,16 +107,15 @@ class ogrouptabs extends simpleTabs_noSpecial
 
   function addTab ($class)
   {
-    @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $class, "Adding tab ");
+    @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $class, 'Adding tab ');
     $plInfos = pluglist::pluginInfos($class);
-    $this->by_name["$class"]            = $plInfos['plShortName'];
-    if (isset($this->removed_tabs["$class"])) {
-      $this->by_object["$class"] = $this->removed_tabs["$class"];
-      unset($this->removed_tabs["$class"]);
+    $this->by_name[$class]            = $plInfos['plShortName'];
+    if (isset($this->removed_tabs[$class])) {
+      $this->by_object[$class] = $this->removed_tabs[$class];
+      unset($this->removed_tabs[$class]);
     } else {
-      $this->by_object["$class"]          = new $class(NULL, $this->dn, $this->getBaseObject());
-      $this->by_object["$class"]->parent  = &$this;
-      $this->by_object["$class"]->set_acl_category($this->acl_category);
+      $this->by_object[$class] = new $class($this->dn, $this->getBaseObject(), $this, FALSE);
+      $this->by_object[$class]->set_acl_category($this->acl_category);
     }
   }
 
diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc
index 2b7952677..a348ee8e4 100644
--- a/plugins/admin/users/class_userManagement.inc
+++ b/plugins/admin/users/class_userManagement.inc
@@ -225,7 +225,7 @@ class userManagement extends simpleManagement
         if (class_available($plug['CLASS'])) {
           $name = $plug['CLASS'];
 
-          $usertabs[$name] = new $name($config, $dn);
+          $usertabs[$name] = new $name($dn);
         }
       }
     }
diff --git a/plugins/config/class_configInLdap.inc b/plugins/config/class_configInLdap.inc
index f2c45f023..9a3fffede 100644
--- a/plugins/config/class_configInLdap.inc
+++ b/plugins/config/class_configInLdap.inc
@@ -49,7 +49,6 @@ class DebugLevelAttribute extends SetAttribute
 class configInLdap extends simplePlugin
 {
   var $objectclasses  = array("fusionDirectoryConf");
-  var $mainTab        = TRUE;
 
   static function plInfo()
   {
@@ -465,7 +464,7 @@ class configInLdap extends simplePlugin
     );
   }
 
-  function __construct($unused, $dn = NULL, $object = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE, $attributesInfo = NULL)
   {
     global $config;
     $attributesInfo = self::getAttributesInfo();
@@ -481,7 +480,7 @@ class configInLdap extends simplePlugin
     $methods = $methods['name'];
     $attributesInfo['password']['attrs'][0]->setChoices($methods);
 
-    parent::__construct($unused, $dn, $object, $attributesInfo);
+    parent::__construct($dn, $object, $parent, $mainTab, $attributesInfo);
 
     $this->fusionConfigMd5 = md5_file(CACHE_DIR."/".CLASS_CACHE);
 
diff --git a/plugins/config/class_mainPluginsConfig.inc b/plugins/config/class_mainPluginsConfig.inc
index 4234effd3..9ad54bd5b 100644
--- a/plugins/config/class_mainPluginsConfig.inc
+++ b/plugins/config/class_mainPluginsConfig.inc
@@ -60,10 +60,5 @@ class mainPluginsConfig extends simplePlugin
       ),
     );
   }
-
-  function __construct($unused, $dn = NULL, $object = NULL)
-  {
-    parent::__construct($unused, $dn, $object);
-  }
 }
 ?>
diff --git a/plugins/config/class_recoveryConfig.inc b/plugins/config/class_recoveryConfig.inc
index 319c30288..6b0782e6e 100644
--- a/plugins/config/class_recoveryConfig.inc
+++ b/plugins/config/class_recoveryConfig.inc
@@ -117,7 +117,7 @@ class recoveryConfig extends simplePlugin
     );
   }
 
-  function __construct($unused, $dn = NULL, $object = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
   {
     global $config;
     // Check if token branch is here
@@ -134,7 +134,7 @@ class recoveryConfig extends simplePlugin
       fusiondirectory_log("Created token branch ".$tokenBranch);
     }
 
-    parent::__construct($unused, $dn, $object);
+    parent::__construct($dn, $object, $parent, $mainTab);
 
     $this->attributesAccess['fdPasswordRecoveryActivated']->setManagedAttributes(
       array(
diff --git a/plugins/config/main.inc b/plugins/config/main.inc
index 224117a82..e08f0ab89 100644
--- a/plugins/config/main.inc
+++ b/plugins/config/main.inc
@@ -18,5 +18,5 @@
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 */
 
-simplePlugin::mainInc('configInLdap', CONFIGRDN.$config->current['BASE'], 'tabs_configInLdap');
+simplePlugin::mainInc('configInLdap', CONFIGRDN.$config->current['BASE'], TRUE);
 ?>
diff --git a/plugins/generic/references/class_reference.inc b/plugins/generic/references/class_reference.inc
index 0a5ef4ad7..a9ca0aa78 100644
--- a/plugins/generic/references/class_reference.inc
+++ b/plugins/generic/references/class_reference.inc
@@ -51,9 +51,9 @@ class reference extends simplePlugin
     );
   }
 
-  function __construct($unused, $dn = NULL, $object = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
   {
-    parent::__construct($unused, $dn, $object);
+    parent::__construct($dn, $object, $parent, $mainTab);
 
     $this->refs = NULL;
   }
diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc
index b4e189990..2c93bfc59 100644
--- a/plugins/personal/generic/class_user.inc
+++ b/plugins/personal/generic/class_user.inc
@@ -267,7 +267,6 @@ class PostalAddressAttribute extends TextAreaAttribute
 class user extends simplePlugin
 {
   var $objectclasses  = array('inetOrgPerson','organizationalPerson','person');
-  var $mainTab        = TRUE;
 
   private $was_locked;
 
@@ -446,9 +445,9 @@ class user extends simplePlugin
     );
   }
 
-  function __construct ($unused, $dn = NULL, $object = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
   {
-    parent::__construct($unused, $dn, $object);
+    parent::__construct($dn, $object, $parent, $mainTab);
 
     $this->attributesAccess['uid']->setUnique('whole');
     $this->attributesAccess['uid']->setDisabled($this->initially_was_account && !$this->is_template);
diff --git a/plugins/personal/posix/class_posixAccount.inc b/plugins/personal/posix/class_posixAccount.inc
index 73cbff2cf..0f3521611 100644
--- a/plugins/personal/posix/class_posixAccount.inc
+++ b/plugins/personal/posix/class_posixAccount.inc
@@ -204,10 +204,10 @@ class posixAccount extends simplePlugin
     );
   }
 
-  function __construct ($unused, $dn = NULL, $object = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
   {
     global $config;
-    parent::__construct($unused, $dn, $object);
+    parent::__construct($dn, $object, $parent, $mainTab);
 
     $this->attributesAccess['gecos']->setVisible(FALSE);
 
diff --git a/plugins/personal/roles/class_userRoles.inc b/plugins/personal/roles/class_userRoles.inc
index 8435931b0..5c2307c0b 100644
--- a/plugins/personal/roles/class_userRoles.inc
+++ b/plugins/personal/roles/class_userRoles.inc
@@ -68,9 +68,9 @@ class userRoles extends simplePlugin
     );
   }
 
-  function __construct ($unused, $dn = NULL, $object = NULL)
+  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
   {
-    parent::__construct($unused, $dn, $object);
+    parent::__construct($dn, $object, $parent, $mainTab);
     $this->ignore_account = FALSE;
 
     /* Groups handling */
-- 
GitLab