From 924bd8f2d29d71ea23d8fd42a58bde82a21b7081 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 17 Apr 2007 09:55:42 +0000 Subject: [PATCH] Added remove multiple users button git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6066 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/users/class_divListUsers.inc | 9 ++- plugins/admin/users/class_userManagement.inc | 79 +++++++++++++++++++- plugins/admin/users/remove.tpl | 4 + 3 files changed, 89 insertions(+), 3 deletions(-) diff --git a/plugins/admin/users/class_divListUsers.inc b/plugins/admin/users/class_divListUsers.inc index 8a2571376..43883eed3 100644 --- a/plugins/admin/users/class_divListUsers.inc +++ b/plugins/admin/users/class_divListUsers.inc @@ -132,9 +132,14 @@ class divListUsers extends MultiSelectWindow $listhead .= _("Base")." ". "  ". - ""; + title='"._("Submit department")."' name='submit_department' alt='". _("Submit")."'> "; + + /* Multiple options */ + $listhead .= "  "; + + $listhead .="";; $this->SetListHeader($listhead); } diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index fc587889b..2a79cf9b6 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -60,7 +60,7 @@ class userManagement extends plugin plugin::execute(); /* LOCK MESSAGE Vars */ - $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/"); + $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/","/^item_selected/","/^remove_multiple_user/"); $smarty = get_smarty(); // Smarty instance $s_action = ""; // Contains the action to be taken @@ -79,6 +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", "create_user_from_tpl" => "userfrom_tpl", "change_pw" => "user_chgpw", "editPaste" => "editPaste", "copy" => "copy", @@ -287,6 +288,67 @@ class userManagement extends plugin } + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + $ids = $this->list_get_selected_items(); + + foreach($ids as $id){ + $dn = $this->list[$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 user(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_user_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + + $acl = $this->ui->get_permissions($dn, "users/user"); + if (preg_match('/d/', $acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'],$dn); + $this->usertab->set_acl_base(); + $this->usertab->delete (); + gosa_log ("User object '".$dn."' has been removed"); + unset ($this->usertab); + $this->usertab= NULL; + } else { + print_red (sprintf(_("You are not allowed to delete the user '%s'!"),$dn)); + if(isset($this->ui->uid)){ + gosa_log ("Warning: '".$this->ui->uid."' tried to trick user deletion."); + } + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + } + } + + /******************** Delete entry requested, display confirm dialog ********************/ @@ -309,6 +371,7 @@ class userManagement 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 user %s."), @LDAP::fix($this->dn))); + $smarty->assign("multiple", false); return($smarty->fetch(get_template_path('remove.tpl', TRUE))); } @@ -877,6 +940,20 @@ class userManagement 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); + } + + /* A set of disabled and therefore overloaded functions. They are not needed in this class. */ function remove_from_parent() { } diff --git a/plugins/admin/users/remove.tpl b/plugins/admin/users/remove.tpl index eae8d7f09..eb78a09b3 100644 --- a/plugins/admin/users/remove.tpl +++ b/plugins/admin/users/remove.tpl @@ -11,7 +11,11 @@

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

-- 2.30.2