summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e83abc9)
raw | patch | inline | side by side (parent: e83abc9)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 19 Apr 2007 06:59:03 +0000 (06:59 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 19 Apr 2007 06:59:03 +0000 (06:59 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6108 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/gofon/macro/class_divListMacros.inc | patch | blob | history | |
plugins/gofon/macro/class_gofonMacroManagement.inc | patch | blob | history | |
plugins/gofon/macro/remove.tpl | patch | blob | history |
diff --git a/plugins/gofon/macro/class_divListMacros.inc b/plugins/gofon/macro/class_divListMacros.inc
index 0a78660d299b0b8f198531f7f2460be52c131fa6..d3712660b052f5545ee997596fc8a70e4ecea7e3 100755 (executable)
$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 = "<input type='checkbox' id='select_all' name='select_all'
+ onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
+
/* 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" => _("Macro name")." / "._("Department"), "attach" => "style=''"));
$this->AddHeader(array("string" => _("Visible"), "attach" => "style='width:50px;'"));
}
$listhead .= _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
" <input class='center' type='image' src='images/list_submit.png' align='middle'
- title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
- "</div>";
+ title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ";
+
+ /* Multiple options */
+ $listhead .= " <input class='center' type='image' align='middle' src='images/edittrash.png'
+ title='"._("Remove selected macros")."' alt='"._("Remove macros")."' name='remove_multiple_macros'> ";
+ $listhead .="</div>";
$this->SetListHeader($listhead);
}
$editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
/* Dynamic action col, depending on snapshot icons */
- $action_col_size = 50;
+ $action_col_size = 60;
if($this->parent->snapshotEnabled()){
$action_col_size += 20;
}
$display .= " [".$desc."]";
}
-
+ /* Create each field */
+ $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
+ "attach" => "style='width:20px;'");
$field1 = array("string" => sprintf($macroimg,$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" => $pic1, "attach" => "style='width:50px;'");
$field4 = 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,$field4));
+ $this->AddElement(array($field0,$field1,$field2,$field3,$field4));
}
}
diff --git a/plugins/gofon/macro/class_gofonMacroManagement.inc b/plugins/gofon/macro/class_gofonMacroManagement.inc
index b3ba05728e85842e808ffb0a116ee69ca10579f5..8f670bb89564fc6b88100de70202b5b59987457d 100755 (executable)
/* Call parent execute */
plugin::execute();
- $_SESSION['LOCK_VARS_TO_USE'] = array("/^goFonMacro_/","/^act$/","/^id$/");
+ $_SESSION['LOCK_VARS_TO_USE'] = array("/^goFonMacro_/","/^act$/","/^id$/","/^item_selected/","/^remove_multiple_macros/");
/*****************
Variable initialisation
// Post for new
}elseif(preg_match("/^goFonMacro_new/",$key)){
$s_action="new";
+ }elseif(preg_match("/^remove_multiple_macros/",$key)){
+ $s_action="del_multiple";
}
}
if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
}
}
+
+
+ /********************
+ 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->macros[$id]['dn'];
+ if (($user= get_lock($dn)) != ""){
+ return(gen_locked_message ($user, $dn));
+ }
+ $this->dns[$id] = $dn;
+ }
+
+ $dns_names = "<br><pre>";
+ foreach($this->dns as $dn){
+ add_lock ($dn, $this->ui->dn);
+ $dns_names .= $dn."\n";
+ }
+ $dns_names .="</pre>";
+
+ /* Lock the current entry, so nobody will edit it during deletion */
+ $smarty->assign("intro", 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_macro_confirm'])){
+
+ /* Remove user by user and check acls before removeing them */
+ foreach($this->dns as $key => $dn){
+
+ $acl = $this->ui->get_permissions($dn,"gofonmacro/macro");
+ if(preg_match("/d/",$acl)){
+
+ /* Delete request is permitted, perform LDAP action */
+ $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $dn,"gofonmacro");
+ $this->macrotabs->delete ();
+ gosa_log ("macro object'".$dn."' has been removed");
+ unset ($this->macrotabs);
+ $this->macrotabs= NULL;
+
+ } else {
+ print_red (_("You are not allowed to delete this macro!"));
+ }
+
+ /* Remove lock file after successfull deletion */
+ del_lock ($dn);
+ unset($this->dns[$key]);
+ }
+ }
+
+
+ /********************
+ Delete MULTIPLE entries Canceled
+ ********************/
+
+ /* Remove lock */
+ if(isset($_POST['delete_multiple_macro_cancel'])){
+ foreach($this->dns as $key => $dn){
+ del_lock ($dn);
+ unset($this->dns[$key]);
+ }
+ }
+
+
/*****************
Remove macro
*****************/
-
+
/* Remove user was requested */
if ($s_action=="del"){
/* Add departments if subsearch is disabled */
if(!$this->DivListMacro->SubSearch){
- $this->DivListMacro->AddDepartments($this->DivListMacro->selectedBase,4);
+ $this->DivListMacro->AddDepartments($this->DivListMacro->selectedBase,4,1);
}
$this->reload();
$this->DivListMacro->setEntries($this->macros);
}
+ 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 adapt_from_template($dn) { }
function check() { }
}
index d38ef8c366e7470b77419ffbaa8a4f3e57892342..4dbd248c545d6a329e79419beb8b38027c987964 100755 (executable)
</p>
<p class="plugbottom">
- <input type=submit name="delete_macro_confirm" value="{t}Delete{/t}">
-
- <input type=submit name="delete_cancel" value="{t}Cancel{/t}">
+ {if $multiple}
+ <input type=submit name="delete_multiple_macro_confirm" value="{t}Delete{/t}">
+
+ <input type=submit name="delete_multiple_macro_cancel" value="{t}Cancel{/t}">
+ {else}
+ <input type=submit name="delete_macro_confirm" value="{t}Delete{/t}">
+
+ <input type=submit name="delete_cancel" value="{t}Cancel{/t}">
+ {/if}
</p>