Code

Added branches container for old stuff
[gosa.git] / gosa-plugins / gofax / 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();
37     $this->EnableAplhabet   (true);
38   
39     /* Disable buttonsm */
40     $this->EnableCloseButton(false);
41     $this->EnableSaveButton (false);
43     /* Dynamic action col, depending on snapshot icons */
44     $action_col_size = 100;
45     if($this->parent->snapshotEnabled()){
46       $action_col_size += 20;
47     }
49     /* Toggle all selected / deselected */
50     $chk = "<input type='checkbox' id='select_all' name='select_all' title='"._("Select all")."'
51                onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
53     /* set Page header */
54     $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
55     $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
56     $this->AddHeader(array("string" => _("Name")." / "._("Department"), "attach" => "style=''"));
57     $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'" ));
59     /* Add Checkboxes / SubSearch checkbox */
60     $this->AddCheckBox("ShowSendBocklists"     , msgPool::selectToView(_("Send blocklist")),     _("Show send blocklists"),true);
61     $this->AddCheckBox("ShowReceiveBlocklists" , msgPool::selectToView(_("Receive blocklist")),  _("Show receive blocklists"),true);
62   
63     $this->AddCheckBox(SEPERATOR);
64     $this->AddCheckBox("SubSearch",  msgPool::selectToView("","subsearch"), msgPool::selectToView("","subsearch_small"), false);
66     /* Name,Text,Default,Connect with alphabet */
67     $this->AddRegex   ("Regex",     _("Regular expression for matching list names"),"*" , true);
68   }
71   function GenHeader()
72   {
73     /* Get all departments within this subtree */
74     $base = $this->config->current['BASE'];
75     $options  = $this->create_department_list($this->module);
76   
77     /* Get acls */
78     $ui       = get_userinfo();
79     $acl      = $ui->get_permissions($this->selectedBase,"gofaxlist/blocklist");
80     $acl_all  = $ui->has_complete_category_acls($this->selectedBase,"gofaxlist");
82     /* Add default header */
83     $listhead = MultiSelectWindow::get_default_header();
85     /* Append department selector */
86     $listhead .= "&nbsp;"._("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
87       " <input class='center' type='image' src='images/lists/submit.png' align='middle' 
88           title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;";
90     /* Create Layers menu */
91     $s  = ".|"._("Actions")."|\n";
93     /* Append create options */
94     if(preg_match("/c/",$acl)) {
95       $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
96         "&nbsp;"._("Create")."|\n";
97       $s.= "...|<input class='center' type='image' src='plugins/gofax/images/list_new_blocklist.png' alt=''>".
98         "&nbsp;"._("Blocklist")."|goFaxBlocklist_new|\n";
99       $s.= "..|---|\n";
100     }
102     /* Multiple options */
103     $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'>".
104       "&nbsp;"._("Remove")."|"."remove_multiple|\n";
106     /* Add Copy & Paste header */
107     $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module);
109     /* Add snapshot icons */
110     $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module);
112     $this->SetDropDownHeaderMenu($s);
113     $this->SetListHeader($listhead);
114   }
116   function execute()
117   {
118     $this->ClearElementsList();
119     $this->GenHeader();
120   }
122   function setEntries($list)
123   {
124     // User and Template  Images
125     $blockimg = "<img class='center' src='plugins/gofax/images/list_blocklist.png' alt='User' title='%s'>";
126     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
128     /* Dynamic action col, depending on snapshot icons */
129     $action_col_size = 100;
130     if($this->parent->snapshotEnabled()){
131       $action_col_size += 20;
132     }
134     /* Append to list */
135     $ui = get_userinfo();
136     foreach($list as $key => $val){
138       $acl = $ui->get_permissions($val['dn'],"gofaxlist/blocklist");
139       $acl_all  = $ui->has_complete_category_acls($val['dn'],"gofaxlist");
141       if(!preg_match("/r/",$acl)){
142         continue;
143       }  
145       $action ="";
147       /* Add copy & cut functionality */
148       $action.= $this->parent->get_copypaste_action($val['dn'],"gofaxlist","blocklist");
150       /* Edit link ; requires read access */
151       $action.= "<input class='center' type='image' src='images/lists/edit.png' alt='"._("edit")."'     name='goFaxBlocklist_edit_%KEY%' title='"._("Edit user")."'>";
153       /* Add snapshot icon */
154       $action.= $this->parent->get_snapshot_action($val['dn'],$this->module);
155  
156       /* Delete entry ; requires remove access */
157       if(preg_match("/d/",$acl)){
158         $action.= "<input class='center' type='image' src='images/lists/trash.png' alt='"._("delete")."' name='goFaxBlocklist_del_%KEY%' title='"._("Delete user")."'>";
159       }
160       
161       // Generate Array to Add
162       if(isset($val["description"][0])){
163         $display= $val["cn"][0]." [".$val["description"][0]."]";
164       }else{
165         $display= $val["cn"][0];
166       }
168       /* Cutted objects should be displayed in light grey */
169       if(isset($this->parent->CopyPasteHandler->queue) && is_array($this->parent->CopyPasteHandler->queue)){
170         foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
171           if($queue_data['dn'] == $val['dn']) {
172             $display = "<font color='#999999'>".$display."</font>";
173             break;
174           }
175         }
176       }
178       
179       /* Create each field */
180       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
181                       "attach" => "style='width:20px;'");
182       $field1 = array("string" => sprintf($blockimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
183       $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'");
184       $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
185       $this->AddElement( array($field0,$field1,$field2,$field3));
186     }
188     /* Create summary string for list footer */
189     $num_deps=0;
190     if(!$this->SubSearch){
191       $num_deps = count($this->Added_Departments);
192     }
193     $num_objs = count($list);
195     $num_obj_str = sprintf(_("Number of listed '%s'"),_("blocklists"));
196     $num_dep_str = sprintf(_("Number of listed '%s'"),_("departments"));
198     $str = "<img class='center' src='plugins/gofax/images/list_blocklist.png'
199               title='".$num_obj_str."' alt='".$num_obj_str."'>&nbsp;".$num_objs."&nbsp;&nbsp;&nbsp;&nbsp;";
200     $str.= "<img class='center' src='images/lists/folder.png'
201               title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
203     $this->set_List_Bottom_Info($str);
205   }
207   function Save()
208   {
209     MultiSelectWindow :: Save();  
210   }
212   function save_object()
213   {
214     /* Save automatic created POSTs like regex, checkboxes */
215     MultiSelectWindow :: save_object();   
216   }
218 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
219 ?>