Code

Migration to get_value
[gosa.git] / 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();
97     $acl      = $ui->get_permissions($this->selectedBase,"application/application");
98     $acl_all  = $ui->has_complete_category_acls($this->parent->app_base,"application");
100     /* Create Layers menu */
101     $s  = ".|"._("Actions")."|\n";
103     /* Append create options */
104     if(preg_match("/c/",$acl)) {
105       $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
106         "&nbsp;"._("Create")."|\n";
107       $s.= "...|<input class='center' type='image' src='images/list_new_app' alt=''>".
108         "&nbsp;"._("Application")."|appl_new|\n";
109     }
111     /* Multiple options */
112     $s.= "..|---|\n";
113     $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'>".
114       "&nbsp;"._("Remove")."|"."remove_multiple|\n";
116     /* Add Copy & Paste header */
117     $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module);
119     /* Add snapshot icons */
120     $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module);
122     $this->SetDropDownHeaderMenu($s);
123     $this->SetListHeader($listhead);
124   }
127   /* so some basic settings */
128   function execute()
129   {
130     $this->ClearElementsList();
131     $this->GenHeader();
132   }
135   function setEntries($list)
136   {
137     /********************
138       Variable init
139      ********************/
140   
141     /* Create links */
142     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
143     $userimg  = "<img class='center' src='plugins/groups/images/groups.png' alt='User'    title='%s'>";
144     $applimg  = "<img class='center' src='plugins/goto/images/select_application.png' alt='A'  title='"._("Application")."'>";
145     $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
147     /* set Page header */
148     $action_col_size = 80;
149     if($this->parent->snapshotEnabled()){
150       $action_col_size += 38;
151     }
153     /********************
154       Attach objects
155      ********************/
156     
157     $ui = get_userinfo();
158     foreach($list as $key => $val){
160       $acl = $ui->get_permissions($val['dn'],"application/application");
161       $acl_all= $ui->has_complete_category_acls($val['dn'],"application");
163       /* Check FAI state 
164        */  
165       $FAIstate = $val['FAIstate'][0];
167       /* Create action icons */
168       $actions= "";
170       /* Add copy & cut functionality */
171       if(!preg_match("/freeze/i",$FAIstate)){
172         $actions.= $this->parent->get_copypaste_action($val['dn'],"application","application");
173       }else{
174         $actions.= "<img src='images/empty.png' class='center' alt=''>&nbsp;";
175         $actions.= "<img src='images/empty.png' class='center' alt=''>&nbsp;";
176       }
178       /* Add edit icon */
179       $actions.= "<input class='center' type='image'
180         src='images/lists/edit.png' alt='"._("edit")."' name='appl_edit_%KEY%' title='"._("Edit this entry")."'>";
182       /* Add snapshot icon */
183       if(!preg_match("/freeze/i",$FAIstate)){
184         $actions.= $this->parent->get_snapshot_action($val['dn'],$this->module);
185       }else{
186         $actions.= "<img src='images/empty.png' class='center' alt=''>&nbsp;";
187         $actions.= "<img src='images/empty.png' class='center' alt=''>&nbsp;";
188       }
191       /* If we are allowed to remove the application account, display remove icon */
192       if(preg_match("/freeze/i",$FAIstate)){
193         $actions .= "<img src='plugins/goto/images/freeze.png' class='center' alt='!' title='"._("Freezed")."'>";
194       }elseif(preg_match("/d/",$acl)){
195         $actions.= "<input class='center' type='image'
196           src='images/lists/trash.png' alt='"._("delete")."' name='appl_del_%KEY%' title='"._("Delete this entry")."'>";
197       }else{
198         $actions.= "<img src='images/empty.png' alt='&nbsp;'>";
199       }
201       $title = "title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'";
203       if(!isset($val['description'][0])){
204         $desc = "";
205       }else{
206         $desc = " - [ ".$val['description'][0]." ]";
207       }
209       /* Cutted objects should be displayed in light grey */
210       $display = $val['cn'][0].$desc;
211       if($this->parent->CopyPasteHandler){
212         foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
213           if($queue_data['dn'] == $val['dn']) {
214             $display = "<font color='#999999'>".$display."</font>";
215             break;
216           }
217         }
218       }
220       /* Create each field */
221       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
222                       "attach" => "style='width:20px;'");
223       $field1 = array("string" => sprintf($applimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
224       $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title);
225       $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
226       $this->AddElement(array($field0,$field1,$field2,$field3));
227     }
229     /* Create summary string for list footer */
230     $num_deps=0;
231     if(!$this->SubSearch){
232       $num_deps = count($this->Added_Departments);
233     }
234     $num_apps = count($list);
236     $num_app_str = _("Number of listed applications");
237     $num_dep_str = _("Number of listed departments");
238   
239     $str = "<img class='center' src='plugins/goto/images/select_application.png' 
240               title='".$num_app_str."' alt='".$num_app_str."'>&nbsp;".$num_apps."&nbsp;&nbsp;&nbsp;&nbsp;";
241     $str.= "<img class='center' src='images/lists/folder.png' 
242               title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
244     $this->set_List_Bottom_Info($str);
245   }
247   function Save()
248   {
249     MultiSelectWindow::Save();  
250   }
252   function save_object()
253   {
254     /* Save automatic created POSTs like regex, checkboxes */
255     MultiSelectWindow::save_object(); 
256   }
259 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
260 ?>