Code

dded a script to generate the pdf from the online manual
[gosa.git] / include / class_ldap.inc
index c4768ee776ecbc1ad26f93240366e4c5fb621056..49ae221547f322c620710745d3765e2d54bc7307 100644 (file)
@@ -562,12 +562,15 @@ class LDAP{
               print_red(_("Unknown FAIstate %s"),$type);
             }
           }elseif(in_array("gosaApplication",$attr['objectClass'])){
-            $attr['objectClass'][] = "FAIobject";
+            if(!in_array("FAIobject",$attr['objectClass'])){
+              $attr['objectClass'][] = "FAIobject";
+            }
             $attr['FAIstate'] = $type;
           }
 
           /* Replace FAIdebianRelease with new release name */
           if(in_array("FAIpackageList" , $attr['objectClass'])){
+            $attr['FAIdebianRelease'] = $destinationName;
             if($type=="branch"){
               $attr['FAIstate'] ="branch";
             }elseif($type=="freeze"){
@@ -597,6 +600,8 @@ class LDAP{
         }
       }
 
+      echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
+
       $this->ls ("(objectClass=*)",$sourcedn);
       while ($this->fetch()){
         $deldn= $this->getDN();
@@ -663,7 +668,13 @@ class LDAP{
     }
 
     $real_path= substr($target, 0, strlen($target) - strlen($this->basedn) -1 );
-    $l= array_reverse(ldap_explode_dn($real_path,0));
+    $tmp = ldap_explode_dn($real_path,0);
+    if(!$tmp){
+      print_red(sprintf(_("The referral url '%s' is missing the ldap base. It should look like this 'ldap://server:port/base'."),$this->fix($this->basedn)));
+      return;
+    }
+
+    $l= array_reverse($tmp);
     unset($l['count']);
     $cdn= $this->basedn;
     $tag= "";
@@ -1127,10 +1138,13 @@ function gen_xls ($dn, $filter= "(objectClass=*)", $attributes= array('*'), $rec
          $objectclasses = array();
        
          # Get base to look for schema 
-         $sr = @ldap_read ($this->cid, NULL, "objectClass=*", array("subschemaSubentry"));
-         $attr = @ldap_get_entries($this->cid,$sr);
+         $sr           = @ldap_read ($this->cid, NULL, "objectClass=*", array("subschemaSubentry"));
+         $attr         = @ldap_get_entries($this->cid,$sr);
+
          if (!isset($attr[0]['subschemasubentry'][0])){
-           return array();
+      $this->error  = @ldap_error($this->cid);
+      gosa_log($this->get_error());
+      return array();
          }
        
          # Get list of objectclasses
@@ -1154,11 +1168,27 @@ 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);
+      }
     }
   }
+  
+  /* added by Guido Serra aka Zeph <zeph@purotesto.it> */
+  function getCn($dn){
+    $simple= split(",", $dn);
+
+    foreach($simple as $piece) {
+      $partial= split("=", $piece);
+
+      if($partial[0] == "cn"){
+        return $partial[1];
+      }
+    }
+
+  }
 
 
 }