Code

* Fixed undefined index for "All"
[gosa.git] / plugins / 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 = 60;
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"), _("Ignore 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'];
79     $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
80                     array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
82     /* Add base */
83     $deps[] = array("dn"=>$this->config->current['BASE']);
85     /* Load possible departments */
86     $ui     = get_userinfo();
87     $first = "";
88     $found = FALSE;
89     $tdeps  = $ui->get_module_departments("gofonconference");
90     $ids    = $this->config->idepartments;
92     foreach($deps as $dep){
93       if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
94   
95         /* Keep first base dn in mind, we could need this
96          *  info if no valid base was found
97          */
98         if(empty($first)) {
99           $first = $dep['dn'];
100         }
102         $value = $ids[$dep['dn']];
103         if ($this->selectedBase == $dep['dn']){
104           $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
105         } else {
106           $options.= "<option value='".$dep['dn']."'>$value</option>";
107         }
108       }
109     }
111     /* The currently used base is not visible with your acl setup.
112      * Set base to first useable base.
113      */
114     if(!$found){
115       $this->selectedBase = $first;
116     }
118     /* Get acls */
119     $acls     = $ui->get_permissions($this->selectedBase,"gofonconference/conference");
120     $acl_all  = $ui->has_complete_category_acls($this->selectedBase,"gofonconference") ;
122     /* Add default header */
123     $listhead = MultiSelectWindow::get_default_header();
125     /* Only display create new conference if we are allowed to create new confe... */
126     if(preg_match("/c/",$acls)){
127       $listhead .=" <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
128         " <input class='center' type='image' align='middle' src='images/list_new_conference.png' 
129         title='"._("Create new conference")."' alt='"._("New conference")."' name='conference_new'>&nbsp;".
130         " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
131     }
133     /* Only display snapshot settings if we are able to write && create new entries */
134     if(preg_match("/(c.*w|w.*c)/",$acl_all)){
135       $listhead .= $this->get_snapshot_header($this->selectedBase);
136     }
137   
138     /* Add the rest (base select ....)*/
139     $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
140       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
141       title='"._("Submit department")."' name='submit_department' alt='".  _("Submit").     "'>&nbsp;";
143     /* Multiple options */
144     $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/edittrash.png'
145       title='"._("Remove selected conferences")."' alt='"._("Remove conferences")."' name='remove_multiple_conferences'>&nbsp;";
147     $listhead .="</div>";
149     $this->SetListHeader($listhead);
150   }
152   function execute()
153   {
154     $this->ClearElementsList();
155     $this->GenHeader();
156   }
158   function setEntries($list)
159   {
160     $linkopen= "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
162     $userimg  = "<img class='center' src='images/select_conference.png' alt='User' title='%s'>";
163     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
165     /* Dynamic action col, depending on snapshot icons */
166     $action_col_size = 60;
167     if($this->parent->snapshotEnabled()){
168       $action_col_size += 20;
169     }
171     /* Insert conferneces*/
172     foreach($list as $conferencekey => $conference ){
174       $acl      = $this->ui->get_permissions($conference['dn'],"gofonconference/conference");
175       $acl_all  = $this->ui->has_complete_category_acls($conference['dn'],"gofonconference");
177       /* You will need at least read access for the 
178           current conference informations to display it */  
179       if(!preg_match("/r/",$acl)){
180         continue;
181       }
183       /* Add edit icon - This is allowed when we have at least read access. */
184       $actions= "<input class='center' type='image' src='images/edit.png'     
185                     alt='"._("edit")."'    name='conference_edit_%KEY%' title='"._("Edit this entry")."'>";
187       /* Add snapshot icon - This is allowed when we have create and write access for the current entry */
188       if(preg_match("/(c.*w|w.*c)/",$acl_all)){
189         $actions.= $this->GetSnapShotActions($conference['dn']);
190       }
192       /* Create delete link - Only if we are allowed to delete this entry */
193       if(preg_match("/d/",$acl)){
194         $actions.= "<input class='center' type='image' src='images/edittrash.png' 
195           alt='"._("delete")."'   name='conference_del_%KEY%'  title='"._("Delete this entry")."'>";
196       }
198       /* Display PIN icon, only if we are the owner of the given conference */
199       $owner = $this->parent->ui->dn==$conference['goFonConferenceOwner'][0];
200       $p_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","goFonPIN");
201       if((isset($conference['goFonPIN'][0])) && $owner && preg_match("/r/",$p_acl)){
202         $pin = "<img class='center' src='images/list_password.png' title='PIN : ".$conference['goFonPIN'][0]."' alt='PIN'>";
203       }else{
204         $pin = "&nbsp;";
205       }
207       /* Display numer of the conference if we are allowed to view it */
208       $n_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","telephoneNumber");
209       if(isset($conference['telephoneNumber'][0]) && preg_match("/r/",$n_acl)){
210         $number = " - ".$conference['telephoneNumber'][0];
211       }else{
212         $number = "&nbsp; - ?";
213       }
215       /* Get conference owner name */
216       $ldap= $this->parent->config->get_ldap_link();
217       $ldap->cat($conference['goFonConferenceOwner'][0], array('cn'));
218       $data = $ldap->fetch();
219       if(isset($data['cn'][0])){
220         $cn = $data['cn'][0];
221       }else{
222         $cn = _("Unknown"); 
223       }  
225       /* Create title */
226       $title = " title='".preg_replace("/ /","&nbsp;",@LDAP::fix($data['dn']))."' ";
228       /* Create each field */
229       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$conferencekey."' name='item_selected_".$conferencekey."'>" ,
230           "attach" => "style='width:20px;'");
231       $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => $title." style='text-align:center;width:20px;'");
232       $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$conference['cn'][0].$number), "attach" => $title." style=''");
233       $a_field3 = array("string"=> $cn , "attach" =>  $title." style='width:200px;'");
234       $a_field4 = array("string"=> $pin, "attach" =>  $title." style='width:50px;'");
235       $a_field5 = array("string"=> preg_replace("/%KEY%/",$conferencekey,$actions), 
236                         "attach"=> $title."style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
238       $this->AddElement(array($field0,$a_field1,$a_field2,$a_field3,$a_field4,$a_field5));
239     }
240   }
242   function Save()
243   {
244     MultiSelectWindow :: Save();  
245   }
247   function save_object()
248   {
249     /* Save automatic created POSTs like regex, checkboxes */
250     MultiSelectWindow :: save_object();   
251   }
253 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
254 ?>