Code

Fixed some errors if mysql is not available
[gosa.git] / plugins / admin / fai / class_faiTemplate.inc
index ed4eb8a8212ffb4f3983c9227d389c744842ff4e..cfe0f41e8e5cb1c9f9e732c3029fa0c8236f7f87 100644 (file)
@@ -72,7 +72,6 @@ class faiTemplate extends plugin
         $this->SubObjects[$object['cn'][0]]['status']= "edited";
         $this->SubObjects[$object['cn'][0]]['dn']= $object['dn'];
       }
-      ksort($this->SubObjects);
     }
   }
 
@@ -91,20 +90,29 @@ class faiTemplate extends plugin
       $this->is_dialog=true;
     }
 
-    $_SESSION['objectinfo'] = $this->dn;
+    if($this->dn != "new"){
+      $_SESSION['objectinfo']= $this->dn;
+    }
+
+
     /* Edit selected Sub Object */
     if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){
-      $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$_POST['SubObject']]);
-      $_SESSION['objectinfo'] = $this->SubObjects[$_POST['SubObject']]['dn'];
+
+      $temp = $_POST['SubObject'][0];
+    
+      $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$temp]);
+      $_SESSION['objectinfo'] = $this->SubObjects[$temp]['dn'];
       $this->is_dialog=true;
     }
     
     /* Remove Sub object */
     if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){
-      if($this->SubObjects[$_POST['SubObject']]['status'] == "edited"){
-        $this->SubObjects[$_POST['SubObject']]['status']= "delete";
-      }else{
-        unset($this->SubObjects[$_POST['SubObject']]);
+      foreach($_POST['SubObject'] as $temp){
+        if($this->SubObjects[$temp]['status'] == "edited"){
+          $this->SubObjects[$temp]['status']= "delete";
+        }else{
+          unset($this->SubObjects[$temp]);
+        }
       }
     }
 
@@ -133,10 +141,20 @@ class faiTemplate extends plugin
         $this->is_dialog=false;
         unset($this->dialog);
         $this->dialog=NULL;
-        ksort($this->SubObjects);
       }
     }
 
+    /* Sort entries */
+    $tmp = $keys = array();
+    foreach($this->SubObjects as $key => $entry){
+      $keys[$key]=$key;
+    }
+    natcasesort($keys);
+    foreach($keys as $key){
+      $tmp[$key]=$this->SubObjects[$key];
+    }
+    $this->SubObjects = $tmp;
+
     /* Cancel Dialog */
     if(isset($_POST['CancelSubObject'])){
       $this->is_dialog=false; 
@@ -176,7 +194,11 @@ class faiTemplate extends plugin
     $a_return=array();
     foreach($this->SubObjects as $obj){
       if($obj['status'] != "delete"){
+      
         if((isset($obj['description']))&&(!empty($obj['description']))){
+          if(strlen($obj['description']) > 40){
+            $obj['description'] = substr($obj['description'],0,40)."...";
+          }
           $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]";
         }else{
           $a_return[$obj['cn']]= $obj['cn'];