1 <?php
3 class divListMacro extends MultiSelectWindow
4 {
6 /* Current base */
7 var $selectedBase = "";
8 var $departments = array();
10 /* Regex */
11 var $Regex = "*";
13 /* checkboxes */
14 var $ShowSendBocklists ;
15 var $ShowReceiveMacros ;
17 /* Subsearch checkbox */
18 var $SubSearch;
20 var $parent ;
21 var $ui ;
23 function divListMacro ($config,$parent)
24 {
25 MultiSelectWindow::MultiSelectWindow($config,"Macros");
27 $this->parent = $parent;
28 $this->ui = get_userinfo();
30 /* Set list strings */
31 $this->SetTitle(_("List of macros"));
32 $this->SetSummary(_("List of macros"));
34 /* Result page will look like a headpage */
35 $this->SetHeadpageMode();
36 $this->SetInformation(_("This menu allows you to add, edit and remove selected macros. ".
37 "You may want to use the range selector on top of the macro listbox, ".
38 "when working with a large number of macros."));
40 $this->EnableAplhabet (true);
42 /* Disable buttonsm */
43 $this->EnableCloseButton(false);
44 $this->EnableSaveButton (false);
46 /* set Page header */
47 $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"));
48 $this->AddHeader(array("string" => _("Username")." / "._("Department"), "attach" => "style=''"));
49 $this->AddHeader(array("string" => _("Visible"), "attach" => "style='width:50px;'"));
50 $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ));
52 /* Add Checkboxes / SubSearch checkbox */
53 $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false);
55 /* Name ,Text ,Default , Connect with alphabet */
56 $this->AddRegex ("Regex", _("Regular expression for matching macro names"),"*" , true);
57 }
59 function GenHeader()
60 {
61 /* Prepare departments,
62 which are shown in the listbox on top of the listbox
63 */
64 $options= "";
65 foreach ($this->config->idepartments as $key => $value){
66 if ($this->selectedBase == $key){
67 $options.= "<option selected='selected' value='$key'>$value</option>";
68 } else {
69 $options.= "<option value='$key'>$value</option>";
70 }
71 }
73 /* NEW LIST MANAGMENT */
74 $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
75 " <input class='center' type='image' src='images/list_root.png' align='middle'
76 title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
77 " <input class='center' type='image' align='middle' src='images/list_back.png'
78 title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
79 " <input class='center' type='image' align='middle' src='images/list_home.png'
80 title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
81 " <input class='center' type='image' src='images/list_reload.png' align='middle'
82 title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'> ".
83 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
84 " <input class='center' type='image' align='middle' src='images/list_new_macro.png'
85 title='"._("Create new phone macro")."' alt='"._("New")."' name='user_new'> ".
86 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
87 _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
88 " <input class='center' type='image' src='images/list_submit.png' align='middle'
89 title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
90 "</div>";
92 $this->SetListHeader($listhead);
93 }
95 function execute()
96 {
97 $this->ClearElementsList();
98 $this->GenHeader();
99 }
101 function setEntries($list)
102 {
104 $action = "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'
105 name='user_edit_%KEY%' title='"._("Edit user")."'>";
106 $action .= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."'
107 name='user_del_%KEY%' title='"._("Delete user")."'>";
109 $empty = "<img class='center' src='images/nothing.png' style='width:16px;height:16px;' alt=''>";
110 $macroimg = "<img class='center' src='images/list_macro.png' alt='"._("Macro")."' title='%s'>";
111 $visible = "<img class='center' src='images/true.png' alt='"._("yes")."' title='"._("visible")."'>";
112 $invisible = "<img class='center' src='images/false.png' alt='"._("no")."'title='"._("invisible")."'>";
113 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
115 foreach($list as $key => $val){
116 $display= $val["displayName"][0];
118 if(isset($val['goFonMacroVisible']['0'])&&($val['goFonMacroVisible']['0'] == "1")){
119 $pic1 = $visible;
120 }else{
121 $pic1 = $invisible;
122 }
124 $field1 = array("string" => sprintf($macroimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
125 $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='dn: ".@LDAP::fix($val['dn'])."'");
126 $field3 = array("string" => $pic1, "attach" => "style='width:50px;'");
127 $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:60px;border-right:0px;text-align:right;'");
129 $this->AddElement(array($field1,$field2,$field3,$field4));
130 }
131 }
133 function Save()
134 {
135 MultiSelectWindow :: Save();
136 }
138 function save_object()
139 {
140 /* Save automatic created POSTs like regex, checkboxes */
141 MultiSelectWindow :: save_object();
142 }
143 }
144 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
145 ?>