/**
  * Validates the input from the object edit form concerning this attribute.
  *
  * @param mixed  $http                   Class eZHTTPTool.
  * @param string $base                   Seems to be always 'ContentObjectAttribute'.
  * @param mixed  $contentObjectAttribute Class eZContentObjectAttribute.
  *
  * @return int eZInputValidator::STATE_INVALID/STATE_ACCEPTED
  */
 public function validateObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
 {
     if ($http->hasPostVariable($base . "_data_ipv4_" . $contentObjectAttribute->attribute("id"))) {
         $data = $http->postVariable($base . "_data_ipv4_" . $contentObjectAttribute->attribute("id"));
         $data = str_replace(" ", "", $data);
         $classAttribute = $contentObjectAttribute->contentClassAttribute();
         if (!$contentObjectAttribute->validateIsRequired() && $data == "") {
             return eZInputValidator::STATE_ACCEPTED;
         }
         $ipParts = explode(".", $data);
         if (count($ipParts) !== 4) {
             $contentObjectAttribute->setValidationError(ezi18n('kernel/classes/datatypes', 'No valid IP v4 address'));
             return eZInputValidator::STATE_INVALID;
         }
         $this->IntegerValidator->setRange(0, 255);
         foreach ($ipParts as $ipPart) {
             $state = $this->IntegerValidator->validate($ipPart);
             if ($state !== 1) {
                 $contentObjectAttribute->setValidationError(ezi18n('kernel/classes/datatypes', 'No valid IP v4 address'));
                 return eZInputValidator::STATE_INVALID;
             }
         }
         return eZInputValidator::STATE_ACCEPTED;
     } else {
         return eZInputValidator::STATE_ACCEPTED;
     }
     return eZInputValidator::STATE_INVALID;
 }
 /**
  * 
  * 
  * @param mixed  $http           Class eZHTTPTool.
  * @param string $base           Seems to be always 'ContentObjectAttribute'.
  * @param mixed  $classAttribute Class eZContentClassAttribute.
  *
  * @return int eZInputValidator::STATE_...
  */
 public function validateClassAttributeHTTPInput($http, $base, $classAttribute)
 {
     $this->IntegerValidator->setRange(0, 9999999);
     if ($http->hasPostVariable($base . EZ_DATATYPESTRING_SOA_RECORD_NS_VARIABLE . $classAttribute->attribute("id"))) {
         $nameserver = $http->postVariable($base . EZ_DATATYPESTRING_SOA_RECORD_NS_VARIABLE . $classAttribute->attribute("id"));
         if ($nameserver != "") {
             if (!ereg('^[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$', $nameserver)) {
                 return eZInputValidator::STATE_INVALID;
             }
         }
     }
     if ($http->hasPostVariable($base . EZ_DATATYPESTRING_SOA_RECORD_EMAIL_VARIABLE . $classAttribute->attribute("id"))) {
         $email = $http->postVariable($base . EZ_DATATYPESTRING_SOA_RECORD_EMAIL_VARIABLE . $classAttribute->attribute("id"));
         if ($email != "") {
             if (trim($email) == "") {
                 return eZInputValidator::STATE_INVALID;
             }
             $vaild_mail = eZMail::validate(trim($email));
             if (!$vaild_mail) {
                 return eZInputValidator::STATE_INVALID;
             }
         }
     }
     if ($http->hasPostVariable($base . EZ_DATATYPESTRING_SOA_RECORD_REFRESH_PERIOD_VARIABLE . $classAttribute->attribute("id"))) {
         $refresh_period = $http->postVariable($base . EZ_DATATYPESTRING_SOA_RECORD_REFRESH_PERIOD_VARIABLE . $classAttribute->attribute("id"));
         if ($refresh_period != "") {
             if ($this->IntegerValidator->validate($refresh_period) !== 1) {
                 return eZInputValidator::STATE_INVALID;
             }
         }
     }
     if ($http->hasPostVariable($base . EZ_DATATYPESTRING_SOA_RECORD_RETRY_INTERVAL_VARIABLE . $classAttribute->attribute("id"))) {
         $retry_interval = $http->postVariable($base . EZ_DATATYPESTRING_SOA_RECORD_RETRY_INTERVAL_VARIABLE . $classAttribute->attribute("id"));
         if ($retry_interval != "") {
             if ($this->IntegerValidator->validate($retry_interval) !== 1) {
                 return eZInputValidator::STATE_INVALID;
             }
         }
     }
     if ($http->hasPostVariable($base . EZ_DATATYPESTRING_SOA_RECORD_EXPIRE_TIME_VARIABLE . $classAttribute->attribute("id"))) {
         $expire_time = $http->postVariable($base . EZ_DATATYPESTRING_SOA_RECORD_EXPIRE_TIME_VARIABLE . $classAttribute->attribute("id"));
         if ($expire_time != "") {
             if ($this->IntegerValidator->validate($expire_time) !== 1) {
                 return eZInputValidator::STATE_INVALID;
             }
         }
     }
     if ($http->hasPostVariable($base . EZ_DATATYPESTRING_SOA_RECORD_DEFAULT_TTL_VARIABLE . $classAttribute->attribute("id"))) {
         $default_ttl = $http->postVariable($base . EZ_DATATYPESTRING_SOA_RECORD_DEFAULT_TTL_VARIABLE . $classAttribute->attribute("id"));
         if ($default_ttl != "") {
             if ($this->IntegerValidator->validate($default_ttl) !== 1) {
                 return eZInputValidator::STATE_INVALID;
             }
         }
     }
     return eZInputValidator::STATE_ACCEPTED;
 }
 public function fixupClassAttributeHTTPInput($http, $base, $classAttribute)
 {
     $maxLenName = $base . self::MAX_LEN_VARIABLE . $classAttribute->attribute('id');
     if ($http->hasPostVariable($maxLenName)) {
         $maxLenValue = $http->postVariable($maxLenName);
         $this->MaxLenValidator->setRange(1, false);
         $maxLenValue = $this->MaxLenValidator->fixup($maxLenValue);
         $http->setPostVariable($maxLenName, $maxLenValue);
     }
 }
 /**
  * Validates input on content object level
  *
  * @return eZInputValidator::STATE_ACCEPTED or eZInputValidator::STATE_INVALID if
  *         the values are accepted or not
  */
 function validateObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
 {
     $integerValidator = new eZIntegerValidator(0);
     $passwordlifetime = false;
     $expirationnotification = false;
     $updatechildren = false;
     if ($http->hasPostVariable($base . "_data_paex_passwordlifetime_" . $contentObjectAttribute->attribute("id"))) {
         $passwordlifetime = $http->postVariable($base . "_data_paex_passwordlifetime_" . $contentObjectAttribute->attribute("id"));
     }
     if ($http->hasPostVariable($base . "_data_paex_expirationnotification_" . $contentObjectAttribute->attribute("id"))) {
         $expirationnotification = $http->postVariable($base . "_data_paex_expirationnotification_" . $contentObjectAttribute->attribute("id"));
     }
     // Check if passwordlifetime is set, that it's an integer >= 0
     $statusPasswordlifetime = $integerValidator->validate($passwordlifetime);
     if ($statusPasswordlifetime != eZInputValidator::STATE_ACCEPTED && trim($passwordlifetime)) {
         $contentObjectAttribute->setValidationError(ezpI18n::tr('mbpaex/classes/datatypes', 'The password lifetime must be an integer >= 0'));
         return eZInputValidator::STATE_INVALID;
     }
     // Check if expirationnotification is set, that it's an integer >= 86400 (1 day)
     $integerValidator->setRange(86400, false);
     $statusExpirationnotification = $integerValidator->validate($expirationnotification);
     if ($statusExpirationnotification != eZInputValidator::STATE_ACCEPTED && trim($expirationnotification)) {
         $contentObjectAttribute->setValidationError(ezpI18n::tr('mbpaex/classes/datatypes', 'The expiration notification time must be an integer >= 86400'));
         return eZInputValidator::STATE_INVALID;
     }
     // Check if password validates regexp
     $contentObjectID = $contentObjectAttribute->attribute("contentobject_id");
     // Check if paex object for the current coID exists, use default one if needed.
     $paex = $contentObjectAttribute->content();
     if ($paex === null) {
         $paex = eZPaEx::create($contentObjectID);
     }
     // If the current contentobject is a user, check if the password has changed and validate if needed
     if ($paex->isUser()) {
         // Search for password entered in the form
         foreach ($http->postVariable($base . '_id') as $coaid) {
             if ($http->hasPostVariable($base . '_data_user_password_' . $coaid)) {
                 $newPassword = $http->postVariable($base . '_data_user_password_' . $coaid);
                 break;
             }
         }
         if (trim($newPassword) && $newPassword != "_ezpassword") {
             if ($paex->canEdit()) {
                 if ($http->hasPostVariable($base . "_data_paex_passwordvalidationregexp_" . $contentObjectAttribute->attribute("id"))) {
                     $paex->setAttribute('passwordvalidationregexp', $http->postVariable($base . "_data_paex_passwordvalidationregexp_" . $contentObjectAttribute->attribute("id")));
                 }
             }
             if (!$paex->validatePassword($newPassword)) {
                 $contentObjectAttribute->setValidationError(ezpI18n::tr('mbpaex/classes/datatypes', "The password doesn't match the validation rule.\n                                                                         Previous password will be preserved if there is any."));
                 return eZInputValidator::STATE_INVALID;
             }
         }
     } else {
         if ($http->hasPostVariable($base . "_data_paex_updatechildren_" . $contentObjectAttribute->attribute("id"))) {
             $updatechildren = $http->postVariable($base . "_data_paex_updatechildren_" . $contentObjectAttribute->attribute("id"));
         }
         // Check if updatechildren is set, that it's an integer 0 or 1 (1 day)
         $integerValidator->setRange(0, 1);
         $statusUpdatechildren = $integerValidator->validate($updatechildren);
         if ($statusUpdatechildren != eZInputValidator::STATE_ACCEPTED && trim($updatechildren)) {
             $contentObjectAttribute->setValidationError(ezpI18n::tr('mbpaex/classes/datatypes', 'Wrong value in updatechildren field'));
             return eZInputValidator::STATE_INVALID;
         }
     }
     return eZInputValidator::STATE_ACCEPTED;
 }