Code

Fixed typo
[gosa.git] / gosa-core / include / class_sortableListing.inc
index b0539c2029bdd44afafb947aade2339d0eff0466..cbb2334586a8d0cb5e27c269ff11c1dbef1b361d 100644 (file)
@@ -100,8 +100,12 @@ class sortableListing {
 
     // Transfer information
     $this->displayData= array();
+    $this->modes= array();
     foreach ($data as $key => $value) {
       $this->displayData[]= $value['data'];
+      if (isset($value['mode'])) {
+        $this->modes[]= $value['mode'];
+      }
     }
     $this->keys= array_keys($data);
 
@@ -182,7 +186,7 @@ class sortableListing {
   public function render()
   {
     $result= "<div class='sortableListContainer' id='scroll_".$this->id."' style='min-width:".$this->width.";height: ".$this->height."'>\n";
-    $result.= "<table border='0' cellpadding='0' cellspacing='0' width='100%' height='100%' ".(!empty($this->cssclass)?" class='".$this->cssclass."'":"").">\n";
+    $result.= "<table summary='"._("Sortable list")."' border='0' cellpadding='0' cellspacing='0' width='100%' style='width:100%' ".(!empty($this->cssclass)?" class='".$this->cssclass."'":"").">\n";
     $action_width= 0;
     if (strpos($this->acl, 'w') === false) {
       $edit_image= $this->editable?"<img class='center' src='images/lists/edit-grey.png' alt='"._("Edit")."'>":"";
@@ -200,12 +204,16 @@ class sortableListing {
     if ($this->colspecs) {
       $result.= " <colgroup>\n";
       for ($i= 0; $i<$this->columns; $i++) {
-        $result.= "  <col style='width:".(isset($this->colspecs[$i])?$this->colspecs[$i]:"*")."'/>\n";
+        if(isset($this->colspecs[$i]) && $this->colspecs[$i] != '*'){
+          $result.= "  <col style='width:".($this->colspecs[$i])."'>\n";
+        }else{
+          $result.= "  <col>\n";
+        }
       }
 
       // Extend by another column if we've actions specified
       if ($action_width) {
-        $result.= "  <col style='width:".$action_width."px'/>\n";
+        $result.= "  <col style='width:".$action_width."px' >\n";
       }
       $result.= " </colgroup>\n";
     }
@@ -246,7 +254,7 @@ class sortableListing {
           switch ($this->modes[$row]) {
             case LIST_DISABLED:
               $id= " sortableListItemDisabled";
-              $editable= false;
+              $editable= "";
               break;
             case LIST_MARKED:
               $id= " sortableListItemMarked";
@@ -361,11 +369,22 @@ class sortableListing {
     }
 
     // Delete requested?
+    $this->action = "";
     if (strpos($this->acl, 'd') !== false){
       foreach ($_POST as $key => $value) {
         if (preg_match('/^del_'.$this->id.'_([0-9]+)_x.*$/', $key, $matches)) {
           $this->active_index= $this->mapping[$matches[1]];
+
+          // Ignore request if mode requests it
+          if (isset($this->modes[$this->active_index]) && $this->modes[$this->active_index] == LIST_DISABLED) {
+            $this->active_index= null;
+            continue;
+          }
+
+          // Set action
           $this->action= "delete";
+
+          // Remove value if requested
           if ($this->instantDelete) {
             $this->deleteEntry($this->active_index);
           }
@@ -378,6 +397,13 @@ class sortableListing {
       foreach ($_POST as $key => $value) {
         if (preg_match('/^edit_'.$this->id.'_([0-9]+)_x.*$/', $key, $matches)) {
           $this->active_index= $this->mapping[$matches[1]];
+
+          // Ignore request if mode requests it
+          if (isset($this->modes[$this->active_index]) && $this->modes[$this->active_index] == LIST_DISABLED) {
+            $this->active_index= null;
+            continue;
+          }
+
           $this->action= "edit";
         }
       }