From ace916e4258e354bfbd15875f9c91a9fd83616f9 Mon Sep 17 00:00:00 2001
From: Benoit Mortier <benoit.mortier@opensides.be>
Date: Wed, 14 Nov 2012 17:05:46 +0100
Subject: [PATCH] Fixes: #1519 Copy/Paste should be fixed

---
 include/class_CopyPasteHandler.inc            | 21 ++--
 include/class_acl.inc                         | 95 +++++++++----------
 include/class_management.inc                  |  2 +-
 include/class_tabs.inc                        | 12 +--
 include/functions.inc                         |  6 +-
 plugins/admin/acl/tabs_acl.inc                | 74 ++++-----------
 plugins/admin/acl/tabs_acl_role.inc           | 14 +--
 plugins/admin/departments/tabs_department.inc | 53 +++++------
 plugins/admin/groups/tabs_group.inc           |  4 +-
 plugins/admin/ogroups/tabs_ogroups.inc        | 73 +++++++-------
 plugins/admin/users/tabs_user.inc             |  2 +-
 plugins/personal/generic/class_user.inc       | 25 -----
 plugins/personal/posix/class_posixAccount.inc | 38 ++++----
 13 files changed, 178 insertions(+), 241 deletions(-)

diff --git a/include/class_CopyPasteHandler.inc b/include/class_CopyPasteHandler.inc
index 92d2316a8..fa3132490 100644
--- a/include/class_CopyPasteHandler.inc
+++ b/include/class_CopyPasteHandler.inc
@@ -147,7 +147,6 @@ class CopyPasteHandler {
       return array();
     }
 
-
     $tab_c  = $entry['tab_class'];
     $tab_o  = $entry['tab_object'];
     $tab_a  = $entry['tab_acl_category'];
@@ -223,7 +222,7 @@ class CopyPasteHandler {
         foreach ($this->disallowed_objects as $entry) {
           $dns[] = $entry['dn'];
         }
-        //  msg_dialog::display(_("Permission"),msgPool::permCreate($dns),INFO_DIALOG);
+        msg_dialog::display(_("Permission"), msgPool::permCreate($dns), INFO_DIALOG);
       }
       $this->require_update = FALSE;
     }
@@ -349,15 +348,17 @@ class CopyPasteHandler {
       $o_ogroup->save();
     }
 
