From: hickert Date: Wed, 18 Apr 2007 08:46:24 +0000 (+0000) Subject: Added remove multiple entries to applications X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;ds=sidebyside;h=7aa8c751a76f14c9cd0c7577b9586d4ab1cd1514;p=gosa.git Added remove multiple entries to applications git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6077 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/applications/class_applicationManagement.inc b/plugins/admin/applications/class_applicationManagement.inc index 801ca3fe6..c07e40ccd 100644 --- a/plugins/admin/applications/class_applicationManagement.inc +++ b/plugins/admin/applications/class_applicationManagement.inc @@ -105,7 +105,7 @@ class applicationManagement extends plugin /* These vars will be stored if you try to open a locked app, to be able to perform your last requests after showing a warning message */ - $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^appl_edit_/","/^appl_del_/"); + $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^appl_edit_/","/^appl_del_/","/^item_selected/","/^remove_multiple_applications/"); $smarty = get_smarty(); // Smarty instance $s_action = ""; // Contains the action to proceed @@ -132,6 +132,8 @@ class applicationManagement extends plugin // Post for new }elseif(preg_match("/^appl_new.*/",$key)){ $s_action="new"; + }elseif(preg_match("/^remove_multiple_applications/",$key)){ + $s_action="del_multiple"; }elseif(preg_match("/^editPaste.*/i",$key)){ $s_action="editPaste"; } @@ -255,6 +257,86 @@ class applicationManagement 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->applications[$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("intro", sprintf(_("You're about to delete the following application(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_application_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + + $ui = get_userinfo(); + $acl = $ui->get_permissions($dn ,"application/application"); + if (preg_match('/d/', $acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->apptabs= new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn,"application"); + $this->apptabs->set_acl_base($dn); + $this->apptabs->delete (); + gosa_log ("Application object'".$dn."' has been removed"); + unset ($this->apptabs); + $this->apptabs= 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 application!")); + 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_application_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + /**************** Delete app ****************/ @@ -369,7 +451,7 @@ class applicationManagement extends plugin /* Display dialog with system list */ $this->DivListApplication->parent = $this; $this->DivListApplication->execute(); - $this->DivListApplication->AddDepartments($this->DivListApplication->selectedBase); + $this->DivListApplication->AddDepartments($this->DivListApplication->selectedBase,3,1); $this->reload(); $this->DivListApplication->setEntries($this->applications); return($this->DivListApplication->Draw()); @@ -477,6 +559,19 @@ class applicationManagement 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); + } + + /* Save to LDAP */ function save() { diff --git a/plugins/admin/applications/class_divListApplication.inc b/plugins/admin/applications/class_divListApplication.inc index e81ca4e07..19aa04b87 100755 --- a/plugins/admin/applications/class_divListApplication.inc +++ b/plugins/admin/applications/class_divListApplication.inc @@ -47,6 +47,13 @@ class divListApplication 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" => _("Application name")." / "._("Department"), "attach" => "style=''")); $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); @@ -143,8 +150,13 @@ class divListApplication extends MultiSelectWindow /* And the rest, a base selection box */ $listhead .= _("Base")." ". "  ". - ""; + title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> "; + + /* Multiple options */ + $listhead .= "  "; + + $listhead .=""; $this->SetListHeader($listhead); } @@ -225,10 +237,14 @@ class divListApplication extends MultiSelectWindow }else{ $desc = " - [ ".$val['description'][0]." ]"; } + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); $field1 = array("string" => sprintf($applimg,$val['dn']), "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, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - $this->AddElement(array($field1,$field2,$field3)); + $this->AddElement(array($field0,$field1,$field2,$field3)); } } diff --git a/plugins/admin/applications/remove.tpl b/plugins/admin/applications/remove.tpl index 5b4c3e823..8598ed857 100644 --- a/plugins/admin/applications/remove.tpl +++ b/plugins/admin/applications/remove.tpl @@ -10,8 +10,14 @@

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

diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index 676e568b9..f8b32dc3c 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_/","/^item_selected/","/^remove_multiple_user/"); + $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/","/^item_selected/","/^remove_multiple_users/"); $smarty = get_smarty(); // Smarty instance $s_action = ""; // Contains the action to be taken