53872dabb41229b99905a76ed2cecad135782681
1 <?php
3 class divListMimeTypes extends MultiSelectWindow
4 {
5 /* Current base */
6 var $selectedBase = "";
7 var $departments = array();
8 var $parent ;
9 var $ui ;
11 /* Regex */
12 var $Regex = "*";
14 /* Subsearch checkbox */
15 var $SubSearch;
17 function divListMimeTypes (&$config, &$parent)
18 {
19 /* Create divlist and setup */
20 MultiSelectWindow::MultiSelectWindow($config, "Mimetypes", "mimetypes");
22 /* initialize required attributes */
23 $this->parent = &$parent;
24 $this->ui = get_userinfo();
26 /* Set list strings */
27 $this->SetTitle (_("List of defined mime types"));
28 $this->SetSummary (_("List of defined mime types"));
30 /* Result page will look like a headpage */
31 $this->SetHeadpageMode();
32 $this->EnableAplhabet(true);
34 /* Disable buttonsm */
35 $this->EnableCloseButton(false);
36 $this->EnableSaveButton (false);
38 /* set Page header */
39 $action_col_size = 80;
40 if($this->parent->snapshotEnabled()){
41 $action_col_size += 38;
42 }
44 /* Toggle all selected / deselected */
45 $chk = "<input type='checkbox' id='select_all' name='select_all' title='"._("Select all")."'
46 onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
48 /* set Page header */
49 $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'"));
50 $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"));
51 $this->AddHeader(array("string" => _("Mime type")." / "._("Department"), "attach" => "style=''"));
52 $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
54 /* Add SubSearch checkbox */
55 $this->AddCheckBox("SubSearch", msgPool::selectToView("","subsearch"), msgPool::selectToView("","subsearch_small"), false);
57 /* Name ,Text ,Default , Connect with alphabet */
58 $this->AddRegex ("Regex", _("Display mime types matching"),"*" , true);
59 }
62 function AddUserBoxToFilter($position)
63 {
64 $str = "";
65 if(($position == 2) && ($this->parent->IsReleaseManagementActivated($this->config))){
66 $smarty = get_smarty();
67 $releases = $this->parent->getReleases();
68 $smarty->assign("mime_release" , $releases[$this->parent->mime_release]);
69 $smarty->assign("mime_base" , $releases[$this->parent->mime_base]);
70 $smarty->assign("branchimage","images/branch.png");
71 $smarty->assign("mime_releases", $releases);
72 $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE));
73 }
74 return($str);
75 }
78 /* Create list header, with create / copy & paste etc*/
79 function GenHeader()
80 {
83 /* Add default header */
84 $listhead = MultiSelectWindow::get_default_header(false);
85 if(!$this->parent->IsReleaseManagementActivated()){
87 /* Prepare departments,
88 which are shown in the listbox on top of the listbox
89 */
90 $options= "";
92 /* Get all departments within this subtree */
93 $ui= get_userinfo();
94 $first = "";
95 $found = FALSE;
96 $base = $this->config->current['BASE'];
98 /* Add base */
99 $tmp = array();
100 $tmp[] = array("dn"=>$this->config->current['BASE']);
101 $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
102 array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
104 $deps = array();
105 foreach($tmp as $tm){
106 $deps[$tm['dn']] = $tm['dn'];
107 }
109 /* Load possible departments */
110 $ui= get_userinfo();
111 $tdeps= $ui->get_module_departments($this->module);
112 $ids = $this->config->idepartments;
113 $first = "";
114 $found = FALSE;
115 foreach($ids as $dep => $name){
116 if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
118 /* Keep first base dn in mind, we could need this
119 * info if no valid base was found
120 */
121 if(empty($first)) {
122 $first = $dep['dn'];
123 }
125 $value = $ids[$dep];
126 if ($this->selectedBase == $dep){
127 $found = TRUE;
128 $options.= "<option selected='selected' value='".$dep."'>$value</option>";
129 } else {
130 $options.= "<option value='".$dep."'>$value</option>";
131 }
132 }
133 }
135 /* The currently used base is not visible with your acl setup.
136 * Set base to first useable base.
137 */
138 if(!$found){
139 $this->selectedBase = $first;
140 }
142 /* And at least add a department selection box */
143 $listhead .= _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
144 " <input class='center' type='image' src='images/lists/submit.png' align='middle'
145 title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ";
147 }
149 /* Get acls */
150 $ui = get_userinfo();
151 $acl = $ui->get_permissions($this->parent->mime_base,"mimetypes/mimetype");
152 $acl_all = $ui->has_complete_category_acls($this->parent->mime_base,"mimetypes") ;
155 /* If this is true we add an additional seperator. Just look a few lines below */
156 $add_sep = false;
158 /* Create Layers menu */
159 $s = ".|"._("Actions")."|\n";
161 /* Append create options */
162 if(preg_match("/c/",$acl)) {
163 $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
164 " "._("Create")."|\n";
165 $s.= "...|<input class='center' type='image' src='images/list_new_mime.png' alt=''>".
166 " "._("Mime type")."|mime_new|\n";
167 $s.= "..|---|\n";
168 }
170 /* Multiple options */
171 $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'>".
172 " "._("Remove")."|"."remove_multiple|\n";
174 if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){
175 $s.= "..|---|\n";
176 $s.= "..|<img src='images/lists/copy.png' alt='' border='0' class='center'>".
177 " "._("Copy")."|"."multiple_copy_systems|\n";
178 if(is_object($this->parent->CopyPasteHandler) && preg_match("/(r.*d|d.*r)/",$acl_all)){
179 $s.= "..|<img src='images/lists/cut.png' alt='' border='0' class='center'>".
180 " "._("Cut")."|"."multiple_cut_systems|\n";
181 }
182 }
184 /* Copy & paste icons */
185 if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){
186 $img = "<img border='0' class='center' src='images/lists/paste.png' alt=''>";
187 $s.="..|".$img." "._("Paste")."|editPaste|\n";
188 }else{
189 $img = "<img border='0' class='center' src='images/lists/paste-grey.png' alt=''>";
190 $s.="..|".$img." "._("Paste")."\n";
191 }
193 /* Add snapshot icons */
194 if(preg_match("/(c.*w|w.*c)/",$acl_all)){
195 $s .= "..|---|\n";
196 $s .= $this->get_snapshot_header(TRUE);
197 }
199 $this->SetDropDownHeaderMenu($s);
200 $this->SetListHeader($listhead);
201 }
204 /* Some basic settings */
205 function execute()
206 {
207 $this->ClearElementsList();
208 $this->GenHeader();
209 }
212 function setEntries($list)
213 {
214 /********************
215 Variable init
216 ********************/
218 /* Create links */
219 $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
220 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
221 $userimg = "<img class='center' src='plugins/groups/images/groups.png' alt='User' title='%s'>";
222 $mimeimg = "<img class='center' src='images/select_mimetype.png' alt='A' title='"._("Mime type")."'>";
223 $empty = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
225 /* set Page header */
226 $action_col_size = 80;
227 if($this->parent->snapshotEnabled()){
228 $action_col_size += 38;
229 }
231 /********************
232 Attach objects
233 ********************/
235 foreach($list as $key => $val){
237 $ui = get_userinfo();
238 $acl = $ui->get_permissions($val['dn'],"mimetypes/mimetype");
239 $acl_all = $ui->has_complete_category_acls($val['dn'],"mimetypes") ;
241 $action = "";
242 if(preg_match("/(r.*d|r.*d)/",$acl_all) && $this->parent->CopyPasteHandler){
243 $action.= "<input class='center' type='image'
244 src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'> ";
245 }else{
246 $action.="<img src='images/empty.png' alt=' ' class='center'> ";
247 }
249 if(preg_match("/r/",$acl_all) && $this->parent->CopyPasteHandler){
250 $action.= "<input class='center' type='image'
251 src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'> ";
252 }else{
253 $action.="<img src='images/empty.png' alt=' ' class='center'> ";
254 }
256 $action.= "<input class='center' type='image'
257 src='images/lists/edit.png' alt='"._("edit")."' name='mime_edit_%KEY%' title='"._("Edit this entry")."'>";
259 /* Add snapshot icon */
260 if(preg_match("/(r.*w|w.*r)/",$acl_all)){
261 $action.= $this->GetSnapShotActions($val['dn']);
262 }else{
263 $action.="<img src='images/empty.png' alt=' ' class='center'> ";
264 $action.="<img src='images/empty.png' alt=' ' class='center'> ";
265 }
267 /* Add delete button */
268 if(preg_match("/d/",$acl)){
269 $action.= "<input class='center' type='image'
270 src='images/lists/trash.png' alt='"._("delete")."' name='mime_del_%KEY%' title='"._("Delete this entry")."'>";
271 }else{
272 $action.= "<img src='images/empty.png' alt=' ' class='center'>";
273 }
275 $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'";
277 if(!isset($val['description'][0])){
278 $desc = "";
279 }else{
280 $desc = " - [ ".$val['description'][0]." ]";
281 }
283 /* Cutted objects should be displayed in light grey */
284 $display = $val['cn'][0].$desc;
285 if($this->parent->CopyPasteHandler){
286 foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
287 if($queue_data['dn'] == $val['dn']) {
288 $display = "<font color='#999999'>".$display."</font>";
289 break;
290 }
291 }
292 }
295 /* Create each field */
296 $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
297 "attach" => "style='width:20px;'");
298 $field1 = array("string" => sprintf($mimeimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
299 $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title);
300 $field3 = array("string" => preg_replace("/%KEY%/", $key, $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
301 $this->AddElement(array($field0,$field1,$field2,$field3));
302 }
305 /* Create summary string for list footer */
306 $num_deps=0;
307 if(!$this->SubSearch){
308 $num_deps = count($this->Added_Departments);
309 }
310 $num_objs = count($list);
312 $num_obj_str = _("Number of listed mimetypes");
313 $num_dep_str = _("Number of listed departments");
315 $str = "<img class='center' src='images/select_mimetype.png'
316 title='".$num_obj_str."' alt='".$num_obj_str."'> ".$num_objs." ";
317 $str.= "<img class='center' src='images/lists/folder.png'
318 title='".$num_dep_str."' alt='".$num_dep_str."'> ".$num_deps." ";
320 $this->set_List_Bottom_Info($str);
321 }
323 function Save()
324 {
325 MultiSelectWindow::Save();
326 }
328 function save_object()
329 {
330 /* Save automatic created POSTs like regex, checkboxes */
331 MultiSelectWindow::save_object();
332 }
334 }
335 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
336 ?>