Code

Added check for array key
authorjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 1 Sep 2005 14:12:36 +0000 (14:12 +0000)
committerjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 1 Sep 2005 14:12:36 +0000 (14:12 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1291 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/gofon/phoneaccount/class_phoneAccount.inc

index 814d890268a70951b60b7566e3ba5d17e02c54a9..3186283b9509d36e632a9a0854ef42ccafdb21ce 100644 (file)
@@ -66,25 +66,30 @@ class phoneAccount extends plugin
       }
     }
 
-    $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
-    $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."),
+    $a_SETUP= array();
+    if(array_key_exists('config',$_SESSION) &&
+       array_key_exists('SERVERS',$_SESSION['config']->data) &&
+       array_key_exists('FON',$_SESSION['config']->data['SERVERS'])) {
+      $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
+      $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."),
           $a_SETUP['SERVER'],$a_SETUP['LOGIN']);
-      gosa_log(mysql_error());
-      return false;
-    }
-    $db  =  @mysql_select_db($a_SETUP['DB'],$r_con);
-    if(!$db){
-      $this->generate_error = sprintf(_("Can't select database %s on %s."),$a_SETUP['DB'],$a_SETUP['SERVER']);
-      gosa_log(mysql_error());
-      return false;
-    }
+        gosa_log(mysql_error());
+        return false;
+      }
+      $db  =  @mysql_select_db($a_SETUP['DB'],$r_con);
+      if(!$db){
+        $this->generate_error = sprintf(_("Can't select database %s on %s."),$a_SETUP['DB'],$a_SETUP['SERVER']);
+        gosa_log(mysql_error());
+        return false;
+      }
  
-    $first = false; 
-    foreach($this->phoneNumbers as $key => $val){
-      if(!$first){
-        $first = $key;
+      $first = false; 
+      foreach($this->phoneNumbers as $key => $val){
+        if(!$first){
+          $first = $key;
+        }
       }
     }