Code

Password is must too
[gosa.git] / plugins / admin / systems / class_goFonServer.inc
index adb0d55f8b45efa950366a006c785b9346b82e30..c117972d5893ca6f61bb3635b3fc41da14c9614a 100644 (file)
@@ -95,48 +95,39 @@ class goFonServer extends plugin{
   function setStatus($value)
   {
     if($value == "none") return;
+    if(!$this->initially_was_account) return;
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->dn);
-    $ldap->cat($this->dn,array("objectClass","goFonAdmin", "goFonAreaCode", "goFonCountryCode","goFonPassword"));
-      
+    $ldap->cat($this->dn,array("objectClass"));
     if($ldap->count()){
-      $attrs =array();
-      foreach(array("goFonAdmin", "goFonAreaCode", "goFonCountryCode","goFonPassword") as $req) {
-        if(!isset($attrs[$req])){
-          if(empty($this->$req)){
-            print_red(sprintf(_("The required attribute '%s' is not set."),$req));
-          }else{
-            $attrs[$req] = $this->$req;
-          }
-        }else{
-          $attrs[$req] = $attrs[$req][0];
-        }
-      }
 
       $tmp = $ldap->fetch();
       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
         $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }    
-      if(!in_array("goFonServer",$attrs['objectClass'])){
-        $attrs['objectClass'][] = "goFonServer";
       }
-
       $flag = $this->StatusFlag;
       $attrs[$flag] = $value;
       $this->$flag = $value;
       $ldap->modify($attrs);
       show_ldap_error($ldap->get_error());
-    }    
+    }
   }
 
-  
+
   function check()
   { 
     $message = plugin::check();
-    foreach (array("goFonAdmin", "goFonAreaCode", "goFonCountryCode") as $attr){
-      if ($this->$attr == "" || preg_match("/ /", $this->$attr)){
-        $message[]= sprintf(_("The attribute '%s' is empty or contains invalid characters."), $attr);
-      }
+    if (empty($this->goFonAdmin)){
+      $message[]= sprintf(_("The attribute DB user is empty or contains invalid characters."), $attr);
+    }
+    if (empty($this->goFonPassword)){
+      $message[]= sprintf(_("The attribute password is empty or contains invalid characters."), $attr);
+    }
+    if (empty($this->goFonAreaCode)){
+      $message[]= sprintf(_("The attribute local dial prefix is empty or contains invalid characters."), $attr);
+    }
+    if (empty($this->goFonCountryCode)){
+      $message[]= sprintf(_("The attribute country dial prefix is empty or contains invalid characters."), $attr);
     }
     return($message);
   }