Code

Added anyway edit to fai class
[gosa.git] / plugins / admin / ogroups / class_phonequeue.inc
index c5fb59f7e3ff720560ef8297eea19773daefac64..c0e669b03843521b43eb1c69fa7efeb1018336b1 100644 (file)
@@ -99,6 +99,9 @@ class phonequeue extends plugin
 
   function execute()
   {
+       /* Call parent execute */
+       plugin::execute();
+
     /* Do we need to flip is_account state? */
     if (isset($_POST['modify_state'])){
       $this->is_account= !$this->is_account;
@@ -110,7 +113,8 @@ class phonequeue extends plugin
         $display= $this->show_header(_("Remove the phone queue from this Account"),
             _("Phone queue is enabled for this group. You can disable it by clicking below."));
       } else {
-        $display= $this->show_header(_("Create phone queue"), _("For this group the phone queues are disabled. You can enable them by clicking below."));
+        $display= $this->show_header(_("Create phone queue"), 
+                  _("For this group the phone queues are disabled. You can enable them by clicking below."));
         return ($display);
       }
     }
@@ -157,7 +161,7 @@ class phonequeue extends plugin
 
     $smarty= get_smarty();
 
-    $smarty->assign("goFonQueueLanguageOptions",array('de'=>_('German'),'ur'=>_('Uruguai')));
+    $smarty->assign("goFonQueueLanguageOptions",array('de'=>_('German')));
     $smarty->assign("goFonQueueStrategyOptions", $this->goFonQueueStrategyOptions);
 
     foreach($this->attributes as $key => $val){
@@ -183,9 +187,6 @@ class phonequeue extends plugin
   function check()
   {
     $message= array();
-  #fixme workaround : Tab is not initialised correct
-         if(!$this->is_account) return($message);
-
     if($this->is_number_used()){
       $message[] = $this->is_number_used();
     }
@@ -219,7 +220,11 @@ class phonequeue extends plugin
   {
 
     $SQL = array();
+
+    if(!isset($_SESSION['config']->data['SERVERS']['FON'])){
+      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'];
     $s_parameter  ="";
@@ -230,7 +235,7 @@ class phonequeue extends plugin
     // Check if we are  connected correctly
     if(!$r_con){
       gosa_log(mysql_error());
-      return (sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
+      return (sprintf(_("The MySQL server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
           $a_SETUP['SERVER'],$a_SETUP['LOGIN']));
     }
 
@@ -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);
   }
 
@@ -563,7 +579,9 @@ class phonequeue extends plugin
 
     /* Save data to LDAP */
     $ldap->cd($this->dn);
-    $ldap->modify($this->attrs);
+    $this->cleanup();
+$ldap->modify ($this->attrs); 
+
 
     show_ldap_error($ldap->get_error());
 
@@ -659,7 +677,9 @@ class phonequeue extends plugin
     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
         $this->attributes, "Save");
     $ldap->cd($this->dn);
-    $ldap->modify($this->attrs);
+    $this->cleanup();
+$ldap->modify ($this->attrs); 
+
     show_ldap_error($ldap->get_error());
   }