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 /* Insert conferneces*/
198 foreach($list as $conferencekey => $conference ){
200 $acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference");
201 $acl_all = $this->ui->has_complete_category_acls($conference['dn'],"gofonconference");
203 /* You will need at least read access for the
204 current conference informations to display it */
205 if(!preg_match("/r/",$acl)){
206 continue;
207 }
209 $actions ="";
211 if(preg_match("/(r.*d|r.*d)/",$acl_all) && $this->parent->CopyPasteHandler){
212 $actions .= "<input class='center' type='image'
213 src='images/lists/cut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'> ";
214 }else{
215 $actions.="<img src='images/empty.png' alt=' ' class='center'> ";
216 }
218 if(preg_match("/r/",$acl_all) && $this->parent->CopyPasteHandler){
219 $actions.= "<input class='center' type='image'
220 src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'> ";
221 }else{
222 $actions.="<img src='images/empty.png' alt=' ' class='center'> ";
223 }
225 /* Add edit icon - This is allowed when we have at least read access. */
226 $actions.= "<input class='center' type='image' src='images/lists/edit.png'
227 alt='"._("edit")."' name='conference_edit_%KEY%' title='"._("Edit this entry")."'>";
229 /* Add snapshot icon */
230 if(preg_match("/(r.*w|w.*r)/",$acl_all)){
231 $actions.= $this->GetSnapShotActions($conference['dn']);
232 }else{
233 $actions.="<img src='images/empty.png' alt=' ' class='center'> ";
234 $actions.="<img src='images/empty.png' alt=' ' class='center'> ";
235 }
237 /* Create delete link - Only if we are allowed to delete this entry */
238 if(preg_match("/d/",$acl)){
239 $actions.= "<input class='center' type='image' src='images/lists/trash.png'
240 alt='"._("delete")."' name='conference_del_%KEY%' title='"._("Delete this entry")."'>";
241 }
243 /* Display PIN icon, only if we are the owner of the given conference */
244 $owner = $this->parent->ui->dn==$conference['goFonConferenceOwner'][0];
245 $p_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","goFonPIN");
246 if((isset($conference['goFonPIN'][0])) && $owner && preg_match("/r/",$p_acl)){
247 $pin = "<img class='center' src='images/list_password.png' title='PIN : ".$conference['goFonPIN'][0]."' alt='PIN'>";
248 }else{
249 $pin = " ";
250 }
252 /* Display numer of the conference if we are allowed to view it */
253 $n_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","telephoneNumber");
254 if(isset($conference['telephoneNumber'][0]) && preg_match("/r/",$n_acl)){
255 $number = " - ".$conference['telephoneNumber'][0];
256 }else{
257 $number = " - ?";
258 }
260 /* Get conference owner name */
261 $ldap= $this->parent->config->get_ldap_link();
262 $ldap->cat($conference['goFonConferenceOwner'][0], array('cn'));
263 $data = $ldap->fetch();
264 if(isset($data['cn'][0])){
265 $cn = $data['cn'][0];
266 }else{
267 $cn = _("Unknown");
268 }
270 /* Create title */
271 $title = " title='".preg_replace("/ /"," ",@LDAP::fix($data['dn']))."' ";
273 /* Cutted objects should be displayed in light grey */
274 $display = $conference['cn'][0].$number;
275 if($this->parent->CopyPasteHandler){
276 foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
277 if($queue_data['dn'] == $conference['dn']) {
278 $display = "<font color='#999999'>".$display."</font>";
279 break;
280 }
281 }
282 }
284 /* Create each field */
285 $field0 = array("string" => "<input type='checkbox' id='item_selected_".$conferencekey."' name='item_selected_".$conferencekey."'>" ,
286 "attach" => "style='width:20px;'");
287 $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => $title." style='text-align:center;width:20px;'");
288 $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$display), "attach" => $title." style=''");
289 $a_field3 = array("string"=> $cn , "attach" => $title." style='width:200px;'");
290 $a_field4 = array("string"=> $pin, "attach" => $title." style='width:50px;'");
291 $a_field5 = array("string"=> preg_replace("/%KEY%/",$conferencekey,$actions),
292 "attach"=> $title."style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
294 $this->AddElement(array($field0,$a_field1,$a_field2,$a_field3,$a_field4,$a_field5));
295 }
297 /* Create summary string for list footer */
298 $num_deps=0;
299 if(!$this->SubSearch){
300 $num_deps = count($this->Added_Departments);
301 }
302 $num_objs = count($list);
304 $num_obj_str = sprintf(_("Number of listed '%s'"),_("conferences"));
305 $num_dep_str = sprintf(_("Number of listed '%s'"),_("departments"));
307 $str = "<img class='center' src='images/select_conference.png'
308 title='".$num_obj_str."' alt='".$num_obj_str."'> ".$num_objs." ";
309 $str.= "<img class='center' src='images/lists/folder.png'
310 title='".$num_dep_str."' alt='".$num_dep_str."'> ".$num_deps." ";
312 $this->set_List_Bottom_Info($str);
313 }
315 function Save()
316 {
317 MultiSelectWindow :: Save();
318 }
320 function save_object()
321 {
322 /* Save automatic created POSTs like regex, checkboxes */
323 MultiSelectWindow :: save_object();
324 }
325 }
326 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
327 ?>