Code

Fixed divlists
[gosa.git] / plugins / gofon / conference / class_phoneConferenceGeneric.inc
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;
72     
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       @log::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     @log::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       gosa_log(@mysql_error($r_current));
319       return(sprintf(_("The MySQL home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
320             $cfg_Current['SERVER'],$cfg_Current['LOGIN']));
321     }
322     $db_current  =  @mysql_select_db($cfg_Current['DB'],$r_current);
323     if(!$db_current){
324       gosa_log(@mysql_error($r_current));
325       mysql_close($r_current);
326       return( sprintf(_("Can't select database '%s' on home server '%s'."),$cfg_Current['DB'],$cfg_Current['SERVER']));
327     }
329     /********************
330      * Check init home server 
331      ********************/
333     if($this->goFonHomeServers != $this->init_HomeServer){
334       $cfg_Init  = $this->goFonHomeServers[$this->init_HomeServer] ;
335       $r_init    =  @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']);
336       if(!$r_init){
337         gosa_log(@mysql_error($r_init));
338         return(sprintf(_("The MySQL initial home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
339               $cfg_Init['SERVER'],$cfg_Init['LOGIN']));
340       }
341       $db_init  =  @mysql_select_db($cfg_Init['DB'],$r_init);
342       if(!$db_init){
343         gosa_log(@mysql_error($r_init));
344         mysql_close($r_init);
345         return( sprintf(_("Can't select database '%s' on initial home server '%s'."),$cfg_Init['DB'],$cfg_Init['SERVER']));
346       }
347     }
348   }
350   /* Check values */
351   function check()
352   {
353     /* Call common method to give check the hook */
354     $message= plugin::check();
356     if($this->is_number_used()){
357       $message[] =  $this->is_number_used();
358     }
360     /* Check if previously selected server is still available */
361     if($this->initially_was_account && !isset($this->goFonHomeServers[$this->goFonHomeServer])){
362       $message[]= sprintf(_("The previously selected asterisk home server (%s) is no longer available."),preg_replace("/,/",", ",$this->goFonHomeServer));
363       return($message);
364     }
366     if((empty($this->goFonPIN))&&($this->goFonConferenceOption_P=="P")&&($this->goFonConferenceOption_D=="D")){
367       $message[]= _("Please enter a PIN.");
368     }
370     if(empty($this->cn)){
371       $message[] =_("Please enter a name for the conference.");
372     }
374     if(!is_numeric($this->telephoneNumber)){
375       $message[] =_("Only numeric chars are allowed in Number field.");
376     }
378     if(!((is_numeric($this->goFonConferenceOptionLifetime))||(empty($this->goFonConferenceOptionLifetime)))){
379       $message[] =_("Only numbers are allowed in Lifetime.");
380     }
382     /* Check if add could be successful */    
383     $str = $this->SQL_add_me(false);
384     if(!empty($str)){
385       $message[] = $str;
386     }
388     return $message;
389   }
392   function SQL_add_me($save)
393   {
394     /* Check if there is at least on server configuration */
395     if(!count($this->goFonHomeServers)){
396       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."));
397     }
398   
399     /********************
400      * Get configuration and try to connect 
401      ********************/
403     /* Check if databases are reachable, returns an error string if anything fails  */
404     $error_str = $this->check_database_accessibility();
405     if($error_str){
406       return($error_str);
407     }
409     /* Remove old entries, returns an error string if anything fails  */
410     $error_str = $this->SQL_remove_me($save);
411     if($error_str){
412       return($error_str);
413     }
415     /* Connect to current database to be able to add new entries */
416     $cfg_Current  = $this->goFonHomeServers[$this->goFonHomeServer] ;
417     $res_cur      =  @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']);
418     $db_cur       =  @mysql_select_db($cfg_Current['DB'],$res_cur);
420     /********************
421      * Remove entries that could cause trouble  
422      ********************/
424     /* If the current home server is different to the initial home server,
425      *  there may be already some entries with the given telephoneNumber and/or cn.
426      * We must remove those entries to avoid duplicate use of the same extension name.
427      */
428     if($this->goFonHomeServer != $this->init_HomeServer){
429       $query = "SELECT id FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$this->telephoneNumber."' OR '".$this->cn."';";
430       $res = @mysql_query($query,$res_cur);
431       if(!$res){
432         gosa_log(@mysql_error($res_cur));
433         return(_("Can not check if there are already some entries with given telephone number and/or cn in the destination home server.").
434             "&nbsp;"._("Please have a look a the gosa logfiles."));
435       }
436       if($save && mysql_affected_rows($res_cur)) {
437         $SQL = "DELETE FROM ".$cfg_Current['EXT_TABLE']." 
438           WHERE   (exten='".$this->telephoneNumber."') 
439           OR    (exten='".$this->cn."')";
441         /* Query and ensure that everything went fine */
442         $res =  @mysql_query($SQL,$res_cur);
443         if(!$res){
444           gosa_log(@mysql_error($res_cur));
445           return(_("Can not remove entries with some telephone number and/or cn from destination home server.").
446               "&nbsp;"._("Please have a look a the gosa logfiles."));
447         }
448       }
449     }
451     /********************
452      * Add new conference entry  
453      ********************/
454     if((!empty($this->telephoneNumber))&&($save==true)){
456       /* Create string out of conference Flags */
457       $parameter  ="";
458       foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s",
459             "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D") as $attrs){
460         $parameter .= $this->$attrs;
461       }
463       $i=1;
464       $EXT=array();
465       $context="GOsa";
466       // Set Language to German
467       $EXT[$i]['exten']   =$this->telephoneNumber;
468       $EXT[$i]['context'] = $context;
469       $EXT[$i]['priority']= $i;
470       $EXT[$i]['app']     ="SetLanguage";
471       $EXT[$i]['appdata'] ="de";
472       $i++;      
474       if($this->goFonConferenceOption_r == "r"){
476         // Recordingformat for conference
477         $EXT[$i]['exten']   =$this->telephoneNumber;
478         $EXT[$i]['context'] =$context;
479         $EXT[$i]['priority']= $i;
480         $EXT[$i]['app']     ="Setvar";
481         $EXT[$i]['appdata'] ="MEETME_RECORDINGFORMAT=".$this->goFonConferenceOptionFormat;
482         $i++;      
484       }
486       // Answer Call
487       $EXT[$i]['exten']   =$this->telephoneNumber;
488       $EXT[$i]['context'] =$context;
489       $EXT[$i]['priority']=$i;
490       $EXT[$i]['app']     ="answer";
491       $EXT[$i]['appdata'] ="";
492       $i++;      
494       // Start Conference 
495       $EXT[$i]['exten']   =$this->telephoneNumber;
496       $EXT[$i]['context'] =$context;
497       $EXT[$i]['priority']=$i;
498       $EXT[$i]['app']     ="MeetMe";
500       if(empty($this->goFonPIN)) {
501         $EXT[$i]['appdata'] =$this->telephoneNumber."|".$parameter;
502       }else{
503         $EXT[$i]['appdata'] =$this->telephoneNumber."|".$parameter."|".$this->goFonPIN;
504       }
505       $i++; 
507       // Start Conference 
508       $EXT[$i]['exten']   =$this->cn;
509       $EXT[$i]['context'] =$context;
510       $EXT[$i]['priority']=1;
511       $EXT[$i]['app']     ="Goto";
512       $EXT[$i]['appdata'] =$this->telephoneNumber."|1";
513       $SQL=array();
515       foreach($EXT as $keytop => $valtop){
516         $s_keys = "";
517         $s_values = ""; 
518         foreach($valtop as $key=>$val){
519           $s_keys   .="`".$key."`,";
520           $s_values .="'".$val."',";
521         }
522         $s_keys   =preg_replace("/\,$/","",$s_keys); 
523         $s_values =preg_replace("/\,$/","",$s_values); 
524         $SQL[]="INSERT INTO ".$cfg_Current['EXT_TABLE']." (".$s_keys.") VALUES (".$s_values.");"; 
525       }
526       foreach($SQL as $sqlsyn){
527         mysql_query($sqlsyn,$res_cur);
528       }
529     } 
531     @mysql_close($res_cur);
532   }
535   /* Remove initial entry from database 
536    * This function checks if there is an entry in the 
537    *  initial home server that uses this->old_cn or $this->old_tele_number
538    *  and removes this entries. 
539    * This function is called from save and remove_from parent.
540    * 
541    *  The parameter '$save' is false if we just 
542    *   want to check if a remove is possible. 
543    *  And true if we realy want to remove the entries.   
544    */
545   function SQL_remove_me($save)
546   {
547     /* check database access */
548     $str = $this->check_database_accessibility();
549     if($str){
550       return($str);
551     }
553     /* Connect to old database */
554     $cfg_Init  = $this->goFonHomeServers[$this->init_HomeServer] ;
555     $r_init    =  @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']);
556     $db_init   =  @mysql_select_db($cfg_Init['DB'],$r_init);
557    
558     /* Check if there is an old entry */
559     $query = "SELECT id FROM ".$cfg_Init['EXT_TABLE']." WHERE exten='".$this->old_tele_number."' OR '".$this->old_cn."';";
560     $res = @mysql_query($query,$r_init);
561     if(!$res){
562       gosa_log(@mysql_error($r_init));
563       return(_("Can not check if entry exists in old database. Please have a look a the gosa logfiles."));
564     }
565    
566     /* There are entries using this cn and/or phone number */
567     if($save && mysql_affected_rows($r_init)) {
568       $SQL = "DELETE FROM ".$cfg_Init['EXT_TABLE']." 
569       WHERE   (exten='".$this->old_tele_number."') 
570         OR    (exten='".$this->old_cn."')";
571   
572       /* Query and ensure that everything went fine */
573       $res =  @mysql_query($SQL,$r_init);
574       if(!$res){
575         gosa_log(@mysql_error($r_init));
576         return(_("Can not remove old entries from initial home server. Please have a look a the gosa logfiles."));
577       }
579     }//ENDE  old num availiable ...
580     @mysql_close($r_init);
581     return(false);
582   }
586   /* This function checks if the given phonenumbers are available or already in use*/
587   function is_number_used()
588   {
589     $ldap= $this->config->get_ldap_link();
590     $ldap->cd($this->config->current['BASE']);
591     $ldap->search("(|(objectClass=goFonAccount)(objectClass=goFonQueue)(objectClass=goFonConference))", array("telephoneNumber","cn","uid"));
592     while($attrs = $ldap->fetch()) {
593       unset($attrs['telephoneNumber']['count']);
594       foreach($attrs['telephoneNumber'] as $tele){
595         if(!isset($attrs['cn'][0])) $attrs['cn'][0]=$attrs['dn'];
596         if(!isset($attrs['uid'][0])) $attrs['uid'][0]=$attrs['dn'];
597         $numbers[$tele]=$attrs;
598       }
599     }
601     $num = $this->telephoneNumber;
602     if((isset($numbers[$num]))&&(($numbers[$num]['cn'][0]!=$this->old_cn))){
603       if(isset($numbers[$num]['uid'][0])){
604         return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['uid'][0]);
605       }else{
606         return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['cn'][0]);
607       }
608     }
609   }
612   /* Save to LDAP */
613   function save()
614   {
616     if((!isset($this->attrs['goFonPIN']))){
617       $pin_use = false;
618     }else{
619       $pin_use = true;
620     }
622     /* Unset PIN if this is a conference without PIN */
623     if((!empty($this->goFonPIN)||($this->goFonConferenceOption_P=="P"))&&($this->goFonConferenceOption_D=="d")){
624       $this->goFonPIN = "";
625     }
627     plugin::save();
629     if(empty($this->old_tele_number)){
630       $this->old_tele_number= $this->telephoneNumber;
631     }
633     $this->SQL_add_me(true);
635     if(empty($this->goFonConferenceOption_P)){
636       if($pin_use){
637         $this->attrs['goFonPIN']=array();
638       }else{
639         unset($this->attrs['goFonPIN']);
640       }
641     }
642     $this->attrs['goFonConferenceOption']="";
643     foreach(array("goFonConferenceOption_P","goFonConferenceOption_r","goFonConferenceOption_M","goFonConferenceOption_s",
644           "goFonConferenceOption_i","goFonConferenceOption_c","goFonConferenceOption_D","goFonConferenceOptionFormat") as $attrs){
645       $this->attrs['goFonConferenceOption'] .= $this->$attrs;
646       unset($this->attrs[$attrs]);         
647     }
649     $this->attrs['goFonConferenceOption'].="|".$this->goFonConferenceOptionLifetime;
650     unset($this->attrs['goFonConferenceOptionLifetime']);
652     /* Write back to ldap */
654     unset($this->attrs['base']);
656     $ldap= $this->config->get_ldap_link();
657     $ldap->cd($this->config->current['BASE']);
658     $ldap->cat($this->dn, array('dn'));
660     if ($ldap->count()){
661       $ldap->cd($this->dn);
662       $this->cleanup();
663       $ldap->modify ($this->attrs); 
664       $this->handle_post_events('modify');
665     } else {
666       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
667       $ldap->cd($this->dn);
668       $ldap->add($this->attrs);
669       $this->handle_post_events('add');
670     }
672     /* Log last action */
673     if($this->initially_was_account){
674       @log::log("modify","gofonconference/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
675     }else{
676       @log::log("create","gofonconference/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
677     }
679     show_ldap_error($ldap->get_error(), sprintf(_("Saving of goFonConference/generic with dn '%s' failed."),$this->dn));
681     /* Optionally execute a command after we're done */
682     $this->postcreate();
683   }
685   /* Return plugin informations for acl handling */
686   function plInfo()
687   {
688     return (array(
689           "plShortName"   => _("Conference"),
690           "plDescription" => _("Phone conference management"),
691           "plSelfModify"  => TRUE,
692           "plDepends"     => array(),
693           "plPriority"    => 0,
694           "plSection"     => array("addons" => _("Addons")),
695           "plCategory"    => array("gofonconference" => array("description" => _("GOfon conference"),
696               "objectClass" => "gofonConference")),
698           "plProvidedAcls" => array(
699             "cn"                            => _("Name"),
700             "base"                          => _("Base"),
701             "description"                   => _("Description"),
702             "goFonPIN"                      => _("Conference PIN"),
704             "goFonHomeServer"              => _("Home server"),
705             "goFonConferenceOptionP"       => _("Preset PIN"),
706             "goFonConferenceOptionr"       => _("Record conference"),
707             "goFonConferenceOptionM"       => _("Play music on hold"),
708             "goFonConferenceOptions"       => _("Activate menu"),
709             "goFonConferenceOptioni"       => _("Announce user activity"),
710             "goFonConferenceOptionc"       => _("Count user"),
711             "goFonConferenceOptionD"       => _("Conference type"),
713             "goFonConferenceOptionFormat"   => _("Format"),
714             "goFonConferenceOptionLifetime" => _("Lifetime"),
715             "telephoneNumber"               => _("Telephone number"),
716             "goFonConferenceOwner"          => _("Owner"))
717             ));
718   }
723 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
724 ?>