19fe00bda4140203e4236b3ab5addd76b70f73e0
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 /* Add default header */
100 $listhead = MultiSelectWindow::get_default_header();
102 /* Add snaphot icons, if allowed */
103 if(preg_match("/(c.*w|w.*c)/",$acl_all)){
104 $listhead .= $this->get_snapshot_header($this->selectedBase);
105 }
107 /* Add create icon if allowed */
108 if(preg_match("/c/",$acl)){
109 $listhead .= " <input class='center' type='image' align='middle' src='images/list_new_blocklist.png' ".
110 " title='"._("Create new blocklist")."' alt='"._("New Blocklist")."' name='goFaxBlocklist_new'> ".
111 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>";
112 }
114 /* Append department selector */
115 $listhead .= " "._("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
116 " <input class='center' type='image' src='images/list_submit.png' align='middle'
117 title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
118 "</div>";
120 $this->SetListHeader($listhead);
121 }
123 function execute()
124 {
125 $this->ClearElementsList();
126 $this->GenHeader();
127 }
129 function setEntries($list)
130 {
131 // User and Template Images
132 $blockimg = "<img class='center' src='images/list_blocklist.png' alt='User' title='%s'>";
133 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
135 /* Dynamic action col, depending on snapshot icons */
136 $action_col_size = 50;
137 if($this->parent->snapshotEnabled()){
138 $action_col_size += 20;
139 }
141 /* Append to list */
142 $ui = get_userinfo();
143 foreach($list as $key => $val){
145 $acl = $ui->get_permissions($val['dn'],"gofaxlist/blocklist");
146 if(!preg_match("/r/",$acl)){
147 continue;
148 }
150 /* Edit link ; requires read access */
151 $action= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."' name='goFaxBlocklist_edit_%KEY%' title='"._("Edit user")."'>";
154 /* Create snapshot ; requires write access && create access */
155 if(preg_match("/w/",$acl) && preg_match("/c/",$acl)){
156 $action.= $this->GetSnapShotActions($val['dn']);
157 }
159 /* Delete entry ; requires remove access */
160 if(preg_match("/d/",$acl)){
161 $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='goFaxBlocklist_del_%KEY%' title='"._("Delete user")."'>";
162 }
164 // Generate Array to Add
165 if(isset($val["description"][0])){
166 $display= $val["cn"][0]." [".$val["description"][0]."]";
167 }else{
168 $display= $val["cn"][0];
169 }
170 $field1 = array("string" => sprintf($blockimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
171 $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'");
172 $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
173 $this->AddElement( array($field1,$field2,$field3));
174 }
175 }
177 function Save()
178 {
179 MultiSelectWindow :: Save();
180 }
182 function save_object()
183 {
184 /* Save automatic created POSTs like regex, checkboxes */
185 MultiSelectWindow :: save_object();
186 }
187 }
188 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
189 ?>