diff --git a/classes/CompareProduct.php b/classes/CompareProduct.php index c9a82ba39..f5515512e 100644 --- a/classes/CompareProduct.php +++ b/classes/CompareProduct.php @@ -35,27 +35,20 @@ class CompareProductCore extends ObjectModel public $date_upd; - protected $fieldRequired = array( - 'id_compare', - 'id_customer'); - - - - /** - * @see ObjectModel::$definition - */ - public static $definition = array( - 'table' => 'compare', - 'primary' => 'id_compare', - 'fields' => array( - 'id_compare' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - ), - ); - + /** + * @see ObjectModel::$definition + */ + public static $definition = array( + 'table' => 'compare', + 'primary' => 'id_compare', + 'fields' => array( + 'id_compare' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), + 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), + ), + ); /** - * Get all comapare products of the customer + * Get all compare products of the customer * @param int $id_customer * @return array */ @@ -70,8 +63,8 @@ class CompareProductCore extends ObjectModel $compareProducts = null; if ($results) - foreach($results as $result) - $compareProducts[] = $result['id_product']; + foreach($results as $result) + $compareProducts[] = $result['id_product']; return $compareProducts; } @@ -97,6 +90,7 @@ class CompareProductCore extends ObjectModel Context::getContext()->cookie->id_compare = $id_compare; } } + return Db::getInstance()->execute(' INSERT INTO `'._DB_PREFIX_.'compare_product` (`id_compare`, `id_product`, `date_add`, `date_upd`) VALUES ('.(int)($id_compare).', '.(int)($id_product).', NOW(), NOW())'); @@ -104,7 +98,8 @@ class CompareProductCore extends ObjectModel /** * Remove a compare product for the customer - * @param int $id_compare, int $id_product + * @param int $id_compare + * @param int $id_product * @return boolean */ public static function removeCompareProduct($id_compare, $id_product) diff --git a/classes/Configuration.php b/classes/Configuration.php index 0aa22388b..7e5d700e1 100644 --- a/classes/Configuration.php +++ b/classes/Configuration.php @@ -44,10 +44,6 @@ class ConfigurationCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - - - - /** * @see ObjectModel::$definition */ @@ -56,13 +52,15 @@ class ConfigurationCore extends ObjectModel 'primary' => 'id_configuration', 'multilang' => true, 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'validate' => 'isConfigName', 'required' => true, 'size' => 32), - 'id_group_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isConfigName', 'required' => true, 'size' => 32), + 'id_group_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'value' => array('type' => self::TYPE_STRING), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - /** @var array Configuration cache */ protected static $_CONF; @@ -75,18 +73,6 @@ class ConfigurationCore extends ObjectModel ) ); - public function getFields() - { - $this->validateFields(); - $fields['name'] = pSQL($this->name); - $fields['id_group_shop'] = $this->id_group_shop; - $fields['id_shop'] = $this->id_shop; - $fields['value'] = pSQL($this->value); - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - return $fields; - } - /** * Check then return multilingual fields for database interaction * diff --git a/classes/Connection.php b/classes/Connection.php index b25be06c5..86f6d8310 100644 --- a/classes/Connection.php +++ b/classes/Connection.php @@ -48,10 +48,6 @@ class ConnectionCore extends ObjectModel /** @var string */ public $date_add; - - - - /* MySQL does not allow 'connection' for a table name */ /** * @see ObjectModel::$definition */ @@ -59,16 +55,19 @@ class ConnectionCore extends ObjectModel 'table' => 'connections', 'primary' => 'id_connections', 'fields' => array( - 'id_guest' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_page' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'ip_address' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'http_referer' => array('type' => 'FILL_ME', 'validate' => 'isAbsoluteUrl'), - 'id_shop' => array('type' => 'FILL_ME', 'required' => true), - 'id_group_shop' => array('type' => 'FILL_ME', 'required' => true), + 'id_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_page' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'ip_address' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'http_referer' => array('type' => self::TYPE_STRING, 'validate' => 'isAbsoluteUrl'), + 'id_shop' => array('type' => self::TYPE_INT, 'required' => true), + 'id_group_shop' => array('type' => self::TYPE_INT, 'required' => true), ), ); - + /** + * @see ObjectModel::getFields() + * @return array + */ public function getFields() { if (!$this->id_shop) @@ -76,15 +75,7 @@ class ConnectionCore extends ObjectModel if (!$this->id_group_shop) $this->id_group_shop = Context::getContext()->shop->getGroupID(); - $this->validateFields(); - $fields['id_guest'] = (int)($this->id_guest); - $fields['id_page'] = (int)($this->id_page); - $fields['ip_address'] = (int)($this->ip_address); - if (Validate::isAbsoluteUrl($this->http_referer)) - $fields['http_referer'] = pSQL($this->http_referer); - $fields['date_add'] = pSQL($this->date_add); - $fields['id_shop'] = (int)$this->id_shop; - $fields['id_group_shop'] = (int)$this->id_group_shop; + $fields = parent::getFields(); return $fields; } diff --git a/classes/ConnectionsSource.php b/classes/ConnectionsSource.php index 8a661545a..56c494989 100644 --- a/classes/ConnectionsSource.php +++ b/classes/ConnectionsSource.php @@ -33,11 +33,6 @@ class ConnectionsSourceCore extends ObjectModel public $keywords; public $date_add; - // Controler les keywords - - - - /** * @see ObjectModel::$definition */ @@ -45,26 +40,14 @@ class ConnectionsSourceCore extends ObjectModel 'table' => 'connections_source', 'primary' => 'id_connections_source', 'fields' => array( - 'id_connections' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'http_referer' => array('type' => 'FILL_ME', 'validate' => 'isAbsoluteUrl'), - 'request_uri' => array('type' => 'FILL_ME', 'validate' => 'isUrl'), - 'keywords' => array('type' => 'FILL_ME', 'validate' => 'isMessage'), - 'date_add' => array('type' => 'FILL_ME', 'required' => true), + 'id_connections' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'http_referer' => array('type' => self::TYPE_STRING, 'validate' => 'isAbsoluteUrl'), + 'request_uri' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl'), + 'keywords' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true), ), ); - - public function getFields() - { - $this->validateFields(); - $fields['id_connections'] = (int)($this->id_connections); - $fields['http_referer'] = pSQL($this->http_referer); - $fields['request_uri'] = pSQL($this->request_uri); - $fields['keywords'] = pSQL($this->keywords); - $fields['date_add'] = pSQL($this->date_add); - return $fields; - } - public function add($autodate = true, $nullValues = false) { if ($result = parent::add($autodate, $nullValues)) diff --git a/classes/Contact.php b/classes/Contact.php index 8c092c500..7975fa602 100644 --- a/classes/Contact.php +++ b/classes/Contact.php @@ -40,13 +40,6 @@ class ContactCore extends ObjectModel public $customer_service; - - - - - - - /** * @see ObjectModel::$definition */ @@ -55,22 +48,15 @@ class ContactCore extends ObjectModel 'primary' => 'id_contact', 'multilang' => true, 'fields' => array( - 'email' => array('type' => 'FILL_ME', 'validate' => 'isEmail', 'size' => 128), - 'customer_service' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), - 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCleanHtml'), + 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 128), + 'customer_service' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + + // Lang fields + '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['email'] = pSQL($this->email); - $fields['customer_service'] = (int)$this->customer_service; - return $fields; - } - /** * Check then return multilingual fields for database interaction * diff --git a/classes/Country.php b/classes/Country.php index 60906c492..1d3956981 100644 --- a/classes/Country.php +++ b/classes/Country.php @@ -64,22 +64,6 @@ class CountryCore extends ObjectModel protected static $_idZones = array(); - - - - - - - - - protected $webserviceParameters = array( - 'objectsNodeName' => 'countries', - 'fields' => array( - 'id_zone' => array('sqlId' => 'id_zone', 'xlink_resource'=> 'zones'), - 'id_currency' => array('sqlId' => 'id_currency', 'xlink_resource'=> 'currencies'), - ), - ); - /** * @see ObjectModel::$definition */ @@ -88,36 +72,29 @@ class CountryCore extends ObjectModel 'primary' => 'id_country', 'multilang' => true, 'fields' => array( - 'id_zone' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'call_prefix' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'iso_code' => array('type' => 'FILL_ME', 'validate' => 'isLanguageIsoCode', 'required' => true, 'size' => 3), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'contains_states' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true), - 'need_identification_number' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true), - 'need_zip_code' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'zip_code_format' => array('type' => 'FILL_ME', 'validate' => 'isZipCodeFormat'), - 'display_tax_label' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), + 'id_zone' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'call_prefix' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'iso_code' => array('type' => self::TYPE_STRING, 'validate' => 'isLanguageIsoCode', 'required' => true, 'size' => 3), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'contains_states' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), + 'need_identification_number' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), + 'need_zip_code' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'zip_code_format' => array('type' => self::TYPE_STRING, 'validate' => 'isZipCodeFormat'), + 'display_tax_label' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), + + // Lang fields + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), ), ); - - public function getFields() - { - $this->validateFields(); - $fields['id_zone'] = (int)$this->id_zone; - $fields['id_currency'] = (int)$this->id_currency; - $fields['iso_code'] = pSQL(strtoupper($this->iso_code)); - $fields['call_prefix'] = (int)$this->call_prefix; - $fields['active'] = (int)$this->active; - $fields['contains_states'] = (int)$this->contains_states; - $fields['need_identification_number'] = (int)$this->need_identification_number; - $fields['need_zip_code'] = (int)$this->need_zip_code; - $fields['zip_code_format'] = $this->zip_code_format; - $fields['display_tax_label'] = $this->display_tax_label; - return $fields; - } + protected $webserviceParameters = array( + 'objectsNodeName' => 'countries', + 'fields' => array( + 'id_zone' => array('sqlId' => 'id_zone', 'xlink_resource'=> 'zones'), + 'id_currency' => array('sqlId' => 'id_currency', 'xlink_resource'=> 'currencies'), + ), + ); /** * Check then return multilingual fields for database interaction diff --git a/classes/County.php b/classes/County.php index 1faa5ccbb..94120cfce 100644 --- a/classes/County.php +++ b/classes/County.php @@ -36,10 +36,6 @@ class CountyCore extends ObjectModel public $id_state; public $active; - - - - /** * @see ObjectModel::$definition */ @@ -47,13 +43,12 @@ class CountyCore extends ObjectModel 'table' => 'county', 'primary' => 'id_county', 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 64), - 'id_state' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), + 'id_state' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), ), ); - private static $_cache_get_counties = array(); private static $_cache_county_zipcode = array(); @@ -67,15 +62,6 @@ class CountyCore extends ObjectModel ), ); - public function getFields() - { - $this->validateFields(); - $fields['id_state'] = (int)($this->id_state); - $fields['name'] = pSQL($this->name); - $fields['active'] = (int)($this->active); - return $fields; - } - public function delete() { return true; diff --git a/classes/Currency.php b/classes/Currency.php index 711632486..19eada4e4 100644 --- a/classes/Currency.php +++ b/classes/Currency.php @@ -59,10 +59,6 @@ class CurrencyCore extends ObjectModel /** @var int bool active */ public $active; - - - - /** * @see ObjectModel::$definition */ @@ -71,20 +67,19 @@ class CurrencyCore extends ObjectModel 'primary' => 'id_currency', 'multilang' => true, 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 32), - 'iso_code' => array('type' => 'FILL_ME', 'validate' => 'isLanguageIsoCode', 'required' => true, 'size' => 3), - 'iso_code_num' => array('type' => 'FILL_ME', 'validate' => 'isNumericIsoCode', 'size' => 3), - 'blank' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'sign' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 8), - 'format' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'decimals' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true), - 'conversion_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true), - 'deleted' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), + 'iso_code' => array('type' => self::TYPE_STRING, 'validate' => 'isLanguageIsoCode', 'required' => true, 'size' => 3), + 'iso_code_num' => array('type' => self::TYPE_STRING, 'validate' => 'isNumericIsoCode', 'size' => 3), + 'blank' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'sign' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 8), + 'format' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'decimals' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), + 'conversion_rate' =>array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true), + 'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), ), ); - /** @var array Currency cache */ static protected $currencies = array(); @@ -142,23 +137,6 @@ class CurrencyCore extends ObjectModel return false; } } - public function getFields() - { - $this->validateFields(); - - $fields['name'] = pSQL($this->name); - $fields['iso_code'] = pSQL($this->iso_code); - $fields['iso_code_num'] = pSQL($this->iso_code_num); - $fields['sign'] = pSQL($this->sign); - $fields['format'] = (int)($this->format); - $fields['decimals'] = (int)($this->decimals); - $fields['blank'] = (int)($this->blank); - $fields['conversion_rate'] = (float)($this->conversion_rate); - $fields['deleted'] = (int)($this->deleted); - $fields['active'] = (int)($this->active); - - return $fields; - } public function deleteSelection($selection) { diff --git a/classes/Customer.php b/classes/Customer.php index 620408b63..a610b1777 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -109,10 +109,6 @@ class CustomerCore extends ObjectModel public $groupBox; - - - - protected $webserviceParameters = array( 'fields' => array( 'id_default_group' => array('xlink_resource' => 'groups'), @@ -132,56 +128,44 @@ class CustomerCore extends ObjectModel 'table' => 'customer', 'primary' => 'id_customer', 'fields' => array( - 'secure_key' => array('type' => 'FILL_ME', 'validate' => 'isMd5'), - 'lastname' => array('type' => 'FILL_ME', 'validate' => 'isName', 'required' => true, 'size' => 32), - 'firstname' => array('type' => 'FILL_ME', 'validate' => 'isName', 'required' => true, 'size' => 32), - 'email' => array('type' => 'FILL_ME', 'validate' => 'isEmail', 'required' => true, 'size' => 128), - 'passwd' => array('type' => 'FILL_ME', 'validate' => 'isPasswd', 'required' => true, 'size' => 32), - 'id_gender' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'birthday' => array('type' => 'FILL_ME', 'validate' => 'isBirthDate'), - 'newsletter' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'optin' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'note' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'size' => 65000), - 'is_guest' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'id_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_group_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'groupBox' => array('type' => 'FILL_ME', 'validate' => 'isArrayWithIds'), + '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'), + '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'), ), ); - protected static $_defaultGroupId = array(); protected static $_customerHasAddress = array(); protected static $_customer_groups = array(); + /** + * @see ObjectModel::getFields() + * @return array + */ public function getFields() { - $this->validateFields(); + $fields = parent::getFields(); if (isset($this->id)) $fields['id_customer'] = (int)$this->id; - $fields['id_shop'] = (int)$this->id_shop; - $fields['id_group_shop'] = (int)$this->id_group_shop; - $fields['secure_key'] = pSQL($this->secure_key); - $fields['note'] = pSQL($this->note, true); - $fields['id_gender'] = (int)$this->id_gender; - $fields['id_default_group'] = (int)$this->id_default_group; - $fields['lastname'] = pSQL($this->lastname); - $fields['firstname'] = pSQL($this->firstname); - $fields['birthday'] = pSQL($this->birthday); - $fields['email'] = pSQL($this->email); - $fields['newsletter'] = (int)$this->newsletter; - $fields['newsletter_date_add'] = pSQL($this->newsletter_date_add); - $fields['ip_registration_newsletter'] = pSQL($this->ip_registration_newsletter); - $fields['optin'] = (int)$this->optin; - $fields['passwd'] = pSQL($this->passwd); - $fields['last_passwd_gen'] = pSQL($this->last_passwd_gen); - $fields['active'] = (int)$this->active; - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - $fields['is_guest'] = (int)$this->is_guest; - $fields['deleted'] = (int)$this->deleted; return $fields; } diff --git a/classes/CustomerMessage.php b/classes/CustomerMessage.php index 853641957..e37efb1f0 100644 --- a/classes/CustomerMessage.php +++ b/classes/CustomerMessage.php @@ -44,31 +44,17 @@ class CustomerMessageCore extends ObjectModel 'table' => 'customer_message', 'primary' => 'id_customer_message', 'fields' => array( - 'message' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'required' => true, 'size' => 65000), - 'id_employee' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'ip_address' => array('type' => 'FILL_ME', 'validate' => 'isIp2Long'), + 'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_customer_thread' => array('type' => self::TYPE_INT), + 'ip_address' => array('type' => self::TYPE_INT, 'validate' => 'isIp2Long'), + 'message' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 65000), + 'file_name' => array('type' => self::TYPE_STRING), + 'user_agent' => array('type' => self::TYPE_STRING), + 'private' => array('type' => self::TYPE_STRING), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - - - - - - public function getFields() - { - $this->validateFields(); - $fields['id_customer_thread'] = (int)$this->id_customer_thread; - $fields['id_employee'] = (int)$this->id_employee; - $fields['message'] = pSQL($this->message); - $fields['file_name'] = pSQL($this->file_name); - $fields['ip_address'] = (int)$this->ip_address; - $fields['user_agent'] = pSQL($this->user_agent); - $fields['private'] = pSQL($this->private); - $fields['date_add'] = pSQL($this->date_add); - return $fields; - } - public static function getMessagesByOrderId($id_order, $private = true) { return Db::getInstance()->executeS(' diff --git a/classes/CustomerThread.php b/classes/CustomerThread.php index 3a32c783f..8051a91b4 100644 --- a/classes/CustomerThread.php +++ b/classes/CustomerThread.php @@ -47,40 +47,20 @@ class CustomerThreadCore extends ObjectModel 'table' => 'customer_thread', 'primary' => 'id_customer_thread', 'fields' => array( - 'id_lang' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_contact' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'email' => array('type' => 'FILL_ME', 'validate' => 'isEmail', 'size' => 254), - 'token' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true), + 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_contact' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_customer' =>array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 254), + 'token' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true), + 'status' => array('type' => self::TYPE_STRING), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - - - - - - - public function getFields() - { - $this->validateFields(); - $fields['id_lang'] = (int)$this->id_lang; - $fields['id_shop'] = (int)$this->id_shop; - $fields['id_contact'] = (int)$this->id_contact; - $fields['id_customer'] = (int)$this->id_customer; - $fields['id_order'] = (int)$this->id_order; - $fields['id_product'] = (int)$this->id_product; - $fields['status'] = pSQL($this->status); - $fields['email'] = pSQL($this->email); - $fields['token'] = pSQL($this->token); - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - return $fields; - } - public function delete() { if (!Validate::isUnsignedId($this->id)) diff --git a/classes/DateRange.php b/classes/DateRange.php index f7c88d5ef..35f5982df 100644 --- a/classes/DateRange.php +++ b/classes/DateRange.php @@ -30,9 +30,6 @@ class DateRangeCore extends ObjectModel public $time_start; public $time_end; - - - /** * @see ObjectModel::$definition */ @@ -40,20 +37,11 @@ class DateRangeCore extends ObjectModel 'table' => 'date_range', 'primary' => 'id_date_range', 'fields' => array( - 'time_start' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'required' => true), - 'time_end' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'required' => true), + 'time_start' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true), + 'time_end' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true), ), ); - - public function getFields() - { - $this->validateFields(); - $fields['time_start'] = pSQL($this->time_start); - $fields['time_end'] = pSQL($this->time_end); - return $fields; - } - public static function getCurrentRange() { $result = Db::getInstance()->getRow(' diff --git a/classes/Delivery.php b/classes/Delivery.php index 34fa79bee..88741e695 100644 --- a/classes/Delivery.php +++ b/classes/Delivery.php @@ -51,10 +51,6 @@ class DeliveryCore extends ObjectModel /** @var float */ public $price; - - - - /** * @see ObjectModel::$definition */ @@ -62,38 +58,35 @@ class DeliveryCore extends ObjectModel 'table' => 'delivery', 'primary' => 'id_delivery', 'fields' => array( - 'id_carrier' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_range_price' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_range_weight' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_zone' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'price' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), + 'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_range_price' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_range_weight' =>array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_zone' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_shop' => array('type' => self::TYPE_INT), + 'id_group_shop' => array('type' => self::TYPE_INT), + 'price' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true), ), ); - protected $webserviceParameters = array( - 'objectsNodeName' => 'deliveries', - 'fields' => array( - 'id_carrier' => array('xlink_resource' => 'carriers'), - 'id_range_price' => array('xlink_resource' => 'price_ranges'), - 'id_range_weight' => array('xlink_resource' => 'weight_ranges'), - 'id_zone' => array('xlink_resource' => 'zones'), + 'objectsNodeName' => 'deliveries', + 'fields' => array( + 'id_carrier' => array('xlink_resource' => 'carriers'), + 'id_range_price' => array('xlink_resource' => 'price_ranges'), + 'id_range_weight' => array('xlink_resource' => 'weight_ranges'), + 'id_zone' => array('xlink_resource' => 'zones'), ) ); public function getFields() { - $this->validateFields(); + $fields = parent::getFields(); + // @todo add null management in definitions if ($this->id_shop) $fields['id_shop'] = (int)$this->id_shop; if ($this->id_group_shop) $fields['id_group_shop'] = (int)$this->id_group_shop; - $fields['id_carrier'] = (int)$this->id_carrier; - $fields['id_range_price'] = (int)$this->id_range_price; - $fields['id_range_weight'] = (int)$this->id_range_weight; - $fields['id_zone'] = (int)$this->id_zone; - $fields['price'] = (float)$this->price; return $fields; } diff --git a/classes/Employee.php b/classes/Employee.php index fbbb0e874..8b15788f7 100644 --- a/classes/Employee.php +++ b/classes/Employee.php @@ -67,10 +67,6 @@ class EmployeeCore extends ObjectModel public $remote_addr; - - - - /** * @see ObjectModel::$definition */ @@ -78,20 +74,22 @@ class EmployeeCore extends ObjectModel 'table' => 'employee', 'primary' => 'id_employee', 'fields' => array( - 'lastname' => array('type' => 'FILL_ME', 'validate' => 'isName', 'required' => true, 'size' => 32), - 'firstname' => array('type' => 'FILL_ME', 'validate' => 'isName', 'required' => true, 'size' => 32), - 'email' => array('type' => 'FILL_ME', 'validate' => 'isEmail', 'required' => true, 'size' => 128), - 'id_lang' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'required' => true), - 'passwd' => array('type' => 'FILL_ME', 'validate' => 'isPasswdAdmin', 'required' => true, 'size' => 32), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'id_profile' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true), - 'bo_color' => array('type' => 'FILL_ME', 'validate' => 'isColor', 'size' => 32), - 'bo_theme' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'size' => 32), - 'bo_show_screencast' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + '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), + 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), + 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswdAdmin', 'required' => true, 'size' => 32), + 'last_passwd_gen' => array('type' => self::TYPE_STRING), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'id_profile' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true), + 'bo_color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor', 'size' => 32), + 'bo_theme' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 32), + 'bo_show_screencast' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'stats_date_from' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'stats_date_to' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - protected $webserviceParameters = array( 'fields' => array( 'id_lang' => array('xlink_resource' => 'languages'), @@ -102,33 +100,19 @@ class EmployeeCore extends ObjectModel ), ); - - public function getFields() + /** + * @see ObjectModel::getFields() + * @return array + */ + public function getFields() { - $this->validateFields(); - - $fields['id_profile'] = (int)$this->id_profile; - $fields['id_lang'] = (int)$this->id_lang; - $fields['lastname'] = pSQL($this->lastname); - $fields['firstname'] = pSQL(Tools::ucfirst($this->firstname)); - $fields['email'] = pSQL($this->email); - $fields['passwd'] = pSQL($this->passwd); - $fields['last_passwd_gen'] = pSQL($this->last_passwd_gen); - if (empty($this->stats_date_from)) $this->stats_date_from = date('Y-m-d 00:00:00'); - $fields['stats_date_from'] = pSQL($this->stats_date_from); if (empty($this->stats_date_to)) $this->stats_date_to = date('Y-m-d 23:59:59'); - $fields['stats_date_to'] = pSQL($this->stats_date_to); - $fields['bo_color'] = pSQL($this->bo_color); - $fields['bo_theme'] = pSQL($this->bo_theme); - $fields['bo_show_screencast'] = (int)$this->bo_show_screencast; - $fields['active'] = (int)$this->active; - - return $fields; + return parent::getFields(); } public function add($autodate = true, $null_values = true) diff --git a/classes/Feature.php b/classes/Feature.php index 894eaa42b..050a44276 100644 --- a/classes/Feature.php +++ b/classes/Feature.php @@ -31,10 +31,6 @@ class FeatureCore extends ObjectModel public $name; public $position; - - - - /** * @see ObjectModel::$definition */ @@ -42,8 +38,10 @@ class FeatureCore extends ObjectModel 'table' => 'feature', 'primary' => 'id_feature', 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), - 'position' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isInt'), + 'position' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + + // Lang fields + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), ), ); @@ -54,11 +52,6 @@ class FeatureCore extends ObjectModel 'fields' => array(), ); - public function getFields() - { - return array('id_feature' => null, 'position' => (int)$this->position); - } - /** * Check then return multilingual fields for database interaction * diff --git a/classes/FeatureValue.php b/classes/FeatureValue.php index 7369447e7..d62a16aaf 100644 --- a/classes/FeatureValue.php +++ b/classes/FeatureValue.php @@ -36,13 +36,6 @@ class FeatureValueCore extends ObjectModel /** @var boolean Custom */ public $custom = 0; - - - - - - - /** * @see ObjectModel::$definition */ @@ -51,13 +44,14 @@ class FeatureValueCore extends ObjectModel 'primary' => 'id_feature_value', 'multilang' => true, 'fields' => array( - 'id_feature' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'custom' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'value' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255), + 'id_feature' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'custom' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + + // Lang fields + 'value' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255), ), ); - protected $webserviceParameters = array( 'objectsNodeName' => 'product_feature_values', 'objectNodeName' => 'product_feature_value', @@ -66,16 +60,6 @@ class FeatureValueCore extends ObjectModel ), ); - public function getFields() - { - $this->validateFields(); - - $fields['id_feature'] = (int)$this->id_feature; - $fields['custom'] = (int)$this->custom; - - return $fields; - } - /** * Check then return multilingual fields for database interaction * diff --git a/classes/Gender.php b/classes/Gender.php index 079ad31ec..f88c62485 100644 --- a/classes/Gender.php +++ b/classes/Gender.php @@ -34,13 +34,6 @@ class GenderCore extends ObjectModel public $name; public $type; - - - - - - - /** * @see ObjectModel::$definition */ @@ -49,12 +42,13 @@ class GenderCore extends ObjectModel 'primary' => 'id_gender', 'multilang' => true, 'fields' => array( - 'type' => array('type' => 'FILL_ME', 'required' => true), + 'type' => array('type' => self::TYPE_INT, 'required' => true), + + // Lang fields 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isString', 'required' => true, 'size' => 20), ), ); - public function __construct($id = null, $id_lang = null, $id_shop = null) { parent::__construct($id, $id_lang, $id_shop); @@ -62,14 +56,6 @@ class GenderCore extends ObjectModel $this->image_dir = _PS_GENDERS_DIR_; } - public function getFields() - { - $this->validateFields(); - $fields['id_gender'] = (int)$this->id_gender; - $fields['type'] = (int)$this->type; - return $fields; - } - /** * Check then return multilingual fields for database interaction * diff --git a/classes/Group.php b/classes/Group.php index e46e5f4db..733a632fc 100644 --- a/classes/Group.php +++ b/classes/Group.php @@ -44,14 +44,6 @@ class GroupCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - - - - - - - - /** * @see ObjectModel::$definition */ @@ -60,27 +52,30 @@ class GroupCore extends ObjectModel 'primary' => 'id_group', 'multilang' => true, 'fields' => array( - 'reduction' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'price_display_method' => array('type' => 'FILL_ME', 'validate' => 'isPriceDisplayMethod', 'required' => true), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), + 'reduction' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'price_display_method' => array('type' => self::TYPE_INT, 'validate' => 'isPriceDisplayMethod', 'required' => true), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + + // Lang fields + 'name' => array('type' => self::TYPE_INT, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), ), ); - protected static $cache_reduction = array(); protected static $group_price_display_method = array(); - protected $webserviceParameters = array(); + protected $webserviceParameters = array(); + /** + * @see ObjectModel::getFields() + * @return array + */ public function getFields() { - $this->validateFields(); + $fields = parent::getFields(); if (isset($this->id)) $fields['id_group'] = (int)$this->id; - $fields['reduction'] = (float)$this->reduction; - $fields['price_display_method'] = (int)$this->price_display_method; - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); return $fields; } diff --git a/classes/GroupReduction.php b/classes/GroupReduction.php index edb7f8ae5..66cd49d22 100644 --- a/classes/GroupReduction.php +++ b/classes/GroupReduction.php @@ -31,9 +31,6 @@ class GroupReductionCore extends ObjectModel public $id_category; public $reduction; - - - /** * @see ObjectModel::$definition */ @@ -41,24 +38,14 @@ class GroupReductionCore extends ObjectModel 'table' => 'group_reduction', 'primary' => 'id_group_reduction', 'fields' => array( - 'id_group' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_category' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'reduction' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), + 'id_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_category' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'reduction' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true), ), ); - protected static $reduction_cache = array(); - public function getFields() - { - $this->validateFields(); - $fields['id_group'] = (int)$this->id_group; - $fields['id_category'] = (int)$this->id_category; - $fields['reduction'] = (float)$this->reduction; - return $fields; - } - public function add($autodate = true, $null_values = false) { return (parent::add($autodate, $null_values) && $this->_setCache()); diff --git a/classes/Guest.php b/classes/Guest.php index ebecfda92..8afa8f7df 100644 --- a/classes/Guest.php +++ b/classes/Guest.php @@ -41,9 +41,6 @@ class GuestCore extends ObjectModel public $real_player; public $windows_media; public $accept_language; - - - /** * @see ObjectModel::$definition @@ -52,52 +49,29 @@ class GuestCore extends ObjectModel 'table' => 'guest', 'primary' => 'id_guest', 'fields' => array( - 'id_operating_system' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_web_browser' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'javascript' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'screen_resolution_x' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'screen_resolution_y' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'screen_color' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'sun_java' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'adobe_flash' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'adobe_director' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'apple_quicktime' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'real_player' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'windows_media' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'accept_language' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'size' => 8), + 'id_operating_system' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_web_browser' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'javascript' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'screen_resolution_x' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'screen_resolution_y' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'screen_color' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'sun_java' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'adobe_flash' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'adobe_director' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'apple_quicktime' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'real_player' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'windows_media' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'accept_language' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 8), ), ); - protected $webserviceParameters = array( 'fields' => array( 'id_customer' => array('xlink_resource' => 'customers'), ), ); - - public function getFields() - { - $this->validateFields(); - - $fields['id_operating_system'] = (int)($this->id_operating_system); - $fields['id_web_browser'] = (int)($this->id_web_browser); - $fields['id_customer'] = (int)($this->id_customer); - $fields['javascript'] = (int)($this->javascript); - $fields['screen_resolution_x'] = (int)($this->screen_resolution_x); - $fields['screen_resolution_y'] = (int)($this->screen_resolution_y); - $fields['screen_color'] = (int)($this->screen_color); - $fields['sun_java'] = (int)($this->sun_java); - $fields['adobe_flash'] = (int)($this->adobe_flash); - $fields['adobe_director'] = (int)($this->adobe_director); - $fields['apple_quicktime'] = (int)($this->apple_quicktime); - $fields['real_player'] = (int)($this->real_player); - $fields['windows_media'] = (int)($this->windows_media); - $fields['accept_language'] = pSQL($this->accept_language); - - return $fields; - } - + function userAgent() { $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; diff --git a/classes/Hook.php b/classes/Hook.php index b733899dd..8bae06b90 100644 --- a/classes/Hook.php +++ b/classes/Hook.php @@ -31,10 +31,6 @@ class HookCore extends ObjectModel public $name; public $title; - - - - /** * @see ObjectModel::$definition */ @@ -42,7 +38,8 @@ class HookCore extends ObjectModel 'table' => 'hook', 'primary' => 'id_hook', 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'validate' => 'isHookName', 'required' => true, 'size' => 32), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isHookName', 'required' => true, 'size' => 32), + 'title' => array('type' => self::TYPE_STRING), ), ); @@ -52,14 +49,6 @@ class HookCore extends ObjectModel static $preloadModulesFromHooks = null; static $preloadHookAlias = null; - public function getFields() - { - $this->validateFields(); - $fields['name'] = pSQL($this->name); - $fields['title'] = pSQL($this->title); - return $fields; - } - /** * Return hook ID from name * diff --git a/classes/Image.php b/classes/Image.php index e0ec6cd49..50b7cbeb3 100644 --- a/classes/Image.php +++ b/classes/Image.php @@ -59,12 +59,6 @@ class ImageCore extends ObjectModel /** @var int access rights of created folders (octal) */ protected static $access_rights = 0775; - - - - - - /** * @see ObjectModel::$definition */ @@ -73,14 +67,15 @@ class ImageCore extends ObjectModel 'primary' => 'id_image', 'multilang' => true, 'fields' => array( - 'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'position' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'cover' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'legend' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), + 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'position' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'cover' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + + // Lang fields + 'legend' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), ), ); - protected static $_cacheGetSize = array(); public function __construct($id = null, $id_lang = null) @@ -90,15 +85,6 @@ class ImageCore extends ObjectModel $this->source_index = _PS_PROD_IMG_DIR_.'index.php'; } - public function getFields() - { - $this->validateFields(); - $fields['id_product'] = (int)$this->id_product; - $fields['position'] = (int)$this->position; - $fields['cover'] = (int)$this->cover; - return $fields; - } - public function getTranslationsFieldsChild() { $this->validateFieldsLang(); diff --git a/classes/ImageType.php b/classes/ImageType.php index 5508ea0bd..0d3b09595 100644 --- a/classes/ImageType.php +++ b/classes/ImageType.php @@ -56,10 +56,6 @@ class ImageTypeCore extends ObjectModel /** @var integer Apply to store */ public $stores; - - - - /** * @see ObjectModel::$definition */ @@ -67,40 +63,24 @@ class ImageTypeCore extends ObjectModel 'table' => 'image_type', 'primary' => 'id_image_type', 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'validate' => 'isImageTypeName', 'required' => true, 'size' => 16), - 'width' => array('type' => 'FILL_ME', 'validate' => 'isImageSize', 'required' => true), - 'height' => array('type' => 'FILL_ME', 'validate' => 'isImageSize', 'required' => true), - 'categories' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'products' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'manufacturers' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'suppliers' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'scenes' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'stores' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isImageTypeName', 'required' => true, 'size' => 16), + 'width' => array('type' => self::TYPE_INT, 'validate' => 'isImageSize', 'required' => true), + 'height' => array('type' => self::TYPE_INT, 'validate' => 'isImageSize', 'required' => true), + 'categories' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'products' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'manufacturers' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'suppliers' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'scenes' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'stores' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), ), ); - /** * @var array Image types cache */ protected static $images_types_cache = array(); - protected $webserviceParameters = array(); - - public function getFields() - { - $this->validateFields(); - $fields['name'] = pSQL($this->name); - $fields['width'] = (int)($this->width); - $fields['height'] = (int)($this->height); - $fields['products'] = (int)($this->products); - $fields['categories'] = (int)($this->categories); - $fields['manufacturers'] = (int)($this->manufacturers); - $fields['suppliers'] = (int)($this->suppliers); - $fields['scenes'] = (int)($this->scenes); - $fields['stores'] = (int)($this->stores); - return $fields; - } + protected $webserviceParameters = array(); /** * Returns image type definitions diff --git a/classes/Language.php b/classes/Language.php index 94379209a..797e891c4 100644 --- a/classes/Language.php +++ b/classes/Language.php @@ -50,10 +50,6 @@ class LanguageCore extends ObjectModel /** @var boolean Status */ public $active = true; - - - - /** * @see ObjectModel::$definition */ @@ -61,13 +57,13 @@ class LanguageCore extends ObjectModel 'table' => 'lang', 'primary' => 'id_lang', 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 32), - 'iso_code' => array('type' => 'FILL_ME', 'validate' => 'isLanguageIsoCode', 'required' => true, 'size' => 2), - 'language_code' => array('type' => 'FILL_ME', 'validate' => 'isLanguageCode', 'size' => 5), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'is_rtl' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'date_format_lite' => array('type' => 'FILL_ME', 'validate' => 'isPhpDateFormat', 'required' => true, 'size' => 32), - 'date_format_full' => array('type' => 'FILL_ME', 'validate' => 'isPhpDateFormat', 'required' => true, 'size' => 32), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), + 'iso_code' => array('type' => self::TYPE_STRING, 'validate' => 'isLanguageIsoCode', 'required' => true, 'size' => 2), + 'language_code' => array('type' => self::TYPE_STRING, 'validate' => 'isLanguageCode', 'size' => 5), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'is_rtl' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'date_format_lite' => array('type' => self::TYPE_STRING, 'validate' => 'isPhpDateFormat', 'required' => true, 'size' => 32), + 'date_format_full' => array('type' => self::TYPE_STRING, 'validate' => 'isPhpDateFormat', 'required' => true, 'size' => 32), ), ); @@ -94,19 +90,16 @@ class LanguageCore extends ObjectModel parent::__construct($id); } + /** + * @see ObjectModel::getFields() + * @return array + */ public function getFields() { - $this->validateFields(); - $fields['name'] = pSQL($this->name); - $fields['iso_code'] = pSQL(strtolower($this->iso_code)); - $fields['language_code'] = pSQL(strtolower($this->language_code)); - $fields['is_rtl'] = (int)$this->is_rtl; - if (empty($fields['language_code'])) - $fields['language_code'] = $fields['iso_code']; - $fields['date_format_lite'] = pSQL($this->date_format_lite); - $fields['date_format_full'] = pSQL($this->date_format_full); - $fields['active'] = (int)$this->active; - return $fields; + if (empty($this->language_code)) + $this->language_code = $this->iso_code; + + return parent::getFields(); } /** diff --git a/classes/Logger.php b/classes/Logger.php index 62d90c503..1f5a572cf 100644 --- a/classes/Logger.php +++ b/classes/Logger.php @@ -51,10 +51,6 @@ class LoggerCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - - - - /** * @see ObjectModel::$definition */ @@ -62,35 +58,19 @@ class LoggerCore extends ObjectModel 'table' => 'log', 'primary' => 'id_log', 'fields' => array( - 'id_log' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'severity' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true), - 'error_code' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'message' => array('type' => 'FILL_ME', 'validate' => 'isMessage', 'required' => true), - 'object_id' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'object_type' => array('type' => 'FILL_ME', 'validate' => 'isName'), + 'id_log' => array('type' => self::TYPE_STRING, 'validate' => 'isUnsignedId'), + 'severity' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true), + 'error_code' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true), + 'object_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'object_type' => array('type' => self::TYPE_STRING, 'validate' => 'isName'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - protected static $is_present = array(); - - public function getFields() - { - $this->validateFields(); - - $fields['severity'] = intval($this->severity); - $fields['error_code'] = intval($this->error_code); - $fields['message'] = pSQL($this->message); - $fields['object_type'] = pSQL($this->object_type); - $fields['object_id'] = intval($this->object_id); - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - - return $fields; - } - - /** * Send e-mail to the shop owner only if the minimal severity level has been reached * @@ -181,6 +161,5 @@ class LoggerCore extends ObjectModel return self::$is_present[$this->getHash()]; } - } diff --git a/classes/Manufacturer.php b/classes/Manufacturer.php index d97654acb..92ad984b4 100644 --- a/classes/Manufacturer.php +++ b/classes/Manufacturer.php @@ -65,12 +65,6 @@ class ManufacturerCore extends ObjectModel /** @var boolean active */ public $active; - - - - - - /** * @see ObjectModel::$definition */ @@ -79,16 +73,20 @@ class ManufacturerCore extends ObjectModel 'primary' => 'id_manufacturer', 'multilang' => true, 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), - 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isString'), - 'short_description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isString', 'size' => 254), - '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'), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), + 'active' => array('type' => self::TYPE_BOOL), + 'date_add' => array('type' => self::TYPE_DATE), + 'date_upd' => array('type' => self::TYPE_DATE), + + // Lang fields + 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isString'), + 'short_description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isString', 'size' => 254), + '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'), ), ); - protected $webserviceParameters = array( 'fields' => array( 'active' => array(), @@ -111,18 +109,16 @@ class ManufacturerCore extends ObjectModel $this->image_dir = _PS_MANU_IMG_DIR_; } + /** + * @see ObjectModel::getFields() + * @return array + */ public function getFields() { - $this->validateFields(); - + $fields = parent::getFields(); if (isset($this->id)) $fields['id_manufacturer'] = (int)$this->id; - $fields['name'] = pSQL($this->name); - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - $fields['active'] = (int)$this->active; - return $fields; } diff --git a/classes/Message.php b/classes/Message.php index 436540ec7..b9e9e073c 100644 --- a/classes/Message.php +++ b/classes/Message.php @@ -49,10 +49,6 @@ class MessageCore extends ObjectModel /** @var string Object creation date */ public $date_add; - - - - /** * @see ObjectModel::$definition @@ -61,31 +57,16 @@ class MessageCore extends ObjectModel 'table' => 'message', 'primary' => 'id_message', 'fields' => array( - 'message' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'required' => true, 'size' => 1600), - 'id_cart' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_employee' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'private' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'message' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 1600), + 'id_cart' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'private' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - - public function getFields() - { - $this->validateFields(); - - $fields['message'] = pSQL($this->message, true); - $fields['id_cart'] = (int)($this->id_cart); - $fields['id_order'] = (int)($this->id_order); - $fields['id_customer'] = (int)($this->id_customer); - $fields['id_employee'] = (int)($this->id_employee); - $fields['private'] = (int)($this->private); - $fields['date_add'] = pSQL($this->date_add); - - return $fields; - } - /** * Return the last message from cart * diff --git a/classes/Meta.php b/classes/Meta.php index 924318827..88fb9f463 100644 --- a/classes/Meta.php +++ b/classes/Meta.php @@ -34,14 +34,6 @@ class MetaCore extends ObjectModel public $keywords; public $url_rewrite; - - - - - - - - /** * @see ObjectModel::$definition */ @@ -51,21 +43,16 @@ class MetaCore extends ObjectModel 'multilang' => true, 'multishop' => true, 'fields' => array( - 'page' => array('type' => 'FILL_ME', 'validate' => 'isFileName', 'required' => true, 'size' => 64), - 'title' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), - 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), - 'keywords' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), - 'url_rewrite' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isLinkRewrite', 'size' => 255), + 'page' => array('type' => self::TYPE_STRING, 'validate' => 'isFileName', 'required' => true, 'size' => 64), + + // Lang fields + 'title' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), + 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + 'keywords' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + 'url_rewrite' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isLinkRewrite', 'size' => 255), ), ); - - public function getFields() - { - $this->validateFields(); - return array('page' => pSQL($this->page)); - } - public function getTranslationsFieldsChild() { $this->validateFieldsLang(); diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index 98dab5d74..e8ee82ea8 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -35,6 +35,7 @@ abstract class ObjectModelCore const TYPE_STRING = 3; const TYPE_FLOAT = 4; const TYPE_DATE = 5; + const TYPE_HTML = 5; /** * List of association types @@ -230,7 +231,7 @@ abstract class ObjectModelCore break; case self::TYPE_BOOL : - $fields[$field] = (bool)$this->$field; + $fields[$field] = (int)$this->$field; break; case self::TYPE_FLOAT : @@ -245,6 +246,10 @@ abstract class ObjectModelCore $fields[$field] = pSQL($this->$field); break; + case self::TYPE_STRING : + $fields[$field] = pSQL($this->$field, true); + break; + default : if (method_exists($this, 'formatType'.$data['type'])) $fields[$field] = $this->{'formatType'.$data['type']}($this->$field); diff --git a/classes/Page.php b/classes/Page.php index fdd9054f9..bb952cc8c 100644 --- a/classes/Page.php +++ b/classes/Page.php @@ -32,9 +32,6 @@ class PageCore extends ObjectModel public $name; - - - /** * @see ObjectModel::$definition */ @@ -42,20 +39,11 @@ class PageCore extends ObjectModel 'table' => 'page', 'primary' => 'id_page', 'fields' => array( - 'id_page_type' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_object' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), + 'id_page_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_object' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), ), ); - - public function getFields() - { - $this->validateFields(); - $fields['id_page_type'] = (int)($this->id_page_type); - $fields['id_object'] = (int)($this->id_object); - return $fields; - } - /** * @return int Current page ID */ diff --git a/classes/ProductDownload.php b/classes/ProductDownload.php index 04402587d..ec438274e 100644 --- a/classes/ProductDownload.php +++ b/classes/ProductDownload.php @@ -59,11 +59,6 @@ class ProductDownloadCore extends ObjectModel protected static $_productIds = array(); - - - - - /** * @see ObjectModel::$definition */ @@ -71,20 +66,19 @@ class ProductDownloadCore extends ObjectModel 'table' => 'product_download', 'primary' => 'id_product_download', 'fields' => array( - 'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_product_attribute ' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'display_filename' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'size' => 255), - 'filename' => array('type' => 'FILL_ME', 'validate' => 'isSha1', 'size' => 255), - 'date_add' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'size' => 20), - 'date_expiration' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'size' => 20), - 'nb_days_accessible' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'size' => 10), - 'nb_downloadable' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'size' => 10), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'size' => 1), - 'is_shareable' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'size' => 1), + 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_product_attribute ' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'display_filename' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255), + 'filename' => array('type' => self::TYPE_STRING, 'validate' => 'isSha1', 'size' => 255), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_expiration' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'nb_days_accessible' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'size' => 10), + 'nb_downloadable' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'size' => 10), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'is_shareable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), ), ); - /** * Build a virtual product * @@ -96,6 +90,18 @@ class ProductDownloadCore extends ObjectModel // @TODO check if the file is present on hard drive } + /** + * @see ObjectModel::getFields() + * @return array + */ + public function getFields() + { + if (!$this->date_expiration) + $this->date_expiration = '0000-00-00 00:00:00'; + + return parent::getFields(); + } + public function add($autodate = true, $nullValues = false) { if (parent::add($autodate, $nullValues)) @@ -126,26 +132,6 @@ class ProductDownloadCore extends ObjectModel return true; } - public function getFields() - { - $this->validateFields(); - $date_expiration = $this->date_expiration; - if (!$date_expiration) - $date_expiration = '0000-00-00 00:00:00'; - - $fields['id_product'] = (int)$this->id_product; - $fields['id_product_attribute'] = pSQL($this->id_product_attribute); - $fields['display_filename'] = pSQL($this->display_filename); - $fields['filename'] = pSQL($this->filename); - $fields['date_add'] = pSQL($this->date_add); - $fields['date_expiration'] = pSQL($date_expiration); - $fields['nb_days_accessible'] = (int)$this->nb_days_accessible; - $fields['nb_downloadable'] = (int)$this->nb_downloadable; - $fields['active'] = (int)$this->active; - $fields['is_shareable'] = (int)$this->is_shareable; - return $fields; - } - /** * Delete the file * @param int $id_product_download : if we need to delete a specific product attribute file diff --git a/classes/ProductSupplier.php b/classes/ProductSupplier.php index 8f74ecc20..3ef483025 100644 --- a/classes/ProductSupplier.php +++ b/classes/ProductSupplier.php @@ -59,10 +59,6 @@ class ProductSupplierCore extends ObjectModel * */ public $product_supplier_price_te; - - - - /** * @see ObjectModel::$definition */ @@ -70,31 +66,16 @@ class ProductSupplierCore extends ObjectModel 'table' => 'product_supplier', 'primary' => 'id_product_supplier', 'fields' => array( - 'product_supplier_reference' => array('type' => 'FILL_ME', 'validate' => 'isReference'), - 'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_product_attribute' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_supplier' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'product_supplier_price_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'supplier_reference' => array('type' => 'FILL_ME', 'size' => 32), + 'product_supplier_reference' => array('type' => self::TYPE_INT, 'validate' => 'isReference'), + 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'product_supplier_price_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'supplier_reference' => array('type' => self::TYPE_STRING, 'size' => 32), ), ); - - public function getFields() - { - $this->validateFields(); - - $fields['id_product'] = (int)$this->id_product; - $fields['id_product_attribute'] = (int)$this->id_product_attribute; - $fields['id_supplier'] = (int)$this->id_supplier; - $fields['product_supplier_reference'] = pSQL($this->product_supplier_reference); - $fields['id_currency'] = (int)$this->id_currency; - $fields['product_supplier_price_te'] = pSQL($this->product_supplier_price_te); - - return $fields; - } - /** * For a given product and supplier, get the product reference * diff --git a/classes/Profile.php b/classes/Profile.php index 50af05af6..5cd01bc8c 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -29,10 +29,6 @@ class ProfileCore extends ObjectModel { /** @var string Name */ public $name; - - - - /** * @see ObjectModel::$definition @@ -42,16 +38,11 @@ class ProfileCore extends ObjectModel 'primary' => 'id_profile', 'multilang' => true, 'fields' => array( + // Lang fields 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), ), ); - - public function getFields() - { - return array('id_profile' => $this->id); - } - /** * Check then return multilingual fields for database interaction * diff --git a/classes/QuickAccess.php b/classes/QuickAccess.php index fdeb14c54..587cb8c11 100644 --- a/classes/QuickAccess.php +++ b/classes/QuickAccess.php @@ -36,13 +36,6 @@ class QuickAccessCore extends ObjectModel /** @var boolean New windows or not */ public $new_window; - - - - - - - /** * @see ObjectModel::$definition */ @@ -51,21 +44,14 @@ class QuickAccessCore extends ObjectModel 'primary' => 'id_quick_access', 'multilang' => true, 'fields' => array( - 'link' => array('type' => 'FILL_ME', 'validate' => 'isUrl', 'required' => true, 'size' => 128), - 'new_window' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), + 'link' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl', 'required' => true, 'size' => 128), + 'new_window' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), + + // Lang fields + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), ), ); - - public function getFields() - { - $this->validateFields(); - $fields['link'] = pSQL($this->link); - $fields['new_window'] = (int)$this->new_window; - return $fields; - } - /** * Check then return multilingual fields for database interaction * diff --git a/classes/RangePrice.php b/classes/RangePrice.php index e14f913ce..2a9c634dc 100644 --- a/classes/RangePrice.php +++ b/classes/RangePrice.php @@ -30,9 +30,6 @@ class RangePriceCore extends ObjectModel public $id_carrier; public $delimiter1; public $delimiter2; - - - /** * @see ObjectModel::$definition @@ -41,13 +38,12 @@ class RangePriceCore extends ObjectModel 'table' => 'range_price', 'primary' => 'id_range_price', 'fields' => array( - 'id_carrier' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true), - 'delimiter1' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedFloat', 'required' => true), - 'delimiter2' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedFloat', 'required' => true), + 'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true), + 'delimiter1' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat', 'required' => true), + 'delimiter2' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat', 'required' => true), ), ); - protected $webserviceParameters = array( 'objectsNodeName' => 'price_ranges', 'objectNodeName' => 'price_range', @@ -55,16 +51,7 @@ class RangePriceCore extends ObjectModel 'id_carrier' => array('xlink_resource' => 'carriers'), ) ); - - public function getFields() - { - $this->validateFields(); - $fields['id_carrier'] = (int)($this->id_carrier); - $fields['delimiter1'] = (float)($this->delimiter1); - $fields['delimiter2'] = (float)($this->delimiter2); - return $fields; - } - + /** * Get all available price ranges * diff --git a/classes/RangeWeight.php b/classes/RangeWeight.php index a4cd667d3..0124016be 100644 --- a/classes/RangeWeight.php +++ b/classes/RangeWeight.php @@ -30,9 +30,6 @@ class RangeWeightCore extends ObjectModel public $id_carrier; public $delimiter1; public $delimiter2; - - - /** * @see ObjectModel::$definition @@ -41,13 +38,12 @@ class RangeWeightCore extends ObjectModel 'table' => 'range_weight', 'primary' => 'id_range_weight', 'fields' => array( - 'id_carrier' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true), - 'delimiter1' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedFloat', 'required' => true), - 'delimiter2' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedFloat', 'required' => true), + 'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true), + 'delimiter1' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat', 'required' => true), + 'delimiter2' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat', 'required' => true), ), ); - protected $webserviceParameters = array( 'objectNodeName' => 'weight_range', 'objectsNodeName' => 'weight_ranges', @@ -55,16 +51,7 @@ class RangeWeightCore extends ObjectModel 'id_carrier' => array('xlink_resource' => 'carriers'), ) ); - - public function getFields() - { - $this->validateFields(); - $fields['id_carrier'] = (int)($this->id_carrier); - $fields['delimiter1'] = (float)($this->delimiter1); - $fields['delimiter2'] = (float)($this->delimiter2); - return $fields; - } - + /** * Get all available weight ranges * diff --git a/classes/Referrer.php b/classes/Referrer.php index 343f127af..0c8391f24 100644 --- a/classes/Referrer.php +++ b/classes/Referrer.php @@ -46,11 +46,6 @@ class ReferrerCore extends ObjectModel public $date_add; - - - - - /** * @see ObjectModel::$definition */ @@ -58,24 +53,23 @@ class ReferrerCore extends ObjectModel 'table' => 'referrer', 'primary' => 'id_referrer', 'fields' => array( - 'id_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 64), - 'passwd' => array('type' => 'FILL_ME', 'validate' => 'isPasswd', 'size' => 32), - 'http_referer_regexp' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'size' => 64), - 'request_uri_regexp' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'size' => 64), - 'http_referer_like' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'size' => 64), - 'request_uri_like' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'size' => 64), - 'http_referer_regexp_not' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml'), - 'request_uri_regexp_not' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml'), - 'http_referer_like_not' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml'), - 'request_uri_like_not' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml'), - 'base_fee' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'percent_fee' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'click_fee' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), + 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'size' => 32), + 'http_referer_regexp' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 64), + 'request_uri_regexp' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 64), + 'http_referer_like' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 64), + 'request_uri_like' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 64), + 'http_referer_regexp_not' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml'), + 'request_uri_regexp_not' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml'), + 'http_referer_like_not' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml'), + 'request_uri_like_not' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml'), + 'base_fee' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'percent_fee' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'click_fee' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - protected static $_join = '(r.http_referer_like IS NULL OR r.http_referer_like = \'\' OR cs.http_referer LIKE r.http_referer_like) AND (r.request_uri_like IS NULL OR r.request_uri_like = \'\' OR cs.request_uri LIKE r.request_uri_like) AND (r.http_referer_like_not IS NULL OR r.http_referer_like_not = \'\' OR cs.http_referer NOT LIKE r.http_referer_like_not) @@ -85,27 +79,6 @@ class ReferrerCore extends ObjectModel AND (r.http_referer_regexp_not IS NULL OR r.http_referer_regexp_not = \'\' OR cs.http_referer NOT REGEXP r.http_referer_regexp_not) AND (r.request_uri_regexp_not IS NULL OR r.request_uri_regexp_not = \'\' OR cs.request_uri NOT REGEXP r.request_uri_regexp_not)'; - public function getFields() - { - $this->validateFields(); - - $fields['name'] = pSQL($this->name); - $fields['passwd'] = pSQL($this->passwd); - $fields['http_referer_regexp'] = pSQL($this->http_referer_regexp, true); - $fields['request_uri_regexp'] = pSQL($this->request_uri_regexp, true); - $fields['http_referer_like'] = pSQL($this->http_referer_like, true); - $fields['request_uri_like'] = pSQL($this->request_uri_like, true); - $fields['http_referer_regexp_not'] = pSQL($this->http_referer_regexp_not, true); - $fields['request_uri_regexp_not'] = pSQL($this->request_uri_regexp_not, true); - $fields['http_referer_like_not'] = pSQL($this->http_referer_like_not, true); - $fields['request_uri_like_not'] = pSQL($this->request_uri_like_not, true); - $fields['base_fee'] = number_format($this->base_fee, 2, '.', ''); - $fields['percent_fee'] = number_format($this->percent_fee, 2, '.', ''); - $fields['click_fee'] = number_format($this->click_fee, 2, '.', ''); - $fields['date_add'] = pSQL($this->date_add); - return $fields; - } - public function add($autodate = true, $nullValues = false) { if (!($result = parent::add($autodate, $nullValues))) diff --git a/classes/RequestSql.php b/classes/RequestSql.php index 7785d6ca9..67d72613b 100644 --- a/classes/RequestSql.php +++ b/classes/RequestSql.php @@ -30,10 +30,6 @@ class RequestSqlCore extends ObjectModel public $name; public $sql; - - - - /** * @see ObjectModel::$definition */ @@ -41,12 +37,11 @@ class RequestSqlCore extends ObjectModel 'table' => 'request_sql', 'primary' => 'id_request_sql', 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'validate' => 'isString', 'required' => true, 'size' => 200), - 'sql' => array('type' => 'FILL_ME', 'validate' => 'isString', 'required' => true, 'size' => 400), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 200), + 'sql' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 400), ), ); - public $tested = array('required' => array ('SELECT', 'FROM'), 'option' => array('WHERE', 'ORDER', 'LIMIT', 'HAVING', 'GROUP', 'UNION'), 'operator' => array('AND', '&&', 'BETWEEN', 'AND', 'BINARY', '&', '~', '|', '^', 'CASE', 'WHEN', 'END', 'DIV', '/', '<=>', '=', '>=', @@ -67,14 +62,6 @@ class RequestSqlCore extends ObjectModel public $error_sql = array(); - public function getFields() - { - parent::validateFields(); - $fields['name'] = pSQL($this->name); - $fields['sql'] = pSQL($this->sql); - return $fields; - } - public static function getRequestSql() { if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT * FROM `'._DB_PREFIX_.'request_sql` ORDER BY `id_request_sql`')) diff --git a/classes/Scene.php b/classes/Scene.php index 8882f5492..6ebad1d78 100644 --- a/classes/Scene.php +++ b/classes/Scene.php @@ -50,21 +50,14 @@ class SceneCore extends ObjectModel 'primary' => 'id_scene', 'multilang' => true, 'fields' => array( - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true), - 'zones' => array('type' => 'FILL_ME', 'validate' => 'isSceneZones'), - 'categories' => array('type' => 'FILL_ME', 'validate' => 'isArrayWithIds'), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 100), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), + + // Lang fields + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 100), ), ); - - - - - - - - protected static $feature_active = null; + protected static $feature_active = null; public function __construct($id = NULL, $id_lang = NULL, $liteResult = true, $hideScenePosition = false) { @@ -77,18 +70,11 @@ class SceneCore extends ObjectModel $this->image_dir = _PS_SCENE_IMG_DIR_; } - public function getFields() - { - $this->validateFields(); - $fields['active'] = (int)($this->active); - return $fields; - } - /** - * Check then return multilingual fields for database interaction - * - * @return array Multilingual fields - */ + * Check then return multilingual fields for database interaction + * + * @return array Multilingual fields + */ public function getTranslationsFieldsChild() { $this->validateFieldsLang(); diff --git a/classes/SearchEngine.php b/classes/SearchEngine.php index ed4eed461..a12bbc1be 100644 --- a/classes/SearchEngine.php +++ b/classes/SearchEngine.php @@ -30,9 +30,6 @@ class SearchEngineCore extends ObjectModel public $server; public $getvar; - - - /** * @see ObjectModel::$definition */ @@ -40,20 +37,11 @@ class SearchEngineCore extends ObjectModel 'table' => 'search_engine', 'primary' => 'id_search_engine', 'fields' => array( - 'server' => array('type' => 'FILL_ME', 'validate' => 'isUrl', 'required' => true), - 'getvar' => array('type' => 'FILL_ME', 'validate' => 'isModuleName', 'required' => true), + 'server' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl', 'required' => true), + 'getvar' => array('type' => self::TYPE_STRING, 'validate' => 'isModuleName', 'required' => true), ), ); - - public function getFields() - { - $this->validateFields(); - $fields['server'] = pSQL($this->server); - $fields['getvar'] = pSQL($this->getvar); - return $fields; - } - public static function getKeywords($url) { $parsedUrl = @parse_url($url); diff --git a/classes/SpecificPrice.php b/classes/SpecificPrice.php index 47e3c35e4..45ac163df 100644 --- a/classes/SpecificPrice.php +++ b/classes/SpecificPrice.php @@ -41,9 +41,6 @@ class SpecificPriceCore extends ObjectModel public $from; public $to; - - - /** * @see ObjectModel::$definition */ @@ -51,45 +48,26 @@ class SpecificPriceCore extends ObjectModel 'table' => 'specific_price', 'primary' => 'id_specific_price', 'fields' => array( - 'id_group_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_product_attribute' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_country' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_group' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'price' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), - 'from_quantity' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'required' => true), - 'reduction' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), - 'reduction_type' => array('type' => 'FILL_ME', 'validate' => 'isReductionType', 'required' => true), - 'from' => array('type' => 'FILL_ME', 'validate' => 'isDateFormat', 'required' => true), - 'to' => array('type' => 'FILL_ME', 'validate' => 'isDateFormat', 'required' => true), - 'id_currency' => array('type' => 'FILL_ME', 'required' => true), + 'id_group_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_currency' => array('type' => self::TYPE_INT, 'required' => true), + 'id_specific_price_rule' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'price' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true), + 'from_quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), + 'reduction' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true), + 'reduction_type' => array('type' => self::TYPE_STRING, 'validate' => 'isReductionType', 'required' => true), + 'from' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'required' => true), + 'to' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'required' => true), ), ); - protected static $_specificPriceCache = array(); protected static $_cache_priorities = array(); - public function getFields() - { - $this->validateFields(); - $fields['id_specific_price_rule'] = (int)$this->id_specific_price_rule; - $fields['id_product'] = (int)$this->id_product; - $fields['id_product_attribute'] = (int)$this->id_product_attribute; - $fields['id_shop'] = (int)$this->id_shop; - $fields['id_currency'] = (int)$this->id_currency; - $fields['id_country'] = (int)$this->id_country; - $fields['id_group'] = (int)$this->id_group; - $fields['price'] = (float)$this->price; - $fields['from_quantity'] = (int)$this->from_quantity; - $fields['reduction'] = (float)$this->reduction; - $fields['reduction_type'] = pSQL($this->reduction_type); - $fields['from'] = pSQL($this->from); - $fields['to'] = pSQL($this->to); - return $fields; - } - public function add($autodate = true, $nullValues = false) { if (parent::add($autodate, $nullValues)) diff --git a/classes/SpecificPriceRule.php b/classes/SpecificPriceRule.php index f69efc42f..9bf0febd5 100755 --- a/classes/SpecificPriceRule.php +++ b/classes/SpecificPriceRule.php @@ -39,9 +39,6 @@ class SpecificPriceRuleCore extends ObjectModel public $from; public $to; - - - /** * @see ObjectModel::$definition */ @@ -49,37 +46,18 @@ class SpecificPriceRuleCore extends ObjectModel 'table' => 'specific_price_rule', 'primary' => 'id_specific_price_rule', 'fields' => array( - 'id_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_country' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_group' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'from_quantity' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'required' => true), - 'reduction' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), - 'reduction_type' => array('type' => 'FILL_ME', 'validate' => 'isReductionType', 'required' => true), - 'from' => array('type' => 'FILL_ME', 'validate' => 'isDateFormat', 'required' => true), - 'to' => array('type' => 'FILL_ME', 'validate' => 'isDateFormat', 'required' => true), - 'id_currency' => array('type' => 'FILL_ME', 'required' => true), + 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_currency' => array('type' => self::TYPE_INT, 'required' => true), + 'id_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'from_quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), + 'reduction' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true), + 'reduction_type' => array('type' => self::TYPE_STRING, 'validate' => 'isReductionType', 'required' => true), + 'from' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'required' => true), + 'to' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'required' => true), ), ); - - public function getFields() - { - $this->validateFields(); - - $fields['name'] = pSQL($this->name); - $fields['id_shop'] = (int)$this->id_shop; - $fields['id_currency'] = (int)$this->id_currency; - $fields['id_country'] = (int)$this->id_country; - $fields['id_group'] = (int)$this->id_group; - $fields['from_quantity'] = (int)$this->from_quantity; - $fields['reduction'] = (float)$this->reduction; - $fields['reduction_type'] = pSQL($this->reduction_type); - $fields['from'] = pSQL($this->from); - $fields['to'] = pSQL($this->to); - - return $fields; - } - public function delete() { $ids_condition_group = Db::getInstance()->executeS('SELECT id_specific_price_rule_condition_group diff --git a/classes/State.php b/classes/State.php index bbd7d7b01..edf01a615 100644 --- a/classes/State.php +++ b/classes/State.php @@ -42,10 +42,6 @@ class StateCore extends ObjectModel /** @var boolean Status for delivery */ public $active = true; - - - - /** * @see ObjectModel::$definition */ @@ -53,33 +49,21 @@ class StateCore extends ObjectModel 'table' => 'state', 'primary' => 'id_state', 'fields' => array( - 'id_country' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_zone' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'iso_code' => array('type' => 'FILL_ME', 'validate' => 'isStateIsoCode', 'required' => true, 'size' => 4), - 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 32), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_zone' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'iso_code' => array('type' => self::TYPE_STRING, 'validate' => 'isStateIsoCode', 'required' => true, 'size' => 4), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), ), ); - - protected $webserviceParameters = array( + protected $webserviceParameters = array( 'fields' => array( 'id_zone' => array('xlink_resource'=> 'zones'), 'id_country' => array('xlink_resource'=> 'countries') ), ); - public function getFields() - { - $this->validateFields(); - $fields['id_country'] = (int)($this->id_country); - $fields['id_zone'] = (int)($this->id_zone); - $fields['iso_code'] = pSQL(strtoupper($this->iso_code)); - $fields['name'] = pSQL($this->name); - $fields['active'] = (int)($this->active); - return $fields; - } - public static function getStates($id_lang = false, $active = false) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' diff --git a/classes/Store.php b/classes/Store.php index 669113429..229960b37 100644 --- a/classes/Store.php +++ b/classes/Store.php @@ -77,10 +77,6 @@ class StoreCore extends ObjectModel /** @var boolean Store status */ public $active = true; - - - - /** * @see ObjectModel::$definition @@ -89,25 +85,26 @@ class StoreCore extends ObjectModel 'table' => 'store', 'primary' => 'id_store', 'fields' => array( - 'id_country' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_state' => array('type' => 'FILL_ME', 'validate' => 'isNullOrUnsignedId'), - 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 128), - 'address1' => array('type' => 'FILL_ME', 'validate' => 'isAddress', 'required' => true, 'size' => 128), - 'address2' => array('type' => 'FILL_ME', 'validate' => 'isAddress', 'size' => 128), - 'city' => array('type' => 'FILL_ME', 'validate' => 'isCityName', 'required' => true, 'size' => 64), - 'latitude' => array('type' => 'FILL_ME', 'validate' => 'isCoordinate', 'size' => 12), - 'longitude' => array('type' => 'FILL_ME', 'validate' => 'isCoordinate', 'size' => 12), - 'hours' => array('type' => 'FILL_ME', 'validate' => 'isSerializedArray', 'size' => 254), - 'phone' => array('type' => 'FILL_ME', 'validate' => 'isPhoneNumber', 'size' => 16), - 'fax' => array('type' => 'FILL_ME', 'validate' => 'isPhoneNumber', 'size' => 16), - 'note' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'size' => 65000), - 'email' => array('type' => 'FILL_ME', 'validate' => 'isEmail', 'size' => 128), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true), - 'postcode' => array('type' => 'FILL_ME', 'size' => 12), + 'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_state' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), + '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, 'size' => 12), + 'city' => array('type' => self::TYPE_STRING, 'validate' => 'isCityName', 'required' => true, 'size' => 64), + 'latitude' => array('type' => self::TYPE_FLOAT, 'validate' => 'isCoordinate', 'size' => 12), + 'longitude' => array('type' => self::TYPE_FLOAT, 'validate' => 'isCoordinate', 'size' => 12), + 'hours' => array('type' => self::TYPE_STRING, 'validate' => 'isSerializedArray', 'size' => 254), + 'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 16), + 'fax' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 16), + 'note' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 65000), + 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 128), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - protected $webserviceParameters = array( 'fields' => array( 'id_country' => array('xlink_resource'=> 'countries'), @@ -116,31 +113,6 @@ class StoreCore extends ObjectModel ), ); - public function getFields() - { - $this->validateFields(); - - $fields['id_country'] = (int)$this->id_country; - $fields['id_state'] = (int)$this->id_state; - $fields['name'] = pSQL($this->name); - $fields['address1'] = pSQL($this->address1); - $fields['address2'] = pSQL($this->address2); - $fields['postcode'] = pSQL($this->postcode); - $fields['city'] = pSQL($this->city); - $fields['latitude'] = (float)$this->latitude; - $fields['longitude'] = (float)$this->longitude; - $fields['hours'] = pSQL($this->hours); - $fields['phone'] = pSQL($this->phone); - $fields['fax'] = pSQL($this->fax); - $fields['note'] = pSQL($this->note); - $fields['email'] = pSQL($this->email); - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - $fields['active'] = (int)$this->active; - - return $fields; - } - public function __construct($id_store = NULL, $id_lang = NULL) { parent::__construct($id_store, $id_lang); @@ -159,5 +131,3 @@ class StoreCore extends ObjectModel return true; } } - - diff --git a/classes/SubDomain.php b/classes/SubDomain.php index 7290119cc..80b7f664b 100644 --- a/classes/SubDomain.php +++ b/classes/SubDomain.php @@ -29,10 +29,6 @@ class SubDomainCore extends ObjectModel { public $name; - - - - /** * @see ObjectModel::$definition */ @@ -40,18 +36,10 @@ class SubDomainCore extends ObjectModel 'table' => 'subdomain', 'primary' => 'id_subdomain', 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'validate' => 'isSubDomainName', 'required' => true, 'size' => 16), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isSubDomainName', 'required' => true, 'size' => 16), ), ); - - public function getFields() - { - $this->validateFields(); - $fields['name'] = pSQL($this->name); - return $fields; - } - public static function getSubDomains() { if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT `name` FROM `'._DB_PREFIX_.'subdomain`')) diff --git a/classes/Supplier.php b/classes/Supplier.php index 180d62370..3bf3361fe 100644 --- a/classes/Supplier.php +++ b/classes/Supplier.php @@ -65,12 +65,6 @@ class SupplierCore extends ObjectModel * */ public $id_address; - - - - - - /** * @see ObjectModel::$definition */ @@ -79,16 +73,20 @@ class SupplierCore extends ObjectModel 'primary' => 'id_supplier', 'multilang' => true, 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), - 'id_address' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName'), - '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), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), + 'id_address' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'active' => array('type' => self::TYPE_BOOL), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + + // Lang fields + 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName'), + '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), ), ); - protected $webserviceParameters = array( 'fields' => array( 'link_rewrite' => array('sqlId' => 'link_rewrite'), @@ -108,19 +106,6 @@ class SupplierCore extends ObjectModel return Tools::link_rewrite($this->name, false); } - public function getFields() - { - $this->validateFields(); - if (isset($this->id)) - $fields['id_supplier'] = (int)$this->id; - $fields['name'] = pSQL($this->name); - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - $fields['active'] = (int)$this->active; - $fields['id_address'] = (int)$this->id_address; - return $fields; - } - public function getTranslationsFieldsChild() { $this->validateFieldsLang(); diff --git a/classes/Tab.php b/classes/Tab.php index da0970bb1..723916be3 100644 --- a/classes/Tab.php +++ b/classes/Tab.php @@ -41,14 +41,6 @@ class TabCore extends ObjectModel /** @var integer position */ public $position; - - - - - - - - /** * @see ObjectModel::$definition */ @@ -57,27 +49,19 @@ class TabCore extends ObjectModel 'primary' => 'id_tab', 'multilang' => true, 'fields' => array( - 'id_parent' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'position' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'module' => array('type' => 'FILL_ME', 'validate' => 'isTabName', 'size' => 64), - 'class_name' => array('type' => 'FILL_ME', 'required' => true, 'size' => 64), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), + 'id_parent' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'position' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'module' => array('type' => self::TYPE_STRING, 'validate' => 'isTabName', 'size' => 64), + 'class_name' => array('type' => self::TYPE_STRING, 'required' => true, 'size' => 64), + + // Lang fields + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), ), ); protected static $_getIdFromClassName = null; - public function getFields() - { - $this->validateFields(); - $fields['id_parent'] = (int)$this->id_parent; - $fields['class_name'] = pSQL($this->class_name); - $fields['module'] = pSQL($this->module); - $fields['position'] = (int)$this->position; - return $fields; - } - public function getTranslationsFieldsChild() { $this->validateFieldsLang(); diff --git a/classes/Tag.php b/classes/Tag.php index 49c7c3df4..06c15f919 100644 --- a/classes/Tag.php +++ b/classes/Tag.php @@ -33,9 +33,6 @@ class TagCore extends ObjectModel /** @var string Name */ public $name; - - - /** * @see ObjectModel::$definition */ @@ -43,16 +40,16 @@ class TagCore extends ObjectModel 'table' => 'tag', 'primary' => 'id_tag', 'fields' => array( - 'id_lang' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true), + 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true), ), ); protected $webserviceParameters = array( - 'fields' => array( - 'id_lang' => array('xlink_resource' => 'languages'), - ), + 'fields' => array( + 'id_lang' => array('xlink_resource' => 'languages'), + ), ); public function __construct($id = null, $name = null, $id_lang = null) @@ -75,14 +72,6 @@ class TagCore extends ObjectModel } } - public function getFields() - { - $this->validateFields(); - $fields['id_lang'] = (int)$this->id_lang; - $fields['name'] = pSQL($this->name); - return $fields; - } - public function add($autodate = true, $null_values = false) { if (!parent::add($autodate, $null_values)) diff --git a/classes/Theme.php b/classes/Theme.php index f02200a49..bd307623f 100644 --- a/classes/Theme.php +++ b/classes/Theme.php @@ -29,9 +29,6 @@ class ThemeCore extends ObjectModel { public $name; - - - /** * @see ObjectModel::$definition */ @@ -39,18 +36,10 @@ class ThemeCore extends ObjectModel 'table' => 'theme', 'primary' => 'id_theme', 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'size' => 64), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 64), ), ); - - public function getFields() - { - $this->validateFields(); - $fields['name'] = pSQL($this->name); - return $fields; - } - public static function getThemes() { $sql = 'SELECT * diff --git a/classes/Zone.php b/classes/Zone.php index 3a18a2c81..e1d72bd5a 100644 --- a/classes/Zone.php +++ b/classes/Zone.php @@ -32,11 +32,9 @@ class ZoneCore extends ObjectModel /** @var boolean Zone status */ public $active = true; - public $eu_zone = false; /* Obsolete; to remove */ - - - + /* @todo Obsolete; to remove */ + public $eu_zone = false; /** * @see ObjectModel::$definition @@ -45,29 +43,20 @@ class ZoneCore extends ObjectModel 'table' => 'zone', 'primary' => 'id_zone', 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 64), - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), ), ); protected $webserviceParameters = array(); - public function getFields() - { - $this->validateFields(); - - $fields['name'] = pSQL($this->name); - $fields['active'] = (int)$this->active; - - return $fields; - } - /** - * Get all available geographical zones - * - * @return array Zones - */ + * Get all available geographical zones + * + * @param bool $active + * @return array Zones + */ public static function getZones($active = false) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' @@ -78,10 +67,11 @@ class ZoneCore extends ObjectModel } /** - * Get a zone ID from its default language name - * - * @return integer id_zone - */ + * Get a zone ID from its default language name + * + * @param string $name + * @return integer id_zone + */ public static function getIdByName($name) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' diff --git a/classes/order/Order.php b/classes/order/Order.php index 01c2625ba..1b0481780 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -142,13 +142,61 @@ class OrderCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - /** @var string Order reference - * This reference is not unique, but unique for a payment + /** + * @var string Order reference, this reference is not unique, but unique for a payment */ public $reference; - - + /** + * @see ObjectModel::$definition + */ + public static $definition = array( + 'table' => 'orders', + 'primary' => 'id_order', + 'fields' => array( + 'id_address_delivery' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_address_invoice' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_cart' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_group_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5'), + 'payment' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true), + 'module' => array('type' => self::TYPE_STRING), + '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'), + 'total_discounts' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_discounts_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_discounts_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_paid' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true), + 'total_paid_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_paid_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_paid_real' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true), + 'total_products' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true), + 'total_products_wt' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true), + 'total_shipping' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_shipping_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_shipping_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'carrier_tax_rate' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'total_wrapping' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_wrapping_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_wrapping_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'shipping_number' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl'), + 'conversion_rate' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true), + 'invoice_number' => array('type' => self::TYPE_INT), + 'delivery_number' => array('type' => self::TYPE_INT), + 'invoice_date' => array('type' => self::TYPE_DATE), + 'delivery_date' => array('type' => self::TYPE_DATE), + 'valid' => array('type' => self::TYPE_BOOL), + 'reference' => array('type' => self::TYPE_STRING), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + ), + ); protected $webserviceParameters = array( 'objectMethods' => array('add' => 'addWs'), @@ -181,111 +229,15 @@ class OrderCore extends ObjectModel 'product_quantity' => array('required' => true), 'product_name' => array('setter' => false), 'product_price' => array('setter' => false), - )), + )), ), ); - /* MySQL does not allow 'order' for a table name */ - /** - * @see ObjectModel::$definition - */ - public static $definition = array( - 'table' => 'orders', - 'primary' => 'id_order', - 'fields' => array( - 'id_address_delivery' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_address_invoice' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_cart' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_group_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_lang' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_carrier' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'secure_key' => array('type' => 'FILL_ME', 'validate' => 'isMd5'), - 'payment' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true), - 'recyclable' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'gift' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'gift_message' => array('type' => 'FILL_ME', 'validate' => 'isMessage'), - 'total_discounts' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_discounts_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_discounts_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_paid' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), - 'total_paid_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_paid_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_paid_real' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), - 'total_products' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), - 'total_products_wt' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), - 'total_shipping' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_shipping_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_shipping_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'carrier_tax_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'total_wrapping' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_wrapping_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_wrapping_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'shipping_number' => array('type' => 'FILL_ME', 'validate' => 'isUrl'), - 'conversion_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true), - ), - ); - - protected $_taxCalculationMethod = PS_TAX_EXC; protected static $_historyCache = array(); - public function getFields() - { - if (!$this->id_lang) - $this->id_lang = Configuration::get('PS_LANG_DEFAULT'); - - $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_cart'] = (int)$this->id_cart; - $fields['id_currency'] = (int)($this->id_currency); - $fields['id_lang'] = (int)($this->id_lang); - $fields['id_customer'] = (int)($this->id_customer); - $fields['id_carrier'] = (int)($this->id_carrier); - $fields['secure_key'] = pSQL($this->secure_key); - $fields['payment'] = pSQL($this->payment); - $fields['module'] = pSQL($this->module); - $fields['conversion_rate'] = (float)($this->conversion_rate); - $fields['recyclable'] = (int)($this->recyclable); - $fields['gift'] = (int)($this->gift); - $fields['gift_message'] = pSQL($this->gift_message); - $fields['shipping_number'] = pSQL($this->shipping_number); - $fields['total_discounts'] = (float)($this->total_discounts); - $fields['total_discounts_tax_incl'] = (float)($this->total_discounts_tax_incl); - $fields['total_discounts_tax_excl'] = (float)($this->total_discounts_tax_excl); - $fields['total_paid'] = (float)($this->total_paid); - $fields['total_paid_tax_incl'] = (float)($this->total_paid_tax_incl); - $fields['total_paid_tax_excl'] = (float)($this->total_paid_tax_excl); - $fields['total_paid_real'] = (float)($this->total_paid_real); - $fields['total_products'] = (float)($this->total_products); - $fields['total_products_wt'] = (float)($this->total_products_wt); - $fields['total_shipping'] = (float)($this->total_shipping); - $fields['total_shipping_tax_incl'] = (float)($this->total_shipping_tax_incl); - $fields['total_shipping_tax_excl'] = (float)($this->total_shipping_tax_excl); - $fields['carrier_tax_rate'] = (float)($this->carrier_tax_rate); - $fields['total_wrapping'] = (float)($this->total_wrapping); - $fields['total_wrapping_tax_incl'] = (float)($this->total_wrapping_tax_incl); - $fields['total_wrapping_tax_excl'] = (float)($this->total_wrapping_tax_excl); - $fields['invoice_number'] = (int)($this->invoice_number); - $fields['delivery_number'] = (int)($this->delivery_number); - $fields['invoice_date'] = pSQL($this->invoice_date); - $fields['delivery_date'] = pSQL($this->delivery_date); - $fields['valid'] = (int)($this->valid) ? 1 : 0; - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - $fields['reference'] = pSQL($this->reference); - - return $fields; - } - public function __construct($id = NULL, $id_lang = NULL) { parent::__construct($id, $id_lang); @@ -298,6 +250,18 @@ class OrderCore extends ObjectModel $this->_taxCalculationMethod = Group::getDefaultPriceDisplayMethod(); } + /** + * @see ObjectModel::getFields() + * @return array + */ + public function getFields() + { + if (!$this->id_lang) + $this->id_lang = Configuration::get('PS_LANG_DEFAULT'); + + return parent::getFields(); + } + public function getTaxCalculationMethod() { return (int)($this->_taxCalculationMethod); diff --git a/classes/order/OrderCarrier.php b/classes/order/OrderCarrier.php index 3f7668c2f..aacaf9a5b 100644 --- a/classes/order/OrderCarrier.php +++ b/classes/order/OrderCarrier.php @@ -55,9 +55,6 @@ class OrderCarrierCore extends ObjectModel /** @var string Object creation date */ public $date_add; - - - /** * @see ObjectModel::$definition */ @@ -65,38 +62,21 @@ class OrderCarrierCore extends ObjectModel 'table' => 'order_carrier', 'primary' => 'id_order_carrier', 'fields' => array( - 'id_order_carrier' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_carrier' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_order_invoice' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'weight' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'shipping_cost_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'shipping_cost_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'tracking_number' => array('type' => 'FILL_ME', 'validate' => 'isAnything'), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_order_invoice' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'weight' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'shipping_cost_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'shipping_cost_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'tracking_number' => array('type' => self::TYPE_FLOAT, 'validate' => 'isAnything'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - - protected $webserviceParameters = array( + protected $webserviceParameters = array( 'fields' => array( 'id_order' => array('xlink_resource' => 'orders'), 'id_carrier' => array('xlink_resource' => 'carriers'), ), ); - - public function getFields() - { - $this->validateFields(); - - $fields['id_order'] = (int)$this->id_order; - $fields['id_carrier'] = (int)$this->id_carrier; - $fields['id_order_invoice'] = (int)$this->id_order_invoice; - $fields['weight'] = (float)$this->weight; - $fields['shipping_cost_tax_excl'] = (float)$this->shipping_cost_tax_excl; - $fields['shipping_cost_tax_incl'] = (float)$this->shipping_cost_tax_incl; - $fields['tracking_number'] = pSQL(($this->tracking_number)); - $fields['date_add'] = pSQL($this->date_add); - - return $fields; - } } \ No newline at end of file diff --git a/classes/order/OrderCartRule.php b/classes/order/OrderCartRule.php index a3420eb71..b5e0cdbda 100644 --- a/classes/order/OrderCartRule.php +++ b/classes/order/OrderCartRule.php @@ -42,10 +42,6 @@ class OrderCartRuleCore extends ObjectModel /** @var integer */ public $value; - - - - /* MySQL does not allow 'order detail' for a table name */ /** * @see ObjectModel::$definition */ @@ -53,28 +49,16 @@ class OrderCartRuleCore extends ObjectModel 'table' => 'order_cart_rule', 'primary' => 'id_order_cart_rule', 'fields' => array( - 'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true), - 'value' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true), + 'value' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true), ), ); - - protected $webserviceParameters = array( + protected $webserviceParameters = array( 'fields' => array( 'id_order' => array('xlink_resource' => 'orders'), ), ); - - public function getFields() - { - $this->validateFields(); - - $fields['id_order'] = (int)($this->id_order); - $fields['name'] = pSQL($this->name); - $fields['value'] = (int)($this->value); - - return $fields; - } } diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php index f42900288..0b2e4b37f 100644 --- a/classes/order/OrderDetail.php +++ b/classes/order/OrderDetail.php @@ -129,10 +129,6 @@ class OrderDetailCore extends ObjectModel /** @var int Id warehouse */ public $id_warehouse; - - - - /** * @see ObjectModel::$definition */ @@ -140,53 +136,52 @@ class OrderDetailCore extends ObjectModel 'table' => 'order_detail', 'primary' => 'id_order_detail', 'fields' => array( - 'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_order_invoice' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_warehouse' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'product_id' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'product_attribute_id' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'product_name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true), - 'product_quantity' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true), - 'product_quantity_in_stock' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'product_quantity_return' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'product_quantity_refunded' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'product_quantity_reinjected' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), - 'product_price' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), - 'reduction_percent' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'reduction_amount' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'group_reduction' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'product_quantity_discount' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'product_ean13' => array('type' => 'FILL_ME', 'validate' => 'isEan13'), - 'product_upc' => array('type' => 'FILL_ME', 'validate' => 'isUpc'), - 'product_reference' => array('type' => 'FILL_ME', 'validate' => 'isReference'), - 'product_supplier_reference' => array('type' => 'FILL_ME', 'validate' => 'isReference'), - 'product_weight' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'tax_name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName'), - 'tax_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'ecotax' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'ecotax_tax_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'discount_quantity_applied' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'download_hash' => array('type' => 'FILL_ME', 'validate' => 'isGenericName'), - 'download_nb' => array('type' => 'FILL_ME', 'validate' => 'isInt'), - 'download_deadline' => array('type' => 'FILL_ME', 'validate' => 'isDateFormat'), - 'unit_price_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'unit_price_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_price_tax_incl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_price_tax_excl' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_order_invoice' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'product_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'product_attribute_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'product_name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true), + 'product_quantity' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true), + 'product_quantity_in_stock' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'product_quantity_return' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'product_quantity_refunded' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'product_quantity_reinjected' =>array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'product_price' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true), + 'reduction_percent' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'reduction_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'group_reduction' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'product_quantity_discount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'product_ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isEan13'), + 'product_upc' => array('type' => self::TYPE_STRING, 'validate' => 'isUpc'), + 'product_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isReference'), + 'product_supplier_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isReference'), + 'product_weight' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'tax_name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), + 'tax_rate' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'ecotax' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'ecotax_tax_rate' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), + 'discount_quantity_applied' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'download_hash' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), + 'download_nb' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'download_deadline' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'), + 'unit_price_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'unit_price_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_price_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_price_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), ), ); - - protected $webserviceParameters = array( - 'fields' => array ( - 'id_order' => array('xlink_resource' => 'orders'), - 'product_id' => array('xlink_resource' => 'products'), - 'product_attribute_id' => array('xlink_resource' => 'combinations'), - 'product_quantity_reinjected' => array(), - 'group_reduction' => array(), - 'discount_quantity_applied' => array(), - 'download_hash' => array(), - 'download_deadline' => array() + protected $webserviceParameters = array( + 'fields' => array ( + 'id_order' => array('xlink_resource' => 'orders'), + 'product_id' => array('xlink_resource' => 'products'), + 'product_attribute_id' => array('xlink_resource' => 'combinations'), + 'product_quantity_reinjected' => array(), + 'group_reduction' => array(), + 'discount_quantity_applied' => array(), + 'download_hash' => array(), + 'download_deadline' => array() ) ); @@ -217,46 +212,6 @@ class OrderDetailCore extends ObjectModel return parent::__construct($id, $id_lang, $id_shop); } - public function getFields() - { - $this->validateFields(); - - $fields['id_order'] = (int)$this->id_order; - $fields['id_order_invoice'] = (int)$this->id_order_invoice; - $fields['id_warehouse'] = pSQL($this->id_warehouse); - $fields['product_id'] = (int)$this->product_id; - $fields['product_attribute_id'] = (int)$this->product_attribute_id; - $fields['product_name'] = pSQL($this->product_name); - $fields['product_quantity'] = (int)$this->product_quantity; - $fields['product_quantity_in_stock'] = (int)$this->product_quantity_in_stock; - $fields['product_quantity_return'] = (int)$this->product_quantity_return; - $fields['product_quantity_refunded'] = (int)$this->product_quantity_refunded; - $fields['product_quantity_reinjected'] = (int)$this->product_quantity_reinjected; - $fields['product_price'] = (float)$this->product_price; - $fields['reduction_percent'] = (float)$this->reduction_percent; - $fields['reduction_amount'] = (float)$this->reduction_amount; - $fields['group_reduction'] = (float)$this->group_reduction; - $fields['product_quantity_discount'] = (float)$this->product_quantity_discount; - $fields['product_ean13'] = pSQL($this->product_ean13); - $fields['product_upc'] = pSQL($this->product_upc); - $fields['product_reference'] = pSQL($this->product_reference); - $fields['product_supplier_reference'] = pSQL($this->product_supplier_reference); - $fields['product_weight'] = (float)$this->product_weight; - $fields['tax_name'] = pSQL($this->tax_name); - $fields['tax_rate'] = (float)$this->tax_rate; - $fields['ecotax'] = (float)$this->ecotax; - $fields['ecotax_tax_rate'] = (float)$this->ecotax_tax_rate; - $fields['download_hash'] = pSQL($this->download_hash); - $fields['download_nb'] = (int)$this->download_nb; - $fields['download_deadline'] = pSQL($this->download_deadline); - $fields['unit_price_tax_incl'] = (float)$this->unit_price_tax_incl; - $fields['unit_price_tax_excl'] = (float)$this->unit_price_tax_excl; - $fields['total_price_tax_incl'] = (float)$this->total_price_tax_incl; - $fields['total_price_tax_excl'] = (float)$this->total_price_tax_excl; - - return $fields; - } - public static function getDownloadFromHash($hash) { if ($hash == '') return false; diff --git a/classes/order/OrderDiscount.php b/classes/order/OrderDiscount.php index 2b493f9b2..e4782b29d 100644 --- a/classes/order/OrderDiscount.php +++ b/classes/order/OrderDiscount.php @@ -25,6 +25,9 @@ * International Registered Trademark & Property of PrestaShop SA */ +/** + * @deprecated 1.5.0 + */ class OrderDiscountCore extends OrderCartRule { public function __get($key) diff --git a/classes/order/OrderHistory.php b/classes/order/OrderHistory.php index 69117a07b..011d6d2af 100644 --- a/classes/order/OrderHistory.php +++ b/classes/order/OrderHistory.php @@ -42,9 +42,6 @@ class OrderHistoryCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - - - /** * @see ObjectModel::$definition */ @@ -52,9 +49,10 @@ class OrderHistoryCore extends ObjectModel 'table' => 'order_history', 'primary' => 'id_order_history', 'fields' => array( - 'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_order_state' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_employee' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_order_state' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); @@ -67,18 +65,6 @@ class OrderHistoryCore extends ObjectModel ), ); - public function getFields() - { - $this->validateFields(); - - $fields['id_order'] = (int)$this->id_order; - $fields['id_order_state'] = (int)$this->id_order_state; - $fields['id_employee'] = (int)$this->id_employee; - $fields['date_add'] = pSQL($this->date_add); - - return $fields; - } - public function changeIdOrderState($new_order_state, $id_order, $id_warehouse = null) { if ($new_order_state != NULL) diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index 7401778b4..7358ee6ff 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -66,9 +66,6 @@ class OrderInvoiceCore extends ObjectModel /** @var intger */ public $date_add; - - - /** * @see ObjectModel::$definition */ @@ -76,33 +73,22 @@ class OrderInvoiceCore extends ObjectModel 'table' => 'order_invoice', 'primary' => 'id_order_invoice', 'fields' => array( - 'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'number' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'number' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'total_discount_tax_excl' =>array('type' => self::TYPE_FLOAT), + 'total_discount_tax_incl' =>array('type' => self::TYPE_FLOAT), + 'total_paid_tax_excl' => array('type' => self::TYPE_FLOAT), + 'total_paid_tax_incl' => array('type' => self::TYPE_FLOAT), + 'total_products' => array('type' => self::TYPE_FLOAT), + 'total_products_wt' => array('type' => self::TYPE_FLOAT), + 'total_shipping_tax_excl' =>array('type' => self::TYPE_FLOAT), + 'total_shipping_tax_incl' =>array('type' => self::TYPE_FLOAT), + 'total_wrapping_tax_excl' =>array('type' => self::TYPE_FLOAT), + 'total_wrapping_tax_incl' =>array('type' => self::TYPE_FLOAT), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - - public function getFields() - { - $this->validateFields(); - - $fields['id_order'] = (int)$this->id_order; - $fields['number'] = (int)$this->number; - $fields['total_discount_tax_excl'] = (float)$this->total_discount_tax_excl; - $fields['total_discount_tax_incl'] = (float)$this->total_discount_tax_incl; - $fields['total_paid_tax_excl'] = (float)$this->total_paid_tax_excl; - $fields['total_paid_tax_incl'] = (float)$this->total_paid_tax_incl; - $fields['total_products'] = (float)$this->total_products; - $fields['total_products_wt'] = (float)$this->total_products_wt; - $fields['total_shipping_tax_excl'] = (float)$this->total_shipping_tax_excl; - $fields['total_shipping_tax_incl'] = (float)$this->total_shipping_tax_incl; - $fields['total_wrapping_tax_excl'] = (float)$this->total_wrapping_tax_excl; - $fields['total_wrapping_tax_incl'] = (float)$this->total_wrapping_tax_incl; - $fields['date_add'] = pSQL($this->date_add); - - return $fields; - } - public function getProductsDetail() { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' diff --git a/classes/order/OrderMessage.php b/classes/order/OrderMessage.php index 725d20d40..445ae1e87 100644 --- a/classes/order/OrderMessage.php +++ b/classes/order/OrderMessage.php @@ -36,14 +36,6 @@ class OrderMessageCore extends ObjectModel /** @var string Object creation date */ public $date_add; - - - - - - - - /** * @see ObjectModel::$definition */ @@ -52,8 +44,11 @@ class OrderMessageCore extends ObjectModel 'primary' => 'id_order_message', 'multilang' => true, 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), - 'message' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isMessage', 'required' => true, 'size' => 1200), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + + // Lang fields + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), + 'message' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isMessage', 'required' => true, 'size' => 1200), ), ); @@ -65,12 +60,6 @@ class OrderMessageCore extends ObjectModel ) ); - public function getFields() - { - $this->validateFields(); - return array('date_add' => pSQL($this->date_add)); - } - public function getTranslationsFieldsChild() { $this->validateFieldsLang(); diff --git a/classes/order/OrderPayment.php b/classes/order/OrderPayment.php index dff12c39b..721f60974 100644 --- a/classes/order/OrderPayment.php +++ b/classes/order/OrderPayment.php @@ -39,10 +39,6 @@ class OrderPaymentCore extends ObjectModel public $card_holder; public $date_add; - - - - /** * @see ObjectModel::$definition */ @@ -50,36 +46,20 @@ class OrderPaymentCore extends ObjectModel 'table' => 'order_payment', 'primary' => 'id_order_payment', 'fields' => array( - 'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'amount' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), - 'payment_method' => array('type' => 'FILL_ME', 'validate' => 'isName'), - 'conversion_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), - 'transaction_id' => array('type' => 'FILL_ME', 'validate' => 'isAnything', 'size' => 254), - 'card_number' => array('type' => 'FILL_ME', 'validate' => 'isAnything', 'size' => 254), - 'card_brand' => array('type' => 'FILL_ME', 'validate' => 'isAnything', 'size' => 254), - 'card_expiration' => array('type' => 'FILL_ME', 'validate' => 'isAnything', 'size' => 254), - 'card_holder' => array('type' => 'FILL_ME', 'validate' => 'isAnything', 'size' => 254), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true), + 'payment_method' => array('type' => self::TYPE_STRING, 'validate' => 'isName'), + 'conversion_rate' => array('type' => self::TYPE_INT, 'validate' => 'isFloat'), + 'transaction_id' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything', 'size' => 254), + 'card_number' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything', 'size' => 254), + 'card_brand' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything', 'size' => 254), + 'card_expiration' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything', 'size' => 254), + 'card_holder' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything', 'size' => 254), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - - public function getFields() - { - $this->validateFields(); - $fields['id_order'] = (int)($this->id_order); - $fields['id_currency'] = (int)($this->id_currency); - $fields['amount'] = (float)($this->amount); - $fields['payment_method'] = pSQL($this->payment_method); - $fields['transaction_id'] = pSQL($this->transaction_id); - $fields['card_number'] = pSQL($this->card_number); - $fields['card_brand'] = pSQL($this->card_brand); - $fields['card_expiration'] = pSQL($this->card_expiration); - $fields['card_holder'] = pSQL($this->card_holder); - $fields['date_add'] = pSQL($this->date_add); - return $fields; - } - public function add($autodate = true, $nullValues = false) { if (parent::add($autodate, $nullValues)) diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 021802b17..fba0f64cc 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -48,9 +48,6 @@ class OrderReturnCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - - - /** * @see ObjectModel::$definition */ @@ -58,27 +55,15 @@ class OrderReturnCore extends ObjectModel 'table' => 'order_return', 'primary' => 'id_order_return', 'fields' => array( - 'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'question' => array('type' => 'FILL_ME', 'validate' => 'isMessage'), + 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'question' => array('type' => self::TYPE_HTML, 'validate' => 'isMessage'), + 'state' => array('type' => self::TYPE_STRING), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - - public function getFields() - { - $this->validateFields(); - - $fields['id_customer'] = pSQL($this->id_customer); - $fields['id_order'] = pSQL($this->id_order); - $fields['state'] = pSQL($this->state); - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - // we don't want to use nl2br now because
will not pass Validation::isMessage() - $fields['question'] = pSQL($this->question, true); - return $fields; - } - public function addReturnDetail($orderDetailList, $productQtyList, $customizationIds, $customizationQtyInput) { /* Classic product return */ diff --git a/classes/order/OrderReturnState.php b/classes/order/OrderReturnState.php index 687be6d70..9ff83d5a8 100644 --- a/classes/order/OrderReturnState.php +++ b/classes/order/OrderReturnState.php @@ -33,11 +33,6 @@ class OrderReturnStateCore extends ObjectModel /** @var string Display state in the specified color */ public $color; - - - - - /** * @see ObjectModel::$definition */ @@ -46,19 +41,13 @@ class OrderReturnStateCore extends ObjectModel 'primary' => 'id_order_return_state', 'multilang' => true, 'fields' => array( - 'color' => array('type' => 'FILL_ME', 'validate' => 'isColor'), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), + 'color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor'), + + // Lang fields + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), ), ); - - public function getFields() - { - $this->validateFields(); - $fields['color'] = pSQL($this->color); - return $fields; - } - /** * Check then return multilingual fields for database interaction * diff --git a/classes/order/OrderSlip.php b/classes/order/OrderSlip.php index 955c96d79..4f60fb007 100644 --- a/classes/order/OrderSlip.php +++ b/classes/order/OrderSlip.php @@ -57,9 +57,6 @@ class OrderSlipCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - - - /** * @see ObjectModel::$definition */ @@ -67,29 +64,18 @@ class OrderSlipCore extends ObjectModel 'table' => 'order_slip', 'primary' => 'id_order_slip', 'fields' => array( - 'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'conversion_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true), + 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'conversion_rate' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true), + 'amount' => array('type' => self::TYPE_INT), + 'shipping_cost' => array('type' => self::TYPE_INT), + 'shipping_cost_amount' => array('type' => self::TYPE_FLOAT), + 'partial' => array('type' => self::TYPE_INT), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); - - public function getFields() - { - $this->validateFields(); - - $fields['id_customer'] = (int)($this->id_customer); - $fields['id_order'] = (int)($this->id_order); - $fields['conversion_rate'] = (float)($this->conversion_rate); - $fields['amount'] = (int)($this->amount); - $fields['shipping_cost'] = (int)($this->shipping_cost); - $fields['shipping_cost_amount'] = (float)($this->shipping_cost_amount); - $fields['partial'] = (int)($this->partial); - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - return $fields; - } - public function addSlipDetail($orderDetailList, $productQtyList) { foreach ($orderDetailList as $key => $orderDetail) diff --git a/classes/order/OrderState.php b/classes/order/OrderState.php index e7a71f8c6..6b0bdfc2b 100644 --- a/classes/order/OrderState.php +++ b/classes/order/OrderState.php @@ -56,12 +56,6 @@ class OrderStateCore extends ObjectModel /** @var boolean Shipped */ public $shipped; - - - - - - /** * @see ObjectModel::$definition */ @@ -70,17 +64,21 @@ class OrderStateCore extends ObjectModel 'primary' => 'id_order_state', 'multilang' => true, 'fields' => array( - 'send_email' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'invoice' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'color' => array('type' => 'FILL_ME', 'validate' => 'isColor'), - 'logable' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'shipped' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), - 'template' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isTplName', 'size' => 64), + 'send_email' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'invoice' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor'), + 'logable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'shipped' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'unremovable' =>array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'delivery' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'hidden' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + + // Lang fields + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), + 'template' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isTplName', 'size' => 64), ), ); - protected $webserviceParameters = array( 'fields' => array( 'unremovable' => array(), @@ -89,20 +87,6 @@ class OrderStateCore extends ObjectModel ), ); - public function getFields() - { - $this->validateFields(); - $fields['send_email'] = (int)$this->send_email; - $fields['invoice'] = (int)$this->invoice; - $fields['color'] = pSQL($this->color); - $fields['unremovable'] = (int)$this->unremovable; - $fields['logable'] = (int)$this->logable; - $fields['delivery'] = (int)$this->delivery; - $fields['hidden'] = (int)$this->hidden; - $fields['shipped'] = (int)$this->shipped; - return $fields; - } - /** * Check then return multilingual fields for database interaction * diff --git a/classes/shop/GroupShop.php b/classes/shop/GroupShop.php index 02a1f5410..9944692a0 100644 --- a/classes/shop/GroupShop.php +++ b/classes/shop/GroupShop.php @@ -37,9 +37,6 @@ class GroupShopCore extends ObjectModel public $share_order; public $deleted; - - - /** * @see ObjectModel::$definition */ @@ -47,15 +44,15 @@ class GroupShopCore extends ObjectModel 'table' => 'group_shop', 'primary' => 'id_group_shop', 'fields' => array( - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'share_customer' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'share_order' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'share_stock' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'size' => 64), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 64), + 'share_customer' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'share_order' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'share_stock' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), ), ); - private static $assoTables = array( 'attribute_group' => array('type' => 'group_shop'), 'attribute' => array('type' => 'group_shop'), @@ -67,17 +64,16 @@ class GroupShopCore extends ObjectModel 'tax_rules_group' => array('type' => 'group_shop'), ); + /** + * @see ObjectModel::getFields() + * @return array + */ public function getFields() { - $this->validateFields(); + if (!$this->share_customer || !$this->share_stock) + $this->share_order = false; - $fields['name'] = pSQL($this->name); - $fields['share_customer'] = (int)$this->share_customer; - $fields['share_stock'] = (int)$this->share_stock; - $fields['share_order'] = ($fields['share_customer'] && $fields['share_stock']) ? (int)$this->share_order : false; - $fields['active'] = (int)$this->active; - $fields['deleted'] = (int)$this->deleted; - return $fields; + return parent::getFields(); } public static function getGroupShops($active = true) diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index b73c06ec2..6bf05f37a 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -48,10 +48,6 @@ class ShopCore extends ObjectModel */ protected $group; - - - - /** * @see ObjectModel::$definition */ @@ -59,15 +55,15 @@ class ShopCore extends ObjectModel 'table' => 'shop', 'primary' => 'id_shop', 'fields' => array( - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 64), - 'id_theme' => array('type' => 'FILL_ME', 'required' => true), - 'id_category' => array('type' => 'FILL_ME', 'required' => true), - 'id_group_shop' => array('type' => 'FILL_ME', 'required' => true), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), + 'id_theme' => array('type' => self::TYPE_INT, 'required' => true), + 'id_category' => array('type' => self::TYPE_INT, 'required' => true), + 'id_group_shop' => array('type' => self::TYPE_INT, 'required' => true), ), ); - /** @var array List of shops cached */ protected static $shops; @@ -120,19 +116,6 @@ class ShopCore extends ObjectModel const SHARE_CUSTOMER = 'share_customer'; const SHARE_ORDER = 'share_order'; - public function getFields() - { - $this->validateFields(); - - $fields['id_group_shop'] = (int)$this->id_group_shop; - $fields['id_category'] = (int)$this->id_category; - $fields['id_theme'] = (int)$this->id_theme; - $fields['name'] = pSQL($this->name); - $fields['active'] = (int)$this->active; - $fields['deleted'] = (int)$this->deleted; - return $fields; - } - public function __construct($id = null, $id_lang = null, $id_shop = null) { parent::__construct($id, $id_lang, $id_shop); diff --git a/classes/shop/ShopUrl.php b/classes/shop/ShopUrl.php index 4d2680d78..0593f4dbf 100644 --- a/classes/shop/ShopUrl.php +++ b/classes/shop/ShopUrl.php @@ -38,10 +38,6 @@ class ShopUrlCore extends ObjectModel private static $main_domain = null; private static $main_domain_ssl = null; - - - - /** * @see ObjectModel::$definition */ @@ -49,19 +45,22 @@ class ShopUrlCore extends ObjectModel 'table' => 'shop_url', 'primary' => 'id_shop_url', 'fields' => array( - 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), - 'domain' => array('type' => 'FILL_ME', 'required' => true, 'size' => 255), - 'id_shop' => array('type' => 'FILL_ME', 'required' => true), - 'physical_uri' => array('type' => 'FILL_ME', 'size' => 64), - 'virtual_uri' => array('type' => 'FILL_ME', 'size' => 64), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'main' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'domain' => array('type' => self::TYPE_STRING, 'required' => true, 'size' => 255), + 'domain_ssl' => array('type' => self::TYPE_STRING, 'size' => 255), + 'id_shop' => array('type' => self::TYPE_INT, 'required' => true), + 'physical_uri' => array('type' => self::TYPE_STRING, 'size' => 64), + 'virtual_uri' => array('type' => self::TYPE_STRING, 'size' => 64), ), ); - + /** + * @see ObjectModel::getFields() + * @return array + */ public function getFields() { - $this->validateFields(); - $this->physical_uri = trim($this->physical_uri, '/'); if ($this->physical_uri) $this->physical_uri = preg_replace('#/+#', '/', '/'.$this->physical_uri.'/'); @@ -72,14 +71,7 @@ class ShopUrlCore extends ObjectModel if ($this->virtual_uri) $this->virtual_uri = preg_replace('#/+#', '/', trim($this->virtual_uri, '/')).'/'; - $fields['domain'] = pSQL($this->domain); - $fields['domain_ssl'] = pSQL($this->domain_ssl); - $fields['physical_uri'] = pSQL($this->physical_uri); - $fields['virtual_uri'] = pSQL($this->virtual_uri); - $fields['id_shop'] = (int)$this->id_shop; - $fields['main'] = (int)$this->main; - $fields['active'] = (int)$this->active; - return $fields; + return parent::getFields(); } public function getURL($ssl = false) diff --git a/classes/stock/Stock.php b/classes/stock/Stock.php index b08c08c81..cb2fea26f 100644 --- a/classes/stock/Stock.php +++ b/classes/stock/Stock.php @@ -59,12 +59,6 @@ class StockCore extends ObjectModel /** @var int the unit price without tax forthe current product */ public $price_te; - - - - - - /** * @see ObjectModel::$definition */ @@ -72,36 +66,18 @@ class StockCore extends ObjectModel 'table' => 'stock', 'primary' => 'id_stock', 'fields' => array( - 'id_warehouse' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_product_attribute' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'reference' => array('type' => 'FILL_ME', 'validate' => 'isReference'), - 'ean13' => array('type' => 'FILL_ME', 'validate' => 'isEan13'), - 'upc' => array('type' => 'FILL_ME', 'validate' => 'isUpc'), - 'physical_quantity' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'required' => true), - 'usable_quantity' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true), - 'price_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), + 'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'reference' => array('type' => self::TYPE_STRING, 'validate' => 'isReference'), + 'ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isEan13'), + 'upc' => array('type' => self::TYPE_STRING, 'validate' => 'isUpc'), + 'physical_quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), + 'usable_quantity' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true), + 'price_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true), ), ); - - public function getFields() - { - $this->validateFields(); - - $fields['id_warehouse'] = (int)$this->id_warehouse; - $fields['id_product'] = (int)$this->id_product; - $fields['id_product_attribute'] = (int)$this->id_product_attribute; - $fields['reference'] = pSQL($this->reference); - $fields['ean13'] = pSQL($this->ean13); - $fields['upc'] = pSQL($this->upc); - $fields['physical_quantity'] = (int)$this->physical_quantity; - $fields['usable_quantity'] = (int)$this->usable_quantity; - $fields['price_te'] = (float)round($this->price_te, 6); - - return $fields; - } - /** * @see ObjectModel::update() */ diff --git a/classes/stock/StockAvailable.php b/classes/stock/StockAvailable.php index 438f665c3..f8fb49f3e 100644 --- a/classes/stock/StockAvailable.php +++ b/classes/stock/StockAvailable.php @@ -54,12 +54,6 @@ class StockAvailableCore extends ObjectModel /** @var bool determine if a product is out of stock - it was previously in Product class */ public $out_of_stock = 0; - - - - - - /** * @see ObjectModel::$definition */ @@ -67,31 +61,16 @@ class StockAvailableCore extends ObjectModel 'table' => 'stock_available', 'primary' => 'id_stock_available', 'fields' => array( - 'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_product_attribute' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_group_shop' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'quantity' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true), - 'depends_on_stock' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true), - 'out_of_stock' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true), + 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_group_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'quantity' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true), + 'depends_on_stock' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), + 'out_of_stock' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true), ), ); - - public function getFields() - { - $this->validateFields(); - $fields['id_product'] = (int)$this->id_product; - $fields['id_product_attribute'] = (int)$this->id_product_attribute; - $fields['id_shop'] = (int)$this->id_shop; - $fields['id_group_shop'] = (int)$this->id_group_shop; - $fields['quantity'] = (int)$this->quantity; - // booleans can NOT be inserted in an INTEGER database field - $fields['depends_on_stock'] = (int)(bool)$this->depends_on_stock; - $fields['out_of_stock'] = (int)$this->out_of_stock; - return $fields; - } - /** * For a given {id_product, id_product_attribute and id_shop}, gets the stock available id associated * diff --git a/classes/stock/StockMvt.php b/classes/stock/StockMvt.php index b87f8a3e2..15aa6b5ef 100644 --- a/classes/stock/StockMvt.php +++ b/classes/stock/StockMvt.php @@ -129,28 +129,23 @@ class StockMvtCore extends ObjectModel 'table' => 'stock_mvt', 'primary' => 'id_stock_mvt', 'fields' => array( - 'date_add' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'required' => true), - 'id_employee' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'employee_firstname' => array('type' => 'FILL_ME', 'validate' => 'isName'), - 'employee_lastname' => array('type' => 'FILL_ME', 'validate' => 'isName'), - 'id_stock' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'physical_quantity' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'required' => true), - 'id_stock_mvt_reason' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'id_supply_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), - 'sign' => array('type' => 'FILL_ME', 'validate' => 'isInt', 'required' => true), - 'last_wa' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'current_wa' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'price_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), - 'referer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), + 'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'employee_firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName'), + 'employee_lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName'), + 'id_stock' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'physical_quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), + 'id_stock_mvt_reason' =>array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_supply_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'sign' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true), + 'last_wa' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'current_wa' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'price_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true), + 'referer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true), ), ); - - - - - protected $webserviceParameters = array( 'objectsNodeName' => 'stock_movements', 'objectNodeName' => 'stock_movement', @@ -162,26 +157,6 @@ class StockMvtCore extends ObjectModel ), ); - public function getFields() - { - $this->validateFields(); - $fields['date_add'] = pSQL($this->date_add); - $fields['id_employee'] = (int)$this->id_employee; - $fields['employee_lastname'] = pSQL($this->employee_lastname); - $fields['employee_firstname'] = pSQL(Tools::ucfirst($this->employee_firstname)); - $fields['id_stock'] = (int)$this->id_stock; - $fields['physical_quantity'] = (int)$this->physical_quantity; - $fields['id_stock_mvt_reason'] = (int)$this->id_stock_mvt_reason; - $fields['id_order'] = (int)$this->id_order; - $fields['id_supply_order'] = (int)$this->id_supply_order; - $fields['sign'] = (int)$this->sign; - $fields['last_wa'] = (float)Tools::ps_round($this->last_wa, 6); - $fields['current_wa'] = (float)Tools::ps_round($this->current_wa, 6); - $fields['price_te'] = (float)Tools::ps_round($this->price_te, 6); - $fields['referer'] = (int)$this->referer; - return $fields; - } - /** * @deprecated since 1.5.0 * diff --git a/classes/stock/StockMvtReason.php b/classes/stock/StockMvtReason.php index 3bc7fee9c..3cc99e82b 100644 --- a/classes/stock/StockMvtReason.php +++ b/classes/stock/StockMvtReason.php @@ -53,30 +53,21 @@ class StockMvtReasonCore extends ObjectModel 'primary' => 'id_stock_mvt_reason', 'multilang' => true, 'fields' => array( - 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255), + 'sign' => array('type' => self::TYPE_INT), + 'deleted' => array('type' => self::TYPE_BOOL), + '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' => 'isGenericName', 'required' => true, 'size' => 255), ), ); - - - - - protected $webserviceParameters = array( 'objectsNodeName' => 'stock_movement_reasons', 'objectNodeName' => 'stock_movement_reason', ); - public function getFields() - { - $this->validateFields(); - $fields['sign'] = (int)$this->sign; - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - $fields['deleted'] = (int)$this->deleted; - return $fields; - } - public function getTranslationsFieldsChild() { $this->validateFieldsLang(); diff --git a/classes/stock/SupplyOrder.php b/classes/stock/SupplyOrder.php index 943ea131b..94583d43b 100755 --- a/classes/stock/SupplyOrder.php +++ b/classes/stock/SupplyOrder.php @@ -120,10 +120,6 @@ class SupplyOrderCore extends ObjectModel */ public $is_template = 0; - - - - /** * @var array Contains object definition * @see ObjectModel::definition @@ -135,54 +131,27 @@ class SupplyOrderCore extends ObjectModel 'table' => 'supply_order', 'primary' => 'id_supply_order', 'fields' => array( - 'id_supplier' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'supplier_name' => array('type' => 'FILL_ME', 'validate' => 'isCatalogName', 'required' => true), - 'id_lang' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_warehouse' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_supply_order_state' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'id_ref_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), - 'reference' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true), - 'date_add' => array('type' => 'FILL_ME', 'validate' => 'isDate'), - 'date_upd' => array('type' => 'FILL_ME', 'validate' => 'isDate'), - 'date_delivery_expected' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'required' => true), - 'total_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_with_discount_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_ti' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'total_tax' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'discount_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true), - 'discount_value_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice'), - 'is_template' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'supplier_name' => array('type' => self::TYPE_STRING, 'validate' => 'isCatalogName', 'required' => true), + 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_supply_order_state' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'id_ref_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'reference' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true), + 'date_delivery_expected' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true), + 'total_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_with_discount_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_ti' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'total_tax' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'discount_rate' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true), + 'discount_value_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), + 'is_template' => 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'), ), ); - - public function getFields() - { - $this->validateFields(); - - $fields['id_supplier'] = (int)$this->id_supplier; - $fields['supplier_name'] = pSQL($this->supplier_name); - $fields['id_lang'] = (int)$this->id_lang; - $fields['id_warehouse'] = (int)$this->id_warehouse; - $fields['id_supply_order_state'] = (int)$this->id_supply_order_state; - $fields['id_currency'] = (int)$this->id_currency; - $fields['id_ref_currency'] = (int)$this->id_ref_currency; - $fields['reference'] = pSQL($this->reference); - $fields['date_add'] = pSQL($this->date_add); - $fields['date_upd'] = pSQL($this->date_upd); - $fields['date_delivery_expected'] = pSQL($this->date_delivery_expected); - $fields['total_te'] = (float)$this->total_te; - $fields['total_with_discount_te'] = (float)$this->total_with_discount_te; - $fields['total_ti'] = (float)$this->total_ti; - $fields['total_tax'] = (float)$this->total_tax; - $fields['discount_rate'] = (float)$this->discount_rate; - $fields['discount_value_te'] = (float)$this->discount_value_te; - $fields['is_template'] = (int)(bool)$this->is_template; - - return $fields; - } - /** * @see ObjectModel::update() */