diff --git a/classes/Address.php b/classes/Address.php index 76651b940..e40e96176 100644 --- a/classes/Address.php +++ b/classes/Address.php @@ -102,23 +102,41 @@ class AddressCore extends ObjectModel protected static $_idZones = array(); protected static $_idCountries = array(); - protected $fieldsRequired = array('id_country', 'alias', 'lastname', 'firstname', 'address1', 'city'); - protected $fieldsSize = array('alias' => 32, 'company' => 32, 'lastname' => 32, 'firstname' => 32, - 'address1' => 128, 'address2' => 128, 'postcode' => 12, 'city' => 64, - 'other' => 300, 'phone' => 16, 'phone_mobile' => 16, 'dni' => 16); - protected $fieldsValidate = array('id_customer' => 'isNullOrUnsignedId', 'id_manufacturer' => 'isNullOrUnsignedId', - 'id_supplier' => 'isNullOrUnsignedId', 'id_warehouse' => 'isNullOrUnsignedId', - 'id_country' => 'isUnsignedId', 'id_state' => 'isNullOrUnsignedId', - 'alias' => 'isGenericName', 'company' => 'isGenericName', 'lastname' => 'isName','vat_number' => 'isGenericName', - 'firstname' => 'isName', 'address1' => 'isAddress', 'address2' => 'isAddress', 'postcode'=>'isPostCode', - 'city' => 'isCityName', 'other' => 'isMessage', - 'phone' => 'isPhoneNumber', 'phone_mobile' => 'isPhoneNumber', 'deleted' => 'isBool', 'dni' => 'isDniLite'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'address', 'primary' => 'id_address', + 'fields' => array( + 'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isNullOrUnsignedId'), + 'id_manufacturer' => array('type' => 'FILL_ME', 'validate' => 'isNullOrUnsignedId'), + 'id_supplier' => array('type' => 'FILL_ME', 'validate' => 'isNullOrUnsignedId'), + 'id_warehouse' => array('type' => 'FILL_ME', 'validate' => 'isNullOrUnsignedId'), + 'id_country' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'id_state' => array('type' => 'FILL_ME', 'validate' => 'isNullOrUnsignedId'), + 'alias' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 32), + 'company' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'size' => 32), + 'lastname' => array('type' => 'FILL_ME', 'validate' => 'isName', 'required' => true, 'size' => 32), + 'vat_number' => array('type' => 'FILL_ME', 'validate' => 'isGenericName'), + 'firstname' => array('type' => 'FILL_ME', 'validate' => 'isName', 'required' => true, 'size' => 32), + 'address1' => array('type' => 'FILL_ME', 'validate' => 'isAddress', 'required' => true, 'size' => 128), + 'address2' => array('type' => 'FILL_ME', 'validate' => 'isAddress', 'size' => 128), + 'postcode' => array('type' => 'FILL_ME', 'validate' => 'isPostCode', 'size' => 12), + 'city' => array('type' => 'FILL_ME', 'validate' => 'isCityName', 'required' => true, 'size' => 64), + 'other' => array('type' => 'FILL_ME', 'validate' => 'isMessage', 'size' => 300), + 'phone' => array('type' => 'FILL_ME', 'validate' => 'isPhoneNumber', 'size' => 16), + 'phone_mobile' => array('type' => 'FILL_ME', 'validate' => 'isPhoneNumber', 'size' => 16), + 'deleted' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'dni' => array('type' => 'FILL_ME', 'validate' => 'isDniLite', 'size' => 16), + ), ); + protected $_includeVars = array('addressType' => 'table'); protected $_includeContainer = false; diff --git a/classes/AddressFormat.php b/classes/AddressFormat.php index 8e3af80a3..490a9089d 100644 --- a/classes/AddressFormat.php +++ b/classes/AddressFormat.php @@ -38,15 +38,22 @@ class AddressFormatCore extends ObjectModel private $_errorFormatList = array(); - protected $fieldsRequired = array ('format'); - protected $fieldsValidate = array ('format' => 'isGenericName'); + + /* MySQL does not allow 'order detail' for a table name */ + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'address_format', 'primary' => 'id_country', + 'fields' => array( + 'format' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true), + ), ); + public static $requireFormFieldsList = array( 'firstname', 'name', diff --git a/classes/Alias.php b/classes/Alias.php index 5171c3edd..2667b3fce 100644 --- a/classes/Alias.php +++ b/classes/Alias.php @@ -31,15 +31,24 @@ class AliasCore extends ObjectModel public $search; public $active = true; - protected $fieldsRequired = array('alias', 'search'); - protected $fieldsSize = array('alias' => 255, 'search' => 255); - protected $fieldsValidate = array('search' => 'isValidSearch', 'alias' => 'isValidSearch', 'active' => 'isBool'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'alias', 'primary' => 'id_alias', + 'fields' => array( + 'search' => array('type' => 'FILL_ME', 'validate' => 'isValidSearch', 'required' => true, 'size' => 255), + 'alias' => array('type' => 'FILL_ME', 'validate' => 'isValidSearch', 'required' => true, 'size' => 255), + 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + ), ); + public function __construct($id = NULL, $alias = NULL, $search = NULL, $id_lang = NULL) { if ($id) diff --git a/classes/Attachment.php b/classes/Attachment.php index 66d764593..c1f116434 100644 --- a/classes/Attachment.php +++ b/classes/Attachment.php @@ -36,20 +36,31 @@ class AttachmentCore extends ObjectModel /** @var integer position */ public $position; - protected $fieldsRequired = array('file', 'mime'); - protected $fieldsSize = array('file' => 40, 'mime' => 128, 'file_name' => 128); - protected $fieldsValidate = array('file' => 'isGenericName', 'mime' => 'isCleanHtml', 'file_name' => 'isGenericName'); + + + - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 32); - protected $fieldsValidateLang = array('name' => 'isGenericName', 'description' => 'isCleanHtml'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'attachment', 'primary' => 'id_attachment', 'multilang' => true, + 'fields' => array( + 'file' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 40), + 'mime' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'required' => true, 'size' => 128), + 'file_name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'size' => 128), + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), + 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCleanHtml'), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/Attribute.php b/classes/Attribute.php index 03439d39f..c93d62dd9 100644 --- a/classes/Attribute.php +++ b/classes/Attribute.php @@ -36,18 +36,28 @@ class AttributeCore extends ObjectModel public $position; public $default; - protected $fieldsRequired = array('id_attribute_group'); - protected $fieldsValidate = array('id_attribute_group' => 'isUnsignedId', 'color' => 'isColor', 'position' => 'isInt'); - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 64); - protected $fieldsValidateLang = array('name' => 'isGenericName'); + + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'attribute', 'primary' => 'id_attribute', 'multilang' => true, + 'fields' => array( + 'id_attribute_group' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'color' => array('type' => 'FILL_ME', 'validate' => 'isColor'), + 'position' => array('type' => 'FILL_ME', 'validate' => 'isInt'), + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), + ), ); + protected $image_dir = _PS_COL_IMG_DIR_; protected $webserviceParameters = array( diff --git a/classes/AttributeGroup.php b/classes/AttributeGroup.php index a77f7decd..d8416c494 100644 --- a/classes/AttributeGroup.php +++ b/classes/AttributeGroup.php @@ -36,18 +36,28 @@ class AttributeGroupCore extends ObjectModel /** @var string Public Name */ public $public_name; - protected $fieldsRequired = array(); - protected $fieldsValidate = array('is_color_group' => 'isBool'); - protected $fieldsRequiredLang = array('name', 'public_name'); - protected $fieldsSizeLang = array('name' => 64, 'public_name' => 64); - protected $fieldsValidateLang = array('name' => 'isGenericName', 'public_name' => 'isGenericName', 'position' => 'isInt'); + + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'attribute_group', 'primary' => 'id_attribute_group', 'multilang' => true, + 'fields' => array( + 'is_color_group' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), + 'public_name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), + 'position' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isInt'), + ), ); + protected $webserviceParameters = array( 'objectsNodeName' => 'product_options', 'objectNodeName' => 'product_option', diff --git a/classes/CMS.php b/classes/CMS.php index 97f36bae5..d13f4c44b 100644 --- a/classes/CMS.php +++ b/classes/CMS.php @@ -37,17 +37,29 @@ class CMSCore extends ObjectModel public $position; public $active; - protected $fieldsValidate = array('id_cms_category' => 'isUnsignedInt'); - protected $fieldsRequiredLang = array('meta_title', 'link_rewrite'); - protected $fieldsSizeLang = array('meta_description' => 255, 'meta_keywords' => 255, 'meta_title' => 128, 'link_rewrite' => 128, 'content' => 3999999999999); - protected $fieldsValidateLang = array('meta_description' => 'isGenericName', 'meta_keywords' => 'isGenericName', 'meta_title' => 'isGenericName', 'link_rewrite' => 'isLinkRewrite', 'content' => 'isString'); + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'cms', 'primary' => 'id_cms', 'multilang' => true, + 'fields' => array( + 'id_cms_category' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'meta_description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + 'meta_keywords' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + 'meta_title' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), + 'link_rewrite' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128), + 'content' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isString', 'size' => 3999999999999), + ), ); + protected $webserviceParameters = array( 'objectNodeName' => 'content', 'objectsNodeName' => 'content_management_system', diff --git a/classes/CMSCategory.php b/classes/CMSCategory.php index 86fa84938..2a158f23c 100644 --- a/classes/CMSCategory.php +++ b/classes/CMSCategory.php @@ -70,20 +70,33 @@ class CMSCategoryCore extends ObjectModel protected static $_links = array(); - protected $fieldsRequired = array('id_parent', 'active'); - protected $fieldsSize = array('id_parent' => 10, 'active' => 1); - protected $fieldsValidate = array('active' => 'isBool', 'id_parent' => 'isUnsignedInt'); - protected $fieldsRequiredLang = array('name', 'link_rewrite'); - protected $fieldsSizeLang = array('name' => 64, 'link_rewrite' => 64, 'meta_title' => 128, 'meta_description' => 255, 'meta_keywords' => 255); - protected $fieldsValidateLang = array('name' => 'isCatalogName', 'link_rewrite' => 'isLinkRewrite', 'description' => 'isCleanHtml', - 'meta_title' => 'isGenericName', 'meta_description' => 'isGenericName', 'meta_keywords' => 'isGenericName'); + + + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'cms_category', 'primary' => 'id_cms_category', 'multilang' => true, + 'fields' => array( + 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true, 'size' => 1), + 'id_parent' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'required' => true, 'size' => 10), + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), + 'link_rewrite' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64), + 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCleanHtml'), + 'meta_title' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), + 'meta_description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + 'meta_keywords' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + ), ); + public function __construct($id_cms_category = NULL, $id_lang = NULL) { parent::__construct($id_cms_category, $id_lang); diff --git a/classes/Carrier.php b/classes/Carrier.php index 8bcfae013..ec361e9d1 100644 --- a/classes/Carrier.php +++ b/classes/Carrier.php @@ -110,23 +110,40 @@ class CarrierCore extends ObjectModel /** @var int grade of the shipping delay (0 for longest, 9 for shortest) */ public $grade; - protected $fieldsRequired = array('name', 'active'); - protected $fieldsSize = array('name' => 64, 'grade' => 1); - protected $fieldsValidate = array('id_tax_rules_group' => 'isInt', 'name' => 'isCarrierName', 'active' => 'isBool', - 'is_free' => 'isBool', 'url' => 'isAbsoluteUrl', 'shipping_handling' => 'isBool', 'range_behavior' => 'isBool', - 'shipping_method' => 'isUnsignedInt', 'max_width' => 'isUnsignedInt', 'max_height' => 'isUnsignedInt', - 'max_deep' => 'isUnsignedInt', 'max_weight' => 'isUnsignedInt', 'grade' => 'isUnsignedInt'); - protected $fieldsRequiredLang = array('delay'); - protected $fieldsSizeLang = array('delay' => 128); - protected $fieldsValidateLang = array('delay' => 'isGenericName'); + + + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'carrier', 'primary' => 'id_carrier', 'multilang' => true, 'multishop' => true, + 'fields' => array( + 'id_tax_rules_group' => array('type' => 'FILL_ME', 'validate' => 'isInt'), + 'name' => array('type' => 'FILL_ME', 'validate' => 'isCarrierName', 'required' => true, 'size' => 64), + 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true), + 'is_free' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'url' => array('type' => 'FILL_ME', 'validate' => 'isAbsoluteUrl'), + 'shipping_handling' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'range_behavior' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'shipping_method' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'max_width' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'max_height' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'max_deep' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'max_weight' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'grade' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'size' => 1), + 'delay' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), + ), ); + protected static $price_by_weight = array(); protected static $price_by_weight2 = array(); protected static $price_by_price = array(); diff --git a/classes/Cart.php b/classes/Cart.php index d582de72c..fa70a2acc 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -84,20 +84,8 @@ class CartCore extends ObjectModel protected static $_nbProducts = array(); protected static $_isVirtualCart = array(); - protected $fieldsRequired = array('id_currency', 'id_lang'); - protected $fieldsValidate = array( - 'id_address_delivery' => 'isUnsignedId', - 'id_carrier' => 'isUnsignedId', - 'id_address_invoice' => 'isUnsignedId', - 'id_currency' => 'isUnsignedId', - 'id_customer' => 'isUnsignedId', - 'id_guest' => 'isUnsignedId', - 'id_lang' => 'isUnsignedId', - 'recyclable' => 'isBool', - 'gift' => 'isBool', - 'gift_message' => 'isMessage', - 'allow_seperated_package' => 'isBool' - ); + + protected $_products = null; protected static $_totalWeight = array(); @@ -106,11 +94,28 @@ class CartCore extends ObjectModel protected static $_taxes_rate = null; protected static $_attributesLists = array(); + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'cart', 'primary' => 'id_cart', + 'fields' => array( + 'id_address_delivery' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), + 'id_carrier' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), + 'id_address_invoice' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), + 'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), + 'id_guest' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), + 'id_lang' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'recyclable' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'gift' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'gift_message' => array('type' => 'FILL_ME', 'validate' => 'isMessage'), + 'allow_seperated_package' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + ), ); + protected $webserviceParameters = array( 'fields' => array( 'id_address_delivery' => array('xlink_resource' => 'addresses'), diff --git a/classes/CartRule.php b/classes/CartRule.php index 0bd3d1725..ba7d52a6b 100644 --- a/classes/CartRule.php +++ b/classes/CartRule.php @@ -57,46 +57,52 @@ class CartRuleCore extends ObjectModel public $date_add; public $date_upd; + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'cart_rule', 'primary' => 'id_cart_rule', 'multilang' => true, + 'fields' => array( + 'id_customer' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), + 'date_from' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'required' => true), + 'date_to' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'required' => true), + 'description' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'size' => 65534), + 'quantity' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'quantity_per_user' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'priority' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'code' => array('type' => 'FILL_ME', 'validate' => 'isCleanHtml', 'size' => 254), + 'minimum_amount' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), + 'minimum_amount_tax' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'minimum_amount_currency' => array('type' => 'FILL_ME', 'validate' => 'isInt'), + 'minimum_amount_shipping' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'country_restriction' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'carrier_restriction' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'group_restriction' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'cart_rule_restriction' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'product_restriction' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'free_shipping' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'reduction_percent' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), + 'reduction_amount' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), + 'reduction_tax' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'reduction_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), + 'reduction_product' => array('type' => 'FILL_ME', 'validate' => 'isInt'), + 'gift_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), + 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'date_add' => array('type' => 'FILL_ME', 'validate' => 'isDate'), + 'date_upd' => array('type' => 'FILL_ME', 'validate' => 'isDate'), + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 254), + ), ); - protected $fieldsRequired = array('date_from', 'date_to'); - protected $fieldsSize = array('code' => 254, 'description' => 65534); - protected $fieldsValidate = array( - 'id_customer' => 'isUnsignedId', - 'date_from' => 'isDate', - 'date_to' => 'isDate', - 'description' => 'isCleanHtml', - 'quantity' => 'isUnsignedInt', - 'quantity_per_user' => 'isUnsignedInt', - 'priority' => 'isUnsignedInt', - 'code' => 'isCleanHtml', - 'minimum_amount' => 'isFloat', - 'minimum_amount_tax' => 'isBool', - 'minimum_amount_currency' => 'isInt', - 'minimum_amount_shipping' => 'isBool', - 'country_restriction' => 'isBool', - 'carrier_restriction' => 'isBool', - 'group_restriction' => 'isBool', - 'cart_rule_restriction' => 'isBool', - 'product_restriction' => 'isBool', - 'free_shipping' => 'isBool', - 'reduction_percent' => 'isFloat', - 'reduction_amount' => 'isFloat', - 'reduction_tax' => 'isBool', - 'reduction_currency' => 'isUnsignedId', - 'reduction_product' => 'isInt', - 'gift_product' => 'isUnsignedId', - 'active' => 'isBool', - 'date_add' => 'isDate', - 'date_upd' => 'isDate' - ); - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 254); - protected $fieldsValidateLang = array('name' => 'isCleanHtml'); + + + + + + + public function getFields() { diff --git a/classes/Category.php b/classes/Category.php index 2e193803f..90355df8f 100644 --- a/classes/Category.php +++ b/classes/Category.php @@ -78,34 +78,38 @@ class CategoryCore extends ObjectModel protected static $_links = array(); - protected $fieldsRequired = array('active'); - protected $fieldsSize = array('active' => 1); - protected $fieldsValidate = array( - 'nleft' => 'isUnsignedInt', - 'nright' => 'isUnsignedInt', - 'level_depth' => 'isUnsignedInt', - 'active' => 'isBool', - 'id_parent' => 'isUnsignedInt', - 'groupBox' => 'isArrayWithIds' - ); - protected $fieldsRequiredLang = array('name', 'link_rewrite'); - protected $fieldsSizeLang = array('name' => 64, 'link_rewrite' => 64, 'meta_title' => 128, 'meta_description' => 255, 'meta_keywords' => 255); - protected $fieldsValidateLang = array( - 'name' => 'isCatalogName', - 'link_rewrite' => 'isLinkRewrite', - 'description' => 'isString', - 'meta_title' => 'isGenericName', - 'meta_description' => 'isGenericName', - 'meta_keywords' => 'isGenericName' - ); + + + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'category', 'primary' => 'id_category', 'multilang' => true, 'multishop' => true, + 'fields' => array( + 'nleft' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'nright' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'level_depth' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool', 'required' => true, 'size' => 1), + 'id_parent' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'groupBox' => array('type' => 'FILL_ME', 'validate' => 'isArrayWithIds'), + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), + 'link_rewrite' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64), + 'description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isString'), + 'meta_title' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), + 'meta_description' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + 'meta_keywords' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), + ), ); + /** @var string id_image is the category ID when an image exists and 'default' otherwise */ public $id_image = 'default'; diff --git a/classes/Combination.php b/classes/Combination.php index 6fdb78185..c875602d4 100644 --- a/classes/Combination.php +++ b/classes/Combination.php @@ -53,39 +53,34 @@ class CombinationCore extends ObjectModel public $available_date; - protected $fieldsRequired = array( - 'id_product', - ); - protected $fieldsSize = array( - 'reference' => 32, - 'supplier_reference' => 32, - 'location' => 64, - 'ean13' => 13, - 'upc' => 12, - 'wholesale_price' => 27, - 'price' => 20, - 'ecotax' => 20, - 'quantity' => 10 - ); - protected $fieldsValidate = array( - 'id_product' => 'isUnsignedId', - 'location' => 'isGenericName', - 'ean13' => 'isEan13', - 'upc' => 'isUpc', - 'wholesale_price' => 'isPrice', - 'price' => 'isPrice', - 'ecotax' => 'isPrice', - 'quantity' => 'isUnsignedInt', - 'weight' => 'isFloat', - 'default_on' => 'isBool', - 'available_date' => 'isDateFormat', - ); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'product_attribute', 'primary' => 'id_product_attribute', + 'fields' => array( + 'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'location' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'size' => 64), + 'ean13' => array('type' => 'FILL_ME', 'validate' => 'isEan13', 'size' => 13), + 'upc' => array('type' => 'FILL_ME', 'validate' => 'isUpc', 'size' => 12), + 'wholesale_price' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'size' => 27), + 'price' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'size' => 20), + 'ecotax' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'size' => 20), + 'quantity' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'size' => 10), + 'weight' => array('type' => 'FILL_ME', 'validate' => 'isFloat'), + 'default_on' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'available_date' => array('type' => 'FILL_ME', 'validate' => 'isDateFormat'), + 'reference' => array('type' => 'FILL_ME', 'size' => 32), + 'supplier_reference' => array('type' => 'FILL_ME', 'size' => 32), + ), ); + protected $webserviceParameters = array( 'objectNodeName' => 'combination', 'objectsNodeName' => 'combinations', diff --git a/classes/CompareProduct.php b/classes/CompareProduct.php index fb87598b1..c9a82ba39 100644 --- a/classes/CompareProduct.php +++ b/classes/CompareProduct.php @@ -39,15 +39,20 @@ class CompareProductCore extends ObjectModel 'id_compare', 'id_customer'); - protected $fieldsValidate = array( - 'id_compare' => 'isUnsignedInt', - 'id_customer' => 'isUnsignedInt' - ); + + + /** + * @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'), + ), + ); - public static $definition = array( - 'table' => 'compare', - 'primary' => 'id_compare', - ); /** * Get all comapare products of the customer diff --git a/classes/Configuration.php b/classes/Configuration.php index 057e55031..0aa22388b 100644 --- a/classes/Configuration.php +++ b/classes/Configuration.php @@ -44,16 +44,25 @@ class ConfigurationCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - protected $fieldsRequired = array('name'); - protected $fieldsSize = array('name' => 32); - protected $fieldsValidate = array('name' => 'isConfigName', 'id_group_shop' => 'isUnsignedId', 'id_shop' => 'isUnsignedId'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'configuration', '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'), + ), ); + /** @var array Configuration cache */ protected static $_CONF; diff --git a/classes/Connection.php b/classes/Connection.php index 67934cc91..b25be06c5 100644 --- a/classes/Connection.php +++ b/classes/Connection.php @@ -48,16 +48,27 @@ class ConnectionCore extends ObjectModel /** @var string */ public $date_add; - protected $fieldsRequired = array ('id_guest', 'id_page', 'id_shop', 'id_group_shop'); - protected $fieldsValidate = array ('id_guest' => 'isUnsignedId', 'id_page' => 'isUnsignedId', - 'ip_address' => 'isInt', 'http_referer' => 'isAbsoluteUrl'); + + /* MySQL does not allow 'connection' for a table name */ + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + public function getFields() { if (!$this->id_shop) diff --git a/classes/ConnectionsSource.php b/classes/ConnectionsSource.php index 9b99a85e4..8a661545a 100644 --- a/classes/ConnectionsSource.php +++ b/classes/ConnectionsSource.php @@ -35,13 +35,24 @@ class ConnectionsSourceCore extends ObjectModel // Controler les keywords - protected $fieldsRequired = array('id_connections', 'date_add'); - protected $fieldsValidate = array('id_connections' => 'isUnsignedId', 'http_referer' => 'isAbsoluteUrl', 'request_uri' => 'isUrl', 'keywords' => 'isMessage'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + public function getFields() { diff --git a/classes/Contact.php b/classes/Contact.php index 709df5229..8c092c500 100644 --- a/classes/Contact.php +++ b/classes/Contact.php @@ -40,19 +40,29 @@ class ContactCore extends ObjectModel public $customer_service; - protected $fieldsRequired = array(); - protected $fieldsSize = array('email' => 128); - protected $fieldsValidate = array('email' => 'isEmail', 'customer_service' => 'isBool'); - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 32); - protected $fieldsValidateLang = array('name' => 'isGenericName', 'description' => 'isCleanHtml'); + + + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'contact', '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'), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/Country.php b/classes/Country.php index c5852e724..60906c492 100644 --- a/classes/Country.php +++ b/classes/Country.php @@ -64,24 +64,13 @@ class CountryCore extends ObjectModel protected static $_idZones = array(); - protected $fieldsRequired = array('id_zone', 'iso_code', 'contains_states', 'need_identification_number', 'display_tax_label'); - protected $fieldsSize = array('iso_code' => 3); - protected $fieldsValidate = array( - 'id_zone' => 'isUnsignedId', - 'id_currency' => 'isUnsignedId', - 'call_prefix' => 'isInt', - 'iso_code' => 'isLanguageIsoCode', - 'active' => 'isBool', - 'contains_states' => 'isBool', - 'need_identification_number' => 'isBool', - 'need_zip_code' => 'isBool', - 'zip_code_format' => 'isZipCodeFormat', - 'display_tax_label' => 'isBool' - ); + + + - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 64); - protected $fieldsValidateLang = array('name' => 'isGenericName'); + + + protected $webserviceParameters = array( 'objectsNodeName' => 'countries', @@ -91,12 +80,29 @@ class CountryCore extends ObjectModel ), ); + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'country', '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), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/County.php b/classes/County.php index 3d0f4e310..1faa5ccbb 100644 --- a/classes/County.php +++ b/classes/County.php @@ -36,15 +36,24 @@ class CountyCore extends ObjectModel public $id_state; public $active; - protected $fieldsRequired = array('name'); - protected $fieldsSize = array('name' => 64); - protected $fieldsValidate = array('name' => 'isGenericName', 'id_state' => 'isUnsignedId', 'active' => 'isBool'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + private static $_cache_get_counties = array(); private static $_cache_county_zipcode = array(); diff --git a/classes/Currency.php b/classes/Currency.php index 2044c4914..711632486 100644 --- a/classes/Currency.php +++ b/classes/Currency.php @@ -59,17 +59,32 @@ class CurrencyCore extends ObjectModel /** @var int bool active */ public $active; - protected $fieldsRequired = array('name', 'iso_code', 'sign', 'conversion_rate', 'format', 'decimals'); - protected $fieldsSize = array('name' => 32, 'iso_code' => 3, 'iso_code_num' => 3, 'sign' => 8); - protected $fieldsValidate = array('name' => 'isGenericName', 'iso_code' => 'isLanguageIsoCode', 'iso_code_num' => 'isNumericIsoCode', 'blank' => 'isInt', 'sign' => 'isGenericName', - 'format' => 'isUnsignedId', 'decimals' => 'isBool', 'conversion_rate' => 'isFloat', 'deleted' => 'isBool', 'active' => 'isBool'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'currency', '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'), + ), ); + /** @var array Currency cache */ static protected $currencies = array(); diff --git a/classes/Customer.php b/classes/Customer.php index 631f20cfa..620408b63 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -109,25 +109,9 @@ class CustomerCore extends ObjectModel public $groupBox; - protected $fieldsRequired = array('lastname', 'passwd', 'firstname', 'email'); - protected $fieldsSize = array('lastname' => 32, 'passwd' => 32, 'firstname' => 32, 'email' => 128, 'note' => 65000); - protected $fieldsValidate = array( - 'secure_key' => 'isMd5', - 'lastname' => 'isName', - 'firstname' => 'isName', - 'email' => 'isEmail', - 'passwd' => 'isPasswd', - 'id_gender' => 'isUnsignedId', - 'birthday' => 'isBirthDate', - 'newsletter' => 'isBool', - 'optin' => 'isBool', - 'active' => 'isBool', - 'note' => 'isCleanHtml', - 'is_guest' => 'isBool', - 'id_shop' => 'isUnsignedId', - 'id_group_shop' => 'isUnsignedId', - 'groupBox' => 'isArrayWithIds' - ); + + + protected $webserviceParameters = array( 'fields' => array( @@ -141,11 +125,32 @@ class CustomerCore extends ObjectModel ), ); + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + protected static $_defaultGroupId = array(); protected static $_customerHasAddress = array(); protected static $_customer_groups = array(); diff --git a/classes/CustomerMessage.php b/classes/CustomerMessage.php index d8b69d19c..853641957 100644 --- a/classes/CustomerMessage.php +++ b/classes/CustomerMessage.php @@ -37,14 +37,23 @@ class CustomerMessageCore extends ObjectModel public $private; public $date_add; + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); - protected $fieldsRequired = array('message'); - protected $fieldsSize = array('message' => 65000); - protected $fieldsValidate = array('message' => 'isCleanHtml', 'id_employee' => 'isUnsignedId', 'ip_address' => 'isIp2Long'); + + + + public function getFields() { diff --git a/classes/CustomerThread.php b/classes/CustomerThread.php index e26fdf589..3a32c783f 100644 --- a/classes/CustomerThread.php +++ b/classes/CustomerThread.php @@ -40,24 +40,29 @@ class CustomerThreadCore extends ObjectModel public $date_add; public $date_upd; + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); - protected $fieldsRequired = array('id_lang', 'id_contact', 'token'); - protected $fieldsSize = array('email' => 254); - protected $fieldsValidate = array( - 'id_lang' => 'isUnsignedId', - 'id_contact' => 'isUnsignedId', - 'id_shop' => 'isUnsignedId', - 'id_customer' => 'isUnsignedId', - 'id_order' => 'isUnsignedId', - 'id_product' => 'isUnsignedId', - 'email' => 'isEmail', - 'token' => 'isGenericName' - ); + + + + public function getFields() { diff --git a/classes/DateRange.php b/classes/DateRange.php index eb7ef2c30..f7c88d5ef 100644 --- a/classes/DateRange.php +++ b/classes/DateRange.php @@ -30,13 +30,21 @@ class DateRangeCore extends ObjectModel public $time_start; public $time_end; - protected $fieldsRequired = array ('time_start', 'time_end'); - protected $fieldsValidate = array ('time_start' => 'isDate', 'time_end' => 'isDate'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + public function getFields() { diff --git a/classes/Delivery.php b/classes/Delivery.php index 09f25edb1..34fa79bee 100644 --- a/classes/Delivery.php +++ b/classes/Delivery.php @@ -51,27 +51,26 @@ class DeliveryCore extends ObjectModel /** @var float */ public $price; - protected $fieldsRequired = array ( - 'id_carrier', - 'id_range_price', - 'id_range_weight', - 'id_zone', - 'price' - ); + - protected $fieldsValidate = array ( - 'id_carrier' => 'isUnsignedId', - 'id_range_price' => 'isUnsignedId', - 'id_range_weight' => 'isUnsignedId', - 'id_zone' => 'isUnsignedId', - 'price' => 'isPrice' - ); + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + protected $webserviceParameters = array( 'objectsNodeName' => 'deliveries', 'fields' => array( diff --git a/classes/Employee.php b/classes/Employee.php index 90eb0d038..fbbb0e874 100644 --- a/classes/Employee.php +++ b/classes/Employee.php @@ -67,17 +67,31 @@ class EmployeeCore extends ObjectModel public $remote_addr; - protected $fieldsRequired = array('lastname', 'firstname', 'email', 'passwd', 'id_profile', 'id_lang'); - protected $fieldsSize = array('lastname' => 32, 'firstname' => 32, 'email' => 128, 'passwd' => 32, 'bo_color' => 32, 'bo_theme' => 32); - protected $fieldsValidate = array('lastname' => 'isName', 'firstname' => 'isName', 'email' => 'isEmail', 'id_lang' => 'isUnsignedInt', - 'passwd' => 'isPasswdAdmin', 'active' => 'isBool', 'id_profile' => 'isInt', 'bo_color' => 'isColor', 'bo_theme' => 'isGenericName', - 'bo_show_screencast' => 'isBool'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + protected $webserviceParameters = array( 'fields' => array( 'id_lang' => array('xlink_resource' => 'languages'), diff --git a/classes/Feature.php b/classes/Feature.php index 88ccd9535..894eaa42b 100644 --- a/classes/Feature.php +++ b/classes/Feature.php @@ -31,18 +31,23 @@ class FeatureCore extends ObjectModel public $name; public $position; - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 128); - protected $fieldsValidateLang = array( - 'name' => 'isGenericName', - 'position' => 'isInt' - ); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + protected $webserviceParameters = array( 'objectsNodeName' => 'product_features', 'objectNodeName' => 'product_feature', diff --git a/classes/FeatureValue.php b/classes/FeatureValue.php index 3d0aeb732..7369447e7 100644 --- a/classes/FeatureValue.php +++ b/classes/FeatureValue.php @@ -36,22 +36,28 @@ class FeatureValueCore extends ObjectModel /** @var boolean Custom */ public $custom = 0; - protected $fieldsRequired = array('id_feature'); - protected $fieldsValidate = array( - 'id_feature' => 'isUnsignedId', - 'custom' => 'isBool' - ); + + - protected $fieldsRequiredLang = array('value'); - protected $fieldsSizeLang = array('value' => 255); - protected $fieldsValidateLang = array('value' => 'isGenericName'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'feature_value', '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), + ), ); + protected $webserviceParameters = array( 'objectsNodeName' => 'product_feature_values', 'objectNodeName' => 'product_feature_value', diff --git a/classes/Gender.php b/classes/Gender.php index 5be2a1055..079ad31ec 100644 --- a/classes/Gender.php +++ b/classes/Gender.php @@ -34,19 +34,27 @@ class GenderCore extends ObjectModel public $name; public $type; - protected $fieldsRequired = array('type'); - protected $fieldsSize = array(); - protected $fieldsValidate = array(); - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 20); - protected $fieldsValidateLang = array('name' => 'isString'); + + + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'gender', 'primary' => 'id_gender', 'multilang' => true, + 'fields' => array( + 'type' => array('type' => 'FILL_ME', 'required' => true), + '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); diff --git a/classes/Group.php b/classes/Group.php index 40886c9ea..e46e5f4db 100644 --- a/classes/Group.php +++ b/classes/Group.php @@ -44,20 +44,29 @@ class GroupCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - protected $fieldsRequired = array('price_display_method'); - protected $fieldsSize = array(); - protected $fieldsValidate = array('reduction' => 'isFloat', 'price_display_method' => 'isPriceDisplayMethod'); + + + - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 32); - protected $fieldsValidateLang = array('name' => 'isGenericName'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'group', '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), + ), ); + protected static $cache_reduction = array(); protected static $group_price_display_method = array(); diff --git a/classes/GroupReduction.php b/classes/GroupReduction.php index dcf34157c..edb7f8ae5 100644 --- a/classes/GroupReduction.php +++ b/classes/GroupReduction.php @@ -31,14 +31,23 @@ class GroupReductionCore extends ObjectModel public $id_category; public $reduction; - protected $fieldsRequired = array('id_group', 'id_category', 'reduction'); - protected $fieldsValidate = array('id_group' => 'isUnsignedId', 'id_category' => 'isUnsignedId', 'reduction' => 'isPrice'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + protected static $reduction_cache = array(); public function getFields() diff --git a/classes/Guest.php b/classes/Guest.php index 2ef23e711..ebecfda92 100644 --- a/classes/Guest.php +++ b/classes/Guest.php @@ -42,28 +42,33 @@ class GuestCore extends ObjectModel public $windows_media; public $accept_language; - protected $fieldsSize = array('accept_language' => 8); - protected $fieldsValidate = array( - 'id_operating_system' => 'isUnsignedId', - 'id_web_browser' => 'isUnsignedId', - 'id_customer' => 'isUnsignedId', - 'javascript' => 'isBool', - 'screen_resolution_x' => 'isInt', - 'screen_resolution_y' => 'isInt', - 'screen_color' => 'isInt', - 'sun_java' => 'isBool', - 'adobe_flash' => 'isBool', - 'adobe_director' => 'isBool', - 'apple_quicktime' => 'isBool', - 'real_player' => 'isBool', - 'windows_media' => 'isBool', - 'accept_language' => 'isGenericName' - ); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + protected $webserviceParameters = array( 'fields' => array( diff --git a/classes/Hook.php b/classes/Hook.php index bcb8ef679..b733899dd 100644 --- a/classes/Hook.php +++ b/classes/Hook.php @@ -31,15 +31,22 @@ class HookCore extends ObjectModel public $name; public $title; - protected $fieldsRequired = array('name'); - protected $fieldsSize = array('name' => 32); - protected $fieldsValidate = array('name' => 'isHookName'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'hook', 'primary' => 'id_hook', + 'fields' => array( + 'name' => array('type' => 'FILL_ME', 'validate' => 'isHookName', 'required' => true, 'size' => 32), + ), ); + protected static $_hookModulesCache; static $preloadModulesFromHooks = null; diff --git a/classes/Image.php b/classes/Image.php index fbfd6d7b4..e0ec6cd49 100644 --- a/classes/Image.php +++ b/classes/Image.php @@ -59,18 +59,28 @@ class ImageCore extends ObjectModel /** @var int access rights of created folders (octal) */ protected static $access_rights = 0775; - protected $fieldsRequired = array('id_product'); - protected $fieldsValidate = array('id_product' => 'isUnsignedId', 'position' => 'isUnsignedInt', 'cover' => 'isBool'); - protected $fieldsRequiredLang = array('legend'); - protected $fieldsSizeLang = array('legend' => 128); - protected $fieldsValidateLang = array('legend' => 'isGenericName'); + + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'image', '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), + ), ); + protected static $_cacheGetSize = array(); public function __construct($id = null, $id_lang = null) diff --git a/classes/ImageType.php b/classes/ImageType.php index 7deb88700..5508ea0bd 100644 --- a/classes/ImageType.php +++ b/classes/ImageType.php @@ -56,25 +56,30 @@ class ImageTypeCore extends ObjectModel /** @var integer Apply to store */ public $stores; - protected $fieldsRequired = array('name', 'width', 'height'); - protected $fieldsValidate = array( - 'name' => 'isImageTypeName', - 'width' => 'isImageSize', - 'height' => 'isImageSize', - 'categories' => 'isBool', - 'products' => 'isBool', - 'manufacturers' => 'isBool', - 'suppliers' => 'isBool', - 'scenes' => 'isBool', - 'stores' => 'isBool' - ); - protected $fieldsSize = array('name' => 16); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + /** * @var array Image types cache */ diff --git a/classes/Language.php b/classes/Language.php index 94c8bc2f2..94379209a 100644 --- a/classes/Language.php +++ b/classes/Language.php @@ -50,16 +50,28 @@ class LanguageCore extends ObjectModel /** @var boolean Status */ public $active = true; - protected $fieldsRequired = array('name', 'iso_code', 'date_format_lite', 'date_format_full'); - protected $fieldsSize = array('name' => 32, 'iso_code' => 2, 'language_code' => 5, 'date_format_lite' => 32, 'date_format_full' => 32); - protected $fieldsValidate = array('name' => 'isGenericName', 'iso_code' => 'isLanguageIsoCode', 'language_code' => 'isLanguageCode', - 'active' => 'isBool', 'is_rtl' => 'isBool', 'date_format_lite' => 'isPhpDateFormat', 'date_format_full' => 'isPhpDateFormat'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + /** @var array Languages cache */ protected static $_checkedLangs; protected static $_LANGUAGES; diff --git a/classes/Logger.php b/classes/Logger.php index e95588d18..62d90c503 100644 --- a/classes/Logger.php +++ b/classes/Logger.php @@ -51,16 +51,27 @@ class LoggerCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - protected $fieldsRequired = array('severity', 'message'); - protected $fieldsSize = array(); - protected $fieldsValidate = array('id_log' => 'isUnsignedId', 'severity' => 'isInt', 'error_code' => 'isUnsignedInt', - 'message' => 'isMessage', 'object_id' => 'isUnsignedInt', 'object_type' => 'isName'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + protected static $is_present = array(); diff --git a/classes/Manufacturer.php b/classes/Manufacturer.php index 6b57de6dc..d97654acb 100644 --- a/classes/Manufacturer.php +++ b/classes/Manufacturer.php @@ -65,29 +65,30 @@ class ManufacturerCore extends ObjectModel /** @var boolean active */ public $active; - protected $fieldsRequired = array('name'); - protected $fieldsSize = array('name' => 64); - protected $fieldsValidate = array('name' => 'isCatalogName'); - protected $fieldsSizeLang = array( - 'short_description' => 254, - 'meta_title' => 128, - 'meta_description' => 255, - 'meta_description' => 255 - ); - protected $fieldsValidateLang = array( - 'description' => 'isString', - 'short_description' => 'isString', - 'meta_title' => 'isGenericName', - 'meta_description' => 'isGenericName', - 'meta_keywords' => 'isGenericName' - ); + + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'manufacturer', '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'), + ), ); + protected $webserviceParameters = array( 'fields' => array( 'active' => array(), diff --git a/classes/Message.php b/classes/Message.php index 197185c75..436540ec7 100644 --- a/classes/Message.php +++ b/classes/Message.php @@ -50,17 +50,27 @@ class MessageCore extends ObjectModel /** @var string Object creation date */ public $date_add; - protected $fieldsRequired = array('message'); - protected $fieldsSize = array('message' => 1600); - protected $fieldsValidate = array( - 'message' => 'isCleanHtml', 'id_cart' => 'isUnsignedId', 'id_order' => 'isUnsignedId', - 'id_customer' => 'isUnsignedId', 'id_employee' => 'isUnsignedId', 'private' => 'isBool'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/Meta.php b/classes/Meta.php index fe78ed729..924318827 100644 --- a/classes/Meta.php +++ b/classes/Meta.php @@ -34,21 +34,32 @@ class MetaCore extends ObjectModel public $keywords; public $url_rewrite; - protected $fieldsRequired = array('page'); - protected $fieldsSize = array('page' => 64); - protected $fieldsValidate = array('page' => 'isFileName'); + + + - protected $fieldsRequiredLang = array(); - protected $fieldsSizeLang = array('title' => 128, 'description' => 255, 'keywords' => 255, 'url_rewrite' => 255); - protected $fieldsValidateLang = array('title' => 'isGenericName', 'description' => 'isGenericName', 'keywords' => 'isGenericName', 'url_rewrite' => 'isLinkRewrite'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'meta', 'primary' => 'id_meta', '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), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/Page.php b/classes/Page.php index 6da57d2d1..fdd9054f9 100644 --- a/classes/Page.php +++ b/classes/Page.php @@ -32,14 +32,22 @@ class PageCore extends ObjectModel public $name; - protected $fieldsRequired = array ('id_page_type'); - protected $fieldsValidate = array ('id_page_type' => 'isUnsignedId', 'id_object' => 'isUnsignedId'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/ProductDownload.php b/classes/ProductDownload.php index c7f5feb33..04402587d 100644 --- a/classes/ProductDownload.php +++ b/classes/ProductDownload.php @@ -59,38 +59,32 @@ class ProductDownloadCore extends ObjectModel protected static $_productIds = array(); - protected $fieldsRequired = array( - 'id_product' - ); + - protected $fieldsSize = array( - 'display_filename' => 255, - 'filename' => 255, - 'date_add' => 20, - 'date_expiration' => 20, - 'nb_days_accessible' => 10, - 'nb_downloadable' => 10, - 'active' => 1, - 'is_shareable' => 1 - ); - protected $fieldsValidate = array( - 'id_product' => 'isUnsignedId', - 'id_product_attribute ' => 'isUnsignedId', - 'display_filename' => 'isGenericName', - 'filename' => 'isSha1', - 'date_add' => 'isDate', - 'date_expiration' => 'isDate', - 'nb_days_accessible' => 'isUnsignedInt', - 'nb_downloadable' => 'isUnsignedInt', - 'active' => 'isUnsignedInt', - 'is_shareable' => 'isUnsignedInt' - ); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + /** * Build a virtual product * diff --git a/classes/ProductSupplier.php b/classes/ProductSupplier.php index 712c04217..8f74ecc20 100644 --- a/classes/ProductSupplier.php +++ b/classes/ProductSupplier.php @@ -59,22 +59,28 @@ class ProductSupplierCore extends ObjectModel * */ public $product_supplier_price_te; - protected $fieldsRequired = array('id_product', 'id_product_attribute', 'id_supplier'); - protected $fieldsSize = array('supplier_reference' => 32); - protected $fieldsValidate = array( - 'product_supplier_reference' => 'isReference', - 'id_product' => 'isUnsignedId', - 'id_product_attribute' => 'isUnsignedId', - 'id_supplier' => 'isUnsignedId', - 'product_supplier_price_te' => 'isPrice', - 'id_currency' => 'isUnsignedId', - ); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/Profile.php b/classes/Profile.php index cee2948cf..50af05af6 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -30,15 +30,22 @@ class ProfileCore extends ObjectModel /** @var string Name */ public $name; - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 32); - protected $fieldsValidateLang = array('name' => 'isGenericName'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'profile', 'primary' => 'id_profile', 'multilang' => true, + 'fields' => array( + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), + ), ); + public function getFields() { diff --git a/classes/QuickAccess.php b/classes/QuickAccess.php index bf174d507..fdeb14c54 100644 --- a/classes/QuickAccess.php +++ b/classes/QuickAccess.php @@ -36,19 +36,28 @@ class QuickAccessCore extends ObjectModel /** @var boolean New windows or not */ public $new_window; - protected $fieldsRequired = array('link', 'new_window'); - protected $fieldsSize = array('link' => 128); - protected $fieldsValidate = array('link' => 'isUrl', 'new_window' => 'isBool'); - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 32); - protected $fieldsValidateLang = array('name' => 'isGenericName'); + + + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'quick_access', '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), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/RangePrice.php b/classes/RangePrice.php index 6227fd9b7..e14f913ce 100644 --- a/classes/RangePrice.php +++ b/classes/RangePrice.php @@ -31,14 +31,23 @@ class RangePriceCore extends ObjectModel public $delimiter1; public $delimiter2; - protected $fieldsRequired = array('id_carrier', 'delimiter1', 'delimiter2'); - protected $fieldsValidate = array('id_carrier' => 'isInt', 'delimiter1' => 'isUnsignedFloat', 'delimiter2' => 'isUnsignedFloat'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + protected $webserviceParameters = array( 'objectsNodeName' => 'price_ranges', 'objectNodeName' => 'price_range', diff --git a/classes/RangeWeight.php b/classes/RangeWeight.php index f8d6915ac..a4cd667d3 100644 --- a/classes/RangeWeight.php +++ b/classes/RangeWeight.php @@ -31,13 +31,22 @@ class RangeWeightCore extends ObjectModel public $delimiter1; public $delimiter2; - protected $fieldsRequired = array('id_carrier', 'delimiter1', 'delimiter2'); - protected $fieldsValidate = array('id_carrier' => 'isInt', 'delimiter1' => 'isUnsignedFloat', 'delimiter2' => 'isUnsignedFloat'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + protected $webserviceParameters = array( 'objectNodeName' => 'weight_range', diff --git a/classes/Referrer.php b/classes/Referrer.php index 636ef0863..343f127af 100644 --- a/classes/Referrer.php +++ b/classes/Referrer.php @@ -46,38 +46,36 @@ class ReferrerCore extends ObjectModel public $date_add; - protected $fieldsRequired = array('name'); - protected $fieldsSize = array( - 'name' => 64, - 'http_referer_regexp' => 64, - 'request_uri_regexp' => 64, - 'http_referer_like' => 64, - 'request_uri_like' => 64, - 'passwd' => 32 - ); + + - protected $fieldsValidate = array( - 'id_shop' => 'isUnsignedInt', - 'name' => 'isGenericName', - 'passwd' => 'isPasswd', - 'http_referer_regexp' => 'isCleanHtml', - 'request_uri_regexp' => 'isCleanHtml', - 'http_referer_like' => 'isCleanHtml', - 'request_uri_like' => 'isCleanHtml', - 'http_referer_regexp_not' => 'isCleanHtml', - 'request_uri_regexp_not' => 'isCleanHtml', - 'http_referer_like_not' => 'isCleanHtml', - 'request_uri_like_not' => 'isCleanHtml', - 'base_fee' => 'isFloat', - 'percent_fee' => 'isFloat', - 'click_fee' => 'isFloat' - ); + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + 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) diff --git a/classes/RequestSql.php b/classes/RequestSql.php index c8dd1d045..7785d6ca9 100644 --- a/classes/RequestSql.php +++ b/classes/RequestSql.php @@ -30,15 +30,23 @@ class RequestSqlCore extends ObjectModel public $name; public $sql; - protected $fieldsRequired = array('name', 'sql'); - protected $fieldsSize = array('name' => 200 , 'sql' => 400); - protected $fieldsValidate = array('name' => 'isString', 'sql' => 'isString'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + 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', '/', '<=>', '=', '>=', diff --git a/classes/Scene.php b/classes/Scene.php index 75576b4d0..8882f5492 100644 --- a/classes/Scene.php +++ b/classes/Scene.php @@ -42,17 +42,27 @@ class SceneCore extends ObjectModel /** @var array Products */ public $products; + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'scene', '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), + ), ); - protected $fieldsRequired = array('active'); - protected $fieldsValidate = array('active' => 'isBool', 'zones' => 'isSceneZones', 'categories' => 'isArrayWithIds'); - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 100); - protected $fieldsValidateLang = array('name' => 'isGenericName'); + + + + + + protected static $feature_active = null; diff --git a/classes/SearchEngine.php b/classes/SearchEngine.php index cceff5c62..ed4eed461 100644 --- a/classes/SearchEngine.php +++ b/classes/SearchEngine.php @@ -30,13 +30,21 @@ class SearchEngineCore extends ObjectModel public $server; public $getvar; - protected $fieldsRequired = array ('server', 'getvar'); - protected $fieldsValidate = array ('server' => 'isUrl', 'getvar' => 'isModuleName'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + public function getFields() { diff --git a/classes/SpecificPrice.php b/classes/SpecificPrice.php index a216b9968..47e3c35e4 100644 --- a/classes/SpecificPrice.php +++ b/classes/SpecificPrice.php @@ -41,14 +41,33 @@ class SpecificPriceCore extends ObjectModel public $from; public $to; - protected $fieldsRequired = array('id_product', 'id_shop', 'id_currency', 'id_country', 'id_group', 'price', 'from_quantity', 'reduction', 'reduction_type', 'from', 'to'); - protected $fieldsValidate = array('id_group_shop' => 'isUnsignedId', 'id_product' => 'isUnsignedId', 'id_product_attribute' => 'isUnsignedId', 'id_shop' => 'isUnsignedId', 'id_country' => 'isUnsignedId', 'id_group' => 'isUnsignedId', 'price' => 'isPrice', 'from_quantity' => 'isUnsignedInt', 'reduction' => 'isPrice', 'reduction_type' => 'isReductionType', 'from' => 'isDateFormat', 'to' => 'isDateFormat'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + protected static $_specificPriceCache = array(); protected static $_cache_priorities = array(); diff --git a/classes/SpecificPriceRule.php b/classes/SpecificPriceRule.php index f6f578aca..f69efc42f 100755 --- a/classes/SpecificPriceRule.php +++ b/classes/SpecificPriceRule.php @@ -39,14 +39,29 @@ class SpecificPriceRuleCore extends ObjectModel public $from; public $to; - protected $fieldsRequired = array('id_shop', 'id_currency', 'id_country', 'id_group', 'from_quantity', 'reduction', 'reduction_type', 'from', 'to'); - protected $fieldsValidate = array('id_shop' => 'isUnsignedId', 'id_country' => 'isUnsignedId', 'id_group' => 'isUnsignedId', 'from_quantity' => 'isUnsignedInt', 'reduction' => 'isPrice', 'reduction_type' => 'isReductionType', 'from' => 'isDateFormat', 'to' => 'isDateFormat'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/State.php b/classes/State.php index cfb496d1a..bbd7d7b01 100644 --- a/classes/State.php +++ b/classes/State.php @@ -42,15 +42,26 @@ class StateCore extends ObjectModel /** @var boolean Status for delivery */ public $active = true; - protected $fieldsRequired = array('id_country', 'id_zone', 'iso_code', 'name'); - protected $fieldsSize = array('iso_code' => 4, 'name' => 32); - protected $fieldsValidate = array('id_country' => 'isUnsignedId', 'id_zone' => 'isUnsignedId', 'iso_code' => 'isStateIsoCode', 'name' => 'isGenericName', 'active' => 'isBool'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + protected $webserviceParameters = array( 'fields' => array( 'id_zone' => array('xlink_resource'=> 'zones'), diff --git a/classes/Store.php b/classes/Store.php index b0c29e8a9..669113429 100644 --- a/classes/Store.php +++ b/classes/Store.php @@ -78,16 +78,35 @@ class StoreCore extends ObjectModel /** @var boolean Store status */ public $active = true; - protected $fieldsRequired = array('id_country', 'name', 'address1', 'city', 'active'); - protected $fieldsSize = array('name' => 128, 'address1' => 128, 'address2' => 128, 'postcode' => 12, 'city' => 64, 'latitude' => 12, 'longitude' => 12, 'hours' => 254, 'phone' => 16, 'fax' => 16, 'email' => 128, 'note' => 65000); - protected $fieldsValidate = array('id_country' => 'isUnsignedId', 'id_state' => 'isNullOrUnsignedId', 'name' => 'isGenericName', 'address1' => 'isAddress', 'address2' => 'isAddress', - 'city' => 'isCityName', 'latitude' => 'isCoordinate', 'longitude' => 'isCoordinate', 'hours' => 'isSerializedArray', 'phone' => 'isPhoneNumber', 'fax' => 'isPhoneNumber', - 'note' => 'isCleanHtml', 'email' => 'isEmail', 'active' => 'isBool'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + protected $webserviceParameters = array( 'fields' => array( diff --git a/classes/SubDomain.php b/classes/SubDomain.php index 6cd09e955..7290119cc 100644 --- a/classes/SubDomain.php +++ b/classes/SubDomain.php @@ -29,15 +29,22 @@ class SubDomainCore extends ObjectModel { public $name; - protected $fieldsRequired = array('name'); - protected $fieldsSize = array('name' => 16); - protected $fieldsValidate = array('name' => 'isSubDomainName'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'subdomain', 'primary' => 'id_subdomain', + 'fields' => array( + 'name' => array('type' => 'FILL_ME', 'validate' => 'isSubDomainName', 'required' => true, 'size' => 16), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/Supplier.php b/classes/Supplier.php index 8ef14547d..180d62370 100644 --- a/classes/Supplier.php +++ b/classes/Supplier.php @@ -65,23 +65,30 @@ class SupplierCore extends ObjectModel * */ public $id_address; - protected $fieldsRequired = array('name'); - protected $fieldsSize = array('name' => 64); - protected $fieldsValidate = array('name' => 'isCatalogName', 'id_address' => 'isUnsignedId'); - protected $fieldsSizeLang = array('meta_title' => 128, 'meta_description' => 255, 'meta_keywords' => 255); - protected $fieldsValidateLang = array( - 'description' => 'isGenericName', - 'meta_title' => 'isGenericName', - 'meta_description' => 'isGenericName', - 'meta_keywords' => 'isGenericName' - ); + + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'supplier', '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), + ), ); + protected $webserviceParameters = array( 'fields' => array( 'link_rewrite' => array('sqlId' => 'link_rewrite'), diff --git a/classes/Tab.php b/classes/Tab.php index aaa8845c3..da0970bb1 100644 --- a/classes/Tab.php +++ b/classes/Tab.php @@ -41,24 +41,31 @@ class TabCore extends ObjectModel /** @var integer position */ public $position; - protected $fieldsRequired = array('class_name'); - protected $fieldsSize = array('class_name' => 64, 'module' => 64); - protected $fieldsValidate = array( - 'id_parent' => 'isInt', - 'position' => 'isUnsignedInt', - 'module' => 'isTabName' - ); + + + - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 32); - protected $fieldsValidateLang = array('name' => 'isGenericName'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'tab', '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), + ), ); + protected static $_getIdFromClassName = null; public function getFields() diff --git a/classes/Tag.php b/classes/Tag.php index 7885ae2b6..49c7c3df4 100644 --- a/classes/Tag.php +++ b/classes/Tag.php @@ -33,14 +33,22 @@ class TagCore extends ObjectModel /** @var string Name */ public $name; - protected $fieldsRequired = array('id_lang', 'name'); - protected $fieldsValidate = array('id_lang' => 'isUnsignedId', 'name' => 'isGenericName'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + protected $webserviceParameters = array( 'fields' => array( 'id_lang' => array('xlink_resource' => 'languages'), diff --git a/classes/Theme.php b/classes/Theme.php index 460ce1ad0..f02200a49 100644 --- a/classes/Theme.php +++ b/classes/Theme.php @@ -29,14 +29,21 @@ class ThemeCore extends ObjectModel { public $name; - protected $fieldsSize = array('name' => 64); - protected $fieldsValidate = array('name' => 'isGenericName'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'theme', 'primary' => 'id_theme', + 'fields' => array( + 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'size' => 64), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/Zone.php b/classes/Zone.php index 2cadf3c9e..3a18a2c81 100644 --- a/classes/Zone.php +++ b/classes/Zone.php @@ -34,15 +34,23 @@ class ZoneCore extends ObjectModel public $active = true; public $eu_zone = false; /* Obsolete; to remove */ - protected $fieldsRequired = array('name'); - protected $fieldsSize = array('name' => 64); - protected $fieldsValidate = array('name' => 'isGenericName', 'active' => 'isBool'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + protected $webserviceParameters = array(); public function getFields() diff --git a/classes/order/Order.php b/classes/order/Order.php index e3df4857c..e7b307cb4 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -147,41 +147,8 @@ class OrderCore extends ObjectModel */ public $reference; - protected $fieldsRequired = array('conversion_rate', 'id_address_delivery', 'id_address_invoice', 'id_cart', 'id_currency', 'id_lang', 'id_customer', 'id_carrier', 'payment', 'total_paid', 'total_paid_real', 'total_products', 'total_products_wt'); - protected $fieldsValidate = array( - 'id_address_delivery' => 'isUnsignedId', - 'id_address_invoice' => 'isUnsignedId', - 'id_cart' => 'isUnsignedId', - 'id_currency' => 'isUnsignedId', - 'id_group_shop' => 'isUnsignedId', - 'id_shop' => 'isUnsignedId', - 'id_lang' => 'isUnsignedId', - 'id_customer' => 'isUnsignedId', - 'id_carrier' => 'isUnsignedId', - 'secure_key' => 'isMd5', - 'payment' => 'isGenericName', - 'recyclable' => 'isBool', - 'gift' => 'isBool', - 'gift_message' => 'isMessage', - 'total_discounts' => 'isPrice', - 'total_discounts_tax_incl' => 'isPrice', - 'total_discounts_tax_excl' => 'isPrice', - 'total_paid' => 'isPrice', - 'total_paid_tax_incl' => 'isPrice', - 'total_paid_tax_excl' => 'isPrice', - 'total_paid_real' => 'isPrice', - 'total_products' => 'isPrice', - 'total_products_wt' => 'isPrice', - 'total_shipping' => 'isPrice', - 'total_shipping_tax_incl' => 'isPrice', - 'total_shipping_tax_excl' => 'isPrice', - 'carrier_tax_rate' => 'isFloat', - 'total_wrapping' => 'isPrice', - 'total_wrapping_tax_incl' => 'isPrice', - 'total_wrapping_tax_excl' => 'isPrice', - 'shipping_number' => 'isUrl', - 'conversion_rate' => 'isFloat' - ); + + protected $webserviceParameters = array( 'objectMethods' => array('add' => 'addWs'), @@ -220,11 +187,49 @@ class OrderCore extends ObjectModel ); /* 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(); diff --git a/classes/order/OrderCarrier.php b/classes/order/OrderCarrier.php index 5c85c5106..3f7668c2f 100644 --- a/classes/order/OrderCarrier.php +++ b/classes/order/OrderCarrier.php @@ -55,22 +55,28 @@ class OrderCarrierCore extends ObjectModel /** @var string Object creation date */ public $date_add; - protected $fieldsRequired = array ('id_order', 'id_carrier'); - protected $fieldsValidate = array ( - 'id_order_carrier' => 'isUnsignedId', - 'id_order' => 'isUnsignedId', - 'id_carrier' => 'isUnsignedId', - 'id_order_invoice' => 'isUnsignedId', - 'weight' => 'isFloat', - 'shipping_cost_tax_excl' => 'isFloat', - 'shipping_cost_tax_incl' => 'isFloat', - 'tracking_number' => 'isAnything'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + protected $webserviceParameters = array( 'fields' => array( 'id_order' => array('xlink_resource' => 'orders'), diff --git a/classes/order/OrderCartRule.php b/classes/order/OrderCartRule.php index a6768fa4e..a3420eb71 100644 --- a/classes/order/OrderCartRule.php +++ b/classes/order/OrderCartRule.php @@ -42,15 +42,24 @@ class OrderCartRuleCore extends ObjectModel /** @var integer */ public $value; - protected $fieldsRequired = array ('id_order', 'name', 'value'); - protected $fieldsValidate = array ('id_order' => 'isUnsignedId', 'name' => 'isGenericName', 'value' => 'isInt'); + + /* MySQL does not allow 'order detail' for a table name */ + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + protected $webserviceParameters = array( 'fields' => array( 'id_order' => array('xlink_resource' => 'orders'), diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php index f711747cc..f42900288 100644 --- a/classes/order/OrderDetail.php +++ b/classes/order/OrderDetail.php @@ -129,54 +129,54 @@ class OrderDetailCore extends ObjectModel /** @var int Id warehouse */ public $id_warehouse; - protected $fieldsRequired = array( - 'id_order', - 'id_warehouse', - 'product_name', - 'product_quantity', - 'product_price'); + - protected $fieldsValidate = array( - 'id_order' => 'isUnsignedId', - 'id_order_invoice' => 'isUnsignedId', - 'id_warehouse' => 'isUnsignedId', - 'product_id' => 'isUnsignedId', - 'product_attribute_id' => 'isUnsignedId', - 'product_name' => 'isGenericName', - 'product_quantity' => 'isInt', - 'product_quantity_in_stock' => 'isInt', - 'product_quantity_return' => 'isUnsignedInt', - 'product_quantity_refunded' => 'isUnsignedInt', - 'product_quantity_reinjected' => 'isUnsignedInt', - 'product_price' => 'isPrice', - 'reduction_percent' => 'isFloat', - 'reduction_amount' => 'isPrice', - 'group_reduction' => 'isFloat', - 'product_quantity_discount' => 'isFloat', - 'product_ean13' => 'isEan13', - 'product_upc' => 'isUpc', - 'product_reference' => 'isReference', - 'product_supplier_reference' => 'isReference', - 'product_weight' => 'isFloat', - 'tax_name' => 'isGenericName', - 'tax_rate' => 'isFloat', - 'ecotax' => 'isFloat', - 'ecotax_tax_rate' => 'isFloat', - 'discount_quantity_applied' => 'isInt', - 'download_hash' => 'isGenericName', - 'download_nb' => 'isInt', - 'download_deadline' => 'isDateFormat', - 'unit_price_tax_incl' => 'isPrice', - 'unit_price_tax_excl' => 'isPrice', - 'total_price_tax_incl' => 'isPrice', - 'total_price_tax_excl' => 'isPrice' - ); + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + protected $webserviceParameters = array( 'fields' => array ( 'id_order' => array('xlink_resource' => 'orders'), diff --git a/classes/order/OrderHistory.php b/classes/order/OrderHistory.php index 5511cfa0d..020e27bbb 100644 --- a/classes/order/OrderHistory.php +++ b/classes/order/OrderHistory.php @@ -42,14 +42,23 @@ class OrderHistoryCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - protected $fieldsRequired = array('id_order', 'id_order_state'); - protected $fieldsValidate = array('id_order' => 'isUnsignedId', 'id_order_state' => 'isUnsignedId', 'id_employee' => 'isUnsignedId'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + protected $webserviceParameters = array( 'objectsNodeName' => 'order_histories', 'fields' => array( diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index ad42f0f35..7401778b4 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -66,14 +66,22 @@ class OrderInvoiceCore extends ObjectModel /** @var intger */ public $date_add; - protected $fieldsRequired = array('id_order', 'number'); - protected $fieldsValidate = array('id_order' => 'isUnsignedId', 'number' => 'isUnsignedId'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/order/OrderMessage.php b/classes/order/OrderMessage.php index 3dd165dcb..725d20d40 100644 --- a/classes/order/OrderMessage.php +++ b/classes/order/OrderMessage.php @@ -36,20 +36,28 @@ class OrderMessageCore extends ObjectModel /** @var string Object creation date */ public $date_add; - protected $fieldsRequired = array(); - protected $fieldsValidate = array(); - protected $fieldsSize = array(); + + + - protected $fieldsRequiredLang = array('name', 'message'); - protected $fieldsSizeLang = array('name' => 128, 'message' => 1200); - protected $fieldsValidateLang = array('name' => 'isGenericName', 'message' => 'isMessage'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'order_message', '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), + ), ); + protected $webserviceParameters = array( 'fields' => array( 'id' => array('sqlId' => 'id_discount_type', 'xlink_resource' => 'order_message_lang'), diff --git a/classes/order/OrderPayment.php b/classes/order/OrderPayment.php index 34ede321f..dff12c39b 100644 --- a/classes/order/OrderPayment.php +++ b/classes/order/OrderPayment.php @@ -39,26 +39,31 @@ class OrderPaymentCore extends ObjectModel public $card_holder; public $date_add; - protected $fieldsRequired = array('id_order', 'id_currency', 'amount'); - protected $fieldsSize = array('transaction_id' => 254, 'card_number' => 254, 'card_brand' => 254, 'card_expiration' => 254, 'card_holder' => 254); - protected $fieldsValidate = array( - 'id_order' => 'isUnsignedId', - 'id_currency' => 'isUnsignedId', - 'amount' => 'isPrice', - 'payment_method' => 'isName', - 'conversion_rate' => 'isFloat', - 'transaction_id' => 'isAnything', - 'card_number' => 'isAnything', - 'card_brand' => 'isAnything', - 'card_expiration' => 'isAnything', - 'card_holder' => 'isAnything' - ); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 8ede7ecf9..021802b17 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -48,13 +48,22 @@ class OrderReturnCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - protected $fieldsRequired = array ('id_customer', 'id_order'); - protected $fieldsValidate = array('id_customer' => 'isUnsignedId', 'id_order' => 'isUnsignedId', 'question' => 'isMessage'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); + public function getFields() { diff --git a/classes/order/OrderReturnState.php b/classes/order/OrderReturnState.php index b46f4c774..687be6d70 100644 --- a/classes/order/OrderReturnState.php +++ b/classes/order/OrderReturnState.php @@ -33,17 +33,25 @@ class OrderReturnStateCore extends ObjectModel /** @var string Display state in the specified color */ public $color; - protected $fieldsValidate = array('color' => 'isColor'); - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 64); - protected $fieldsValidateLang = array('name' => 'isGenericName'); + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'order_return_state', '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), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/order/OrderSlip.php b/classes/order/OrderSlip.php index b0761f3db..955c96d79 100644 --- a/classes/order/OrderSlip.php +++ b/classes/order/OrderSlip.php @@ -57,14 +57,23 @@ class OrderSlipCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - protected $fieldsRequired = array ('id_customer', 'id_order', 'conversion_rate'); - protected $fieldsValidate = array('id_customer' => 'isUnsignedId', 'id_order' => 'isUnsignedId', 'conversion_rate' => 'isFloat'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/order/OrderState.php b/classes/order/OrderState.php index 53c20c609..e7a71f8c6 100644 --- a/classes/order/OrderState.php +++ b/classes/order/OrderState.php @@ -56,24 +56,31 @@ class OrderStateCore extends ObjectModel /** @var boolean Shipped */ public $shipped; - protected $fieldsValidate = array( - 'send_email' => 'isBool', - 'invoice' => 'isBool', - 'color' => 'isColor', - 'logable' => 'isBool', - 'shipped' => 'isBool' - ); + - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 64, 'template' => 64); - protected $fieldsValidateLang = array('name' => 'isGenericName', 'template' => 'isTplName'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'order_state', '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), + ), ); + protected $webserviceParameters = array( 'fields' => array( 'unremovable' => array(), diff --git a/classes/shop/GroupShop.php b/classes/shop/GroupShop.php index 8e34e00b2..02a1f5410 100644 --- a/classes/shop/GroupShop.php +++ b/classes/shop/GroupShop.php @@ -37,20 +37,25 @@ class GroupShopCore extends ObjectModel public $share_order; public $deleted; - protected $fieldsSize = array('name' => 64); - protected $fieldsValidate = array( - 'active' => 'isBool', - 'share_customer' => 'isBool', - 'share_order' => 'isBool', - 'share_stock' => 'isBool', - 'name' => 'isGenericName', - ); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + private static $assoTables = array( 'attribute_group' => array('type' => 'group_shop'), 'attribute' => array('type' => 'group_shop'), diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index 689de4b5e..b73c06ec2 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -48,18 +48,26 @@ class ShopCore extends ObjectModel */ protected $group; - protected $fieldsRequired = array('id_theme', 'id_category', 'id_group_shop', 'name'); - protected $fieldsSize = array('name' => 64); - protected $fieldsValidate = array( - 'active' => 'isBool', - 'name' => 'isGenericName', - ); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + /** @var array List of shops cached */ protected static $shops; diff --git a/classes/shop/ShopUrl.php b/classes/shop/ShopUrl.php index 0b80cda63..4d2680d78 100644 --- a/classes/shop/ShopUrl.php +++ b/classes/shop/ShopUrl.php @@ -38,15 +38,26 @@ class ShopUrlCore extends ObjectModel private static $main_domain = null; private static $main_domain_ssl = null; - protected $fieldsRequired = array('domain', 'id_shop'); - protected $fieldsSize = array('domain' => 255, 'physical_uri' => 64, 'virtual_uri' => 64); - protected $fieldsValidate = array('active' => 'isBool'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/stock/Stock.php b/classes/stock/Stock.php index fd8b32a69..b08c08c81 100644 --- a/classes/stock/Stock.php +++ b/classes/stock/Stock.php @@ -59,34 +59,32 @@ class StockCore extends ObjectModel /** @var int the unit price without tax forthe current product */ public $price_te; - protected $fieldsRequired = array( - 'id_warehouse', - 'id_product', - 'id_product_attribute', - 'physical_quantity', - 'usable_quantity', - 'price_te', - ); + - protected $fieldsSize = array(); + - protected $fieldsValidate = array( - 'id_warehouse' => 'isUnsignedId', - 'id_product' => 'isUnsignedId', - 'id_product_attribute' => 'isUnsignedId', - 'reference' => 'isReference', - 'ean13' => 'isEan13', - 'upc' => 'isUpc', - 'physical_quantity' => 'isUnsignedInt', - 'usable_quantity' => 'isInt', - 'price_te' => 'isPrice', - ); + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/stock/StockAvailable.php b/classes/stock/StockAvailable.php index 0b6d83b5c..438f665c3 100644 --- a/classes/stock/StockAvailable.php +++ b/classes/stock/StockAvailable.php @@ -54,31 +54,30 @@ 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; - protected $fieldsRequired = array( - 'id_product', - 'id_product_attribute', - 'quantity', - 'depends_on_stock', - 'out_of_stock' - ); + - protected $fieldsSize = array(); + - protected $fieldsValidate = array( - 'id_product' => 'isUnsignedId', - 'id_product_attribute' => 'isUnsignedId', - 'id_shop' => 'isUnsignedId', - 'id_group_shop' => 'isUnsignedId', - 'quantity' => 'isInt', - 'depends_on_stock' => 'isBool', - 'out_of_stock' => 'isInt' - ); + + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/stock/StockMvt.php b/classes/stock/StockMvt.php index 551a5972d..b87f8a3e2 100644 --- a/classes/stock/StockMvt.php +++ b/classes/stock/StockMvt.php @@ -122,37 +122,34 @@ class StockMvtCore extends ObjectModel */ public $quantity; + /** + * @see ObjectModel::$definition + */ public static $definition = array( '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'), + ), ); - protected $fieldsRequired = array( - 'date_add', - 'id_employee', - 'id_stock', - 'physical_quantity', - 'id_stock_mvt_reason', - 'sign', - 'price_te' - ); - protected $fieldsValidate = array( - 'date_add' => 'isDate', - 'id_employee' => 'isUnsignedId', - 'employee_firstname' => 'isName', - 'employee_lastname' => 'isName', - 'id_stock' => 'isUnsignedId', - 'physical_quantity' => 'isUnsignedInt', - 'id_stock_mvt_reason' => 'isUnsignedId', - 'id_order' => 'isUnsignedId', - 'id_supply_order' => 'isUnsignedId', - 'sign' => 'isInt', - 'last_wa' => 'isPrice', - 'current_wa' => 'isPrice', - 'price_te' => 'isPrice', - 'referer' => 'isUnsignedId' - ); + + + protected $webserviceParameters = array( 'objectsNodeName' => 'stock_movements', diff --git a/classes/stock/StockMvtReason.php b/classes/stock/StockMvtReason.php index 37de016d8..3bc7fee9c 100644 --- a/classes/stock/StockMvtReason.php +++ b/classes/stock/StockMvtReason.php @@ -45,15 +45,22 @@ class StockMvtReasonCore extends ObjectModel /** @var boolean True if the movement reason has been deleted (staying in database as deleted) */ public $deleted = 0; + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'stock_mvt_reason', 'primary' => 'id_stock_mvt_reason', 'multilang' => true, + 'fields' => array( + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255), + ), ); - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 255); - protected $fieldsValidateLang = array('name' => 'isGenericName'); + + + + protected $webserviceParameters = array( 'objectsNodeName' => 'stock_movement_reasons', diff --git a/classes/stock/SupplyOrder.php b/classes/stock/SupplyOrder.php index bf028464d..943ea131b 100755 --- a/classes/stock/SupplyOrder.php +++ b/classes/stock/SupplyOrder.php @@ -120,49 +120,43 @@ class SupplyOrderCore extends ObjectModel */ public $is_template = 0; - protected $fieldsRequired = array( - 'id_supplier', - 'supplier_name', - 'id_lang', - 'id_warehouse', - 'id_supply_order_state', - 'id_currency', - 'id_ref_currency', - 'reference', - 'discount_rate', - 'date_delivery_expected' - ); + - protected $fieldsValidate = array( - 'id_supplier' => 'isUnsignedId', - 'supplier_name' => 'isCatalogName', - 'id_lang' => 'isUnsignedId', - 'id_warehouse' => 'isUnsignedId', - 'id_supply_order_state' => 'isUnsignedId', - 'id_currency' => 'isUnsignedId', - 'id_ref_currency' => 'isUnsignedId', - 'reference' => 'isGenericName', - 'date_add' => 'isDate', - 'date_upd' => 'isDate', - 'date_delivery_expected' => 'isDate', - 'total_te' => 'isPrice', - 'total_with_discount_te' => 'isPrice', - 'total_ti' => 'isPrice', - 'total_tax' => 'isPrice', - 'discount_rate' => 'isFloat', - 'discount_value_te' => 'isPrice', - 'is_template' => 'isBool', - ); + /** * @var array Contains object definition * @see ObjectModel::definition */ + /** + * @see ObjectModel::$definition + */ public static $definition = array( - 'table' => 'supply_order', - 'primary' => 'id_supply_order', + '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'), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/stock/SupplyOrderDetail.php b/classes/stock/SupplyOrderDetail.php index 66fe827f5..82b56d2fe 100755 --- a/classes/stock/SupplyOrderDetail.php +++ b/classes/stock/SupplyOrderDetail.php @@ -142,56 +142,43 @@ class SupplyOrderDetailCore extends ObjectModel */ public $price_with_order_discount_te = 0; - protected $fieldsRequired = array( - 'id_supply_order', - 'id_product', - 'id_product_attribute', - 'name', - 'id_currency', - 'exchange_rate', - 'unit_price_te', - 'quantity_expected', - 'price_te', - 'discount_rate', - 'discount_value_te', - 'price_with_discount_te', - 'tax_rate', - 'tax_value', - 'price_ti', - 'tax_value_with_order_discount', - 'price_with_order_discount_te' - ); + - protected $fieldsValidate = array( - 'id_supply_order' => 'isUnsignedId', - 'id_product' => 'isUnsignedId', - 'id_product_attribute' => 'isUnsignedId', - 'reference' => 'isReference', - 'supplier_reference' => 'isReference', - 'name' => 'isGenericName', - 'ean13' => 'isEan13', - 'upc' => 'isUpc', - 'id_currency' => 'isUnsignedId', - 'exchange_rate' => 'isFloat', - 'unit_price_te' => 'isPrice', - 'quantity_expected' => 'isUnsignedInt', - 'quantity_received' => 'isUnsignedInt', - 'price_te' => 'isPrice', - 'discount_rate' => 'isFloat', - 'discount_value_te' => 'isPrice', - 'price_with_discount_te' => 'isPrice', - 'tax_rate' => 'isFloat', - 'tax_value' => 'isPrice', - 'price_ti' => 'isPrice', - 'tax_value_with_order_discount' => 'isFloat', - 'price_with_order_discount_te' => 'isPrice', - ); + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'supply_order_detail', 'primary' => 'id_supply_order_detail', + 'fields' => array( + 'id_supply_order' => 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'), + 'supplier_reference' => array('type' => 'FILL_ME', 'validate' => 'isReference'), + 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true), + 'ean13' => array('type' => 'FILL_ME', 'validate' => 'isEan13'), + 'upc' => array('type' => 'FILL_ME', 'validate' => 'isUpc'), + 'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'exchange_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true), + 'unit_price_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), + 'quantity_expected' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'required' => true), + 'quantity_received' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'price_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), + 'discount_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true), + 'discount_value_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), + 'price_with_discount_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), + 'tax_rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true), + 'tax_value' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), + 'price_ti' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), + 'tax_value_with_order_discount' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true), + 'price_with_order_discount_te' => array('type' => 'FILL_ME', 'validate' => 'isPrice', 'required' => true), + ), ); + /** * @see ObjectModel::getFields() */ diff --git a/classes/stock/SupplyOrderHistory.php b/classes/stock/SupplyOrderHistory.php index dc5651b8d..c84ead76d 100755 --- a/classes/stock/SupplyOrderHistory.php +++ b/classes/stock/SupplyOrderHistory.php @@ -60,27 +60,27 @@ class SupplyOrderHistoryCore extends ObjectModel */ public $date_add; - protected $fieldsRequired = array( - 'id_supply_order', - 'id_employee', - 'id_state', - 'date_add' - ); + - protected $fieldsValidate = array( - 'id_supply_order' => 'isUnsignedId', - 'id_employee' => 'isUnsignedId', - 'employee_firstname' => 'isName', - 'employee_lastname' => 'isName', - 'id_state' => 'isUnsignedId', - 'date_add' => 'isDate' - ); + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'supply_order_history', 'primary' => 'id_supply_order_history', + 'fields' => array( + 'id_supply_order' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', '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_state' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'date_add' => array('type' => 'FILL_ME', 'validate' => 'isDate', 'required' => true), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/stock/SupplyOrderReceiptHistory.php b/classes/stock/SupplyOrderReceiptHistory.php index 7712afb8b..9d394fd1c 100755 --- a/classes/stock/SupplyOrderReceiptHistory.php +++ b/classes/stock/SupplyOrderReceiptHistory.php @@ -65,28 +65,28 @@ class SupplyOrderReceiptHistoryCore extends ObjectModel */ public $date_add; - protected $fieldsRequired = array( - 'id_supply_order_detail', - 'id_supply_order_state', - 'id_employee', - 'quantity' - ); + - protected $fieldsValidate = array( - 'id_supply_order_detail' => 'isUnsignedId', - 'id_supply_order_state' => 'isUnsignedId', - 'id_employee' => 'isUnsignedId', - 'employee_firstname' => 'isName', - 'employee_lastname' => 'isName', - 'quantity' => 'isUnsignedInt', - 'date_add' => 'isDate' - ); + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'supply_order_receipt_history', 'primary' => 'id_supply_order_receipt_history', + 'fields' => array( + 'id_supply_order_detail' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'id_supply_order_state' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', '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'), + 'quantity' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt', 'required' => true), + 'date_add' => array('type' => 'FILL_ME', 'validate' => 'isDate'), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/stock/SupplyOrderState.php b/classes/stock/SupplyOrderState.php index 513929211..e474713b9 100755 --- a/classes/stock/SupplyOrderState.php +++ b/classes/stock/SupplyOrderState.php @@ -65,25 +65,31 @@ class SupplyOrderStateCore extends ObjectModel */ public $color; - protected $fieldsValidate = array( - 'delivery_note' => 'isBool', - 'editable' => 'isBool', - 'receipt_state' => 'isBool', - 'pending_receipt' => 'isBool', - 'enclosed' => 'isBool', - 'color' => 'isColor' - ); + - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 128); - protected $fieldsValidateLang = array('name' => 'isGenericName'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'supply_order_state', 'primary' => 'id_supply_order_state', 'multilang' => true, + 'fields' => array( + 'delivery_note' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'editable' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'receipt_state' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'pending_receipt' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'enclosed' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'color' => array('type' => 'FILL_ME', 'validate' => 'isColor'), + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), + ), ); + /** * @see ObjectModel::getFields() */ diff --git a/classes/stock/Warehouse.php b/classes/stock/Warehouse.php index 90cd8245e..085f2b1b6 100644 --- a/classes/stock/Warehouse.php +++ b/classes/stock/Warehouse.php @@ -59,35 +59,30 @@ class WarehouseCore extends ObjectModel */ public $management_type; - protected $fieldsRequired = array( - 'id_address', - 'reference', - 'name', - 'id_employee', - 'management_type', - 'id_currency' - ); + - protected $fieldsSize = array( - 'stock_management' => 32, - 'reference' => 45, - 'name' => 45 - ); + - protected $fieldsValidate = array( - 'id_address' => 'isUnsignedId', - 'reference' => 'isString', - 'name' => 'isName', - 'id_employee' => 'isUnsignedId', - 'management_type' => 'isStockManagement', /* @see Validate::isStockManagement() */ - 'id_currency' => 'isUnsignedId' - ); + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'warehouse', 'primary' => 'id_warehouse', + 'fields' => array( + 'id_address' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'reference' => array('type' => 'FILL_ME', 'validate' => 'isString', 'required' => true, 'size' => 45), + 'name' => array('type' => 'FILL_ME', 'validate' => 'isName', 'required' => true, 'size' => 45), + 'id_employee' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'management_type' => array('type' => 'FILL_ME', 'validate' => 'isStockManagement', 'required' => true), + 'id_currency' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'stock_management' => array('type' => 'FILL_ME', 'size' => 32), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/stock/WarehouseProductLocation.php b/classes/stock/WarehouseProductLocation.php index b9080e652..d41dff59d 100644 --- a/classes/stock/WarehouseProductLocation.php +++ b/classes/stock/WarehouseProductLocation.php @@ -49,20 +49,25 @@ class WarehouseProductLocationCore extends ObjectModel * */ public $location; - protected $fieldsRequired = array('id_product', 'id_product_attribute', 'id_warehouse'); - protected $fieldsSize = array('location' => 64); - protected $fieldsValidate = array( - 'location' => 'isReference', - 'id_product' => 'isUnsignedId', - 'id_product_attribute' => 'isUnsignedId', - 'id_warehouse' => 'isUnsignedId', - ); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'warehouse_product_location', 'primary' => 'id_warehouse_product_location', + 'fields' => array( + 'location' => array('type' => 'FILL_ME', 'validate' => 'isReference', 'size' => 64), + 'id_product' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'id_product_attribute' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'id_warehouse' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/tax/Tax.php b/classes/tax/Tax.php index c26c230ae..40f41138d 100644 --- a/classes/tax/Tax.php +++ b/classes/tax/Tax.php @@ -43,17 +43,25 @@ class TaxCore extends ObjectModel /** @var string Account Number */ public $account_number; - protected $fieldsRequired = array('rate'); - protected $fieldsValidate = array('rate' => 'isFloat'); - protected $fieldsRequiredLang = array('name'); - protected $fieldsSizeLang = array('name' => 32); - protected $fieldsValidateLang = array('name' => 'isGenericName'); + + + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'tax', 'primary' => 'id_tax', + 'fields' => array( + 'rate' => array('type' => 'FILL_ME', 'validate' => 'isFloat', 'required' => true), + 'name' => array('type' => 'FILL_ME', 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 32), + ), ); + protected static $_product_country_tax = array(); protected static $_product_tax_via_rules = array(); diff --git a/classes/tax/TaxRule.php b/classes/tax/TaxRule.php index cf94c0de4..38ca01c48 100644 --- a/classes/tax/TaxRule.php +++ b/classes/tax/TaxRule.php @@ -36,21 +36,28 @@ class TaxRuleCore extends ObjectModel public $behavior; public $description; - protected $fieldsRequired = array('id_tax_rules_group', 'id_country', 'id_tax'); - protected $fieldsValidate = array('id_tax_rules_group' => 'isUnsignedId', - 'id_country' => 'isUnsignedId', - 'id_state' => 'isUnsignedId', - 'zipcode_from' => 'isPostCode', - 'zipcode_to' => 'isPostCode', - 'id_tax' => 'isUnsignedId', - 'behavior' => 'isUnsignedInt', - 'description' => 'isString'); + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'tax_rule', 'primary' => 'id_tax_rule', + 'fields' => array( + 'id_tax_rules_group' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'id_country' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'id_state' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId'), + 'zipcode_from' => array('type' => 'FILL_ME', 'validate' => 'isPostCode'), + 'zipcode_to' => array('type' => 'FILL_ME', 'validate' => 'isPostCode'), + 'id_tax' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedId', 'required' => true), + 'behavior' => array('type' => 'FILL_ME', 'validate' => 'isUnsignedInt'), + 'description' => array('type' => 'FILL_ME', 'validate' => 'isString'), + ), ); + public function getFields() { $this->validateFields(); diff --git a/classes/tax/TaxRulesGroup.php b/classes/tax/TaxRulesGroup.php index ba17100da..78ed00391 100644 --- a/classes/tax/TaxRulesGroup.php +++ b/classes/tax/TaxRulesGroup.php @@ -33,15 +33,22 @@ class TaxRulesGroupCore extends ObjectModel /** @var bool active state */ public $active; - protected $fieldsRequired = array('name'); - protected $fieldsSize = array('name' => 64); - protected $fieldsValidate = array('name' => 'isGenericName'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'tax_rules_group', 'primary' => 'id_tax_rules_group', + 'fields' => array( + 'name' => array('type' => 'FILL_ME', 'validate' => 'isGenericName', 'required' => true, 'size' => 64), + ), ); + protected static $_taxes = array(); public function getFields() diff --git a/classes/webservice/WebserviceKey.php b/classes/webservice/WebserviceKey.php index ae1bbeb63..acb7bdf93 100755 --- a/classes/webservice/WebserviceKey.php +++ b/classes/webservice/WebserviceKey.php @@ -36,15 +36,23 @@ class WebserviceKeyCore extends ObjectModel /** @var string Webservice Account description */ public $description; - protected $fieldsRequired = array('key'); - protected $fieldsSize = array('key' => 32); - protected $fieldsValidate = array('active' => 'isBool'); + + + + /** + * @see ObjectModel::$definition + */ public static $definition = array( 'table' => 'webservice_account', 'primary' => 'id_webservice_account', + 'fields' => array( + 'active' => array('type' => 'FILL_ME', 'validate' => 'isBool'), + 'key' => array('type' => 'FILL_ME', 'required' => true, 'size' => 32), + ), ); + public function add($autodate = true, $nullValues = false) { if (WebserviceKey::keyExists($this->key))