Code

Fix filter box generation
[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"), _("Ignore 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     print_a($this->parent);
57     if(($position  == 2) && ($this->parent->IsReleaseManagementActivated($this->config))){
58       $smarty = get_smarty();
59       $smarty->assign("selectedRelease",$this->selectedRelease);
60       $smarty->assign("branchimage","images/branch.png");
61       $smarty->assign("releases",$this->AvailableReleases);
62       $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE));
63     }
64     return($str);
65   }
67   function GenHeader()
68   {
69     /* Prepare departments,
70        which are shown in the listbox on top of the listbox
71      */
72     $options= "";
73     foreach ($this->config->idepartments as $key => $value){
74       if ($this->selectedBase == $key){
75         $options.= "<option selected='selected' value='$key'>$value</option>";
76       } else {
77         $options.= "<option value='$key'>$value</option>";
78       }
79     }
81     /* Get copy & paste icon */
82     if($this->parent->CopyPasteHandler){
83       $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
84     }else{
85       $Copy_Paste ="";
86     }
88     /* Create listhead, it will be shown on top of the divlist.
89      * It provides general navigation and object creation
90      */
91     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
92       " <input class='center' type='image' src='images/list_root.png' align='middle' ".
93         "title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
94       " <input class='center' type='image' align='middle' src='images/list_back.png' ".
95         "title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
96       " <input class='center' type='image' align='middle' src='images/list_home.png' ".
97         "title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'>&nbsp;".
98       " <input class='center' type='image' src='images/list_reload.png' align='middle' ".
99         "title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
100       " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
101       " <input class='center' type='image' align='middle' src='images/list_new_app.png' alt='"._("new").
102         "' title='"._("Create new application")."' name='appl_new'>&nbsp;".
103       $Copy_Paste.
104       " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
105       _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
106       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
107         title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
108       "</div>";
110     $this->SetListHeader($listhead);
111   }
113   /* so some basic settings */
114   function execute()
115   {
116     $this->ClearElementsList();
117     $this->GenHeader();
118     $this->AvailableReleases = $this->parent->getReleases($this->selectedBase);
119   }
121   function setEntries($list)
122   {
123     /********************
124       Variable init
125      ********************/
126   
127     /* Create links */
128     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
129     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
130     $userimg  = "<img class='center' src='images/select_groups.png' alt='User'    title='%s'>";
131     $applimg  = "<img class='center' src='images/select_application.png' alt='A'  title='"._("Application")."'>";
132     $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
135     /* Create action icons */
136     $actions = "";
137     if($this->parent->CopyPasteHandler){
138       $actions.= "<input class='center' type='image'
139         src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
140       $actions.= "<input class='center' type='image'
141         src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
142     }
143     $actions.= "<input class='center' type='image'
144       src='images/edit.png' alt='"._("edit")."' name='appl_edit_%KEY%' title='"._("Edit this entry")."'>";
145     $actions.= "<input class='center' type='image'
146       src='images/edittrash.png' alt='"._("delete")."' name='appl_del_%KEY%' title='"._("Delete this entry")."'>";
149     /********************
150       Attach objects
151      ********************/
153     foreach($list as $key => $val){
154       $title = "title='dn:&nbsp;".@LDAP::fix($val['dn'])."'";
156       if(!isset($val['description'][0])){
157         $desc = "";
158       }else{
159         $desc = " - [ ".$val['description'][0]." ]";
160       }
161       $field1 = array("string" => sprintf($applimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
162       $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
163       $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:80px;border-right:0px;text-align:right;'");
164       $this->AddElement(array($field1,$field2,$field3));
165     }
166   }
168   function Save()
169   {
170     MultiSelectWindow::Save();  
171   }
173   function save_object()
174   {
175     /* Save automatic created POSTs like regex, checkboxes */
176     MultiSelectWindow::save_object(); 
177     $_SESSION['appfilter']['release']  = $this->selectedRelease;
178   }
181 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
182 ?>