Code

Merged icons for save/restore
[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. Having a large size of departments, you might prefer the range selectors on   top of the department list."));
34   
35     /* Disable buttonsm */
36     $this->EnableCloseButton(false);
37     $this->EnableSaveButton (false);
39     /* Dynamic action col, depending on snapshot icons */
40     $action_col_size = 50;
41     if($this->parent->snapshotEnabled()){
42       $action_col_size += 20;
43     }
45     /* set Page header */
46     $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
47     $this->AddHeader(array("string"=>_("Department name"), "attach" => "style=''"));
48     $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
50     /* Add SubSearch checkbox */    
51     $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Ignore subtrees"), false);
53     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
54     $this->AddRegex   ("Regex",     _("Regular expression for matching group names"), "*" , true);
55   }
58   function GenHeader()
59   {
60     /* Prepare departments,
61        which are shown in the listbox on top of the listbox
62      */
63     $options= "";
64     foreach ($this->config->idepartments as $key => $value){
65       if ($this->selectedBase == $key){
66         $options.= "<option selected='selected' value='$key'>$value</option>";
67       } else {
68         $options.= "<option value='$key'>$value</option>";
69       }
70     }
72     /* Generate list head */
73     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
74       " <input type='image' class='center' src='images/list_root.png' align='middle' 
75         title='"._("Go to root department")."' name='dep_root' alt='".       _("Root")."'>&nbsp;".
76       " <input type='image' class='center' src='images/list_up.png' align='middle' 
77         title='"._("Go up one department")."' name='dep_back' alt='"._("Up").  "'>&nbsp;".
78       " <input type='image' class='center' src='images/list_home.png' align='middle' 
79         title='"._("Go to users home department")."' name='dep_home' alt='". _("Home")."'>&nbsp;".
80       " <input class='center' type='image' src='images/list_reload.png' align='middle' 
81         title='"._("Reload list")."' name='submit_department' alt='".      _("Submit")."'>&nbsp;".
82       " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
84     if($this->parent->snapshotEnabled()){
85       $listhead .= "  <input class='center' type='image' align='middle' src='images/restore.png'        
86         title='"._("Restore snapshopts of already deleted objects")."' alt='"._("Restore")."' name='RestoreDeletedSnapShot'>".
87         " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
88     }
90     $listhead .=  " <input class='center' type='image' src='images/list_new_department.png' 
91         align='middle' alt='"._("Create new department")."' name='dep_new'>&nbsp; ".
92       " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
93       _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
94       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
95         title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
96       "</div>";
98     $this->SetListHeader($listhead);
99   }
101   function execute()
102   {
103     $this->ClearElementsList();
104     $this->GenHeader();
105   }
107   function setEntries($list)
108   {
110     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
112     /* Dynamic action col, depending on snapshot icons */
113     $action_col_size = 50;
114     if($this->parent->snapshotEnabled()){
115       $action_col_size += 20;
116     }
118     foreach($list as $key => $val) {
119   
120       $cdn= convert_department_dn($val['dn']);  
121       if(isset($val["description"][0])) {
122         $disp = get_sub_department($cdn)." - [".$val["description"][0]."]";
123       }else{
124         $disp = get_sub_department($cdn);
125       }
126   
127       $actions= "<input class='center' type='image' src='images/edit.png'
128         alt='"._("edit")."'   name='dep_edit_%KEY%' title='"._("Edit this entry")."'>";
129       $actions.= $this->GetSnapShotActions($val['dn']);
130       $actions.= "<input class='center' type='image' src='images/edittrash.png'
131         alt='"._("delete")."'   name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
133       if(!isset($this->config->departments[trim($key)])){
134         $this->config->departments[trim($key)]="";
135       }
137       $non_empty="";
138       $keys= str_replace("/","\/",$key);
139       foreach($this->config->departments as $keyd=>$vald ){
140         if(preg_match("/".$keys."\/.*/",$keyd)){
141           $non_empty="full";
142         }
143       }
145       $title = preg_replace('/ /', '&nbsp;', @LDAP::fix($this->config->departments[$key]));
146       $field0 = array("string" => "<img src='images/".$non_empty."folder.png' title='"._("department")."' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
147       $field1 = array("string" => sprintf($linkopen,base64_encode($cdn),$disp), "attach" => "style='' title='".$title."'");
148       $field2 = array("string" => preg_replace("/%KEY%/", base64_encode($key), $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:
149           right;'");
151       $this->AddElement( array($field0,$field1,$field2));
152     }
153   }
155   function Save()
156   {
157     MultiSelectWindow::Save();
158   }
160   function save_object()
161   {
162     /* Save automatic created POSTs like regex, checkboxes */
163     MultiSelectWindow::save_object();   
164   }
166 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
167 ?>