X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Ffai%2Fclass_faiScript.inc;h=ac945d890fedffa402ae1542b5017aa9546b303a;hb=793fbb375529a5b60d733fd587d51ab96da989a5;hp=e70a404564d2f63b0c524e9b89ea5f26a9b6f7ec;hpb=d71f6f636232cf977dacefd8336844f4423d98a8;p=gosa.git
diff --git a/plugins/admin/fai/class_faiScript.inc b/plugins/admin/fai/class_faiScript.inc
index e70a40456..ac945d890 100644
--- a/plugins/admin/fai/class_faiScript.inc
+++ b/plugins/admin/fai/class_faiScript.inc
@@ -2,11 +2,6 @@
class faiScript extends plugin
{
- /* CLI vars */
- var $cli_summary = "Manage server basic objects";
- var $cli_description = "Some longer text\nfor help";
- var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
/* attribute list for save action */
var $ignore_account = TRUE;
@@ -36,12 +31,15 @@ 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 $base ="";
var $release ="";
var $copy_paste_mode = false;
- var $CopyPasteVars = array("SubObjects","FAIstate");
+ var $cut_paste_mode = false;
+ var $CopyPasteVars = array("SubObjects");
function faiScript ($config, $dn= NULL)
@@ -135,6 +133,7 @@ class faiScript extends plugin
if(isset($_POST['AddSubObject'])){
$this->dialog= new $this->subClassName($this->config,"new");
$this->dialog->acl = $this->acl;
+ $this->dialog->parent = &$this;
$this->is_dialog=true;
}
@@ -142,41 +141,61 @@ class faiScript extends plugin
$_SESSION['objectinfo']= $this->dn;
}
-
- /* New Listhandling
- */
- $once = true;
+ /* Handle posts */
+ $s_action = $s_entry = "";
foreach($_POST as $name => $value){
- if(preg_match("/^editscript_/",$name)&&($once)){
- $once = false;
- $entry = preg_replace("/^editscript_/","",$name);
- $entry = base64_decode(preg_replace("/_.*/","",$entry));
-
- $obj = $this->SubObjects[$entry];
- if($obj['status'] == "FreshLoaded"){
- $obj = $this->get_object_attributes($obj,$this->sub_Load_Later);
- }
- $this->dialog= new $this->subClassName($this->config,$this->dn,$obj);
- $this->dialog->acl = $this->acl;
- $_SESSION['objectinfo'] = $obj['dn'];
- $this->dialog->parent = &$this;
- $this->is_dialog=true;
+ /* Edit script posted */
+ if(preg_match("/^editscript_/",$name)){
+ $s_action = "edit";
+ $s_entry = preg_replace("/^editscript_/","",$name);
+ $s_entry = base64_decode(preg_replace("/_.*/","",$s_entry));
+ break;
+ }
+ /* Delete script requested */
+ if(preg_match("/^deletescript_/",$name)){
+ $s_action = "remove";
+ $s_entry = preg_replace("/^deletescript_/","",$name);
+ $s_entry = base64_decode(preg_replace("/_.*/","",$s_entry));
+ break;
}
- if(preg_match("/^deletescript_/",$name)&&($once)){
- $once = false;
- $entry = preg_replace("/^deletescript_/","",$name);
- $entry = base64_decode(preg_replace("/_.*/","",$entry));
-
- $status = $this->SubObjects[$entry]['status'];
- if($status == "edited" || $status == "FreshLoaded"){
- $this->SubObjects[$entry]['status']= "delete";
- }else{
- unset($this->SubObjects[$entry]);
- }
+ }
+
+ if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){
+ $s_entry = $_GET['id'];
+ if(isset($this->SubObjects[$s_entry])){
+ $s_action = "edit";
}
}
+
+ if($s_action =="edit" && isset($this->SubObjects[$s_entry])){
+
+ /* Get object, and load missing entry values */
+ $obj = $this->SubObjects[$s_entry];
+ if($obj['status'] == "FreshLoaded"){
+ $obj = $this->get_object_attributes($obj,$this->sub_Load_Later);
+ }
+
+ /* Create new dialog and set acl attributes */
+ $this->dialog= new $this->subClassName($this->config,$this->dn,$obj);
+ $this->dialog->acl = $this->acl;
+ $_SESSION['objectinfo'] = $obj['dn'];
+ $this->dialog->parent = &$this;
+ $this->is_dialog=true;
+ }
+
+ /* Check acls, are we allowed to delete an entry */
+ if($s_action == "remove" && isset($this->SubObjects[$s_entry])){
+ $entry = $this->SubObjects[$s_entry];
+ $status = $entry['status'];
+ if($status == "edited" || $status == "FreshLoaded"){
+ $this->SubObjects[$s_entry]['status']= "delete";
+ }else{
+ unset($this->SubObjects[$s_entry]);
+ }
+ }
+
///// Ende new list handling
if(isset($_POST['SaveSubObject'])){
$this->dialog->save_object();
@@ -216,11 +235,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;
@@ -242,8 +274,35 @@ class faiScript extends plugin
/* Divlist added 23.02.2006
Containing FAIscripts
*/
- $divlist = new divSelectBox("FAIscripts");
- $divlist->setHeight(400);
+ $divlist = new divlist("FAIscripts");
+ $divlist -> SetEntriesPerPage(0);
+ $plug = $_GET['plug'];
+
+ if($this->sort_order == "up"){
+ $dir = "";
+ }else{
+ $dir = "";
+ }
+
+ if($this->sort_by == "name"){
+ $sort_name = $dir;
+ $sort_prio = "";
+ }else{
+ $sort_name = "";
+ $sort_prio = $dir;
+ }
+
+ $divlist->SetHeader(array(
+ array("string"=>""._("Name").$sort_name.""),
+ array("string"=>"".$sort_prio._("Priority")."",
+ "attach" => "style='width:100px;'"),
+ array("string"=>_("Download"),
+ "attach" => "style='width:100px;'"),
+ array("string"=>_("Action"),
+ "attach"=>"style='border-right: 0px;width:100px;text-align:right;'")));
+ $divlist->SetHeight(300);
+ $divlist->SetWidth("100%");
+
if((chkacl($this->acl,"cn")!="") || ($this->FAIstate == "freeze")){
$img_edit = "";
$img_remo = "";
@@ -262,10 +321,11 @@ class faiScript extends plugin
";
}
- $divlist->AddEntry(array( array("string"=>$name['name']),
- array("string"=>$down , "attach" => "style='width:20px;'"),
+ $divlist->AddEntry(array( array("string"=>"".$name['name'].""),
+ array("string"=>$name['FAIpriority'] , "attach" => "style='width:100px;'"),
+ array("string"=>$down , "attach" => "style='width:100px;'"),
array("string"=>str_replace("%s",base64_encode($key),$img_edit.$img_remo),
- "attach"=>"style='border-right: 0px;width:50px;text-align:right;'")));
+ "attach"=>"style='border-right: 0px;width:100px;text-align:right;'")));
}
$smarty->assign("Entry_divlist",$divlist->DrawList());
@@ -301,6 +361,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'])."]";
@@ -337,6 +398,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'];
+ }
}
@@ -347,7 +420,7 @@ class faiScript extends plugin
$message= plugin::check();
/* If this is a new script, check if a script with this name already exists */
- if(!empty($this->release) && $this->copy_paste_mode){
+ if(!empty($this->release) && ($this->copy_paste_mode || $this->cut_paste_mode) ){
/* Check if current name is already used for fai scripts in selected release */
$dn = 'cn='.$this->cn.",ou=scripts,".$this->release;