Code

Added modified menu templates, removed unused templates
[gosa.git] / include / class_ldap.inc
index 5da63f53488d8b7fadb53364fb27bb5b4e9afbc7..17ae13ff4071b267c4f606dbe63bf5e69bfc1197 100644 (file)
@@ -445,7 +445,7 @@ class LDAP{
   */
   function copy_FAI_resource_recursive($sourcedn,$destinationdn,$destinationName,$type="branch",$is_first = true,$depth=0)
   {
-    error_reporting(E_ALL);
+    error_reporting(E_ALL | E_STRICT);
     
     if($is_first){
       echo "<h2>".sprintf(_("Creating copy of %s"),"<i>".@LDAP::fix($sourcedn)."</i>")."</h2>";
@@ -573,7 +573,7 @@ class LDAP{
           }
 
           if($this->error != "Success"){
-            /* Some error occured */
+            /* Some error occurred */
             print "---------------------------------------------";
             print $this->get_error()."<br>";
             print $sourcedn."<br>";
@@ -659,7 +659,7 @@ class LDAP{
     $classes= $this->get_objectclasses();
 
     foreach ($l as $part){
-      if ($party != "dummy"){
+      if ($part != "dummy"){
         $cdn= "$part,$cdn";
       }
 
@@ -772,9 +772,15 @@ class LDAP{
         }
         $this->cd($cdn);
         $this->add($na);
+    
         show_ldap_error($this->get_error(), sprintf(_("Creating subtree '%s' failed."),$cdn));
+        if (!preg_match('/success/i', $this->error)){
+          return FALSE;
+        }
       }
     }
+
+    return TRUE;
   }
 
 
@@ -851,7 +857,7 @@ class LDAP{
     $url= preg_replace('!\?\?.*$!', '', $url);
     $server= preg_replace('!^([^:]+://[^/]+)/.*$!', '\\1', $url);
 
-    if ($referrals == NULL){
+    if ($referrals === NULL){
       $referrals= $this->referrals;
     }
 
@@ -1106,6 +1112,13 @@ class LDAP{
   */
   function import_single_entry($str_attr,$modify,$delete)
   {
+    global $config;
+
+    if(!$config){
+      trigger_error("Can't import ldif, can't read config object.");
+    }
+  
+
     if($this->reconnect) $this->connect();
 
     $ret = false;
@@ -1183,7 +1196,8 @@ class LDAP{
      
       /* Create missing trees */
       $this->cd ($this->basedn);
-      $this->create_missing_trees($data['dn']);
+      $this->cd($config->current['BASE']);
+      $this->create_missing_trees(preg_replace("/^[^,]+,/","",$data['dn']));
       $this->cd($data['dn']);
 
       $dn = $data['dn'];
@@ -1248,7 +1262,15 @@ class LDAP{
   function get_objectclasses()
   {
     $objectclasses = array();
-       
+    global $config;
+
+    /* Only read schema if it is allowed */
+    if(isset($config) && preg_match("/config/i",get_class($config))){
+      if(!isset($config->data['MAIN']['SCHEMA_CHECK']) || !preg_match("/true/i",$config->data['MAIN']['SCHEMA_CHECK'])){
+        return($objectclasses);
+      } 
+    }
+       
          # Get base to look for schema 
          $sr = @ldap_read ($this->cid, NULL, "objectClass=*", array("subschemaSubentry"));
     if(!$sr){
@@ -1311,7 +1333,6 @@ class LDAP{
       }
 
          }
-
          return $objectclasses;
   }
 
@@ -1373,9 +1394,9 @@ class LDAP{
     $r= ldap_bind ($ds, $admin, $password);
 
     /* Get base to look for naming contexts */
-    $sr  = @ldap_read ($ds, "", "objectClass=*", array("namingContexts", ));
+    $sr  = @ldap_read ($ds, "", "objectClass=*", array("+"));
     $attr= @ldap_get_entries($ds,$sr);
-    
+
     return ($attr[0]['namingcontexts']);
   }
 
@@ -1394,9 +1415,19 @@ class LDAP{
     $sr  = @ldap_read ($ds, "", "objectClass=*", array("+"));
     $attr= @ldap_get_entries($ds,$sr);
    
-    print_a($attr); 
+    /* Return empty array, if nothing was set */
+    if (!isset($attr[0])){
+      return array();
+    }
+
+    /* Rework array... */
+    $result= array();
+    for ($i= 0; $i<$attr[0]['count']; $i++){
+      $result[$attr[0][$i]]= $attr[0][$attr[0][$i]];
+      unset($result[$attr[0][$i]]['count']);
+    }
 
-    return ($attr);
+    return ($result);
   }