-    // Update roles
-    $roles = get_sub_list("(&(objectClass=organizationalRole)(roleOccupant=".LDAP::prepare4filter(LDAP::fix($src_dn))."))",
-            "roles", array(get_ou("roleRDN")), $this->config->current['BASE'], array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
+    if (class_available('roleGeneric')) {
+      // Update roles
+      $roles = get_sub_list("(&(objectClass=organizationalRole)(roleOccupant=".LDAP::prepare4filter(LDAP::fix($src_dn))."))",
+              "roles", array(get_ou("roleRDN")), $this->config->current['BASE'], array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
 
-    // Walk through all roles
-    foreach ($roles as $role) {
-      $role = new roleGeneric($this->config, $role['dn']);
-      $role->roleOccupant[] = $dst_dn;
-      $role->save();
+      // Walk through all roles
+      foreach ($roles as $role) {
+        $role = new roleGeneric($this->config, $role['dn']);
+        $role->roleOccupant[] = $dst_dn;
+        $role->save();
+      }
     }
 
     // Update groups
diff --git a/include/class_acl.inc b/include/class_acl.inc
index 51f71e017..c1af0fded 100644
--- a/include/class_acl.inc
+++ b/include/class_acl.inc
@@ -31,10 +31,6 @@
  */
 class acl extends plugin
 {
-  /* Definitions */
-  var $plHeadline= "Access control";
-  var $plDescription= "Manage access control lists";
-
   /* attribute list for save action */
   var $attributes= array('gosaAclEntry');
   var $objectclasses= array('gosaAcl');
@@ -71,52 +67,53 @@ class acl extends plugin
    *
    * \param String $dn The DN
    */
-  function acl (&$config, $parent, $dn= NULL)
+  function acl (&$config, $dn = NULL, $baseobject = NULL)
   {
     /* Include config object */
-    plugin::plugin($config, $dn);
+    plugin::plugin($config, $dn, $baseobject);
 
     /* Load ACL's */
-    $this->gosaAclEntry= array();
-    if (isset($this->attrs['gosaAclEntry'])){
-      for ($i= 0; $i<$this->attrs['gosaAclEntry']['count']; $i++){
-        $acl= $this->attrs['gosaAclEntry'][$i];
-        $this->gosaAclEntry= array_merge($this->gosaAclEntry, acl::explodeACL($acl));
+    $this->gosaAclEntry = array();
+    if (isset($this->attrs['gosaAclEntry'])) {
+      for ($i = 0; $i < $this->attrs['gosaAclEntry']['count']; $i++) {
+        $acl = $this->attrs['gosaAclEntry'][$i];
+        $this->gosaAclEntry = array_merge($this->gosaAclEntry, acl::explodeACL($acl));
       }
     }
     ksort($this->gosaAclEntry);
 
     /* Save parent - we've to know more about it than other plugins... */
-    $this->parent= &$parent;
+    if (($baseobject !== NULL) && isset($baseobject->parent)) {
+      $this->parent = &($baseobject->parent);
+    }
 
     /* Container? */
-    if (preg_match('/^(o|ou|c|l|dc)=/i', $dn)){
-      $this->isContainer= TRUE;
+    if (preg_match('/^(o|ou|c|l|dc)=/i', $dn)) {
+      $this->isContainer = TRUE;
     }
 
     /* Users */
-    $ui= get_userinfo();
-    $tag= $ui->gosaUnitTag;
-    $ldap= $config->get_ldap_link();
+    $ui   = get_userinfo();
+    $tag  = $ui->gosaUnitTag;
+    $ldap = $config->get_ldap_link();
     $ldap->cd($config->current['BASE']);
-    if ($tag == ""){
+    if ($tag == "") {
       $ldap->search('(objectClass=gosaAccount)', array('uid', 'cn'));
     } else {
       $ldap->search('(&(objectClass=gosaAccount)(gosaUnitTag='.$tag.'))', array('uid', 'cn'));
     }
-    while ($attrs= $ldap->fetch()){
 
+    while ($attrs = $ldap->fetch()) {
       // Allow objects without cn to be listed without causing an error.
-      if(!isset($attrs['cn'][0]) && isset($attrs['uid'][0])){
-        $this->users['U:'.$attrs['dn']]=  $attrs['uid'][0];
-      }elseif(!isset($attrs['uid'][0]) && isset($attrs['cn'][0])){
-        $this->users['U:'.$attrs['dn']]=  $attrs['cn'][0];
-      }elseif(!isset($attrs['uid'][0]) && !isset($attrs['cn'][0])){
-        $this->users['U:'.$attrs['dn']]= $attrs['dn'];
-      }else{
-        $this->users['U:'.$attrs['dn']]= $attrs['cn'][0].' ['.$attrs['uid'][0].']';
+      if (!isset($attrs['cn'][0]) && isset($attrs['uid'][0])) {
+        $this->users['U:'.$attrs['dn']] =  $attrs['uid'][0];
+      } elseif (!isset($attrs['uid'][0]) && isset($attrs['cn'][0])) {
+        $this->users['U:'.$attrs['dn']] =  $attrs['cn'][0];
+      } elseif (!isset($attrs['uid'][0]) && !isset($attrs['cn'][0])) {
+        $this->users['U:'.$attrs['dn']] = $attrs['dn'];
+      } else {
+        $this->users['U:'.$attrs['dn']] = $attrs['cn'][0].' ['.$attrs['uid'][0].']';
       }
-
     }
     ksort($this->users);
 
@@ -127,14 +124,14 @@ class acl extends plugin
 #    } else {
 #      $ldap->search('(&(objectClass=posixGroup)(gosaUnitTag='.$tag.'))', array('cn', 'description'));
 #    }
-    while ($attrs= $ldap->fetch()){
-      $dsc= "";
-      if (isset($attrs['description'][0])){
-        $dsc= $attrs['description'][0];
+    while ($attrs = $ldap->fetch()) {
+      $dsc = "";
+      if (isset($attrs['description'][0])) {
+        $dsc = $attrs['description'][0];
       }
-      $this->groups['G:'.$attrs['dn']]= $attrs['cn'][0].' ['.$dsc.']';
+      $this->groups['G:'.$attrs['dn']] = $attrs['cn'][0].' ['.$dsc.']';
     }
-    $this->groups['G:*']= _("All users");
+    $this->groups['G:*'] = _("All users");
     ksort($this->groups);
 
     /* Roles */
@@ -144,7 +141,7 @@ class acl extends plugin
 #    } else {
 #     $ldap->search('(&(objectClass=gosaRole)(gosaUnitTag='.$tag.'))', array('cn', 'description','gosaAclTemplate','dn'));
 #    }
-    while ($attrs= $ldap->fetch()){
+    while ($attrs= $ldap->fetch()) {
       $dsc= "";
       if (isset($attrs['description'][0])){
         $dsc= $attrs['description'][0];
@@ -162,27 +159,27 @@ class acl extends plugin
     }
 
     /* Objects */
-    $tmp= session::global_get('plist');
-    $plist= $tmp->info;
-    $cats = array();
-    if (isset($this->parent) && $this->parent !== NULL){
-      $oc= array();
-      foreach ($this->parent->by_object as $key => $obj){
-        $oc= array_merge($oc, $obj->objectclasses);
-        if(isset($obj->acl_category)){
-          $tmp= str_replace("/","",$obj->acl_category);
+    $tmp    = session::global_get('plist');
+    $plist  = $tmp->info;
+    $cats   = array();
+    if (isset($this->parent) && $this->parent !== NULL) {
+      $oc = array();
+      foreach ($this->parent->by_object as $key => $obj) {
+        $oc = array_merge($oc, $obj->objectclasses);
+        if (isset($obj->acl_category)) {
+          $tmp = str_replace("/", "", $obj->acl_category);
           $cats[$tmp] = $tmp;
         }
       }
-      if (in_array_ics('organizationalUnit', $oc)){
-        $this->isContainer= TRUE;
+      if (in_array_ics('organizationalUnit', $oc)) {
+        $this->isContainer = TRUE;
       }
     } else {
-      $oc=  $this->attrs['objectClass'];
+      $oc = $this->attrs['objectClass'];
     }
 
     /* Extract available categories from plugin info list */
-    foreach ($plist as $class => $acls){
+    foreach ($plist as $class => $acls) {
 
       /* Only feed categories */
       if (isset($acls['plCategory'])){
@@ -1353,7 +1350,7 @@ class acl extends plugin
   {
     return array(
       "plShortName"   => _("ACL"),
-      "plDescription" => _("ACL")."&nbsp;("._("Access control list").")",
+      "plDescription" => _("Manage access control lists"),
       "plSelfModify"  => FALSE,
       "plCategory"    => array("acl" => array("description"  => _("ACL")."&nbsp;&amp;&nbsp;"._("ACL roles"),
                                                       "objectClass"  => array("gosaAcl","gosaRole"))),
diff --git a/include/class_management.inc b/include/class_management.inc
index 67369b77e..08a794e2a 100644
--- a/include/class_management.inc
+++ b/include/class_management.inc
@@ -725,7 +725,7 @@ class management
         trigger_error("We can't edit any object(s). 'tabClass' or 'tabType' is empty!");
       }else{
         $tab = $tabClass;
-        $this->tabObject= new $tab($this->config,$this->config->data['TABS'][$tabType], $this->dn,$aclCategory);
+        $this->tabObject = new $tab($this->config, $this->config->data['TABS'][$tabType], $this->dn, $aclCategory);
         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dn,"Edit entry initiated!");
         $this->tabObject->set_acl_base($this->dn);
         $this->tabObject->parent = &$this;
diff --git a/include/class_tabs.inc b/include/class_tabs.inc
index 8c885ee85..fc735a178 100644
--- a/include/class_tabs.inc
+++ b/include/class_tabs.inc
@@ -427,14 +427,14 @@ class tabs
   function addSpecialTabs($hide_refs = FALSE, $hide_acls = FALSE)
   {
     if (!$hide_acls) {
-      $this->by_name['acl']= _("ACL");
-      $this->by_object['acl']= new acl($this->config, $this, $this->dn);
-      $this->by_object['acl']->parent= &$this;
+      $this->by_name['acl']           = _("ACL");
+      $this->by_object['acl']         = new acl($this->config, $this->dn, $this->getBaseObject());
+      $this->by_object['acl']->parent = &$this;
     }
     if (!$hide_refs) {
-      $this->by_name['reference']= _("References");
-      $this->by_object['reference']= new reference($this->config, $this->dn);
-      $this->by_object['reference']->parent= &$this;
+      $this->by_name['reference']           = _("References");
+      $this->by_object['reference']         = new reference($this->config, $this->dn, $this->getBaseObject());
+      $this->by_object['reference']->parent = &$this;
     }
   }
 
diff --git a/include/functions.inc b/include/functions.inc
index ba2bd0373..ef15d4809 100644
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -113,14 +113,16 @@ $REWRITE= array( "ä" => "ae",
 function __fusiondirectory_autoload($class_name) {
     global $class_mapping, $BASE_DIR;
 
-    if ($class_mapping === NULL){
+    if ($class_mapping === NULL) {
       echo sprintf(_("Fatal error: no class locations defined - please run '%s' to fix this"), "<b>fusiondirectory-setup --update-cache</b>");
       exit;
     }
 
-    if (isset($class_mapping["$class_name"])){
+    if (isset($class_mapping["$class_name"])) {
       require_once($BASE_DIR."/".$class_mapping["$class_name"]);
     } else {
+      @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $class_name, "Could not load");
+      print_r(debug_backtrace());
       echo sprintf(_("Fatal error: cannot instantiate class '%s' - try running '%s' to fix this"), $class_name, "<b>fusiondirectory-setup --update-cache</b>");
       exit;
     }
diff --git a/plugins/admin/acl/tabs_acl.inc b/plugins/admin/acl/tabs_acl.inc
index 6e023c599..26e3093da 100644
--- a/plugins/admin/acl/tabs_acl.inc
+++ b/plugins/admin/acl/tabs_acl.inc
@@ -23,73 +23,37 @@
 class acltab extends tabs
 {
 
-  function acltab($config, $data, $dn)
+  function acltab($config, $data, $dn, $cat = "", $copied_object = NULL)
   {
     $data = array(array("CLASS" => "acl" , "NAME" => _("ACL")));
-
-    /* Save dn */
-    $this->dn= $dn;
-    $this->config= $config;
-
-    $baseobject= NULL;
-
-    foreach ($data as $tab){
-      $this->by_name[$tab['CLASS']]= $tab['NAME'];
-
-      
-      if ($baseobject === NULL){
-        if($tab['CLASS'] == "acl"){
-          $baseobject= new $tab['CLASS']($this->config, $this, $this->dn);
-        }else{
-          $baseobject= new $tab['CLASS']($this->config,$this->dn);
-        }
-        $this->by_object[$tab['CLASS']]= $baseobject;
-      } else {
-        if($tab['CLASS'] == "acl"){
-          $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config,$this,$this->dn, $baseobject);
-        }else{
-          $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject);
-        }
-      }
-
-      $this->by_object[$tab['CLASS']]->parent= &$this;
-      $this->by_object[$tab['CLASS']]->set_acl_category("acl");
-      $this->read_only |= $this->by_object[$tab['CLASS']]->read_only;
-
-      /* Initialize current */
-      if ($this->current == ""){
-        $this->current= $tab['CLASS'];
-      }
-    }
+    parent::__construct($config, $data, $dn, "", $copied_object);
   }
 
-  function save($ignore_account= FALSE)
+  function save($ignore_account = FALSE)
   {
-    $ret= tabs::save();
-    return $ret;
+    return parent::save();
   }
 
-  function save_object($ignore_account= FALSE)
+  function save_object($ignore_account = FALSE)
   {
-    tabs::save_object();
+    return parent::save_object();
   }
-  
+
   function execute()
   {
-    $display= tabs::execute();
-    if($this->read_only){
-      $display.= "<p style=\"text-align:right\">\n";
-      $display.= "  <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
-      $display.= "</p>";
-    }elseif(!$this->by_object['acl']->dialog){
-      $display.= "<p style=\"text-align:right\">\n";
-      $display.= "  <input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
-      $display.= "  &nbsp;\n";
-      $display.= "  <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
-      $display.= "</p>";
+    $display = parent::execute();
+    if ($this->read_only) {
+      $display .= "<p style=\"text-align:right\">\n";
+      $display .= "  <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
+      $display .= "</p>";
+    } elseif (!$this->by_object['acl']->dialog) {
+      $display .= "<p style=\"text-align:right\">\n";
+      $display .= "  <input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
+      $display .= "  &nbsp;\n";
+      $display .= "  <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
+      $display .= "</p>";
     }
-    return($display);
+    return $display;
   }
 }
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
diff --git a/plugins/admin/acl/tabs_acl_role.inc b/plugins/admin/acl/tabs_acl_role.inc
index dc8ce18d0..43e4868cf 100644
--- a/plugins/admin/acl/tabs_acl_role.inc
+++ b/plugins/admin/acl/tabs_acl_role.inc
@@ -23,21 +23,21 @@
 class aclroletab extends tabs
 {
 
-  function aclroletab($config, $data, $dn)
+  function aclroletab($config, $data, $dn, $cat = "", $copied_object = NULL)
   {
     $data = array(array("CLASS" => "aclrole" , "NAME" => _("ACL Templates")));
-    tabs::tabs($config, $data, $dn,"acl");
+    tabs::tabs($config, $data, $dn, "acl", $copied_object);
   }
 
-  function save($ignore_account= FALSE)
+  function save($ignore_account = FALSE)
   {
-    $baseobject= $this->by_object['aclrole'];
+    $baseobject = $this->by_object['aclrole'];
 
     /* Check for new 'dn', in order to propagate the
        'dn' to all plugins */
-    $new_dn= 'cn='.$baseobject->cn.",".get_ou('aclRoleRDN').$baseobject->base;
+    $new_dn = 'cn='.$baseobject->cn.",".get_ou('aclRoleRDN').$baseobject->base;
 
-    if ($this->dn != $new_dn){
+    if ($this->dn != $new_dn) {
 
       /* Write entry on new 'dn' */
       if ($this->dn != "new"){
@@ -58,7 +58,7 @@ class aclroletab extends tabs
   {
     tabs::save_object();
   }
-  
+
   function execute()
   {
     $display= tabs::execute();
diff --git a/plugins/admin/departments/tabs_department.inc b/plugins/admin/departments/tabs_department.inc
index b313a5577..bd0e1eec1 100644
--- a/plugins/admin/departments/tabs_department.inc
+++ b/plugins/admin/departments/tabs_department.inc
@@ -22,18 +22,18 @@
 
 class deptabs extends tabs
 {
-  var $base= "";
-  var $moved = FALSE;
-  var $base_name = "department";
+  var $base       = "";
+  var $moved      = FALSE;
+  var $base_name  = "department";
 
-  function deptabs($config, $data, $dn,$category,$hide_refs = FALSE, $hide_acls = FALSE)
+  function deptabs($config, $data, $dn, $category, $copied_object)
   {
-    tabs::tabs($config, $data, $dn,$category,$hide_refs, $hide_acls);
+    parent::tabs($config, $data, $dn, $category, $copied_object);
 
     /* Detect the base class  (The classs which extends from department)
      */
-    foreach($this->by_object as $name => $object){
-      if($object instanceOf department){
+    foreach ($this->by_object as $name => $object) {
+      if ($object instanceOf department) {
         $this->base_name = get_class($object);
         break;
       }
@@ -42,42 +42,41 @@ class deptabs extends tabs
 
     /* Add references/acls/snapshots */
     $this->addSpecialTabs();
-    if(isset($this->by_object['acl'])){
-      $this->by_object['acl']->skipTagging= TRUE;
+    if (isset($this->by_object['acl'])) {
+      $this->by_object['acl']->skipTagging = TRUE;
     }
   }
 
-  function check($ignore_account= FALSE)
+  function check($ignore_account = FALSE)
   {
-    return (tabs::check(TRUE));
+    return parent::check(TRUE);
   }
 
-  function save($ignore_account= FALSE)
+  function save($ignore_account = FALSE)
   {
-    $baseobject= &$this->by_object[$this->base_name];
-    $namingAttr       = $baseobject->namingAttr;
-    $nAV      = preg_replace('/,/', '\,', $baseobject->$namingAttr); 
-    $nAV      = preg_replace('/"/', '\"', $nAV); 
-    $new_dn   = @LDAP::convert($namingAttr.'='.$nAV.','.$baseobject->base);
+    $baseobject = &$this->by_object[$this->base_name];
+    $namingAttr = $baseobject->namingAttr;
+    $nAV        = preg_replace('/,/', '\,', $baseobject->$namingAttr);
+    $nAV        = preg_replace('/"/', '\"', $nAV);
+    $new_dn     = @LDAP::convert($namingAttr.'='.$nAV.','.$baseobject->base);
 
     /* Move group? */
-    if ($this->dn != $new_dn && $this->dn != "new"){
-      $baseobject->move($this->dn,$new_dn);
-    } 
+    if ($this->dn != $new_dn && $this->dn != "new") {
+      $baseobject->move($this->dn, $new_dn);
+    }
 
-    /* Update department cache. 
+    /* Update department cache.
      */
-    if($this->dn != $new_dn){
+    if ($this->dn != $new_dn) {
       global $config;
       $config->get_departments();
     }
 
-    $this->dn= $new_dn;
-    $baseobject->dn= $this->dn;
-    if (!$ignore_account){
-      tabs::save(TRUE);
+    $this->dn       = $new_dn;
+    $baseobject->dn = $this->dn;
+    if (!$ignore_account) {
+      parent::save(TRUE);
     }
   }
 }
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
diff --git a/plugins/admin/groups/tabs_group.inc b/plugins/admin/groups/tabs_group.inc
index 61dbeffa5..64312c496 100644
--- a/plugins/admin/groups/tabs_group.inc
+++ b/plugins/admin/groups/tabs_group.inc
@@ -23,9 +23,9 @@
 class grouptabs extends tabs
 {
 
-  function grouptabs($config, $data, $dn, $cat = "", $hide_refs = FALSE, $hide_acls = FALSE)
+  function grouptabs($config, $data, $dn, $cat = "", $copied_object = NULL)
   {
-    tabs::tabs($config, $data, $dn, "groups", $hide_refs, $hide_acls);
+    tabs::tabs($config, $data, $dn, "groups", $copied_object);
     $this->addSpecialTabs();
   }
 
diff --git a/plugins/admin/ogroups/tabs_ogroups.inc b/plugins/admin/ogroups/tabs_ogroups.inc
index 3c14df221..cdf9af52f 100644
--- a/plugins/admin/ogroups/tabs_ogroups.inc
+++ b/plugins/admin/ogroups/tabs_ogroups.inc
@@ -28,12 +28,13 @@ class ogrouptabs extends tabs
 
   function reload($dd)
   {
-    $objects      = preg_replace('/[\[\]]/', '', $dd);
+    $objects = preg_replace('/[\[\]]/', '', $dd);
+    $baseobject = $this->getBaseObject();
 
     /* Check if we have a group with a set different mixed objects.
      */
     $mixed_type = FALSE;
-    for($i = 0 ; $i < (strlen($objects) -1 );$i++){
+    for ($i = 0 ; $i < (strlen($objects) -1 );$i++) {
       $mixed_type |= $objects[$i] != $objects[($i+1)];
     }
 
@@ -41,11 +42,11 @@ class ogrouptabs extends tabs
      * but there is no user left with goPhoneAccount ... remove it.
      */
     $usePhoneTab = false;
-    if(class_available("phonequeue")){
+    if (class_available("phonequeue")) {
 
-      foreach($this->by_object['ogroup']->memberList as $dn => $val){
-        if(isset($this->by_object['ogroup']->objcache[$dn])){
-          $obj = $this->by_object['ogroup']->objcache[$dn];
+      foreach($baseobject->memberList as $dn => $val){
+        if(isset($baseobject->objcache[$dn])){
+          $obj = $baseobject->objcache[$dn];
           if(isset($obj['objectClass'])){
             if(in_array("goFonAccount",$obj['objectClass'])){
               $usePhoneTab = true;
@@ -76,14 +77,14 @@ class ogrouptabs extends tabs
      */
     if(class_available("phonequeue")){
       if(!isset($this->by_object['phonequeue'])){
-        foreach($this->by_object['ogroup']->memberList as $dn => $val){
-          if(isset($this->by_object['ogroup']->objcache[$dn])){
-            $obj = $this->by_object['ogroup']->objcache[$dn];
+        foreach($baseobject->memberList as $dn => $val){
+          if(isset($baseobject->objcache[$dn])){
+            $obj = $baseobject->objcache[$dn];
             if(isset($obj['objectClass'])){
               if(in_array("goFonAccount",$obj['objectClass'])){
-                $this->by_name['phonequeue']= _("Phone queue");
-                $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
-                $this->by_object['phonequeue']->parent= &$this;
+                $this->by_name['phonequeue'] = _("Phone queue");
+                $this->by_object['phonequeue'] = new phonequeue($this->config, $this->dn, $baseobject);
+                $this->by_object['phonequeue']->parent = &$this;
                 break;
               }
             }
@@ -97,7 +98,7 @@ class ogrouptabs extends tabs
       if((preg_match("/U/",$objects))&&(!isset($this->by_object['mailogroup']))){
         if ($this->config->get_cfg_value("mailmethod") == "kolab"){
           $this->by_name['mailogroup']= _("Mail");
-          $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
+          $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn, $baseobject);
           $this->by_object['mailogroup']->parent= &$this;
         }
       }
@@ -134,7 +135,7 @@ class ogrouptabs extends tabs
     if(class_available("environment")){
       if((preg_match("/G/",$objects) || preg_match("/U/",$objects)) && !isset($this->by_name['environment'])){
         $this->by_name['environment']= _("Environment");
-        $this->by_object['environment']= new environment($this->config, $this->dn);
+        $this->by_object['environment']= new environment($this->config, $this->dn, $baseobject);
         $this->by_object['environment']->acl = "#all#";
         $this->by_object['environment']->parent= &$this;
       }
@@ -153,7 +154,7 @@ class ogrouptabs extends tabs
     if(class_available("appgroup")){
       if((preg_match("/G/",$objects) || preg_match("/U/",$objects)) && !isset($this->by_name['appgroup'])){
         $this->by_name['appgroup']= _("Applications");
-        $this->by_object['appgroup']= new appgroup($this->config, $this->dn);
+        $this->by_object['appgroup']= new appgroup($this->config, $this->dn, $baseobject);
         $this->by_object['appgroup']->acl = "#all#";
         $this->by_object['appgroup']->parent= &$this;
       }
@@ -199,8 +200,8 @@ class ogrouptabs extends tabs
 
   function addTab ($class, $name) {
     $this->by_name["$class"] = $name;
-    $this->by_object["$class"] = new $class($this->config, $this->dn, $this->by_object['ogroup']);
-    $this->by_object["$class"]->parent= &$this;
+    $this->by_object["$class"] = new $class($this->config, $this->dn, $this->getBaseObject());
+    $this->by_object["$class"]->parent = &$this;
     $this->by_object["$class"]->acl = "#all#";
   }
 
@@ -209,14 +210,14 @@ class ogrouptabs extends tabs
     $this->by_object['ogroup']->AddDelMembership();
     $this->reload($this->by_object['ogroup']->gosaGroupObjects);
     $str .= tabs::execute();
-    return ( $str);
+    return $str;
   }
 
-  function ogrouptabs($config, $data, $dn,$category ="ogroups",$hide_refs = FALSE, $hide_acls = FALSE)
+  function ogrouptabs($config, $data, $dn, $category = "ogroups", $copied_object = NULL)
   {
 
-    tabs::tabs($config, $data, $dn, $category,$hide_refs, $hide_acls);
-    $this->base= $this->by_object['ogroup']->base;
+    tabs::tabs($config, $data, $dn, $category, $copied_object);
+    $this->base = $this->by_object['ogroup']->base;
     $this->acl_category = $category;
 
     /* Add references/acls/snapshots */
@@ -244,22 +245,22 @@ class ogrouptabs extends tabs
   }
 
 
-  function check($ignore_account= FALSE)
+  function check($ignore_account = FALSE)
   {
-    return (tabs::check(FALSE));
+    return parent::check(FALSE);
   }
 
 
-  function save_object($save_current= FALSE)
+  function save_object($save_current = FALSE)
   {
-    tabs::save_object($save_current);
+    parent::save_object($save_current);
 
     /* Update reference, transfer variables */
     $baseobject= $this->by_object['ogroup'];
-    foreach ($this->by_object as $name => $obj){
+    foreach ($this->by_object as $name => $obj) {
 
       /* Don't touch base object */
-      if ($name != 'ogroup'){
+      if ($name != 'ogroup') {
         $obj->parent    = &$this;
         $obj->uid       = $baseobject->uid;
         $obj->cn        = $baseobject->cn;
@@ -269,24 +270,24 @@ class ogrouptabs extends tabs
       }
 
       /* Update parent in base object */
-      $this->by_object['ogroup']->parent= &$this;
+      $this->by_object['ogroup']->parent = &$this;
     }
   }
 
 
-  function save($ignore_account= FALSE)
+  function save($ignore_account = FALSE)
   {
-    $baseobject= $this->by_object['ogroup'];
+    $baseobject = $this->by_object['ogroup'];
 
     /* Check for new 'dn', in order to propagate the
        'dn' to all plugins */
-    $new_dn= 'cn='.$baseobject->cn.','.get_ou('ogroupRDN').$baseobject->base;
+    $new_dn = 'cn='.$baseobject->cn.','.get_ou('ogroupRDN').$baseobject->base;
 
     /* Move group? */
-    if (LDAP::fix($this->dn) != LDAP::fix($new_dn)){
+    if (LDAP::fix($this->dn) != LDAP::fix($new_dn)) {
 
       /* Write entry on new 'dn' */
-      if ($this->dn != "new"){
+      if ($this->dn != "new") {
         $baseobject->move($this->dn, $new_dn);
         $this->by_object['ogroup']= $baseobject;
       }
@@ -295,7 +296,7 @@ class ogrouptabs extends tabs
       $this->dn= $new_dn;
     }
 
-    if ($this->dn == "new"){
+    if ($this->dn == "new") {
       $this->dn= 'cn='.$baseobject->cn.','.get_ou('ogroupRDN').$baseobject->base;
     }
 
@@ -305,9 +306,7 @@ class ogrouptabs extends tabs
   function getCopyDialog()
   {
     $this->reload($this->by_object['ogroup']->gosaGroupObjects);
-    return(tabs::getCopyDialog());
+    return tabs::getCopyDialog();
   }
 }
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
diff --git a/plugins/admin/users/tabs_user.inc b/plugins/admin/users/tabs_user.inc
index 0943bb684..cc95811d4 100644
--- a/plugins/admin/users/tabs_user.inc
+++ b/plugins/admin/users/tabs_user.inc
@@ -30,7 +30,7 @@ class usertabs extends tabs
   var $givenName  = "";
   var $sn         = "";
 
-  function usertabs($config, $data, $dn, $cat = "", $copied_object)
+  function usertabs($config, $data, $dn, $cat = "", $copied_object = NULL)
   {
     parent::tabs($config, $data, $dn, 'users', $copied_object);
     $this->base = $this->by_object['user']->base;
diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc
index 09dcf238b..8b0bc280f 100644
--- a/plugins/personal/generic/class_user.inc
+++ b/plugins/personal/generic/class_user.inc
@@ -1557,31 +1557,6 @@ class user extends plugin
     return($ret);
   }
 
-  function saveCopyDialog()
-  {
-    /* Set_acl_base */
-    $this->set_acl_base($this->base);
-
-    if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){
-      $this->set_picture($_FILES['picture_file']['tmp_name']);
-    }
-
-    /* Remove picture? */
-    if (isset($_POST['picture_remove'])){
-      $this->jpegPhoto= "*removed*";
-      $this->set_picture ("./plugins/users/images/default.jpg");
-      $this->is_modified= TRUE;
-    }
-
-    $attrs = array("uid","givenName","sn");
-    foreach($attrs as $attr){
-      if(isset($_POST[$attr])){
-        $this->$attr = $_POST[$attr];
-      }
-    }
-  }
-
-
   function PrepareForCopyPaste($source)
   {
     plugin::PrepareForCopyPaste($source);
diff --git a/plugins/personal/posix/class_posixAccount.inc b/plugins/personal/posix/class_posixAccount.inc
index ef7775d6d..c0ea294e8 100644
--- a/plugins/personal/posix/class_posixAccount.inc
+++ b/plugins/personal/posix/class_posixAccount.inc
@@ -104,7 +104,7 @@ class posixAccount extends plugin
 
   /* constructor, if 'dn' is set, the node loads the given
      'dn' from LDAP */
-  function posixAccount (&$config, $dn= NULL)
+  function posixAccount (&$config, $dn = NULL, $object = NULL)
   {
     global $class_mapping;
 
@@ -112,51 +112,51 @@ class posixAccount extends plugin
     $this->config= $config;
 
     /* Load bases attributes */
-    plugin::plugin($config, $dn);
+    plugin::plugin($config, $dn, $object);
 
     /*  If gotoLastSystemLogin is available read it from ldap and create a readable
         date time string, fallback to sambaLogonTime if available.
      */
-    if(isset($this->attrs['gotoLastSystemLogin'][0]) && preg_match("/^[0-9]*$/",$this->attrs['gotoLastSystemLogin'][0])){
+    if (isset($this->attrs['gotoLastSystemLogin'][0]) && preg_match("/^[0-9]*$/",$this->attrs['gotoLastSystemLogin'][0])) {
       $this->gotoLastSystemLogin = date("d.m.Y H:i:s", strtotime($this->attrs['gotoLastSystemLogin'][0]));
-    } else if(isset($this->attrs['sambaLogonTime'][0]) && preg_match("/^[0-9]*$/",$this->attrs['sambaLogonTime'][0])){
+    } elseif(isset($this->attrs['sambaLogonTime'][0]) && preg_match("/^[0-9]*$/",$this->attrs['sambaLogonTime'][0])) {
       $this->gotoLastSystemLogin = date("d.m.Y H:i:s", $this->attrs['sambaLogonTime'][0]);
     }
 
     /* Setting uid to default */
-    if(isset($this->attrs['uid'][0])){
+    if (isset($this->attrs['uid'][0])) {
       $this->uid = $this->attrs['uid'][0];
     }
 
-    $ldap= $this->config->get_ldap_link();
+    $ldap = $this->config->get_ldap_link();
 
-    if ($dn !== NULL){
+    if ($dn !== NULL) {
 
       /* Correct is_account. shadowAccount is not required. */
       if (isset($this->attrs['objectClass']) &&
-          in_array ('posixAccount', $this->attrs['objectClass'])){
+          in_array ('posixAccount', $this->attrs['objectClass'])) {
 
-        $this->is_account= TRUE;
+        $this->is_account = TRUE;
       }
 
       /* Is this account a trustAccount? */
-      if ($this->is_account && isset($this->attrs['host'])){
+      if ($this->is_account && isset($this->attrs['host'])) {
 
         if ($this->attrs['host'][0] == "*") {
-          $this->trustModel= "fullaccess";
+          $this->trustModel = "fullaccess";
         } else {
-          $this->trustModel= "byhost";
+          $this->trustModel = "byhost";
           $this->accessTo = array();
-            if ($this->is_account && isset($this->attrs['host'])){
-              for ($i= 0; $i<$this->attrs['host']['count']; $i++){
-                $tmp= $this->attrs['host'][$i];
+            if ($this->is_account && isset($this->attrs['host'])) {
+              for ($i = 0; $i < $this->attrs['host']['count']; $i++) {
+                $tmp = $this->attrs['host'][$i];
                 $this->accessTo[$tmp]= $tmp;
               }
             }
         }
-        $this->was_trust_account= TRUE;
+        $this->was_trust_account = TRUE;
       } else {
-        $this->was_trust_account= FALSE;
+        $this->was_trust_account = FALSE;
         $this->trustModel= "";
       }
 
@@ -170,8 +170,8 @@ class posixAccount extends plugin
       $this->initially_was_account = $this->is_account;
 
       // Templates do not have a gidNumber
-      if($this->gidNumber == 2147483647){
-        $this->gidNumber = "";
+      if ($this->gidNumber == 2147483647) {
+        $this->gidNumber    = "";
         $this->primaryGroup = 0;
       }
 
-- 
GitLab