Code

msgPool
[gosa.git] / gosa-plugins / gofon / gofon / conference / class_divListConferences.inc
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");
26     
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);
38   
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'
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" => "&nbsp;", "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     }
89   
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")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
132       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
133       title='"._("Submit department")."' name='submit_department' alt='".  _("Submit").     "'>&nbsp;";
135     /* Create Layers menu */
136     $s  = ".|"._("Actions")."|\n";
137     $s .= "..|<img src='images/list_new.png' alt='' border='0' class='center'>".
138       "&nbsp;"._("Create")."|\n";
140     /* Append create options */
141     if(preg_match("/(c.*w|w.*c)/",$acl_all)){
142       $s.= "...|<input class='center' type='image' src='images/list_new_conference.png' alt=''>".
143         "&nbsp;"._("Conference")."|conference_new|\n";
144     }
146     /* Multiple options */
147     $s.= "..|---|\n";
148     $s.= "..|<img src='images/edittrash.png' alt='' border='0' class='center'>".
149       "&nbsp;"._("Remove")."|"."remove_multiple|\n";
151     /* Add multiple copy & cut icons */
152     if(is_object($this->parent->CopyPasteHandler)){
153       $s.= "..|---|\n";
154       $s.= "..|<img src='images/editcopy.png' alt='' border='0' class='center'>".
155         "&nbsp;"._("Copy")."|"."multiple_copy_systems|\n";
156       $s.= "..|<img src='images/editcut.png' alt='' border='0' class='center'>".
157         "&nbsp;"._("Cut")."|"."multiple_cut_systems|\n";
159       if($this->parent->CopyPasteHandler->entries_queued()){
160         $img = "<img border='0' class='center' src='images/editpaste.png' alt=''>";
161         $s.="..|".$img."&nbsp;"._("Paste")."|editPaste|\n";
162       }else{
163         $img = "<img border='0' class='center' src='images/cant_editpaste.png' alt=''>";
164         $s.="..|".$img."&nbsp;"._("Paste")."\n";
165       }
166     }
168     /* Add snapshot icons */
169     if(preg_match("/(c.*w|w.*c)/",$acls)){
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']."&amp;act=dep_open&amp;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']."&amp;id=%s&amp;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 ="";
210       if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
211         $actions.= "<input class='center' type='image'
212           src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
213         $actions.= "<input class='center' type='image'
214           src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
215       }
217       /* Add edit icon - This is allowed when we have at least read access. */
218       $actions.= "<input class='center' type='image' src='images/edit.png'     
219                     alt='"._("edit")."'    name='conference_edit_%KEY%' title='"._("Edit this entry")."'>";
221       /* Add snapshot icon - This is allowed when we have create and write access for the current entry */
222       if(preg_match("/(c.*w|w.*c)/",$acl_all)){
223         $actions.= $this->GetSnapShotActions($conference['dn']);
224       }
226       /* Create delete link - Only if we are allowed to delete this entry */
227       if(preg_match("/d/",$acl)){
228         $actions.= "<input class='center' type='image' src='images/edittrash.png' 
229           alt='"._("delete")."'   name='conference_del_%KEY%'  title='"._("Delete this entry")."'>";
230       }
232       /* Display PIN icon, only if we are the owner of the given conference */
233       $owner = $this->parent->ui->dn==$conference['goFonConferenceOwner'][0];
234       $p_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","goFonPIN");
235       if((isset($conference['goFonPIN'][0])) && $owner && preg_match("/r/",$p_acl)){
236         $pin = "<img class='center' src='images/list_password.png' title='PIN : ".$conference['goFonPIN'][0]."' alt='PIN'>";
237       }else{
238         $pin = "&nbsp;";
239       }
241       /* Display numer of the conference if we are allowed to view it */
242       $n_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","telephoneNumber");
243       if(isset($conference['telephoneNumber'][0]) && preg_match("/r/",$n_acl)){
244         $number = " - ".$conference['telephoneNumber'][0];
245       }else{
246         $number = "&nbsp; - ?";
247       }
249       /* Get conference owner name */
250       $ldap= $this->parent->config->get_ldap_link();
251       $ldap->cat($conference['goFonConferenceOwner'][0], array('cn'));
252       $data = $ldap->fetch();
253       if(isset($data['cn'][0])){
254         $cn = $data['cn'][0];
255       }else{
256         $cn = _("Unknown"); 
257       }  
259       /* Create title */
260       $title = " title='".preg_replace("/ /","&nbsp;",@LDAP::fix($data['dn']))."' ";
262       /* Cutted objects should be displayed in light grey */
263       $display = $conference['cn'][0].$number;
264       if($this->parent->CopyPasteHandler){
265         foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
266           if($queue_data['dn'] == $conference['dn']) {
267             $display = "<font color='#999999'>".$display."</font>";
268             break;
269           }
270         }
271       }
273       /* Create each field */
274       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$conferencekey."' name='item_selected_".$conferencekey."'>" ,
275           "attach" => "style='width:20px;'");
276       $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => $title." style='text-align:center;width:20px;'");
277       $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$display), "attach" => $title." style=''");
278       $a_field3 = array("string"=> $cn , "attach" =>  $title." style='width:200px;'");
279       $a_field4 = array("string"=> $pin, "attach" =>  $title." style='width:50px;'");
280       $a_field5 = array("string"=> preg_replace("/%KEY%/",$conferencekey,$actions), 
281                         "attach"=> $title."style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
283       $this->AddElement(array($field0,$a_field1,$a_field2,$a_field3,$a_field4,$a_field5));
284     }
286     /* Create summary string for list footer */
287     $num_deps=0;
288     if(!$this->SubSearch){
289       $num_deps = count($this->Added_Departments);
290     }
291     $num_objs = count($list);
293     $num_obj_str = sprintf(_("Number of listed %s"),_("conferences"));
294     $num_dep_str = sprintf(_("Number of listed %s"),_("departments"));
296     $str = "<img class='center' src='images/select_conference.png'
297               title='".$num_obj_str."' alt='".$num_obj_str."'>&nbsp;".$num_objs."&nbsp;&nbsp;&nbsp;&nbsp;";
298     $str.= "<img class='center' src='images/folder.png'
299               title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
301     $this->set_List_Bottom_Info($str);
302   }
304   function Save()
305   {
306     MultiSelectWindow :: Save();  
307   }
309   function save_object()
310   {
311     /* Save automatic created POSTs like regex, checkboxes */
312     MultiSelectWindow :: save_object();   
313   }
315 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
316 ?>