Code

Added department divlist management.
[gosa.git] / plugins / admin / departments / class_divListDepartment.inc
1 <?php
3 class divListDepartment extends MultiSelectWindow
4 {
6   /* Current base */
7   var $selectedBase       = "";
8   var $departments        = array();
10   /* Regex */
11   var $Regex              = "*";
12   
13   /* Subsearch checkbox */
14   var $SubSearch          = false;
16   var $parent             ;
17   var $ui                 ;
19   function divListDepartment ($config,$parent)
20   {
21     MultiSelectWindow::MultiSelectWindow($config,"Department");
22     
23     $this->parent       = $parent;
24     $this->ui           = get_userinfo();
26     /* Set list strings */
27     $this->SetTitle(_("List of departments"));
28     $this->SetSummary(_("List of departments"));
29     $this->EnableAplhabet   (true);
31     /* Result page will look like a headpage */
32     $this->SetHeadpageMode();
33     $this->SetInformation(_("This menu allows you to create, delete and edit selected departments. ".
34                             "Having a large size of departments, you might prefer the range selectors on   top of the department list."));
35   
36     /* Disable buttonsm */
37     $this->EnableCloseButton(false);
38     $this->EnableSaveButton (false);
40     /* set Page header */
41     $this->AddHeader(array("string" => "&nbsp;","attach"=>"style='width:20px;'"));
42     $this->AddHeader(array("string" => _("Groupname / Department")));
43     $this->AddHeader(array("string" => _("Properties"),"attach"=>"style='width:136px;'"));
44     $this->AddHeader(array("string" => _("Actions"),"attach"=>"style='width:80px;border-right:0px;'"));
46     /* Add SubSearch checkbox */    
47     $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Ignore subtrees"), false);
49     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
50     $this->AddRegex   ("Regex",     _("Regular expression for matching group names"), "*" , true);
51   }
54   function GenHeader()
55   {
56     /* Prepare departments,
57        which are shown in the listbox on top of the listbox
58      */
59     $options= "";
60     foreach ($this->config->idepartments as $key => $value){
61       if ($this->selectedBase == $key){
62         $options.= "<option selected='selected' value='$key'>$value</option>";
63       } else {
64         $options.= "<option value='$key'>$value</option>";
65       }
66     }
68     /* Generate list head */
69       $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
70         " <input type='image' class='center' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='".       _("Root")."'>&nbsp;".
71         " <input type='image' class='center' src='images/list_up.png' align='middle' title='"._("Go up one department")."' name='dep_back' alt='"._("Up").  "'>&nbsp;".
72         " <input type='image' class='center' src='images/list_home.png' align='middle' title='"._("Go to users home department")."' name='dep_home' alt='". _("Home")."'>&nbsp;".
73         " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='".      _("Submit")."'>&nbsp;".
74         " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
75         " <input class='center' type='image' src='images/list_new_department.png' align='middle' alt='"._("Create new department")."' name='dep_new'>&nbsp; ".
76         " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
77         _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
78         " <input class='center' type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
79         "</div>";
81     $this->SetListHeader($listhead);
82   }
84   function execute()
85   {
86     $this->ClearElementsList();
87     $this->GenHeader();
88   }
90   function setEntries($list)
91   {
92     $actions= "<input class='center' type='image' src='images/edit.png'
93       alt='"._("edit")."'   name='dep_edit_%KEY%' title='"._("Edit this entry")."'>";
94     $actions.= "<input class='center' type='image' src='images/edittrash.png'
95       alt='"._("delete")."'   name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
97     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
99     foreach($list as $key => $val) {
100       if(!isset($this->config->departments[trim($key)])){
101         $this->config->departments[trim($key)]="";
102       }
104       $non_empty="";
105       $keys= str_replace("/","\/",$key);
106       foreach($this->config->departments as $keyd=>$vald ){
107         if(preg_match("/".$keys."\/.*/",$keyd)){
108           $non_empty="full";
109         }
110       }
112       $title = $this->config->departments[$key];
113       $field0 = array("string" => "<img src='images/".$non_empty."folder.png' title='"._("department")."' alt='department'>", "attach" => "style='text-
114           align:center;width:20px;'");
115       $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style='' title='".$title."'");
116       $field2 = array("string" => preg_replace("/%KEY%/", base64_encode($key), $actions), "attach" => "style='width:60px;border-right:0px;text-align:
117           right;'");
119       $this->AddElement( array($field0,$field1,$field2));
120     }
121   }
123   function Save()
124   {
125     MultiSelectWindow :: Save();  
126   }
128   function save_object()
129   {
130     /* Save automatic created POSTs like regex, checkboxes */
131     MultiSelectWindow::save_object();   
132   }
134 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
135 ?>