1 <?php
3 class divListFai extends MultiSelectWindow
4 {
5 /* Current base */
6 var $selectedBase = "";
7 var $selectedBranch = "main";
8 var $AvailableBranches = array();
9 var $departments = array();
11 /* Regex */
12 var $Regex = "*";
13 var $ShowProfiles;
14 var $ShowTemplates;
15 var $ShowScripts;
16 var $ShowHooks;
17 var $ShowVariables;
18 var $ShowPackages;
19 var $ShowPartitions;
21 /* Subsearch checkbox */
22 var $SubSearch;
24 var $parent ;
25 var $ui ;
27 var $SaveAdditionalVars = array("selectedBranch");
29 function divListFai ($config,$parent)
30 {
31 MultiSelectWindow::MultiSelectWindow($config,"Fai");
33 $this->parent = $parent;
34 $this->ui = get_userinfo();
36 /* Set default base */
37 if(!isset($_SESSION['CurrentMainBase'])){
38 $_SESSION['CurrentMainBase'] = $this->config->current['BASE'];
39 }
40 $this->selectedBase = $_SESSION['CurrentMainBase'];
42 /* Set list strings */
43 $this->SetTitle(_("List of FAI classes"));
44 $this->SetSummary(_("This table displays all FAI classes in the selected tree."));
46 /* Result page will look like a headpage */
47 $this->SetHeadpageMode();
48 $this->SetInformation(_("This menu allows you to create, delete and edit FAI classes."));
50 $this->EnableAplhabet (true);
52 /* Disable buttonsm */
53 $this->EnableCloseButton(false);
54 $this->EnableSaveButton (false);
56 /* set Page header */
57 $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"));
58 $this->AddHeader(array("string" => _("Name of FAI class"), "attach" => "style=''"));
59 $this->AddHeader(array("string" => _("Class type"), "attach" => "style='width:200px;'"));
60 $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:80px;border-right:0px;text-align:right;'"));
62 $this->AddCheckBox("ShowProfiles" , _("Display FAI profile objects") ,_("Show profiles") ,true);
63 $this->AddCheckBox("ShowTemplates" , _("Display FAI template objects") ,_("Show templates") ,true);
64 $this->AddCheckBox("ShowScripts" , _("Display FAI scripts") ,_("Show scripts") ,true);
65 $this->AddCheckBox("ShowHooks" , _("Display FAI hooks") ,_("Show hooks") ,true);
66 $this->AddCheckBox("ShowVariables" , _("Display FAI variables") ,_("Show variables") ,true);
67 $this->AddCheckBox("ShowPackages" , _("Display FAI packages") ,_("Show packages") ,true);
68 $this->AddCheckBox("ShowPartitions" , _("Display FAI partitions") ,_("Show partitions") ,true);
70 /* Add SubSearch checkbox */
71 //$this->AddCheckBox(SEPERATOR);
72 //$this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false);
74 /* Name ,Text ,Default , Connect with alphabet */
75 $this->AddRegex ("Regex", _("Display users matching"),"*" , true);
76 }
78 function AddUserBoxToFilter($position){
79 $str = "";
80 if($position == 2){
81 $smarty = get_smarty();
82 $smarty->assign("selectedBranch",$this->selectedBranch);
83 $smarty->assign("branchimage","images/branch.png");
84 $smarty->assign("branches",$this->AvailableBranches);
85 $str = $smarty->fetch(get_template_path('branch_selector.tpl', TRUE));
86 }
87 return($str);
88 }
90 function GenHeader()
91 {
92 /* Prepare departments,
93 which are shown in the listbox on top of the listbox
94 */
95 $options= "";
96 foreach ($this->config->idepartments as $key => $value){
97 if ($this->selectedBase == $key){
98 $options.= "<option selected='selected' value='$key'>$value</option>";
99 } else {
100 $options.= "<option value='$key'>$value</option>";
101 }
102 }
107 /* Get copy & paste icon */
108 if($this->parent->CopyPasteHandler){
109 $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
110 }else{
111 $Copy_Paste ="";
112 }
114 /* Create listhead, it will be shown on top of the divlist.
115 * It provides general navigation and object creation
116 */
117 $listhead =
118 "<div style='background:#F0F0F9;padding:5px;'> ".
120 "<input class='center' type='image' src='images/list_root.png' align='middle'
121 title='"._("Go to root department")."' name='dep_root' alt='". _("Root")."'> ".
123 "<input class='center' type='image' src='images/list_up.png' align='middle'
124 title='"._("Go up one department")."' name='dep_back' alt='"._("Up"). "'> ".
126 "<input class='center' type='image' src='images/list_home.png' align='middle'
127 title='"._("Go to users home department")."' name='dep_home' alt='"._("Home")."'> ".
129 " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='".
130 _("Submit")."'> ".
132 "<img class='center' src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\"> ".
134 " <input class='center' type='image' src='images/fai_new_profile.png' align='middle'
135 title='"._("New profile")."' name='Create_profile' alt='"._("P")."'> ".
137 "<img class='center' src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\"> ".
139 " <input class='center' type='image' src='images/fai_new_partitionTable.png' align='middle'
140 title='"._("New partition table")."' name='Create_partition' alt='"._("PT")."'> ".
142 " <input class='center' type='image' src='images/fai_new_script.png' align='middle'
143 title='"._("New scripts")."' name='Create_script' alt='"._("S")."'> ".
145 " <input class='center' type='image' src='images/fai_new_hook.png' align='middle'
146 title='"._("New hooks")."' name='Create_hook' alt='"._("H")."'> ".
148 " <input class='center' type='image' src='images/fai_new_variable.png' align='middle'
149 title='"._("New variables")."' name='Create_variable' alt='"._("V")."'> ".
151 " <input class='center' type='image' src='images/fai_new_template.png' align='middle'
152 title='"._("New templates")."' name='Create_template' alt='"._("T")."'> ".
154 " <input class='center' type='image' src='images/fai_new_packages.png' align='middle'
155 title='"._("New package list")."' name='Create_package' alt='"._("PK")."'> ".
157 $Copy_Paste.
159 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
161 _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
162 " <input class='center' type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='". _("Submit")."'> ".
164 "</div>";
166 $this->SetListHeader($listhead);
167 }
169 /* so some basic settings */
170 function execute()
171 {
172 $this->ClearElementsList();
173 $this->GenHeader();
174 }
176 function setEntries($list)
177 {
178 /********************
179 Variable init
180 ********************/
182 $objects = array(
183 "FAIpartitionTable" => array("IMG"=> "images/fai_partitionTable.png", "NAME"=>"Partition table","KZL"=> "PT", "VAR"=>"ShowPartitions"),
184 "FAIpackageList" => array("IMG"=> "images/fai_packages.png", "NAME"=>"Package list" , "KZL"=> "PL", "VAR"=>"ShowPackages"),
185 "FAIscript" => array("IMG"=> "images/fai_script.png", "NAME"=>"Scripts" , "KZL"=> "S", "VAR"=>"ShowScripts"),
186 "FAIvariable" => array("IMG"=> "images/fai_variable.png", "NAME"=>"Variables" , "KZL"=> "V", "VAR"=>"ShowVariables"),
187 "FAIhook" => array("IMG"=> "images/fai_hook.png", "NAME"=>"Hooks", "KZL"=> "H", "VAR"=>"ShowHooks"),
188 "FAIprofile" => array("IMG"=> "images/fai_profile.png", "NAME"=>"Profile" , "KZL"=> "P", "VAR"=>"ShowProfiles"),
189 "FAItemplate" => array("IMG"=> "images/fai_template.png", "NAME"=>"Templates" , "KZL"=> "T", "VAR"=>"ShowTemplates"));
191 $editlink ="<a href='?plug=".$_GET['plug']."&edit_entry=%KEY%' title='%TITLE%'>%NAME%</a>";
193 /********************
194 Attach objects
195 ********************/
197 foreach($list as $key => $value){
198 $info = "";
199 $img = "";
200 $type = $value['type'];
201 $abort =false;
203 if(isset($objects[$type])){
204 $img = "<img class='center' src='".$objects[$type]['IMG']."' title='".$objects[$type]['NAME']."' alt='".$objects[$type]['KZL']."'>";
205 $info = $objects[$type]['NAME'];
206 $var = $objects[$type]['VAR'];
207 }else{
208 $img = "<img class='center' src='images/empty.png' alt=''>";
209 $info = "";
210 $var = "";
211 }
213 if((isset($value['description']))&&(!empty($value['description']))){
214 $desc= " [".$value['description']."]";
215 }else{
216 $desc= "";
217 }
219 /* Create action icons */
220 $action ="";
221 if($this->parent->CopyPasteHandler){
222 if($value['FAIstate'] != "freeze"){
223 $action .= "<input class='center' type='image'
224 src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'> ";
225 }
226 $action.= "<input class='center' type='image'
227 src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'> ";
228 }
230 if($value['FAIstate'] == "freeze"){
231 $action .= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'
232 name='entry_edit_%KEY%' title='"._("Edit class")."'>";
233 $edi = $editlink;
234 $acti = $action;
235 }else{
236 $action .= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'
237 name='entry_edit_%KEY%' title='"._("Edit class")."'>";
238 $action .= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."'
239 name='entry_delete_%KEY%' title='"._("Delete class")."'>";
240 $acti = $action;
241 $edi = $editlink;
242 }
246 $field1 = array("string" => $img , "attach" => "style='text-align:center;width:20px;'");
247 $field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/","/%TITLE%/"),array($key,$value['cn'].$desc,preg_replace('/ /', ' ', @LDAP::fix($value['dn']))),$edi) , "attach" => "style=''");
248 $field3 = array("string" => $info, "attach" => "style='width:200px;'");
249 $field4 = array("string" => preg_replace("/%KEY%/",$key,$acti) , "attach" => "style='width:80px;border-right:0px;text-align:right;'");
250 $this->AddElement(array($field1,$field2,$field3,$field4));
251 }
252 }
254 function Save()
255 {
256 MultiSelectWindow::Save();
257 }
259 function save_object()
260 {
261 /* Save automatic created POSTs like regex, checkboxes */
262 MultiSelectWindow::save_object();
263 $_SESSION['faifilter']['branch'] = $this->selectedBranch;
264 }
265 }
266 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
267 ?>