From 7b6ca4ef6836748b63f0f5bc91e5fc008c037a34 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 18 Apr 2007 13:35:41 +0000 Subject: [PATCH] Added remove multiple objects git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6093 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../blocklists/class_blocklistManagement.inc | 90 ++++++++++++++++++- .../blocklists/class_divListBlocklists.inc | 21 ++++- plugins/gofax/blocklists/remove.tpl | 12 ++- 3 files changed, 115 insertions(+), 8 deletions(-) diff --git a/plugins/gofax/blocklists/class_blocklistManagement.inc b/plugins/gofax/blocklists/class_blocklistManagement.inc index d3e737780..a002dfcb8 100644 --- a/plugins/gofax/blocklists/class_blocklistManagement.inc +++ b/plugins/gofax/blocklists/class_blocklistManagement.inc @@ -39,7 +39,7 @@ class blocklist extends plugin /* Call parent execute */ plugin::execute(); - $_SESSION['LOCK_VARS_TO_USE'] = array("/^goFaxBlocklist_/","/^act$/","/^id$/"); + $_SESSION['LOCK_VARS_TO_USE'] = array("/^goFaxBlocklist_/","/^act$/","/^id$/","/^remove_multiple_blocklists/","/^item_selected/"); /*************** Init vars @@ -69,6 +69,8 @@ class blocklist extends plugin // Post for new }elseif(preg_match("/^goFaxBlocklist_new.*/",$key)){ $s_action="new"; + }elseif(preg_match("/^remove_multiple_blocklists/",$key)){ + $s_action="del_multiple"; } } @@ -149,6 +151,76 @@ class blocklist extends plugin } + /******************** + Delete MULTIPLE entries requested, display confirm dialog + ********************/ + + if ($s_action=="del_multiple"){ + + $this->dns = array(); + $ids = $this->list_get_selected_items(); + + if(count($ids)){ + foreach($ids as $id){ + $dn = $this->blocklists[$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 blocklists(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_blocklist_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + $acl = $this->ui->get_permissions($dn, "blocklist/blocklist"); + if (preg_match('/d/', $acl)){ + $this->dn = $dn; + $this->remove_from_parent(); + } else { + print_red (sprintf(_("You are not allowed to delete the blocklist '%s'!"),$dn)); + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + $this->reload(); + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_blocklist_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + /*************** Remove blocklist ***************/ @@ -165,6 +237,7 @@ class blocklist extends plugin add_lock ($this->dn, $this->ui->dn); $smarty->assign("info", sprintf(_("You're about to delete the blocklist '%s'."), $this->dn)); + $smarty->assign("multiple", false); return($smarty->fetch(get_template_path('remove.tpl', TRUE))); } } @@ -351,7 +424,7 @@ class blocklist extends plugin /* Add departments if subsearch is disabled */ if(!$this->DivListBlocklist->SubSearch){ - $this->DivListBlocklist->AddDepartments($this->DivListBlocklist->selectedBase); + $this->DivListBlocklist->AddDepartments($this->DivListBlocklist->selectedBase,3,1); } $this->reload(); $this->DivListBlocklist->setEntries($this->blocklists); @@ -360,6 +433,19 @@ class blocklist 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); + } + + /* Return departments, that will be included within snapshot detection */ function get_used_snapshot_bases() { diff --git a/plugins/gofax/blocklists/class_divListBlocklists.inc b/plugins/gofax/blocklists/class_divListBlocklists.inc index f96f64c43..02c616324 100755 --- a/plugins/gofax/blocklists/class_divListBlocklists.inc +++ b/plugins/gofax/blocklists/class_divListBlocklists.inc @@ -47,7 +47,12 @@ class divListBlocklist extends MultiSelectWindow $action_col_size += 20; } + /* 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" => _("Blocklist name")." / "._("Department"), "attach" => "style=''")); $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'" )); @@ -114,8 +119,13 @@ class divListBlocklist extends MultiSelectWindow /* Append department selector */ $listhead .= " "._("Base")." ". "  ". - ""; + title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> "; + + /* Multiple options */ + $listhead .= "  "; + + $listhead .=""; $this->SetListHeader($listhead); } @@ -167,10 +177,15 @@ class divListBlocklist extends MultiSelectWindow }else{ $display= $val["cn"][0]; } + + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); $field1 = array("string" => sprintf($blockimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'"); $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"); $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action), "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/gofax/blocklists/remove.tpl b/plugins/gofax/blocklists/remove.tpl index 6784741a4..ebea1e3ca 100644 --- a/plugins/gofax/blocklists/remove.tpl +++ b/plugins/gofax/blocklists/remove.tpl @@ -11,8 +11,14 @@

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

-- 2.30.2