Code

Only warn user that mysql isn't reachable if we really have changed something
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 19 Jul 2007 13:35:01 +0000 (13:35 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 19 Jul 2007 13:35:01 +0000 (13:35 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6924 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/gofon/phoneaccount/class_phoneAccount.inc

index 0387abb0f9ef954b8655cafbe7b97c17549a4d6c..1693935245549a6bb16f4ec9973481e220742bc9 100644 (file)
@@ -117,13 +117,13 @@ class phoneAccount extends plugin
 
         $r_con =  @mysql_pconnect($cur_cfg['SERVER'],$cur_cfg['LOGIN'],$cur_cfg['PASSWORD']);
         if(!$r_con){
-          print_red( sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
-                $cur_cfg['SERVER'],$cur_cfg['LOGIN']));
+#          print_red( sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
+#                $cur_cfg['SERVER'],$cur_cfg['LOGIN']));
           new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error());
         }
         $db  =  @mysql_select_db($cur_cfg['DB'],$r_con);
         if(!$db){
-          print_red(sprintf(_("Can't select database %s on %s."),$cur_cfg['DB'],$cur_cfg['SERVER']));
+#          print_red(sprintf(_("Can't select database %s on %s."),$cur_cfg['DB'],$cur_cfg['SERVER']));
           new log("debug","gofonreport/".get_class($this),"",array(),@mysql_error());
         }
 
@@ -257,11 +257,6 @@ class phoneAccount extends plugin
     ksort($this->hardware_list);
     $this->a_old_telenums = $this->phoneNumbers;
 
-    if($this->is_account){
-      $this->is_modified = true;
-    }
-
-
     /* Get voicemail PIN from MySQL DB 
      * Because every user can change his PIN directly from the phone
      *  without any update to the ldap
@@ -1075,6 +1070,7 @@ class phoneAccount extends plugin
   {
     $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']);
     if (isset($_POST["phoneTab"])){
+    
       plugin::save_object();
 
       /* Save checkbox */
@@ -1094,6 +1090,10 @@ class phoneAccount extends plugin
         $this->macrostillavailable=true;
       }
 
+      if(isset($_POST['macro']) && $_POST['macro'] != $this->macro){
+        $this->is_modified =true;
+      }
+
       if(is_array($this->phoneNumbers)){
         foreach($this->phoneNumbers as $telenumms) {
           $nummsinorder[]=$telenumms; 
@@ -1105,8 +1105,12 @@ class phoneAccount extends plugin
 
       /* get all Postvars */
       if(isset($this->macroarray[$this->macro])){
+
         if($this->acl_is_writeable("goFonMarco",$SkipWrite)){
           foreach($this->macroarray[$this->macro] as $key => $paras){
+
+            $backup = $this->macroarray[$this->macro][$key];
+
             if(isset($_POST[$paras['var']])){
               $this->macroarray[$this->macro][$key]['choosen'] = $_POST[$paras['var']];
             }
@@ -1125,6 +1129,9 @@ class phoneAccount extends plugin
               }
             }
           }
+          if(count(array_diff($this->macroarray[$this->macro][$key],$backup))){
+            $this->modified = TRUE;
+          }
         }
       }
     }
@@ -1159,8 +1166,10 @@ class phoneAccount extends plugin
       }
     }
 
-    if(!$this->generate_mysql_entension_entries()){
-      $message[] = $this->generate_error;
+    if ($this->initially_was_account != $this->is_account || $this->is_modified){
+      if(!$this->generate_mysql_entension_entries()){
+        $message[] = $this->generate_error;
+      }
     }
 
     /* We need at least one phone number */
@@ -1216,9 +1225,11 @@ class phoneAccount extends plugin
 
     $this->attrs['goFonForwarding']=array();
 
-    $str = $this->generate_mysql_entension_entries(true);
-    if(empty($str)){
-      print_red($str);
+    if ($this->initially_was_account != $this->is_account || $this->is_modified){
+      $str = $this->generate_mysql_entension_entries(true);
+      if(empty($str)){
+        print_red($str);
+      }
     }
 
     if($this->attrs['goFonMacro']==""){