1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2003 Cajus Pollmeier
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 require "tabs_conference.inc";
22 class phoneConferenceManagment extends plugin
23 {
24 /* Definitions */
25 var $plHeadline = "Phone conferences";
26 var $plDescription = "Management";
28 /* CLI vars */
29 var $cli_summary = "Handling of LDAP subtrees";
30 var $cli_description = "Some longer text\nfor help";
31 var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
33 /* attribute list for save action */
34 var $attributes = array();
35 var $objectclasses = array();
37 var $conferences = array();
38 var $conftab = false;
40 var $DivListConference = NULL;
42 /* Initialise Class */
43 function phoneConferenceManagment ($config, $ui)
44 {
45 $this->ui = $ui;
46 $this->dn = "";
47 $this->config = $config;
49 $acl= get_permissions ($ui->dn, $ui->subtreeACL);
50 $this->acl= get_module_permission($acl, "conference", $ui->dn);
52 $this->DivListConference = new divListConference($this->config,$this);
53 }
56 /* Execute class and display something */
57 function execute()
58 {
59 /* Call parent execute */
60 plugin::execute();
62 /***************
63 Variable initialisation
64 ***************/
66 /* Reload departments */
67 $smarty = get_smarty();
68 $display = "";
69 $s_action = ""; // Will contain an action, like del or edit
70 $s_entry = ""; // The entry name for edit delete -...
71 $conferencefilter = $_SESSION["conferencefilter"];
74 /***************
75 Check posts
76 ***************/
78 foreach($_POST as $key => $post){
79 if(preg_match("/.*new.*/i",$key)){
80 $s_action = "new";
81 // Post for delete
82 }elseif(preg_match("/conf_del.*/",$key)){
83 $s_action = "del";
84 $s_entry = preg_replace("/conf_".$s_action."_/i","",$key);
85 $s_entry = preg_replace("/_.*$/","",$s_entry);
86 // Post for edit
87 }elseif(preg_match("/conf_edit_.*/",$key)){
88 $s_action="edit";
89 $s_entry = preg_replace("/conf_".$s_action."_/i","",$key);
90 $s_entry = preg_replace("/_.*$/","",$s_entry);
91 }
92 }
94 /* Edit Entry */
95 if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
96 $s_action = "edit";
97 $s_entry = $_GET['id'];
98 }
101 /***************
102 Cancel dialogs
103 ***************/
105 /* Reset requested? */
106 if (isset($_POST['edit_cancel'])){
107 if (isset($this->conftab)){
108 del_lock ($this->conftab->dn);
109 unset ($this->conftab);
110 }
111 $this->conftab= NULL;
112 $this->lognames= array();;
113 $this->cn= "";
114 unset ($_SESSION['objectinfo']);
115 }
118 /***************
119 Delete
120 ***************/
122 /* Delete Entry if Posted action (s_action) == del
123 * The entry which will be deleted is defined in $s_entry
124 */
125 if ($s_action =="del"){
126 $this->dn= $this->conferences[$s_entry]['dn'];
128 /* Check locking */
129 if (($conf= get_lock($this->dn)) != ""){
130 $_SESSION['dn']= $this->dn;
131 return(gen_locked_message($conf, $this->dn));
132 } else {
133 add_lock ($this->dn, $this->ui->dn);
134 $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), $this->dn));
135 $display.= $smarty->fetch (get_template_path('remove.tpl', TRUE));
136 return ($display);
137 }
138 }
141 /***************
142 Delete confirmed
143 ***************/
145 /* If department deletion is accepted ...
146 * Finally delete department
147 */
148 if (isset($_POST['delete_department_confirm'])){
149 if (chkacl($this->acl, "delete") == ""){
150 $this->remove_from_parent();
151 gosa_log ("Department object'".$this->dn."' has been removed");
152 } else {
153 print_red (_("You have no permission to remove this department."));
154 }
155 }
158 /***************
159 Edit
160 ***************/
162 /* Edit Entry if Posted action (s_action) == edit
163 * The entry which will be edited is defined in $s_entry
164 */
165 if (($s_action=="edit") && (!isset($this->conftab->config))){
167 $this->dn= $this->conferences[$s_entry]['dn'];
169 if (($conf= get_lock($this->dn)) != ""){
170 return(gen_locked_message ($conf, $this->dn));
171 }
173 /* Lock the current entry, so everyone will get the above dialog */
174 add_lock ($this->dn, $this->ui->dn);
176 /* Register conftab to trigger edit dialog */
177 $this->conftab= new conferencetabs($this->config,$this->config->data['TABS']['CONFERENCETABS'], $this->dn);
178 $_SESSION['objectinfo']= $this->dn;
179 }
182 /***************
183 Create new
184 ***************/
186 /* Insert new entry*/
187 if($s_action == "new"){
189 /* Set up the users ACL's for this 'dn' */
190 $this->dn= "new";
191 $this->conftab= new conferencetabs($this->config,$this->config->data['TABS']['CONFERENCETABS'], $this->dn);
192 unset($_SESSION['objectinfo']);
193 }
196 /***************
197 Save entry
198 ***************/
200 /* Edit finished, check and save changes */
201 if ((isset($_POST['edit_finish'])) && (isset($this->conftab->config))){
202 /* Check tabs, will feed message array */
203 $this->conftab->last= $this->conftab->current;
204 $this->conftab->save_object();
205 $message= $this->conftab->check();
207 if (count($message) == 0){
208 if($this->conftab->save() == 1){
209 gosa_log ("goFonConference object '".$this->dn."' saving failed.");
210 return;
211 }
212 gosa_log ("goFonConference object '".$this->dn."' has been saved");
214 if ($this->dn != "new"){
215 del_lock ($this->dn);
216 }
218 $this->conftab->save ();
219 del_lock ($this->conftab->dn);;
220 unset ($this->conftab);
221 $this->conftab= NULL;
222 unset ($_SESSION['objectinfo']);
223 } else {
224 show_errors($message);
225 }
226 }
229 /***************
230 Display dialogs
231 ***************/
233 /* if edit or new, show dialog */
234 if(($this->conftab) && (isset($this->conftab->config))){
235 $display= $this->conftab->execute();
237 /* Don't show buttons if tab dialog requests this */
238 if (!$this->conftab->by_object[$this->conftab->current]->dialog){
239 $display.= "<p style=\"text-align:right\">\n";
240 $display.= "<input type=\"submit\" name=\"edit_finish\" value=\""._("Save")."\">\n";
241 $display.= " \n";
242 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
243 $display.= "</p>";
244 }
245 return ($display);
246 }
249 /***************
250 display divlist
251 ***************/
253 /* Return rendered main page */
254 /* Display dialog with system list */
255 $this->DivListConference->execute();
257 /* Add departments if subsearch is disabled */
258 if(!$this->DivListConference->SubSearch){
259 $this->DivListConference->AddDepartments($this->DivListConference->selectedBase,5);
260 }
261 $this->reload();
262 $this->DivListConference->setEntries($this->conferences);
263 return($this->DivListConference->Draw());
264 }
267 /* Reload entries for divlist.
268 * reload all conferences for the current base, with the given regex
269 */
270 function reload()
271 {
272 $Base = $this->DivListConference->selectedBase;
273 $SubSearch = $this->DivListConference->SubSearch;
274 $Regex = $this->DivListConference->Regex;
275 $Flags = GL_SIZELIMIT ;
276 $Filter = "(&(|(cn=".$Regex.")(description=".$Regex."))(objectClass=goFonConference))";
277 $Attrs = array("cn","goFonConferenceOwner","goFonPIN","telephoneNumber");
279 if($SubSearch){
280 $Flags |= GL_SUBSEARCH;
281 }
283 $this->conferences= get_list($Filter, $this->ui->subtreeACL, $Base, $Attrs, $Flags);
284 }
286 function remove_from_parent()
287 {
288 $cfg = new conference($this->config, $this->dn);
290 $cfg->remove_from_parent();
291 $ldap= $this->config->get_ldap_link();
292 $ldap->cd ($this->dn);
293 $ldap->recursive_remove();
295 /* Optionally execute a command after we're done */
296 $this->postremove();
298 /* Delete references to object groups */
299 $ldap->cd ($this->config->current['BASE']);
300 $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
301 while ($ldap->fetch()){
302 $og= new conftab($this->config, $ldap->getDN());
303 unset($og->member[$this->dn]);
304 $og->save ();
305 }
307 }
309 function save_object()
310 {
311 $this->DivListConference->save_object();
312 }
314 function remove_lock()
315 {
316 if (isset($this->dn)){
317 del_lock ($this->dn);
318 }
319 }
321 }
322 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
323 ?>