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", "gofon");
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);
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" => " ", "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 }
64 function GenHeader()
65 {
66 /* Prepare departments,
67 which are shown in the listbox on top of the listbox
68 */
69 $options= "";
70 foreach ($this->config->idepartments as $key => $value){
71 if ($this->selectedBase == $key){
72 $options.= "<option selected='selected' value='$key'>$value</option>";
73 } else {
74 $options.= "<option value='$key'>$value</option>";
75 }
76 }
78 /* NEW LIST MANAGMENT */
79 $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
80 " <input class='center' type='image' src='images/list_root.png' align='middle'
81 title='"._("Go to root department")."' name='dep_root' alt='". _("Root")."'> ".
82 " <input class='center' type='image' align='middle' src='images/list_back.png'
83 title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
84 " <input class='center' type='image' align='middle' src='images/list_home.png'
85 title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
86 " <input class='center' type='image' src='images/list_reload.png' align='middle'
87 title='"._("Reload list")."' name='submit_department' alt='". _("Submit")."'> ".
88 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
89 " <input class='center' type='image' align='middle' src='images/list_new_conference.png'
90 title='"._("Create new conference")."' alt='"._("New conference")."' name='user_new'> ".
91 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
92 $listhead .= $this->get_snapshot_header($this->selectedBase);
93 $listhead .= _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
94 " <input class='center' type='image' src='images/list_submit.png' align='middle'
95 title='"._("Submit department")."' name='submit_department' alt='". _("Submit"). "'> ".
96 "</div>";
98 $this->SetListHeader($listhead);
99 }
101 function execute()
102 {
103 $this->ClearElementsList();
104 $this->GenHeader();
105 }
107 function setEntries($list)
108 {
109 $linkopen= "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
111 $userimg = "<img class='center' src='images/select_conference.png' alt='User' title='%s'>";
112 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
114 /* Dynamic action col, depending on snapshot icons */
115 $action_col_size = 50;
116 if($this->parent->snapshotEnabled()){
117 $action_col_size += 20;
118 }
120 /* Insert conferneces*/
121 foreach($list as $conferencekey => $conference ){
123 $acl = $this->ui -> get_permissions($conference['dn'],"gofon/conference");
125 /* You will need at least read access for the
126 current conference informations to display it */
127 if(!preg_match("/r/",$acl)){
128 continue;
129 }
131 /* Add edit icon - This is allowed when we have at least read access. */
132 $actions= "<input class='center' type='image' src='images/edit.png'
133 alt='"._("edit")."' name='conf_edit_%KEY%' title='"._("Edit this entry")."'>";
135 /* Add snapshot icon - This is allowed when we have create and write access for the current entry */
136 if(preg_match("/[cw]/",$acl)){
137 $actions.= $this->GetSnapShotActions($conference['dn']);
138 }
140 /* Create delete link - Only if we are allowed to delete this entry */
141 if(preg_match("/d/",$acl)){
142 $actions.= "<input class='center' type='image' src='images/edittrash.png'
143 alt='"._("delete")."' name='conf_del_%KEY%' title='"._("Delete this entry")."'>";
144 }
146 /* Display PIN icon, only if we are the owner of the given conference */
147 $owner = $this->parent->ui->dn==$conference['goFonConferenceOwner'][0];
148 $p_acl = $this->ui->get_permissions($conference['dn'],"gofon/conference","goFonPIN");
149 if((isset($conference['goFonPIN'][0])) && $owner && preg_match("/r/",$p_acl)){
150 $pin = "<img class='center' src='images/list_password.png' title='PIN : ".$conference['goFonPIN'][0]."' alt='PIN'>";
151 }else{
152 $pin = " ";
153 }
155 /* Display numer of the conference if we are allowed to view it */
156 $n_acl = $this->ui->get_permissions($conference['dn'],"gofon/conference","telephoneNumber");
157 if(isset($conference['telephoneNumber'][0]) && preg_match("/r/",$n_acl)){
158 $number = " - ".$conference['telephoneNumber'][0];
159 }else{
160 $number = " - ?";
161 }
163 /* Get conference owner name */
164 $ldap= $this->parent->config->get_ldap_link();
165 $ldap->cat($conference['goFonConferenceOwner'][0], array('cn'));
166 $data = $ldap->fetch();
167 if(isset($data['cn'][0])){
168 $cn = $data['cn'][0];
169 }else{
170 $cn = _("Unknown");
171 }
173 /* Create title */
174 $title = " title='".preg_replace("/ /"," ",@LDAP::fix($data['dn']))."' ";
176 $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => $title." style='text-align:center;width:20px;'");
177 $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$conference['cn'][0].$number), "attach" => $title." style=''");
178 $a_field3 = array("string"=> $cn , "attach" => $title." style='width:200px;'");
179 $a_field4 = array("string"=> $pin, "attach" => $title." style='width:50px;'");
180 $a_field5 = array("string"=> preg_replace("/%KEY%/",$conferencekey,$actions),
181 "attach"=> $title."style='width:52px;border-right:0px;text-align:right;'");
183 $this->AddElement(array($a_field1,$a_field2,$a_field3,$a_field4,$a_field5));
184 }
185 }
187 function Save()
188 {
189 MultiSelectWindow :: Save();
190 }
192 function save_object()
193 {
194 /* Save automatic created POSTs like regex, checkboxes */
195 MultiSelectWindow :: save_object();
196 }
197 }
198 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
199 ?>