Merge branch 'feature/override_object_model' of gitlab.antadis.net:dev-antadis/bebeboutik into develop
This commit is contained in:
commit
f78296570e
71
override/classes/ObjectModel.php
Normal file
71
override/classes/ObjectModel.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 9535 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
abstract class ObjectModel extends 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 AND (string)$value != '0')
|
||||
if (!$this->id OR $field != 'passwd')
|
||||
$errors[] = '<b>'.static::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})) AND Tools::strlen($value) > $maxLength)
|
||||
$errors[] = '<b>'.static::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)
|
||||
{
|
||||
// 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))
|
||||
$errors[] = '<b>'.static::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.');
|
||||
else
|
||||
{
|
||||
if ($field == 'passwd')
|
||||
{
|
||||
if ($value = Tools::getValue($field))
|
||||
$this->{$field} = Tools::encrypt($value);
|
||||
}
|
||||
else
|
||||
$this->{$field} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user