1 <?php
3 class divListConference extends MultiSelectWindow
4 {
6 /* Current base */
7 var $selectedBase = "";
8 var $departments = array();
10 /* Regex */
11 var $Regex = "*";
13 /* checkboxes */
14 var $ShowSendBocklists ;
15 var $ShowReceiveMacros ;
17 /* Subsearch checkbox */
18 var $SubSearch;
20 var $parent ;
21 var $ui ;
23 function divListConference (&$config,$parent)
24 {
25 MultiSelectWindow::MultiSelectWindow($config,"Conferences", "gofonconference");
27 $this->parent = $parent;
28 $this->ui = get_userinfo();
30 /* Set list strings */
31 $this->SetTitle(_("List of conference rooms"));
32 $this->SetSummary(_("List of conference rooms"));
34 /* Result page will look like a headpage */
35 $this->SetHeadpageMode();
37 $this->EnableAplhabet(true);
39 /* Disable buttonsm */
40 $this->EnableCloseButton(false);
41 $this->EnableSaveButton (false);
43 /* Dynamic action col, depending on snapshot icons */
44 $action_col_size = 100;
45 if($this->parent->snapshotEnabled()){
46 $action_col_size += 20;
47 }
49 /* Toggle all selected / deselected */
50 $chk = "<input type='checkbox' id='select_all' name='select_all' title='"._("Select all")."'
51 onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
53 /* set Page header */
54 $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'"));
55 $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"));
56 $this->AddHeader(array("string" =>_("Name")." - "._("Number"), "attach" => "style=''"));
57 $this->AddHeader(array("string" => _("Owner"), "attach" => "style='width:200px;'"));
58 $this->AddHeader(array("string" => _("PIN"), "attach" => "style='width:50px;'"));
59 $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
61 /* Add Checkboxes / SubSearch checkbox */
62 $this->AddCheckBox("SubSearch", msgPool::selectToView("","subsearch"), msgPool::selectToView("","subsearch_small"), false);
64 /* Name ,Text ,Default , Connect with alphabet */
65 $this->AddRegex ("Regex", _("Regular expression for matching conference names"),"*" , true);
66 }
69 function GenHeader()
70 {
71 /* Prepare departments,
72 which are shown in the listbox on top of the listbox
73 */
74 $options= "";
76 /* Get all departments within this subtree */
77 $base = $this->config->current['BASE'];
79 /* Add base */
80 $tmp = array();
81 $tmp[] = array("dn"=>$this->config->current['BASE']);
82 $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
83 array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
85 $deps = array();
86 foreach($tmp as $tm){
87 $deps[$tm['dn']] = $tm['dn'];
88 }
90 /* Load possible departments */
91 $ui= get_userinfo();
92 $tdeps= $ui->get_module_departments("gofonconference");
93 $ids = $this->config->idepartments;
94 $first = "";
95 $found = FALSE;
96 foreach($ids as $dep => $name){
97 if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
99 /* Keep first base dn in mind, we could need this
100 * info if no valid base was found
101 */
102 if(empty($first)) {
103 $first = $dep['dn'];
104 }
106 $value = $ids[$dep];
107 if ($this->selectedBase == $dep){
108 $found = TRUE;
109 $options.= "<option selected='selected' value='".$dep."'>$value</option>";
110 } else {
111 $options.= "<option value='".$dep."'>$value</option>";
112 }
113 }
114 }
116 /* The currently used base is not visible with your acl setup.
117 * Set base to first useable base.
118 */
119 if(!$found){
120 $this->selectedBase = $first;
121 }
123 /* Get acls */
124 $acls = $ui->get_permissions($this->selectedBase,"gofonconference/conference");
125 $acl_all = $ui->has_complete_category_acls($this->selectedBase,"gofonconference") ;
127 /* Add default header */
128 $listhead = MultiSelectWindow::get_default_header();
130 /* Add the rest (base select ....)*/
131 $listhead .= _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
132 " <input class='center' type='image' src='images/lists/submit.png' align='middle'
133 title='"._("Submit department")."' name='submit_department' alt='". _("Submit"). "'> ";
135 /* Create Layers menu */
136 $s = ".|"._("Actions")."|\n";
138 /* Append create options */
139 if(preg_match("/(c.*w|w.*c)/",$acl_all)){
140 $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
141 " "._("Create")."|\n";
142 $s.= "...|<input class='center' type='image' src='images/list_new_conference.png' alt=''>".
143 " "._("Conference")."|conference_new|\n";
144 $s.= "..|---|\n";
145 }
147 /* Multiple options */
148 $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'>".
149 " "._("Remove")."|"."remove_multiple|\n";
151 if(is_object($this->parent->CopyPasteHandler) && preg_match("/r/",$acl_all)){
152 $s.= "..|---|\n";
153 $s.= "..|<img src='images/lists/copy.png' alt='' border='0' class='center'>".
154 " "._("Copy")."|"."multiple_copy_systems|\n";
155 $s.= "..|<img src='images/lists/cut.png' alt='' border='0' class='center'>".
156 " "._("Cut")."|"."multiple_cut_systems|\n";
157 }
159 /* Copy & paste icons */
160 if(is_object($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->entries_queued()){
161 $img = "<img border='0' class='center' src='images/lists/paste.png' alt=''>";
162 $s.="..|".$img." "._("Paste")."|editPaste|\n";
163 }else{
164 $img = "<img border='0' class='center' src='images/lists/paste-grey.png' alt=''>";
165 $s.="..|".$img." "._("Paste")."\n";
166 }
168 /* Add snapshot icons */
169 if(preg_match("/(c.*w|w.*c)/",$acl_all)){
170 $s .= "..|---|\n";
171 $s .= $this->get_snapshot_header(TRUE);
172 }
174 $this->SetDropDownHeaderMenu($s);
175 $this->SetListHeader($listhead);
176 }
178 function execute()
179 {
180 $this->ClearElementsList();
181 $this->GenHeader();
182 }
184 function setEntries($list)
185 {
186 $linkopen= "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
188 $userimg = "<img class='center' src='images/select_conference.png' alt='User' title='%s'>";
189 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
191 /* Dynamic action col, depending on snapshot icons */
192 $action_col_size = 100;
193 if($this->parent->snapshotEnabled()){
194 $action_col_size += 20;
195 }
197 $ui = get_userinfo();
199 /* Insert conferneces*/
200 foreach($list as $conferencekey => $conference ){
202 $acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference");
203 $acl_all = $this->ui->has_complete_category_acls($conference['dn'],"gofonconference");
205 /* You will need at least read access for the
206 current conference informations to display it */
207 if(!preg_match("/r/",$acl)){
208 continue;
209 }
211 $actions ="";
212 if($ui->is_cutable($conference['dn'],"gofonconference","conference") && $this->parent->CopyPasteHandler){
213 $actions .= "<input class='center' type='image'
214 src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'> ";
215 }else{
216 $actions.="<img src='images/empty.png' alt=' ' class='center'> ";
217 }
219 if($ui->is_copyable($conference['dn'],"gofonconference","conference") && $this->parent->CopyPasteHandler){
220 $actions.= "<input class='center' type='image'
221 src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'> ";
222 }else{
223 $actions.="<img src='images/empty.png' alt=' ' class='center'> ";
224 }
226 /* Add edit icon - This is allowed when we have at least read access. */
227 $actions.= "<input class='center' type='image' src='images/lists/edit.png'
228 alt='"._("edit")."' name='conference_edit_%KEY%' title='"._("Edit this entry")."'>";
230 /* Add snapshot icon */
231 if(preg_match("/(r.*w|w.*r)/",$acl_all)){
232 $actions.= $this->GetSnapShotActions($conference['dn']);
233 }else{
234 $actions.="<img src='images/empty.png' alt=' ' class='center'> ";
235 $actions.="<img src='images/empty.png' alt=' ' class='center'> ";
236 }
238 /* Create delete link - Only if we are allowed to delete this entry */
239 if(preg_match("/d/",$acl)){
240 $actions.= "<input class='center' type='image' src='images/lists/trash.png'
241 alt='"._("delete")."' name='conference_del_%KEY%' title='"._("Delete this entry")."'>";
242 }
244 /* Display PIN icon, only if we are the owner of the given conference */
245 $owner = $this->parent->ui->dn==$conference['goFonConferenceOwner'][0];
246 $p_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","goFonPIN");
247 if((isset($conference['goFonPIN'][0])) && $owner && preg_match("/r/",$p_acl)){
248 $pin = "<img class='center' src='images/list_password.png' title='PIN : ".$conference['goFonPIN'][0]."' alt='PIN'>";
249 }else{
250 $pin = " ";
251 }
253 /* Display numer of the conference if we are allowed to view it */
254 $n_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","telephoneNumber");
255 if(isset($conference['telephoneNumber'][0]) && preg_match("/r/",$n_acl)){
256 $number = " - ".$conference['telephoneNumber'][0];
257 }else{
258 $number = " - ?";
259 }
261 /* Get conference owner name */
262 $ldap= $this->parent->config->get_ldap_link();
263 $ldap->cat($conference['goFonConferenceOwner'][0], array('cn'));
264 $data = $ldap->fetch();
265 if(isset($data['cn'][0])){
266 $cn = $data['cn'][0];
267 }else{
268 $cn = _("Unknown");
269 }
271 /* Create title */
272 $title = " title='".preg_replace("/ /"," ",@LDAP::fix($data['dn']))."' ";
274 /* Cutted objects should be displayed in light grey */
275 $display = $conference['cn'][0].$number;
276 if($this->parent->CopyPasteHandler){
277 foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
278 if($queue_data['dn'] == $conference['dn']) {
279 $display = "<font color='#999999'>".$display."</font>";
280 break;
281 }
282 }
283 }
285 /* Create each field */
286 $field0 = array("string" => "<input type='checkbox' id='item_selected_".$conferencekey."' name='item_selected_".$conferencekey."'>" ,
287 "attach" => "style='width:20px;'");
288 $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => $title." style='text-align:center;width:20px;'");
289 $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$display), "attach" => $title." style=''");
290 $a_field3 = array("string"=> $cn , "attach" => $title." style='width:200px;'");
291 $a_field4 = array("string"=> $pin, "attach" => $title." style='width:50px;'");
292 $a_field5 = array("string"=> preg_replace("/%KEY%/",$conferencekey,$actions),
293 "attach"=> $title."style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
295 $this->AddElement(array($field0,$a_field1,$a_field2,$a_field3,$a_field4,$a_field5));
296 }
298 /* Create summary string for list footer */
299 $num_deps=0;
300 if(!$this->SubSearch){
301 $num_deps = count($this->Added_Departments);
302 }
303 $num_objs = count($list);
305 $num_obj_str = sprintf(_("Number of listed '%s'"),_("conferences"));
306 $num_dep_str = sprintf(_("Number of listed '%s'"),_("departments"));
308 $str = "<img class='center' src='images/select_conference.png'
309 title='".$num_obj_str."' alt='".$num_obj_str."'> ".$num_objs." ";
310 $str.= "<img class='center' src='images/lists/folder.png'
311 title='".$num_dep_str."' alt='".$num_dep_str."'> ".$num_deps." ";
313 $this->set_List_Bottom_Info($str);
314 }
316 function Save()
317 {
318 MultiSelectWindow :: Save();
319 }
321 function save_object()
322 {
323 /* Save automatic created POSTs like regex, checkboxes */
324 MultiSelectWindow :: save_object();
325 }
326 }
327 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
328 ?>