From ef66e2cb67f5656eb0cfbe872d397d3abb819fa5 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 18 Apr 2007 06:12:03 +0000 Subject: [PATCH] Added "multiple action checkboxes" to object group list. Remove multiple implemented too. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6073 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/ogroups/class_divListOGroup.inc | 19 +++- .../admin/ogroups/class_ogroupManagement.inc | 98 ++++++++++++++++++- plugins/admin/ogroups/remove.tpl | 12 ++- plugins/admin/users/class_divListUsers.inc | 2 +- plugins/admin/users/class_userManagement.inc | 4 +- 5 files changed, 123 insertions(+), 12 deletions(-) diff --git a/plugins/admin/ogroups/class_divListOGroup.inc b/plugins/admin/ogroups/class_divListOGroup.inc index ad23b1f3d..5ac05bc77 100755 --- a/plugins/admin/ogroups/class_divListOGroup.inc +++ b/plugins/admin/ogroups/class_divListOGroup.inc @@ -53,7 +53,12 @@ class divListOGroup extends MultiSelectWindow $action_col_size += 38; } + /* Toggle all selected / deselected */ + $chk = ""; + /* set Page header */ + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); $this->AddHeader(array("string" => _("Name of object groups")." / "._("Departments"), "attach" => "style=''")); $this->AddHeader(array("string" => _("Properties"), "attach" => "style='width:136px;'")); @@ -148,8 +153,13 @@ class divListOGroup extends MultiSelectWindow /* Add department selector */ $listhead .= _("Base")." ". "  ". - ""; + title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> "; + + /* Multiple options */ + $listhead .= "  "; + + $listhead .=""; $this->SetListHeader($listhead); } @@ -219,12 +229,15 @@ class divListOGroup extends MultiSelectWindow }else{ $desc = " - [ ".$val['description'][0]." ]"; } + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); $field1 = array("string" => ""._("Object group")."", "attach" => "style='text-align:center;width: 20px;'"); $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title); $field3 = array("string" => preg_replace("/%KEY/", $key, $this->parent->convert_list($val))." ".$mail, "attach" => "style='width:136px;'"); $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - $this->AddElement(array($field1,$field2,$field3,$field4)); + $this->AddElement(array($field0,$field1,$field2,$field3,$field4)); } } diff --git a/plugins/admin/ogroups/class_ogroupManagement.inc b/plugins/admin/ogroups/class_ogroupManagement.inc index df051b473..4f4317233 100644 --- a/plugins/admin/ogroups/class_ogroupManagement.inc +++ b/plugins/admin/ogroups/class_ogroupManagement.inc @@ -59,7 +59,7 @@ class ogroupManagement extends plugin Variable intialisation && Check posts for commands ****************/ - $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/"); + $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/","/^item_selected/","/^remove_multiple_ogroups/"); $smarty = get_smarty(); $s_action = ""; @@ -86,6 +86,8 @@ class ogroupManagement extends plugin }elseif(preg_match("/^cut_.*/",$key)){ $s_action="cut"; $s_entry = preg_replace("/^cut_/i","",$key); + }elseif(preg_match("/^remove_multiple_ogroups/",$key)){ + $s_action="del_multiple"; }elseif(preg_match("/_group_edit_/",$key)){ $type = preg_replace("/_group_edit_.*$/","",$key); $s_action="edit"; @@ -129,6 +131,84 @@ class ogroupManagement extends plugin } + + + + + + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + if ($s_action=="del_multiple"){ + $ids = $this->list_get_selected_items(); + if(count($ids)){ + foreach($ids as $id){ + $dn = $this->ogrouplist[$id]['dn']; + if (($user= get_lock($dn)) != ""){ + return(gen_locked_message ($user, $dn)); + } + $this->dns[$id] = $dn; + } + $dns_names = "
";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="
"; + /* Lock the current entry, so nobody will edit it during deletion */ + $smarty->assign("info", sprintf(_("You're about to delete the following object group(s) %s"), @LDAP::fix($dns_names))); + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. Users should be deleted. */ + if (isset($_POST['delete_multiple_ogroup_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + + $acl = $this->ui->get_permissions($dn, "ogroups"); + if (preg_match('/d/', $acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->ogroup= new ogrouptabs($this->config,$this->config->data['TABS']['OGROUPTABS'], $dn); + $this->ogroup->delete (); + gosa_log ("Object group'".$this->dn."' has been removed"); + unset ($this->ogroup); + $this->ogroup= NULL; + } else { + + /* Normally this shouldn't be reached, send some extra + logs to notify the administrator */ + print_red (_("You are not allowed to delete this object group!")); + gosa_log ("Warning: '".$this->ui->uid."' tried to trick group deletion."); + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_ogroup_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + /**************** Delete object group ****************/ @@ -152,6 +232,7 @@ class ogroupManagement extends plugin /* Lock the current entry, so nobody will edit it during deletion */ add_lock ($this->dn, $this->ui->dn); $smarty->assign("info", sprintf(_("You're about to delete the object group '%s'."), @LDAP::fix($this->dn))); + $smarty->assign("multiple", false); return($smarty->fetch(get_template_path('remove.tpl', TRUE))); } else { @@ -321,7 +402,7 @@ class ogroupManagement extends plugin /* Add departments if subsearch is disabled */ if(!$this->DivListOGroup->SubSearch){ - $this->DivListOGroup->AddDepartments($this->DivListOGroup->selectedBase,4); + $this->DivListOGroup->AddDepartments($this->DivListOGroup->selectedBase,4,1); } $this->reload (); $this->DivListOGroup->setEntries($this->ogrouplist); @@ -439,6 +520,19 @@ class ogroupManagement 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 copyPasteHandling($s_action,$s_entry) { if($this->CopyPasteHandler){ diff --git a/plugins/admin/ogroups/remove.tpl b/plugins/admin/ogroups/remove.tpl index fd14a5a67..720156b97 100644 --- a/plugins/admin/ogroups/remove.tpl +++ b/plugins/admin/ogroups/remove.tpl @@ -11,8 +11,14 @@

- -   - + {if $multiple} + +   + + {else} + +   + + {/if}

diff --git a/plugins/admin/users/class_divListUsers.inc b/plugins/admin/users/class_divListUsers.inc index 177be0a36..e5cec852e 100644 --- a/plugins/admin/users/class_divListUsers.inc +++ b/plugins/admin/users/class_divListUsers.inc @@ -138,7 +138,7 @@ class divListUsers extends MultiSelectWindow /* Multiple options */ $listhead .= "  "; + title='"._("Remove selected user")."' alt='"._("Remove user")."' name='remove_multiple_users'> "; $listhead .="";; $this->SetListHeader($listhead); diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index 9d24b558f..676e568b9 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -79,7 +79,7 @@ class userManagement extends plugin foreach(array("del" => "user_del", "edit" => "user_edit", "new" => "user_new", "new_tpl" => "user_tplnew", - "del_multiple" => "^remove_multiple_user", + "del_multiple" => "^remove_multiple_users", "create_user_from_tpl" => "userfrom_tpl", "change_pw" => "user_chgpw", "editPaste" => "editPaste", "copy" => "copy", @@ -305,8 +305,6 @@ class userManagement extends plugin $this->dns[$id] = $dn; } - - $dns_names = "
";
         foreach($this->dns as $dn){
           add_lock ($dn, $this->ui->dn);
-- 
2.30.2