Code

Updated several plugins
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 28 Apr 2010 13:45:23 +0000 (13:45 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 28 Apr 2010 13:45:23 +0000 (13:45 +0000)
-Applied bugfixes catched during testing trunk

git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6@17912 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_CopyPasteHandler.inc
gosa-core/include/class_userinfo.inc
gosa-core/plugins/admin/departments/class_department.inc
gosa-core/plugins/personal/generic/class_user.inc
gosa-core/plugins/personal/posix/class_posixAccount.inc

index 4d6fb1ddb04928d4e27061661fa2e7dfc6607ba6..9c87c0b374c07a68ae5168f017dcb1024106c07f 100644 (file)
@@ -352,6 +352,7 @@ class CopyPasteHandler {
         $this->lastdn = $this->current['object']->dn;
         $this->current= $this->_update_vars($this->current);
         $this->current['object']->save();
+        $this->handleReferences();
         $this->current = FALSE;
       } 
     }
@@ -368,6 +369,7 @@ class CopyPasteHandler {
       /* Load next queue entry */
       if(!count($msgs)){
         $this->current['object']->save();
+        $this->handleReferences();
         $this->lastdn = $this->current['object']->dn;
         $this->current = FALSE;
       }else{
@@ -415,7 +417,7 @@ class CopyPasteHandler {
         $smarty->assign("AttributesToFix",$this->generateAttributesToFix());
         $smarty->assign("SubDialog",$this->current['object']->SubDialog);
         $smarty->assign("objectDN",$this->current['source_data']['dn']);
-        $smarty->assign("message", sprintf(_("This object will be pasted: %s"), "<br><br>".$this->current['source_data']['dn']));
+        $smarty->assign("message", sprintf(_("This object will be pasted: %s"), "<br><br>".bold($this->current['source_data']['dn'])));
         return($smarty->fetch(get_template_path("copyPasteDialog.tpl",FALSE)));
       }
     }
@@ -504,6 +506,60 @@ class CopyPasteHandler {
   }
 
 
+  function handleReferences()
+  {
+    $dst_dn = $this->current['object']->dn;
+    $src_dn = $this->current['dn'];
+
+    // Only copy references if required 
+    if($this->current['method'] != 'copy') return;
+
+    // Migrate objectgroups
+    $ogroups = get_sub_list("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter(LDAP::fix($src_dn))."))",
+            "ogroups", array(get_ou("ogroupRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
+
+    // Walk through all objectGroups
+    foreach($ogroups as $ogroup){
+        $o_ogroup= new ogroup($this->config,$ogroup['dn']);
+        $o_ogroup->member[$dst_dn]= $dst_dn;
+        $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);
+
+    // Walk through all roles
+    foreach($roles as $role){
+        $role = new roleGeneric($this->config,$role['dn']);
+        $role->roleOccupant[] = $dst_dn;
+        $role->save();
+    }
+
+    // Update groups
+    if(isset($this->current['object']->uid) && !empty($this->current['object']->uid)){
+
+        $ldap = $this->config->get_ldap_link();
+        $ldap->cd($this->config->current['BASE']);
+        $ldap->cat($src_dn);
+        $attrs = $ldap->fetch();
+        if(isset($attrs['uid'][0])){
+            $suid = $attrs['uid'][0];
+
+            $uid = $this->current['object']->uid;
+            $groups = get_sub_list("(&(objectClass=posixGroup)(memberUid={$suid}))",
+                    "groups",array(get_ou("groupRDN")),$this->config->current['BASE'],array("dn"), GL_SUBSEARCH | GL_NO_ACL_CHECK);
+
+            // Walk through all POSIX groups
+            foreach($groups as $group){
+                $o_group= new group($this->config,$group['dn']);
+                $o_group->addUser($uid);
+                $o_group->save();
+            }
+        }
+    }
+  }
+
   /* returns the paste icon for headpages */ 
   function generatePasteIcon()
   {
index 1b5fac84eb57e51b426f94f8f004acc4d57790e1..fcfaae8545494ab5fa9693dd4ea42343ce86b9ed 100644 (file)
@@ -489,7 +489,10 @@ class userinfo
                 foreach($this->ocMapping[$ocs] as $oc){
                   if (isset($subacl['acl'][$ocs.'/'.$oc])){
 
-                    if($dn != $this->dn && strpos($subacl['acl'][$ocs.'/'.$oc][0],"s") !== FALSE) continue;
+                      // Skip ACLs wich are defined for ourselfs only - if not checking against ($ui->dn)
+                      if(isset($subacl['acl'][$ocs.'/'.$oc][0]) && 
+                              $dn != $this->dn && 
+                              strpos($subacl['acl'][$ocs.'/'.$oc][0],"s") !== FALSE) continue;
 
                     foreach($subacl['acl'][$ocs.'/'.$oc] as $attr => $dummy){
                       $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$ocs.'/'.$oc][$attr]);
index 859ec3f9a52b4eab00a467a531c8d9022340bc02..bdf658aab0de4f9ddbab1c229fd0c9ceac06d979 100644 (file)
@@ -230,7 +230,7 @@ class department extends plugin
     $this->baseSelector->setBases($tmp);
 
     foreach ($this->attributes as $val){
-      $smarty->assign("$val", $this->$val);
+      $smarty->assign("$val", htmlentities($this->$val,ENT_COMPAT,'UTF-8'));
     }
     $smarty->assign("base", $this->baseSelector->render());
 
index 9bf7f47c728c90edac0ca79813a05d3862d699ea..9d3f500a9cd07ed3b87b191e3d0d94744e1d9d9c 100644 (file)
@@ -733,7 +733,6 @@ class user extends plugin
     while ($ldap->fetch()){
       $og= new ogroup($this->config, $ldap->getDN());
       unset($og->member[$this->dn]);
-      $og->member= array_values($og->member);
       $og->save ();
     }
 
@@ -1630,6 +1629,20 @@ class user extends plugin
     $this->old_userPKCS12= "";
     $this->old_userSMIMECertificate= "";
     $this->old_userCertificate= "";
+
+    /* Generate dateOfBirth entry */
+    if (isset ($source['dateOfBirth'])){
+        list($year, $month, $day)= explode("-", $source['dateOfBirth'][0], 3);
+        $this->dateOfBirth= "$day.$month.$year";
+    } else {
+        $this->dateOfBirth= "";
+    }
+
+    // Try to load the user picture
+    $tmp_dn = $this->dn;
+    $this->dn = $source['dn'];
+    $this->load_picture();
+    $this->dn = $tmp_dn;
   }
 
 
index 2bd4f5fac4abff81c49ae30ed94df352ee296778..6c31a176496b9767189c3e5579554b9839c5ee8e 100644 (file)
@@ -1425,6 +1425,17 @@ class posixAccount extends plugin
       $this->primaryGroup= $source['gidNumber'][0];
     }
 
+
+    /* Adjust shadow checkboxes */
+    foreach (array("shadowMin", "shadowMax", "shadowWarning", "shadowInactive",
+                "shadowExpire") as $val){
+
+        if ($this->$val != 0){
+            $oval= "activate_".$val;
+            $this->$oval= "1";
+        }
+    }
+
   }