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 */
21 class conference extends plugin
22 {
23 /* department attributes */
24 var $cn = "";
25 var $description = "";
26 var $base = "";
27 var $old_base = "";
28 var $ou = "";
29 var $goFonPIN = "";
30 var $old_cn = "";
32 var $goFonConferenceOption = "";
33 var $goFonConferenceOption_P = ""; // Set PIN
34 var $goFonConferenceOption_r = ""; // record Conference
35 var $goFonConferenceOption_M = ""; // Play Music opn hold
36 var $goFonConferenceOption_s = ""; // activate menu
37 var $goFonConferenceOption_i = ""; // announce new and leaving user
38 var $goFonConferenceOption_c = ""; // Count User
39 var $goFonConferenceOption_D = ""; // Conference Type, no PIN/PIN
41 var $goFonConferenceOwner = "";
42 var $goFonHomeServer = "0"; // Home server of the conference
43 var $init_HomeServer = "0"; // Initial home server of the conference
44 var $goFonHomeServers = array(); // All available home servers
46 var $goFonConferenceOptionFormat = "";
47 var $goFonConferenceOptionLifetime = "";
48 var $telephoneNumber = "";
50 var $old_tele_number = false;
51 var $old_dn;
53 /* Headpage attributes */
54 var $last_dep_sorting= "invalid";
55 var $departments= array();
56 var $view_logged = FALSE;
57 var $dialog ;
59 /* attribute list for save action */
60 var $attributes= array("cn","base", "description", "goFonPIN","goFonConferenceOption_P","goFonConferenceOption_r","goFonHomeServer",
61 "goFonConferenceOption_M","goFonConferenceOption_s","goFonConferenceOption_i","goFonConferenceOption_c","goFonHomeServer",
62 "goFonConferenceOption_D","goFonConferenceOptionFormat","goFonConferenceOptionLifetime","telephoneNumber","goFonConferenceOwner");
64 var $objectclasses= array("top", "goFonConference");
66 function conference ($config, $dn, $plugin= NULL)
67 {
68 plugin::plugin($config, $dn, $plugin);
69 $this->is_account = TRUE;
70 $this->ui = get_userinfo();
71 $this->orig_dn = $dn;
74 /* Check server configurations
75 * Load all server configuration in $this->goFonHomeServers if available
76 * and use first server as default if necessary.
77 */
78 $a_SETUP= array();
79 if(array_key_exists('config',$_SESSION) &&
80 array_key_exists('SERVERS',$_SESSION['config']->data) &&
81 array_key_exists('FON',$_SESSION['config']->data['SERVERS']) &&
82 count($_SESSION['config']->data['SERVERS']['FON']) &&
83 is_callable("mysql_connect")
84 ) {
86 /* Set available server */
87 $this->goFonHomeServers = $_SESSION['config']->data['SERVERS']['FON'];
89 /* Set default server */
90 if($this->dn == "new"){
91 $this->goFonHomeServer = $this->goFonHomeServers[0]['DN'];
92 }
94 /* Remember inital home server, to be able to remove old entries */
95 $this->init_HomeServer = $this->goFonHomeServer;
97 /* get config */
98 if(!isset($this->goFonHomeServers[$this->goFonHomeServer])){
99 print_red(sprintf(_("The specified home server '%s' is not available in GOsa server configuration. Saving this account will create a new entry on the server '%s'. Use cancel if you do not want to create a new entry while ignoring old accounts."),$this->goFonHomeServer, $this->goFonHomeServers[0]['DN']));
101 $this->goFonHomeServer = $this->goFonHomeServers[0]['DN'];
102 $this->init_HomeServer = $this->goFonHomeServers[0]['DN'];
103 }
104 $cur_cfg = $this->goFonHomeServers[$this->goFonHomeServer];
105 }
107 /* Set base */
108 if ($this->dn == "new"){
109 $ui= get_userinfo();
110 if(isset($_SESSION['CurrentMainBase'])){
111 $this->base = $_SESSION['CurrentMainBase'];
112 }else{
113 $this->base= dn2base($ui->dn);
114 }
115 } else {
117 /* The base is something like this
118 "cn=Confis,ou=conferences,ou=asterisk,ou=configs,ou=systems," */
119 $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,/", "", $this->dn);
120 }
122 $this->goFonConferenceOwner=$this->ui->dn;
124 /* Parse Options ...
125 * Parameter|Lifetime|number
126 */
127 if($this->dn!="new"){
128 $tmp1= split("\|",$this->attrs['goFonConferenceOption'][0]);
130 for($i = 0 ; $i < strlen($tmp1[0]);$i++){
131 $varname = "goFonConferenceOption_".$tmp1[0][$i];
132 if($tmp1[0][$i]=="d"){
133 $this->goFonConferenceOption_D = $tmp1[0][$i];
134 }else{
135 $this->$varname = $tmp1[0][$i];
136 }
137 }
139 $this->goFonConferenceOptionLifetime = $tmp1[1];
140 $this->old_tele_number = $this->telephoneNumber;
141 }
142 $this->old_dn = $this->dn;
143 $this->old_cn = $this->cn;
144 $this->old_base = $this->base;
145 }
148 function execute()
149 {
150 /* Call parent execute */
151 plugin::execute();
153 /* Log last action */
154 if($this->is_account && !$this->view_logged){
155 $this->view_logged = TRUE;
156 new log("view","gofonconference/".get_class($this),$this->dn);
157 }
159 $smarty= get_smarty();
161 $smarty->assign("bases" ,$this->config->idepartments);
162 $smarty->assign("base" ,$this->base);
164 $once = true;
165 foreach($_POST as $name => $value){
166 if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_writeable("base")){
167 $once = false;
168 $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
169 $this->dialog->setCurrentBase($this->base);
170 }
171 }
173 /* Dialog handling */
174 if(is_object($this->dialog)){
175 /* Must be called before save_object */
176 $this->dialog->save_object();
178 if($this->dialog->isClosed()){
179 $this->dialog = false;
180 }elseif($this->dialog->isSelected()){
181 $tmp = $this->get_allowed_bases();
182 if(isset($tmp[$this->dialog->isSelected()])){
183 $this->base = $this->dialog->isSelected();
184 }
185 $this->dialog= false;
186 }else{
187 return($this->dialog->execute());
188 }
189 }
191 foreach ($this->attributes as $val){
192 $smarty->assign("$val", $this->$val);
193 if(!$this->$val){
194 $smarty->assign($val."CHK", "");
195 }else{
196 $smarty->assign($val."CHK", " checked ");
197 }
198 }
200 /* Create array with goFonHomeServer */
201 $tmp = array();
202 foreach($this->goFonHomeServers as $dn => $val){
203 if(!is_numeric($dn)){
204 $tmp[$dn] = $val['SERVER'];
205 }
206 }
207 $smarty->assign("goFonHomeServers",$tmp);
208 $smarty->assign("goFonConferenceOptions", array("D"=>"Conference ","d"=>"Conference without PIN"));
209 $smarty->assign("goFonConferenceOptionFormats", array("WAV"=>"Wave","GSM"=>"GSM","WAV49"=>"Wave49"));
210 $smarty->assign("goFonConferenceOption", $this->goFonConferenceOption_D);
212 $tmp = $this->plInfo();
213 foreach($tmp['plProvidedAcls'] as $name => $translation){
214 $smarty->assign($name."ACL",$this->getacl($name));
215 }
217 if($this->acl_is_writeable("base")){
218 $smarty->assign("baseSelect",true);
219 }else{
220 $smarty->assign("baseSelect",false);
221 }
223 $smarty->assign("bases" ,$this->get_allowed_bases());
224 $smarty->assign("base_select" ,$this->base);
227 if($_SESSION['js']==1){
228 if($this->goFonConferenceOption_P != "P"){
229 $smarty->assign("goFonPINACL", $this->getacl("goFonPIN",TRUE));
230 $smarty->assign("goFonPIN","");
231 }
232 if($this->goFonConferenceOption_r != "r"){
233 $smarty->assign("goFonConferenceOptionFormatACL", $this->getacl("goFonConferenceOptionr",TRUE));
234 }
235 }
236 return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
237 }
240 function remove_from_parent()
241 {
242 /* Check if 'old' home server is available in gosa FON server configuration
243 * Try to remove this entry from database and display errors.
244 */
245 if(isset($this->goFonHomeServers[$this->goFonHomeServer])){
246 $str = $this->SQL_remove_me(true);
247 if($str){
248 print_red($str);
249 return false;
250 }
251 }else{
252 print_red(_("Could not remove the conference entry from database on home server (%s). Please check your asterisk database configuration."));
253 return false;
254 }
256 /* Remove ldap entry */
257 $ldap= $this->config->get_ldap_link();
258 $ldap->cd ($this->dn);
259 $ldap->recursive_remove();
261 new log("remove","gofonconference/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
263 /* Optionally execute a command after we're done */
264 $this->handle_post_events('remove');
265 }
268 /* Save data to object */
269 function save_object()
270 {
271 if(isset($_POST['phoneConferenceGeneric'])){
273 /* Create a base backup and reset the
274 base directly after calling plugin::save_object();
275 Base will be set seperatly a few lines below */
276 $base_tmp = $this->base;
277 plugin::save_object();
278 $this->base = $base_tmp;
280 /* Save base, since this is no LDAP attribute */
281 $tmp = $this->get_allowed_bases();
282 if(isset($_POST['base'])){
283 if(isset($tmp[$_POST['base']])){
284 $this->base= $_POST['base'];
285 }
286 }
287 foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s",
288 "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D") as $attrs){
290 /* Acl can't contain _ so we remove it here. */
291 $acl_name = preg_replace("/_/","",$attrs);
293 if($this->acl_is_writeable($acl_name)){
295 if(isset($_POST[$attrs])){
296 $this->$attrs = $_POST[$attrs];
297 }else{
298 $this->$attrs = false;
299 }
300 }
301 }
302 }
303 }
306 function check_database_accessibility()
307 {
308 /* Check if mysql extension is available */
309 if(!is_callable("mysql_pconnect")){
310 return(_("Can't save any changes to asterisk database, there is currently no mysql extension available in your php setup."));
311 }
313 /********************
314 * Check currently selected home server
315 ********************/
317 $cfg_Current = $this->goFonHomeServers[$this->goFonHomeServer];
318 $r_current = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']);
319 if(!$r_current){
320 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_current));
322 return(sprintf(_("The MySQL home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
323 $cfg_Current['SERVER'],$cfg_Current['LOGIN']));
324 }
325 $db_current = @mysql_select_db($cfg_Current['DB'],$r_current);
326 if(!$db_current){
327 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_current));
328 mysql_close($r_current);
329 return( sprintf(_("Can't select database '%s' on home server '%s'."),$cfg_Current['DB'],$cfg_Current['SERVER']));
330 }
332 /********************
333 * Check init home server
334 ********************/
336 if($this->goFonHomeServers != $this->init_HomeServer){
337 $cfg_Init = $this->goFonHomeServers[$this->init_HomeServer] ;
338 $r_init = @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']);
339 if(!$r_init){
340 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init));
342 return(sprintf(_("The MySQL initial home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
343 $cfg_Init['SERVER'],$cfg_Init['LOGIN']));
344 }
345 $db_init = @mysql_select_db($cfg_Init['DB'],$r_init);
346 if(!$db_init){
347 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init));
348 mysql_close($r_init);
349 return( sprintf(_("Can't select database '%s' on initial home server '%s'."),$cfg_Init['DB'],$cfg_Init['SERVER']));
350 }
351 }
352 }
354 /* Check values */
355 function check()
356 {
357 /* Call common method to give check the hook */
358 $message= plugin::check();
360 if($this->is_number_used()){
361 $message[] = $this->is_number_used();
362 }
364 /* Check if previously selected server is still available */
365 if($this->initially_was_account && !isset($this->goFonHomeServers[$this->goFonHomeServer])){
366 $message[]= sprintf(_("The previously selected asterisk home server (%s) is no longer available."),preg_replace("/,/",", ",$this->goFonHomeServer));
367 return($message);
368 }
370 if((empty($this->goFonPIN))&&($this->goFonConferenceOption_P=="P")&&($this->goFonConferenceOption_D=="D")){
371 $message[]= _("Please enter a PIN.");
372 }
374 if(empty($this->cn)){
375 $message[] =_("Please enter a name for the conference.");
376 }
378 if(!is_numeric($this->telephoneNumber)){
379 $message[] =_("Only numeric chars are allowed in Number field.");
380 }
382 if(!((is_numeric($this->goFonConferenceOptionLifetime))||(empty($this->goFonConferenceOptionLifetime)))){
383 $message[] =_("Only numbers are allowed in Lifetime.");
384 }
386 /* Check if add could be successful */
387 $str = $this->SQL_add_me(false);
388 if(!empty($str)){
389 $message[] = $str;
390 }
392 if($this->old_cn != $this->cn || $this->base != $this->old_base){
393 $ldap = $this->config->get_ldap_link();
394 $ldap->cd("ou=conferences,ou=asterisk,ou=configs,ou=systems,".$this->base);
395 $ldap->search("(&(objectClass=goFonConference)(cn=".$this->cn."))",array("cn"));
396 if($ldap->count()){
397 $message[] =_("There is already a conference with this name in the current tree.");
398 }
399 }
400 return $message;
401 }
404 function SQL_add_me($save)
405 {
406 /* Check if there is at least on server configuration */
407 if(!count($this->goFonHomeServers)){
408 return( _("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database."));
409 }
411 /********************
412 * Get configuration and try to connect
413 ********************/
415 /* Check if databases are reachable, returns an error string if anything fails */
416 $error_str = $this->check_database_accessibility();
417 if($error_str){
418 return($error_str);
419 }
421 /* Remove old entries, returns an error string if anything fails */
422 $error_str = $this->SQL_remove_me($save);
423 if($error_str){
424 return($error_str);
425 }
427 /* Connect to current database to be able to add new entries */
428 $cfg_Current = $this->goFonHomeServers[$this->goFonHomeServer] ;
429 $res_cur = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']);
430 $db_cur = @mysql_select_db($cfg_Current['DB'],$res_cur);
432 /********************
433 * Remove entries that could cause trouble
434 ********************/
436 /* If the current home server is different to the initial home server,
437 * there may be already some entries with the given telephoneNumber and/or cn.
438 * We must remove those entries to avoid duplicate use of the same extension name.
439 */
440 if($this->goFonHomeServer != $this->init_HomeServer){
441 $query = "SELECT id FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$this->telephoneNumber."' OR '".$this->cn."';";
442 $res = @mysql_query($query,$res_cur);
443 if(!$res){
444 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($res_cur));
445 return(_("Can not check if there are already some entries with given telephone number and/or cn in the destination home server.").
446 " "._("Please have a look a the gosa logfiles."));
447 }
448 if($save && mysql_affected_rows($res_cur)) {
449 $SQL = "DELETE FROM ".$cfg_Current['EXT_TABLE']."
450 WHERE (exten='".$this->telephoneNumber."')
451 OR (exten='".$this->cn."')";
453 /* Query and ensure that everything went fine */
454 $res = @mysql_query($SQL,$res_cur);
455 if(!$res){
456 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($res_cur));
457 return(_("Can not remove entries with some telephone number and/or cn from destination home server.").
458 " "._("Please have a look a the gosa logfiles."));
459 }
460 }
461 }
463 /********************
464 * Add new conference entry
465 ********************/
466 if((!empty($this->telephoneNumber))&&($save==true)){
468 /* Create string out of conference Flags */
469 $parameter ="";
470 foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s",
471 "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D") as $attrs){
472 $parameter .= $this->$attrs;
473 }
475 $i=1;
476 $EXT=array();
477 $context="GOsa";
478 // Set Language to German
479 $EXT[$i]['exten'] =$this->telephoneNumber;
480 $EXT[$i]['context'] = $context;
481 $EXT[$i]['priority']= $i;
482 $EXT[$i]['app'] ="SetLanguage";
483 $EXT[$i]['appdata'] ="de";
484 $i++;
486 if($this->goFonConferenceOption_r == "r"){
488 // Recordingformat for conference
489 $EXT[$i]['exten'] =$this->telephoneNumber;
490 $EXT[$i]['context'] =$context;
491 $EXT[$i]['priority']= $i;
492 $EXT[$i]['app'] ="Setvar";
493 $EXT[$i]['appdata'] ="MEETME_RECORDINGFORMAT=".$this->goFonConferenceOptionFormat;
494 $i++;
496 }
498 // Answer Call
499 $EXT[$i]['exten'] =$this->telephoneNumber;
500 $EXT[$i]['context'] =$context;
501 $EXT[$i]['priority']=$i;
502 $EXT[$i]['app'] ="answer";
503 $EXT[$i]['appdata'] ="";
504 $i++;
506 // Start Conference
507 $EXT[$i]['exten'] =$this->telephoneNumber;
508 $EXT[$i]['context'] =$context;
509 $EXT[$i]['priority']=$i;
510 $EXT[$i]['app'] ="MeetMe";
512 if(empty($this->goFonPIN)) {
513 $EXT[$i]['appdata'] =$this->telephoneNumber."|".$parameter;
514 }else{
515 $EXT[$i]['appdata'] =$this->telephoneNumber."|".$parameter."|".$this->goFonPIN;
516 }
517 $i++;
519 // Start Conference
520 $EXT[$i]['exten'] =$this->cn;
521 $EXT[$i]['context'] =$context;
522 $EXT[$i]['priority']=1;
523 $EXT[$i]['app'] ="Goto";
524 $EXT[$i]['appdata'] =$this->telephoneNumber."|1";
525 $SQL=array();
527 foreach($EXT as $keytop => $valtop){
528 $s_keys = "";
529 $s_values = "";
530 foreach($valtop as $key=>$val){
531 $s_keys .="`".$key."`,";
532 $s_values .="'".$val."',";
533 }
534 $s_keys =preg_replace("/\,$/","",$s_keys);
535 $s_values =preg_replace("/\,$/","",$s_values);
536 $SQL[]="INSERT INTO ".$cfg_Current['EXT_TABLE']." (".$s_keys.") VALUES (".$s_values.");";
537 }
538 foreach($SQL as $sqlsyn){
539 mysql_query($sqlsyn,$res_cur);
540 }
541 }
543 @mysql_close($res_cur);
544 }
547 /* Remove initial entry from database
548 * This function checks if there is an entry in the
549 * initial home server that uses this->old_cn or $this->old_tele_number
550 * and removes this entries.
551 * This function is called from save and remove_from parent.
552 *
553 * The parameter '$save' is false if we just
554 * want to check if a remove is possible.
555 * And true if we realy want to remove the entries.
556 */
557 function SQL_remove_me($save)
558 {
559 /* check database access */
560 $str = $this->check_database_accessibility();
561 if($str){
562 return($str);
563 }
565 /* Connect to old database */
566 $cfg_Init = $this->goFonHomeServers[$this->init_HomeServer] ;
567 $r_init = @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']);
568 $db_init = @mysql_select_db($cfg_Init['DB'],$r_init);
570 /* Check if there is an old entry */
571 $query = "SELECT id FROM ".$cfg_Init['EXT_TABLE']." WHERE exten='".$this->old_tele_number."' OR '".$this->old_cn."';";
572 $res = @mysql_query($query,$r_init);
573 if(!$res){
574 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init));
575 return(_("Can not check if entry exists in old database. Please have a look a the gosa logfiles."));
576 }
578 /* There are entries using this cn and/or phone number */
579 if($save && mysql_affected_rows($r_init)) {
580 $SQL = "DELETE FROM ".$cfg_Init['EXT_TABLE']."
581 WHERE (exten='".$this->old_tele_number."')
582 OR (exten='".$this->old_cn."')";
584 /* Query and ensure that everything went fine */
585 $res = @mysql_query($SQL,$r_init);
586 if(!$res){
587 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init));
588 return(_("Can not remove old entries from initial home server. Please have a look a the gosa logfiles."));
589 }
591 }//ENDE old num availiable ...
592 @mysql_close($r_init);
593 return(false);
594 }
598 /* This function checks if the given phonenumbers are available or already in use*/
599 function is_number_used()
600 {
601 $ldap= $this->config->get_ldap_link();
602 $ldap->cd($this->config->current['BASE']);
603 $ldap->search("(|(objectClass=goFonAccount)(objectClass=goFonQueue)(objectClass=goFonConference))", array("telephoneNumber","cn","uid"));
604 while($attrs = $ldap->fetch()) {
605 unset($attrs['telephoneNumber']['count']);
606 foreach($attrs['telephoneNumber'] as $tele){
607 if(!isset($attrs['cn'][0])) $attrs['cn'][0]=$attrs['dn'];
608 if(!isset($attrs['uid'][0])) $attrs['uid'][0]=$attrs['dn'];
609 $numbers[$tele]=$attrs;
610 }
611 }
613 $num = $this->telephoneNumber;
614 if((isset($numbers[$num]))&&(($numbers[$num]['cn'][0]!=$this->old_cn))){
615 if(isset($numbers[$num]['uid'][0])){
616 return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['uid'][0]);
617 }else{
618 return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['cn'][0]);
619 }
620 }
621 }
624 /* Save to LDAP */
625 function save()
626 {
628 if((!isset($this->attrs['goFonPIN']))){
629 $pin_use = false;
630 }else{
631 $pin_use = true;
632 }
634 /* Unset PIN if this is a conference without PIN */
635 if((!empty($this->goFonPIN)||($this->goFonConferenceOption_P=="P"))&&($this->goFonConferenceOption_D=="d")){
636 $this->goFonPIN = "";
637 }
639 plugin::save();
641 if(empty($this->old_tele_number)){
642 $this->old_tele_number= $this->telephoneNumber;
643 }
645 $this->SQL_add_me(true);
647 if(empty($this->goFonConferenceOption_P)){
648 if($pin_use){
649 $this->attrs['goFonPIN']=array();
650 }else{
651 unset($this->attrs['goFonPIN']);
652 }
653 }
654 $this->attrs['goFonConferenceOption']="";
655 foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s",
656 "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D","goFonConferenceOptionFormat") as $attrs){
657 $this->attrs['goFonConferenceOption'] .= $this->$attrs;
658 unset($this->attrs[$attrs]);
659 }
661 $this->attrs['goFonConferenceOption'].="|".$this->goFonConferenceOptionLifetime;
662 unset($this->attrs['goFonConferenceOptionLifetime']);
664 /* Write back to ldap */
666 unset($this->attrs['base']);
668 $ldap= $this->config->get_ldap_link();
669 $ldap->cd($this->config->current['BASE']);
670 $ldap->cat($this->dn, array('dn'));
672 if ($ldap->count()){
673 $ldap->cd($this->dn);
674 $this->cleanup();
675 $ldap->modify ($this->attrs);
676 $this->handle_post_events('modify');
677 } else {
678 $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
679 $ldap->cd($this->dn);
680 $ldap->add($this->attrs);
681 $this->handle_post_events('add');
682 }
684 /* Log last action */
685 if($this->initially_was_account){
686 new log("modify","gofonconference/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
687 }else{
688 new log("create","gofonconference/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
689 }
691 show_ldap_error($ldap->get_error(), sprintf(_("Saving of goFonConference/generic with dn '%s' failed."),$this->dn));
693 /* Optionally execute a command after we're done */
694 $this->postcreate();
695 }
698 function getCopyDialog()
699 {
700 $smarty = get_smarty();
701 $smarty->assign("cn" ,$this->cn);
702 $smarty->assign("telephoneNumber" ,$this->telephoneNumber);
703 $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
704 $ret = array();
705 $ret['string'] = $str;
706 $ret['status'] = "";
707 return($ret);
708 }
711 function saveCopyDialog()
712 {
713 if(isset($_POST['cn'])){
714 $this->cn = $_POST['cn'];
715 }
716 if(isset($_POST['telephoneNumber'])){
717 $this->telephoneNumber = $_POST['telephoneNumber'];
718 }
719 }
721 function PrepareForCopyPaste($source)
722 {
723 plugin::PrepareForCopyPaste($source) ;
725 $source_o = new conference($this->config,$source['dn']);
727 foreach($this->attributes as $attr){
728 $this->$attr = $source_o->$attr;
729 }
730 }
733 /* Return plugin informations for acl handling */
734 function plInfo()
735 {
736 return (array(
737 "plShortName" => _("Conference"),
738 "plDescription" => _("Phone conference management"),
739 "plSelfModify" => TRUE,
740 "plDepends" => array(),
741 "plPriority" => 0,
742 "plSection" => array("addons" => _("Addons")),
743 "plCategory" => array("gofonconference" => array("description" => _("GOfon conference"),
744 "objectClass" => "gofonConference")),
746 "plProvidedAcls" => array(
747 "cn" => _("Name"),
748 "base" => _("Base"),
749 "description" => _("Description"),
750 "goFonPIN" => _("Conference PIN"),
752 "goFonHomeServer" => _("Home server"),
753 "goFonConferenceOptionP" => _("Preset PIN"),
754 "goFonConferenceOptionr" => _("Record conference"),
755 "goFonConferenceOptionM" => _("Play music on hold"),
756 "goFonConferenceOptions" => _("Activate menu"),
757 "goFonConferenceOptioni" => _("Announce user activity"),
758 "goFonConferenceOptionc" => _("Count user"),
759 "goFonConferenceOptionD" => _("Conference type"),
761 "goFonConferenceOptionFormat" => _("Format"),
762 "goFonConferenceOptionLifetime" => _("Lifetime"),
763 "telephoneNumber" => _("Telephone number"),
764 "goFonConferenceOwner" => _("Owner"))
765 ));
766 }
769 }
771 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
772 ?>