Code

More cleanup
[gosa.git] / gosa-core / include / class_MultiSelectWindow.inc
1 <?php
3 define ("SEPERATOR", 1002);
5 class MultiSelectWindow{
7         var $bool_DisplayAlpahabet      = false;
8         var $bool_DisplayCloseButton= true;     
9         var $bool_DisplaySaveButton = true;     
11         var $SaveButtonString           = "";
12         var $CloseButtonString  = "";
14         var $string_Title                         = "";
15         var $string_ListHeader  = "";
16   var $string_ListDropDown= "";
17         var $string_Summary                     = "";
18         var $string_Information = "";
20         var $array_Header                         = array();
21         var $array_Elements                     = array();      
22         var $array_Checkboxes           = array();      
23         var $array_Regexes                      = array();      
25         var $config                                         = array("");
26         var $is_closed                            = false;
27         var $is_saved                               = false;
28         var $is_headpage                          = false;      // if true the design changes
29         var $filterName                           = "Liste";
30         var $DepartmentsAdded           = false;
31   var $Added_Departments  = array();
32         var $selectedBase       = "";
34   var $DivHeight          = "";
36   var $HideFilterPart     = false;
37   var $List_Bottom_Info   = "";
38   var $SaveAdditionalVars = array();  // Additional Post vars to store 
39   var $module= "";
41   var $IgnoreAccount = TRUE;
43         function ClearElementsList()
44         {
45                 $this->array_Elements = array();
46         }
48   function HideFilterPart($bool = true)
49   {
50     $this->HideFilterPart = $bool;
51   }
53   function SetHeight($height)
54   { 
55     $this->DivHeight=$height;
56   }
58         /* Adds a regex input field to the current dialog */
59         function AddRegex($name,$string,$value,$conn,$image="images/search.png")
60         {
61                 $arr = array();
63                 /* Check if the given input field name was already used 
64                    for this type of dialog */   
65     $MultiDialogFilters = session::get('MultiDialogFilters');
66                 if(isset($MultiDialogFilters[$this->filterName][$name])){
67                         $arr['value']   = $MultiDialogFilters[$this->filterName][$name];
68                         $this->$name = $arr['value'];
69                 }else{
70                         $arr['value']   = $value;       
71                 }
73                 $arr['name']            = $name;
74                 $arr['string']          = $string;
75                 $arr['image']           = $image;       
76                 $arr['connAlpha']       = $conn;                // Connect with alphabet select 
77                 $this->array_Regexes[] = $arr;
78         }
81   function SetDropDownHeaderMenu($str)
82   {
83     $this->string_ListDropDown = $str;
84   }
86   function GetDropDownHeaderMenu()
87   {
88     if(!empty($this->string_ListDropDown)){
89       $mid = new LayersMenu(6, 7, 2, 1);
90       $mid->setImgwww("./images/");
91       $mid->setIcondir("./images/");
92       $mid->setDirroot("../include/layer-menu/");
93       $mid->setHorizontalMenuTpl("../ihtml/".get_template_path("",FALSE).'GOsa_MultiSelectHeader.ihtml');
94       $mid->setSubMenuTpl("../ihtml/".get_template_path("",FALSE).'GOsa_MultiSelectHeaderSubEntry.ihtml');
95       $mid->setMenuStructureString($this->string_ListDropDown);
96       $mid->parseStructureForMenu('menu');
97       $mid->newHorizontalMenu('menu');
98       $s = $mid->getHeader();
99       $s.= $mid->getMenu('menu');
100       $s.= $mid->getFooter('menu');
101       return($s);
102     }else{
103       return("");
104     }
105   }
108         /* Contrucktion */
109         function MultiSelectWindow(&$config, $filterName, $module)
110         {
111                 $this->config = &$config;
112                 $this->module = $module;
113                 $this->SaveButtonString         = _("Save");
114                 $this->CloseButtonString        = _("Close");
115                 $this->filterName                       = $filterName;
116     $this->ui = get_userinfo();
117                 $this->selectedBase  = session::get('CurrentMainBase');
119     /* Check default values for SaveAdditionalVars */
120     $MultiDialogFilters = session::get('MultiDialogFilters');
121     foreach($this->SaveAdditionalVars as $name){
122       if(isset($MultiDialogFilters[$this->filterName][$name])){
123         $this->$name = $MultiDialogFilters[$this->filterName][$name];
124       }
125     }
126     
127         }
129         /* Enables the headpage mode, which changes the list look */
130         function SetHeadpageMode()
131         {
132                 $this->is_headpage = true;
133         }
135         /* Sets the List internal name (not displayed anywhere) 
136            it is used to identify every single list
137          */     
138         function SetTitle($str)
139         {
140                 $this->string_Title = $str;
141         }
143         /* Set the list header string  */
144         function SetListHeader($str)
145         {
146                 $this->string_ListHeader = $str;
147         }
149         /* This sets the list description which is the first gray bar on top of the list */
150         function SetSummary($str)
151         {
152                 $this->string_Summary = $str;
153         }
155         /* If the save button is enabled, you can change its caption with this function */      
156         function SetSaveButtonString($str)
157         {
158                 $this->SaveButtonString = $str;
159         }
161         /* If the close button is enabled, you can change its caption with this function */     
162         function SetCloseButtonString($str)
163         {
164                 $this->CloseButtonString = $str;
165         }
167         /* With this function you can change the text of the information box */
168         function SetInformation($str)
169         {
170                 $this->string_Information = $str;
171         }
173         /* Display the alphabet selection box*/
174         function EnableAplhabet($bool)
175         {
176                 $this->bool_DisplayAlpahabet = $bool;
177         }
179         /* Add additional header col */
180         function AddHeader($arr)
181         {
182                 $this->array_Header[] = $arr;
183         }
185         /* add additional List element */
186         function AddElement($arr)
187         {
188                 $this->array_Elements[] = $arr;
189         }
192   /* Return default header part. With back, home and root icons and department selection */
193   function get_default_header()
194   {
195     $enable_back = TRUE;
196     $enable_root = TRUE;
197     $enable_home = TRUE;
199     $ui = get_userinfo();
201     /* Check if selectedBase = first available base */
202     $deps = $ui->get_module_departments($this->module);
204     if(!count($deps) || $deps[0] == $this->selectedBase){
205       $enable_back = FALSE;
206       $enable_root = FALSE;
207     }
208   
209     $listhead ="";
210  
211     /* Check if we are in users home  department */ 
212     if(!count($deps) ||$this->selectedBase == get_base_from_people($ui->dn)){
213       $enable_home = FALSE;
214     }
216     /* Draw root button */
217     if($enable_root){
218       $listhead .= " <input class='center' type='image' src='images/list_root.png' align='middle'
219         title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;";
220     }else{
221       $listhead .= " <img src='images/list_root_gray.png' class='center' alt='"._("Root")."'>&nbsp;";
222     }
224     /* Draw back button */
225     if($enable_back){
226       $listhead .= " <input class='center' type='image' align='middle' src='images/list_back.png'
227         title='"._("Go up one department")."' alt='"._("Up")."'                name='dep_back'>&nbsp;";
228     }else{
229       $listhead .= " <img src='images/list_back_gray.png' class='center' alt='"._("Up")."'>&nbsp;";
230     }
232     /* Draw home button */
233     if($enable_home){
234       $listhead .= " <input class='center' type='image' align='middle' src='images/list_home.png'
235         title='"._("Go to users department")."' alt='"._("Home")."'            name='dep_home'>&nbsp;";
236     }else{
237       $listhead .= " <img src='images/list_home_gray.png' class='center' alt='"._("Home")."'>&nbsp;";
238     }
239    
240     /* And at least draw reload button, this button is enabled everytime */ 
241     $listhead .=  " <input class='center' type='image' src='images/list_reload.png' align='middle'
242       title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
243       " <img   class='center' src='images/list_seperator.png' align='middle' alt='-' height='16' width='1'>&nbsp;";
245     return ($listhead);
246   }
248         /* Add a checkbox to the filter element,
249            the name specifies an existing class var to store the 'selection' */
250         function AddCheckBox($name,$value="Unset",$string="Unset",$default=false)
251         {
252                 $arr = array();
254                 if($name == SEPERATOR){
255                         $arr['name'] = SEPERATOR;
256                 }else{
257                         /* Check if there was already a variable 
258                            for this dialog which we should use instead of the default*/
259       $MultiDialogFilters = session::get('MultiDialogFilters');
260                         if(isset($MultiDialogFilters[$this->filterName][$name])){
261                                 $arr['default'] = $MultiDialogFilters[$this->filterName][$name];
262                                 $this->$name = $arr['default'];
263                         }else{
264                                 $arr['default'] = $default; 
265         $this->$name = $default;
266                         }
267                         $arr['name']          = $name;
268                         $arr['string']      = $string;
269                         $arr['value']         = $value;
270                         $arr['enabled']     = true;
272                 }
273                 $this->array_Checkboxes[] = $arr;
274         }
277         /* Hides or unhides the checkbox with the given name */
278         function DisableCheckBox($name,$HideShow = false)
279         {
280                 foreach($this->array_Checkboxes as $key => $chkbox){
281                         if($chkbox['name'] == $name){
282                                 $this->array_Checkboxes[$key]['enabled'] = $HideShow;
283                         }
284                 }
285         }
288         /* Returns true if the close button was pressed */
289         function isClosed()
290         {
291                 return($this->is_closed);
292         }
294         /* Enable the close button */
295         function EnableCloseButton($bool)
296         {
297                 $this->bool_DisplayCloseButton = $bool;
298         }
300         /* Enable the save button on the bottom of the list*/
301         function EnableSaveButton ($bool)
302         {
303                 $this->bool_DisplaySaveButton = $bool;
304         }
306   /* Add a list specific filter object to position 
307       1 on top of Information 
308       2 Between Information && Filter
309       3 Below the Filter Part */
310   function AddUserBoxToFilter($position)
311   {
312     return("");
313   }
315   function EnableJSLeaveMsg($ignore = TRUE)
316   {
317     $this->IgnoreAccount = !$ignore;
318   }
320         /* Draw the list with all list elements and filters */
321         function Draw()
322         {
324                 /* Check for exeeded sizelimit */
325                 if (($message= check_sizelimit()) != ""){
326                         return($message);
327                 }
329                 $smarty = get_smarty();
330                 $smarty->assign("UserBox1",$this->AddUserBoxToFilter(1));
331                 $smarty->assign("UserBox2",$this->AddUserBoxToFilter(2));
332                 $smarty->assign("UserBox3",$this->AddUserBoxToFilter(3));
334                 $divlist = new divlist($this->string_Title);
335                 $divlist->SetSummary($this->string_Summary);
336                 $divlist->SetEntriesPerPage(0); // 0 for scrollable list
338     /* Display list footer with summary of all listed entries */
339     if(isset($this->config->data['MAIN']['LIST_SUMMARY']) && preg_match("/true/i",$this->config->data['MAIN']['LIST_SUMMARY'])){
340       $divlist->SetFooter($this->get_List_Bottom_Info());
341     }
342   
343     if($this->DivHeight != ""){
344       $divlist->SetHeight($this->DivHeight);
345     }
347                 /* set Header informations 
348                  */
349                 $header = array();
350                 foreach($this->array_Header as $head){
351                         $header[] = $head;
352                 }
353                 $divlist->SetHeader($header);
355                 /* set Entries 
356                  */
357                 $elements = array();
358                 foreach($this->array_Elements as $element){
359                         $divlist->AddEntry($element);
360                 }
362                 /* Create checkboxes fields 
363                  */
364                 $boxes = "";
365                 $boxClick = " onClick='document.mainform.submit();' ";
366                 foreach($this->array_Checkboxes as $box){
368                         if($box['name'] == SEPERATOR){
369                                 $boxes .= "</td></tr></table><table style='width:100%;border-top:1px solid #B0B0B0;'><tr><td>";
370                                 continue;
371                         }
373                         /* Skip disabled boxes */
374                         if(!$box['enabled']) continue;
376                         /* Check if box is checked */
377                         if($box['default'] == true){
378                                 $boxes .="<input type='checkbox' name=\"".$box['name']."\" value='1' title=\"".htmlentities($box['value'])."\" checked ".$boxClick.">&nbsp;".$box['string']."<br>";
379                         }else{
380                                 $boxes .="<input type='checkbox' name=\"".$box['name']."\" value='1' title=\"".htmlentities($box['value'])."\" ".$boxClick.">&nbsp;".$box['string']."<br>";
381                         }
382                 }
383                 $smarty->assign("CheckBoxes", $boxes);
385                 /* Assign regex fields 
386                  */
387                 $regexes = "";
388                 foreach($this->array_Regexes as $regex){
389                         $regexes.="<table summary=\"\" style=\"width:100%;border-top:1px solid #B0B0B0;\">
390                                 <tr>
391                                 <td>
392                                 <label for=\"".$regex['name']."\">
393                                 <img alt=\"".$regex['string']."\" src=\"".$regex['image']."\" align=middle>
394                                 </label>
395                                 </td>
396                                 <td width=\"99%\">
397                                 <input id=\"".$regex['name']."\" type=\"text\" style='width:99%' name=\"".$regex['name']."\" maxlength='20'
398                                 value=\"".htmlentities($regex['value'])."\" title=\"".htmlentities($regex['string'])."\"> 
399                                 </td>
400                                 </tr>
401                                 </table>";
402                 }
403                 $smarty->assign("regexes"                       , $regexes );
405     /* Hide Filter Part if Requested or empty */
406     if((empty($boxes)) && (empty($regexes)) || ($this->HideFilterPart)){
407                   $smarty->assign("Skip_Filter_Part",   true);
408     }else{ 
409                   $smarty->assign("Skip_Filter_Part",   false);
410     }
412                 /* Assign alphabet and display it 
413                  */     
414                 $smarty->assign("Display_alphabet",     $this->bool_DisplayAlpahabet);
415                 $smarty->assign("alphabet",             generate_alphabet());
416                 $smarty->assign("Header"                        , $this->string_ListHeader);
417                 $smarty->assign("HeaderDropDown", $this->GetDropDownHeaderMenu());
418                 $smarty->assign("Summary"                       , $this->string_Summary);
419                 $smarty->assign("Title"                         , $this->string_Title);
420                 $smarty->assign("Information"           , $this->string_Information);
421                 $smarty->assign("IgnoreAccount"         , $this->IgnoreAccount);
423                 /* Check for exeeded sizelimit */
424                 $smarty->assign("hint"                          , print_sizelimit_warning());
425                 $smarty->assign("DivList"                       , $divlist->DrawList());
428                 if($this->is_headpage){
429                         $smarty->assign("tree_image",           get_template_path('images/tree.png'));
430                         $smarty->assign("infoimage",            get_template_path('images/info.png'));
431                         $smarty->assign("launchimage",          get_template_path('images/launch.png'));
432                         $smarty->assign("apply",                        apply_filter());
433                 }else{
434                         $smarty->assign("tree_image",           get_template_path('images/tree.png'));
435                         $smarty->assign("infoimage",            get_template_path('images/info_small.png'));
436                         $smarty->assign("launchimage",          get_template_path('images/rocket.png'));
437                         $smarty->assign("apply",                        apply_filter());
438                 }
440                 /* Button handling */
441                 $smarty->assign("SaveButtonString" ,$this->SaveButtonString);
442                 $smarty->assign("CloseButtonString",$this->CloseButtonString);
444                 $smarty->assign("Display_Close",        $this->bool_DisplayCloseButton);
445                 $smarty->assign("Display_Save" ,        $this->bool_DisplaySaveButton);
447                 $smarty->assign("filterName"    ,       $this->filterName);
448                 $smarty->assign("is_headpage"   ,       $this->is_headpage);
450                 $display = $smarty->fetch(get_template_path("MultiSelectWindow.tpl"));
451                 return($display);
452         }
454         /* Set the close var, which simulates the close button is pressed */
455         function Close()
456         {
457                 $this->is_closed = true;
458         }
460         function Save()
461         {
462                 $this->is_saved = true;
463         }
465         /* Store all checkboxes/ regexes ... 
466            Store data also into a session var, to keep the checkboxes check after reload  */
467         function save_object()
468         {
469     /* Get up to date config */
470     if(isset($this->parent->config)){
471       $this->config = $this->parent->config;
472     }
474     /* Update current base */
475     $s_action ="";
476     foreach($_POST as $key => $value){
477       if(preg_match("/^dep_back.*/i",$key)){
478         $s_action="back";
479       }elseif(preg_match("/^dep_root.*/",$key)){
480         $s_action="root";
481       }elseif(preg_match("/^dep_home.*/i",$key)){
482         $s_action="home";
483       }
484     }
486     /* Save base selection from headpage selectbox*/
487     if(isset($_POST['CurrentMainBase'])){
488       $this->selectedBase = $_POST['CurrentMainBase'];
489     }
491     /* Homebutton is posted */
492     if($s_action=="home"){
493       $ui= get_userinfo();
494       $base = get_base_from_people($ui->dn);
495       $this->selectedBase= $base;
496     }
498     /* Open selected department
499        this is posted by the parent class MultiSelectWindow */
500     if(isset($_GET['act'])&& ($_GET['act'] == "dep_open")){
501       $s_entry = base64_decode($_GET['dep_id']);
502       if (!isset($this->config->departments[$s_entry])){
503         print_red(_("Error: The requested subtree has an inconsistent DN encoding, check your LDAP!"));
504       } else {
505         $this->selectedBase = $this->config->departments[$s_entry];
506       }
507     }
509     /* back to the roots ^^ */
510     if($s_action=="root"){
511       $this->selectedBase=($this->config->current['BASE']);
512       $dep_id = $this->ui->get_module_departments($this->module);
513       if(isset($dep_id[key($dep_id)])){
514         $this->selectedBase = $dep_id[key($dep_id)];
515       }
516     }
519     /* If Back-button is pressed, move back one step in DN */
520     if($s_action=="back"){
522       /* Get parent deprtment and check if we are allowed to step in it */
523       $base_back= preg_replace("/^[^,]+,/", "", session::get('CurrentMainBase'));
524       $dep_id = $this->ui->get_module_departments($this->module);
525       if(in_array_ics($base_back,$dep_id)){
527         /* The department array keeps non DN entries as index. We need to convert
528            it before checking the existance. */
529         $base_back= trim(convert_department_dn($base_back));
531         /* Check if the department exists, otherwise revert to the configure base DN */
532         if(isset($this->config->departments[$base_back])){
533           $this->selectedBase= $this->config->departments[$base_back];
534         }else{
535           $this->selectedBase= $this->config->departments['/'];
536         }
537       }
538     }
539     session::set('CurrentMainBase',$this->selectedBase);
541                 if(isset($_POST['MultiSelectWindow'.$this->filterName])){
543       /* Save some additional vars */
544       $MultiDialogFilters = session::get('MultiDialogFilters');
545       foreach($this->SaveAdditionalVars as $name){
546         if(isset($_POST[$name])){
547           if(isset($this->$name)){
548             $this->$name = $_POST[$name];
549             $MultiDialogFilters[$this->filterName][$name] = $_POST[$name];
550           }
551         }
552       }
553       session::set('MultiDialogFilters',$MultiDialogFilters);
555                         /* Check posts from checkboxes 
556                          */
557                         foreach($this->array_Checkboxes as $key => $box){
558                                 if(isset($_POST[$box['name']])){
559                                         $this->array_Checkboxes[$key]['default'] = true;
560                                         $this->$box['name'] = true;
561                                 }else{
562                                         $this->array_Checkboxes[$key]['default'] = false;
563                                         $this->$box['name'] = false;
564                                 }
566                                 /* Save settings in out session */
567         $MultiDialogFilters = session::get('MultiDialogFilters');
568                                 $MultiDialogFilters[$this->filterName][$box['name']] = $this->$box['name'];
569         session::set('MultiDialogFilters',$MultiDialogFilters);
570                         }
572                         /* Check regex posts */
573                         foreach($this->array_Regexes as $key => $box){
574                                 $this->array_Regexes[$key]['value'] = $_POST[$box['name']];
575                                 $this->$box['name'] = $_POST[$box['name']];
576         $MultiDialogFilters = session::get('MultiDialogFilters');
577                                 $MultiDialogFilters[$this->filterName][$box['name']] = $this->$box['name'];
578         session::set('MultiDialogFilters',$MultiDialogFilters);
579                         }
581                         /* call close/save if buttons are pressed */
582                         if(isset($_POST['CloseMultiSelectWindow'])){
583                                 $this->Close();
584                         }
586                         if(isset($_POST['SaveMultiSelectWindow'])){
587                                 $this->Save();
588                         }
589                 }
591                 /* check for alphabet selection
592                    Check which regexes are connected to the alphabet 
593                  */     
594                 if(isset($_GET['search'])){
595                         foreach($this->array_Regexes as $key => $box){
596                                 /* check if this regex is connected to the alphabet selection */
597                                 if(($box['connAlpha'])&&(isset($_GET['search']))){
598                                         $val =  $_GET['search']."*";
599                                         $val = preg_replace("/\*\**/","*",$val);
600                                         $this->array_Regexes[$key]['value'] = $val;
601                                         $this->$box['name'] = $val;
602           $MultiDialogFilters = session::get('MultiDialogFilters');
603           $MultiDialogFilters[$this->filterName][$box['name']] =  $val;
604           session::set('MultiDialogFilters',$MultiDialogFilters);
605                                 }
606                         }
607                 }
608         }
611   /* Create header snapshot value */
612   function get_snapshot_header($layer_menu = FALSE)
613   {
614     $str = "";
615     if($this->parent->snapshotEnabled()){
616       $ok = false;
617       foreach($this->parent->get_used_snapshot_bases() as $base){
618         $ok |= count($this->parent->getAllDeletedSnapshots($base)) >= 1 ;
619       }
620       if($ok){
621         if($layer_menu){
622           $str = "..|<img class='center' src='images/restore.png' alt='"._("Restore")."'>&nbsp;"._("Restore")."|RestoreDeletedSnapShot|\n";
623         }else{
624           $str = "<input class='center' type='image' align='middle' src='images/restore.png'
625             title='"._("Restore snapshopts of already deleted objects")."' 
626             alt='"._("Restore")."' name='RestoreDeletedSnapShot'>&nbsp;"; 
627         }
628       }else{
629         if($layer_menu){
630           $str = "..|<img class='center' src='images/restore_grey.png' alt=''>&nbsp;"._("Restore")."||\n";
631         }else{
632           $str = "<img class='center' src='images/restore_grey.png' alt=''>&nbsp;";
633         }
634       }
635 #      $str .= "<img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
636     }
637     return($str);
638   }
641   function GetSnapShotActions($dn)
642   {
643     $str= "";
644     if($this->parent->snapshotEnabled()){
646       if(count($this->parent->Available_SnapsShots($dn))){
647         $str.= "<input class='center' type='image' src='images/restore.png'
648           alt='"._("Restore snapshot")."' name='RestoreSnapShotDialog_".base64_encode($dn)."' title='"._("Restore snapshot")."'>&nbsp;";
649       } else {
650         $str = "<img class='center' src='images/restore_grey.png' alt=''>&nbsp;";
651       }
653       $str.= "<input class='center' type='image' src='images/snapshot.png'
654         alt='"._("Create snapshot")."' name='CreateSnapShotDialog_".base64_encode($dn)."' title='"._("Create a new snapshot from this object")."'>&nbsp;";
655     }
657     return($str);
658   }
661         /* this function adds the sub-departments of the current tree to the list */
662         function AddDepartments($base = false,$numtabs = 3,$empty_tabs_in_front = 0)
663         {
664                 $this->DepartmentsAdded = true;
665     $this->Added_Departments = array();
667                 /* check for a valid base */
668                 if(!$base){
669                         if(!session::is_set('CurrentMainBase')){
670                                 session::set('CurrentMainBase',$this->config->current['BASE']);
671                         }
672                         $base  = session::get('CurrentMainBase');
673                 }
675                 /* Create ldap obj and switch into base*/
676                 $ldap = $this->config->get_ldap_link();
677                 $ldap->cd($base);
679                 /* reset current deps */
680                 $this->departments = array();
682                 /* Get all departments within this subtree */
683                 $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
684                     array("ou", "description"), GL_SIZELIMIT | GL_CONVERT);
686                 /* Edit delete link for system types
687                  */
688                 $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
690                 /* Create an array with all visible (in the list) departments */
691                 $departments = array();
692                 foreach($deps as $value){
693                         if(isset($value['description'][0])){
694                                 $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]";
695                         }else{
696                                 $this->departments[$value['dn']]= get_sub_department($value['dn']);
697                         }
698                 }
699                 natcasesort($this->departments);
702     if($empty_tabs_in_front){
703 #      $numtabs -= $empty_tabs_in_front;
704     }
705   
706                 /* Add deps to this dialog object list */
707                 foreach($this->departments as $key=> $val){
709                         /* Add missing entries ... */
710                         if(!isset($this->config->departments[trim($key)])){
711                                 $this->config->departments[trim($key)]="";
712                         }
714                         /* check if this department contains sub-departments
715                            Display different image in this case
716                          */
717                         $non_empty="";
718                         $nkey= normalizePreg($key);
719                         foreach($this->config->departments as $keyd=>$vald ){
720                                 if(preg_match('/$nkey\/.*/',$keyd)){
721                                         $non_empty="full";
722                                 }
723                         }
725                         /* Add to divlist */
726                         $row = array();
728       if($empty_tabs_in_front){
729         for($i = 0; $i < $empty_tabs_in_front ; $i ++){
730           $row[] = array("string"=>"&nbsp;", "attach" => "style='text-align:center;width:20px;'");
731         }
732       }
734                         $row[]=$field1=array("string"=>"<img src='images/".$non_empty."folder.png' alt='department'>","attach"=>"style='text-align:center;width:20px;'");
735                         $row[]=$field2=array("string"=>sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''");
737                         if($numtabs > 2){       
738                                 for($i = 2 ; $i < $numtabs;$i++){
739           if(isset( $this->array_Header[$i + $empty_tabs_in_front]['attach'])){
740             $row[] = array("string"=>"&nbsp;","attach" => $this->array_Header[$i + $empty_tabs_in_front]['attach']);
741           }else{
742             $row[] = array("string"=>"&nbsp;");
743           }
744                                 }
745                         }
746                         $this->AddElement($row);
747       $this->Added_Departments[] = $row;
748                 }
749         }
751   function set_List_Bottom_Info($str)
752   {
753     $this->List_Bottom_Info = $str;
754   }
756   function get_List_Bottom_Info()
757   {
758     return($this->List_Bottom_Info); 
759   }
761 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
762 ?>