From: hickert Date: Tue, 17 Apr 2007 13:47:02 +0000 (+0000) Subject: Added multiple remove to group list X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=50f59430f96ad744d5e4ed7c68725f52698a13eb;p=gosa.git Added multiple remove to group list git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6071 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/groups/class_divListGroup.inc b/plugins/admin/groups/class_divListGroup.inc index 70070da43..518e36740 100644 --- a/plugins/admin/groups/class_divListGroup.inc +++ b/plugins/admin/groups/class_divListGroup.inc @@ -50,7 +50,12 @@ class divListGroup 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='width:20px;'")); $this->AddHeader(array("string"=>_("Groupname / Department"))); $this->AddHeader(array("string"=>_("Properties"),"attach"=>"style='width:136px;'")); @@ -146,9 +151,13 @@ class divListGroup extends MultiSelectWindow /* Add department selection */ $listhead .= _("Base")." ". "  ". - ""; + "'> "; + + /* Multiple options */ + $listhead .= "  "; + $listhead .= ""; $this->SetListHeader($listhead); } @@ -249,12 +258,15 @@ class divListGroup extends MultiSelectWindow $desc .= " (".$val['FAIrelease'][0].")"; } + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + $field1 = array("string" => sprintf($userimg,$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, $posix." ".$enviro." ".$mail." ".$samba." ".$appl." ".$phone), "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/groups/class_groupManagement.inc b/plugins/admin/groups/class_groupManagement.inc index 09c4bf058..a7376241d 100644 --- a/plugins/admin/groups/class_groupManagement.inc +++ b/plugins/admin/groups/class_groupManagement.inc @@ -67,7 +67,7 @@ class groupManagement extends plugin plugin::execute(); /* Store these posts if the current object is locked (used by somebody else)*/ - $_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_groups/"); /* Save data */ $s_action = ""; @@ -106,6 +106,8 @@ class groupManagement extends plugin }elseif(preg_match("/^cut_.*/",$key)){ $s_action="cut"; $s_entry = preg_replace("/^cut_/i","",$key); + }elseif(preg_match("/^remove_multiple_groups/",$key)){ + $s_action="del_multiple"; } } $s_entry = preg_replace("/_.$/","",$s_entry); @@ -217,6 +219,121 @@ class groupManagement 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->grouplist[$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 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_group_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); + unset($this->dns[$key]); + } + } + + + /******************** + Delete MULTIPLE entries confirmed + ********************/ + + /* Confirmation for deletion has been passed. Users should be deleted. */ + if (isset($_POST['delete_multiple_groups_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + $acl = $this->ui->get_permissions($this->dn,"groups/group"); + if(preg_match("/d/",$acl)){ + + /* Delete request is permitted, perform LDAP action */ + $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $this->dn); + $this->grouptab->set_acl_base($this->dn); + $this->grouptab->delete (); + gosa_log ("Group object'".$this->dn."' has been removed"); + unset ($this->grouptab); + $this->grouptab= 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 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_user_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + /******************** Delete group ********************/ @@ -241,6 +358,7 @@ class groupManagement 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 group '%s'."), @LDAP::fix($this->dn))); + $smarty->assign("multiple", false); return($smarty->fetch(get_template_path('remove.tpl', TRUE))); } else { @@ -352,7 +470,7 @@ class groupManagement extends plugin /* Add departments if subsearch is disabled */ if(!$this->DivListGroup->SubSearch){ - $this->DivListGroup->AddDepartments($this->DivListGroup->selectedBase,4); + $this->DivListGroup->AddDepartments($this->DivListGroup->selectedBase,4,1); } $this->reload (); $this->DivListGroup->setEntries($this->grouplist); @@ -367,6 +485,18 @@ class groupManagement 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 reload($CreatePosixsList=false) { diff --git a/plugins/admin/groups/remove.tpl b/plugins/admin/groups/remove.tpl index 1f3ff8b96..c91b28f7f 100644 --- a/plugins/admin/groups/remove.tpl +++ b/plugins/admin/groups/remove.tpl @@ -11,8 +11,17 @@

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