diff --git a/classes/Address.php b/classes/Address.php index e40e96176..e4502e611 100644 --- a/classes/Address.php +++ b/classes/Address.php @@ -102,10 +102,6 @@ class AddressCore extends ObjectModel protected static $_idZones = array(); protected static $_idCountries = array(); - - - - /** * @see ObjectModel::$definition */ @@ -113,30 +109,31 @@ class AddressCore extends ObjectModel 'table' => 'address', 'primary' => 'id_address', 'fields' => array( - 'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isNullOrUnsignedId'), - 'id_manufacturer' => array('type' => 'FILL_ME', 'validate' => 'isNullOrUnsignedId'), - 'id_supplier' => array('type' => 'FILL_ME', 'validate' => 'isNullOrUnsignedId'), - 'id_warehouse' => array('type' => 'FILL_ME', 'validate' => 'isNullOrUnsignedId'), - 'id_country' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_state' => array('type' => 'FILL_ME', 'validate' => 'isNullOrUnsignedId'), - 'alias' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 32), - 'company' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'size' => 32), - 'lastname' => array('type' => 'FILL_ME', 'validate' => 'isName', 'required' => true, 'size' => 32), - 'vat_number' => array('type' => 'FILL_ME', 'validate' => 'isGenericName'), - 'firstname' => array('type' => 'FILL_ME', 'validate' => 'isName', 'required' => true, 'size' => 32), - 'address1' => array('type' => 'FILL_ME', 'validate' => 'isAddress', 'required' => true, 'size' => 128), - 'address2' => array('type' => 'FILL_ME', 'validate' => 'isAddress', 'size' => 128), - 'postcode' => array('type' => 'FILL_ME', 'validate' => 'isPostCode', 'size' => 12), - 'city' => array('type' => 'FILL_ME', 'validate' => 'isCityName', 'required' => true, 'size' => 64), - 'other' => array('type' => 'FILL_ME', 'validate' => 'isMessage', 'size' => 300), - 'phone' => array('type' => 'FILL_ME', 'validate' => 'isPhoneNumber', 'size' => 16), - 'phone_mobile' => array('type' => 'FILL_ME', 'validate' => 'isPhoneNumber', 'size' => 16), - 'deleted' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'dni' => array('type' => 'FILL_ME', 'validate' => 'isDniLite', 'size' => 16), + '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'), ), ); - protected $_includeVars = array('addressType' => 'table'); protected $_includeContainer = false; @@ -205,31 +202,10 @@ class AddressCore extends ObjectModel public function getFields() { - $this->validateFields(); + $fields = parent::getFields(); if (isset($this->id)) $fields['id_address'] = (int)$this->id; - $fields['id_customer'] = is_null($this->id_customer) ? 0 : (int)$this->id_customer; - $fields['id_manufacturer'] = is_null($this->id_manufacturer) ? 0 : (int)$this->id_manufacturer; - $fields['id_supplier'] = is_null($this->id_supplier) ? 0 : (int)$this->id_supplier; - $fields['id_warehouse'] = is_null($this->id_warehouse) ? 0 : (int)$this->id_warehouse; - $fields['id_country'] = (int)$this->id_country; - $fields['id_state'] = (int)$this->id_state; - $fields['alias'] = pSQL($this->alias); - $fields['company'] = pSQL($this->company); - $fields['lastname'] = pSQL($this->lastname); - $fields['firstname'] = pSQL($this->firstname); - $fields['address1'] = pSQL($this->address1); - $fields['address2'] = pSQL($this->address2); - $fields['postcode'] = pSQL($this->postcode); - $fields['city'] = pSQL($this->city); - $fields['other'] = pSQL($this->other); - $fields['phone'] = pSQL($this->phone); - $fields['phone_mobile'] = pSQL($this->phone_mobile); - $fields['vat_number'] = pSQL($this->vat_number); - $fields['dni'] = pSQL($this->dni); - $fields['deleted'] = (int)$this->deleted; - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); + return $fields; } diff --git a/classes/AddressFormat.php b/classes/AddressFormat.php index 490a9089d..fb77bc30b 100644 --- a/classes/AddressFormat.php +++ b/classes/AddressFormat.php @@ -38,10 +38,6 @@ class AddressFormatCore extends ObjectModel private $_errorFormatList = array(); - - - - /* MySQL does not allow 'order detail' for a table name */ /** * @see ObjectModel::$definition */ @@ -49,11 +45,11 @@ class AddressFormatCore extends ObjectModel 'table' => 'address_format', 'primary' => 'id_country', 'fields' => array( - 'format' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true), + 'format' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true), + 'id_country' => array('type' => self::TYPE_INT), ), ); - public static $requireFormFieldsList = array( 'firstname', 'name', @@ -100,16 +96,6 @@ class AddressFormatCore extends ObjectModel const _CLEANING_REGEX_ = '#([^\w:_]+)#i'; - public function getFields() - { - $this->validateFields(); - - $fields['id_country'] = (int)($this->id_country); - $fields['format'] = pSQL($this->format); - - return $fields; - } - /* * Check if the the association of the field name and a class name * is valide diff --git a/classes/Alias.php b/classes/Alias.php index 2667b3fce..902cf7d4e 100644 --- a/classes/Alias.php +++ b/classes/Alias.php @@ -31,10 +31,6 @@ class AliasCore extends ObjectModel public $search; public $active = true; - - - - /** * @see ObjectModel::$definition */ @@ -42,13 +38,12 @@ class AliasCore extends ObjectModel 'table' => 'alias', 'primary' => 'id_alias', 'fields' => array( - 'search' => array('type' => 'FILL_ME', 'validate' => 'isValidSearch', 'required' => true, 'size' => 255), - 'alias' => array('type' => 'FILL_ME', 'validate' => 'isValidSearch', 'required' => true, 'size' => 255), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'search' => array('type' => self::TYPE_STRING, 'validate' => 'isValidSearch', 'required' => true, 'size' => 255), + 'alias' => array('type' => self::TYPE_STRING, 'validate' => 'isValidSearch', 'required' => true, 'size' => 255), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), ), ); - public function __construct($id = NULL, $alias = NULL, $search = NULL, $id_lang = NULL) { if ($id) @@ -118,16 +113,6 @@ class AliasCore extends ObjectModel return implode(', ', $aliases); } - public function getFields() - { - $this->validateFields(); - - $fields['alias'] = pSQL($this->alias); - $fields['search'] = pSQL($this->search); - $fields['active'] = (int)$this->active; - return $fields; - } - /** * This method is allow to know if a feature is used or active * @since 1.5.0.1 diff --git a/classes/Attachment.php b/classes/Attachment.php index c1f116434..59739f4a7 100644 --- a/classes/Attachment.php +++ b/classes/Attachment.php @@ -36,14 +36,6 @@ class AttachmentCore extends ObjectModel /** @var integer position */ public $position; - - - - - - - - /** * @see ObjectModel::$definition */ @@ -52,24 +44,14 @@ class AttachmentCore extends ObjectModel 'primary' => 'id_attachment', 'multilang' => true, 'fields' => array( - 'file' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 40), - 'mime' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'required' => true, 'size' => 128), - 'file_name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'size' => 128), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), - 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCleanHtml'), + 'file' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 40), + 'mime' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 128), + 'file_name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 128), + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), + 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCleanHtml'), ), ); - - public function getFields() - { - $this->validateFields(); - $fields['file_name'] = pSQL($this->file_name); - $fields['file'] = pSQL($this->file); - $fields['mime'] = pSQL($this->mime); - return $fields; - } - public function getTranslationsFieldsChild() { $this->validateFieldsLang(); diff --git a/classes/Attribute.php b/classes/Attribute.php index c93d62dd9..01bd1e7c5 100644 --- a/classes/Attribute.php +++ b/classes/Attribute.php @@ -36,12 +36,6 @@ class AttributeCore extends ObjectModel public $position; public $default; - - - - - - /** * @see ObjectModel::$definition */ @@ -50,10 +44,10 @@ class AttributeCore extends ObjectModel 'primary' => 'id_attribute', 'multilang' => true, 'fields' => array( - 'id_attribute_group' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'color' => array('type' => 'FILL_ME', 'validate' => 'isColor'), - 'position' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), + 'id_attribute_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor'), + 'position' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), ), ); @@ -75,17 +69,6 @@ class AttributeCore extends ObjectModel parent::__construct($id, $id_lang, $id_shop); } - public function getFields() - { - $this->validateFields(); - - $fields['id_attribute_group'] = (int)$this->id_attribute_group; - $fields['color'] = pSQL($this->color); - $fields['position'] = (int)$this->position; - - return $fields; - } - /** * Check then return multilingual fields for database interaction * diff --git a/classes/AttributeGroup.php b/classes/AttributeGroup.php index d8416c494..b999217e7 100644 --- a/classes/AttributeGroup.php +++ b/classes/AttributeGroup.php @@ -36,12 +36,6 @@ class AttributeGroupCore extends ObjectModel /** @var string Public Name */ public $public_name; - - - - - - /** * @see ObjectModel::$definition */ @@ -50,10 +44,11 @@ class AttributeGroupCore extends ObjectModel 'primary' => 'id_attribute_group', 'multilang' => true, 'fields' => array( - 'is_color_group' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), - 'public_name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), - 'position' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isInt'), + 'is_color_group' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'group_type' => array('type' => self::TYPE_STRING), + 'position' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), + 'public_name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), ), ); @@ -72,17 +67,6 @@ class AttributeGroupCore extends ObjectModel ), ); - public function getFields() - { - $this->validateFields(); - - $fields['is_color_group'] = (int)$this->is_color_group; - $fields['group_type'] = pSQL($this->group_type); - $fields['position'] = (int)$this->position; - - return $fields; - } - public function add($autodate = true, $nullValues = false) { if ($this->position <= 0) diff --git a/classes/CMS.php b/classes/CMS.php index d13f4c44b..80dbad16d 100644 --- a/classes/CMS.php +++ b/classes/CMS.php @@ -37,11 +37,6 @@ class CMSCore extends ObjectModel public $position; public $active; - - - - - /** * @see ObjectModel::$definition */ @@ -50,31 +45,24 @@ class CMSCore extends ObjectModel 'primary' => 'id_cms', 'multilang' => true, 'fields' => array( - 'id_cms_category' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'meta_description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), - 'meta_keywords' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), - 'meta_title' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), - 'link_rewrite' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128), - 'content' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isString', 'size' => 3999999999999), + 'id_cms_category' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'position' => array('type' => self::TYPE_INT), + 'active' => array('type' => self::TYPE_BOOL), + + // Lang fields + 'meta_description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + 'meta_keywords' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + 'meta_title' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), + 'link_rewrite' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128), + 'content' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isString', 'size' => 3999999999999), ), ); - protected $webserviceParameters = array( 'objectNodeName' => 'content', 'objectsNodeName' => 'content_management_system', ); - public function getFields() - { - $this->validateFields(); - $fields['id_cms'] = (int)($this->id); - $fields['id_cms_category'] = (int)($this->id_cms_category); - $fields['position'] = (int)($this->position); - $fields['active'] = (int)($this->active); - return $fields; - } - public function getTranslationsFieldsChild() { $this->validateFieldsLang(); diff --git a/classes/CMSCategory.php b/classes/CMSCategory.php index 2a158f23c..4051f5847 100644 --- a/classes/CMSCategory.php +++ b/classes/CMSCategory.php @@ -70,13 +70,6 @@ class CMSCategoryCore extends ObjectModel protected static $_links = array(); - - - - - - - /** * @see ObjectModel::$definition */ @@ -85,18 +78,23 @@ class CMSCategoryCore extends ObjectModel 'primary' => 'id_cms_category', 'multilang' => true, 'fields' => array( - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true, 'size' => 1), - 'id_parent' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'required' => true, 'size' => 10), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), - 'link_rewrite' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64), - 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCleanHtml'), - 'meta_title' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), - 'meta_description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), - 'meta_keywords' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), + 'id_parent' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), + 'position' => array('type' => self::TYPE_INT), + 'level_depth' => array('type' => self::TYPE_INT), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + + // Lang fields + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), + 'link_rewrite' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64), + 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCleanHtml'), + 'meta_title' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), + 'meta_description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + 'meta_keywords' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), ), ); - public function __construct($id_cms_category = NULL, $id_lang = NULL) { parent::__construct($id_cms_category, $id_lang); @@ -104,15 +102,10 @@ class CMSCategoryCore extends ObjectModel public function getFields() { - $this->validateFields(); + $fields = parent::getFields(); if (isset($this->id)) $fields['id_cms_category'] = (int)($this->id); - $fields['active'] = (int)($this->active); - $fields['id_parent'] = (int)($this->id_parent); - $fields['position'] = (int)($this->position); - $fields['level_depth'] = (int)($this->level_depth); - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); + return $fields; } diff --git a/classes/Carrier.php b/classes/Carrier.php index ec361e9d1..b881f6221 100644 --- a/classes/Carrier.php +++ b/classes/Carrier.php @@ -110,13 +110,6 @@ class CarrierCore extends ObjectModel /** @var int grade of the shipping delay (0 for longest, 9 for shortest) */ public $grade; - - - - - - - /** * @see ObjectModel::$definition */ @@ -126,24 +119,33 @@ class CarrierCore extends ObjectModel 'multilang' => true, 'multishop' => true, 'fields' => array( - 'id_tax_rules_group' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'name' => array('type' => 'FILL_ME', 'validate' => 'isCarrierName', 'required' => true, 'size' => 64), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true), - 'is_free' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'url' => array('type' => 'FILL_ME', 'validate' => 'isAbsoluteUrl'), - 'shipping_handling' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'range_behavior' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'shipping_method' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'max_width' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'max_height' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'max_deep' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'max_weight' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'grade' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'size' => 1), - 'delay' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), + // Classic fields + 'id_reference' => array('type' => self::TYPE_INT), + 'id_tax_rules_group' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isCarrierName', 'required' => true, 'size' => 64), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), + 'is_free' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'url' => array('type' => self::TYPE_STRING, 'validate' => 'isAbsoluteUrl'), + 'shipping_handling' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'shipping_external' => array('type' => self::TYPE_BOOL), + 'range_behavior' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'shipping_method' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'max_width' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'max_height' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'max_deep' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'max_weight' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'grade' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'size' => 1), + 'external_module_name' => array('type' => self::TYPE_STRING, 'size' => 64), + 'is_module' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'need_range' => array('type' => self::TYPE_BOOL), + 'position' => array('type' => self::TYPE_INT), + 'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + + // Lang fields + 'delay' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), ), ); - protected static $price_by_weight = array(); protected static $price_by_weight2 = array(); protected static $price_by_price = array(); @@ -159,32 +161,6 @@ class CarrierCore extends ObjectModel ), ); - public function getFields() - { - $this->validateFields(); - $fields['id_tax_rules_group'] = (int)$this->id_tax_rules_group; - $fields['name'] = pSQL($this->name); - $fields['url'] = pSQL($this->url); - $fields['active'] = (int)$this->active; - $fields['deleted'] = (int)$this->deleted; - $fields['shipping_handling'] = (int)$this->shipping_handling; - $fields['range_behavior'] = (int)$this->range_behavior; - $fields['shipping_method'] = (int)$this->shipping_method; - $fields['is_module'] = (int)$this->is_module; - $fields['is_free'] = (int)$this->is_free; - $fields['shipping_external'] = (int)$this->shipping_external; - $fields['external_module_name'] = $this->external_module_name; - $fields['need_range'] = $this->need_range; - $fields['position'] = (int)$this->position; - $fields['id_reference'] = (int)$this->id_reference; - $fields['max_width'] = (int)$this->max_width; - $fields['max_height'] = (int)$this->max_height; - $fields['max_depth'] = (int)$this->max_depth; - $fields['max_weight'] = (int)$this->max_weight; - $fields['grade'] = (int)$this->grade; - return $fields; - } - public function __construct($id = null, $id_lang = null) { parent::__construct($id, $id_lang); diff --git a/classes/Cart.php b/classes/Cart.php index fa70a2acc..3c4f80e87 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -101,21 +101,26 @@ class CartCore extends ObjectModel 'table' => 'cart', 'primary' => 'id_cart', 'fields' => array( - 'id_address_delivery' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_carrier' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_address_invoice' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_guest' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_lang' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'recyclable' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'gift' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'gift_message' => array('type' => 'FILL_ME', 'validate' => 'isMessage'), - 'allow_seperated_package' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'id_group_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_address_delivery' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_address_invoice' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'recyclable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'gift' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'gift_message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage'), + 'delivery_option' => array('type' => self::TYPE_STRING), + 'secure_key' => array('type' => self::TYPE_STRING, 'size' => 32), + 'allow_seperated_package' =>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'), ), ); - protected $webserviceParameters = array( 'fields' => array( 'id_address_delivery' => array('xlink_resource' => 'addresses'), @@ -143,32 +148,6 @@ class CartCore extends ObjectModel const ONLY_WRAPPING = 6; const ONLY_PRODUCTS_WITHOUT_SHIPPING = 7; - public function getFields() - { - $this->validateFields(); - - $fields['id_group_shop'] = (int)$this->id_group_shop; - $fields['id_shop'] = (int)$this->id_shop; - - $fields['id_address_delivery'] = (int)$this->id_address_delivery; - $fields['id_address_invoice'] = (int)$this->id_address_invoice; - $fields['id_currency'] = (int)$this->id_currency; - $fields['id_customer'] = (int)$this->id_customer; - $fields['id_carrier'] = (int)$this->id_carrier; - $fields['id_guest'] = (int)$this->id_guest; - $fields['id_lang'] = (int)$this->id_lang; - $fields['recyclable'] = (int)$this->recyclable; - $fields['gift'] = (int)$this->gift; - $fields['secure_key'] = pSQL($this->secure_key); - $fields['gift_message'] = pSQL($this->gift_message); - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - $fields['allow_seperated_package'] = (int)$this->allow_seperated_package; - $fields['delivery_option'] = $this->delivery_option; - - return $fields; - } - public function __construct($id = null, $id_lang = null) { parent::__construct($id, $id_lang); diff --git a/classes/CartRule.php b/classes/CartRule.php index ba7d52a6b..131694559 100644 --- a/classes/CartRule.php +++ b/classes/CartRule.php @@ -65,78 +65,39 @@ class CartRuleCore extends ObjectModel 'primary' => 'id_cart_rule', 'multilang' => true, 'fields' => array( - 'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'date_from' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'required' => true), - 'date_to' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'required' => true), - 'description' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'size' => 65534), - 'quantity' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'quantity_per_user' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'priority' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'code' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'size' => 254), - 'minimum_amount' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'minimum_amount_tax' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'minimum_amount_currency' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'minimum_amount_shipping' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'country_restriction' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'carrier_restriction' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'group_restriction' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'cart_rule_restriction' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'product_restriction' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'free_shipping' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'reduction_percent' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'reduction_amount' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'reduction_tax' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'reduction_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'reduction_product' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'gift_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'date_add' => array('type' => 'FILL_ME', 'validate' => 'isDate'), - 'date_upd' => array('type' => 'FILL_ME', 'validate' => 'isDate'), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 254), + 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'date_from' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true), + 'date_to' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true), + 'description' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 65534), + 'quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'quantity_per_user' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'priority' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'code' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 254), + 'minimum_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'minimum_amount_tax' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'minimum_amount_currency' =>array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'minimum_amount_shipping' =>array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'country_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'carrier_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'group_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'cart_rule_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'product_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'free_shipping' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'reduction_percent' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'reduction_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'reduction_tax' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'reduction_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'reduction_product' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'gift_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + + // Lang fields + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 254), ), ); - - - - - - - - - public function getFields() - { - $this->validateFields(); - $fields['id_customer'] = (int)$this->id_customer; - $fields['priority'] = (int)$this->priority; - $fields['code'] = pSQL($this->code); - $fields['quantity'] = (int)$this->quantity; - $fields['quantity_per_user'] = (int)$this->quantity_per_user; - $fields['date_from'] = pSQL($this->date_from); - $fields['date_to'] = pSQL($this->date_to); - $fields['description'] = pSQL($this->description); - $fields['minimum_amount'] = (float)$this->minimum_amount; - $fields['minimum_amount_tax'] = (int)$this->minimum_amount_tax; - $fields['minimum_amount_currency'] = (int)$this->minimum_amount_currency; - $fields['minimum_amount_shipping'] = (int)$this->minimum_amount_shipping; - $fields['country_restriction'] = (int)$this->country_restriction; - $fields['carrier_restriction'] = (int)$this->carrier_restriction; - $fields['group_restriction'] = (int)$this->group_restriction; - $fields['cart_rule_restriction'] = (int)$this->cart_rule_restriction; - $fields['product_restriction'] = (int)$this->product_restriction; - $fields['free_shipping'] = (int)$this->free_shipping; - $fields['reduction_percent'] = (float)$this->reduction_percent; - $fields['reduction_amount'] = (float)$this->reduction_amount; - $fields['reduction_tax'] = (int)$this->reduction_tax; - $fields['reduction_currency'] = (int)$this->reduction_currency; - $fields['reduction_product'] = (int)$this->reduction_product; - $fields['gift_product'] = (int)$this->gift_product; - $fields['active'] = (int)$this->active; - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - return $fields; - } - public function getTranslationsFieldsChild() { if (!$this->validateFieldsLang()) diff --git a/classes/Category.php b/classes/Category.php index 90355df8f..9d9d5df25 100644 --- a/classes/Category.php +++ b/classes/Category.php @@ -78,13 +78,6 @@ class CategoryCore extends ObjectModel protected static $_links = array(); - - - - - - - /** * @see ObjectModel::$definition */ @@ -94,22 +87,25 @@ class CategoryCore extends ObjectModel 'multilang' => true, 'multishop' => true, 'fields' => array( - 'nleft' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'nright' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'level_depth' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true, 'size' => 1), - 'id_parent' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'groupBox' => array('type' => 'FILL_ME', 'validate' => 'isArrayWithIds'), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), - 'link_rewrite' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64), - 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isString'), - 'meta_title' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), - 'meta_description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), - 'meta_keywords' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + 'nleft' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'nright' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'level_depth' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true, 'size' => 1), + 'id_parent' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'position' => array('type' => self::TYPE_INT), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + + // Lang fields + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), + 'link_rewrite' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64), + 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isString'), + 'meta_title' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), + 'meta_description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + 'meta_keywords' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), ), ); - /** @var string id_image is the category ID when an image exists and 'default' otherwise */ public $id_image = 'default'; @@ -136,17 +132,10 @@ class CategoryCore extends ObjectModel public function getFields() { - $this->validateFields(); + $fields = parent::getFields(); if (isset($this->id)) $fields['id_category'] = (int)$this->id; - $fields['active'] = (int)$this->active; - $fields['id_parent'] = (int)$this->id_parent; - $fields['position'] = (int)$this->position; - $fields['level_depth'] = (int)$this->level_depth; - $fields['nleft'] = (int)$this->nleft; - $fields['nright'] = (int)$this->nright; - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); + return $fields; } diff --git a/classes/Combination.php b/classes/Combination.php index c875602d4..d089101bf 100644 --- a/classes/Combination.php +++ b/classes/Combination.php @@ -53,10 +53,6 @@ class CombinationCore extends ObjectModel public $available_date; - - - - /** * @see ObjectModel::$definition */ @@ -64,23 +60,22 @@ class CombinationCore extends ObjectModel 'table' => 'product_attribute', 'primary' => 'id_product_attribute', 'fields' => array( - 'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'location' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'size' => 64), - 'ean13' => array('type' => 'FILL_ME', 'validate' => 'isEan13', 'size' => 13), - 'upc' => array('type' => 'FILL_ME', 'validate' => 'isUpc', 'size' => 12), - 'wholesale_price' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'size' => 27), - 'price' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'size' => 20), - 'ecotax' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'size' => 20), - 'quantity' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'size' => 10), - 'weight' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'default_on' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'available_date' => array('type' => 'FILL_ME', 'validate' => 'isDateFormat'), - 'reference' => array('type' => 'FILL_ME', 'size' => 32), - 'supplier_reference' => array('type' => 'FILL_ME', 'size' => 32), + 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'location' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 64), + 'ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isEan13', 'size' => 13), + 'upc' => array('type' => self::TYPE_STRING, 'validate' => 'isUpc', 'size' => 12), + 'wholesale_price' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'size' => 27), + 'price' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'size' => 20), + 'ecotax' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'size' => 20), + 'quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'size' => 10), + 'weight' => array('type' => self::TYPE_INT, 'validate' => 'isFloat'), + 'default_on' => array('type' => self::TYPE_INT, 'validate' => 'isBool'), + 'available_date' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'), + 'reference' => array('type' => self::TYPE_STRING, 'size' => 32), + 'supplier_reference' => array('type' => self::TYPE_STRING, 'size' => 32), ), ); - protected $webserviceParameters = array( 'objectNodeName' => 'combination', 'objectsNodeName' => 'combinations', @@ -93,25 +88,6 @@ class CombinationCore extends ObjectModel ), ); - public function getFields() - { - $this->validateFields(); - $fields['id_product'] = (int)($this->id_product); - $fields['reference'] = pSQL($this->reference); - $fields['supplier_reference'] = pSQL($this->supplier_reference); - $fields['location'] = pSQL($this->location); - $fields['ean13'] = pSQL($this->ean13); - $fields['upc'] = pSQL($this->upc); - $fields['wholesale_price'] = pSQL($this->wholesale_price); - $fields['price'] = pSQL($this->price); - $fields['ecotax'] = pSQL($this->ecotax); - $fields['quantity'] = (int)($this->quantity); - $fields['weight'] = pSQL($this->weight); - $fields['default_on'] = (int)($this->default_on); - $fields['available_date'] = pSQL($this->available_date); - return $fields; - } - public function delete() { if (!parent::delete() OR $this->deleteAssociations() === false)