Code

cdcdcbc9d5a70a002a9df14a64dee0c261b81604
[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();
36     $this->SetInformation(_("This menu allows you to create, delete and edit selected phone conferences. Having a large number of phone conferences, you might prefer the range selectors on top of the conferences list."));
38     $this->EnableAplhabet(true);
39   
40     /* Disable buttonsm */
41     $this->EnableCloseButton(false);
42     $this->EnableSaveButton (false);
44     /* Dynamic action col, depending on snapshot icons */
45     $action_col_size = 100;
46     if($this->parent->snapshotEnabled()){
47       $action_col_size += 20;
48     }
50     /* Toggle all selected / deselected */
51     $chk = "<input type='checkbox' id='select_all' name='select_all'
52       onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
54     /* set Page header */
55     $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
56     $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
57     $this->AddHeader(array("string" =>_("Name - Number"), "attach" => "style=''"));
58     $this->AddHeader(array("string" => _("Owner"), "attach" => "style='width:200px;'"));
59     $this->AddHeader(array("string" => _("PIN"), "attach" => "style='width:50px;'"));
60     $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
62     /* Add Checkboxes / SubSearch checkbox */
63     $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Search in subtrees"), false);
65     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
66     $this->AddRegex   ("Regex",      _("Regular expression for matching conference names"),"*" , true);
67   }
70   function GenHeader()
71   {
72     /* Prepare departments,
73        which are shown in the listbox on top of the listbox
74      */
75     $options= "";
77     /* Get all departments within this subtree */
78     $base = $this->config->current['BASE'];
80     /* Add base */
81     $tmp = array();
82     $tmp[] = array("dn"=>$this->config->current['BASE']);
83     $tmp=  array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
84                     array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
86     $deps = array();
87     foreach($tmp as $tm){
88       $deps[$tm['dn']] = $tm['dn'];
89     }
90   
91     /* Load possible departments */
92     $ui= get_userinfo();
93     $tdeps= $ui->get_module_departments("gofonconference");
94     $ids = $this->config->idepartments;
95     $first = "";
96     $found = FALSE;
97     foreach($ids as $dep => $name){
98       if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
100         /* Keep first base dn in mind, we could need this
101          *  info if no valid base was found
102          */
103         if(empty($first)) {
104           $first = $dep['dn'];
105         }
107         $value = $ids[$dep];
108         if ($this->selectedBase == $dep){
109           $found = TRUE;
110           $options.= "<option selected='selected' value='".$dep."'>$value</option>";
111         } else {
112           $options.= "<option value='".$dep."'>$value</option>";
113         }
114       }
115     }
117     /* The currently used base is not visible with your acl setup.
118      * Set base to first useable base.
119      */
120     if(!$found){
121       $this->selectedBase = $first;
122     }
124     /* Get acls */
125     $acls     = $ui->get_permissions($this->selectedBase,"gofonconference/conference");
126     $acl_all  = $ui->has_complete_category_acls($this->selectedBase,"gofonconference") ;
128     /* Add default header */
129     $listhead = MultiSelectWindow::get_default_header();
131     /* Add the rest (base select ....)*/
132     $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
133       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
134       title='"._("Submit department")."' name='submit_department' alt='".  _("Submit").     "'>&nbsp;";
136     /* Create Layers menu */
137     $s  = ".|"._("Actions")."|\n";
138     $s .= "..|<img src='images/list_new.png' alt='' border='0' class='center'>".
139       "&nbsp;"._("Create")."|\n";
141     /* Append create options */
142     if(preg_match("/(c.*w|w.*c)/",$acl_all)){
143       $s.= "...|<input class='center' type='image' src='images/list_new_conference.png' alt=''>".
144         "&nbsp;"._("Conference")."|conference_new|\n";
145     }
147     /* Multiple options */
148     $s.= "..|---|\n";
149     $s.= "..|<img src='images/edittrash.png' alt='' border='0' class='center'>".
150       "&nbsp;"._("Remove")."|"."remove_multiple|\n";
152     /* Add multiple copy & cut icons */
153     if(is_object($this->parent->CopyPasteHandler)){
154       $s.= "..|---|\n";
155       $s.= "..|<img src='images/editcopy.png' alt='' border='0' class='center'>".
156         "&nbsp;"._("Copy")."|"."multiple_copy_systems|\n";
157       $s.= "..|<img src='images/editcut.png' alt='' border='0' class='center'>".
158         "&nbsp;"._("Cut")."|"."multiple_cut_systems|\n";
160       if($this->parent->CopyPasteHandler->entries_queued()){
161         $img = "<img border='0' class='center' src='images/editpaste.png' alt=''>";
162         $s.="..|".$img."&nbsp;"._("Paste")."|editPaste|\n";
163       }else{
164         $img = "<img border='0' class='center' src='images/cant_editpaste.png' alt=''>";
165         $s.="..|".$img."&nbsp;"._("Paste")."\n";
166       }
167     }
169     /* Add snapshot icons */
170     if(preg_match("/(c.*w|w.*c)/",$acls)){
171       $s .= "..|---|\n";
172       $s .= $this->get_snapshot_header(TRUE);
173     }
175     $this->SetDropDownHeaderMenu($s);
176     $this->SetListHeader($listhead);
177   }
179   function execute()
180   {
181     $this->ClearElementsList();
182     $this->GenHeader();
183   }
185   function setEntries($list)
186   {
187     $linkopen= "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
189     $userimg  = "<img class='center' src='images/select_conference.png' alt='User' title='%s'>";
190     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
192     /* Dynamic action col, depending on snapshot icons */
193     $action_col_size = 100;
194     if($this->parent->snapshotEnabled()){
195       $action_col_size += 20;
196     }
198     /* Insert conferneces*/
199     foreach($list as $conferencekey => $conference ){
201       $acl      = $this->ui->get_permissions($conference['dn'],"gofonconference/conference");
202       $acl_all  = $this->ui->has_complete_category_acls($conference['dn'],"gofonconference");
204       /* You will need at least read access for the 
205           current conference informations to display it */  
206       if(!preg_match("/r/",$acl)){
207         continue;
208       }
210       $actions ="";
211       if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
212         $actions.= "<input class='center' type='image'
213           src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
214         $actions.= "<input class='center' type='image'
215           src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
216       }
218       /* Add edit icon - This is allowed when we have at least read access. */
219       $actions.= "<input class='center' type='image' src='images/edit.png'     
220                     alt='"._("edit")."'    name='conference_edit_%KEY%' title='"._("Edit this entry")."'>";
222       /* Add snapshot icon - This is allowed when we have create and write access for the current entry */
223       if(preg_match("/(c.*w|w.*c)/",$acl_all)){
224         $actions.= $this->GetSnapShotActions($conference['dn']);
225       }
227       /* Create delete link - Only if we are allowed to delete this entry */
228       if(preg_match("/d/",$acl)){
229         $actions.= "<input class='center' type='image' src='images/edittrash.png' 
230           alt='"._("delete")."'   name='conference_del_%KEY%'  title='"._("Delete this entry")."'>";
231       }
233       /* Display PIN icon, only if we are the owner of the given conference */
234       $owner = $this->parent->ui->dn==$conference['goFonConferenceOwner'][0];
235       $p_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","goFonPIN");
236       if((isset($conference['goFonPIN'][0])) && $owner && preg_match("/r/",$p_acl)){
237         $pin = "<img class='center' src='images/list_password.png' title='PIN : ".$conference['goFonPIN'][0]."' alt='PIN'>";
238       }else{
239         $pin = "&nbsp;";
240       }
242       /* Display numer of the conference if we are allowed to view it */
243       $n_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","telephoneNumber");
244       if(isset($conference['telephoneNumber'][0]) && preg_match("/r/",$n_acl)){
245         $number = " - ".$conference['telephoneNumber'][0];
246       }else{
247         $number = "&nbsp; - ?";
248       }
250       /* Get conference owner name */
251       $ldap= $this->parent->config->get_ldap_link();
252       $ldap->cat($conference['goFonConferenceOwner'][0], array('cn'));
253       $data = $ldap->fetch();
254       if(isset($data['cn'][0])){
255         $cn = $data['cn'][0];
256       }else{
257         $cn = _("Unknown"); 
258       }  
260       /* Create title */
261       $title = " title='".preg_replace("/ /","&nbsp;",@LDAP::fix($data['dn']))."' ";
263       /* Cutted objects should be displayed in light grey */
264       $display = $conference['cn'][0].$number;
265       if($this->parent->CopyPasteHandler){
266         foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
267           if($queue_data['dn'] == $conference['dn']) {
268             $display = "<font color='#999999'>".$display."</font>";
269             break;
270           }
271         }
272       }
274       /* Create each field */
275       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$conferencekey."' name='item_selected_".$conferencekey."'>" ,
276           "attach" => "style='width:20px;'");
277       $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => $title." style='text-align:center;width:20px;'");
278       $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$display), "attach" => $title." style=''");
279       $a_field3 = array("string"=> $cn , "attach" =>  $title." style='width:200px;'");
280       $a_field4 = array("string"=> $pin, "attach" =>  $title." style='width:50px;'");
281       $a_field5 = array("string"=> preg_replace("/%KEY%/",$conferencekey,$actions), 
282                         "attach"=> $title."style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
284       $this->AddElement(array($field0,$a_field1,$a_field2,$a_field3,$a_field4,$a_field5));
285     }
287     /* Create summary string for list footer */
288     $num_deps=0;
289     if(!$this->SubSearch){
290       $num_deps = count($this->Added_Departments);
291     }
292     $num_objs = count($list);
294     $num_obj_str = _("Number of listed conferences");
295     $num_dep_str = _("Number of listed departments");
297     $str = "<img class='center' src='images/select_conference.png'
298               title='".$num_obj_str."' alt='".$num_obj_str."'>&nbsp;".$num_objs."&nbsp;&nbsp;&nbsp;&nbsp;";
299     $str.= "<img class='center' src='images/folder.png'
300               title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
302     $this->set_List_Bottom_Info($str);
303   }
305   function Save()
306   {
307     MultiSelectWindow :: Save();  
308   }
310   function save_object()
311   {
312     /* Save automatic created POSTs like regex, checkboxes */
313     MultiSelectWindow :: save_object();   
314   }
316 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
317 ?>