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");
25 $this->parent = $parent;
26 $this->ui = get_userinfo();
28 /* Set default base */
29 if(!isset($_SESSION['CurrentMainBase'])){
30 $_SESSION['CurrentMainBase'] = $this->config->current['BASE'];
31 }
32 $this->selectedBase = $_SESSION['CurrentMainBase'];
34 /* Set list strings */
35 $this->SetTitle(_("List of Applications"));
36 $this->SetSummary(_("This table displays all applications in the selected tree."));
38 /* Result page will look like a headpage */
39 $this->SetHeadpageMode();
40 $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."));
42 $this->EnableAplhabet(true);
44 /* Disable buttonsm */
45 $this->EnableCloseButton(false);
46 $this->EnableSaveButton (false);
48 /* set Page header */
49 $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"));
50 $this->AddHeader(array("string" => _("Application name")." / "._("Department"), "attach" => "style=''"));
51 $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:80px;border-right:0px;text-align:right;'"));
53 /* Add SubSearch checkbox */
54 $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false);
56 /* Name ,Text ,Default , Connect with alphabet */
57 $this->AddRegex ("Regex", _("Display users matching"),"*" , true);
58 }
60 function AddUserBoxToFilter($position){
61 $str = "";
62 if(($position == 2) && ($this->parent->enableReleaseManagement)){
63 $smarty = get_smarty();
64 $smarty->assign("selectedRelease",$this->selectedRelease);
65 $smarty->assign("branchimage","images/branch.png");
66 $smarty->assign("releases",$this->AvailableReleases);
67 $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE));
68 }
69 return($str);
70 }
72 function GenHeader()
73 {
74 /* Prepare departments,
75 which are shown in the listbox on top of the listbox
76 */
77 $options= "";
78 foreach ($this->config->idepartments as $key => $value){
79 if ($this->selectedBase == $key){
80 $options.= "<option selected='selected' value='$key'>$value</option>";
81 } else {
82 $options.= "<option value='$key'>$value</option>";
83 }
84 }
86 /* Get copy & paste icon */
87 if($this->parent->CopyPasteHandler){
88 $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
89 }else{
90 $Copy_Paste ="";
91 }
93 /* Create listhead, it will be shown on top of the divlist.
94 * It provides general navigation and object creation
95 */
96 $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
97 " <input class='center' type='image' src='images/list_root.png' align='middle' ".
98 "title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
99 " <input class='center' type='image' align='middle' src='images/list_back.png' ".
100 "title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
101 " <input class='center' type='image' align='middle' src='images/list_home.png' ".
102 "title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
103 " <input class='center' type='image' src='images/list_reload.png' align='middle' ".
104 "title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'> ".
105 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
106 " <input class='center' type='image' align='middle' src='images/list_new_app.png' alt='"._("new").
107 "' title='"._("Create new application")."' name='appl_new'> ".
108 $Copy_Paste.
109 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
110 _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
111 " <input class='center' type='image' src='images/list_submit.png' align='middle'
112 title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
113 "</div>";
115 $this->SetListHeader($listhead);
116 }
118 /* so some basic settings */
119 function execute()
120 {
121 $this->ClearElementsList();
122 $this->GenHeader();
123 $this->AvailableReleases = $this->parent->getReleases($this->selectedBase);
124 }
126 function setEntries($list)
127 {
128 /********************
129 Variable init
130 ********************/
132 /* Create links */
133 $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
134 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
135 $userimg = "<img class='center' src='images/select_groups.png' alt='User' title='%s'>";
136 $applimg = "<img class='center' src='images/select_application.png' alt='A' title='"._("Application")."'>";
137 $empty = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
140 /* Create action icons */
141 $actions = "";
142 if($this->parent->CopyPasteHandler){
143 $actions.= "<input class='center' type='image'
144 src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'> ";
145 $actions.= "<input class='center' type='image'
146 src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'> ";
147 }
148 $actions.= "<input class='center' type='image'
149 src='images/edit.png' alt='"._("edit")."' name='appl_edit_%KEY%' title='"._("Edit this entry")."'>";
150 $actions.= "<input class='center' type='image'
151 src='images/edittrash.png' alt='"._("delete")."' name='appl_del_%KEY%' title='"._("Delete this entry")."'>";
154 /********************
155 Attach objects
156 ********************/
158 foreach($list as $key => $val){
159 $title = "title='dn: ".@LDAP::fix($val['dn'])."'";
161 if(!isset($val['description'][0])){
162 $desc = "";
163 }else{
164 $desc = " - [ ".$val['description'][0]." ]";
165 }
166 $field1 = array("string" => sprintf($applimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
167 $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
168 $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:80px;border-right:0px;text-align:right;'");
169 $this->AddElement(array($field1,$field2,$field3));
170 }
171 }
173 function Save()
174 {
175 MultiSelectWindow::Save();
176 }
178 function save_object()
179 {
180 /* Save automatic created POSTs like regex, checkboxes */
181 MultiSelectWindow::save_object();
182 $_SESSION['appfilter']['release'] = $this->selectedRelease;
183 }
184 }
185 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
186 ?>