Code

Fix filename and path of list_new_app.png (#6187)
[gosa.git] / trunk / gosa-plugins / goto / admin / applications / class_divListApplication.inc
1 <?php
3 class divListApplication extends MultiSelectWindow
4 {
5   /* Current base */
6   var $departments        = array();
7   var $parent               ;
8   var $ui                   ;
10   /* Regex */
11   var $Regex           = "*";
13   /* Subsearch checkbox */
14   var $SubSearch;
15   var $selectedBase ="";
17   function divListApplication (&$config,&$parent)
18   {
19     MultiSelectWindow::MultiSelectWindow($config,"Application", "application");
20   
21     $this->parent       = &$parent;
22     $this->ui           = get_userinfo();
24     /* Set list strings */
25     $this->SetTitle(_("List of Applications"));
26     $this->SetSummary(_("This table displays all applications in the selected tree."));
28     /* Result page will look like a headpage */
29     $this->SetHeadpageMode();
31     $this->EnableAplhabet(true);
32   
33     /* Disable buttonsm */
34     $this->EnableCloseButton(false);
35     $this->EnableSaveButton (false);
37     /* set Page header */
38     $action_col_size = 80;
39     if($this->parent->snapshotEnabled()){
40       $action_col_size += 38;
41     }
44     /* Toggle all selected / deselected */
45     $chk = "<input type='checkbox' id='select_all' name='select_all' title='"._("Select all")."'
46                onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
48     /* set Page header */
49     $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
50     $this->AddHeader(array("string" => "&nbsp;",                "attach" => "style='text-align:center;width:20px;'"));
51     $this->AddHeader(array("string" => _("Application name")." / "._("Department"), "attach" => "style=''"));
52     $this->AddHeader(array("string" => _("Actions"),            "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
54     /* Add SubSearch checkbox */
55     $this->AddCheckBox("SubSearch",  msgPool::selectToView("","subsearch"), msgPool::selectToView("","subsearch_small"), false);
57     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
58     $this->AddRegex   ("Regex",     _("Display users matching"),"*" , true);
59   }
62   function AddUserBoxToFilter($position)
63   {
64     $str = "";
65     if(($position  == 2) && ($this->parent->IsReleaseManagementActivated($this->config))){
66       $smarty = get_smarty();
67       $releases = $this->parent->getReleases();
68       $smarty->assign("app_release" , $releases[$this->parent->app_release]);
69       $smarty->assign("app_base"    , $releases[$this->parent->app_base]);
70       $smarty->assign("branchimage","plugins/goto/images/branch.png");
71       $smarty->assign("app_releases", $releases);
72       $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE));
73     }
74     return($str);
75   }
78   function GenHeader()
79   {
80     /* Add default header */
81     $listhead = MultiSelectWindow::get_default_header(false);
83     if(!$this->parent->IsReleaseManagementActivated()){
84       
85       /* Get all departments within this subtree */
86       $base = $this->config->current['BASE'];
87       $options  = $this->create_department_list($this->module);
89       /* And the rest, a base selection box */
90       $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
91         " <input class='center' type='image' src='images/lists/submit.png' align='middle' 
92           title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;";
93     }
95     /* Get acls */
96     $ui = get_userinfo();
98     if($this->parent->IsReleaseManagementActivated()){
99       $acl      = $ui->get_permissions($this->parent->acl_base,"application/application");
100       $acl_all  = $ui->has_complete_category_acls($this->parent->acl_base,"application");
101     }else{
102       $acl      = $ui->get_permissions($this->selectedBase,"application/application");
103       $acl_all  = $ui->has_complete_category_acls($this->parent->app_base,"application");
104     }
106     /* Create Layers menu */
107     $s  = ".|"._("Actions")."|\n";
109     /* Append create options */
110     $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
111       "&nbsp;"._("Create")."|\n";
112     if(preg_match("/c/",$acl)) {
113       $s.= "...|<input class='center' type='image' src='plugins/goto/images/list_new_app.png' alt=''>".
114         "&nbsp;"._("Application")."|appl_new|\n";
115     }
117     /* Multiple options */
118     $s.= "..|---|\n";
119     $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'>".
120       "&nbsp;"._("Remove")."|"."remove_multiple|\n";
122     /* Add Copy & Paste header */
123     $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module);
125     /* Add snapshot icons */
126     $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module);
128     $this->SetDropDownHeaderMenu($s);
129     $this->SetListHeader($listhead);
130   }
133   /* so some basic settings */
134   function execute()
135   {
136     $this->ClearElementsList();
137     $this->GenHeader();
138   }
141   function setEntries($list)
142   {
143     /********************
144       Variable init
145      ********************/
146   
147     /* Create links */
148     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
149     $userimg  = "<img class='center' src='plugins/groups/images/groups.png' alt='User'    title='%s'>";
150     $applimg  = "<img class='center' src='plugins/goto/images/select_application.png' alt='A'  title='"._("Application")."'>";
151     $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
153     /* set Page header */
154     $action_col_size = 80;
155     if($this->parent->snapshotEnabled()){
156       $action_col_size += 38;
157     }
159     /********************
160       Attach objects
161      ********************/
162     
163     $ui = get_userinfo();
164     foreach($list as $key => $val){
166       $acl = $ui->get_permissions($val['dn'],"application/application");
167       $acl_all= $ui->has_complete_category_acls($val['dn'],"application");
169       /* Check FAI state 
170        */  
171       $FAIstate = $val['FAIstate'][0];
173       /* Create action icons */
174       $actions= "";
176       /* Add copy & cut functionality */
177       if(!preg_match("/freeze/i",$FAIstate)){
178         $actions.= $this->parent->get_copypaste_action($val['dn'],"application","application");
179       }else{
180         $actions.= "<img src='images/empty.png' class='center' alt=''>&nbsp;";
181         $actions.= "<img src='images/empty.png' class='center' alt=''>&nbsp;";
182       }
184       /* Add edit icon */
185       $actions.= "<input class='center' type='image'
186         src='images/lists/edit.png' alt='"._("edit")."' name='appl_edit_%KEY%' title='"._("Edit this entry")."'>";
188       /* Add snapshot icon */
189       if(!preg_match("/freeze/i",$FAIstate)){
190         $actions.= $this->parent->get_snapshot_action($val['dn'],$this->module);
191       }else{
192         $actions.= "<img src='images/empty.png' class='center' alt=''>&nbsp;";
193         $actions.= "<img src='images/empty.png' class='center' alt=''>&nbsp;";
194       }
197       /* If we are allowed to remove the application account, display remove icon */
198       if(preg_match("/freeze/i",$FAIstate)){
199         $actions .= "<img src='plugins/goto/images/freeze.png' class='center' alt='!' title='"._("Freezed")."'>";
200       }elseif(preg_match("/d/",$acl)){
201         $actions.= "<input class='center' type='image'
202           src='images/lists/trash.png' alt='"._("delete")."' name='appl_del_%KEY%' title='"._("Delete this entry")."'>";
203       }else{
204         $actions.= "<img src='images/empty.png' alt='&nbsp;'>";
205       }
207       $title = "title='".preg_replace('/ /', '&nbsp;', LDAP::fix($val['dn']))."'";
209       if(!isset($val['description'][0])){
210         $desc = "";
211       }else{
212         $desc = " - [ ".$val['description'][0]." ]";
213       }
215       /* Cutted objects should be displayed in light grey */
216       $display = $val['cn'][0].$desc;
217       if($this->parent->CopyPasteHandler){
218         foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
219           if($queue_data['dn'] == $val['dn']) {
220             $display = "<font color='#999999'>".$display."</font>";
221             break;
222           }
223         }
224       }
226       /* Create each field */
227       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
228                       "attach" => "style='width:20px;'");
229       $field1 = array("string" => sprintf($applimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
230       $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title);
231       $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
232       $this->AddElement(array($field0,$field1,$field2,$field3));
233     }
235     /* Create summary string for list footer */
236     $num_deps=0;
237     if(!$this->SubSearch){
238       $num_deps = count($this->Added_Departments);
239     }
240     $num_apps = count($list);
242     $num_app_str = _("Number of listed applications");
243     $num_dep_str = _("Number of listed departments");
244   
245     $str = "<img class='center' src='plugins/goto/images/select_application.png' 
246               title='".$num_app_str."' alt='".$num_app_str."'>&nbsp;".$num_apps."&nbsp;&nbsp;&nbsp;&nbsp;";
247     $str.= "<img class='center' src='images/lists/folder.png' 
248               title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
250     $this->set_List_Bottom_Info($str);
251   }
253   function Save()
254   {
255     MultiSelectWindow::Save();  
256   }
258   function save_object()
259   {
260     /* Save automatic created POSTs like regex, checkboxes */
261     MultiSelectWindow::save_object(); 
262   }
265 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
266 ?>