From 43b49db42c4a2e24e69f8bfc8fae9e80a5e1d8dc Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 6 Aug 2007 07:09:57 +0000 Subject: [PATCH] Added sorting to FAIscripts git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6963 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_divlist.inc | 17 ++++++---- plugins/admin/fai/class_faiScript.inc | 48 +++++++++++++++++++++++---- plugins/admin/fai/faiScript.tpl | 2 -- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/include/class_divlist.inc b/include/class_divlist.inc index cd12a5ebd..2c28bc7cf 100644 --- a/include/class_divlist.inc +++ b/include/class_divlist.inc @@ -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.= ""; } else { $s_return.= "
"; } @@ -105,9 +108,9 @@ class divlist { // Using scrolltable? if($this->i_entriesPerPage == 0) { if(!$this->force_height) { - $s_return.= "\n
"; + $s_return.= "\n
"; } else { - $s_return.= "\n
"; + $s_return.= "\n
"; } } @@ -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
"; + $s_return .= "\n
"; $s_return .= ""; } else { - $s_return .= "\n
"; + $s_return .= "\n
"; $s_return .= ""; } } diff --git a/plugins/admin/fai/class_faiScript.inc b/plugins/admin/fai/class_faiScript.inc index 72f2d2009..cdefc1929 100644 --- a/plugins/admin/fai/class_faiScript.inc +++ b/plugins/admin/fai/class_faiScript.inc @@ -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"=>""._("Name").""), + array("string"=>""._("Priority").""), + 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']; + } } diff --git a/plugins/admin/fai/faiScript.tpl b/plugins/admin/fai/faiScript.tpl index acb0d135c..093e8b5f7 100644 --- a/plugins/admin/fai/faiScript.tpl +++ b/plugins/admin/fai/faiScript.tpl @@ -36,9 +36,7 @@

  -

-- 2.30.2