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 $ou = "";
28 var $goFonPIN = "";
29 var $old_cn = "";
31 var $goFonConferenceOption = "";
32 var $goFonConferenceOption_P = ""; // Set PIN
33 var $goFonConferenceOption_r = ""; // record Conference
34 var $goFonConferenceOption_M = ""; // Play Music opn hold
35 var $goFonConferenceOption_s = ""; // activate menu
36 var $goFonConferenceOption_i = ""; // announce new and leaving user
37 var $goFonConferenceOption_c = ""; // Count User
38 var $goFonConferenceOption_D = ""; // Conference Type, no PIN/PIN
40 var $goFonConferenceOwner = "";
41 var $goFonHomeServer = "0"; // Home server of the conference
42 var $init_HomeServer = "0"; // Initial home server of the conference
43 var $goFonHomeServers = array(); // All available home servers
45 var $goFonConferenceOptionFormat = "";
46 var $goFonConferenceOptionLifetime = "";
47 var $telephoneNumber = "";
49 var $old_tele_number = false;
50 var $old_dn;
52 /* Headpage attributes */
53 var $last_dep_sorting= "invalid";
54 var $departments= array();
55 var $view_logged = FALSE;
56 var $dialog ;
58 /* attribute list for save action */
59 var $attributes= array("cn","base", "description", "goFonPIN","goFonConferenceOption_P","goFonConferenceOption_r","goFonHomeServer",
60 "goFonConferenceOption_M","goFonConferenceOption_s","goFonConferenceOption_i","goFonConferenceOption_c","goFonHomeServer",
61 "goFonConferenceOption_D","goFonConferenceOptionFormat","goFonConferenceOptionLifetime","telephoneNumber","goFonConferenceOwner");
63 var $objectclasses= array("top", "goFonConference");
65 function conference ($config, $dn, $plugin= NULL)
66 {
67 plugin::plugin($config, $dn, $plugin);
68 $this->is_account = TRUE;
69 $this->ui = get_userinfo();
70 $this->orig_dn = $dn;
73 /* Check server configurations
74 * Load all server configuration in $this->goFonHomeServers if available
75 * and use first server as default if necessary.
76 */
77 $a_SETUP= array();
78 if(array_key_exists('config',$_SESSION) &&
79 array_key_exists('SERVERS',$_SESSION['config']->data) &&
80 array_key_exists('FON',$_SESSION['config']->data['SERVERS']) &&
81 count($_SESSION['config']->data['SERVERS']['FON']) &&
82 is_callable("mysql_connect")
83 ) {
85 /* Set available server */
86 $this->goFonHomeServers = $_SESSION['config']->data['SERVERS']['FON'];
88 /* Set default server */
89 if($this->dn == "new"){
90 $this->goFonHomeServer = $this->goFonHomeServers[0]['DN'];
91 }
93 /* Remember inital home server, to be able to remove old entries */
94 $this->init_HomeServer = $this->goFonHomeServer;
96 /* get config */
97 if(!isset($this->goFonHomeServers[$this->goFonHomeServer])){
98 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']));
100 $this->goFonHomeServer = $this->goFonHomeServers[0]['DN'];
101 $this->init_HomeServer = $this->goFonHomeServers[0]['DN'];
102 }
103 $cur_cfg = $this->goFonHomeServers[$this->goFonHomeServer];
104 }
106 /* Set base */
107 if ($this->dn == "new"){
108 $ui= get_userinfo();
109 if(isset($_SESSION['CurrentMainBase'])){
110 $this->base = $_SESSION['CurrentMainBase'];
111 }else{
112 $this->base= dn2base($ui->dn);
113 }
114 } else {
116 /* The base is something like this
117 "cn=Confis,ou=conferences,ou=asterisk,ou=configs,ou=systems," */
118 $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,/", "", $this->dn);
119 }
121 $this->goFonConferenceOwner=$this->ui->dn;
123 /* Parse Options ...
124 * Parameter|Lifetime|number
125 */
126 if($this->dn!="new"){
127 $tmp1= split("\|",$this->attrs['goFonConferenceOption'][0]);
129 for($i = 0 ; $i < strlen($tmp1[0]);$i++){
130 $varname = "goFonConferenceOption_".$tmp1[0][$i];
131 if($tmp1[0][$i]=="d"){
132 $this->goFonConferenceOption_D = $tmp1[0][$i];
133 }else{
134 $this->$varname = $tmp1[0][$i];
135 }
136 }
138 $this->goFonConferenceOptionLifetime = $tmp1[1];
139 $this->old_tele_number = $this->telephoneNumber;
140 }
141 $this->old_dn = $this->dn;
142 $this->old_cn = $this->cn;
143 }
146 function execute()
147 {
148 /* Call parent execute */
149 plugin::execute();
151 /* Log last action */
152 if($this->is_account && !$this->view_logged){
153 $this->view_logged = TRUE;
154 new log("view","gofonconference/".get_class($this),$this->dn);
155 }
157 $smarty= get_smarty();
159 $smarty->assign("bases" ,$this->config->idepartments);
160 $smarty->assign("base" ,$this->base);
162 $once = true;
163 foreach($_POST as $name => $value){
164 if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_writeable("base")){
165 $once = false;
166 $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
167 $this->dialog->setCurrentBase($this->base);
168 }
169 }
171 /* Dialog handling */
172 if(is_object($this->dialog)){
173 /* Must be called before save_object */
174 $this->dialog->save_object();
176 if($this->dialog->isClosed()){
177 $this->dialog = false;
178 }elseif($this->dialog->isSelected()){
179 $tmp = $this->get_allowed_bases();
180 if(isset($tmp[$this->dialog->isSelected()])){
181 $this->base = $this->dialog->isSelected();
182 }
183 $this->dialog= false;
184 }else{
185 return($this->dialog->execute());
186 }
187 }
189 foreach ($this->attributes as $val){
190 $smarty->assign("$val", $this->$val);
191 if(!$this->$val){
192 $smarty->assign($val."CHK", "");
193 }else{
194 $smarty->assign($val."CHK", " checked ");
195 }
196 }
198 /* Create array with goFonHomeServer */
199 $tmp = array();
200 foreach($this->goFonHomeServers as $dn => $val){
201 if(!is_numeric($dn)){
202 $tmp[$dn] = $val['SERVER'];
203 }
204 }
205 $smarty->assign("goFonHomeServers",$tmp);
206 $smarty->assign("goFonConferenceOptions", array("D"=>"Conference ","d"=>"Conference without PIN"));
207 $smarty->assign("goFonConferenceOptionFormats", array("WAV"=>"Wave","GSM"=>"GSM","WAV49"=>"Wave49"));
208 $smarty->assign("goFonConferenceOption", $this->goFonConferenceOption_D);
210 $tmp = $this->plInfo();
211 foreach($tmp['plProvidedAcls'] as $name => $translation){
212 $smarty->assign($name."ACL",$this->getacl($name));
213 }
215 if($this->acl_is_writeable("base")){
216 $smarty->assign("baseSelect",true);
217 }else{
218 $smarty->assign("baseSelect",false);
219 }
221 $smarty->assign("bases" ,$this->get_allowed_bases());
222 $smarty->assign("base_select" ,$this->base);
225 if($_SESSION['js']==1){
226 if($this->goFonConferenceOption_P != "P"){
227 $smarty->assign("goFonPINACL", $this->getacl("goFonPIN",TRUE));
228 $smarty->assign("goFonPIN","");
229 }
230 if($this->goFonConferenceOption_r != "r"){
231 $smarty->assign("goFonConferenceOptionFormatACL", $this->getacl("goFonConferenceOptionr",TRUE));
232 }
233 }
234 return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
235 }
238 function remove_from_parent()
239 {
240 /* Check if 'old' home server is available in gosa FON server configuration
241 * Try to remove this entry from database and display errors.
242 */
243 if(isset($this->goFonHomeServers[$this->goFonHomeServer])){
244 $str = $this->SQL_remove_me(true);
245 if($str){
246 print_red($str);
247 return false;
248 }
249 }else{
250 print_red(_("Could not remove the conference entry from database on home server (%s). Please check your asterisk database configuration."));
251 return false;
252 }
254 /* Remove ldap entry */
255 $ldap= $this->config->get_ldap_link();
256 $ldap->cd ($this->dn);
257 $ldap->recursive_remove();
259 new log("remove","gofonconference/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
261 /* Optionally execute a command after we're done */
262 $this->handle_post_events('remove');
263 }
266 /* Save data to object */
267 function save_object()
268 {
269 if(isset($_POST['phoneConferenceGeneric'])){
271 /* Create a base backup and reset the
272 base directly after calling plugin::save_object();
273 Base will be set seperatly a few lines below */
274 $base_tmp = $this->base;
275 plugin::save_object();
276 $this->base = $base_tmp;
278 /* Save base, since this is no LDAP attribute */
279 $tmp = $this->get_allowed_bases();
280 if(isset($_POST['base'])){
281 if(isset($tmp[$_POST['base']])){
282 $this->base= $_POST['base'];
283 }
284 }
285 foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s",
286 "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D") as $attrs){
288 /* Acl can't contain _ so we remove it here. */
289 $acl_name = preg_replace("/_/","",$attrs);
291 if($this->acl_is_writeable($acl_name)){
293 if(isset($_POST[$attrs])){
294 $this->$attrs = $_POST[$attrs];
295 }else{
296 $this->$attrs = false;
297 }
298 }
299 }
300 }
301 }
304 function check_database_accessibility()
305 {
306 /* Check if mysql extension is available */
307 if(!is_callable("mysql_pconnect")){
308 return(_("Can't save any changes to asterisk database, there is currently no mysql extension available in your php setup."));
309 }
311 /********************
312 * Check currently selected home server
313 ********************/
315 $cfg_Current = $this->goFonHomeServers[$this->goFonHomeServer];
316 $r_current = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']);
317 if(!$r_current){
318 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_current));
320 return(sprintf(_("The MySQL home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
321 $cfg_Current['SERVER'],$cfg_Current['LOGIN']));
322 }
323 $db_current = @mysql_select_db($cfg_Current['DB'],$r_current);
324 if(!$db_current){
325 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_current));
326 mysql_close($r_current);
327 return( sprintf(_("Can't select database '%s' on home server '%s'."),$cfg_Current['DB'],$cfg_Current['SERVER']));
328 }
330 /********************
331 * Check init home server
332 ********************/
334 if($this->goFonHomeServers != $this->init_HomeServer){
335 $cfg_Init = $this->goFonHomeServers[$this->init_HomeServer] ;
336 $r_init = @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']);
337 if(!$r_init){
338 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init));
340 return(sprintf(_("The MySQL initial home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
341 $cfg_Init['SERVER'],$cfg_Init['LOGIN']));
342 }
343 $db_init = @mysql_select_db($cfg_Init['DB'],$r_init);
344 if(!$db_init){
345 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init));
346 mysql_close($r_init);
347 return( sprintf(_("Can't select database '%s' on initial home server '%s'."),$cfg_Init['DB'],$cfg_Init['SERVER']));
348 }
349 }
350 }
352 /* Check values */
353 function check()
354 {
355 /* Call common method to give check the hook */
356 $message= plugin::check();
358 if($this->is_number_used()){
359 $message[] = $this->is_number_used();
360 }
362 /* Check if previously selected server is still available */
363 if($this->initially_was_account && !isset($this->goFonHomeServers[$this->goFonHomeServer])){
364 $message[]= sprintf(_("The previously selected asterisk home server (%s) is no longer available."),preg_replace("/,/",", ",$this->goFonHomeServer));
365 return($message);
366 }
368 if((empty($this->goFonPIN))&&($this->goFonConferenceOption_P=="P")&&($this->goFonConferenceOption_D=="D")){
369 $message[]= _("Please enter a PIN.");
370 }
372 if(empty($this->cn)){
373 $message[] =_("Please enter a name for the conference.");
374 }
376 if(!is_numeric($this->telephoneNumber)){
377 $message[] =_("Only numeric chars are allowed in Number field.");
378 }
380 if(!((is_numeric($this->goFonConferenceOptionLifetime))||(empty($this->goFonConferenceOptionLifetime)))){
381 $message[] =_("Only numbers are allowed in Lifetime.");
382 }
384 /* Check if add could be successful */
385 $str = $this->SQL_add_me(false);
386 if(!empty($str)){
387 $message[] = $str;
388 }
390 return $message;
391 }
394 function SQL_add_me($save)
395 {
396 /* Check if there is at least on server configuration */
397 if(!count($this->goFonHomeServers)){
398 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."));
399 }
401 /********************
402 * Get configuration and try to connect
403 ********************/
405 /* Check if databases are reachable, returns an error string if anything fails */
406 $error_str = $this->check_database_accessibility();
407 if($error_str){
408 return($error_str);
409 }
411 /* Remove old entries, returns an error string if anything fails */
412 $error_str = $this->SQL_remove_me($save);
413 if($error_str){
414 return($error_str);
415 }
417 /* Connect to current database to be able to add new entries */
418 $cfg_Current = $this->goFonHomeServers[$this->goFonHomeServer] ;
419 $res_cur = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']);
420 $db_cur = @mysql_select_db($cfg_Current['DB'],$res_cur);
422 /********************
423 * Remove entries that could cause trouble
424 ********************/
426 /* If the current home server is different to the initial home server,
427 * there may be already some entries with the given telephoneNumber and/or cn.
428 * We must remove those entries to avoid duplicate use of the same extension name.
429 */
430 if($this->goFonHomeServer != $this->init_HomeServer){
431 $query = "SELECT id FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$this->telephoneNumber."' OR '".$this->cn."';";
432 $res = @mysql_query($query,$res_cur);
433 if(!$res){
434 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($res_cur));
435 return(_("Can not check if there are already some entries with given telephone number and/or cn in the destination home server.").
436 " "._("Please have a look a the gosa logfiles."));
437 }
438 if($save && mysql_affected_rows($res_cur)) {
439 $SQL = "DELETE FROM ".$cfg_Current['EXT_TABLE']."
440 WHERE (exten='".$this->telephoneNumber."')
441 OR (exten='".$this->cn."')";
443 /* Query and ensure that everything went fine */
444 $res = @mysql_query($SQL,$res_cur);
445 if(!$res){
446 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($res_cur));
447 return(_("Can not remove entries with some telephone number and/or cn from destination home server.").
448 " "._("Please have a look a the gosa logfiles."));
449 }
450 }
451 }
453 /********************
454 * Add new conference entry
455 ********************/
456 if((!empty($this->telephoneNumber))&&($save==true)){
458 /* Create string out of conference Flags */
459 $parameter ="";
460 foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s",
461 "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D") as $attrs){
462 $parameter .= $this->$attrs;
463 }
465 $i=1;
466 $EXT=array();
467 $context="GOsa";
468 // Set Language to German
469 $EXT[$i]['exten'] =$this->telephoneNumber;
470 $EXT[$i]['context'] = $context;
471 $EXT[$i]['priority']= $i;
472 $EXT[$i]['app'] ="SetLanguage";
473 $EXT[$i]['appdata'] ="de";
474 $i++;
476 if($this->goFonConferenceOption_r == "r"){
478 // Recordingformat for conference
479 $EXT[$i]['exten'] =$this->telephoneNumber;
480 $EXT[$i]['context'] =$context;
481 $EXT[$i]['priority']= $i;
482 $EXT[$i]['app'] ="Setvar";
483 $EXT[$i]['appdata'] ="MEETME_RECORDINGFORMAT=".$this->goFonConferenceOptionFormat;
484 $i++;
486 }
488 // Answer Call
489 $EXT[$i]['exten'] =$this->telephoneNumber;
490 $EXT[$i]['context'] =$context;
491 $EXT[$i]['priority']=$i;
492 $EXT[$i]['app'] ="answer";
493 $EXT[$i]['appdata'] ="";
494 $i++;
496 // Start Conference
497 $EXT[$i]['exten'] =$this->telephoneNumber;
498 $EXT[$i]['context'] =$context;
499 $EXT[$i]['priority']=$i;
500 $EXT[$i]['app'] ="MeetMe";
502 if(empty($this->goFonPIN)) {
503 $EXT[$i]['appdata'] =$this->telephoneNumber."|".$parameter;
504 }else{
505 $EXT[$i]['appdata'] =$this->telephoneNumber."|".$parameter."|".$this->goFonPIN;
506 }
507 $i++;
509 // Start Conference
510 $EXT[$i]['exten'] =$this->cn;
511 $EXT[$i]['context'] =$context;
512 $EXT[$i]['priority']=1;
513 $EXT[$i]['app'] ="Goto";
514 $EXT[$i]['appdata'] =$this->telephoneNumber."|1";
515 $SQL=array();
517 foreach($EXT as $keytop => $valtop){
518 $s_keys = "";
519 $s_values = "";
520 foreach($valtop as $key=>$val){
521 $s_keys .="`".$key."`,";
522 $s_values .="'".$val."',";
523 }
524 $s_keys =preg_replace("/\,$/","",$s_keys);
525 $s_values =preg_replace("/\,$/","",$s_values);
526 $SQL[]="INSERT INTO ".$cfg_Current['EXT_TABLE']." (".$s_keys.") VALUES (".$s_values.");";
527 }
528 foreach($SQL as $sqlsyn){
529 mysql_query($sqlsyn,$res_cur);
530 }
531 }
533 @mysql_close($res_cur);
534 }
537 /* Remove initial entry from database
538 * This function checks if there is an entry in the
539 * initial home server that uses this->old_cn or $this->old_tele_number
540 * and removes this entries.
541 * This function is called from save and remove_from parent.
542 *
543 * The parameter '$save' is false if we just
544 * want to check if a remove is possible.
545 * And true if we realy want to remove the entries.
546 */
547 function SQL_remove_me($save)
548 {
549 /* check database access */
550 $str = $this->check_database_accessibility();
551 if($str){
552 return($str);
553 }
555 /* Connect to old database */
556 $cfg_Init = $this->goFonHomeServers[$this->init_HomeServer] ;
557 $r_init = @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']);
558 $db_init = @mysql_select_db($cfg_Init['DB'],$r_init);
560 /* Check if there is an old entry */
561 $query = "SELECT id FROM ".$cfg_Init['EXT_TABLE']." WHERE exten='".$this->old_tele_number."' OR '".$this->old_cn."';";
562 $res = @mysql_query($query,$r_init);
563 if(!$res){
564 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init));
565 return(_("Can not check if entry exists in old database. Please have a look a the gosa logfiles."));
566 }
568 /* There are entries using this cn and/or phone number */
569 if($save && mysql_affected_rows($r_init)) {
570 $SQL = "DELETE FROM ".$cfg_Init['EXT_TABLE']."
571 WHERE (exten='".$this->old_tele_number."')
572 OR (exten='".$this->old_cn."')";
574 /* Query and ensure that everything went fine */
575 $res = @mysql_query($SQL,$r_init);
576 if(!$res){
577 new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($r_init));
578 return(_("Can not remove old entries from initial home server. Please have a look a the gosa logfiles."));
579 }
581 }//ENDE old num availiable ...
582 @mysql_close($r_init);
583 return(false);
584 }
588 /* This function checks if the given phonenumbers are available or already in use*/
589 function is_number_used()
590 {
591 $ldap= $this->config->get_ldap_link();
592 $ldap->cd($this->config->current['BASE']);
593 $ldap->search("(|(objectClass=goFonAccount)(objectClass=goFonQueue)(objectClass=goFonConference))", array("telephoneNumber","cn","uid"));
594 while($attrs = $ldap->fetch()) {
595 unset($attrs['telephoneNumber']['count']);
596 foreach($attrs['telephoneNumber'] as $tele){
597 if(!isset($attrs['cn'][0])) $attrs['cn'][0]=$attrs['dn'];
598 if(!isset($attrs['uid'][0])) $attrs['uid'][0]=$attrs['dn'];
599 $numbers[$tele]=$attrs;
600 }
601 }
603 $num = $this->telephoneNumber;
604 if((isset($numbers[$num]))&&(($numbers[$num]['cn'][0]!=$this->old_cn))){
605 if(isset($numbers[$num]['uid'][0])){
606 return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['uid'][0]);
607 }else{
608 return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['cn'][0]);
609 }
610 }
611 }
614 /* Save to LDAP */
615 function save()
616 {
618 if((!isset($this->attrs['goFonPIN']))){
619 $pin_use = false;
620 }else{
621 $pin_use = true;
622 }
624 /* Unset PIN if this is a conference without PIN */
625 if((!empty($this->goFonPIN)||($this->goFonConferenceOption_P=="P"))&&($this->goFonConferenceOption_D=="d")){
626 $this->goFonPIN = "";
627 }
629 plugin::save();
631 if(empty($this->old_tele_number)){
632 $this->old_tele_number= $this->telephoneNumber;
633 }
635 $this->SQL_add_me(true);
637 if(empty($this->goFonConferenceOption_P)){
638 if($pin_use){
639 $this->attrs['goFonPIN']=array();
640 }else{
641 unset($this->attrs['goFonPIN']);
642 }
643 }
644 $this->attrs['goFonConferenceOption']="";
645 foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s",
646 "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D","goFonConferenceOptionFormat") as $attrs){
647 $this->attrs['goFonConferenceOption'] .= $this->$attrs;
648 unset($this->attrs[$attrs]);
649 }
651 $this->attrs['goFonConferenceOption'].="|".$this->goFonConferenceOptionLifetime;
652 unset($this->attrs['goFonConferenceOptionLifetime']);
654 /* Write back to ldap */
656 unset($this->attrs['base']);
658 $ldap= $this->config->get_ldap_link();
659 $ldap->cd($this->config->current['BASE']);
660 $ldap->cat($this->dn, array('dn'));
662 if ($ldap->count()){
663 $ldap->cd($this->dn);
664 $this->cleanup();
665 $ldap->modify ($this->attrs);
666 $this->handle_post_events('modify');
667 } else {
668 $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
669 $ldap->cd($this->dn);
670 $ldap->add($this->attrs);
671 $this->handle_post_events('add');
672 }
674 /* Log last action */
675 if($this->initially_was_account){
676 new log("modify","gofonconference/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
677 }else{
678 new log("create","gofonconference/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
679 }
681 show_ldap_error($ldap->get_error(), sprintf(_("Saving of goFonConference/generic with dn '%s' failed."),$this->dn));
683 /* Optionally execute a command after we're done */
684 $this->postcreate();
685 }
687 /* Return plugin informations for acl handling */
688 function plInfo()
689 {
690 return (array(
691 "plShortName" => _("Conference"),
692 "plDescription" => _("Phone conference management"),
693 "plSelfModify" => TRUE,
694 "plDepends" => array(),
695 "plPriority" => 0,
696 "plSection" => array("addons" => _("Addons")),
697 "plCategory" => array("gofonconference" => array("description" => _("GOfon conference"),
698 "objectClass" => "gofonConference")),
700 "plProvidedAcls" => array(
701 "cn" => _("Name"),
702 "base" => _("Base"),
703 "description" => _("Description"),
704 "goFonPIN" => _("Conference PIN"),
706 "goFonHomeServer" => _("Home server"),
707 "goFonConferenceOptionP" => _("Preset PIN"),
708 "goFonConferenceOptionr" => _("Record conference"),
709 "goFonConferenceOptionM" => _("Play music on hold"),
710 "goFonConferenceOptions" => _("Activate menu"),
711 "goFonConferenceOptioni" => _("Announce user activity"),
712 "goFonConferenceOptionc" => _("Count user"),
713 "goFonConferenceOptionD" => _("Conference type"),
715 "goFonConferenceOptionFormat" => _("Format"),
716 "goFonConferenceOptionLifetime" => _("Lifetime"),
717 "telephoneNumber" => _("Telephone number"),
718 "goFonConferenceOwner" => _("Owner"))
719 ));
720 }
723 }
725 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
726 ?>