Code

Added RDN style for users
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 6 Feb 2007 11:09:31 +0000 (11:09 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 6 Feb 2007 11:09:31 +0000 (11:09 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5692 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_tabs.inc
plugins/admin/users/tabs_user.inc
plugins/personal/generic/class_user.inc

index 8e2d42ca4861c77d3dd7305f14edb0c3610c4ce8..0808b9abe2d0fa1f019e8cab6145a65fe8ea34b0 100644 (file)
@@ -124,7 +124,6 @@ class tabs
                $obj->save_object ();
                $this->by_object[$this->current]= $obj;
        }
-
   }
 
   function gen_tabs()
index 25dfee8c2b39f5002680c0d6ce4cb4e33fdeaa1e..ecc70d05b982d0bec259cb88c6c23921a7795c19 100644 (file)
@@ -11,6 +11,7 @@ class usertabs extends tabs
 
     /* Add references/acls/snapshots */
     $this->addSpecialTabs();
+
   }
 
   function save_object($save_current= FALSE)
@@ -90,50 +91,9 @@ class usertabs extends tabs
        'dn' to all plugins */
     $baseobject= $this->by_object['user'];
 
-    /* Assemble cn */
-    $pt= "";
-    if(isset($this->config->current['INCLUDE_PERSONAL_TITLE']) && preg_match("/true/i",$this->config->current['INCLUDE_PERSONAL_TITLE'])){
-      if(!empty($baseobject->personalTitle)){
-        $pt = $baseobject->personalTitle." ";
-      }
-    }
-    
-    if ($this->dn == 'new'){
-      $baseobject->cn= $pt.$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=".$pt.$baseobject->givenName." ".$baseobject->sn.','.
-          get_people_ou().$baseobject->base;
-      }
-      
-      /* Hickert: 31.08.2005 
-       * fixed error = Trying to overwrite cn=***  which already exists.
-       * If you changed one of the "Name" / "Givenname" attributes to lower or upper case, like "test" to "Test", (in DNMODE=cn)
-       *  the old_dn and new dn were different. cn=test ... cn=Test ...
-       * The following code decided to move the entry from old_dn to new_dn. (Because they differ)
-       * But the ldap attribute cn is not case sensitive and the function plugin::move() quits with 
-       *  an error, because source and destination dn are both the same (for ldap, but not for php).
-       * This fix allow you to change the givenname or name attributes.
-       */
-      if(strtolower($this->dn)==strtolower($new_dn)){
-        $this->dn=$new_dn;
-      }
-  
-      if ($this->dn != $new_dn){
-
-        /* Write entry on new 'dn' */
-        $baseobject->cn= $pt.$baseobject->givenName." ".$baseobject->sn;
+    if ($this->dn != 'new'){
+      $new_dn= $baseobject->new_dn;
+      if (strtolower($this->dn) != strtolower($new_dn)){
 
         /* Udpate acls */
         $baseobject->update_acls($this->dn,$new_dn);
@@ -142,11 +102,11 @@ class usertabs extends tabs
 
         /* 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();
   }
 
index bb0607a3eddc4b5e373658f199a86020a4444e75..b02dc292d0d784b007657b037aff418aa2bc1dbe 100644 (file)
@@ -24,6 +24,7 @@ class user extends plugin
   /* Plugin specific values */
   var $base= "";
   var $cn= "";
+  var $new_dn= "";
   var $personalTitle= "";
   var $academicTitle= "";
   var $homePostalAddress= "";
@@ -894,24 +895,17 @@ class user extends plugin
 
     }
 
-    /* Build new dn */
-    if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
-      $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
-    } else {
-      $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
-    }
-
     /* This only gets called when user is renaming himself */
     $ldap= $this->config->get_ldap_link();
-    if ($this->dn != $new_dn){
+    if ($this->dn != $this->new_dn){
 
       /* Write entry on new 'dn' */
-      $this->update_acls($this->dn,$new_dn);
-      $this->move($this->dn, $new_dn);
+      $this->update_acls($this->dn,$this->new_dn);
+      $this->move($this->dn, $this->new_dn);
 
       /* Happen to use the new one */
-      change_ui_dn($this->dn, $new_dn);
-      $this->dn= $new_dn;
+      change_ui_dn($this->dn, $this->new_dn);
+      $this->dn= $this->new_dn;
     }
 
 
@@ -1053,9 +1047,14 @@ class user extends plugin
 
     /* Permissions for that base? */
     if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
-      $new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
+      $this->new_dn= 'uid='.$this->uid.','.get_people_ou().$this->base;
     } else {
-      $new_dn= 'cn='.$this->cn.','.get_people_ou().$this->base;
+      /* Don't touch dn, if cn hasn't changed */
+      if (isset($this->saved_attributes['cn']) && $this->saved_attributes['cn'] == $this->cn){
+        $this->new_dn= $this->dn;
+      } else {
+        $this->new_dn= $this->create_unique_dn('cn', get_people_ou().$this->base);
+      }
     }
 
     /* Set the new acl base */
@@ -1086,10 +1085,8 @@ class user extends plugin
         $message[]= _("The required field 'Login' is not set.");
       }
       if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
-        $ldap->cd($this->config->current['BASE']);
-        $ldap->search("(cn=".$this->cn.")", array("uid"));
-        $ldap->fetch();
-        if ($ldap->count() != 0 && $this->dn != $new_dn && $this->dn == 'new'){
+        $ldap->cat($this->new_dn);
+        if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){
           $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
         }
       }