1 <?php
3 class divListBlocklist 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 $ShowReceiveBlocklists ;
17 /* Subsearch checkbox */
18 var $SubSearch;
20 var $parent ;
21 var $ui ;
23 function divListBlocklist ($config,$parent)
24 {
25 MultiSelectWindow::MultiSelectWindow($config,"Blocklists");
27 $this->parent = $parent;
28 $this->ui = get_userinfo();
30 /* Set list strings */
31 $this->SetTitle(_("List of blocklists"));
32 $this->SetSummary(_("List of blocklists"));
34 /* Result page will look like a headpage */
35 $this->SetHeadpageMode();
36 $this->SetInformation(_("This menu allows you to create, delete and edit selected blocklists. Having a large size of lists, you might prefer the range selectors on top of the select box."));
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" => _("Blocklist name")." / "._("Department"), "attach" => "style=''"));
53 $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'" ));
55 /* Add Checkboxes / SubSearch checkbox */
56 $this->AddCheckBox("ShowSendBocklists" , _("Select to see send blocklists"), _("Show send blocklists"),true);
57 $this->AddCheckBox("ShowReceiveBlocklists" , _("Select to see receive blocklists"), _("Show receive blocklists"),true);
59 $this->AddCheckBox(SEPERATOR);
60 $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false);
62 /* Name ,Text ,Default , Connect with alphabet */
63 $this->AddRegex ("Regex", _("Regular expression for matching list names"),"*" , true);
64 }
66 function GenHeader()
67 {
68 /* Prepare departments,
69 which are shown in the listbox on top of the listbox
70 */
71 $options= "";
72 foreach ($this->config->idepartments as $key => $value){
73 if ($this->selectedBase == $key){
74 $options.= "<option selected='selected' value='$key'>$value</option>";
75 } else {
76 $options.= "<option value='$key'>$value</option>";
77 }
78 }
80 /* NEW LIST MANAGMENT */
81 $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
82 " <input class='center' type='image' src='images/list_root.png' align='middle'
83 title='"._("Go to root department")."' name='dep_root' alt='". _("Root")."'> ".
84 " <input class='center' type='image' align='middle' src='images/list_back.png'
85 title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
86 " <input class='center' type='image' align='middle' src='images/list_home.png'
87 title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
88 " <input class='center' type='image' src='images/list_reload.png' align='middle'
89 title='"._("Reload list")."' name='submit_department' alt='". _("Submit")."'> ".
90 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
92 if($this->parent->snapshotEnabled()){
93 $listhead .= " <input class='center' type='image' align='middle' src='images/restore.png'
94 title='"._("Restore snapshopts of already deleted objects")."' alt='"._("Restore")."' name='RestoreDeletedSnapShot'>".
95 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
96 }
98 $listhead .= " <input class='center' type='image' align='middle' src='images/list_new_blocklist.png'
99 title='"._("Create new blocklist")."' alt='"._("New Blocklist")."' name='user_new'> ".
100 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>".
101 " "._("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
102 " <input class='center' type='image' src='images/list_submit.png' align='middle'
103 title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
104 "</div>";
106 $this->SetListHeader($listhead);
107 }
109 function execute()
110 {
111 $this->ClearElementsList();
112 $this->GenHeader();
113 }
115 function setEntries($list)
116 {
117 // User and Template Images
118 $blockimg = "<img class='center' src='images/list_blocklist.png' alt='User' title='%s'>";
119 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
121 /* Dynamic action col, depending on snapshot icons */
122 $action_col_size = 50;
123 if($this->parent->snapshotEnabled()){
124 $action_col_size += 20;
125 }
127 /* Append to list */
128 foreach($list as $key => $val){
130 $action = $this->GetSnapShotActions($val['dn']);
131 $action.= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."' name='user_edit_%KEY%' title='"._("Edit user")."'>";
132 $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='user_del_%KEY%' title='"._("Delete user")."'>";
134 // Generate Array to Add
135 $display= "[".$val["cn"][0]."]";
136 $field1 = array("string" => sprintf($blockimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
137 $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'");
138 $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
139 $this->AddElement( array($field1,$field2,$field3));
140 }
141 }
143 function Save()
144 {
145 MultiSelectWindow :: Save();
146 }
148 function save_object()
149 {
150 /* Save automatic created POSTs like regex, checkboxes */
151 MultiSelectWindow :: save_object();
152 }
153 }
154 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
155 ?>