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 $departments= array();
56 var $DivHeight = "";
58 var $HideFilterPart = false;
59 var $List_Bottom_Info = "";
60 var $SaveAdditionalVars = array(); // Additional Post vars to store
61 var $module= "";
63 var $base_selection_regex = "*";
65 var $IgnoreAccount = TRUE;
66 var $footer = "";
67 var $post_id = "1 2 3";
69 function ClearElementsList()
70 {
71 $ui =get_userinfo();
72 $deps = $ui->get_module_departments($this->module);
73 if(!in_array($this->selectedBase, $deps)){
74 $this->selectedBase = array_shift($deps);
75 }
76 $this->array_Elements = array();
77 }
79 function HideFilterPart($bool = true)
80 {
81 $this->HideFilterPart = $bool;
82 }
84 function SetHeight($height)
85 {
86 $this->DivHeight=$height;
87 }
89 /* Adds a regex input field to the current dialog */
90 function AddRegex($name,$string,$value,$conn,$image="images/lists/search.png")
91 {
92 $arr = array();
94 /* Check if the given input field name was already used
95 for this type of dialog */
96 $MultiDialogFilters = session::get('MultiDialogFilters');
97 if(isset($MultiDialogFilters[$this->filterName][$name])){
98 $arr['value'] = $MultiDialogFilters[$this->filterName][$name];
99 $this->$name = $arr['value'];
100 }else{
101 $arr['value'] = $value;
102 }
104 $arr['name'] = $name;
105 $arr['string'] = $string;
106 $arr['image'] = $image;
107 $arr['connAlpha'] = $conn; // Connect with alphabet select
108 $this->array_Regexes[] = $arr;
109 }
112 function SetDropDownHeaderMenu($str)
113 {
114 $this->string_ListDropDown = $str;
115 }
117 function GetDropDownHeaderMenu()
118 {
119 if(!empty($this->string_ListDropDown)){
120 $mid = new LayersMenu(6, 7, 2, 1);
121 $mid->setImgwww("./images/layer_menu/");
122 $mid->setIcondir("./images/layer_menu/");
123 $mid->setDirroot("../include/utils/layer-menu/");
124 $mid->setHorizontalMenuTpl("../ihtml/".get_template_path("",FALSE).'GOsa_MultiSelectHeader.ihtml');
125 $mid->setSubMenuTpl("../ihtml/".get_template_path("",FALSE).'GOsa_MultiSelectHeaderSubEntry.ihtml');
126 $mid->setMenuStructureString($this->string_ListDropDown);
127 $mid->parseStructureForMenu('menu');
128 $mid->newHorizontalMenu('menu');
129 $s = $mid->getHeader();
130 $s.= $mid->getMenu('menu');
131 $s.= $mid->getFooter('menu');
132 return($s);
133 }else{
134 return("");
135 }
136 }
139 /* Contrucktion */
140 function MultiSelectWindow(&$config, $filterName, $module)
141 {
142 $this->config = &$config;
143 $this->module = $module;
144 $this->SaveButtonString = _("Save");
145 $this->CloseButtonString = _("Close");
146 $this->filterName = $filterName;
147 $this->ui = get_userinfo();
148 $this->post_id = preg_replace("/[^0-9]/","",microtime(TRUE));
150 /* Check default values for SaveAdditionalVars */
151 $MultiDialogFilters = session::get('MultiDialogFilters');
152 foreach($this->SaveAdditionalVars as $name){
153 if(isset($MultiDialogFilters[$this->filterName][$name])){
154 $this->$name = $MultiDialogFilters[$this->filterName][$name];
155 }
156 }
158 }
160 /* Enables the headpage mode, which changes the list look */
161 function SetHeadpageMode()
162 {
163 $this->is_headpage = true;
164 }
166 /* Sets the List internal name (not displayed anywhere)
167 it is used to identify every single list
168 */
169 function SetTitle($str)
170 {
171 $this->string_Title = $str;
172 }
174 /* Set the list header string */
175 function SetListHeader($str)
176 {
177 $this->string_ListHeader = $str;
178 }
180 /* This sets the list description which is the first gray bar on top of the list */
181 function SetSummary($str)
182 {
183 $this->string_Summary = $str;
184 }
186 /* If the save button is enabled, you can change its caption with this function */
187 function SetSaveButtonString($str)
188 {
189 $this->SaveButtonString = $str;
190 }
192 /* If the close button is enabled, you can change its caption with this function */
193 function SetCloseButtonString($str)
194 {
195 $this->CloseButtonString = $str;
196 }
198 /* With this function you can change the text of the information box */
199 function SetInformation($str)
200 {
201 $this->string_Information = $str;
202 }
204 /* Display the alphabet selection box*/
205 function EnableAplhabet($bool)
206 {
207 $this->bool_DisplayAlpahabet = $bool;
208 }
210 /* Add additional header col */
211 function AddHeader($arr)
212 {
213 $this->array_Header[] = $arr;
214 }
216 /* add additional List element */
217 function AddElement($arr)
218 {
219 $this->array_Elements[] = $arr;
220 }
223 /* Return default header part. With back, home and root icons and department selection */
224 function get_default_header($seperator= TRUE)
225 {
226 $enable_back = TRUE;
227 $enable_root = TRUE;
228 $enable_home = TRUE;
230 $ui = get_userinfo();
232 /* Check if selectedBase = first available base */
233 $deps = $ui->get_module_departments($this->module);
235 if(!count($deps) || $deps[0] == $this->selectedBase){
236 $enable_back = FALSE;
237 $enable_root = FALSE;
238 }
240 $listhead ="";
242 /* Check if we are in users home department */
243 if(!count($deps) ||$this->selectedBase == get_base_from_people($ui->dn)){
244 $enable_home = FALSE;
245 }
247 /* Draw root button */
248 if($enable_root){
249 $listhead .= " <input class='center' type='image' src='images/lists/root.png' align='middle'
250 title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ";
251 }else{
252 $listhead .= " <img src='images/lists/root_grey.png' class='center' alt='"._("Root")."'> ";
253 }
255 /* Draw back button */
256 if($enable_back){
257 $listhead .= " <input class='center' type='image' align='middle' src='images/lists/back.png'
258 title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ";
259 }else{
260 $listhead .= " <img src='images/lists/back_grey.png' class='center' alt='"._("Up")."'> ";
261 }
263 /* Draw home button */
264 if($enable_home){
265 $listhead .= " <input class='center' type='image' align='middle' src='images/lists/home.png'
266 title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ";
267 }else{
268 $listhead .= " <img src='images/lists/home_grey.png' class='center' alt='"._("Home")."'> ";
269 }
271 /* And at least draw reload button, this button is enabled everytime */
272 $listhead .= " <input class='center' type='image' src='images/lists/reload.png' align='middle'
273 title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'> ";
274 if ($seperator){
275 $listhead.= " <img class='center' src='images/lists/seperator.png' align='middle' alt='-' height='16' width='1'> ";
276 }
277 return ($listhead);
278 }
280 /* Add a checkbox to the filter element,
281 the name specifies an existing class var to store the 'selection' */
282 function AddCheckBox($name,$value="Unset",$string="Unset",$default=false)
283 {
284 $arr = array();
286 if($name == SEPERATOR){
287 $arr['name'] = SEPERATOR;
288 }else{
289 /* Check if there was already a variable
290 for this dialog which we should use instead of the default*/
291 $MultiDialogFilters = session::get('MultiDialogFilters');
292 if(isset($MultiDialogFilters[$this->filterName][$name])){
293 $arr['default'] = $MultiDialogFilters[$this->filterName][$name];
294 $this->$name = $arr['default'];
295 }else{
296 $arr['default'] = $default;
297 $this->$name = $default;
298 }
299 $arr['name'] = $name;
300 $arr['string'] = $string;
301 $arr['value'] = $value;
302 $arr['enabled'] = true;
304 }
305 $this->array_Checkboxes[] = $arr;
306 }
309 /* Hides or unhides the checkbox with the given name */
310 function DisableCheckBox($name,$HideShow = false)
311 {
312 foreach($this->array_Checkboxes as $key => $chkbox){
313 if($chkbox['name'] == $name){
314 $this->array_Checkboxes[$key]['enabled'] = $HideShow;
315 }
316 }
317 }
320 /* Returns true if the close button was pressed */
321 function isClosed()
322 {
323 return($this->is_closed);
324 }
327 function SetListFooter($str){
328 $this->footer = $str;
329 }
332 /* Enable the close button */
333 function EnableCloseButton($bool)
334 {
335 $this->bool_DisplayCloseButton = $bool;
336 }
338 /* Enable the save button on the bottom of the list*/
339 function EnableSaveButton ($bool)
340 {
341 $this->bool_DisplaySaveButton = $bool;
342 }
344 /* Add a list specific filter object to position
345 1 on top of Information
346 2 Between Information && Filter
347 3 Below the Filter Part */
348 function AddUserBoxToFilter($position)
349 {
350 return("");
351 }
353 function EnableJSLeaveMsg($ignore = TRUE)
354 {
355 $this->IgnoreAccount = !$ignore;
356 }
358 /* Draw the list with all list elements and filters */
359 function Draw()
360 {
362 /* Check for exeeded sizelimit */
363 if (($message= check_sizelimit()) != ""){
364 return($message);
365 }
367 $smarty = get_smarty();
368 $smarty->assign("UserBox1",$this->AddUserBoxToFilter(1));
369 $smarty->assign("UserBox2",$this->AddUserBoxToFilter(2));
370 $smarty->assign("UserBox3",$this->AddUserBoxToFilter(3));
372 $divlist = new divlist($this->string_Title);
373 $divlist->SetSummary($this->string_Summary);
374 $divlist->SetEntriesPerPage(0); // 0 for scrollable list
376 /* Display list footer with summary of all listed entries */
377 if ($this->config->get_cfg_value("listSummary") == "true"){
378 $divlist->SetFooter($this->get_List_Bottom_Info());
379 }
381 if($this->DivHeight != ""){
382 $divlist->SetHeight($this->DivHeight);
383 }
385 /* set Header informations
386 */
387 $header = array();
388 foreach($this->array_Header as $head){
389 $header[] = $head;
390 }
391 $divlist->SetHeader($header);
393 /* set Entries
394 */
395 $elements = array();
396 foreach($this->array_Elements as $element){
397 $divlist->AddEntry($element);
398 }
400 /* Create checkboxes fields
401 */
402 $boxes = "";
403 $boxClick = " onClick='document.mainform.submit();' ";
404 foreach($this->array_Checkboxes as $box){
406 if($box['name'] == SEPERATOR){
407 $boxes .= "</td></tr></table><table style='width:100%;border-top:1px solid #B0B0B0;'><tr><td>";
408 continue;
409 }
411 /* Skip disabled boxes */
412 if(!$box['enabled']) continue;
414 /* Check if box is checked */
415 if($box['default'] == true){
416 $boxes .="<input type='checkbox' name=\"".$box['name']."\" value='1' title=\"".htmlspecialchars($box['value'])."\" checked ".$boxClick."> ".$box['string']."<br>";
417 }else{
418 $boxes .="<input type='checkbox' name=\"".$box['name']."\" value='1' title=\"".htmlspecialchars($box['value'])."\" ".$boxClick."> ".$box['string']."<br>";
419 }
420 }
421 $smarty->assign("CheckBoxes", $boxes);
423 /* Assign regex fields
424 */
425 $regexes = "";
426 foreach($this->array_Regexes as $regex){
427 $regexes.="<table summary=\"\" style=\"width:100%;border-top:1px solid #B0B0B0;\">
428 <tr>
429 <td>
430 <label for=\"".$regex['name']."\">
431 <img alt=\"".$regex['string']."\" src=\"".$regex['image']."\" align=middle>
432 </label>
433 </td>
434 <td width=\"99%\">
435 <input id=\"".$regex['name']."\" type=\"text\" style='width:99%' name=\"".$regex['name']."\" maxlength='20'
436 value=\"".htmlspecialchars($regex['value'])."\" title=\"".htmlspecialchars($regex['string'])."\">
437 </td>
438 </tr>
439 </table>";
440 }
441 $smarty->assign("regexes" , $regexes );
443 /* Hide Filter Part if Requested or empty */
444 if((empty($boxes)) && (empty($regexes)) || ($this->HideFilterPart)){
445 $smarty->assign("Skip_Filter_Part", true);
446 }else{
447 $smarty->assign("Skip_Filter_Part", false);
448 }
450 /* Assign alphabet and display it
451 */
452 $smarty->assign("Display_alphabet", $this->bool_DisplayAlpahabet);
453 $smarty->assign("alphabet", generate_alphabet());
454 $smarty->assign("Header" , $this->string_ListHeader);
455 $smarty->assign("HeaderDropDown", $this->GetDropDownHeaderMenu());
456 $smarty->assign("Summary" , $this->string_Summary);
457 $smarty->assign("Title" , $this->string_Title);
458 $smarty->assign("Information" , $this->string_Information);
459 $smarty->assign("IgnoreAccount" , $this->IgnoreAccount);
460 $smarty->assign("POST_ID", $this->post_id);
462 /* Check for exeeded sizelimit */
463 $smarty->assign("hint" , print_sizelimit_warning());
464 $smarty->assign("DivList" , $divlist->DrawList()."\n\n\n\n\n".$this->footer."\n\n\n\n\n");
466 if($this->is_headpage){
467 $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
468 $smarty->assign("infoimage", get_template_path('images/info.png'));
469 $smarty->assign("launchimage", get_template_path('images/launch.png'));
470 $smarty->assign("apply", apply_filter());
471 }else{
472 $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
473 $smarty->assign("infoimage", get_template_path('images/info_small.png'));
474 $smarty->assign("launchimage", get_template_path('images/rocket.png'));
475 $smarty->assign("apply", apply_filter());
476 }
478 /* Button handling */
479 $smarty->assign("SaveButtonString" ,$this->SaveButtonString);
480 $smarty->assign("CloseButtonString",$this->CloseButtonString);
482 $smarty->assign("Display_Close", $this->bool_DisplayCloseButton);
483 $smarty->assign("Display_Save" , $this->bool_DisplaySaveButton);
485 $smarty->assign("filterName" , $this->filterName);
486 $smarty->assign("is_headpage" , $this->is_headpage);
488 $display = $smarty->fetch(get_template_path("MultiSelectWindow.tpl"));
489 return($display);
490 }
492 /* Set the close var, which simulates the close button is pressed */
493 function Close()
494 {
495 $this->is_closed = true;
496 }
498 function Save()
499 {
500 $this->is_saved = true;
501 }
503 /* Store all checkboxes/ regexes ...
504 Store data also into a session var, to keep the checkboxes check after reload */
505 function save_object()
506 {
508 /* Ensure that we do not handle posts for other dialogs
509 */
510 if((isset($_POST['POST_ID']) && $_POST['POST_ID'] != $this->post_id) ||
511 (isset($_GET['post_id']) && $_GET['post_id'] != $this->post_id)){
512 return;
513 }
515 /* Get up to date config */
516 if(isset($this->parent->config)){
517 $this->config = $this->parent->config;
518 }
520 /* Update current base */
521 $s_action ="";
522 foreach($_POST as $key => $value){
523 if(preg_match("/^dep_back.*/i",$key)){
524 $s_action="back";
525 }elseif(preg_match("/^dep_root.*/",$key)){
526 $s_action="root";
527 }elseif(preg_match("/^dep_home.*/i",$key)){
528 $s_action="home";
529 }
530 }
532 /* Save base selection from headpage selectbox */
533 if(isset($_POST['CurrentMainBase'])){
534 $this->selectedBase = get_post('CurrentMainBase');
535 session::global_set("CurrentMainBase", $this->selectedBase);
536 } else {
537 $this->selectedBase= session::global_get("CurrentMainBase");
538 }
540 /* Homebutton is posted */
541 if($s_action=="home"){
542 $ui= get_userinfo();
543 $base = get_base_from_people($ui->dn);
544 $this->selectedBase= $base;
545 }
547 /* Open selected department
548 this is posted by the parent class MultiSelectWindow */
549 if(isset($_GET['act'])&& ($_GET['act'] == "dep_open")){
550 $s_entry = $_GET['dep_id'];
551 if (!isset($this->departments[$s_entry])){
553 msg_dialog::display(_("LDAP error"), sprintf(_("Inconsistent DN encoding detected: '%s'"), LDAP::fix($s_entry)), ERROR_DIALOG);
554 } else {
555 $this->selectedBase = $this->departments[$s_entry]['dn'];
556 }
557 }
559 /* back to the roots ^^ */
560 if($s_action=="root"){
561 $this->selectedBase=($this->config->current['BASE']);
562 $dep_id = $this->ui->get_module_departments($this->module);
563 if(isset($dep_id[key($dep_id)])){
564 $this->selectedBase = $dep_id[key($dep_id)];
565 }
566 }
568 /* If Back-button is pressed, move back one step in DN */
569 if($s_action=="back"){
572 /* Get parent deprtment and check if we are allowed to step in it */
573 $base_back= preg_replace("/^[^,]+,/", "", $this->selectedBase);
574 $dep_id = $this->ui->get_module_departments($this->module);
575 if(in_array_ics($base_back,$dep_id)){
576 if(in_array($base_back,$this->config->departments)){
577 $this->selectedBase = $base_back;
578 }
579 }
580 }
582 if(isset($_POST['MultiSelectWindow'.$this->filterName])){
584 /* Save some additional vars */
585 $MultiDialogFilters = session::get('MultiDialogFilters');
586 foreach($this->SaveAdditionalVars as $name){
587 if(isset($_POST[$name])){
588 if(isset($this->$name)){
589 $this->$name = $_POST[$name];
590 $MultiDialogFilters[$this->filterName][$name] = $_POST[$name];
591 }
592 }
593 }
594 session::set('MultiDialogFilters',$MultiDialogFilters);
596 /* Check posts from checkboxes
597 */
598 foreach($this->array_Checkboxes as $key => $box){
599 if(isset($_POST[$box['name']])){
600 $this->array_Checkboxes[$key]['default'] = true;
601 $this->$box['name'] = true;
602 }else{
603 $this->array_Checkboxes[$key]['default'] = false;
604 $this->$box['name'] = false;
605 }
607 /* Save settings in out session */
608 $MultiDialogFilters = session::get('MultiDialogFilters');
609 $MultiDialogFilters[$this->filterName][$box['name']] = $this->$box['name'];
610 session::set('MultiDialogFilters',$MultiDialogFilters);
611 }
613 /* Check regex posts */
614 foreach($this->array_Regexes as $key => $box){
615 $this->array_Regexes[$key]['value'] = $_POST[$box['name']];
616 $this->$box['name'] = $_POST[$box['name']];
617 $MultiDialogFilters = session::get('MultiDialogFilters');
618 $MultiDialogFilters[$this->filterName][$box['name']] = $this->$box['name'];
619 session::set('MultiDialogFilters',$MultiDialogFilters);
620 }
622 /* call close/save if buttons are pressed */
623 if(isset($_POST['CloseMultiSelectWindow'])){
624 $this->Close();
625 }
627 if(isset($_POST['SaveMultiSelectWindow'])){
628 $this->Save();
629 }
630 }
632 /* check for alphabet selection
633 Check which regexes are connected to the alphabet
634 */
635 if(isset($_GET['search'])){
636 foreach($this->array_Regexes as $key => $box){
637 /* check if this regex is connected to the alphabet selection */
638 if(($box['connAlpha'])&&(isset($_GET['search']))){
639 $val = $_GET['search']."*";
640 $val = preg_replace("/\*\**/","*",$val);
641 $this->array_Regexes[$key]['value'] = $val;
642 $this->$box['name'] = $val;
643 $MultiDialogFilters = session::get('MultiDialogFilters');
644 $MultiDialogFilters[$this->filterName][$box['name']] = $val;
645 session::set('MultiDialogFilters',$MultiDialogFilters);
646 }
647 }
648 }
650 /* Save currenlty selected base in session */
651 session::global_set("CurrentMainBase",$this->selectedBase);
652 }
655 /* this function adds the sub-departments of the current tree to the list */
656 function AddDepartments($base = false,$numtabs = 3,$empty_tabs_in_front = 0)
657 {
658 $this->DepartmentsAdded = true;
659 $this->Added_Departments = array();
660 $this->departments = array();
662 if(isset($this->Regex)){
663 $this->base_selection_regex = $this->Regex;
664 }
666 $linkopen = "<a href='?plug=".$_GET['plug']."&post_id=".$this->post_id."&act=dep_open&dep_id=%s'>%s</a>";
667 $types = departmentManagement::get_support_departments();
668 $ui = get_userinfo();
669 $module_deps = $ui->get_module_departments($this->module);
670 $found_deps = array();
672 /* check for a valid base */
673 if(!$base){
674 $base = $this->selectedBase;
675 }
677 /* Create ldap obj and switch into base*/
678 $ldap = $this->config->get_ldap_link();
679 $ldap->cd($base);
681 /* Get all departments within this subtree */
682 $s_filter = "";
683 $s_attrs = array("description","objectClass");
684 $s_acls = $this->module;
685 foreach($types as $name => $data){
686 $s_filter.= "(&(objectClass=gosaDepartment)(objectClass=".$data['OC'].")(".$data['ATTR']."=".$this->base_selection_regex."))";
687 $s_attrs[]= $data['ATTR'];
688 }
690 $tmp = get_list("(|".$s_filter.")",$s_acls,$this->selectedBase,$s_attrs,GL_NONE);
691 foreach($tmp as $attrs){
692 foreach($types as $name => $data){
693 if(in_array($data['OC'],$attrs['objectClass']) && isset($attrs[$data['ATTR']][0])){
694 $attrs['NAME'] = $attrs[$data['ATTR']][0];
695 $attrs['TYPE'] = $data;
696 $name = $attrs['NAME']." ".$attrs['dn'];
697 $departments[$name] = $attrs;
698 $found_deps[$name] = $attrs['dn'];
699 break;
700 }
701 }
702 }
704 /* Detect allowed departments
705 */
706 $deps = array_intersect($found_deps,$module_deps);
707 uksort($deps, 'strnatcasecmp');
708 $key = 0;
709 foreach($deps as $name => $dn){
710 $key ++;
711 $val = $departments[$name];
712 $this->departments[$key] = $val;
713 $img = "<image src='".$val['TYPE']['IMG']."' class='center'>";
715 /* Add spacer cols to divlist
716 */
717 $row = array();
718 if($empty_tabs_in_front){
719 for($i = 0; $i < $empty_tabs_in_front ; $i ++){
720 $row[] = array("string"=>" ", "attach" => "style='text-align:center;width:20px;'");
721 }
722 }
724 /* Create entry name
725 */
726 $name = $val['NAME'];
727 if(isset($val['description'])){
728 $name .= " - [".$val["description"][0]."]";
729 }
731 /* Add departments
732 */
733 $row[]=array("string"=> $img,"attach"=>"style='text-align:center;width:20px;'");
734 $row[]=array("string"=>sprintf($linkopen,$key,$name), "attach" => "style=''");
736 /* Add spacer tabs
737 */
738 if($numtabs > 2){
739 for($i = 2 ; $i < $numtabs;$i++){
740 if(isset( $this->array_Header[$i + $empty_tabs_in_front]['attach'])){
741 $row[] = array("string"=>" ","attach" => $this->array_Header[$i + $empty_tabs_in_front]['attach']);
742 }else{
743 $row[] = array("string"=>" ");
744 }
745 }
746 }
747 $this->AddElement($row);
748 $this->Added_Departments[] = $row;
749 }
750 }
753 function create_department_list($modules)
754 {
755 $departments = array();
756 $ui= get_userinfo();
757 $first = "";
758 $found = FALSE;
759 $options ="";
761 $ids = $this->config->idepartments;
762 $d = $ui->get_module_departments($modules);
763 $k_ids = array_keys($ids);
764 $deps = array_intersect($d,$k_ids);
765 foreach($k_ids as $department){
766 $departments[$department] = $ids[$department];
767 }
769 foreach($departments as $value => $name){
771 /* Keep first base dn in mind, we could need this
772 * info if no valid base was found
773 */
774 if(empty($first)) {
775 $first = $value;
776 }
779 $v_value = htmlentities($value,ENT_QUOTES);
780 if ($this->selectedBase == $value){
781 $found = TRUE;
782 $options.= "<option selected='selected' value=\"".$v_value."\">$name</option>";
783 } else {
784 $options.= "<option value=\"".$v_value."\">$name</option>";
785 }
786 }
788 /* The currently used base is not visible with your acl setup.
789 * Set base to first useable base.
790 */
791 if(!$found){
792 $this->selectedBase = $first;
793 }
795 return($options);
796 }
798 function set_List_Bottom_Info($str)
799 {
800 $this->List_Bottom_Info = $str;
801 }
803 function get_List_Bottom_Info()
804 {
805 return($this->List_Bottom_Info);
806 }
807 }
808 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
809 ?>