3a970c19f66c01802b850c2dd6fbe37a17ce0bde
1 <?php
2 /*
3 * This code is part of GOsa (http://www.gosa-project.org)
4 * Copyright (C) 2003-2008 GONICUS GmbH
5 *
6 * ID: $$Id$$
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
23 define ("SEPERATOR", 1002);
25 class MultiSelectWindow{
27 var $bool_DisplayAlpahabet = false;
28 var $bool_DisplayCloseButton= true;
29 var $bool_DisplaySaveButton = true;
31 var $SaveButtonString = "";
32 var $CloseButtonString = "";
34 var $string_Title = "";
35 var $string_ListHeader = "";
36 var $string_ListDropDown= "";
37 var $string_Summary = "";
38 var $string_Information = "";
40 var $array_Header = array();
41 var $array_Elements = array();
42 var $array_Checkboxes = array();
43 var $array_Regexes = array();
45 var $config = array("");
46 var $is_closed = false;
47 var $is_saved = false;
48 var $is_headpage = false; // if true the design changes
49 var $filterName = "Liste";
50 var $DepartmentsAdded = false;
51 var $Added_Departments = array();
52 var $selectedBase = "";
54 var $DivHeight = "";
56 var $HideFilterPart = false;
57 var $List_Bottom_Info = "";
58 var $SaveAdditionalVars = array(); // Additional Post vars to store
59 var $module= "";
61 var $IgnoreAccount = TRUE;
62 var $footer = "";
64 function ClearElementsList()
65 {
66 $this->array_Elements = array();
67 }
69 function HideFilterPart($bool = true)
70 {
71 $this->HideFilterPart = $bool;
72 }
74 function SetHeight($height)
75 {
76 $this->DivHeight=$height;
77 }
79 /* Adds a regex input field to the current dialog */
80 function AddRegex($name,$string,$value,$conn,$image="images/search.png")
81 {
82 $arr = array();
84 /* Check if the given input field name was already used
85 for this type of dialog */
86 $MultiDialogFilters = session::get('MultiDialogFilters');
87 if(isset($MultiDialogFilters[$this->filterName][$name])){
88 $arr['value'] = $MultiDialogFilters[$this->filterName][$name];
89 $this->$name = $arr['value'];
90 }else{
91 $arr['value'] = $value;
92 }
94 $arr['name'] = $name;
95 $arr['string'] = $string;
96 $arr['image'] = $image;
97 $arr['connAlpha'] = $conn; // Connect with alphabet select
98 $this->array_Regexes[] = $arr;
99 }
102 function SetDropDownHeaderMenu($str)
103 {
104 $this->string_ListDropDown = $str;
105 }
107 function GetDropDownHeaderMenu()
108 {
109 if(!empty($this->string_ListDropDown)){
110 $mid = new LayersMenu(6, 7, 2, 1);
111 $mid->setImgwww("./images/");
112 $mid->setIcondir("./images/");
113 $mid->setDirroot("../include/utils/layer-menu/");
114 $mid->setHorizontalMenuTpl("../ihtml/".get_template_path("",FALSE).'GOsa_MultiSelectHeader.ihtml');
115 $mid->setSubMenuTpl("../ihtml/".get_template_path("",FALSE).'GOsa_MultiSelectHeaderSubEntry.ihtml');
116 $mid->setMenuStructureString($this->string_ListDropDown);
117 $mid->parseStructureForMenu('menu');
118 $mid->newHorizontalMenu('menu');
119 $s = $mid->getHeader();
120 $s.= $mid->getMenu('menu');
121 $s.= $mid->getFooter('menu');
122 return($s);
123 }else{
124 return("");
125 }
126 }
129 /* Contrucktion */
130 function MultiSelectWindow(&$config, $filterName, $module)
131 {
132 $this->config = &$config;
133 $this->module = $module;
134 $this->SaveButtonString = _("Save");
135 $this->CloseButtonString = _("Close");
136 $this->filterName = $filterName;
137 $this->ui = get_userinfo();
138 $this->selectedBase = session::get('CurrentMainBase');
140 /* Check default values for SaveAdditionalVars */
141 $MultiDialogFilters = session::get('MultiDialogFilters');
142 foreach($this->SaveAdditionalVars as $name){
143 if(isset($MultiDialogFilters[$this->filterName][$name])){
144 $this->$name = $MultiDialogFilters[$this->filterName][$name];
145 }
146 }
148 }
150 /* Enables the headpage mode, which changes the list look */
151 function SetHeadpageMode()
152 {
153 $this->is_headpage = true;
154 }
156 /* Sets the List internal name (not displayed anywhere)
157 it is used to identify every single list
158 */
159 function SetTitle($str)
160 {
161 $this->string_Title = $str;
162 }
164 /* Set the list header string */
165 function SetListHeader($str)
166 {
167 $this->string_ListHeader = $str;
168 }
170 /* This sets the list description which is the first gray bar on top of the list */
171 function SetSummary($str)
172 {
173 $this->string_Summary = $str;
174 }
176 /* If the save button is enabled, you can change its caption with this function */
177 function SetSaveButtonString($str)
178 {
179 $this->SaveButtonString = $str;
180 }
182 /* If the close button is enabled, you can change its caption with this function */
183 function SetCloseButtonString($str)
184 {
185 $this->CloseButtonString = $str;
186 }
188 /* With this function you can change the text of the information box */
189 function SetInformation($str)
190 {
191 $this->string_Information = $str;
192 }
194 /* Display the alphabet selection box*/
195 function EnableAplhabet($bool)
196 {
197 $this->bool_DisplayAlpahabet = $bool;
198 }
200 /* Add additional header col */
201 function AddHeader($arr)
202 {
203 $this->array_Header[] = $arr;
204 }
206 /* add additional List element */
207 function AddElement($arr)
208 {
209 $this->array_Elements[] = $arr;
210 }
213 /* Return default header part. With back, home and root icons and department selection */
214 function get_default_header()
215 {
216 $enable_back = TRUE;
217 $enable_root = TRUE;
218 $enable_home = TRUE;
220 $ui = get_userinfo();
222 /* Check if selectedBase = first available base */
223 $deps = $ui->get_module_departments($this->module);
225 if(!count($deps) || $deps[0] == $this->selectedBase){
226 $enable_back = FALSE;
227 $enable_root = FALSE;
228 }
230 $listhead ="";
232 /* Check if we are in users home department */
233 if(!count($deps) ||$this->selectedBase == get_base_from_people($ui->dn)){
234 $enable_home = FALSE;
235 }
237 /* Draw root button */
238 if($enable_root){
239 $listhead .= " <input class='center' type='image' src='images/lists/root.png' align='middle'
240 title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ";
241 }else{
242 $listhead .= " <img src='images/lists/root_grey.png' class='center' alt='"._("Root")."'> ";
243 }
245 /* Draw back button */
246 if($enable_back){
247 $listhead .= " <input class='center' type='image' align='middle' src='images/lists/back.png'
248 title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ";
249 }else{
250 $listhead .= " <img src='images/lists/back_grey.png' class='center' alt='"._("Up")."'> ";
251 }
253 /* Draw home button */
254 if($enable_home){
255 $listhead .= " <input class='center' type='image' align='middle' src='images/lists/home.png'
256 title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ";
257 }else{
258 $listhead .= " <img src='images/lists/home_grey.png' class='center' alt='"._("Home")."'> ";
259 }
261 /* And at least draw reload button, this button is enabled everytime */
262 $listhead .= " <input class='center' type='image' src='images/lists/reload.png' align='middle'
263 title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'> ".
264 " <img class='center' src='images/list_seperator.png' align='middle' alt='-' height='16' width='1'> ";
266 return ($listhead);
267 }
269 /* Add a checkbox to the filter element,
270 the name specifies an existing class var to store the 'selection' */
271 function AddCheckBox($name,$value="Unset",$string="Unset",$default=false)
272 {
273 $arr = array();
275 if($name == SEPERATOR){
276 $arr['name'] = SEPERATOR;
277 }else{
278 /* Check if there was already a variable
279 for this dialog which we should use instead of the default*/
280 $MultiDialogFilters = session::get('MultiDialogFilters');
281 if(isset($MultiDialogFilters[$this->filterName][$name])){
282 $arr['default'] = $MultiDialogFilters[$this->filterName][$name];
283 $this->$name = $arr['default'];
284 }else{
285 $arr['default'] = $default;
286 $this->$name = $default;
287 }
288 $arr['name'] = $name;
289 $arr['string'] = $string;
290 $arr['value'] = $value;
291 $arr['enabled'] = true;
293 }
294 $this->array_Checkboxes[] = $arr;
295 }
298 /* Hides or unhides the checkbox with the given name */
299 function DisableCheckBox($name,$HideShow = false)
300 {
301 foreach($this->array_Checkboxes as $key => $chkbox){
302 if($chkbox['name'] == $name){
303 $this->array_Checkboxes[$key]['enabled'] = $HideShow;
304 }
305 }
306 }
309 /* Returns true if the close button was pressed */
310 function isClosed()
311 {
312 return($this->is_closed);
313 }
316 function SetListFooter($str){
317 $this->footer = $str;
318 }
321 /* Enable the close button */
322 function EnableCloseButton($bool)
323 {
324 $this->bool_DisplayCloseButton = $bool;
325 }
327 /* Enable the save button on the bottom of the list*/
328 function EnableSaveButton ($bool)
329 {
330 $this->bool_DisplaySaveButton = $bool;
331 }
333 /* Add a list specific filter object to position
334 1 on top of Information
335 2 Between Information && Filter
336 3 Below the Filter Part */
337 function AddUserBoxToFilter($position)
338 {
339 return("");
340 }
342 function EnableJSLeaveMsg($ignore = TRUE)
343 {
344 $this->IgnoreAccount = !$ignore;
345 }
347 /* Draw the list with all list elements and filters */
348 function Draw()
349 {
351 /* Check for exeeded sizelimit */
352 if (($message= check_sizelimit()) != ""){
353 return($message);
354 }
356 $smarty = get_smarty();
357 $smarty->assign("UserBox1",$this->AddUserBoxToFilter(1));
358 $smarty->assign("UserBox2",$this->AddUserBoxToFilter(2));
359 $smarty->assign("UserBox3",$this->AddUserBoxToFilter(3));
361 $divlist = new divlist($this->string_Title);
362 $divlist->SetSummary($this->string_Summary);
363 $divlist->SetEntriesPerPage(0); // 0 for scrollable list
365 /* Display list footer with summary of all listed entries */
366 if(isset($this->config->data['MAIN']['LIST_SUMMARY']) && preg_match("/true/i",$this->config->data['MAIN']['LIST_SUMMARY'])){
367 $divlist->SetFooter($this->get_List_Bottom_Info());
368 }
370 if($this->DivHeight != ""){
371 $divlist->SetHeight($this->DivHeight);
372 }
374 /* set Header informations
375 */
376 $header = array();
377 foreach($this->array_Header as $head){
378 $header[] = $head;
379 }
380 $divlist->SetHeader($header);
382 /* set Entries
383 */
384 $elements = array();
385 foreach($this->array_Elements as $element){
386 $divlist->AddEntry($element);
387 }
389 /* Create checkboxes fields
390 */
391 $boxes = "";
392 $boxClick = " onClick='document.mainform.submit();' ";
393 foreach($this->array_Checkboxes as $box){
395 if($box['name'] == SEPERATOR){
396 $boxes .= "</td></tr></table><table style='width:100%;border-top:1px solid #B0B0B0;'><tr><td>";
397 continue;
398 }
400 /* Skip disabled boxes */
401 if(!$box['enabled']) continue;
403 /* Check if box is checked */
404 if($box['default'] == true){
405 $boxes .="<input type='checkbox' name=\"".$box['name']."\" value='1' title=\"".htmlentities($box['value'])."\" checked ".$boxClick."> ".$box['string']."<br>";
406 }else{
407 $boxes .="<input type='checkbox' name=\"".$box['name']."\" value='1' title=\"".htmlentities($box['value'])."\" ".$boxClick."> ".$box['string']."<br>";
408 }
409 }
410 $smarty->assign("CheckBoxes", $boxes);
412 /* Assign regex fields
413 */
414 $regexes = "";
415 foreach($this->array_Regexes as $regex){
416 $regexes.="<table summary=\"\" style=\"width:100%;border-top:1px solid #B0B0B0;\">
417 <tr>
418 <td>
419 <label for=\"".$regex['name']."\">
420 <img alt=\"".$regex['string']."\" src=\"".$regex['image']."\" align=middle>
421 </label>
422 </td>
423 <td width=\"99%\">
424 <input id=\"".$regex['name']."\" type=\"text\" style='width:99%' name=\"".$regex['name']."\" maxlength='20'
425 value=\"".htmlentities($regex['value'])."\" title=\"".htmlentities($regex['string'])."\">
426 </td>
427 </tr>
428 </table>";
429 }
430 $smarty->assign("regexes" , $regexes );
432 /* Hide Filter Part if Requested or empty */
433 if((empty($boxes)) && (empty($regexes)) || ($this->HideFilterPart)){
434 $smarty->assign("Skip_Filter_Part", true);
435 }else{
436 $smarty->assign("Skip_Filter_Part", false);
437 }
439 /* Assign alphabet and display it
440 */
441 $smarty->assign("Display_alphabet", $this->bool_DisplayAlpahabet);
442 $smarty->assign("alphabet", generate_alphabet());
443 $smarty->assign("Header" , $this->string_ListHeader);
444 $smarty->assign("HeaderDropDown", $this->GetDropDownHeaderMenu());
445 $smarty->assign("Summary" , $this->string_Summary);
446 $smarty->assign("Title" , $this->string_Title);
447 $smarty->assign("Information" , $this->string_Information);
448 $smarty->assign("IgnoreAccount" , $this->IgnoreAccount);
450 /* Check for exeeded sizelimit */
451 $smarty->assign("hint" , print_sizelimit_warning());
452 $smarty->assign("DivList" , $divlist->DrawList()."\n\n\n\n\n".$this->footer."\n\n\n\n\n");
454 if($this->is_headpage){
455 $smarty->assign("tree_image", get_template_path('images/tree.png'));
456 $smarty->assign("infoimage", get_template_path('images/info.png'));
457 $smarty->assign("launchimage", get_template_path('images/launch.png'));
458 $smarty->assign("apply", apply_filter());
459 }else{
460 $smarty->assign("tree_image", get_template_path('images/tree.png'));
461 $smarty->assign("infoimage", get_template_path('images/info_small.png'));
462 $smarty->assign("launchimage", get_template_path('images/rocket.png'));
463 $smarty->assign("apply", apply_filter());
464 }
466 /* Button handling */
467 $smarty->assign("SaveButtonString" ,$this->SaveButtonString);
468 $smarty->assign("CloseButtonString",$this->CloseButtonString);
470 $smarty->assign("Display_Close", $this->bool_DisplayCloseButton);
471 $smarty->assign("Display_Save" , $this->bool_DisplaySaveButton);
473 $smarty->assign("filterName" , $this->filterName);
474 $smarty->assign("is_headpage" , $this->is_headpage);
476 $display = $smarty->fetch(get_template_path("MultiSelectWindow.tpl"));
477 return($display);
478 }
480 /* Set the close var, which simulates the close button is pressed */
481 function Close()
482 {
483 $this->is_closed = true;
484 }
486 function Save()
487 {
488 $this->is_saved = true;
489 }
491 /* Store all checkboxes/ regexes ...
492 Store data also into a session var, to keep the checkboxes check after reload */
493 function save_object()
494 {
495 /* Get up to date config */
496 if(isset($this->parent->config)){
497 $this->config = $this->parent->config;
498 }
500 /* Update current base */
501 $s_action ="";
502 foreach($_POST as $key => $value){
503 if(preg_match("/^dep_back.*/i",$key)){
504 $s_action="back";
505 }elseif(preg_match("/^dep_root.*/",$key)){
506 $s_action="root";
507 }elseif(preg_match("/^dep_home.*/i",$key)){
508 $s_action="home";
509 }
510 }
512 /* Save base selection from headpage selectbox*/
513 if(isset($_POST['CurrentMainBase'])){
514 $this->selectedBase = $_POST['CurrentMainBase'];
515 }
517 /* Homebutton is posted */
518 if($s_action=="home"){
519 $ui= get_userinfo();
520 $base = get_base_from_people($ui->dn);
521 $this->selectedBase= $base;
522 }
524 /* Open selected department
525 this is posted by the parent class MultiSelectWindow */
526 if(isset($_GET['act'])&& ($_GET['act'] == "dep_open")){
527 $s_entry = base64_decode($_GET['dep_id']);
528 if (!isset($this->config->departments[$s_entry])){
529 msg_dialog::display(_("LDAP error"), sprintf(_("Inconsistent DN encoding detected: '%s'"), LDAP::fix($s_entry)), ERROR_DIALOG);
530 } else {
531 $this->selectedBase = $this->config->departments[$s_entry];
532 }
533 }
535 /* back to the roots ^^ */
536 if($s_action=="root"){
537 $this->selectedBase=($this->config->current['BASE']);
538 $dep_id = $this->ui->get_module_departments($this->module);
539 if(isset($dep_id[key($dep_id)])){
540 $this->selectedBase = $dep_id[key($dep_id)];
541 }
542 }
545 /* If Back-button is pressed, move back one step in DN */
546 if($s_action=="back"){
548 /* Get parent deprtment and check if we are allowed to step in it */
549 $base_back= preg_replace("/^[^,]+,/", "", session::get('CurrentMainBase'));
550 $dep_id = $this->ui->get_module_departments($this->module);
551 if(in_array_ics($base_back,$dep_id)){
553 /* The department array keeps non DN entries as index. We need to convert
554 it before checking the existance. */
555 $base_back= trim(convert_department_dn($base_back));
557 /* Check if the department exists, otherwise revert to the configure base DN */
558 if(isset($this->config->departments[$base_back])){
559 $this->selectedBase= $this->config->departments[$base_back];
560 }else{
561 $this->selectedBase= $this->config->departments['/'];
562 }
563 }
564 }
565 session::set('CurrentMainBase',$this->selectedBase);
567 if(isset($_POST['MultiSelectWindow'.$this->filterName])){
569 /* Save some additional vars */
570 $MultiDialogFilters = session::get('MultiDialogFilters');
571 foreach($this->SaveAdditionalVars as $name){
572 if(isset($_POST[$name])){
573 if(isset($this->$name)){
574 $this->$name = $_POST[$name];
575 $MultiDialogFilters[$this->filterName][$name] = $_POST[$name];
576 }
577 }
578 }
579 session::set('MultiDialogFilters',$MultiDialogFilters);
581 /* Check posts from checkboxes
582 */
583 foreach($this->array_Checkboxes as $key => $box){
584 if(isset($_POST[$box['name']])){
585 $this->array_Checkboxes[$key]['default'] = true;
586 $this->$box['name'] = true;
587 }else{
588 $this->array_Checkboxes[$key]['default'] = false;
589 $this->$box['name'] = false;
590 }
592 /* Save settings in out session */
593 $MultiDialogFilters = session::get('MultiDialogFilters');
594 $MultiDialogFilters[$this->filterName][$box['name']] = $this->$box['name'];
595 session::set('MultiDialogFilters',$MultiDialogFilters);
596 }
598 /* Check regex posts */
599 foreach($this->array_Regexes as $key => $box){
600 $this->array_Regexes[$key]['value'] = $_POST[$box['name']];
601 $this->$box['name'] = $_POST[$box['name']];
602 $MultiDialogFilters = session::get('MultiDialogFilters');
603 $MultiDialogFilters[$this->filterName][$box['name']] = $this->$box['name'];
604 session::set('MultiDialogFilters',$MultiDialogFilters);
605 }
607 /* call close/save if buttons are pressed */
608 if(isset($_POST['CloseMultiSelectWindow'])){
609 $this->Close();
610 }
612 if(isset($_POST['SaveMultiSelectWindow'])){
613 $this->Save();
614 }
615 }
617 /* check for alphabet selection
618 Check which regexes are connected to the alphabet
619 */
620 if(isset($_GET['search'])){
621 foreach($this->array_Regexes as $key => $box){
622 /* check if this regex is connected to the alphabet selection */
623 if(($box['connAlpha'])&&(isset($_GET['search']))){
624 $val = $_GET['search']."*";
625 $val = preg_replace("/\*\**/","*",$val);
626 $this->array_Regexes[$key]['value'] = $val;
627 $this->$box['name'] = $val;
628 $MultiDialogFilters = session::get('MultiDialogFilters');
629 $MultiDialogFilters[$this->filterName][$box['name']] = $val;
630 session::set('MultiDialogFilters',$MultiDialogFilters);
631 }
632 }
633 }
634 }
637 /* Create header snapshot value */
638 function get_snapshot_header($layer_menu = FALSE)
639 {
640 $str = "";
641 if($this->parent->snapshotEnabled()){
642 $ok = false;
643 foreach($this->parent->get_used_snapshot_bases() as $base){
644 $ok |= count($this->parent->getAllDeletedSnapshots($base)) >= 1 ;
645 }
646 if($ok){
647 if($layer_menu){
648 $str = "..|<img class='center' src='images/lists/restore.png' alt='"._("Restore")."'> "._("Restore")."|RestoreDeletedSnapShot|\n";
649 }else{
650 $str = "<input class='center' type='image' align='middle' src='images/lists/restore.png'
651 title='"._("Restore snapshopts of already deleted objects")."'
652 alt='"._("Restore")."' name='RestoreDeletedSnapShot'> ";
653 }
654 }else{
655 if($layer_menu){
656 $str = "..|<img class='center' src='images/lists/restore_grey.png' alt=''> "._("Restore")."||\n";
657 }else{
658 $str = "<img class='center' src='images/lists/restore_grey.png' alt=''> ";
659 }
660 }
661 # $str .= "<img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
662 }
663 return($str);
664 }
667 function GetSnapShotActions($dn)
668 {
669 $str= "";
670 if($this->parent->snapshotEnabled()){
672 if(count($this->parent->Available_SnapsShots($dn))){
673 $str.= "<input class='center' type='image' src='images/lists/restore.png'
674 alt='"._("Restore snapshot")."' name='RestoreSnapShotDialog_".base64_encode($dn)."' title='"._("Restore snapshot")."'> ";
675 } else {
676 $str = "<img class='center' src='images/lists/restore_grey.png' alt=''> ";
677 }
679 $str.= "<input class='center' type='image' src='images/snapshot.png'
680 alt='"._("Create snapshot")."' name='CreateSnapShotDialog_".base64_encode($dn)."' title='"._("Create a new snapshot from this object")."'> ";
681 }
683 return($str);
684 }
687 /* this function adds the sub-departments of the current tree to the list */
688 function AddDepartments($base = false,$numtabs = 3,$empty_tabs_in_front = 0)
689 {
690 $this->DepartmentsAdded = true;
691 $this->Added_Departments = array();
693 /* check for a valid base */
694 if(!$base){
695 if(!session::is_set('CurrentMainBase')){
696 session::set('CurrentMainBase',$this->config->current['BASE']);
697 }
698 $base = session::get('CurrentMainBase');
699 }
701 /* Create ldap obj and switch into base*/
702 $ldap = $this->config->get_ldap_link();
703 $ldap->cd($base);
705 /* reset current deps */
706 $this->departments = array();
708 /* Get all departments within this subtree */
709 $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
710 array("ou", "description"), GL_SIZELIMIT | GL_CONVERT);
712 /* Edit delete link for system types
713 */
714 $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
716 /* Create an array with all visible (in the list) departments */
717 $departments = array();
718 foreach($deps as $value){
719 if(isset($value['description'][0])){
720 $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]";
721 }else{
722 $this->departments[$value['dn']]= get_sub_department($value['dn']);
723 }
724 }
725 natcasesort($this->departments);
728 if($empty_tabs_in_front){
729 # $numtabs -= $empty_tabs_in_front;
730 }
732 /* Add deps to this dialog object list */
733 foreach($this->departments as $key=> $val){
735 /* Add missing entries ... */
736 if(!isset($this->config->departments[trim($key)])){
737 $this->config->departments[trim($key)]="";
738 }
740 /* check if this department contains sub-departments
741 Display different image in this case
742 */
743 $non_empty="";
744 $nkey= normalizePreg($key);
745 foreach($this->config->departments as $keyd=>$vald ){
746 if(preg_match('/$nkey\/.*/',$keyd)){
747 $non_empty="full";
748 }
749 }
751 /* Add to divlist */
752 $row = array();
754 if($empty_tabs_in_front){
755 for($i = 0; $i < $empty_tabs_in_front ; $i ++){
756 $row[] = array("string"=>" ", "attach" => "style='text-align:center;width:20px;'");
757 }
758 }
760 $row[]=$field1=array("string"=>"<img src='images/".$non_empty."folder.png' alt='department'>","attach"=>"style='text-align:center;width:20px;'");
761 $row[]=$field2=array("string"=>sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''");
763 if($numtabs > 2){
764 for($i = 2 ; $i < $numtabs;$i++){
765 if(isset( $this->array_Header[$i + $empty_tabs_in_front]['attach'])){
766 $row[] = array("string"=>" ","attach" => $this->array_Header[$i + $empty_tabs_in_front]['attach']);
767 }else{
768 $row[] = array("string"=>" ");
769 }
770 }
771 }
772 $this->AddElement($row);
773 $this->Added_Departments[] = $row;
774 }
775 }
777 function set_List_Bottom_Info($str)
778 {
779 $this->List_Bottom_Info = $str;
780 }
782 function get_List_Bottom_Info()
783 {
784 return($this->List_Bottom_Info);
785 }
786 }
787 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
788 ?>