Code

Added sorting to FAIscripts
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 6 Aug 2007 07:09:57 +0000 (07:09 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 6 Aug 2007 07:09:57 +0000 (07:09 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6963 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_divlist.inc
plugins/admin/fai/class_faiScript.inc
plugins/admin/fai/faiScript.tpl

index cd12a5ebdf206bce265b25f4900e6dc206bd33eb..2c28bc7cfa37525ec75cbddcefd96ffaff19c502 100644 (file)
@@ -24,7 +24,7 @@ class divlist {
                $this->i_currentPage    = 0;
                $this->i_entriesPerPage = 10;
     $this->s_height         = "450";
-    $this->s_width          = "600";
+    $this->s_width          = "600px";
                $this->s_summary        = "";
                $this->a_entries        = array();
                $this->a_header         = array();
@@ -56,6 +56,9 @@ class divlist {
   
   function SetWidth($s_width) {
                $this->s_width= $s_width;
+    if(preg_match("/^[0-9]*$/",$this->s_width)){
+      $this->s_width .="px";
+    }
        }
 
        function SetEntriesPerPage($i_num){
@@ -66,11 +69,11 @@ class divlist {
                $s_return = "";
     if(!$this->force_height){
                  $s_return.= "<table summary='".$this->s_summary."' style='width:".
-                  $this->s_width."px;height:".$this->s_height.
+                  $this->s_width.";height:".$this->s_height.
                   "px;' cellspacing='0' id='t_scrolltable'>";
     } else {
                  $s_return.= "<table summary='".$this->s_summary."' style='width:".
-                  $this->s_width."px;height:".$this->s_height.
+                  $this->s_width.";height:".$this->s_height.
                   "px;' cellspacing='0' id='t_scrolltable_onlywidth'>";
     }
 
@@ -105,9 +108,9 @@ class divlist {
     // Using scrolltable?
     if($this->i_entriesPerPage == 0) {
       if(!$this->force_height) {
-        $s_return.= "\n<tr><td class='scrollhead'><table summary='' style='width:".$this->s_width."px;' cellspacing='0' id='t_scrollhead'>";
+        $s_return.= "\n<tr><td class='scrollhead'><table summary='' style='width:".$this->s_width.";' cellspacing='0' id='t_scrollhead'>";
       } else {
-        $s_return.= "\n<tr><td class='scrollhead'><table summary='' style='width:".$this->s_width."px;' cellspacing='0' id='t_scrollhead_onlywidth'>";
+        $s_return.= "\n<tr><td class='scrollhead'><table summary='' style='width:".$this->s_width.";' cellspacing='0' id='t_scrollhead_onlywidth'>";
       }
     }
 
@@ -149,10 +152,10 @@ class divlist {
     if($this->i_entriesPerPage == 0) {
       // We need to construct a "body"-table that is width-of-scrollbar thinner than the "head"-table.
       if(!$this->force_height) {
-        $s_return .= "\n<tr><td colspan='".$this->cols."' class='scrollbody'><div style='width:".$this->s_width."px;height:".($this->s_height-20)."px;' id='d_scrollbody' class='scrollbody'>";
+        $s_return .= "\n<tr><td colspan='".$this->cols."' class='scrollbody'><div style='width:".$this->s_width.";height:".($this->s_height-20)."px;' id='d_scrollbody' class='scrollbody'>";
         $s_return .= "<table summary='' style='height:100%;width:581px;' cellspacing='0' id='t_scrollbody'>";
       } else {
-        $s_return .= "\n<tr><td colspan='".$this->cols."' class='scrollbody'><div style='width:".$this->s_width."px;height:".($this->s_height-20)."px;' id='d_scrollbody_onlywidth' class='scrollbody'>";
+        $s_return .= "\n<tr><td colspan='".$this->cols."' class='scrollbody'><div style='width:".$this->s_width.";height:".($this->s_height-20)."px;' id='d_scrollbody_onlywidth' class='scrollbody'>";
         $s_return .= "<table summary='' style='height:100%;width:581px;' cellspacing='0' id='t_scrollbody_onlywidth'>";
       }
        }
index 72f2d200960839c07a626ddff540f3ac68a8d5e3..cdefc192922144b83ae456ebf663c3feae93d540 100644 (file)
@@ -36,7 +36,9 @@ class faiScript extends plugin
   var $dialog           = NULL;     // a dialog, e.g. new disk dialog
   var $SubObjects       = array();  // All leafobjects of this object
 
-  var $FAIstate         ="";
+  var $FAIstate         = "";
+  var $sort_by          = "name";
+  var $sort_order       = "up";
 
   var $view_logged = FALSE;
   var $ui;
@@ -263,11 +265,24 @@ class faiScript extends plugin
 
     /* Sort entries */
     $tmp = $keys = array();
-    foreach($this->SubObjects as $key => $entry){
-      $keys[$key]=$key;
+
+    if($this->sort_by == "name"){
+      foreach($this->SubObjects as $key => $entry){
+        $keys[$key]=$entry['cn'];
+      }
+    }elseif($this->sort_by == "priority"){
+      foreach($this->SubObjects as $key => $entry){
+        $keys[$key]=$entry['FAIpriority'];
+      }
     }
+
     natcasesort($keys);
-    foreach($keys as $key){
+
+    if($this->sort_order == "down"){
+      $keys =array_reverse($keys);
+    }
+
+    foreach($keys as $key => $order_var){
       $tmp[$key]=$this->SubObjects[$key];
     }
     $this->SubObjects = $tmp;
@@ -289,8 +304,15 @@ class faiScript extends plugin
     /* Divlist            added 23.02.2006 
        Containing FAIscripts 
      */
-    $divlist = new divSelectBox("FAIscripts");
-    $divlist->setHeight(400);
+    $divlist = new divlist("FAIscripts");
+    $plug = $_GET['plug'];
+    
+    $divlist->SetHeader(array(  array("string"=>"<a href='?plug=".$plug."&amp;sort=name'>"._("Name")."</a>"),
+                                array("string"=>"<a href='?plug=".$plug."&amp;sort=priority'>"._("Priority")."</a>"),
+                                array("string"=>_("Download")),
+                                array("string"=>_("Action"))));
+    $divlist->SetHeight(300);
+    $divlist->SetWidth("100%");
     foreach($this->getList(true) as $key => $name){
 
       $dn= $this->acl_base_for_current_object($name['dn']);
@@ -321,6 +343,7 @@ class faiScript extends plugin
       $s_acl = $this->ui->get_permissions($dn,"fai/faiScriptEntry","cn")  ;
       if(preg_match("/r/",$s_acl)){
         $divlist->AddEntry(array( array("string"=>$name['name']),
+              array("string"=>$name['FAIpriority'] , "attach" => "style='width:20px;'"),
               array("string"=>$down , "attach" => "style='width:20px;'"),
               array("string"=>str_replace("%s",base64_encode($key),$act),
                 "attach"=>"style='border-right: 0px;width:50px;text-align:right;'")));
@@ -367,6 +390,7 @@ class faiScript extends plugin
             $a_return[$obj['cn']]['name']= $obj['cn'];
           }
           $a_return[$obj['cn']]['dn']= $obj['dn'];
+          $a_return[$obj['cn']]['FAIpriority']= $obj['FAIpriority'];
         }else{
           if((isset($obj['description']))&&(!empty($obj['description']))){
             $a_return[$obj['cn']]= $obj['cn']." [".stripslashes($obj['description'])."]";
@@ -420,6 +444,18 @@ class faiScript extends plugin
         }
       }
     }
+    
+    /* Get sort order */
+    if(isset($_GET['sort']) && in_array($_GET['sort'],array("name","priority"))){
+      if($this->sort_by == $_GET['sort']){
+        if($this->sort_order == "up"){
+          $this->sort_order = "down";
+        }elseif($this->sort_order == "down"){
+          $this->sort_order = "up";
+        }
+      }
+      $this->sort_by = $_GET['sort'];
+    }
   }
 
 
index acb0d135c69a8910866afaa0c13ae163c292ee31..093e8b5f76df2132bca228a5478c32ba47fabc9b 100644 (file)
@@ -36,9 +36,7 @@
        <tr>
                <td>
                                <h2><img class="center" alt="" src="images/fai_script.png" align="middle" title="{t}Objects{/t}">&nbsp;
-                                       <LABEL for="SubObject">
                                                {t}List of scripts{/t}
-                                       </LABEL>
                                </h2>
                                <table width="100%" summary="">
                                <tr>