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. You may want to use the range selector on top of the macro listbox, when working with a large number of macros."));
38 $this->EnableAplhabet (true);
40 /* Disable buttonsm */
41 $this->EnableCloseButton(false);
42 $this->EnableSaveButton (false);
44 /* Dynamic action col, depending on snapshot icons */
45 $action_col_size = 50;
46 if($this->parent->snapshotEnabled()){
47 $action_col_size += 20;
48 }
50 /* set Page header */
51 $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"));
52 $this->AddHeader(array("string" => _("macro name")." / "._("Department"), "attach" => "style=''"));
53 $this->AddHeader(array("string" => _("Visible"), "attach" => "style='width:50px;'"));
54 $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'" ));
56 /* Add Checkboxes / SubSearch checkbox */
57 $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false);
59 /* Name ,Text ,Default , Connect with alphabet */
60 $this->AddRegex ("Regex", _("Regular expression for matching macro names"),"*" , true);
61 }
63 function GenHeader()
64 {
65 /* Prepare departments,
66 which are shown in the listbox on top of the listbox
67 */
68 $options= "";
69 foreach ($this->config->idepartments as $key => $value){
70 if ($this->selectedBase == $key){
71 $options.= "<option selected='selected' value='$key'>$value</option>";
72 } else {
73 $options.= "<option value='$key'>$value</option>";
74 }
75 }
77 /* NEW LIST MANAGMENT */
78 $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
79 " <input class='center' type='image' src='images/list_root.png' align='middle'
80 title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
81 " <input class='center' type='image' align='middle' src='images/list_back.png'
82 title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
83 " <input class='center' type='image' align='middle' src='images/list_home.png'
84 title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
85 " <input class='center' type='image' src='images/list_reload.png' align='middle'
86 title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'> ".
87 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
89 if($this->parent->snapshotEnabled()){
90 $listhead .= " <input class='center' type='image' align='middle' src='images/restore.png'
91 title='"._("Restore snapshopts of already deleted objects")."' alt='"._("Restore")."' name='RestoreDeletedSnapShot'>".
92 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
93 }
95 $listhead .= " <input class='center' type='image' align='middle' src='images/list_new_macro.png'
96 title='"._("Create new phone macro")."' alt='"._("New")."' name='user_new'> ".
97 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
98 _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
99 " <input class='center' type='image' src='images/list_submit.png' align='middle'
100 title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
101 "</div>";
103 $this->SetListHeader($listhead);
104 }
106 function execute()
107 {
108 $this->ClearElementsList();
109 $this->GenHeader();
110 }
112 function setEntries($list)
113 {
115 $action = "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'
116 name='user_edit_%KEY%' title='"._("Edit macro")."'>";
117 $action .= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."'
118 name='user_del_%KEY%' title='"._("Delete macro")."'>";
120 $empty = "<img class='center' src='images/nothing.png' style='width:16px;height:16px;' alt=''>";
121 $macroimg = "<img class='center' src='images/list_macro.png' alt='"._("Macro")."' title='%s'>";
122 $visible = "<img class='center' src='images/true.png' alt='"._("yes")."' title='"._("visible")."'>";
123 $invisible = "<img class='center' src='images/false.png' alt='"._("no")."'title='"._("invisible")."'>";
124 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
126 /* Dynamic action col, depending on snapshot icons */
127 $action_col_size = 50;
128 if($this->parent->snapshotEnabled()){
129 $action_col_size += 20;
130 }
132 foreach($list as $key => $val){
134 $action= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'
135 name='user_edit_%KEY%' title='"._("Edit macro")."'>";
136 $action.= $this->GetSnapShotActions($val['dn']);
137 $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."'
138 name='user_del_%KEY%' title='"._("Delete macro")."'>";
140 $display= $val["displayName"][0];
142 if(isset($val['goFonMacroVisible']['0'])&&($val['goFonMacroVisible']['0'] == "1")){
143 $pic1 = $visible;
144 }else{
145 $pic1 = $invisible;
146 }
148 $field1 = array("string" => sprintf($macroimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
149 $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'");
150 $field3 = array("string" => $pic1, "attach" => "style='width:50px;'");
151 $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
153 $this->AddElement(array($field1,$field2,$field3,$field4));
154 }
155 }
157 function Save()
158 {
159 MultiSelectWindow :: Save();
160 }
162 function save_object()
163 {
164 /* Save automatic created POSTs like regex, checkboxes */
165 MultiSelectWindow :: save_object();
166 }
167 }
168 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
169 ?>