// Small changes on validateController
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11967 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+22
-22
@@ -109,28 +109,28 @@ class AddressCore extends ObjectModel
|
||||
'table' => 'address',
|
||||
'primary' => 'id_address',
|
||||
'fields' => array(
|
||||
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'),
|
||||
'id_manufacturer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'),
|
||||
'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'),
|
||||
'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'),
|
||||
'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_state' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'),
|
||||
'alias' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32),
|
||||
'company' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 32),
|
||||
'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
|
||||
'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
|
||||
'vat_number' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
|
||||
'address1' => array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'required' => true, 'size' => 128),
|
||||
'address2' => array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'size' => 128),
|
||||
'postcode' => array('type' => self::TYPE_STRING, 'validate' => 'isPostCode', 'size' => 12),
|
||||
'city' => array('type' => self::TYPE_STRING, 'validate' => 'isCityName', 'required' => true, 'size' => 64),
|
||||
'other' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 300),
|
||||
'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 16),
|
||||
'phone_mobile' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 16),
|
||||
'dni' => array('type' => self::TYPE_STRING, 'validate' => 'isDniLite', 'size' => 16),
|
||||
'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'),
|
||||
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_from_front' => false),
|
||||
'id_manufacturer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_from_front' => false),
|
||||
'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_from_front' => false),
|
||||
'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_from_front' => false),
|
||||
'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true, 'copy_from_front' => true),
|
||||
'id_state' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_from_front' => true),
|
||||
'alias' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32, 'copy_from_front' => true),
|
||||
'company' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 32, 'copy_from_front' => true),
|
||||
'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32, 'copy_from_front' => true),
|
||||
'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32, 'copy_from_front' => true),
|
||||
'vat_number' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'copy_from_front' => true),
|
||||
'address1' => array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'required' => true, 'size' => 128, 'copy_from_front' => true),
|
||||
'address2' => array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'size' => 128, 'copy_from_front' => true),
|
||||
'postcode' => array('type' => self::TYPE_STRING, 'validate' => 'isPostCode', 'size' => 12, 'copy_from_front' => true),
|
||||
'city' => array('type' => self::TYPE_STRING, 'validate' => 'isCityName', 'required' => true, 'size' => 64, 'copy_from_front' => true),
|
||||
'other' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 300, 'copy_from_front' => true),
|
||||
'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 16, 'copy_from_front' => true),
|
||||
'phone_mobile' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 16, 'copy_from_front' => true),
|
||||
'dni' => array('type' => self::TYPE_STRING, 'validate' => 'isDniLite', 'size' => 16, 'copy_from_front' => true),
|
||||
'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_from_front' => false),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'copy_from_front' => false),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'copy_from_front' => false),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
+29
-29
@@ -152,35 +152,35 @@ class CustomerCore extends ObjectModel
|
||||
'table' => 'customer',
|
||||
'primary' => 'id_customer',
|
||||
'fields' => array(
|
||||
'secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5'),
|
||||
'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
|
||||
'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
|
||||
'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128),
|
||||
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 32),
|
||||
'last_passwd_gen' => array('type' => self::TYPE_STRING),
|
||||
'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate'),
|
||||
'newsletter' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'newsletter_date_add' => array('type' => self::TYPE_DATE),
|
||||
'ip_registration_newsletter' => array('type' => self::TYPE_STRING),
|
||||
'optin' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'website' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl'),
|
||||
'company' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
|
||||
'siret' => array('type' => self::TYPE_STRING, 'validate' => 'isSiret'),
|
||||
'ape' => array('type' => self::TYPE_STRING, 'validate' => 'isApe'),
|
||||
'outstanding_allow_amount' => array('type' => self::TYPE_INT, 'validate' => 'isFloat'),
|
||||
'show_public_prices' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'id_risk' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
|
||||
'max_payment_days' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
|
||||
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'note' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 65000),
|
||||
'is_guest' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_group_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_default_group' => array('type' => self::TYPE_INT),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
'secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5', 'copy_from_front' => false),
|
||||
'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32, 'copy_from_front' => true),
|
||||
'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32, 'copy_from_front' => true),
|
||||
'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128, 'copy_from_front' => true),
|
||||
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 32, 'copy_from_front' => true),
|
||||
'last_passwd_gen' => array('type' => self::TYPE_STRING, 'copy_from_front' => false),
|
||||
'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_from_front' => true),
|
||||
'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate', 'copy_from_front' => true),
|
||||
'newsletter' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_from_front' => true),
|
||||
'newsletter_date_add' => array('type' => self::TYPE_DATE,'copy_from_front' => false),
|
||||
'ip_registration_newsletter' => array('type' => self::TYPE_STRING, 'copy_from_front' => false),
|
||||
'optin' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_from_front' => true),
|
||||
'website' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl', 'copy_from_front' => true),
|
||||
'company' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'copy_from_front' => true),
|
||||
'siret' => array('type' => self::TYPE_STRING, 'validate' => 'isSiret', 'copy_from_front' => true),
|
||||
'ape' => array('type' => self::TYPE_STRING, 'validate' => 'isApe', 'copy_from_front' => true),
|
||||
'outstanding_allow_amount' => array('type' => self::TYPE_INT, 'validate' => 'isFloat', 'copy_from_front' => false),
|
||||
'show_public_prices' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_from_front' => false),
|
||||
'id_risk' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_from_front' => false),
|
||||
'max_payment_days' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_from_front' => false),
|
||||
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_from_front' => false),
|
||||
'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_from_front' => false),
|
||||
'note' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 65000, 'copy_from_front' => false),
|
||||
'is_guest' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_from_front' => false),
|
||||
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_from_front' => false),
|
||||
'id_group_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_from_front' => false),
|
||||
'id_default_group' => array('type' => self::TYPE_INT, 'copy_from_front' => false),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_from_front' => false),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_from_front' => false),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
+15
-18
@@ -759,27 +759,24 @@ abstract class ObjectModelCore
|
||||
public function validateController($htmlentities = true)
|
||||
{
|
||||
$errors = array();
|
||||
|
||||
/* Checking for required fields */
|
||||
$fieldsRequired = array_merge($this->fieldsRequired, (isset(self::$fieldsRequiredDatabase[get_class($this)]) ? self::$fieldsRequiredDatabase[get_class($this)] : array()));
|
||||
foreach ($fieldsRequired AS $field)
|
||||
if (($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0')
|
||||
if (!$this->id OR $field != 'passwd')
|
||||
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.');
|
||||
|
||||
|
||||
/* Checking for maximum fields sizes */
|
||||
foreach ($this->fieldsSize AS $field => $maxLength)
|
||||
if (($value = Tools::getValue($field, $this->{$field})) && Tools::strlen($value) > $maxLength)
|
||||
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is too long.').' ('.Tools::displayError('Maximum length:').' '.$maxLength.')';
|
||||
|
||||
/* Checking for fields validity */
|
||||
foreach ($this->fieldsValidate AS $field => $function)
|
||||
foreach ($this->def['fields'] as $field => $data)
|
||||
{
|
||||
if (!isset($data['copy_from_front']) || !$data['copy_from_front'])
|
||||
continue;
|
||||
/* Checking for required fields */
|
||||
if (isset($data['required']) && $data['required'] && ($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0')
|
||||
if (!$this->id OR $field != 'passwd')
|
||||
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.');
|
||||
|
||||
/* Checking for maximum fields sizes */
|
||||
if (isset($data['size']) && ($value = Tools::getValue($field, $this->{$field})) && Tools::strlen($value) > $data['size'])
|
||||
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is too long.').' ('.Tools::displayError('Maximum length:').' '.$data['size'].')';
|
||||
|
||||
/* Checking for fields validity */
|
||||
// Hack for postcode required for country which does not have postcodes
|
||||
if ($value = Tools::getValue($field, $this->{$field}) OR ($field == 'postcode' AND $value == '0'))
|
||||
{
|
||||
if (!Validate::$function($value) && (!empty($value) || in_array($field, $this->fieldsRequired)))
|
||||
if (isset($data['validate']) && !Validate::$data['validate']($value) && (!empty($value) || $data['required']))
|
||||
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.');
|
||||
else
|
||||
{
|
||||
@@ -1270,4 +1267,4 @@ abstract class ObjectModelCore
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,27 +44,6 @@ class IdentityControllerCore extends FrontController
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if (count($_POST))
|
||||
{
|
||||
$exclusion = array('secure_key',
|
||||
'old_passwd',
|
||||
'passwd',
|
||||
'active',
|
||||
'date_add',
|
||||
'date_upd',
|
||||
'last_passwd_gen',
|
||||
'newsletter_date_add',
|
||||
'id_default_group',
|
||||
'id_shop',
|
||||
'id_group_shop',
|
||||
'ip_registration_newsletter',
|
||||
'note',
|
||||
'is_guest');
|
||||
$fields = $this->customer->getFields();
|
||||
foreach ($fields as $key => $value)
|
||||
if (!in_array($key, $exclusion))
|
||||
$this->customer->{$key} = key_exists($key, $_POST) ? trim($_POST[$key]) : 0;
|
||||
}
|
||||
|
||||
if (isset($_POST['years']) && isset($_POST['months']) && isset($_POST['days']))
|
||||
$this->customer->birthday = (int)($_POST['years']).'-'.(int)($_POST['months']).'-'.(int)($_POST['days']);
|
||||
|
||||
Reference in New Issue
Block a user