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", "gofaxlist");
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 }
67 function GenHeader()
68 {
69 /* Prepare departments,
70 which are shown in the listbox on top of the listbox
71 */
72 $options= "";
74 /* Get all departments within this subtree */
75 $base = $this->config->current['BASE'];
76 $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
77 array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
79 /* Load possible departments */
80 $ui= get_userinfo();
81 $tdeps= $ui->get_module_departments("gofaxlist");
82 $ids = $this->config->idepartments;
83 foreach($deps as $dep){
84 if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
85 $value = $ids[$dep['dn']];
86 if ($this->selectedBase == $dep['dn']){
87 $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
88 } else {
89 $options.= "<option value='".$dep['dn']."'>$value</option>";
90 }
91 }
92 }
94 /* Get acls */
95 $ui = get_userinfo();
96 $acl = $ui->get_permissions($this->selectedBase,"gofaxlist/blocklist");
97 $acl_all = $ui->has_complete_category_acls($this->selectedBase,"gofaxlist");
99 /* NEW LIST MANAGMENT */
100 $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
101 " <input class='center' type='image' src='images/list_root.png' align='middle'
102 title='"._("Go to root department")."' name='dep_root' alt='". _("Root")."'> ".
103 " <input class='center' type='image' align='middle' src='images/list_back.png'
104 title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
105 " <input class='center' type='image' align='middle' src='images/list_home.png'
106 title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
107 " <input class='center' type='image' src='images/list_reload.png' align='middle'
108 title='"._("Reload list")."' name='submit_department' alt='". _("Submit")."'> ".
109 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
111 /* Add snaphot icons, if allowed */
112 if(preg_match("/(c.*w|w.*c)/",$acl_all)){
113 $listhead .= $this->get_snapshot_header($this->selectedBase);
114 }
116 /* Add create icon if allowed */
117 if(preg_match("/c/",$acl)){
118 $listhead .= " <input class='center' type='image' align='middle' src='images/list_new_blocklist.png' ".
119 " title='"._("Create new blocklist")."' alt='"._("New Blocklist")."' name='user_new'> ".
120 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>";
121 }
123 /* Append department selector */
124 $listhead .= " "._("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
125 " <input class='center' type='image' src='images/list_submit.png' align='middle'
126 title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
127 "</div>";
129 $this->SetListHeader($listhead);
130 }
132 function execute()
133 {
134 $this->ClearElementsList();
135 $this->GenHeader();
136 }
138 function setEntries($list)
139 {
140 // User and Template Images
141 $blockimg = "<img class='center' src='images/list_blocklist.png' alt='User' title='%s'>";
142 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
144 /* Dynamic action col, depending on snapshot icons */
145 $action_col_size = 50;
146 if($this->parent->snapshotEnabled()){
147 $action_col_size += 20;
148 }
150 /* Append to list */
151 $ui = get_userinfo();
152 foreach($list as $key => $val){
154 $acl = $ui->get_permissions($val['dn'],"gofaxlist/blocklist");
155 if(!preg_match("/r/",$acl)){
156 continue;
157 }
159 /* Edit link ; requires read access */
160 $action= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."' name='user_edit_%KEY%' title='"._("Edit user")."'>";
163 /* Create snapshot ; requires write access && create access */
164 if(preg_match("/w/",$acl) && preg_match("/c/",$acl)){
165 $action.= $this->GetSnapShotActions($val['dn']);
166 }
168 /* Delete entry ; requires remove access */
169 if(preg_match("/d/",$acl)){
170 $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='user_del_%KEY%' title='"._("Delete user")."'>";
171 }
173 // Generate Array to Add
174 if(isset($val["description"][0])){
175 $display= $val["cn"][0]." [".$val["description"][0]."]";
176 }else{
177 $display= $val["cn"][0];
178 }
179 $field1 = array("string" => sprintf($blockimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
180 $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'");
181 $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
182 $this->AddElement( array($field1,$field2,$field3));
183 }
184 }
186 function Save()
187 {
188 MultiSelectWindow :: Save();
189 }
191 function save_object()
192 {
193 /* Save automatic created POSTs like regex, checkboxes */
194 MultiSelectWindow :: save_object();
195 }
196 }
197 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
198 ?>