Code

Added logging to fax extensions
[gosa.git] / plugins / gofax / blocklists / class_divListBlocklists.inc
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");
26     
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);
39   
40     /* Disable buttonsm */
41     $this->EnableCloseButton(false);
42     $this->EnableSaveButton (false);
44     /* Dynamic action col, depending on snapshot icons */
45     $action_col_size = 60;
46     if($this->parent->snapshotEnabled()){
47       $action_col_size += 20;
48     }
50     /* Toggle all selected / deselected */
51     $chk = "<input type='checkbox' id='select_all' name='select_all'
52                onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
54     /* set Page header */
55     $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
56     $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
57     $this->AddHeader(array("string" => _("Blocklist name")." / "._("Department"), "attach" => "style=''"));
58     $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'" ));
60     /* Add Checkboxes / SubSearch checkbox */
61     $this->AddCheckBox("ShowSendBocklists"     , _("Select to see send blocklists"),    _("Show send blocklists"),true);
62     $this->AddCheckBox("ShowReceiveBlocklists" , _("Select to see receive blocklists"), _("Show receive blocklists"),true);
63   
64     $this->AddCheckBox(SEPERATOR);
65     $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Ignore subtrees"), false);
67     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
68     $this->AddRegex   ("Regex",     _("Regular expression for matching list names"),"*" , true);
69   }
72   function GenHeader()
73   {
74     /* Prepare departments,
75        which are shown in the listbox on top of the listbox
76      */
77     $options= "";
79     /* Get all departments within this subtree */
80     $base = $this->config->current['BASE'];
82     /* Add base */
83     $deps[] = array("dn"=>$this->config->current['BASE']);
84     $deps= array_merge($deps,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
85                     array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
87     /* Load possible departments */
88     $first = "";
89     $found = FALSE;
90     $ui= get_userinfo();
91     $tdeps= $ui->get_module_departments("gofaxlist");
92     $ids = $this->config->idepartments;
93     foreach($deps as $dep){
94       if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
96         /* Keep first base dn in mind, we could need this
97          *  info if no valid base was found
98          */
99         if(empty($first)) {
100           $first = $dep['dn'];
101         }
102   
103         $value = $ids[$dep['dn']];
104         if ($this->selectedBase == $dep['dn']){
105           $found = TRUE;
106           $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
107         } else {
108           $options.= "<option value='".$dep['dn']."'>$value</option>";
109         }
110       }
111     }
113     /* The currently used base is not visible with your acl setup.
114      * Set base to first useable base.
115      */
116     if(!$found){
117       $this->selectedBase = $first;
118     }
119   
120     /* Get acls */
121     $ui       = get_userinfo();
122     $acl      = $ui->get_permissions($this->selectedBase,"gofaxlist/blocklist");
123     $acl_all  = $ui->has_complete_category_acls($this->selectedBase,"gofaxlist");
125     /* Add default header */
126     $listhead = MultiSelectWindow::get_default_header();
128     /* Add snaphot icons, if allowed */
129     if(preg_match("/(c.*w|w.*c)/",$acl_all)){
130       $listhead .= $this->get_snapshot_header($this->selectedBase);
131     }
133     /* Add create icon if allowed */
134     if(preg_match("/c/",$acl)){
135       $listhead .= " <input class='center' type='image' align='middle' src='images/list_new_blocklist.png' ".
136         "  title='"._("Create new blocklist")."' alt='"._("New Blocklist")."' name='goFaxBlocklist_new'>&nbsp;".
137         " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>";
138     }
139   
140     /* Append department selector */
141     $listhead .= "&nbsp;"._("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
142       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
143           title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;";
145     /* Multiple options */
146     $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/edittrash.png'
147         title='"._("Remove selected blocklists")."' alt='"._("Remove blocklists")."' name='remove_multiple_blocklists'>&nbsp;";
149     $listhead .="</div>";
151     $this->SetListHeader($listhead);
152   }
154   function execute()
155   {
156     $this->ClearElementsList();
157     $this->GenHeader();
158   }
160   function setEntries($list)
161   {
162     // User and Template  Images
163     $blockimg = "<img class='center' src='images/list_blocklist.png' alt='User' title='%s'>";
164     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
166     /* Dynamic action col, depending on snapshot icons */
167     $action_col_size = 60;
168     if($this->parent->snapshotEnabled()){
169       $action_col_size += 20;
170     }
172     /* Append to list */
173     $ui = get_userinfo();
174     foreach($list as $key => $val){
176       $acl = $ui->get_permissions($val['dn'],"gofaxlist/blocklist");
177       if(!preg_match("/r/",$acl)){
178         continue;
179       }  
181       /* Edit link ; requires read access */
182       $action= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'     name='goFaxBlocklist_edit_%KEY%' title='"._("Edit user")."'>";
184       
185       /* Create snapshot ; requires write access && create access */
186       if(preg_match("/w/",$acl) && preg_match("/c/",$acl)){
187         $action.= $this->GetSnapShotActions($val['dn']);
188       }
189       
190       /* Delete entry ; requires remove access */
191       if(preg_match("/d/",$acl)){
192         $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='goFaxBlocklist_del_%KEY%' title='"._("Delete user")."'>";
193       }
194       
195       // Generate Array to Add
196       if(isset($val["description"][0])){
197         $display= $val["cn"][0]." [".$val["description"][0]."]";
198       }else{
199         $display= $val["cn"][0];
200       }
202       
203       /* Create each field */
204       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
205                       "attach" => "style='width:20px;'");
206       $field1 = array("string" => sprintf($blockimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
207       $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'");
208       $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
209       $this->AddElement( array($field0,$field1,$field2,$field3));
210     }
211   }
213   function Save()
214   {
215     MultiSelectWindow :: Save();  
216   }
218   function save_object()
219   {
220     /* Save automatic created POSTs like regex, checkboxes */
221     MultiSelectWindow :: save_object();   
222   }
224 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
225 ?>