Code

Removed executable bits that are not nessesary
[gosa.git] / plugins / admin / applications / class_divListApplication.inc
1 <?php
3 class divListApplication extends MultiSelectWindow
4 {
5   /* Current base */
6   var $selectedBase       = "";
7   var $selectedRelease    = "main";
8   var $AvailableReleases  = array();
9   var $departments        = array();
10   var $parent               ;
11   var $ui                   ;
13   /* Regex */
14   var $Regex           = "*";
16   /* Subsearch checkbox */
17   var $SubSearch;
19   var $SaveAdditionalVars = array("selectedRelease");
21   function divListApplication ($config,$parent)
22   {
23     MultiSelectWindow::MultiSelectWindow($config,"Application");
24     
25     $this->parent       = $parent;
26     $this->ui           = get_userinfo();
28     /* Set list strings */
29     $this->SetTitle(_("List of Applications"));
30     $this->SetSummary(_("This table displays all applications in the selected tree."));
32     /* Result page will look like a headpage */
33     $this->SetHeadpageMode();
34     $this->SetInformation(_("This menu allows you to add, edit and remove selected applications. You may want to use the range selector on top of the application listbox, when working with a large number of applications."));
36     $this->EnableAplhabet(true);
37   
38     /* Disable buttonsm */
39     $this->EnableCloseButton(false);
40     $this->EnableSaveButton (false);
42     /* set Page header */
43     $this->AddHeader(array("string" => "&nbsp;",                "attach" => "style='text-align:center;width:20px;'"));
44     $this->AddHeader(array("string" => _("Application name")." / "._("Department"), "attach" => "style=''"));
45     $this->AddHeader(array("string" => _("Actions"),            "attach" => "style='width:80px;border-right:0px;text-align:right;'"));
47     /* Add SubSearch checkbox */
48     $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Search in subtrees"), false);
50     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
51     $this->AddRegex   ("Regex",     _("Display users matching"),"*" , true);
52   }
54   function AddUserBoxToFilter($position){
55     $str = "";
56     if(($position  == 2) && ($this->parent->IsReleaseManagementActivated($this->config))){
57       $smarty = get_smarty();
58       $smarty->assign("selectedRelease",$this->selectedRelease);
59       $smarty->assign("branchimage","images/branch.png");
60       $smarty->assign("releases",$this->AvailableReleases);
61       $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE));
62     }
63     return($str);
64   }
66   function GenHeader()
67   {
68     /* Prepare departments,
69        which are shown in the listbox on top of the listbox
70      */
71     $options= "";
72     foreach ($this->config->idepartments as $key => $value){
73       if ($this->selectedBase == $key){
74         $options.= "<option selected='selected' value='$key'>$value</option>";
75       } else {
76         $options.= "<option value='$key'>$value</option>";
77       }
78     }
80     /* Get copy & paste icon */
81     if($this->parent->CopyPasteHandler){
82       $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
83     }else{
84       $Copy_Paste ="";
85     }
87     /* Add default header */
88     $listhead = MultiSelectWindow::get_default_header();
89     $listhead.= " <input class='center' type='image' align='middle' src='images/list_new_app.png' alt='"._("new").
90         "' title='"._("Create new application")."' name='appl_new'>&nbsp;".
91       $Copy_Paste.
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   /* so some basic settings */
102   function execute()
103   {
104     $this->ClearElementsList();
105     $this->GenHeader();
106     $this->AvailableReleases = $this->parent->getReleases($this->selectedBase);
107   }
109   function setEntries($list)
110   {
111     /********************
112       Variable init
113      ********************/
114   
115     /* Create links */
116     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
117     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
118     $userimg  = "<img class='center' src='images/select_groups.png' alt='User'    title='%s'>";
119     $applimg  = "<img class='center' src='images/select_application.png' alt='A'  title='"._("Application")."'>";
120     $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
123     /********************
124       Attach objects
125      ********************/
127     foreach($list as $key => $val){
129       $acl= get_permissions ($val['dn'], $this->ui->subtreeACL);
130       $acl= get_module_permission($acl, "application", $val['dn']);
132       /* Get state */
133       $state = "";
134       if(isset($val['FAIstate'])){
135         $state = $val['FAIstate'][0];
136       }
138       /* If this application is a freezed one, we must hide some action buttons */
139       $is_freezed = preg_match("/freeze/i",$state);
141       /* Create action icons */
142       $actions = "";
144       if($acl == "#all#" || preg_match('/#create#/', $acl)){
145         if(($this->parent->CopyPasteHandler) && (!$is_freezed)){
146           $actions.= "<input class='center' type='image'
147             src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
148         }
149         if($this->parent->CopyPasteHandler){
150           $actions.= "<input class='center' type='image'
151             src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
152         }
153       }
154     
155       $actions.= "<input class='center' type='image'
156         src='images/edit.png' alt='"._("edit")."' name='appl_edit_%KEY%' title='"._("Edit this entry")."'>";
157       if($is_freezed){
158         $actions.= "<img src='images/empty.png' width='16' alt='&nbsp;' class='center'>";
159       }else{
161         if(chkacl($acl,"delete") == ""){
162           $actions.= "<input class='center' type='image'
163             src='images/edittrash.png' alt='"._("delete")."' name='appl_del_%KEY%' title='"._("Delete this entry")."'>";
164         }
165       }
168       $title = "title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'";
170       if(!isset($val['description'][0])){
171         $desc = "";
172       }else{
173         $desc = " - [ ".$val['description'][0]." ]";
174       }
176       /* Cutted objects should be displayed in light grey */
177       $display = $val['cn']['0'].$desc;
178       if(isset($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->cutCurrent && $val['dn'] == $this->parent->CopyPasteHandler->objectdn){
179         $display = "<font color='#999999'>".$display."</font>";
180       }
182       $field1 = array("string" => sprintf($applimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
183       $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title);
184       $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:80px;border-right:0px;text-align:right;'");
185       $this->AddElement(array($field1,$field2,$field3));
186     }
188     /* Create summary string for list footer */
189     $num_deps=0;
190     if(!$this->SubSearch){
191       $num_deps = count($this->Added_Departments);
192     }
193     $num_apps = count($list);
195     $num_app_str = _("Number of listed applications");
196     $num_dep_str = _("Number of listed departments");
197   
198     $str = "<img class='center' src='images/select_application.png' 
199               title='".$num_app_str."' alt='".$num_app_str."'>&nbsp;".$num_apps."&nbsp;&nbsp;&nbsp;&nbsp;";
200     $str.= "<img class='center' src='images/folder.png' 
201               title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
203     $this->set_List_Bottom_Info($str);
204   }
206   function Save()
207   {
208     MultiSelectWindow::Save();  
209   }
211   function save_object()
212   {
213     /* Save automatic created POSTs like regex, checkboxes */
214     MultiSelectWindow::save_object(); 
215     $_SESSION['appfilter']['release']  = $this->selectedRelease;
216   }
219 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
220 ?>