From af0deb8bc716e8b711432ee8b5a4e22497efbca7 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 19 Apr 2007 07:55:28 +0000 Subject: [PATCH] Added remove multiple to conferences git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6112 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../conference/class_divListConferences.inc | 23 ++++- .../class_phoneConferenceManagment.inc | 91 ++++++++++++++++++- plugins/gofon/conference/remove.tpl | 14 ++- .../macro/class_gofonMacroManagement.inc | 1 + 4 files changed, 118 insertions(+), 11 deletions(-) diff --git a/plugins/gofon/conference/class_divListConferences.inc b/plugins/gofon/conference/class_divListConferences.inc index 15f66f1db..180cf03fd 100755 --- a/plugins/gofon/conference/class_divListConferences.inc +++ b/plugins/gofon/conference/class_divListConferences.inc @@ -42,12 +42,17 @@ class divListConference extends MultiSelectWindow $this->EnableSaveButton (false); /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 50; + $action_col_size = 60; if($this->parent->snapshotEnabled()){ $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" =>_("Name - Number"), "attach" => "style=''")); $this->AddHeader(array("string" => _("Owner"), "attach" => "style='width:200px;'")); @@ -113,8 +118,13 @@ class divListConference extends MultiSelectWindow /* Add the rest (base select ....)*/ $listhead .= _("Base")." ". "  ". - ""; + title='"._("Submit department")."' name='submit_department' alt='". _("Submit"). "'> "; + + /* Multiple options */ + $listhead .= "  "; + + $listhead .=""; $this->SetListHeader($listhead); } @@ -133,7 +143,7 @@ class divListConference extends MultiSelectWindow $editlink = "%s"; /* Dynamic action col, depending on snapshot icons */ - $action_col_size = 50; + $action_col_size = 60; if($this->parent->snapshotEnabled()){ $action_col_size += 20; } @@ -195,6 +205,9 @@ class divListConference extends MultiSelectWindow /* Create title */ $title = " title='".preg_replace("/ /"," ",@LDAP::fix($data['dn']))."' "; + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => $title." style='text-align:center;width:20px;'"); $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$conference['cn'][0].$number), "attach" => $title." style=''"); $a_field3 = array("string"=> $cn , "attach" => $title." style='width:200px;'"); @@ -202,7 +215,7 @@ class divListConference extends MultiSelectWindow $a_field5 = array("string"=> preg_replace("/%KEY%/",$conferencekey,$actions), "attach"=> $title."style='width:".$action_col_size."px;border-right:0px;text-align:right;'"); - $this->AddElement(array($a_field1,$a_field2,$a_field3,$a_field4,$a_field5)); + $this->AddElement(array($field0,$a_field1,$a_field2,$a_field3,$a_field4,$a_field5)); } } diff --git a/plugins/gofon/conference/class_phoneConferenceManagment.inc b/plugins/gofon/conference/class_phoneConferenceManagment.inc index 463c449d3..039399748 100644 --- a/plugins/gofon/conference/class_phoneConferenceManagment.inc +++ b/plugins/gofon/conference/class_phoneConferenceManagment.inc @@ -55,7 +55,7 @@ class phoneConferenceManagment extends plugin /* Call parent execute */ plugin::execute(); - $_SESSION['LOCK_VARS_TO_USE'] = array("/^id$/","/^act$/","/^conference_/"); + $_SESSION['LOCK_VARS_TO_USE'] = array("/^id$/","/^act$/","/^conference_/","/^item_selected/","/^remove_multiple_conferences/"); /*************** Variable initialisation @@ -85,6 +85,8 @@ class phoneConferenceManagment extends plugin $s_action="edit"; $s_entry = preg_replace("/conference_edit_/i","",$key); $s_entry = preg_replace("/_.*$/","",$s_entry); + }elseif(preg_match("/^remove_multiple_conferences/",$key)){ + $s_action="del_multiple"; } } @@ -112,6 +114,76 @@ class phoneConferenceManagment 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->conferences[$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_conference_confirm'])){ + + /* Remove user by user and check acls before removeing them */ + foreach($this->dns as $key => $dn){ + $this->dn = $dn; + $acl = $this->ui->get_permissions($this->dn,"gofonconference/conference"); + if(preg_match("/d/",$acl)){ + $this->remove_from_parent(); + gosa_log ("Department object'".$this->dn."' has been removed"); + } else { + print_red (_("You have no permission to remove this department.")); + } + /* Remove lock file after successfull deletion */ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + + /******************** + Delete MULTIPLE entries Canceled + ********************/ + + /* Remove lock */ + if(isset($_POST['delete_multiple_conference_cancel'])){ + foreach($this->dns as $key => $dn){ + del_lock ($dn); + unset($this->dns[$key]); + } + } + + /*************** Delete ***************/ @@ -132,6 +204,7 @@ class phoneConferenceManagment extends plugin } else { add_lock ($this->dn, $this->ui->dn); $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), $this->dn)); + $smarty->assign("multiple", false); $display.= $smarty->fetch (get_template_path('remove.tpl', TRUE)); return ($display); } @@ -277,7 +350,7 @@ class phoneConferenceManagment extends plugin /* Add departments if subsearch is disabled */ if(!$this->DivListConference->SubSearch){ - $this->DivListConference->AddDepartments($this->DivListConference->selectedBase,5); + $this->DivListConference->AddDepartments($this->DivListConference->selectedBase,5,1); } $this->reload(); $this->DivListConference->setEntries($this->conferences); @@ -350,6 +423,20 @@ class phoneConferenceManagment 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); + } + + } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/plugins/gofon/conference/remove.tpl b/plugins/gofon/conference/remove.tpl index 33fdbbc2f..970abd4be 100644 --- a/plugins/gofon/conference/remove.tpl +++ b/plugins/gofon/conference/remove.tpl @@ -1,8 +1,8 @@
 {t}Warning{/t}
-

{$info} +

{t}This includes 'all' accounts, systems, etc. in this subtree. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}

@@ -11,8 +11,14 @@

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

diff --git a/plugins/gofon/macro/class_gofonMacroManagement.inc b/plugins/gofon/macro/class_gofonMacroManagement.inc index 8f670bb89..8069d41cd 100755 --- a/plugins/gofon/macro/class_gofonMacroManagement.inc +++ b/plugins/gofon/macro/class_gofonMacroManagement.inc @@ -285,6 +285,7 @@ class gofonMacro extends plugin add_lock ($this->dn, $this->ui->dn); $smarty= get_smarty(); $smarty->assign("intro", sprintf(_("You're about to delete the macro '%s'."), $this->dn)); + $smarty->assign("multiple", false); return($smarty->fetch (get_template_path('remove.tpl', TRUE))); } else { -- 2.30.2