Code

Changed Management Action Post names
[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 = 50;
46     if($this->parent->snapshotEnabled()){
47       $action_col_size += 20;
48     }
50     /* set Page header */
51     $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
52     $this->AddHeader(array("string" =>_("Name - Number"), "attach" => "style=''"));
53     $this->AddHeader(array("string" => _("Owner"), "attach" => "style='width:200px;'"));
54     $this->AddHeader(array("string" => _("PIN"), "attach" => "style='width:50px;'"));
55     $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
57     /* Add Checkboxes / SubSearch checkbox */
58     $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Ignore subtrees"), false);
60     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
61     $this->AddRegex   ("Regex",      _("Regular expression for matching conference names"),"*" , true);
62   }
65   function GenHeader()
66   {
67     /* Prepare departments,
68        which are shown in the listbox on top of the listbox
69      */
70     $options= "";
72     /* Get all departments within this subtree */
73     $base = $this->config->current['BASE'];
74     $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
75                     array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
77     /* Load possible departments */
78     $ui     = get_userinfo();
79     $tdeps  = $ui->get_module_departments("gofonconference");
80     $ids    = $this->config->idepartments;
82     foreach($deps as $dep){
83       if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
84         $value = $ids[$dep['dn']];
85         if ($this->selectedBase == $dep['dn']){
86           $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
87         } else {
88           $options.= "<option value='".$dep['dn']."'>$value</option>";
89         }
90       }
91     }
93     /* Get acls */
94     $acls     = $ui->get_permissions($this->selectedBase,"gofonconference/conference");
95     $acl_all  = $ui->has_complete_category_acls($this->selectedBase,"gofonconference") ;
97     /* NEW LIST MANAGMENT */
98     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
99       " <input class='center' type='image' src='images/list_root.png' align='middle' 
100       title='"._("Go to root department")."' name='dep_root' alt='".         _("Root")."'>&nbsp;".
101       " <input class='center' type='image' align='middle' src='images/list_back.png' 
102       title='"._("Go up one department")."' alt='"._("Up")."'                name='dep_back'>&nbsp;".
103       " <input class='center' type='image' align='middle' src='images/list_home.png' 
104       title='"._("Go to users department")."' alt='"._("Home")."'            name='dep_home'>&nbsp;".
105       " <input class='center' type='image' src='images/list_reload.png' align='middle' 
106       title='"._("Reload list")."' name='submit_department' alt='".        _("Submit")."'>&nbsp;";
108     /* Only display create new conference if we are allowed to create new confe... */
109     if(preg_match("/c/",$acls)){
110       $listhead .=" <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
111         " <input class='center' type='image' align='middle' src='images/list_new_conference.png' 
112         title='"._("Create new conference")."' alt='"._("New conference")."' name='conference_new'>&nbsp;".
113         " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
114     }
116     /* Only display snapshot settings if we are able to write && create new entries */
117     if(preg_match("/(c.*w|w.*c)/",$acl_all)){
118       $listhead .= $this->get_snapshot_header($this->selectedBase);
119     }
120   
121     /* Add the rest (base select ....)*/
122     $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
123       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
124       title='"._("Submit department")."' name='submit_department' alt='".  _("Submit").     "'>&nbsp;".
125       "</div>";
127     $this->SetListHeader($listhead);
128   }
130   function execute()
131   {
132     $this->ClearElementsList();
133     $this->GenHeader();
134   }
136   function setEntries($list)
137   {
138     $linkopen= "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
140     $userimg  = "<img class='center' src='images/select_conference.png' alt='User' title='%s'>";
141     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
143     /* Dynamic action col, depending on snapshot icons */
144     $action_col_size = 50;
145     if($this->parent->snapshotEnabled()){
146       $action_col_size += 20;
147     }
149     /* Insert conferneces*/
150     foreach($list as $conferencekey => $conference ){
152       $acl      = $this->ui->get_permissions($conference['dn'],"gofonconference/conference");
153       $acl_all  = $this->ui->has_complete_category_acls($conference['dn'],"gofonconference");
155       /* You will need at least read access for the 
156           current conference informations to display it */  
157       if(!preg_match("/r/",$acl)){
158         continue;
159       }
161       /* Add edit icon - This is allowed when we have at least read access. */
162       $actions= "<input class='center' type='image' src='images/edit.png'     
163                     alt='"._("edit")."'    name='conference_edit_%KEY%' title='"._("Edit this entry")."'>";
165       /* Add snapshot icon - This is allowed when we have create and write access for the current entry */
166       if(preg_match("/(c.*w|w.*c)/",$acl_all)){
167         $actions.= $this->GetSnapShotActions($conference['dn']);
168       }
170       /* Create delete link - Only if we are allowed to delete this entry */
171       if(preg_match("/d/",$acl)){
172         $actions.= "<input class='center' type='image' src='images/edittrash.png' 
173           alt='"._("delete")."'   name='conference_del_%KEY%'  title='"._("Delete this entry")."'>";
174       }
176       /* Display PIN icon, only if we are the owner of the given conference */
177       $owner = $this->parent->ui->dn==$conference['goFonConferenceOwner'][0];
178       $p_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","goFonPIN");
179       if((isset($conference['goFonPIN'][0])) && $owner && preg_match("/r/",$p_acl)){
180         $pin = "<img class='center' src='images/list_password.png' title='PIN : ".$conference['goFonPIN'][0]."' alt='PIN'>";
181       }else{
182         $pin = "&nbsp;";
183       }
185       /* Display numer of the conference if we are allowed to view it */
186       $n_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","telephoneNumber");
187       if(isset($conference['telephoneNumber'][0]) && preg_match("/r/",$n_acl)){
188         $number = " - ".$conference['telephoneNumber'][0];
189       }else{
190         $number = "&nbsp; - ?";
191       }
193       /* Get conference owner name */
194       $ldap= $this->parent->config->get_ldap_link();
195       $ldap->cat($conference['goFonConferenceOwner'][0], array('cn'));
196       $data = $ldap->fetch();
197       if(isset($data['cn'][0])){
198         $cn = $data['cn'][0];
199       }else{
200         $cn = _("Unknown"); 
201       }  
203       /* Create title */
204       $title = " title='".preg_replace("/ /","&nbsp;",@LDAP::fix($data['dn']))."' ";
206       $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => $title." style='text-align:center;width:20px;'");
207       $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$conference['cn'][0].$number), "attach" => $title." style=''");
208       $a_field3 = array("string"=> $cn , "attach" =>  $title." style='width:200px;'");
209       $a_field4 = array("string"=> $pin, "attach" =>  $title." style='width:50px;'");
210       $a_field5 = array("string"=> preg_replace("/%KEY%/",$conferencekey,$actions), 
211                         "attach"=> $title."style='width:52px;border-right:0px;text-align:right;'");
213       $this->AddElement(array($a_field1,$a_field2,$a_field3,$a_field4,$a_field5));
214     }
215   }
217   function Save()
218   {
219     MultiSelectWindow :: Save();  
220   }
222   function save_object()
223   {
224     /* Save automatic created POSTs like regex, checkboxes */
225     MultiSelectWindow :: save_object();   
226   }
228 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
229 ?>