Code

Updated terminal copy & paste
[gosa.git] / plugins / admin / users / tabs_user.inc
index 451d9f973f2f1b84184179214f38b627134d963b..ecc70d05b982d0bec259cb88c6c23921a7795c19 100644 (file)
@@ -6,8 +6,12 @@ class usertabs extends tabs
 
   function usertabs($config, $data, $dn)
   {
-    tabs::tabs($config, $data, $dn);
+    tabs::tabs($config, $data, $dn, 'users');
     $this->base= $this->by_object['user']->base;
+
+    /* Add references/acls/snapshots */
+    $this->addSpecialTabs();
+
   }
 
   function save_object($save_current= FALSE)
@@ -18,15 +22,32 @@ class usertabs extends tabs
     $baseobject= $this->by_object['user'];
     foreach ($this->by_object as $name => $obj){
 
+      /* Adding uid to sub plugins of connectivity */
+      if($name == "connectivity"){
+        foreach ($obj->plugin_name as $plg_name){
+          if(isset($obj->plugin[$plg_name]->uid)){
+            $obj->plugin[$plg_name]->uid = $baseobject->uid;
+          }
+        }
+      }
+
       /* Don't touch base object */
       if ($name != 'user'){
         $obj->parent= &$this;
         $obj->uid= $baseobject->uid;
         $obj->sn= $baseobject->uid;
         $obj->givenName= $baseobject->uid;
-        $this->by_object[$name]= $obj;
       }
 
+      /* Copy mail if needed */
+      if ($name == "gofaxAccount"){
+        if (isset($this->by_object['mailAccount']) && $this->by_object['mailAccount']->is_account){
+          $obj->mail= $this->by_object['mailAccount']->mail;
+        }
+      }
+
+      $this->by_object[$name]= $obj;
+
       /* Update parent in base object */
       $this->by_object['user']->parent= &$this;
     }
@@ -59,6 +80,9 @@ class usertabs extends tabs
       $number= key($this->by_object['phoneAccount']->phoneNumbers);
       $this->by_object['user']->telephoneNumber= $number;
     }
+
+    /* Possibly change acl base */
+    $this->set_acl_base();
   }
 
   function save()
@@ -66,39 +90,23 @@ class usertabs extends tabs
     /* Check for new 'dn', in order to propagate the
        'dn' to all plugins */
     $baseobject= $this->by_object['user'];
-    if ($this->dn == 'new'){
-      $baseobject->cn= $baseobject->givenName." ".$baseobject->sn;
-      $this->by_object['user']= $baseobject;
-      if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
-        $this->dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
-      } else {
-        $this->dn= 'cn='.$baseobject->cn.','.get_people_ou().$baseobject->base;
-      }
-    } // != 'new' 
-    else 
-    {
-      /* Extract cn and compare with actual cn present in 'dn' */
-      if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
-        $new_dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
-      } else {
-        $new_dn= "cn=".$baseobject->givenName." ".$baseobject->sn.','.
-          get_people_ou().$baseobject->base;
-      }
 
-      if ($this->dn != $new_dn){
+    if ($this->dn != 'new'){
+      $new_dn= $baseobject->new_dn;
+      if (strtolower($this->dn) != strtolower($new_dn)){
 
-        /* Write entry on new 'dn' */
-        $baseobject->cn= $baseobject->givenName." ".$baseobject->sn;
+        /* Udpate acls */
+        $baseobject->update_acls($this->dn,$new_dn);
         $baseobject->move($this->dn, $new_dn);
         $this->by_object['user']= $baseobject;
 
         /* Did we change ourselves? Update ui object. */
         change_ui_dn($this->dn, $new_dn);
-
-        /* Happen to use the new one */
-        $this->dn= $new_dn;
       }
     }
+
+    $this->dn= $baseobject->new_dn;
+
     return tabs::save();
   }
 
@@ -109,6 +117,16 @@ class usertabs extends tabs
       $this->by_object[$key]->is_template= TRUE;
     }
   }
+  
+  function saveCopyDialog()
+  {
+    tabs::saveCopyDialog();
+    $baseobject= $this->by_object['user'];
+    $uid = $baseobject->uid;
+    foreach($this->by_object as  $name => $obj){
+      $this->by_object[$name]->uid = $uid;
+    }
+  }
 
 }