Code

Prepared for multiple asterisk servers
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Dec 2006 06:53:47 +0000 (06:53 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Dec 2006 06:53:47 +0000 (06:53 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5437 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_config.inc
plugins/admin/ogroups/class_phonequeue.inc
plugins/admin/users/class_divListUsers.inc
plugins/gofon/conference/class_phoneConferenceGeneric.inc
plugins/gofon/fonreports/class_fonreport.inc
plugins/gofon/macro/class_gofonMacro.inc
plugins/gofon/phoneaccount/class_phoneAccount.inc

index ffa4f7d71ebcb6deed64c5c7e01e4f80ae4b4800..938f9a07177a01f630752285a0f9c57f3a4104fe 100644 (file)
@@ -376,18 +376,20 @@ class config  {
     /* Get asterisk servers */
     $ldap->cd ($this->current['BASE']);
     $ldap->search ("(objectClass=goFonServer)");
+    $this->data['SERVERS']['FON']= array(); 
     if ($ldap->count()){
-      $attrs= $ldap->fetch();
-      $this->data['SERVERS']['FON']= array( 
-          'SERVER'     => $attrs['cn'][0],
-          'LOGIN'      => $attrs['goFonAdmin'][0],
-          'PASSWORD'   => $attrs['goFonPassword'][0],
-          'DB'         => "gophone",
-          'SIP_TABLE'          => "sip_users",
-          'EXT_TABLE'  => "extensions",
-          'VOICE_TABLE'        => "voicemail_users",
-          'QUEUE_TABLE'        => "queues",
-          'QUEUE_MEMBER_TABLE' => "queue_members");
+      while ($attrs= $ldap->fetch()){
+        $this->data['SERVERS']['FON'][]= array( 
+            'SERVER'   => $attrs['cn'][0],
+            'LOGIN'    => $attrs['goFonAdmin'][0],
+            'PASSWORD'         => $attrs['goFonPassword'][0],
+            'DB'               => "gophone",
+            'SIP_TABLE'                => "sip_users",
+            'EXT_TABLE'        => "extensions",
+            'VOICE_TABLE'      => "voicemail_users",
+            'QUEUE_TABLE'      => "queues",
+            'QUEUE_MEMBER_TABLE'       => "queue_members");
+      }
     }
 
     /* Get glpi servers */
index bd592dabaf9054b3a123c316e250d63f162b16eb..b665f91dff80356813ad728f8cca85e8317e5295 100644 (file)
@@ -223,12 +223,12 @@ class phonequeue extends plugin
 
     $SQL = array();
 
-    if(!isset($_SESSION['config']->data['SERVERS']['FON'])){
+    if(!isset($_SESSION['config']->data['SERVERS']['FON'][0])){
       return(_("There is currently no asterisk server defined. Your settings can't be saved."));
     }
 
     // Get Configuration for Mysql database Server
-    $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
+    $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'][0];
     $s_parameter  ="";
 
     // Connect to DB server
@@ -603,7 +603,7 @@ class phonequeue extends plugin
     $SQL = array();
 
     // Get Configuration for Mysql database Server
-    $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
+    $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'][0];
     $s_parameter  ="";
 
     // Connect to DB server
index 722760672e1a2d6aa17587ec1edd4e117157fbf8..6d63ff3fa8017a2450004e73b03b97a221810c23 100644 (file)
@@ -182,8 +182,8 @@ class divListUsers extends MultiSelectWindow
      */
     $r_db   =false;
     $r_con  =false;
-    if (isset($_SESSION['config']->data['SERVERS']['FON'])){
-      $a_SETUP= $_SESSION['config']->data['SERVERS']['FON'];
+    if (isset($_SESSION['config']->data['SERVERS']['FON'][0])){
+      $a_SETUP= $_SESSION['config']->data['SERVERS']['FON'][0];
       $r_con = false;
       $r_db  = false;
       if(is_callable("mysql_pconnect")){
index cd62cf5c5d54f99be6d58a4c6289d588dc2bbedd..ad3832ac54d8e67659acd955aef1c2c14f34d375 100644 (file)
@@ -245,13 +245,13 @@ class conference extends plugin
 
   function SQL_add_me($save){
 
-    if(!isset($_SESSION['config']->data['SERVERS']['FON'])){
+    if(!isset($_SESSION['config']->data['SERVERS']['FON'][0])){
       $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);
     }
   
     // Get Configuration for Mysql database Server
-    $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
+    $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'][0];
 
     // Connect to DB server
     $r_con = false;    
@@ -376,7 +376,7 @@ class conference extends plugin
 
     if($this->old_tele_number){
       // Get Configuration for Mysql database Server
-      $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
+      $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'][0];
 
       // Connect to DB server
       $r_con =  @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
index 31efc71f39f963be33ea2cdde7cfe08bbc7b55d6..aaefaab6c392f2c44f9e3cf4d46a86b608f52e57 100644 (file)
@@ -153,7 +153,7 @@ class fonreport extends plugin
      *****************/
 
     /* Connecting, selecting database */
-    if (!isset($this->config->data['SERVERS']['FON'])){
+    if (!isset($this->config->data['SERVERS']['FON'][0])){
       print_red(_("Can't connect to phone database, no reports can be shown!"));
       return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
     }elseif(!is_callable("mysql_connect")){
@@ -161,7 +161,7 @@ class fonreport extends plugin
       return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
     }else{
 
-      $cfg= $this->config->data['SERVERS']['FON'];
+      $cfg= $this->config->data['SERVERS']['FON'][0];
       $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
       if ($link === FALSE){
         print_red(_("Can't connect to phone database, no reports can be shown!"));
@@ -179,7 +179,7 @@ class fonreport extends plugin
      *****************/
 
     $query  = $this->CreateQuerySyntax();
-    $cfg    = $this->config->data['SERVERS']['FON'];
+    $cfg    = $this->config->data['SERVERS']['FON'][0];
     $link   = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
 
     @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query");
index bb2f3f2c06fa9187c5d6a9943c95fbd9d094c8d6..dc5f9189458535af022d72dd391b5dca3ec92785 100755 (executable)
@@ -93,7 +93,7 @@ class macro extends plugin
     $tmp       = array();
     $number = 0; 
 
-    if(!isset($_SESSION['config']->data['SERVERS']['FON'])){
+    if(!isset($_SESSION['config']->data['SERVERS']['FON'][0])){
       print_red(_("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."));
     }
 
@@ -212,7 +212,7 @@ class macro extends plugin
   // Generate MySQL Syntax 
   function generate_mysql_entension_entries($save = false,$delete_only=false,$remove_old_macroname=false){
 
-    if(!isset($_SESSION['config']->data['SERVERS']['FON'])){
+    if(!isset($_SESSION['config']->data['SERVERS']['FON'][0])){
       return(true);
     }
 
@@ -225,7 +225,7 @@ class macro extends plugin
     }
 
     // Get Configuration for Mysql database Server  
-    $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
+    $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'][0];
 
     // Connect to DB server
     $r_con =  @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']); 
index 0cf7ac03a6684df4a90025ec05e5a1f02382b3cc..87985ba3e1b793d0960ffead3648e18bcc915ffd 100644 (file)
@@ -78,7 +78,7 @@ class phoneAccount extends plugin
        array_key_exists('FON',$_SESSION['config']->data['SERVERS']) &&
        is_callable("mysql_connect")
        ) {
-      $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
+      $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'][0];
       $r_con =  @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
       if(!$r_con){
         $this->generate_error = sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
@@ -250,7 +250,7 @@ class phoneAccount extends plugin
   // Generate MySQL Syntax
   function generate_mysql_entension_entries($save = false){
 
-    if(!isset($_SESSION['config']->data['SERVERS']['FON'])){
+    if(!isset($_SESSION['config']->data['SERVERS']['FON'][0])){
       if($save)
       print_red(_("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(true);
@@ -263,7 +263,7 @@ class phoneAccount extends plugin
     }
   
     // Get Configuration for Mysql database Server
-    $a_SETUP        = $_SESSION['config']->data['SERVERS']['FON'];  // DB Configuration
+    $a_SETUP        = $_SESSION['config']->data['SERVERS']['FON'][0];  // DB Configuration
     $s_parameter    = "";                                           // Contains paramter for selected Macro 
     $r_con          = false;                                        // DB connection
     $r_db           = false;                                        // Selected DB
@@ -646,7 +646,7 @@ class phoneAccount extends plugin
     $smarty->assign("macro", $this->macro);   
 
     /* check if there is a FON server created */
-    if(!isset($_SESSION['config']->data['SERVERS']['FON'])){
+    if(!isset($_SESSION['config']->data['SERVERS']['FON'][0])){
       print_red(_("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."));
     }
 
@@ -1031,7 +1031,7 @@ class phoneAccount extends plugin
        array_key_exists('FON', $_SESSION['config']->data['SERVERS']) &&
         is_callable("mysql_pconnect")) {
       // Get Configuration for Mysql database Server
-      $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
+      $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'][0];
       $s_parameter  ="";
 
       // Connect to DB server