Code

Invalid repository settings fixed.
[gosa.git] / plugins / admin / ogroups / class_phonequeue.inc
index c5fb59f7e3ff720560ef8297eea19773daefac64..c7f61c946901f3b32fd880e1f93226eba7fe698c 100644 (file)
@@ -219,7 +219,12 @@ class phonequeue extends plugin
   {
 
     $SQL = array();
+
+    if(!isset($_SESSION['config']->data['SERVERS']['FON'])){
+      return(_("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer).\nYour Settings can't be saved to asterisk Database."));
+      return(false);
+    }
+
     // Get Configuration for Mysql database Server
     $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
     $s_parameter  ="";
@@ -281,11 +286,13 @@ class phonequeue extends plugin
       $i = 0;
       $queueuser =array();
       foreach($this->parent->by_object['ogroup']->memberList as $member){
-        if(in_array("goFonAccount",$member['objectClass'])){
-          $i ++ ;
-          $queueuser[$i]['queue_name']  = $this->attrs['cn'][0]; 
-          $queueuser[$i]['interface']   = "SIP/".$member['uid'][0]; 
-          $queueuser[$i]['penalty']     = 1; 
+        if(isset($member['objectClass'])){
+          if(in_array("goFonAccount",$member['objectClass'])){
+            $i ++ ;
+            $queueuser[$i]['queue_name']  = $this->attrs['cn'][0]; 
+            $queueuser[$i]['interface']   = "SIP/".$member['uid'][0]; 
+            $queueuser[$i]['penalty']     = 1; 
+          }
         }
       }
 
@@ -309,13 +316,18 @@ class phonequeue extends plugin
 
       $queueusers=0;
       foreach($this->parent->by_object['ogroup']->memberList as $member){
-        if(in_array("goFonAccount",$member['objectClass'])){
-          $queueusers++;
+        if(isset($member['objectClass'])){
+          if(in_array("goFonAccount",$member['objectClass'])){
+            $queueusers++;
+          }
         }
       }
 
 
       $i = 0;
+
+      $i_insert_only_once = false;
+      
       foreach($this->telephoneNumber as $num){
        
         // If there are no member in a Queue
@@ -323,12 +335,15 @@ class phonequeue extends plugin
 
         // A Queue is not deleted directly, it is stored until the o group is deleted
         
-        $a_ext[$i]['context']  = 'GOsa';
-        $a_ext[$i]['exten']    = $this->attrs['cn'][0];
-        $a_ext[$i]['priority'] = 1;
-        $a_ext[$i]['app']      = "Goto";
-        $a_ext[$i]['appdata']  = $num."|1";
-        $i ++ ; 
+        if($i_insert_only_once == false){
+          $i_insert_only_once = true;
+          $a_ext[$i]['context']  = 'GOsa';
+          $a_ext[$i]['exten']    = $this->attrs['cn'][0];
+          $a_ext[$i]['priority'] = 1;
+          $a_ext[$i]['app']      = "Goto";
+          $a_ext[$i]['appdata']  = $num."|1";
+          $i ++ ; 
+        }
     
         if($queueusers == 0){
           $a_ext[$i]['context']  = 'GOsa';
@@ -480,6 +495,7 @@ class phonequeue extends plugin
       }
 
     }
+    @mysql_close($r_con);
     return(false);
   }