Code

* Fixed undefined index for "All"
[gosa.git] / plugins / admin / fai / class_askClassName.inc
index a5bddcd7f4b0987a597b0e1195cdedf62fe3add4..3486cc3c4de40883a99da6dbfc1d718d39810c97 100644 (file)
@@ -22,12 +22,15 @@ class askClassName extends plugin
     $this->ui = $ui;
     $this->objectClass = $objectClass;
     plugin::plugin ($config, $dn);
+    if(!isset($_SESSION['CurrentMainBase'])){
+      $_SESSION['CurrentMainBase'] = $this->config->current['BASE'];
+    }
   }
 
   function execute()
   {
-       /* Call parent execute */
-       plugin::execute();
+    /* Call parent execute */
+    plugin::execute();
 
     /* Fill templating stuff */
     $smarty = get_smarty();
@@ -42,23 +45,27 @@ class askClassName extends plugin
      * With a second search detect all object that belong to the different ous. 
      */
 
-    $bb ="";
+    $base = "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase'];
     if($faifilter['branch'] != "main"){
-      $bb = "ou=".$faifilter['branch'].",";
+      $base = $faifilter['branch'];
     }
-    $base = $bb."ou=fai,ou=configs,ou=systems,".$faifilter['base'];
     $ldap = $this->config->get_ldap_link();
-    $res  = get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)",FALSE, $base, array("cn","description","objectClass"),TRUE);
-    $used = array();
+    
+    $res= get_list("(&(objectClass=organizationalUnit)(!(objectClass=FAIbranch)))", "fai", $base,
+                   array("cn","description","objectClass"), GL_SIZELIMIT );
 
     $delete = array();
+    $used   = array();
     foreach($res as $objecttypes){
-      $res2 = get_list2($this->ui->subtreeACL, "(objectClass=*)",
-          FALSE, $objecttypes['dn'], array("cn","description","objectClass","FAIclass"),TRUE);
-
+      $res2= get_list("(objectClass=*)", "fai", $objecttypes['dn'],
+                      array("cn","description","objectClass","FAIclass","FAIstate"), GL_SIZELIMIT | GL_CONVERT );
       foreach($res2 as $object){
+
         /* skip class names with this name */ 
         if(in_array($this->objectClass,$object['objectClass'])){
+          if(isset($object['FAIstate'][0]) && preg_match("/removed$/",$object['FAIstate'][0])){
+            continue;
+          }
           $delete[] = $object['cn'][0];
         }
     
@@ -70,7 +77,7 @@ class askClassName extends plugin
         }
       }
     }
-    
+
     /* Create headline
      * Depending on the object type we want to create, a different headline will be shown
      */ 
@@ -107,7 +114,7 @@ class askClassName extends plugin
       $smarty->assign("grey", "");
     }
     $smarty->assign("ClassNames", $used);
-    $smarty->assign("ClassNameKeys", $used);
+    $smarty->assign("ClassName",  $this->ClassName);
     $display.= $smarty->fetch(get_template_path('askClassName.tpl', TRUE));
     return($display);
   }
@@ -133,7 +140,13 @@ class askClassName extends plugin
    */
   function check()
   {
-    $message= array();
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+  
+    if($this->ClassName != preg_replace("/ /","",trim($this->ClassName))){
+      $message[] = _("Spaces are not allowed within class names.");
+    }
+
     if(empty($this->ClassName)){
       $message[]=_("The given class name is empty.");
     }