From 71aafb6fd9652bfbc251c8a9811aca354f4e72a8 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 30 Mar 2010 10:16:13 +0000 Subject: [PATCH] Updated FAI Hook listing git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17389 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-plugins/fai/admin/fai/class_faiHook.inc | 141 ++++++------------ .../fai/admin/fai/class_faiHookEntry.inc | 6 +- .../fai/admin/fai/class_faiScript.inc | 2 + 3 files changed, 48 insertions(+), 101 deletions(-) diff --git a/gosa-plugins/fai/admin/fai/class_faiHook.inc b/gosa-plugins/fai/admin/fai/class_faiHook.inc index e71fc1b85..7a21677a9 100644 --- a/gosa-plugins/fai/admin/fai/class_faiHook.inc +++ b/gosa-plugins/fai/admin/fai/class_faiHook.inc @@ -64,6 +64,31 @@ class faiHook extends plugin $this->is_new =TRUE; } $this->ui = get_userinfo(); + + $this->hookListWidget= new sortableListing($this->convertList(TRUE), $this->convertList()); + $this->hookListWidget->setDeleteable(true); + $this->hookListWidget->setInstantDelete(false); + $this->hookListWidget->setEditable(true); + $this->hookListWidget->setWidth("100%"); + $this->hookListWidget->setHeight("140px"); + $this->hookListWidget->setHeader(array(_("Name"),_("Description"))); + } + + + function convertList($type = FALSE) + { + $data = array(); + $s_acl = $this->ui->get_permissions($this->dn,"fai/faiScriptEntry","FAIscript"); + foreach($this->SubObjects as $cn => $entry){ + if($entry['status'] == "delete") continue; + if($type){ + $data[$cn] = $entry; + }else{ + if(!isset($entry['description'])) $entry['description']=""; + $data[$cn] = array('data' => array($entry['cn'], $entry['description'])); + } + } + return($data); } @@ -142,13 +167,15 @@ class faiHook extends plugin /* New Listhandling */ $once = true; - 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]; + $this->hookListWidget->setAcl($this->getacl("")); + $this->hookListWidget->save_object(); + $action = $this->hookListWidget->getAction(); + + if($action['action'] =="edit"){ + $s_entry = $this->hookListWidget->getKey($action['targets'][0]); + if(isset($this->SubObjects[$s_entry])){ + $obj = $this->SubObjects[$s_entry]; if($obj['status'] == "FreshLoaded"){ $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); } @@ -162,58 +189,26 @@ class faiHook extends plugin $this->dialog->parent = &$this; $this->is_dialog=true; } - if(preg_match("/^deletescript_/",$name)&&($once)){ - $entry = preg_replace("/^deletescript_/","",$name); - $entry = base64_decode(preg_replace("/_.*/","",$entry)); + } - $dn = $this->acl_base_for_current_object($this->SubObjects[$entry]['dn']); + if($action['action'] =="delete"){ + $s_entry = $this->hookListWidget->getKey($action['targets'][0]); + if(isset($this->SubObjects[$s_entry])){ + $dn = $this->acl_base_for_current_object($this->SubObjects[$s_entry]['dn']); $acl = $this->ui -> get_permissions($dn,"fai/faiScriptEntry") ; - if(preg_match("/d/",$acl)){ - $once = false; - - $status = $this->SubObjects[$entry]['status']; + $status = $this->SubObjects[$s_entry]['status']; if($status == "edited" || $status == "FreshLoaded"){ - $this->SubObjects[$entry]['status']= "delete"; + $this->SubObjects[$s_entry]['status']= "delete"; }else{ - unset($this->SubObjects[$entry]); + unset($this->SubObjects[$s_entry]); } } } } - /* File download requested */ - if(isset($_GET['getFAIHook'])){ - if(isset($this->SubObjects[base64_decode($_GET['getFAIHook'])])){ - $obj = $this->SubObjects[base64_decode($_GET['getFAIHook'])]; - $obj = $this->get_object_attributes($obj,$this->sub_Load_Later); - send_binary_content(stripslashes($obj['FAIscript']),$obj['cn'].".FAIhook"); - } - } - - /* Edit entries via GET */ - if(isset($_GET['act']) && isset($_GET['id'])){ - if($_GET['act'] == "edit" && isset($this->SubObjects[base64_decode($_GET['id'])])){ - $obj = $this->SubObjects[base64_decode($_GET['id'])]; - 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->FAIstate = $this->FAIstate; - $this->dialog->acl = $this->acl; - $this->dialog->set_acl_base($this->acl_base_for_current_object($obj['dn'])); - $this->dialog->set_acl_category("fai"); - set_object_info($obj['dn']); - $this->dialog->parent = &$this; - $this->is_dialog=true; - } - } - - ///// Ende new list handling - /* Add new sub object */ if(isset($_POST['AddSubObject'])){ - $c_dn = $this->acl_base_for_current_object($this->dn); $this->dialog= new $this->subClassName($this->config,"new"); $this->dialog->set_acl_base($c_dn); @@ -292,57 +287,9 @@ class faiHook extends plugin return($display); } - - - /* Divlist added 28.02.2006 - Containing FAIscripts - */ - - $divlist = new divSelectBox("FAIhooks"); - $divlist->setHeight(400); - - foreach($this->getList(true) as $key => $name){ - - $dn= $this->acl_base_for_current_object($name['dn']); - $acl = $this->ui->get_permissions($dn,"fai/faiHookEntry") ; - $act = ""; - - /* Check if this object is freezed, in this case hide the delete icon */ - if(preg_match("/^freeze/", $this->FAIstate)){ - $act .= ""; - }else{ - $act .= ""; - if(preg_match("/d/",$acl)){ - $act .=""; - } - } - - /* Check if we are allowed to use the export button for this object */ - $s_acl = $this->ui->get_permissions($dn,"fai/faiHookEntry","FAIscript") ; - if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new") || !preg_match("/r/",$s_acl)){ - $down = ""; - }else{ - $down = " - "._("Download")." - "; - } - - /* Check if we are allowed to view the object */ - $s_acl = $this->ui->get_permissions($dn,"fai/faiHookEntry","cn") ; - if(preg_match("/r/",$s_acl)){ - - $edit_link = "".$name['name'].""; - $divlist->AddEntry(array( array("string"=>$edit_link), - 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;'"))); - } - } - $smarty->assign("Entry_divlist",$divlist->DrawList()); - /* Divlist creation complete - */ - - $smarty->assign("SubObjects",$this->getList()); + $this->hookListWidget->setListData($this->convertList(TRUE), $this->convertList()); + $this->hookListWidget->update(); + $smarty->assign("Entry_divlist",$this->hookListWidget->render()); /* Magic quotes GPC, escapes every ' " \, to solve some security risks * If we post the escaped strings they will be escaped again diff --git a/gosa-plugins/fai/admin/fai/class_faiHookEntry.inc b/gosa-plugins/fai/admin/fai/class_faiHookEntry.inc index 09b5d8dbf..c6003f604 100644 --- a/gosa-plugins/fai/admin/fai/class_faiHookEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiHookEntry.inc @@ -70,15 +70,13 @@ class faiHookEntry extends plugin } /* File download requested */ - if(isset($_GET['getFAIHook'])){ + if(isset($_POST['download'])){ send_binary_content(stripslashes($this->FAIscript),$this->cn.".FAIhook"); } /* Create download button*/ if($this->dn != "new" && $this->acl_is_readable("FAIscript")){ - $smarty->assign("DownMe"," - "._("Download")." - "); + $smarty->assign("DownMe", image('images/save.png', "download")); }else{ $smarty->assign("DownMe",""); } diff --git a/gosa-plugins/fai/admin/fai/class_faiScript.inc b/gosa-plugins/fai/admin/fai/class_faiScript.inc index a20ca37ef..750d1d77c 100644 --- a/gosa-plugins/fai/admin/fai/class_faiScript.inc +++ b/gosa-plugins/fai/admin/fai/class_faiScript.inc @@ -81,6 +81,7 @@ class faiScript extends plugin $this->scriptListWidget->setHeader(array(_("Name"),_("Description"))); } + function convertList($type = FALSE) { $data = array(); @@ -90,6 +91,7 @@ class faiScript extends plugin if($type){ $data[$cn] = $entry; }else{ + if(!isset($entry['description'])) $entry['description']=""; $data[$cn] = array('data' => array($entry['cn'], $entry['description'])); } } -- 2.30.2