X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fgofon%2Fconference%2Fclass_phoneConferenceGeneric.inc;h=cd62cf5c5d54f99be6d58a4c6289d588dc2bbedd;hb=9ba37d0ddd9297f3eded1e12d899e939d9f15555;hp=4a79d946fd8fe8c0e3e1cb36c107c75cf44ae1d2;hpb=f7e386221abfcdc1f9adecf989f96ab375f07592;p=gosa.git diff --git a/plugins/gofon/conference/class_phoneConferenceGeneric.inc b/plugins/gofon/conference/class_phoneConferenceGeneric.inc index 4a79d946f..cd62cf5c5 100644 --- a/plugins/gofon/conference/class_phoneConferenceGeneric.inc +++ b/plugins/gofon/conference/class_phoneConferenceGeneric.inc @@ -26,7 +26,6 @@ class conference extends plugin var $base = ""; var $ou = ""; var $goFonPIN = ""; - var $acl = ""; var $old_cn = ""; var $goFonConferenceOption = ""; @@ -40,6 +39,8 @@ class conference extends plugin var $goFonConferenceOwner = ""; + var $error_shown = false; + var $goFonConferenceOptionFormat = ""; var $goFonConferenceOptionLifetime = ""; var $telephoneNumber = ""; @@ -53,6 +54,8 @@ class conference extends plugin var $last_dep_sorting= "invalid"; var $departments= array(); + var $dialog ; + /* attribute list for save action */ var $attributes= array("cn","base", "description", "goFonPIN","goFonConferenceOption_P","goFonConferenceOption_r", "goFonConferenceOption_M","goFonConferenceOption_s","goFonConferenceOption_i","goFonConferenceOption_c", @@ -60,9 +63,9 @@ class conference extends plugin var $objectclasses= array("top", "goFonConference"); - function conference ($config, $dn) + function conference ($config, $dn, $plugin= NULL) { - plugin::plugin($config, $dn); + plugin::plugin($config, $dn, $plugin); $this->is_account = TRUE; $this->ui = get_userinfo(); $this->dn = $dn; @@ -72,8 +75,8 @@ class conference extends plugin /* Set base */ if ($this->dn == "new"){ $ui= get_userinfo(); - if(isset($_SESSION['conferencefilter']['depselect'])){ - $this->base = $_SESSION['conferencefilter']['depselect']; + if(isset($_SESSION['CurrentMainBase'])){ + $this->base = $_SESSION['CurrentMainBase']; }else{ $this->base= dn2base($ui->dn); } @@ -81,8 +84,9 @@ class conference extends plugin $this->base= preg_replace ("/^[^,]+,/", "", $this->dn); } - $acl= get_permissions ($this->dn, $this->ui->subtreeACL); - $this->acl= get_module_permission($acl, "goFonConference", $this->dn); + $ui= get_userinfo(); + $acl= get_permissions ($ui->dn, $this->ui->subtreeACL); + $this->acl= get_module_permission($acl, "conference", $ui->dn); $this->goFonConferenceOwner=$this->ui->dn; /* Parse Options ... @@ -109,16 +113,38 @@ class conference extends plugin function execute() { - //$acl= get_permissions ($this->dn, $this->ui->subtreeACL); - //$this->acl= get_module_permission($acl, "goFonConference", $this->dn); + /* Call parent execute */ + plugin::execute(); - $this->config->departments = get_departments($this->dn); - $this->config->make_idepartments(); $smarty= get_smarty(); - $smarty->assign("bases" ,array_flip($this->config->departments)); + $smarty->assign("bases" ,$this->config->idepartments); $smarty->assign("base" ,$this->base); + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once){ + $once = false; + $this->dialog = new baseSelectDialog($this->config); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog)){ + /* Must be called before save_object */ + $this->dialog->save_object(); + + if($this->dialog->isClosed()){ + $this->dialog = false; + }elseif($this->dialog->isSelected()){ + $this->base = $this->dialog->isSelected(); + $this->dialog= false; + }else{ + return($this->dialog->execute()); + } + } + $smarty->assign("goFonConferenceOptions", array("D"=>"Conference ","d"=>"Conference without PIN")); $smarty->assign("goFonConferenceOptionFormats", array("WAV"=>"Wave","GSM"=>"GSM","WAV49"=>"Wave49")); $smarty->assign("goFonConferenceOption", $this->goFonConferenceOption_D); @@ -147,6 +173,8 @@ class conference extends plugin function remove_from_parent() { + $this->SQL_remove_me(true); + $ldap= $this->config->get_ldap_link(); $ldap->cd ($this->dn); $ldap->recursive_remove(); @@ -176,7 +204,8 @@ class conference extends plugin /* Check values */ function check() { - $message= array(); + /* Call common method to give check the hook */ + $message= plugin::check(); if($this->is_number_used()){ $message[] = $this->is_number_used(); @@ -198,7 +227,7 @@ class conference extends plugin $message[] =_("Only numeric chars are allowed in Number field."); } - if(!is_numeric($this->goFonConferenceOptionLifetime)){ + if(!((is_numeric($this->goFonConferenceOptionLifetime))||(empty($this->goFonConferenceOptionLifetime)))){ $message[] =_("Only numbers are allowed in Lifetime."); } @@ -217,7 +246,7 @@ class conference extends plugin function SQL_add_me($save){ if(!isset($_SESSION['config']->data['SERVERS']['FON'])){ - $this->generate_error = _("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). \n Your Settings can't be saved to asterisk Database. "); + $this->generate_error = _("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."); return(false); } @@ -225,11 +254,20 @@ class conference extends plugin $a_SETUP = $_SESSION['config']->data['SERVERS']['FON']; // Connect to DB server + $r_con = false; + + if(!is_callable("mysql_pconnect")){ + if(!$this->error_shown){ + print_red(_("Can't save any changes to asterisk database, there is currently no mysql extension available in your php setup.")); + $this->error_shown = true; + } + return(true); + } $r_con = @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']); // Check if we are connected correctly if(!$r_con){ - $this->generate_error = sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), + $this->generate_error = sprintf(_("The MySQL server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), $a_SETUP['SERVER'],$a_SETUP['LOGIN']); gosa_log(mysql_error()); return false; @@ -328,6 +366,13 @@ class conference extends plugin } function SQL_remove_me($save){ + if(!is_callable("mysql_pconnect")){ + if(!$this->error_shown){ + print_red(_("Can't save any changes to asterisk database, there is currently no mysql extension available in your php setup.")); + $this->error_shown = true; + } + return(true); + } if($this->old_tele_number){ // Get Configuration for Mysql database Server @@ -412,6 +457,10 @@ class conference extends plugin plugin::save(); + if(empty($this->old_tele_number)){ + $this->old_tele_number= $this->telephoneNumber; + } + $this->SQL_remove_me(true); $this->SQL_add_me(true); @@ -443,18 +492,21 @@ class conference extends plugin } $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($this->dn, array('dn')); - $ldap->cat($this->dn); - $a= $ldap->fetch(); - $ldap->cd($this->dn); - if (count($a)){ - $ldap->modify($this->attrs); + if ($ldap->count()){ + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); $this->handle_post_events('modify'); } else { + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + $ldap->cd($this->dn); $ldap->add($this->attrs); $this->handle_post_events('add'); } - show_ldap_error($ldap->get_error()); + show_ldap_error($ldap->get_error(), _("Saving phone conference failed")); /* Optionally execute a command after we're done */ $this->postcreate();