From: hickert
Date: Wed, 22 Aug 2007 07:49:18 +0000 (+0000)
Subject: Updated gotomasses to supprt multiple actions
X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3d75206cebce18e654826a7159f8c07df1fe89cb;p=gosa.git
Updated gotomasses to supprt multiple actions
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7095 594d385d-05f5-0310-b6e9-bd551577e9d8
---
diff --git a/plugins/addons/gotomasses/class_gotomasses.inc b/plugins/addons/gotomasses/class_gotomasses.inc
index dc2bb580e..540e0d9f7 100644
--- a/plugins/addons/gotomasses/class_gotomasses.inc
+++ b/plugins/addons/gotomasses/class_gotomasses.inc
@@ -17,6 +17,7 @@ class gotomasses extends plugin
var $tasks = array();
var $current =false;
var $dialog = FALSE;
+ var $ids_to_remove = array();
function gotomasses($config, $dn= NULL)
{
@@ -37,7 +38,8 @@ class gotomasses extends plugin
************/
$s_entry = $s_action = "";
- $arr = array("/^edit_task_/"=>"edit","/^remove_task_/"=>"remove","/^new_task_/"=>"new_task");
+ $arr = array( "/^edit_task_/"=>"edit","/^remove_task_/"=>"remove",
+ "/^new_task_/"=>"new_task","/^remove_multiple_task_/" => "remove_multiple");
foreach($arr as $regex => $action){
foreach($_POST as $name => $value){
if(preg_match($regex,$name)){
@@ -52,13 +54,43 @@ class gotomasses extends plugin
* List posts
************/
+ /* Remove multiple */
+ if($s_action == "remove_multiple"){
+ if(!$this->acl_is_removeable()){
+ print_red(_("You are not allowed to remove a task."));
+ }else{
+ $this->ids_to_remove = $this->list_get_selected_items();
+ $tmp = "";
+ foreach($this->ids_to_remove as $id){
+ $task = $this->tasks[$id];
+ $tmp.= "\n".$this->target_to_string($task);
+ }
+ $smarty->assign("multiple", TRUE);
+ $smarty->assign("info",sprintf(_("Your are about to delete the following tasks: %s"),"".$tmp."
"));
+ $this->current = $s_entry;
+ return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+ }
+ }
+
+ /* Remove specified tasks */
+ if(count($this->ids_to_remove) && isset($_POST['delete_multiple_confirm'])){
+ foreach($this->ids_to_remove as $id){
+ if(isset($this->tasks[$id])){
+ unset($this->tasks);
+ }
+ }
+ }
+
/* Remove entry from list */
if($s_action == "remove" && isset($this->tasks[$s_entry])){
if(!$this->acl_is_removeable()){
print_red(_("You are not allowed to remove a task."));
}else{
- $smarty->assign("info",_("Your are about to delete a gotomasses task."));
+ $entry = $this->tasks[$s_entry];
$this->current = $s_entry;
+ $smarty->assign("info",sprintf(_("Your are about to delete the following tasks: %s"),
+ "".$this->target_to_string($entry)."
"));
+ $smarty->assign("multiple", FALSE);
return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
}
}
@@ -70,6 +102,11 @@ class gotomasses extends plugin
$this->save();
}
+ /* Remove aborted */
+ if(isset($_POST['delete_cancel'])){
+ $this->ids_to_remove = array();;
+ }
+
/* Edit selected entry */
if($s_action == "edit" && isset($this->tasks[$s_entry])){
$entry = $this->tasks[$s_entry];
@@ -131,14 +168,17 @@ class gotomasses extends plugin
$divlist->SetInformation(_("This menu allows you to add, remove and change the properties of gotomasses tasks."));
/* Display add button if allowed */
+ $header = "";
+
/* Get Permissions */
$ui = get_userinfo();
$acls = $this->getacl("");
@@ -148,6 +188,13 @@ class gotomasses extends plugin
/* Create divlist */
$divlist->SetListHeader($header);
+ /* Toggle all selected / deselected */
+ $chk = "";
+
+ /* set Page header */
+ $divlist->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'"));
+
$divlist->AddHeader(array("string"=>""._("Target").""));
$divlist->AddHeader(array("string"=>""._("Schedule")."",
"attach"=>"style='width:100px;'"));
@@ -162,11 +209,15 @@ class gotomasses extends plugin
if($this->acl_is_removeable()){
$action.= "";
}
+ /* Create each field */
+ $field0 = array("string" => "" ,
+ "attach" => "style='width:20px;'");
+
$field1 = array("string" => "".$this->target_to_string($task)."
");
$field2 = array("string" => $this->time_to_string($task),"attach" => "style='width:100px;'");
$field3 = array("string" => $this->action_to_string($task),"attach" => "style='width:80px;'");
$field4 = array("string" => $action,"attach" => "style='text-align:right;width:40px;border-right:0px;'");
- $divlist->AddElement(array($field1,$field2,$field3,$field4));
+ $divlist->AddElement(array($field0,$field1,$field2,$field3,$field4));
}
}
@@ -360,6 +411,19 @@ class gotomasses extends plugin
}
+ function list_get_selected_items()
+ {
+ $ids = array();
+ foreach($_POST as $name => $value){
+ if(preg_match("/^item_selected_[0-9]*$/",$name)){
+ $id = preg_replace("/^item_selected_/","",$name);
+ $ids[$id] = $id;
+ }
+ }
+ return($ids);
+ }
+
+
function get_actions()
{
/* Prepare list of available actions */
diff --git a/plugins/addons/gotomasses/remove.tpl b/plugins/addons/gotomasses/remove.tpl
index e34108e5a..023142f97 100644
--- a/plugins/addons/gotomasses/remove.tpl
+++ b/plugins/addons/gotomasses/remove.tpl
@@ -11,7 +11,11 @@
+{if $multiple}
+
+{else}
+{/if}