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 /* set Page header */
45 $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"));
46 $this->AddHeader(array("string" => _("Blocklist name")." / "._("Department"), "attach" => "style=''"));
47 $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ));
49 /* Add Checkboxes / SubSearch checkbox */
50 $this->AddCheckBox("ShowSendBocklists" , _("Select to see send blocklists"), _("Show send blocklists"),true);
51 $this->AddCheckBox("ShowReceiveBlocklists" , _("Select to see receive blocklists"), _("Show receive blocklists"),true);
53 $this->AddCheckBox(SEPERATOR);
54 $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false);
56 /* Name ,Text ,Default , Connect with alphabet */
57 $this->AddRegex ("Regex", _("Regular expression for matching list names"),"*" , true);
58 }
60 function GenHeader()
61 {
62 /* Prepare departments,
63 which are shown in the listbox on top of the listbox
64 */
65 $options= "";
66 foreach ($this->config->idepartments as $key => $value){
67 if ($this->selectedBase == $key){
68 $options.= "<option selected='selected' value='$key'>$value</option>";
69 } else {
70 $options.= "<option value='$key'>$value</option>";
71 }
72 }
74 /* Add default header */
75 $listhead = MultiSelectWindow::get_default_header();
76 $listhead.= " <input class='center' type='image' align='middle' src='images/list_new_blocklist.png'
77 title='"._("Create new blocklist")."' alt='"._("New Blocklist")."' name='user_new'> ".
78 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>".
79 " "._("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
80 " <input class='center' type='image' src='images/list_submit.png' align='middle'
81 title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
82 "</div>";
84 $this->SetListHeader($listhead);
85 }
87 function execute()
88 {
89 $this->ClearElementsList();
90 $this->GenHeader();
91 }
93 function setEntries($list)
94 {
95 $action= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."' name='user_edit_%KEY%' title='"._("Edit user")."'>";
96 $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='user_del_%KEY%' title='"._("Delete user")."'>";
98 // User and Template Images
99 $blockimg = "<img class='center' src='images/list_blocklist.png' alt='User' title='%s'>";
100 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
102 /* Append to list */
103 foreach($list as $key => $val){
104 // Generate Array to Add
105 $display= "[".$val["cn"][0]."]";
106 $field1 = array("string" => sprintf($blockimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
107 $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'");
108 $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:60px;border-right:0px;text-align:right;'");
109 $this->AddElement( array($field1,$field2,$field3));
110 }
111 }
113 function Save()
114 {
115 MultiSelectWindow :: Save();
116 }
118 function save_object()
119 {
120 /* Save automatic created POSTs like regex, checkboxes */
121 MultiSelectWindow :: save_object();
122 }
123 }
124 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
125 ?>