Code

Fixed alphabet match
[gosa.git] / gosa-core / include / class_listing.inc
index 1f819c2d213bd9b3d34cd6ac92285aaf30b34afe..095bbfbd720b63935f8841f693f0c6026403df47 100644 (file)
@@ -266,7 +266,7 @@ class listing {
     $result= "<input type='hidden' value='$this->pid' name='PID'>\n";
     $height= 450;
     if ($this->height != 0) {
-      $result= "<input type='hidden' value='$this->height' id='d_height'>\n";
+      $result.= "<input type='hidden' value='$this->height' id='d_height'>\n";
       $height= $this->height;
     }
     
@@ -408,6 +408,7 @@ class listing {
     $result.= "</table></div>";
 
     $smarty= get_smarty();
+    $smarty->assign("usePrototype", "true");
     $smarty->assign("FILTER", $this->filter->render());
     $smarty->assign("SIZELIMIT", print_sizelimit_warning());
     $smarty->assign("LIST", $result);
@@ -467,7 +468,12 @@ class listing {
       if (preg_match('/^export.*$/', $_POST['act']) && isset($this->exporter[$_POST['act']])) {
         $exporter= $this->exporter[$_POST['act']];
         $userinfo= ", "._("created by")." ".$ui->cn." - ".strftime('%A, %d. %B %Y, %H:%M:%S');
-        $instance= new $exporter['class']($this->headline.$userinfo, $this->plainHeader, $this->entries, $this->exportColumns);
+        $entryIterator= new listingSortIterator($this->entries, $this->sortDirection[$this->sortColumn], "_sort".$this->sortColumn, $this->sortType);
+        $sortedEntries= array();
+        foreach ($entryIterator as $entry){
+          $sortedEntries[]= $entry;
+        }
+        $instance= new $exporter['class']($this->headline.$userinfo, $this->plainHeader, $sortedEntries, $this->exportColumns);
         $type= call_user_func(array($exporter['class'], "getInfo"));
         $type= $type[$_POST['act']];
         send_binary_content($instance->query(), $type['filename'], $type= $type['mime']);
@@ -767,9 +773,28 @@ class listing {
     foreach($actions as $action) {
       // Skip the entry completely if there's no permission to execute it
       if (!$this->hasActionPermission($action, $dn)) {
+        $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
         continue;
       }
 
+      // Skip entry if the pseudo filter does not fit
+      if (isset($action['filter']) && preg_match('/^[a-z0-9_]+!?=[a-z0-9_]+$/i', $action['filter'])) {
+        list($fa, $fv)= split('=', $action['filter']);
+        if (preg_match('/^(.*)!$/', $fa, $m)){
+          $fa= $m[1];
+          if (isset($this->entries[$row][$fa]) && $this->entries[$row][$fa][0] == $fv) {
+            $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
+            continue;
+          }
+        } else {
+          if (!isset($this->entries[$row][$fa]) && !$this->entries[$row][$fa][0] == $fv) {
+            $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
+            continue;
+          }
+        }
+      }
+
+
       // If there's an objectclass definition and we don't have it
       // add an empty picture here.
       if (isset($action['objectclass'])){
@@ -991,10 +1016,15 @@ class listing {
       return "";
     }
 
+    // Array?
+    if (isset($this->xmlData['actionmenu']['action']['type'])){
+      $this->xmlData['actionmenu']['action']= array($this->xmlData['actionmenu']['action']);
+    }
+
     // Load shortcut
     $actions= &$this->xmlData['actionmenu']['action'];
     $result= "<input type='hidden' name='act' id='actionmenu' value=''><div style='display:none'><input type='submit' name='exec_act' id='exec_act' value=''></div>".
-             "<ul class='level1' id='root'><li><a href='#'>Aktionen&nbsp;<img ".
+             "<ul class='level1' id='root'><li><a href='#'>"._("Actions")."&nbsp;<img ".
              "border=0 class='center' src='images/lists/sort-down.png'></a>";
 
     // Build ul/li list
@@ -1006,6 +1036,7 @@ class listing {
 
   function recurseActions($actions)
   {
+    global $class_mapping;
     static $level= 2;
     $result= "<ul class='level$level'>";
     $separator= "";
@@ -1017,6 +1048,16 @@ class listing {
         continue;
       }
 
+      // Skip entry if there're missing dependencies
+      if (isset($action['depends'])) {
+        $deps= is_array($action['depends'])?$action['depends']:array($action['depends']);
+        foreach($deps as $clazz) {
+          if (!isset($class_mapping[$clazz])){
+            continue 2;
+          }
+        }
+      }
+
       // Fill image if set
       $img= "";
       if (isset($action['image'])){