Code

Fixed new members in ogroups
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 15 Sep 2006 09:47:47 +0000 (09:47 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 15 Sep 2006 09:47:47 +0000 (09:47 +0000)
Fixed session problem for logger

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

include/class_ldap.inc
plugins/admin/ogroups/class_ogroup.inc

index c4768ee776ecbc1ad26f93240366e4c5fb621056..504a470d45dca1630fe747bb3ba5395e17a1fd67 100644 (file)
@@ -1154,9 +1154,11 @@ function gen_xls ($dn, $filter= "(objectClass=*)", $attributes= array('*'), $rec
 
   function log($string)
   {
-    $cfg= $_SESSION['config'];
-    if (isset($cfg->current['LDAPSTATS']) && preg_match('/true/i', $cfg->current['LDAPSTATS'])){
+    if (isset($_SESSION['config'])){
+      $cfg= $_SESSION['config'];
+      if (isset($cfg->current['LDAPSTATS']) && preg_match('/true/i', $cfg->current['LDAPSTATS'])){
         syslog (LOG_INFO, $string);
+      }
     }
   }
 
index 9715ac161c635f8d0b15d3358d7e0443d387230e..4552807b8f4c189c3b7d10267fbcde17cbd19826 100644 (file)
@@ -95,9 +95,10 @@ class ogroup extends plugin
     $this->reload();
   }
 
-  function AddDelMembership($NewMember = false){
-
+  function AddDelMembership($NewMember = false)
+  {
     if($NewMember){
+      $this->importMember($NewMember);
       $this->memberList[$NewMember]= $this->objcache[$NewMember];
       $this->member[$NewMember]= $NewMember;
       unset ($this->objects[$NewMember]);
@@ -440,48 +441,7 @@ class ogroup extends plugin
   
     /* Walk through all single member entry */
     foreach($this->member as $dn){
-
-      /* The dn for the current member can't be resolved 
-         it seams that this entry was removed 
-       */ 
-      /* Try to resolv the entry again, if it still fails, display error msg */
-      $ldap->cat($dn, array("cn", "sn", "givenName", "ou", "description", "objectClass"));
-
-      /* It has failed, add entry with type flag I (Invalid)*/
-      if ($ldap->error != "Success"){
-        $this->memberList[$dn]= array('text' => _("Non existing dn:")." ".@LDAP::fix($dn),"type" => "I");
-
-      } else {
-
-        /* Append this entry to our all object list */
-
-        /* Fetch object */
-        $attrs= $ldap->fetch();
-
-        $type= $this->getObjectType($attrs);
-        $name= $this->getObjectName($attrs);
-
-        if (isset($attrs["description"][0])){
-          $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type");
-        } elseif (isset($attrs["uid"][0])) {
-          $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["uid"][0]."]", "type" => "$type");
-        } else {
-          $this->objcache[$attrs["dn"]]= array("text" => "$name", "type" => "$type");
-        }
-        $this->objcache[$attrs["dn"]]['objectClass']  = $attrs['objectClass'];
-        if(isset($attrs['uid'])){
-          $this->objcache[$attrs["dn"]]['uid']          = $attrs['uid'];
-        }
-
-        /* Fill array */
-        if (isset($attrs["description"][0])){
-          $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type");
-        } else {
-          $this->objects[$attrs["dn"]]= array("text" => "$name", "type" => "$type");
-        }
-
-        $this->memberList[$dn]= $this->objects[$attrs["dn"]];
-      }
+      $this->importMember($dn);
     }
     uasort ($this->memberList, 'sort_list');
     reset ($this->memberList);
@@ -504,6 +464,48 @@ class ogroup extends plugin
   }
 
 
+  function importMember($dn)
+  {
+    $ldap= $this->config->get_ldap_link();
+
+    /* Try to resolv the entry again, if it still fails, display error msg */
+    $ldap->cat($dn, array("cn", "sn", "givenName", "ou", "description", "objectClass"));
+
+    /* It has failed, add entry with type flag I (Invalid)*/
+    if ($ldap->error != "Success"){
+      $this->memberList[$dn]= array('text' => _("Non existing dn:")." ".@LDAP::fix($dn),"type" => "I");
+    } else {
+      /* Append this entry to our all object list */
+
+      /* Fetch object */
+      $attrs= $ldap->fetch();
+
+      $type= $this->getObjectType($attrs);
+      $name= $this->getObjectName($attrs);
+
+      if (isset($attrs["description"][0])){
+        $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type");
+      } elseif (isset($attrs["uid"][0])) {
+        $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["uid"][0]."]", "type" => "$type");
+      } else {
+        $this->objcache[$attrs["dn"]]= array("text" => "$name", "type" => "$type");
+      }
+      $this->objcache[$attrs["dn"]]['objectClass']  = $attrs['objectClass'];
+      if(isset($attrs['uid'])){
+        $this->objcache[$attrs["dn"]]['uid']          = $attrs['uid'];
+      }
+
+      /* Fill array */
+      if (isset($attrs["description"][0])){
+        $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type");
+      } else {
+        $this->objects[$attrs["dn"]]= array("text" => "$name", "type" => "$type");
+      }
+
+      $this->memberList[$dn]= $this->objects[$attrs["dn"]];
+    }
+  }
+
   function convert_list($input)
   {
     $temp= "";