From 0e5b90275281b7312816f73a013ed13043c2eedc Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 18 Oct 2013 13:57:24 +0200 Subject: [PATCH 01/22] hardcode utf8 parameters --- core/lib/Thelia/Config/DefinePropel.php | 4 +- install/thelia.sql | 196 ++++++++++++------------ local/config/schema.xml | 7 +- 3 files changed, 107 insertions(+), 100 deletions(-) diff --git a/core/lib/Thelia/Config/DefinePropel.php b/core/lib/Thelia/Config/DefinePropel.php index 3f7547fde..05a42a504 100755 --- a/core/lib/Thelia/Config/DefinePropel.php +++ b/core/lib/Thelia/Config/DefinePropel.php @@ -44,7 +44,9 @@ class DefinePropel "dsn" => $connection["dsn"], "user" => $connection["user"], "password" => $connection["password"], - "classname" => $connection["classname"] + "classname" => $connection["classname"], + 'options' => array( + \PDO::MYSQL_ATTR_INIT_COMMAND => array('value' =>'SET NAMES \'UTF8\'')) ); } } diff --git a/install/thelia.sql b/install/thelia.sql index 4371aa4f5..c062681d1 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -21,7 +21,7 @@ CREATE TABLE `category` `version_created_at` DATETIME, `version_created_by` VARCHAR(100), PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- product @@ -54,7 +54,7 @@ CREATE TABLE `product` CONSTRAINT `fk_product_template` FOREIGN KEY (`template_id`) REFERENCES `template` (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- product_category @@ -83,7 +83,7 @@ CREATE TABLE `product_category` REFERENCES `category` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- country @@ -108,7 +108,7 @@ CREATE TABLE `country` REFERENCES `area` (`id`) ON UPDATE RESTRICT ON DELETE SET NULL -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- tax @@ -124,7 +124,7 @@ CREATE TABLE `tax` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- tax_rule @@ -139,7 +139,7 @@ CREATE TABLE `tax_rule` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- tax_rule_country @@ -174,7 +174,7 @@ CREATE TABLE `tax_rule_country` REFERENCES `country` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- feature @@ -190,7 +190,7 @@ CREATE TABLE `feature` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- feature_av @@ -212,7 +212,7 @@ CREATE TABLE `feature_av` REFERENCES `feature` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- feature_product @@ -249,7 +249,7 @@ CREATE TABLE `feature_product` REFERENCES `feature_av` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- feature_template @@ -276,7 +276,7 @@ CREATE TABLE `feature_template` CONSTRAINT `fk_feature_template` FOREIGN KEY (`template_id`) REFERENCES `template` (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- attribute @@ -291,7 +291,7 @@ CREATE TABLE `attribute` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- attribute_av @@ -313,7 +313,7 @@ CREATE TABLE `attribute_av` REFERENCES `attribute` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- attribute_combination @@ -347,7 +347,7 @@ CREATE TABLE `attribute_combination` REFERENCES `product_sale_elements` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- product_sale_elements @@ -375,7 +375,7 @@ CREATE TABLE `product_sale_elements` REFERENCES `product` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- attribute_template @@ -402,7 +402,7 @@ CREATE TABLE `attribute_template` CONSTRAINT `fk_attribute_template` FOREIGN KEY (`template_id`) REFERENCES `template` (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- config @@ -421,7 +421,7 @@ CREATE TABLE `config` `updated_at` DATETIME, PRIMARY KEY (`id`), UNIQUE INDEX `name_UNIQUE` (`name`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- customer @@ -455,7 +455,7 @@ CREATE TABLE `customer` REFERENCES `customer_title` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- address @@ -502,7 +502,7 @@ CREATE TABLE `address` REFERENCES `country` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- customer_title @@ -518,7 +518,7 @@ CREATE TABLE `customer_title` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- lang @@ -544,7 +544,7 @@ CREATE TABLE `lang` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- folder @@ -564,7 +564,7 @@ CREATE TABLE `folder` `version_created_at` DATETIME, `version_created_by` VARCHAR(100), PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- content @@ -583,7 +583,7 @@ CREATE TABLE `content` `version_created_at` DATETIME, `version_created_by` VARCHAR(100), PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- product_image @@ -606,7 +606,7 @@ CREATE TABLE `product_image` REFERENCES `product` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- product_document @@ -629,7 +629,7 @@ CREATE TABLE `product_document` REFERENCES `product` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- order @@ -707,7 +707,7 @@ CREATE TABLE `order` REFERENCES `lang` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- currency @@ -726,7 +726,7 @@ CREATE TABLE `currency` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- order_address @@ -751,7 +751,7 @@ CREATE TABLE `order_address` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- order_product @@ -787,7 +787,7 @@ CREATE TABLE `order_product` REFERENCES `order` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- order_status @@ -803,7 +803,7 @@ CREATE TABLE `order_status` `updated_at` DATETIME, PRIMARY KEY (`id`), UNIQUE INDEX `code_UNIQUE` (`code`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- order_product_attribute_combination @@ -832,7 +832,7 @@ CREATE TABLE `order_product_attribute_combination` REFERENCES `order_product` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- module @@ -852,7 +852,7 @@ CREATE TABLE `module` `updated_at` DATETIME, PRIMARY KEY (`id`), UNIQUE INDEX `code_UNIQUE` (`code`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- accessory @@ -881,7 +881,7 @@ CREATE TABLE `accessory` REFERENCES `product` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- area @@ -897,7 +897,7 @@ CREATE TABLE `area` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- area_delivery_module @@ -926,7 +926,7 @@ CREATE TABLE `area_delivery_module` REFERENCES `module` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- group @@ -942,7 +942,7 @@ CREATE TABLE `group` `updated_at` DATETIME, PRIMARY KEY (`id`), UNIQUE INDEX `code_UNIQUE` (`code`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- resource @@ -958,7 +958,7 @@ CREATE TABLE `resource` `updated_at` DATETIME, PRIMARY KEY (`id`), UNIQUE INDEX `code_UNIQUE` (`code`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- admin @@ -980,7 +980,7 @@ CREATE TABLE `admin` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- admin_group @@ -1008,7 +1008,7 @@ CREATE TABLE `admin_group` REFERENCES `admin` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- group_resource @@ -1038,7 +1038,7 @@ CREATE TABLE `group_resource` REFERENCES `resource` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- group_module @@ -1067,7 +1067,7 @@ CREATE TABLE `group_module` REFERENCES `module` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- message @@ -1087,7 +1087,7 @@ CREATE TABLE `message` `version_created_by` VARCHAR(100), PRIMARY KEY (`id`), UNIQUE INDEX `name_UNIQUE` (`name`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- coupon @@ -1123,7 +1123,7 @@ CREATE TABLE `coupon` INDEX `idx_is_removing_postage` (`is_removing_postage`), INDEX `idx_max_usage` (`max_usage`), INDEX `idx_is_available_on_special_offers` (`is_available_on_special_offers`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- coupon_order @@ -1145,7 +1145,7 @@ CREATE TABLE `coupon_order` REFERENCES `order` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- admin_log @@ -1164,7 +1164,7 @@ CREATE TABLE `admin_log` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- content_folder @@ -1193,7 +1193,7 @@ CREATE TABLE `content_folder` REFERENCES `folder` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- cart @@ -1230,7 +1230,7 @@ CREATE TABLE `cart` CONSTRAINT `fk_cart_currency_id` FOREIGN KEY (`currency_id`) REFERENCES `currency` (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- cart_item @@ -1265,7 +1265,7 @@ CREATE TABLE `cart_item` CONSTRAINT `fk_cart_item_product_sale_elements_id` FOREIGN KEY (`product_sale_elements_id`) REFERENCES `product_sale_elements` (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- product_price @@ -1292,7 +1292,7 @@ CREATE TABLE `product_price` FOREIGN KEY (`currency_id`) REFERENCES `currency` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- category_image @@ -1315,7 +1315,7 @@ CREATE TABLE `category_image` REFERENCES `category` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- folder_image @@ -1338,7 +1338,7 @@ CREATE TABLE `folder_image` REFERENCES `folder` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- content_image @@ -1361,7 +1361,7 @@ CREATE TABLE `content_image` REFERENCES `content` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- category_document @@ -1384,7 +1384,7 @@ CREATE TABLE `category_document` REFERENCES `category` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- content_document @@ -1407,7 +1407,7 @@ CREATE TABLE `content_document` REFERENCES `content` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- folder_document @@ -1430,7 +1430,7 @@ CREATE TABLE `folder_document` REFERENCES `folder` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- product_associated_content @@ -1459,7 +1459,7 @@ CREATE TABLE `product_associated_content` REFERENCES `content` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- category_associated_content @@ -1488,7 +1488,7 @@ CREATE TABLE `category_associated_content` REFERENCES `content` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- rewriting_url @@ -1515,7 +1515,7 @@ CREATE TABLE `rewriting_url` REFERENCES `rewriting_url` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- rewriting_argument @@ -1537,7 +1537,7 @@ CREATE TABLE `rewriting_argument` REFERENCES `rewriting_url` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- template @@ -1551,7 +1551,7 @@ CREATE TABLE `template` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- module_image @@ -1574,7 +1574,7 @@ CREATE TABLE `module_image` REFERENCES `module` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- order_product_tax @@ -1599,7 +1599,7 @@ CREATE TABLE `order_product_tax` REFERENCES `order_product` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- category_i18n @@ -1620,7 +1620,7 @@ CREATE TABLE `category_i18n` FOREIGN KEY (`id`) REFERENCES `category` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- product_i18n @@ -1641,7 +1641,7 @@ CREATE TABLE `product_i18n` FOREIGN KEY (`id`) REFERENCES `product` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- country_i18n @@ -1662,7 +1662,7 @@ CREATE TABLE `country_i18n` FOREIGN KEY (`id`) REFERENCES `country` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- tax_i18n @@ -1681,7 +1681,7 @@ CREATE TABLE `tax_i18n` FOREIGN KEY (`id`) REFERENCES `tax` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- tax_rule_i18n @@ -1700,7 +1700,7 @@ CREATE TABLE `tax_rule_i18n` FOREIGN KEY (`id`) REFERENCES `tax_rule` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- feature_i18n @@ -1721,7 +1721,7 @@ CREATE TABLE `feature_i18n` FOREIGN KEY (`id`) REFERENCES `feature` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- feature_av_i18n @@ -1742,7 +1742,7 @@ CREATE TABLE `feature_av_i18n` FOREIGN KEY (`id`) REFERENCES `feature_av` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- attribute_i18n @@ -1763,7 +1763,7 @@ CREATE TABLE `attribute_i18n` FOREIGN KEY (`id`) REFERENCES `attribute` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- attribute_av_i18n @@ -1784,7 +1784,7 @@ CREATE TABLE `attribute_av_i18n` FOREIGN KEY (`id`) REFERENCES `attribute_av` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- config_i18n @@ -1805,7 +1805,7 @@ CREATE TABLE `config_i18n` FOREIGN KEY (`id`) REFERENCES `config` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- customer_title_i18n @@ -1824,7 +1824,7 @@ CREATE TABLE `customer_title_i18n` FOREIGN KEY (`id`) REFERENCES `customer_title` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- folder_i18n @@ -1845,7 +1845,7 @@ CREATE TABLE `folder_i18n` FOREIGN KEY (`id`) REFERENCES `folder` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- content_i18n @@ -1866,7 +1866,7 @@ CREATE TABLE `content_i18n` FOREIGN KEY (`id`) REFERENCES `content` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- product_image_i18n @@ -1887,7 +1887,7 @@ CREATE TABLE `product_image_i18n` FOREIGN KEY (`id`) REFERENCES `product_image` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- product_document_i18n @@ -1908,7 +1908,7 @@ CREATE TABLE `product_document_i18n` FOREIGN KEY (`id`) REFERENCES `product_document` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- currency_i18n @@ -1926,7 +1926,7 @@ CREATE TABLE `currency_i18n` FOREIGN KEY (`id`) REFERENCES `currency` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- order_status_i18n @@ -1947,7 +1947,7 @@ CREATE TABLE `order_status_i18n` FOREIGN KEY (`id`) REFERENCES `order_status` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- module_i18n @@ -1968,7 +1968,7 @@ CREATE TABLE `module_i18n` FOREIGN KEY (`id`) REFERENCES `module` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- group_i18n @@ -1989,7 +1989,7 @@ CREATE TABLE `group_i18n` FOREIGN KEY (`id`) REFERENCES `group` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- resource_i18n @@ -2010,7 +2010,7 @@ CREATE TABLE `resource_i18n` FOREIGN KEY (`id`) REFERENCES `resource` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- message_i18n @@ -2031,7 +2031,7 @@ CREATE TABLE `message_i18n` FOREIGN KEY (`id`) REFERENCES `message` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- coupon_i18n @@ -2051,7 +2051,7 @@ CREATE TABLE `coupon_i18n` FOREIGN KEY (`id`) REFERENCES `coupon` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- category_image_i18n @@ -2072,7 +2072,7 @@ CREATE TABLE `category_image_i18n` FOREIGN KEY (`id`) REFERENCES `category_image` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- folder_image_i18n @@ -2093,7 +2093,7 @@ CREATE TABLE `folder_image_i18n` FOREIGN KEY (`id`) REFERENCES `folder_image` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- content_image_i18n @@ -2114,7 +2114,7 @@ CREATE TABLE `content_image_i18n` FOREIGN KEY (`id`) REFERENCES `content_image` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- category_document_i18n @@ -2135,7 +2135,7 @@ CREATE TABLE `category_document_i18n` FOREIGN KEY (`id`) REFERENCES `category_document` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- content_document_i18n @@ -2156,7 +2156,7 @@ CREATE TABLE `content_document_i18n` FOREIGN KEY (`id`) REFERENCES `content_document` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- folder_document_i18n @@ -2177,7 +2177,7 @@ CREATE TABLE `folder_document_i18n` FOREIGN KEY (`id`) REFERENCES `folder_document` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- template_i18n @@ -2195,7 +2195,7 @@ CREATE TABLE `template_i18n` FOREIGN KEY (`id`) REFERENCES `template` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- module_image_i18n @@ -2216,7 +2216,7 @@ CREATE TABLE `module_image_i18n` FOREIGN KEY (`id`) REFERENCES `module_image` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- category_version @@ -2240,7 +2240,7 @@ CREATE TABLE `category_version` FOREIGN KEY (`id`) REFERENCES `category` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- product_version @@ -2266,7 +2266,7 @@ CREATE TABLE `product_version` FOREIGN KEY (`id`) REFERENCES `product` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- folder_version @@ -2290,7 +2290,7 @@ CREATE TABLE `folder_version` FOREIGN KEY (`id`) REFERENCES `folder` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- content_version @@ -2313,7 +2313,7 @@ CREATE TABLE `content_version` FOREIGN KEY (`id`) REFERENCES `content` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- message_version @@ -2336,7 +2336,7 @@ CREATE TABLE `message_version` FOREIGN KEY (`id`) REFERENCES `message` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; -- --------------------------------------------------------------------- -- coupon_version @@ -2366,7 +2366,7 @@ CREATE TABLE `coupon_version` FOREIGN KEY (`id`) REFERENCES `coupon` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB CHARACTER SET='utf8' COLLATE='utf8_general_ci'; # This restores the fkey checks, after having unset them earlier SET FOREIGN_KEY_CHECKS = 1; diff --git a/local/config/schema.xml b/local/config/schema.xml index 65928176e..04ae32873 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1,5 +1,10 @@ - + + + + + + From 4630007bc25e6c55a22ac8e8b3f8f376eb4385b4 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 22 Oct 2013 09:11:33 +0200 Subject: [PATCH 02/22] fix typo in error message --- core/lib/Thelia/Controller/Front/ContactController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Controller/Front/ContactController.php b/core/lib/Thelia/Controller/Front/ContactController.php index 83bd2588e..215c27870 100644 --- a/core/lib/Thelia/Controller/Front/ContactController.php +++ b/core/lib/Thelia/Controller/Front/ContactController.php @@ -58,7 +58,7 @@ class ContactController extends BaseFrontController } if ($error_message !== false) { - \Thelia\Log\Tlog::getInstance()->error(sprintf("Error during customer creation process : %s", $error_message)); + \Thelia\Log\Tlog::getInstance()->error(sprintf('Error during sending contant mail : %s', $error_message)); $contactForm->setErrorMessage($error_message); From f70c5362e979ca895fab197c209ff294f986497b Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 22 Oct 2013 09:13:21 +0200 Subject: [PATCH 03/22] fix typo --- core/lib/Thelia/Controller/Front/ContactController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Controller/Front/ContactController.php b/core/lib/Thelia/Controller/Front/ContactController.php index 215c27870..543d65c71 100644 --- a/core/lib/Thelia/Controller/Front/ContactController.php +++ b/core/lib/Thelia/Controller/Front/ContactController.php @@ -58,7 +58,7 @@ class ContactController extends BaseFrontController } if ($error_message !== false) { - \Thelia\Log\Tlog::getInstance()->error(sprintf('Error during sending contant mail : %s', $error_message)); + \Thelia\Log\Tlog::getInstance()->error(sprintf('Error during sending contact mail : %s', $error_message)); $contactForm->setErrorMessage($error_message); From f4c4cea32b1257d2393756f58f66549af9774c00 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 22 Oct 2013 09:36:52 +0200 Subject: [PATCH 04/22] create newsletter entity --- core/lib/Thelia/Model/Base/Newsletter.php | 1452 +++++++++++++++++ .../lib/Thelia/Model/Base/NewsletterQuery.php | 636 ++++++++ .../lib/Thelia/Model/Base/ProfileResource.php | 134 +- .../Model/Base/ProfileResourceQuery.php | 79 +- .../lib/Thelia/Model/Map/CustomerTableMap.php | 2 +- .../Thelia/Model/Map/NewsletterTableMap.php | 462 ++++++ .../Model/Map/ProfileResourceTableMap.php | 46 +- core/lib/Thelia/Model/Newsletter.php | 10 + core/lib/Thelia/Model/NewsletterQuery.php | 21 + install/thelia.sql | 23 +- local/config/schema.xml | 13 +- 11 files changed, 2683 insertions(+), 195 deletions(-) create mode 100644 core/lib/Thelia/Model/Base/Newsletter.php create mode 100644 core/lib/Thelia/Model/Base/NewsletterQuery.php create mode 100644 core/lib/Thelia/Model/Map/NewsletterTableMap.php create mode 100644 core/lib/Thelia/Model/Newsletter.php create mode 100644 core/lib/Thelia/Model/NewsletterQuery.php diff --git a/core/lib/Thelia/Model/Base/Newsletter.php b/core/lib/Thelia/Model/Base/Newsletter.php new file mode 100644 index 000000000..5282045d3 --- /dev/null +++ b/core/lib/Thelia/Model/Base/Newsletter.php @@ -0,0 +1,1452 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Newsletter instance. If + * obj is an instance of Newsletter, delegates to + * equals(Newsletter). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Newsletter The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Newsletter The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [email] column value. + * + * @return string + */ + public function getEmail() + { + + return $this->email; + } + + /** + * Get the [firstname] column value. + * + * @return string + */ + public function getFirstname() + { + + return $this->firstname; + } + + /** + * Get the [lastname] column value. + * + * @return string + */ + public function getLastname() + { + + return $this->lastname; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\Newsletter The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = NewsletterTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [email] column. + * + * @param string $v new value + * @return \Thelia\Model\Newsletter The current object (for fluent API support) + */ + public function setEmail($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->email !== $v) { + $this->email = $v; + $this->modifiedColumns[] = NewsletterTableMap::EMAIL; + } + + + return $this; + } // setEmail() + + /** + * Set the value of [firstname] column. + * + * @param string $v new value + * @return \Thelia\Model\Newsletter The current object (for fluent API support) + */ + public function setFirstname($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->firstname !== $v) { + $this->firstname = $v; + $this->modifiedColumns[] = NewsletterTableMap::FIRSTNAME; + } + + + return $this; + } // setFirstname() + + /** + * Set the value of [lastname] column. + * + * @param string $v new value + * @return \Thelia\Model\Newsletter The current object (for fluent API support) + */ + public function setLastname($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->lastname !== $v) { + $this->lastname = $v; + $this->modifiedColumns[] = NewsletterTableMap::LASTNAME; + } + + + return $this; + } // setLastname() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\Newsletter The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = NewsletterTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Newsletter The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = NewsletterTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Newsletter The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = NewsletterTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : NewsletterTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : NewsletterTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)]; + $this->email = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : NewsletterTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->firstname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : NewsletterTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->lastname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : NewsletterTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : NewsletterTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : NewsletterTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 7; // 7 = NewsletterTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\Newsletter object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(NewsletterTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildNewsletterQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see Newsletter::setDeleted() + * @see Newsletter::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(NewsletterTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildNewsletterQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(NewsletterTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(NewsletterTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(NewsletterTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(NewsletterTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + NewsletterTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = NewsletterTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . NewsletterTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(NewsletterTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(NewsletterTableMap::EMAIL)) { + $modifiedColumns[':p' . $index++] = 'EMAIL'; + } + if ($this->isColumnModified(NewsletterTableMap::FIRSTNAME)) { + $modifiedColumns[':p' . $index++] = 'FIRSTNAME'; + } + if ($this->isColumnModified(NewsletterTableMap::LASTNAME)) { + $modifiedColumns[':p' . $index++] = 'LASTNAME'; + } + if ($this->isColumnModified(NewsletterTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(NewsletterTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(NewsletterTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO newsletter (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'EMAIL': + $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR); + break; + case 'FIRSTNAME': + $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); + break; + case 'LASTNAME': + $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = NewsletterTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getEmail(); + break; + case 2: + return $this->getFirstname(); + break; + case 3: + return $this->getLastname(); + break; + case 4: + return $this->getLocale(); + break; + case 5: + return $this->getCreatedAt(); + break; + case 6: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + { + if (isset($alreadyDumpedObjects['Newsletter'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['Newsletter'][$this->getPrimaryKey()] = true; + $keys = NewsletterTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getEmail(), + $keys[2] => $this->getFirstname(), + $keys[3] => $this->getLastname(), + $keys[4] => $this->getLocale(), + $keys[5] => $this->getCreatedAt(), + $keys[6] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = NewsletterTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setEmail($value); + break; + case 2: + $this->setFirstname($value); + break; + case 3: + $this->setLastname($value); + break; + case 4: + $this->setLocale($value); + break; + case 5: + $this->setCreatedAt($value); + break; + case 6: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = NewsletterTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setEmail($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setFirstname($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setLastname($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setLocale($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(NewsletterTableMap::DATABASE_NAME); + + if ($this->isColumnModified(NewsletterTableMap::ID)) $criteria->add(NewsletterTableMap::ID, $this->id); + if ($this->isColumnModified(NewsletterTableMap::EMAIL)) $criteria->add(NewsletterTableMap::EMAIL, $this->email); + if ($this->isColumnModified(NewsletterTableMap::FIRSTNAME)) $criteria->add(NewsletterTableMap::FIRSTNAME, $this->firstname); + if ($this->isColumnModified(NewsletterTableMap::LASTNAME)) $criteria->add(NewsletterTableMap::LASTNAME, $this->lastname); + if ($this->isColumnModified(NewsletterTableMap::LOCALE)) $criteria->add(NewsletterTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(NewsletterTableMap::CREATED_AT)) $criteria->add(NewsletterTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(NewsletterTableMap::UPDATED_AT)) $criteria->add(NewsletterTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(NewsletterTableMap::DATABASE_NAME); + $criteria->add(NewsletterTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\Newsletter (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setEmail($this->getEmail()); + $copyObj->setFirstname($this->getFirstname()); + $copyObj->setLastname($this->getLastname()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Newsletter Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->email = null; + $this->firstname = null; + $this->lastname = null; + $this->locale = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(NewsletterTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildNewsletter The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = NewsletterTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/NewsletterQuery.php b/core/lib/Thelia/Model/Base/NewsletterQuery.php new file mode 100644 index 000000000..ef9ac0a22 --- /dev/null +++ b/core/lib/Thelia/Model/Base/NewsletterQuery.php @@ -0,0 +1,636 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildNewsletter|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = NewsletterTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(NewsletterTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildNewsletter A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, EMAIL, FIRSTNAME, LASTNAME, LOCALE, CREATED_AT, UPDATED_AT FROM newsletter WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildNewsletter(); + $obj->hydrate($row); + NewsletterTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildNewsletter|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(NewsletterTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(NewsletterTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(NewsletterTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(NewsletterTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(NewsletterTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the email column + * + * Example usage: + * + * $query->filterByEmail('fooValue'); // WHERE email = 'fooValue' + * $query->filterByEmail('%fooValue%'); // WHERE email LIKE '%fooValue%' + * + * + * @param string $email The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function filterByEmail($email = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($email)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $email)) { + $email = str_replace('*', '%', $email); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(NewsletterTableMap::EMAIL, $email, $comparison); + } + + /** + * Filter the query on the firstname column + * + * Example usage: + * + * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue' + * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%' + * + * + * @param string $firstname The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function filterByFirstname($firstname = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($firstname)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $firstname)) { + $firstname = str_replace('*', '%', $firstname); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(NewsletterTableMap::FIRSTNAME, $firstname, $comparison); + } + + /** + * Filter the query on the lastname column + * + * Example usage: + * + * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue' + * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%' + * + * + * @param string $lastname The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function filterByLastname($lastname = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($lastname)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $lastname)) { + $lastname = str_replace('*', '%', $lastname); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(NewsletterTableMap::LASTNAME, $lastname, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(NewsletterTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(NewsletterTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(NewsletterTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(NewsletterTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(NewsletterTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(NewsletterTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(NewsletterTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Exclude object from result + * + * @param ChildNewsletter $newsletter Object to remove from the list of results + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function prune($newsletter = null) + { + if ($newsletter) { + $this->addUsingAlias(NewsletterTableMap::ID, $newsletter->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the newsletter table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(NewsletterTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + NewsletterTableMap::clearInstancePool(); + NewsletterTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildNewsletter or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildNewsletter object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(NewsletterTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(NewsletterTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + NewsletterTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + NewsletterTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(NewsletterTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(NewsletterTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(NewsletterTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(NewsletterTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(NewsletterTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildNewsletterQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(NewsletterTableMap::CREATED_AT); + } + +} // NewsletterQuery diff --git a/core/lib/Thelia/Model/Base/ProfileResource.php b/core/lib/Thelia/Model/Base/ProfileResource.php index 9f3d246fc..bd62a76af 100644 --- a/core/lib/Thelia/Model/Base/ProfileResource.php +++ b/core/lib/Thelia/Model/Base/ProfileResource.php @@ -77,18 +77,11 @@ abstract class ProfileResource implements ActiveRecordInterface protected $resource_id; /** - * The value for the read field. + * The value for the access field. * Note: this column has a database default value of: 0 * @var int */ - protected $read; - - /** - * The value for the write field. - * Note: this column has a database default value of: 0 - * @var int - */ - protected $write; + protected $access; /** * The value for the created_at field. @@ -128,8 +121,7 @@ abstract class ProfileResource implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->read = 0; - $this->write = 0; + $this->access = 0; } /** @@ -426,25 +418,14 @@ abstract class ProfileResource implements ActiveRecordInterface } /** - * Get the [read] column value. + * Get the [access] column value. * * @return int */ - public function getRead() + public function getAccess() { - return $this->read; - } - - /** - * Get the [write] column value. - * - * @return int - */ - public function getWrite() - { - - return $this->write; + return $this->access; } /** @@ -559,46 +540,25 @@ abstract class ProfileResource implements ActiveRecordInterface } // setResourceId() /** - * Set the value of [read] column. + * Set the value of [access] column. * * @param int $v new value * @return \Thelia\Model\ProfileResource The current object (for fluent API support) */ - public function setRead($v) + public function setAccess($v) { if ($v !== null) { $v = (int) $v; } - if ($this->read !== $v) { - $this->read = $v; - $this->modifiedColumns[] = ProfileResourceTableMap::READ; + if ($this->access !== $v) { + $this->access = $v; + $this->modifiedColumns[] = ProfileResourceTableMap::ACCESS; } return $this; - } // setRead() - - /** - * Set the value of [write] column. - * - * @param int $v new value - * @return \Thelia\Model\ProfileResource The current object (for fluent API support) - */ - public function setWrite($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->write !== $v) { - $this->write = $v; - $this->modifiedColumns[] = ProfileResourceTableMap::WRITE; - } - - - return $this; - } // setWrite() + } // setAccess() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -652,11 +612,7 @@ abstract class ProfileResource implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->read !== 0) { - return false; - } - - if ($this->write !== 0) { + if ($this->access !== 0) { return false; } @@ -696,19 +652,16 @@ abstract class ProfileResource implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProfileResourceTableMap::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)]; $this->resource_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProfileResourceTableMap::translateFieldName('Read', TableMap::TYPE_PHPNAME, $indexType)]; - $this->read = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProfileResourceTableMap::translateFieldName('Access', TableMap::TYPE_PHPNAME, $indexType)]; + $this->access = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProfileResourceTableMap::translateFieldName('Write', TableMap::TYPE_PHPNAME, $indexType)]; - $this->write = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProfileResourceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProfileResourceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProfileResourceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProfileResourceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -721,7 +674,7 @@ abstract class ProfileResource implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 7; // 7 = ProfileResourceTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 6; // 6 = ProfileResourceTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\ProfileResource object", 0, $e); @@ -977,11 +930,8 @@ abstract class ProfileResource implements ActiveRecordInterface if ($this->isColumnModified(ProfileResourceTableMap::RESOURCE_ID)) { $modifiedColumns[':p' . $index++] = 'RESOURCE_ID'; } - if ($this->isColumnModified(ProfileResourceTableMap::READ)) { - $modifiedColumns[':p' . $index++] = 'READ'; - } - if ($this->isColumnModified(ProfileResourceTableMap::WRITE)) { - $modifiedColumns[':p' . $index++] = 'WRITE'; + if ($this->isColumnModified(ProfileResourceTableMap::ACCESS)) { + $modifiedColumns[':p' . $index++] = 'ACCESS'; } if ($this->isColumnModified(ProfileResourceTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -1009,11 +959,8 @@ abstract class ProfileResource implements ActiveRecordInterface case 'RESOURCE_ID': $stmt->bindValue($identifier, $this->resource_id, PDO::PARAM_INT); break; - case 'READ': - $stmt->bindValue($identifier, $this->read, PDO::PARAM_INT); - break; - case 'WRITE': - $stmt->bindValue($identifier, $this->write, PDO::PARAM_INT); + case 'ACCESS': + $stmt->bindValue($identifier, $this->access, PDO::PARAM_INT); break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); @@ -1093,15 +1040,12 @@ abstract class ProfileResource implements ActiveRecordInterface return $this->getResourceId(); break; case 3: - return $this->getRead(); + return $this->getAccess(); break; case 4: - return $this->getWrite(); - break; - case 5: return $this->getCreatedAt(); break; - case 6: + case 5: return $this->getUpdatedAt(); break; default: @@ -1136,10 +1080,9 @@ abstract class ProfileResource implements ActiveRecordInterface $keys[0] => $this->getId(), $keys[1] => $this->getProfileId(), $keys[2] => $this->getResourceId(), - $keys[3] => $this->getRead(), - $keys[4] => $this->getWrite(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), + $keys[3] => $this->getAccess(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1197,15 +1140,12 @@ abstract class ProfileResource implements ActiveRecordInterface $this->setResourceId($value); break; case 3: - $this->setRead($value); + $this->setAccess($value); break; case 4: - $this->setWrite($value); - break; - case 5: $this->setCreatedAt($value); break; - case 6: + case 5: $this->setUpdatedAt($value); break; } // switch() @@ -1235,10 +1175,9 @@ abstract class ProfileResource implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setProfileId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setResourceId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setRead($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setWrite($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); + if (array_key_exists($keys[3], $arr)) $this->setAccess($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); } /** @@ -1253,8 +1192,7 @@ abstract class ProfileResource implements ActiveRecordInterface if ($this->isColumnModified(ProfileResourceTableMap::ID)) $criteria->add(ProfileResourceTableMap::ID, $this->id); if ($this->isColumnModified(ProfileResourceTableMap::PROFILE_ID)) $criteria->add(ProfileResourceTableMap::PROFILE_ID, $this->profile_id); if ($this->isColumnModified(ProfileResourceTableMap::RESOURCE_ID)) $criteria->add(ProfileResourceTableMap::RESOURCE_ID, $this->resource_id); - if ($this->isColumnModified(ProfileResourceTableMap::READ)) $criteria->add(ProfileResourceTableMap::READ, $this->read); - if ($this->isColumnModified(ProfileResourceTableMap::WRITE)) $criteria->add(ProfileResourceTableMap::WRITE, $this->write); + if ($this->isColumnModified(ProfileResourceTableMap::ACCESS)) $criteria->add(ProfileResourceTableMap::ACCESS, $this->access); if ($this->isColumnModified(ProfileResourceTableMap::CREATED_AT)) $criteria->add(ProfileResourceTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(ProfileResourceTableMap::UPDATED_AT)) $criteria->add(ProfileResourceTableMap::UPDATED_AT, $this->updated_at); @@ -1332,8 +1270,7 @@ abstract class ProfileResource implements ActiveRecordInterface { $copyObj->setProfileId($this->getProfileId()); $copyObj->setResourceId($this->getResourceId()); - $copyObj->setRead($this->getRead()); - $copyObj->setWrite($this->getWrite()); + $copyObj->setAccess($this->getAccess()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1474,8 +1411,7 @@ abstract class ProfileResource implements ActiveRecordInterface $this->id = null; $this->profile_id = null; $this->resource_id = null; - $this->read = null; - $this->write = null; + $this->access = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/ProfileResourceQuery.php b/core/lib/Thelia/Model/Base/ProfileResourceQuery.php index 23794538f..ba4fca82d 100644 --- a/core/lib/Thelia/Model/Base/ProfileResourceQuery.php +++ b/core/lib/Thelia/Model/Base/ProfileResourceQuery.php @@ -24,16 +24,14 @@ use Thelia\Model\Map\ProfileResourceTableMap; * @method ChildProfileResourceQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildProfileResourceQuery orderByProfileId($order = Criteria::ASC) Order by the profile_id column * @method ChildProfileResourceQuery orderByResourceId($order = Criteria::ASC) Order by the resource_id column - * @method ChildProfileResourceQuery orderByRead($order = Criteria::ASC) Order by the read column - * @method ChildProfileResourceQuery orderByWrite($order = Criteria::ASC) Order by the write column + * @method ChildProfileResourceQuery orderByAccess($order = Criteria::ASC) Order by the access column * @method ChildProfileResourceQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildProfileResourceQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildProfileResourceQuery groupById() Group by the id column * @method ChildProfileResourceQuery groupByProfileId() Group by the profile_id column * @method ChildProfileResourceQuery groupByResourceId() Group by the resource_id column - * @method ChildProfileResourceQuery groupByRead() Group by the read column - * @method ChildProfileResourceQuery groupByWrite() Group by the write column + * @method ChildProfileResourceQuery groupByAccess() Group by the access column * @method ChildProfileResourceQuery groupByCreatedAt() Group by the created_at column * @method ChildProfileResourceQuery groupByUpdatedAt() Group by the updated_at column * @@ -55,16 +53,14 @@ use Thelia\Model\Map\ProfileResourceTableMap; * @method ChildProfileResource findOneById(int $id) Return the first ChildProfileResource filtered by the id column * @method ChildProfileResource findOneByProfileId(int $profile_id) Return the first ChildProfileResource filtered by the profile_id column * @method ChildProfileResource findOneByResourceId(int $resource_id) Return the first ChildProfileResource filtered by the resource_id column - * @method ChildProfileResource findOneByRead(int $read) Return the first ChildProfileResource filtered by the read column - * @method ChildProfileResource findOneByWrite(int $write) Return the first ChildProfileResource filtered by the write column + * @method ChildProfileResource findOneByAccess(int $access) Return the first ChildProfileResource filtered by the access column * @method ChildProfileResource findOneByCreatedAt(string $created_at) Return the first ChildProfileResource filtered by the created_at column * @method ChildProfileResource findOneByUpdatedAt(string $updated_at) Return the first ChildProfileResource filtered by the updated_at column * * @method array findById(int $id) Return ChildProfileResource objects filtered by the id column * @method array findByProfileId(int $profile_id) Return ChildProfileResource objects filtered by the profile_id column * @method array findByResourceId(int $resource_id) Return ChildProfileResource objects filtered by the resource_id column - * @method array findByRead(int $read) Return ChildProfileResource objects filtered by the read column - * @method array findByWrite(int $write) Return ChildProfileResource objects filtered by the write column + * @method array findByAccess(int $access) Return ChildProfileResource objects filtered by the access column * @method array findByCreatedAt(string $created_at) Return ChildProfileResource objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildProfileResource objects filtered by the updated_at column * @@ -155,7 +151,7 @@ abstract class ProfileResourceQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, PROFILE_ID, RESOURCE_ID, READ, WRITE, CREATED_AT, UPDATED_AT FROM profile_resource WHERE ID = :p0 AND PROFILE_ID = :p1 AND RESOURCE_ID = :p2'; + $sql = 'SELECT ID, PROFILE_ID, RESOURCE_ID, ACCESS, CREATED_AT, UPDATED_AT FROM profile_resource WHERE ID = :p0 AND PROFILE_ID = :p1 AND RESOURCE_ID = :p2'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -388,16 +384,16 @@ abstract class ProfileResourceQuery extends ModelCriteria } /** - * Filter the query on the read column + * Filter the query on the access column * * Example usage: * - * $query->filterByRead(1234); // WHERE read = 1234 - * $query->filterByRead(array(12, 34)); // WHERE read IN (12, 34) - * $query->filterByRead(array('min' => 12)); // WHERE read > 12 + * $query->filterByAccess(1234); // WHERE access = 1234 + * $query->filterByAccess(array(12, 34)); // WHERE access IN (12, 34) + * $query->filterByAccess(array('min' => 12)); // WHERE access > 12 * * - * @param mixed $read The value to use as filter. + * @param mixed $access The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -405,16 +401,16 @@ abstract class ProfileResourceQuery extends ModelCriteria * * @return ChildProfileResourceQuery The current query, for fluid interface */ - public function filterByRead($read = null, $comparison = null) + public function filterByAccess($access = null, $comparison = null) { - if (is_array($read)) { + if (is_array($access)) { $useMinMax = false; - if (isset($read['min'])) { - $this->addUsingAlias(ProfileResourceTableMap::READ, $read['min'], Criteria::GREATER_EQUAL); + if (isset($access['min'])) { + $this->addUsingAlias(ProfileResourceTableMap::ACCESS, $access['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($read['max'])) { - $this->addUsingAlias(ProfileResourceTableMap::READ, $read['max'], Criteria::LESS_EQUAL); + if (isset($access['max'])) { + $this->addUsingAlias(ProfileResourceTableMap::ACCESS, $access['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -425,48 +421,7 @@ abstract class ProfileResourceQuery extends ModelCriteria } } - return $this->addUsingAlias(ProfileResourceTableMap::READ, $read, $comparison); - } - - /** - * Filter the query on the write column - * - * Example usage: - * - * $query->filterByWrite(1234); // WHERE write = 1234 - * $query->filterByWrite(array(12, 34)); // WHERE write IN (12, 34) - * $query->filterByWrite(array('min' => 12)); // WHERE write > 12 - * - * - * @param mixed $write The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildProfileResourceQuery The current query, for fluid interface - */ - public function filterByWrite($write = null, $comparison = null) - { - if (is_array($write)) { - $useMinMax = false; - if (isset($write['min'])) { - $this->addUsingAlias(ProfileResourceTableMap::WRITE, $write['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($write['max'])) { - $this->addUsingAlias(ProfileResourceTableMap::WRITE, $write['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProfileResourceTableMap::WRITE, $write, $comparison); + return $this->addUsingAlias(ProfileResourceTableMap::ACCESS, $access, $comparison); } /** diff --git a/core/lib/Thelia/Model/Map/CustomerTableMap.php b/core/lib/Thelia/Model/Map/CustomerTableMap.php index 4dd1c3e7d..2c1fdfae2 100644 --- a/core/lib/Thelia/Model/Map/CustomerTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTableMap.php @@ -205,7 +205,7 @@ class CustomerTableMap extends TableMap $this->addForeignKey('TITLE_ID', 'TitleId', 'INTEGER', 'customer_title', 'ID', true, null, null); $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null); $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null); - $this->addColumn('EMAIL', 'Email', 'VARCHAR', false, 50, null); + $this->addColumn('EMAIL', 'Email', 'VARCHAR', false, 255, null); $this->addColumn('PASSWORD', 'Password', 'VARCHAR', false, 255, null); $this->addColumn('ALGO', 'Algo', 'VARCHAR', false, 128, null); $this->addColumn('RESELLER', 'Reseller', 'TINYINT', false, null, null); diff --git a/core/lib/Thelia/Model/Map/NewsletterTableMap.php b/core/lib/Thelia/Model/Map/NewsletterTableMap.php new file mode 100644 index 000000000..192c8cfa6 --- /dev/null +++ b/core/lib/Thelia/Model/Map/NewsletterTableMap.php @@ -0,0 +1,462 @@ + array('Id', 'Email', 'Firstname', 'Lastname', 'Locale', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'email', 'firstname', 'lastname', 'locale', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(NewsletterTableMap::ID, NewsletterTableMap::EMAIL, NewsletterTableMap::FIRSTNAME, NewsletterTableMap::LASTNAME, NewsletterTableMap::LOCALE, NewsletterTableMap::CREATED_AT, NewsletterTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'EMAIL', 'FIRSTNAME', 'LASTNAME', 'LOCALE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'email', 'firstname', 'lastname', 'locale', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Email' => 1, 'Firstname' => 2, 'Lastname' => 3, 'Locale' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'email' => 1, 'firstname' => 2, 'lastname' => 3, 'locale' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(NewsletterTableMap::ID => 0, NewsletterTableMap::EMAIL => 1, NewsletterTableMap::FIRSTNAME => 2, NewsletterTableMap::LASTNAME => 3, NewsletterTableMap::LOCALE => 4, NewsletterTableMap::CREATED_AT => 5, NewsletterTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'EMAIL' => 1, 'FIRSTNAME' => 2, 'LASTNAME' => 3, 'LOCALE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'email' => 1, 'firstname' => 2, 'lastname' => 3, 'locale' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('newsletter'); + $this->setPhpName('Newsletter'); + $this->setClassName('\\Thelia\\Model\\Newsletter'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('EMAIL', 'Email', 'VARCHAR', true, 255, null); + $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', false, 255, null); + $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', false, 255, null); + $this->addColumn('LOCALE', 'Locale', 'VARCHAR', false, 45, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? NewsletterTableMap::CLASS_DEFAULT : NewsletterTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (Newsletter object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = NewsletterTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = NewsletterTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + NewsletterTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = NewsletterTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + NewsletterTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = NewsletterTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = NewsletterTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + NewsletterTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(NewsletterTableMap::ID); + $criteria->addSelectColumn(NewsletterTableMap::EMAIL); + $criteria->addSelectColumn(NewsletterTableMap::FIRSTNAME); + $criteria->addSelectColumn(NewsletterTableMap::LASTNAME); + $criteria->addSelectColumn(NewsletterTableMap::LOCALE); + $criteria->addSelectColumn(NewsletterTableMap::CREATED_AT); + $criteria->addSelectColumn(NewsletterTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.EMAIL'); + $criteria->addSelectColumn($alias . '.FIRSTNAME'); + $criteria->addSelectColumn($alias . '.LASTNAME'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(NewsletterTableMap::DATABASE_NAME)->getTable(NewsletterTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(NewsletterTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(NewsletterTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new NewsletterTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a Newsletter or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or Newsletter object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(NewsletterTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Newsletter) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(NewsletterTableMap::DATABASE_NAME); + $criteria->add(NewsletterTableMap::ID, (array) $values, Criteria::IN); + } + + $query = NewsletterQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { NewsletterTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { NewsletterTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the newsletter table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return NewsletterQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Newsletter or Criteria object. + * + * @param mixed $criteria Criteria or Newsletter object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(NewsletterTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Newsletter object + } + + if ($criteria->containsKey(NewsletterTableMap::ID) && $criteria->keyContainsValue(NewsletterTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.NewsletterTableMap::ID.')'); + } + + + // Set the correct dbName + $query = NewsletterQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // NewsletterTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +NewsletterTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProfileResourceTableMap.php b/core/lib/Thelia/Model/Map/ProfileResourceTableMap.php index 4e46d9c33..5a7f1e07e 100644 --- a/core/lib/Thelia/Model/Map/ProfileResourceTableMap.php +++ b/core/lib/Thelia/Model/Map/ProfileResourceTableMap.php @@ -57,7 +57,7 @@ class ProfileResourceTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 7; + const NUM_COLUMNS = 6; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class ProfileResourceTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 7; + const NUM_HYDRATE_COLUMNS = 6; /** * the column name for the ID field @@ -85,14 +85,9 @@ class ProfileResourceTableMap extends TableMap const RESOURCE_ID = 'profile_resource.RESOURCE_ID'; /** - * the column name for the READ field + * the column name for the ACCESS field */ - const READ = 'profile_resource.READ'; - - /** - * the column name for the WRITE field - */ - const WRITE = 'profile_resource.WRITE'; + const ACCESS = 'profile_resource.ACCESS'; /** * the column name for the CREATED_AT field @@ -116,12 +111,12 @@ class ProfileResourceTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'ProfileId', 'ResourceId', 'Read', 'Write', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'profileId', 'resourceId', 'read', 'write', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ProfileResourceTableMap::ID, ProfileResourceTableMap::PROFILE_ID, ProfileResourceTableMap::RESOURCE_ID, ProfileResourceTableMap::READ, ProfileResourceTableMap::WRITE, ProfileResourceTableMap::CREATED_AT, ProfileResourceTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'PROFILE_ID', 'RESOURCE_ID', 'READ', 'WRITE', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'profile_id', 'resource_id', 'read', 'write', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + self::TYPE_PHPNAME => array('Id', 'ProfileId', 'ResourceId', 'Access', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'profileId', 'resourceId', 'access', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProfileResourceTableMap::ID, ProfileResourceTableMap::PROFILE_ID, ProfileResourceTableMap::RESOURCE_ID, ProfileResourceTableMap::ACCESS, ProfileResourceTableMap::CREATED_AT, ProfileResourceTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PROFILE_ID', 'RESOURCE_ID', 'ACCESS', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'profile_id', 'resource_id', 'access', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -131,12 +126,12 @@ class ProfileResourceTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'ProfileId' => 1, 'ResourceId' => 2, 'Read' => 3, 'Write' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'profileId' => 1, 'resourceId' => 2, 'read' => 3, 'write' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - self::TYPE_COLNAME => array(ProfileResourceTableMap::ID => 0, ProfileResourceTableMap::PROFILE_ID => 1, ProfileResourceTableMap::RESOURCE_ID => 2, ProfileResourceTableMap::READ => 3, ProfileResourceTableMap::WRITE => 4, ProfileResourceTableMap::CREATED_AT => 5, ProfileResourceTableMap::UPDATED_AT => 6, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'PROFILE_ID' => 1, 'RESOURCE_ID' => 2, 'READ' => 3, 'WRITE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - self::TYPE_FIELDNAME => array('id' => 0, 'profile_id' => 1, 'resource_id' => 2, 'read' => 3, 'write' => 4, 'created_at' => 5, 'updated_at' => 6, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + self::TYPE_PHPNAME => array('Id' => 0, 'ProfileId' => 1, 'ResourceId' => 2, 'Access' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'profileId' => 1, 'resourceId' => 2, 'access' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(ProfileResourceTableMap::ID => 0, ProfileResourceTableMap::PROFILE_ID => 1, ProfileResourceTableMap::RESOURCE_ID => 2, ProfileResourceTableMap::ACCESS => 3, ProfileResourceTableMap::CREATED_AT => 4, ProfileResourceTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PROFILE_ID' => 1, 'RESOURCE_ID' => 2, 'ACCESS' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'profile_id' => 1, 'resource_id' => 2, 'access' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -159,8 +154,7 @@ class ProfileResourceTableMap extends TableMap $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignPrimaryKey('PROFILE_ID', 'ProfileId', 'INTEGER' , 'profile', 'ID', true, null, null); $this->addForeignPrimaryKey('RESOURCE_ID', 'ResourceId', 'INTEGER' , 'resource', 'ID', true, null, null); - $this->addColumn('READ', 'Read', 'TINYINT', false, null, 0); - $this->addColumn('WRITE', 'Write', 'TINYINT', false, null, 0); + $this->addColumn('ACCESS', 'Access', 'INTEGER', true, null, 0); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -377,16 +371,14 @@ class ProfileResourceTableMap extends TableMap $criteria->addSelectColumn(ProfileResourceTableMap::ID); $criteria->addSelectColumn(ProfileResourceTableMap::PROFILE_ID); $criteria->addSelectColumn(ProfileResourceTableMap::RESOURCE_ID); - $criteria->addSelectColumn(ProfileResourceTableMap::READ); - $criteria->addSelectColumn(ProfileResourceTableMap::WRITE); + $criteria->addSelectColumn(ProfileResourceTableMap::ACCESS); $criteria->addSelectColumn(ProfileResourceTableMap::CREATED_AT); $criteria->addSelectColumn(ProfileResourceTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.PROFILE_ID'); $criteria->addSelectColumn($alias . '.RESOURCE_ID'); - $criteria->addSelectColumn($alias . '.READ'); - $criteria->addSelectColumn($alias . '.WRITE'); + $criteria->addSelectColumn($alias . '.ACCESS'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Newsletter.php b/core/lib/Thelia/Model/Newsletter.php new file mode 100644 index 000000000..80026cd76 --- /dev/null +++ b/core/lib/Thelia/Model/Newsletter.php @@ -0,0 +1,10 @@ + - + @@ -776,8 +776,7 @@ - - + @@ -1246,4 +1245,12 @@
+ + + + + + + +
From aabd05f17fe4200990d56fd6fd84dea10b778dd9 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 22 Oct 2013 09:42:57 +0200 Subject: [PATCH 05/22] create form and controller for newsletter --- core/lib/Thelia/Config/Resources/config.xml | 1 + .../Controller/Front/NewsletterController.php | 52 +++++++++++++ core/lib/Thelia/Form/NewsletterForm.php | 75 +++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 core/lib/Thelia/Controller/Front/NewsletterController.php create mode 100644 core/lib/Thelia/Form/NewsletterForm.php diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 4305851b1..493f9fbf8 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -147,6 +147,7 @@
+ diff --git a/core/lib/Thelia/Controller/Front/NewsletterController.php b/core/lib/Thelia/Controller/Front/NewsletterController.php new file mode 100644 index 000000000..a5778ad46 --- /dev/null +++ b/core/lib/Thelia/Controller/Front/NewsletterController.php @@ -0,0 +1,52 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Front; +use Thelia\Form\Exception\FormValidationException; +use Thelia\Form\NewsletterForm; + + +/** + * Class NewsletterController + * @package Thelia\Controller\Front + * @author Manuel Raynaud + */ +class NewsletterController extends BaseFrontController +{ + + public function subscribeAction() + { + $error_message = false; + $newsletterForm = new NewsletterForm($this->getRequest()); + + try { + + $form = $this->validateForm($newsletterForm); + + + + } catch(FormValidationException $e) { + + } + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/NewsletterForm.php b/core/lib/Thelia/Form/NewsletterForm.php new file mode 100644 index 000000000..2bfff496c --- /dev/null +++ b/core/lib/Thelia/Form/NewsletterForm.php @@ -0,0 +1,75 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form; +use Symfony\Component\Validator\Constraints\Email; +use Symfony\Component\Validator\Constraints\NotBlank; + + +/** + * Class NewsletterForm + * @package Thelia\Form + * @author Manuel Raynaud + */ +class NewsletterForm extends BaseForm +{ + + /** + * + * in this function you add all the fields you need for your Form. + * Form this you have to call add method on $this->formBuilder attribute : + * + * $this->formBuilder->add("name", "text") + * ->add("email", "email", array( + * "attr" => array( + * "class" => "field" + * ), + * "label" => "email", + * "constraints" => array( + * new \Symfony\Component\Validator\Constraints\NotBlank() + * ) + * ) + * ) + * ->add('age', 'integer'); + * + * @return null + */ + protected function buildForm() + { + $this->formBuilder + ->add('email', 'email', array( + 'constraints' => array( + new NotBlank(), + new Email() + ) + )); + } + + /** + * @return string the name of you form. This name must be unique + */ + public function getName() + { + return 'thelia_newsletter'; + } +} \ No newline at end of file From 6b8c7602b4b4f42cc30b02c8f81e5a9ccaa9e26e Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 22 Oct 2013 09:45:37 +0200 Subject: [PATCH 06/22] create newsletter event --- .../Core/Event/Newsletter/NewsletterEvent.php | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 core/lib/Thelia/Core/Event/Newsletter/NewsletterEvent.php diff --git a/core/lib/Thelia/Core/Event/Newsletter/NewsletterEvent.php b/core/lib/Thelia/Core/Event/Newsletter/NewsletterEvent.php new file mode 100644 index 000000000..9d64d59f5 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Newsletter/NewsletterEvent.php @@ -0,0 +1,117 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Newsletter; +use Thelia\Core\Event\ActionEvent; + + +/** + * Class NewsletterEvent + * @package Thelia\Core\Event\Newsletter + * @author Manuel Raynaud + */ +class NewsletterEvent extends ActionEvent +{ + /** + * @var string email to save + */ + protected $email; + + /** + * @var string first name subscriber + */ + protected $firstname; + + /** + * @var string last name subscriber + */ + protected $lastname; + + function __construct($email) + { + $this->email = $email; + } + + /** + * @param string $email + * + * @return $this + */ + public function setEmail($email) + { + $this->email = $email; + + return $this; + } + + /** + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * @param string $firstname + * + * @return $this + */ + public function setFirstname($firstname) + { + $this->firstname = $firstname; + + return $this; + } + + /** + * @return string + */ + public function getFirstname() + { + return $this->firstname; + } + + /** + * @param string $lastname + * + * @return $this + */ + public function setLastname($lastname) + { + $this->lastname = $lastname; + + return $this; + } + + /** + * @return string + */ + public function getLastname() + { + return $this->lastname; + } + + + +} \ No newline at end of file From f52a0f36527479fb7fed2014396d54b35a4ac1a9 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 22 Oct 2013 09:46:38 +0200 Subject: [PATCH 07/22] create event message for newsletter subsribe action --- core/lib/Thelia/Core/Event/TheliaEvents.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 65d7a9cc2..731c03f23 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -681,4 +681,9 @@ final class TheliaEvents * sent for clearing cache */ const CACHE_CLEAR = 'thelia.cache.clear'; + + /** + * sent for subscribing to the newsletter + */ + const NEWSLETTER_SUBSCRIBE = 'thelia.newsletter.subscribe'; } From f6fb778c3e20781530434bdec81daca0af837a54 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 22 Oct 2013 09:48:24 +0200 Subject: [PATCH 08/22] create newsletter listener --- core/lib/Thelia/Action/Newsletter.php | 70 +++++++++++++++++++++ core/lib/Thelia/Config/Resources/action.xml | 4 ++ 2 files changed, 74 insertions(+) create mode 100644 core/lib/Thelia/Action/Newsletter.php diff --git a/core/lib/Thelia/Action/Newsletter.php b/core/lib/Thelia/Action/Newsletter.php new file mode 100644 index 000000000..fd5aeeb6c --- /dev/null +++ b/core/lib/Thelia/Action/Newsletter.php @@ -0,0 +1,70 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\Newsletter\NewsletterEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Tests\Action\BaseAction; + + +/** + * Class Newsletter + * @package Thelia\Action + * @author Manuel Raynaud + */ +class Newsletter extends BaseAction implements EventSubscriberInterface +{ + + public function subscribe(NewsletterEvent $event) + { + + } + + /** + * Returns an array of event names this subscriber wants to listen to. + * + * The array keys are event names and the value can be: + * + * * The method name to call (priority defaults to 0) + * * An array composed of the method name to call and the priority + * * An array of arrays composed of the method names to call and respective + * priorities, or 0 if unset + * + * For instance: + * + * * array('eventName' => 'methodName') + * * array('eventName' => array('methodName', $priority)) + * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) + * + * @return array The event names to listen to + * + * @api + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::NEWSLETTER_SUBSCRIBE => array('subscribe', 128) + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 4bc25b65d..e5d6c9492 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -156,6 +156,10 @@ + + + + From 30f09734814c6e96855c3faf8a971b9179a001fe Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 22 Oct 2013 09:51:42 +0200 Subject: [PATCH 09/22] complete newsletter controller --- .../Controller/Front/NewsletterController.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/core/lib/Thelia/Controller/Front/NewsletterController.php b/core/lib/Thelia/Controller/Front/NewsletterController.php index a5778ad46..b0d92353e 100644 --- a/core/lib/Thelia/Controller/Front/NewsletterController.php +++ b/core/lib/Thelia/Controller/Front/NewsletterController.php @@ -22,6 +22,8 @@ /*************************************************************************************/ namespace Thelia\Controller\Front; +use Thelia\Core\Event\Newsletter\NewsletterEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Form\Exception\FormValidationException; use Thelia\Form\NewsletterForm; @@ -43,10 +45,31 @@ class NewsletterController extends BaseFrontController $form = $this->validateForm($newsletterForm); + $event = new NewsletterEvent($form->get('email')->getData()); + if (null !== $customer = $this->getSecurityContext()->getCustomerUser()) + { + $event->setFirstname($customer->getFirstname()); + $event->setLastname($customer->getLastname()); + } + + $this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $event); } catch(FormValidationException $e) { + $error_message = $e->getMessage(); + } + if($error_message) { + \Thelia\Log\Tlog::getInstance()->error(sprintf('Error during sending contact mail : %s', $error_message)); + + $newsletterForm->setErrorMessage($error_message); + + $this->getParserContext() + ->addForm($newsletterForm) + ->setGeneralError($error_message) + ; + } else { + $this->redirectToRoute('newsletter.success'); } } } \ No newline at end of file From 888c2c6ab9a6940f58e69d5dc2668c02586cfa4f Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 22 Oct 2013 09:54:44 +0200 Subject: [PATCH 10/22] create routes for newsletter management --- .../lib/Thelia/Config/Resources/routing/front.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index 74cf23db8..f73e2712c 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -168,6 +168,7 @@ Thelia\Controller\Front\Mail::test + Thelia\Controller\Front\DefaultController::noAction contact @@ -182,5 +183,19 @@ Thelia\Controller\Front\DefaultController::noAction contact-success + + + + + Thelia\Controller\Front\NewsletterController::subscribeAction + newsletter + + + + Thelia\Controller\Front\DefaultController::noAction + newsletter-success + + + From c9074892b287474bbe3f4bc58053c4dd9d846400 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 22 Oct 2013 10:01:02 +0200 Subject: [PATCH 11/22] complete controller and newsletter listener --- core/lib/Thelia/Action/Newsletter.php | 10 ++++++- .../Controller/Front/NewsletterController.php | 9 ++++-- .../Core/Event/Newsletter/NewsletterEvent.php | 30 ++++++++++++++++++- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/core/lib/Thelia/Action/Newsletter.php b/core/lib/Thelia/Action/Newsletter.php index fd5aeeb6c..fa2e54f09 100644 --- a/core/lib/Thelia/Action/Newsletter.php +++ b/core/lib/Thelia/Action/Newsletter.php @@ -25,7 +25,8 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\Newsletter\NewsletterEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Tests\Action\BaseAction; +use Thelia\Action\BaseAction; +use Thelia\Model\Newsletter as NewsletterModel; /** @@ -38,7 +39,14 @@ class Newsletter extends BaseAction implements EventSubscriberInterface public function subscribe(NewsletterEvent $event) { + $newsletter = new NewsletterModel(); + $newsletter + ->setEmail($event->getEmail()) + ->setFirstname($event->getFirstname()) + ->setLastname($event->getLastname()) + ->setLocale($event->getLocale()) + ->save(); } /** diff --git a/core/lib/Thelia/Controller/Front/NewsletterController.php b/core/lib/Thelia/Controller/Front/NewsletterController.php index b0d92353e..bdc52db75 100644 --- a/core/lib/Thelia/Controller/Front/NewsletterController.php +++ b/core/lib/Thelia/Controller/Front/NewsletterController.php @@ -22,9 +22,9 @@ /*************************************************************************************/ namespace Thelia\Controller\Front; + use Thelia\Core\Event\Newsletter\NewsletterEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Form\Exception\FormValidationException; use Thelia\Form\NewsletterForm; @@ -45,7 +45,10 @@ class NewsletterController extends BaseFrontController $form = $this->validateForm($newsletterForm); - $event = new NewsletterEvent($form->get('email')->getData()); + $event = new NewsletterEvent( + $form->get('email')->getData(), + $this->getRequest()->getSession()->getLang()->getLocale() + ); if (null !== $customer = $this->getSecurityContext()->getCustomerUser()) { @@ -55,7 +58,7 @@ class NewsletterController extends BaseFrontController $this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $event); - } catch(FormValidationException $e) { + } catch(\Exception $e) { $error_message = $e->getMessage(); } diff --git a/core/lib/Thelia/Core/Event/Newsletter/NewsletterEvent.php b/core/lib/Thelia/Core/Event/Newsletter/NewsletterEvent.php index 9d64d59f5..fc50980c0 100644 --- a/core/lib/Thelia/Core/Event/Newsletter/NewsletterEvent.php +++ b/core/lib/Thelia/Core/Event/Newsletter/NewsletterEvent.php @@ -47,9 +47,15 @@ class NewsletterEvent extends ActionEvent */ protected $lastname; - function __construct($email) + /** + * @var string current locale + */ + protected $locale; + + function __construct($email, $locale) { $this->email = $email; + $this->locale = $locale; } /** @@ -112,6 +118,28 @@ class NewsletterEvent extends ActionEvent return $this->lastname; } + /** + * @param string $locale + * + * @return $this + */ + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + /** + * @return string + */ + public function getLocale() + { + return $this->locale; + } + + + } \ No newline at end of file From cc4f4f0bbef38c3dc9f37d305cf01a5c7f16da29 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 22 Oct 2013 10:49:30 +0200 Subject: [PATCH 12/22] create newsletter template --- .../Thelia/Config/Resources/routing/front.xml | 7 ++- .../Controller/Front/NewsletterController.php | 4 +- core/lib/Thelia/Form/NewsletterForm.php | 6 +++ templates/default/layout.tpl | 8 +++- templates/default/newsletter-success.html | 15 ++++++ templates/default/newsletter.html | 46 +++++++++++++++++++ 6 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 templates/default/newsletter-success.html create mode 100644 templates/default/newsletter.html diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index f73e2712c..3e0c39939 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -187,7 +187,12 @@ - + + Thelia\Controller\Front\DefaultController::noAction + newsletter + + + Thelia\Controller\Front\NewsletterController::subscribeAction newsletter diff --git a/core/lib/Thelia/Controller/Front/NewsletterController.php b/core/lib/Thelia/Controller/Front/NewsletterController.php index bdc52db75..636923f5b 100644 --- a/core/lib/Thelia/Controller/Front/NewsletterController.php +++ b/core/lib/Thelia/Controller/Front/NewsletterController.php @@ -62,8 +62,8 @@ class NewsletterController extends BaseFrontController $error_message = $e->getMessage(); } - if($error_message) { - \Thelia\Log\Tlog::getInstance()->error(sprintf('Error during sending contact mail : %s', $error_message)); + if($error_message !== false) { + \Thelia\Log\Tlog::getInstance()->error(sprintf('Error during newsletter subscription : %s', $error_message)); $newsletterForm->setErrorMessage($error_message); diff --git a/core/lib/Thelia/Form/NewsletterForm.php b/core/lib/Thelia/Form/NewsletterForm.php index 2bfff496c..3e70dde67 100644 --- a/core/lib/Thelia/Form/NewsletterForm.php +++ b/core/lib/Thelia/Form/NewsletterForm.php @@ -22,8 +22,10 @@ /*************************************************************************************/ namespace Thelia\Form; + use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; /** @@ -61,6 +63,10 @@ class NewsletterForm extends BaseForm 'constraints' => array( new NotBlank(), new Email() + ), + 'label' => Translator::getInstance()->trans('email'), + 'label_attr' => array( + 'for' => 'email_newsletter' ) )); } diff --git a/templates/default/layout.tpl b/templates/default/layout.tpl index 647b3267a..22e8cb5a5 100644 --- a/templates/default/layout.tpl +++ b/templates/default/layout.tpl @@ -297,13 +297,17 @@ URL: http://www.thelia.net

{intl l="Newsletter"}

{intl l="Sign up to receive our latest news."}

+ {form name="thelia.newsletter"} + {form_field form=$form field="email"}
- - + +
+ {/form_field} + {/form}
diff --git a/templates/default/newsletter-success.html b/templates/default/newsletter-success.html new file mode 100644 index 000000000..8c6820fe8 --- /dev/null +++ b/templates/default/newsletter-success.html @@ -0,0 +1,15 @@ +{extends file="layout.tpl"} + +{* Breadcrumb *} +{block name='no-return-functions' append} + {$breadcrumbs = [['title' => {intl l="Thanks !"}, 'url'=>{url path="/contact/success"}]]} +{/block} + +{block name="main-content"} +
+
+

{intl l="Thanks !"}

+

{intl l="Thanks for your subscrition to the newsletter"}

+
+
+{/block} \ No newline at end of file diff --git a/templates/default/newsletter.html b/templates/default/newsletter.html new file mode 100644 index 000000000..f7e4d25dc --- /dev/null +++ b/templates/default/newsletter.html @@ -0,0 +1,46 @@ +{extends file="layout.tpl"} + +{* Breadcrumb *} +{block name='no-return-functions' append} + {$breadcrumbs = [['title' => {intl l="Newsletter"}, 'url'=>{url path="/newsletter"}]]} +{/block} + +{block name="main-content"} +
+
+

{intl l="Newsletter"}

+ + {form name="thelia.newsletter"} +
+ {form_hidden_fields form=$form} +
+
+ 1. {intl l="Personal Informations"} +
+
+ {form_field form=$form field="email"} +
+ +
+ + {if $error } + {$message} + {assign var="error_focus" value="true"} + {elseif $value != "" && !$error} + + {/if} +
+
+ {/form_field} +
+
+ +
+
+
+
+
+ {/form} +
+
+{/block} \ No newline at end of file From 47212490d215366e2e8a3f04b3f09f9f4ecdfa8f Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 22 Oct 2013 10:58:16 +0200 Subject: [PATCH 13/22] verify if an email already exists in newsletter table --- core/lib/Thelia/Form/NewsletterForm.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Form/NewsletterForm.php b/core/lib/Thelia/Form/NewsletterForm.php index 3e70dde67..7b32ed8df 100644 --- a/core/lib/Thelia/Form/NewsletterForm.php +++ b/core/lib/Thelia/Form/NewsletterForm.php @@ -23,9 +23,12 @@ namespace Thelia\Form; +use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Core\Translation\Translator; +use Thelia\Model\NewsletterQuery; /** @@ -62,7 +65,13 @@ class NewsletterForm extends BaseForm ->add('email', 'email', array( 'constraints' => array( new NotBlank(), - new Email() + new Email(), + new Callback(array( + "methods" => array( + array($this, + "verifyExistingEmail") + ) + )) ), 'label' => Translator::getInstance()->trans('email'), 'label_attr' => array( @@ -71,6 +80,14 @@ class NewsletterForm extends BaseForm )); } + public function verifyExistingEmail($value, ExecutionContextInterface $context) + { + $customer = NewsletterQuery::create()->findOneByEmail($value); + if ($customer) { + $context->addViolation("This email already exists"); + } + } + /** * @return string the name of you form. This name must be unique */ From b00f70fa24b4d42ceb9c7c9b5f8655421ba8a6c7 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 22 Oct 2013 11:09:24 +0200 Subject: [PATCH 14/22] permission management --- .../Admin/AbstractCrudController.php | 37 ++- .../Controller/Admin/AddressController.php | 10 +- .../Controller/Admin/AreaController.php | 14 +- .../Admin/AttributeAvController.php | 2 +- .../Controller/Admin/AttributeController.php | 10 +- .../Controller/Admin/BaseAdminController.php | 10 +- .../Controller/Admin/CategoryController.php | 16 +- .../Controller/Admin/ConfigController.php | 10 +- .../Controller/Admin/ContentController.php | 12 +- .../Controller/Admin/CountryController.php | 10 +- .../Controller/Admin/CouponController.php | 15 +- .../Controller/Admin/CurrencyController.php | 11 +- .../Controller/Admin/CustomerController.php | 11 +- .../Controller/Admin/FeatureAvController.php | 2 +- .../Controller/Admin/FeatureController.php | 10 +- .../Controller/Admin/FileController.php | 27 +-- .../Controller/Admin/FolderController.php | 2 +- .../Controller/Admin/LanguageController.php | 5 +- .../Admin/MailingSystemController.php | 5 +- .../Controller/Admin/MessageController.php | 2 +- .../Controller/Admin/ModuleController.php | 9 +- .../Controller/Admin/OrderController.php | 13 +- .../Controller/Admin/ProductController.php | 28 ++- .../Controller/Admin/ProfileController.php | 7 +- .../Admin/ShippingZoneController.php | 11 +- .../Thelia/Controller/Admin/TaxController.php | 2 +- .../Controller/Admin/TaxRuleController.php | 14 +- .../Controller/Admin/TemplateController.php | 16 +- .../Thelia/Core/Security/AccessManager.php | 84 +++++++ .../Core/Security/Resource/AdminResources.php | 121 +++------- .../Thelia/Core/Security/SecurityContext.php | 28 ++- core/lib/Thelia/Core/Template/Loop/Auth.php | 50 ++-- .../Template/Smarty/AbstractSmartyPlugin.php | 4 + .../Smarty/Plugins/AdminUtilities.php | 5 +- .../Core/Template/Smarty/Plugins/Security.php | 11 +- core/lib/Thelia/Model/Admin.php | 5 +- .../lib/Thelia/Model/Base/ProfileResource.php | 134 +++-------- .../Model/Base/ProfileResourceQuery.php | 79 ++----- .../Model/Map/ProfileResourceTableMap.php | 46 ++-- .../Thelia/Type/AlphaNumStringListType.php | 2 +- core/lib/Thelia/Type/AlphaNumStringType.php | 2 +- install/insert.sql | 115 ++------- install/thelia.sql | 3 +- local/config/schema.xml | 3 +- templates/admin/default/admin-layout.tpl | 2 +- templates/admin/default/admin-profiles.html | 219 ------------------ .../default/ajax/product-related-tab.html | 6 +- .../default/ajax/template-attribute-list.html | 3 +- .../default/ajax/template-feature-list.html | 3 +- templates/admin/default/attribute-edit.html | 6 +- templates/admin/default/attributes.html | 6 +- templates/admin/default/categories.html | 9 +- templates/admin/default/category-edit.html | 3 +- templates/admin/default/configuration.html | 3 +- templates/admin/default/content-edit.html | 3 +- templates/admin/default/countries.html | 3 +- templates/admin/default/country-edit.html | 3 +- templates/admin/default/coupon-create.html | 5 +- templates/admin/default/coupon-list.html | 5 +- templates/admin/default/coupon-read.html | 5 +- templates/admin/default/coupon-update.html | 5 +- templates/admin/default/currencies.html | 16 +- templates/admin/default/currency-edit.html | 3 +- templates/admin/default/customer-edit.html | 3 +- templates/admin/default/customers.html | 3 +- templates/admin/default/document-edit.html | 3 +- templates/admin/default/feature-edit.html | 16 +- templates/admin/default/features.html | 16 +- templates/admin/default/folder-edit.html | 3 +- templates/admin/default/folders.html | 29 +-- templates/admin/default/image-edit.html | 3 +- templates/admin/default/languages.html | 3 +- templates/admin/default/mailing-system.html | 3 +- templates/admin/default/message-edit.html | 3 +- templates/admin/default/messages.html | 3 +- templates/admin/default/modules.html | 3 +- templates/admin/default/order-edit.html | 3 +- templates/admin/default/orders.html | 3 +- templates/admin/default/product-edit.html | 3 +- templates/admin/default/profile-edit.html | 3 +- templates/admin/default/profiles.html | 3 +- .../default/shipping-configuration-edit.html | 3 +- .../admin/default/shipping-configuration.html | 3 +- .../admin/default/shipping-zones-edit.html | 3 +- templates/admin/default/shipping-zones.html | 3 +- templates/admin/default/tax-edit.html | 3 +- templates/admin/default/tax-rule-edit.html | 3 +- templates/admin/default/taxes-rules.html | 3 +- templates/admin/default/template-edit.html | 3 +- templates/admin/default/templates.html | 3 +- templates/admin/default/variable-edit.html | 3 +- templates/admin/default/variables.html | 3 +- templates/default/account.html | 2 +- templates/default/address-update.html | 2 +- templates/default/address.html | 2 +- templates/default/order-delivery.html | 2 +- templates/default/order-invoice.html | 2 +- 97 files changed, 568 insertions(+), 902 deletions(-) create mode 100644 core/lib/Thelia/Core/Security/AccessManager.php delete mode 100644 templates/admin/default/admin-profiles.html diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index 170c35c4f..114bd75c1 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -23,6 +23,7 @@ namespace Thelia\Controller\Admin; +use Thelia\Core\Security\AccessManager; use Thelia\Form\Exception\FormValidationException; use Thelia\Core\Event\UpdatePositionEvent; @@ -40,10 +41,7 @@ abstract class AbstractCrudController extends BaseAdminController protected $orderRequestParameterName; // Permissions - protected $viewPermissionIdentifier; - protected $createPermissionIdentifier; - protected $updatePermissionIdentifier; - protected $deletePermissionIdentifier; + protected $resourceCode; // Events protected $createEventIdentifier; @@ -58,10 +56,7 @@ abstract class AbstractCrudController extends BaseAdminController * @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual * @param string $orderRequestParameterName Name of the request parameter that set the list order (null if list is not sortable) * - * @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view" - * @param string $createPermissionIdentifier the 'create' permission identifier. Example: "admin.configuration.message.create" - * @param string $updatePermissionIdentifier the 'update' permission identifier. Example: "admin.configuration.message.update" - * @param string $deletePermissionIdentifier the 'delete' permission identifier. Example: "admin.configuration.message.delete" + * @param string $resourceCode the 'resource' code. Example: "admin.configuration.message" * * @param string $createEventIdentifier the dispatched create TheliaEvent identifier. Example: TheliaEvents::MESSAGE_CREATE * @param string $updateEventIdentifier the dispatched update TheliaEvent identifier. Example: TheliaEvents::MESSAGE_UPDATE @@ -76,10 +71,7 @@ abstract class AbstractCrudController extends BaseAdminController $defaultListOrder = null, $orderRequestParameterName = null, - $viewPermissionIdentifier, - $createPermissionIdentifier, - $updatePermissionIdentifier, - $deletePermissionIdentifier, + $resourceCode, $createEventIdentifier, $updateEventIdentifier, @@ -92,10 +84,7 @@ abstract class AbstractCrudController extends BaseAdminController $this->defaultListOrder = $defaultListOrder; $this->orderRequestParameterName = $orderRequestParameterName; - $this->viewPermissionIdentifier = $viewPermissionIdentifier; - $this->createPermissionIdentifier = $createPermissionIdentifier; - $this->updatePermissionIdentifier = $updatePermissionIdentifier; - $this->deletePermissionIdentifier = $deletePermissionIdentifier; + $this->resourceCode = $resourceCode; $this->createEventIdentifier = $createEventIdentifier; $this->updateEventIdentifier = $updateEventIdentifier; @@ -278,7 +267,7 @@ abstract class AbstractCrudController extends BaseAdminController */ public function defaultAction() { - if (null !== $response = $this->checkAuth($this->viewPermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::VIEW)) return $response; return $this->renderList(); } @@ -290,7 +279,7 @@ abstract class AbstractCrudController extends BaseAdminController public function createAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->createPermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::CREATE)) return $response; $error_msg = false; @@ -351,7 +340,7 @@ abstract class AbstractCrudController extends BaseAdminController public function updateAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; // Load the object $object = $this->getExistingObject(); @@ -377,7 +366,7 @@ abstract class AbstractCrudController extends BaseAdminController public function processUpdateAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $error_msg = false; @@ -442,7 +431,7 @@ abstract class AbstractCrudController extends BaseAdminController public function updatePositionAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; try { $mode = $this->getRequest()->get('mode', null); @@ -476,7 +465,7 @@ abstract class AbstractCrudController extends BaseAdminController protected function genericUpdatePositionAction($object, $eventName, $doFinalRedirect = true) { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; if ($object != null) { @@ -510,7 +499,7 @@ abstract class AbstractCrudController extends BaseAdminController public function setToggleVisibilityAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $changeEvent = $this->createToggleVisibilityEvent($this->getRequest()); @@ -532,7 +521,7 @@ abstract class AbstractCrudController extends BaseAdminController public function deleteAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->deletePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::DELETE)) return $response; // Get the currency id, and dispatch the delet request $deleteEvent = $this->getDeleteEvent(); diff --git a/core/lib/Thelia/Controller/Admin/AddressController.php b/core/lib/Thelia/Controller/Admin/AddressController.php index 897b8421d..f934b3279 100644 --- a/core/lib/Thelia/Controller/Admin/AddressController.php +++ b/core/lib/Thelia/Controller/Admin/AddressController.php @@ -24,8 +24,9 @@ namespace Thelia\Controller\Admin; use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent; use Thelia\Core\Event\Address\AddressEvent; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Security\AccessManager; use Thelia\Form\AddressCreateForm; use Thelia\Form\AddressUpdateForm; use Thelia\Model\AddressQuery; @@ -45,10 +46,7 @@ class AddressController extends AbstractCrudController null, null, - AdminResources::ADDRESS_VIEW, - AdminResources::ADDRESS_CREATE, - AdminResources::ADDRESS_UPDATE, - AdminResources::ADDRESS_DELETE, + AdminResources::ADDRESS, TheliaEvents::ADDRESS_CREATE, TheliaEvents::ADDRESS_UPDATE, @@ -61,7 +59,7 @@ class AddressController extends AbstractCrudController public function useAddressAction() { - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $address_id = $this->getRequest()->request->get('address_id'); diff --git a/core/lib/Thelia/Controller/Admin/AreaController.php b/core/lib/Thelia/Controller/Admin/AreaController.php index bceddad96..4126ef741 100644 --- a/core/lib/Thelia/Controller/Admin/AreaController.php +++ b/core/lib/Thelia/Controller/Admin/AreaController.php @@ -23,7 +23,7 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Area\AreaAddCountryEvent; use Thelia\Core\Event\Area\AreaCreateEvent; use Thelia\Core\Event\Area\AreaDeleteEvent; @@ -31,6 +31,7 @@ use Thelia\Core\Event\Area\AreaRemoveCountryEvent; use Thelia\Core\Event\Area\AreaUpdateEvent; use Thelia\Core\Event\Area\AreaUpdatePostageEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Security\AccessManager; use Thelia\Form\Area\AreaCountryForm; use Thelia\Form\Area\AreaCreateForm; use Thelia\Form\Area\AreaModificationForm; @@ -53,10 +54,7 @@ class AreaController extends AbstractCrudController null, null, - AdminResources::AREA_VIEW, - AdminResources::AREA_CREATE, - AdminResources::AREA_UPDATE, - AdminResources::AREA_DELETE, + AdminResources::AREA, TheliaEvents::AREA_CREATE, TheliaEvents::AREA_UPDATE, @@ -233,7 +231,7 @@ class AreaController extends AbstractCrudController public function addCountry() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $areaCountryForm = new AreaCountryForm($this->getRequest()); $error_msg = null; @@ -275,7 +273,7 @@ class AreaController extends AbstractCrudController public function removeCountry() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $request = $this->getRequest(); $removeCountryEvent = new AreaRemoveCountryEvent($request->request->get('areai_id', 0), $request->request->get('country_id', 0)); @@ -286,7 +284,7 @@ class AreaController extends AbstractCrudController public function updatePostageAction() { - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $areaUpdateForm = new AreaPostageForm($this->getRequest()); $error_msg = null; diff --git a/core/lib/Thelia/Controller/Admin/AttributeAvController.php b/core/lib/Thelia/Controller/Admin/AttributeAvController.php index 1e060de2c..92d50955b 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeAvController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeAvController.php @@ -23,7 +23,7 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Attribute\AttributeAvDeleteEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\Attribute\AttributeAvUpdateEvent; diff --git a/core/lib/Thelia/Controller/Admin/AttributeController.php b/core/lib/Thelia/Controller/Admin/AttributeController.php index e2e3f1a7e..00162ffcf 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeController.php @@ -23,11 +23,12 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Attribute\AttributeDeleteEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\Attribute\AttributeUpdateEvent; use Thelia\Core\Event\Attribute\AttributeCreateEvent; +use Thelia\Core\Security\AccessManager; use Thelia\Model\AttributeQuery; use Thelia\Form\AttributeModificationForm; use Thelia\Form\AttributeCreationForm; @@ -51,10 +52,7 @@ class AttributeController extends AbstractCrudController 'manual', 'order', - AdminResources::ATTRIBUTE_VIEW, - AdminResources::ATTRIBUTE_CREATE, - AdminResources::ATTRIBUTE_UPDATE, - AdminResources::ATTRIBUTE_DELETE, + AdminResources::ATTRIBUTE, TheliaEvents::ATTRIBUTE_CREATE, TheliaEvents::ATTRIBUTE_UPDATE, @@ -254,7 +252,7 @@ class AttributeController extends AbstractCrudController protected function addRemoveFromAllTemplates($eventType) { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; try { if (null !== $object = $this->getExistingObject()) { diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 829e51c37..186727ed5 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -111,16 +111,18 @@ class BaseAdminController extends BaseController /** * Check current admin user authorisations. An ADMIN role is assumed. * - * @param mixed $permissions a single permission or an array of permissions. + * @param mixed $resources a single resource or an array of resources. + * @param mixed $accesses a single access or an array of accesses. * * @return mixed null if authorization is granted, or a Response object which contains the error page otherwise * */ - protected function checkAuth($permissions) + protected function checkAuth($resources, $accesses) { - $permArr = is_array($permissions) ? $permissions : array($permissions); + $resources = is_array($resources) ? $resources : array($resources); + $accesses = is_array($accesses) ? $accesses : array($accesses); - if ($this->getSecurityContext()->isGranted(array("ADMIN"), $permArr)) { + if ($this->getSecurityContext()->isGranted(array("ADMIN"), $resources, $accesses)) { // Okay ! return null; } diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index e08ffdff9..86e4bb00c 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -24,11 +24,12 @@ namespace Thelia\Controller\Admin; use Symfony\Component\HttpFoundation\Response; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Category\CategoryDeleteEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\Category\CategoryUpdateEvent; use Thelia\Core\Event\Category\CategoryCreateEvent; +use Thelia\Core\Security\AccessManager; use Thelia\Model\CategoryQuery; use Thelia\Form\CategoryModificationForm; use Thelia\Form\CategoryCreationForm; @@ -55,10 +56,7 @@ class CategoryController extends AbstractCrudController 'manual', 'category_order', - AdminResources::CATEGORY_VIEW, - AdminResources::CATEGORY_CREATE, - AdminResources::CATEGORY_UPDATE, - AdminResources::CATEGORY_DELETE, + AdminResources::CATEGORY, TheliaEvents::CATEGORY_CREATE, TheliaEvents::CATEGORY_UPDATE, @@ -217,7 +215,7 @@ class CategoryController extends AbstractCrudController public function setToggleVisibilityAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $event = new CategoryToggleVisibilityEvent($this->getExistingObject()); @@ -297,7 +295,7 @@ class CategoryController extends AbstractCrudController public function addRelatedContentAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $content_id = intval($this->getRequest()->get('content_id')); @@ -327,7 +325,7 @@ class CategoryController extends AbstractCrudController public function addRelatedPictureAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) { + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) { return $response; } @@ -355,7 +353,7 @@ class CategoryController extends AbstractCrudController public function deleteRelatedContentAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $content_id = intval($this->getRequest()->get('content_id')); diff --git a/core/lib/Thelia/Controller/Admin/ConfigController.php b/core/lib/Thelia/Controller/Admin/ConfigController.php index 1a99d8470..f8eafe820 100644 --- a/core/lib/Thelia/Controller/Admin/ConfigController.php +++ b/core/lib/Thelia/Controller/Admin/ConfigController.php @@ -23,11 +23,12 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Config\ConfigDeleteEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\Config\ConfigUpdateEvent; use Thelia\Core\Event\Config\ConfigCreateEvent; +use Thelia\Core\Security\AccessManager; use Thelia\Model\ConfigQuery; use Thelia\Form\ConfigModificationForm; use Thelia\Form\ConfigCreationForm; @@ -46,10 +47,7 @@ class ConfigController extends AbstractCrudController 'name', 'order', - AdminResources::CONFIG_VIEW, - AdminResources::CONFIG_CREATE, - AdminResources::CONFIG_UPDATE, - AdminResources::CONFIG_DELETE, + AdminResources::CONFIG, TheliaEvents::CONFIG_CREATE, TheliaEvents::CONFIG_UPDATE, @@ -188,7 +186,7 @@ class ConfigController extends AbstractCrudController public function changeValuesAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $variables = $this->getRequest()->get('variable', array()); diff --git a/core/lib/Thelia/Controller/Admin/ContentController.php b/core/lib/Thelia/Controller/Admin/ContentController.php index 721c193f0..adf3cc697 100644 --- a/core/lib/Thelia/Controller/Admin/ContentController.php +++ b/core/lib/Thelia/Controller/Admin/ContentController.php @@ -22,7 +22,7 @@ /*************************************************************************************/ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Content\ContentAddFolderEvent; use Thelia\Core\Event\Content\ContentCreateEvent; use Thelia\Core\Event\Content\ContentDeleteEvent; @@ -31,6 +31,7 @@ use Thelia\Core\Event\Content\ContentToggleVisibilityEvent; use Thelia\Core\Event\Content\ContentUpdateEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Security\AccessManager; use Thelia\Form\ContentCreationForm; use Thelia\Form\ContentModificationForm; use Thelia\Model\ContentQuery; @@ -50,10 +51,7 @@ class ContentController extends AbstractCrudController 'manual', 'content_order', - AdminResources::CONTENT_VIEW, - AdminResources::CONTENT_CREATE, - AdminResources::CONTENT_UPDATE, - AdminResources::CONTENT_DELETE, + AdminResources::CONTENT, TheliaEvents::CONTENT_CREATE, TheliaEvents::CONTENT_UPDATE, @@ -71,7 +69,7 @@ class ContentController extends AbstractCrudController public function addAdditionalFolderAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $folder_id = intval($this->getRequest()->request->get('additional_folder_id')); @@ -99,7 +97,7 @@ class ContentController extends AbstractCrudController public function removeAdditionalFolderAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $folder_id = intval($this->getRequest()->request->get('additional_folder_id')); diff --git a/core/lib/Thelia/Controller/Admin/CountryController.php b/core/lib/Thelia/Controller/Admin/CountryController.php index 356c3d846..e5bcce67b 100644 --- a/core/lib/Thelia/Controller/Admin/CountryController.php +++ b/core/lib/Thelia/Controller/Admin/CountryController.php @@ -22,12 +22,13 @@ /*************************************************************************************/ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Country\CountryCreateEvent; use Thelia\Core\Event\Country\CountryDeleteEvent; use Thelia\Core\Event\Country\CountryToggleDefaultEvent; use Thelia\Core\Event\Country\CountryUpdateEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Security\AccessManager; use Thelia\Form\CountryCreationForm; use Thelia\Form\CountryModificationForm; use Thelia\Model\CountryQuery; @@ -47,10 +48,7 @@ class CountryController extends AbstractCrudController 'manual', 'country_order', - AdminResources::COUNTRY_VIEW, - AdminResources::COUNTRY_CREATE, - AdminResources::COUNTRY_UPDATE, - AdminResources::COUNTRY_DELETE, + AdminResources::COUNTRY, TheliaEvents::COUNTRY_CREATE, TheliaEvents::COUNTRY_UPDATE, @@ -237,7 +235,7 @@ class CountryController extends AbstractCrudController public function toggleDefaultAction() { - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $content = null; if (null !== $country_id = $this->getRequest()->get('country_id')) { $toogleDefaultEvent = new CountryToggleDefaultEvent($country_id); diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index 03a7b7477..3d5b2d72f 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -27,11 +27,12 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Router; use Thelia\Condition\ConditionFactory; use Thelia\Condition\ConditionManagerInterface; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Condition\ConditionCreateOrUpdateEvent; use Thelia\Core\Event\Coupon\CouponConsumeEvent; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Security\AccessManager; use Thelia\Coupon\CouponManager; use Thelia\Coupon\ConditionCollection; use Thelia\Coupon\Type\CouponInterface; @@ -63,7 +64,7 @@ class CouponController extends BaseAdminController */ public function browseAction() { - $this->checkAuth('ADMIN', AdminResources::COUPON_VIEW); + $this->checkAuth(AdminResources::COUPON, AccessManager::VIEW); $args['urlReadCoupon'] = $this->getRoute( 'admin.coupon.read', @@ -95,7 +96,7 @@ class CouponController extends BaseAdminController */ public function readAction($couponId) { - $this->checkAuth('ADMIN', AdminResources::COUPON_VIEW); + $this->checkAuth(AdminResources::COUPON, AccessManager::VIEW); // Database request repeated in the loop but cached $search = CouponQuery::create(); @@ -123,7 +124,7 @@ class CouponController extends BaseAdminController public function createAction() { // Check current user authorization - $response = $this->checkAuth(AdminResources::COUPON_CREATE); + $response = $this->checkAuth(AdminResources::COUPON, AccessManager::CREATE); if ($response !== null) { return $response; } @@ -171,7 +172,7 @@ class CouponController extends BaseAdminController public function updateAction($couponId) { // Check current user authorization - $response = $this->checkAuth(AdminResources::COUPON_UPDATE); + $response = $this->checkAuth(AdminResources::COUPON, AccessManager::UPDATE); if ($response !== null) { return $response; } @@ -278,7 +279,7 @@ var_dump($coupon->getIsRemovingPostage());; */ public function getConditionInputAction($conditionId) { - $this->checkAuth('ADMIN', AdminResources::COUPON_VIEW); + $this->checkAuth(AdminResources::COUPON, AccessManager::VIEW); $this->checkXmlHttpRequest(); @@ -308,7 +309,7 @@ var_dump($coupon->getIsRemovingPostage());; */ public function updateConditionsAction($couponId) { - $this->checkAuth('ADMIN', AdminResources::COUPON_VIEW); + $this->checkAuth(AdminResources::COUPON, AccessManager::VIEW); $this->checkXmlHttpRequest(); diff --git a/core/lib/Thelia/Controller/Admin/CurrencyController.php b/core/lib/Thelia/Controller/Admin/CurrencyController.php index 2510b845c..a50a5cdd6 100644 --- a/core/lib/Thelia/Controller/Admin/CurrencyController.php +++ b/core/lib/Thelia/Controller/Admin/CurrencyController.php @@ -23,7 +23,7 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Currency\CurrencyDeleteEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\Currency\CurrencyUpdateEvent; @@ -47,10 +47,7 @@ class CurrencyController extends AbstractCrudController 'manual', 'order', - AdminResources::CURRENCY_VIEW, - AdminResources::CURRENCY_CREATE, - AdminResources::CURRENCY_UPDATE, - AdminResources::CURRENCY_DELETE, + AdminResources::CURRENCY, TheliaEvents::CURRENCY_CREATE, TheliaEvents::CURRENCY_UPDATE, @@ -187,7 +184,7 @@ class CurrencyController extends AbstractCrudController public function updateRatesAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; try { $this->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES); @@ -205,7 +202,7 @@ class CurrencyController extends AbstractCrudController public function setDefaultAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $changeEvent = new CurrencyUpdateEvent($this->getRequest()->get('currency_id', 0)); diff --git a/core/lib/Thelia/Controller/Admin/CustomerController.php b/core/lib/Thelia/Controller/Admin/CustomerController.php index 2ae53dc91..fd203a066 100644 --- a/core/lib/Thelia/Controller/Admin/CustomerController.php +++ b/core/lib/Thelia/Controller/Admin/CustomerController.php @@ -24,11 +24,12 @@ namespace Thelia\Controller\Admin; use Propel\Runtime\Exception\PropelException; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Customer\CustomerAddressEvent; use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent; use Thelia\Core\Event\Customer\CustomerEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Security\AccessManager; use Thelia\Form\CustomerModification; use Thelia\Form\Exception\FormValidationException; use Thelia\Model\CustomerQuery; @@ -43,13 +44,13 @@ class CustomerController extends BaseAdminController { public function indexAction() { - if (null !== $response = $this->checkAuth(AdminResources::CUSTOMER_VIEW)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::CUSTOMER, AccessManager::VIEW)) return $response; return $this->render("customers", array("display_customer" => 20)); } public function viewAction($customer_id) { - if (null !== $response = $this->checkAuth(AdminResources::CUSTOMER_VIEW)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::CUSTOMER, AccessManager::VIEW)) return $response; return $this->render("customer-edit", array( "customer_id" => $customer_id )); @@ -63,7 +64,7 @@ class CustomerController extends BaseAdminController */ public function updateAction($customer_id) { - if (null !== $response = $this->checkAuth(AdminResources::CUSTOMER_UPDATE)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::CUSTOMER, AccessManager::UPDATE)) return $response; $message = false; @@ -119,7 +120,7 @@ class CustomerController extends BaseAdminController public function deleteAction() { - if (null !== $response = $this->checkAuth(AdminResources::CUSTOMER_DELETE)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::CUSTOMER, AccessManager::DELETE)) return $response; $message = null; diff --git a/core/lib/Thelia/Controller/Admin/FeatureAvController.php b/core/lib/Thelia/Controller/Admin/FeatureAvController.php index e65fceac0..f3b80ef51 100644 --- a/core/lib/Thelia/Controller/Admin/FeatureAvController.php +++ b/core/lib/Thelia/Controller/Admin/FeatureAvController.php @@ -23,7 +23,7 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Feature\FeatureAvDeleteEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\Feature\FeatureAvUpdateEvent; diff --git a/core/lib/Thelia/Controller/Admin/FeatureController.php b/core/lib/Thelia/Controller/Admin/FeatureController.php index c681a7b61..7696b9c6e 100644 --- a/core/lib/Thelia/Controller/Admin/FeatureController.php +++ b/core/lib/Thelia/Controller/Admin/FeatureController.php @@ -23,11 +23,12 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Feature\FeatureDeleteEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\Feature\FeatureUpdateEvent; use Thelia\Core\Event\Feature\FeatureCreateEvent; +use Thelia\Core\Security\AccessManager; use Thelia\Model\FeatureQuery; use Thelia\Form\FeatureModificationForm; use Thelia\Form\FeatureCreationForm; @@ -51,10 +52,7 @@ class FeatureController extends AbstractCrudController 'manual', 'order', - AdminResources::FEATURE_VIEW, - AdminResources::FEATURE_CREATE, - AdminResources::FEATURE_UPDATE, - AdminResources::FEATURE_DELETE, + AdminResources::FEATURE, TheliaEvents::FEATURE_CREATE, TheliaEvents::FEATURE_UPDATE, @@ -254,7 +252,7 @@ class FeatureController extends AbstractCrudController protected function addRemoveFromAllTemplates($eventType) { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; try { if (null !== $object = $this->getExistingObject()) { diff --git a/core/lib/Thelia/Controller/Admin/FileController.php b/core/lib/Thelia/Controller/Admin/FileController.php index 0c6f51630..3c2ad0ba9 100755 --- a/core/lib/Thelia/Controller/Admin/FileController.php +++ b/core/lib/Thelia/Controller/Admin/FileController.php @@ -26,12 +26,13 @@ namespace Thelia\Controller\Admin; use Propel\Runtime\Exception\PropelException; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\Response; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent; use Thelia\Core\Event\Document\DocumentDeleteEvent; use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent; use Thelia\Core\Event\Image\ImageDeleteEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Security\AccessManager; use Thelia\Form\Exception\FormValidationException; use Thelia\Log\Tlog; use Thelia\Model\CategoryDocument; @@ -70,7 +71,7 @@ class FileController extends BaseAdminController */ public function saveImageAjaxAction($parentId, $parentType) { - $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update')); + $this->checkAuth(AdminResources::retrieve($parentType), AccessManager::UPDATE); $this->checkXmlHttpRequest(); if ($this->isParentTypeValid($parentType)) { @@ -146,7 +147,7 @@ class FileController extends BaseAdminController */ public function saveDocumentAjaxAction($parentId, $parentType) { - $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update')); + $this->checkAuth(AdminResources::retrieve($parentType), AccessManager::UPDATE); $this->checkXmlHttpRequest(); if ($this->isParentTypeValid($parentType)) { @@ -210,7 +211,7 @@ class FileController extends BaseAdminController */ public function getImageListAjaxAction($parentId, $parentType) { - $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update')); + $this->checkAuth(AdminResources::retrieve($parentType), AccessManager::UPDATE); $this->checkXmlHttpRequest(); $args = array('imageType' => $parentType, 'parentId' => $parentId); @@ -227,7 +228,7 @@ class FileController extends BaseAdminController */ public function getDocumentListAjaxAction($parentId, $parentType) { - $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update')); + $this->checkAuth(AdminResources::retrieve($parentType), AccessManager::UPDATE); $this->checkXmlHttpRequest(); $args = array('documentType' => $parentType, 'parentId' => $parentId); @@ -244,7 +245,7 @@ class FileController extends BaseAdminController */ public function getImageFormAjaxAction($parentId, $parentType) { - $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update')); + $this->checkAuth(AdminResources::retrieve($parentType), AccessManager::UPDATE); $this->checkXmlHttpRequest(); $args = array('imageType' => $parentType, 'parentId' => $parentId); @@ -261,7 +262,7 @@ class FileController extends BaseAdminController */ public function getDocumentFormAjaxAction($parentId, $parentType) { - $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update')); + $this->checkAuth(AdminResources::retrieve($parentType), AccessManager::UPDATE); $this->checkXmlHttpRequest(); $args = array('documentType' => $parentType, 'parentId' => $parentId); @@ -278,7 +279,7 @@ class FileController extends BaseAdminController */ public function viewImageAction($imageId, $parentType) { - if (null !== $response = $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'))) { + if (null !== $response = $this->checkAuth(AdminResources::retrieve($parentType), AccessManager::UPDATE)) { return $response; } try { @@ -307,7 +308,7 @@ class FileController extends BaseAdminController */ public function viewDocumentAction($documentId, $parentType) { - if (null !== $response = $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'))) { + if (null !== $response = $this->checkAuth(AdminResources::retrieve($parentType), AccessManager::UPDATE)) { return $response; } try { @@ -336,7 +337,7 @@ class FileController extends BaseAdminController */ public function updateImageAction($imageId, $parentType) { - if (null !== $response = $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'))) { + if (null !== $response = $this->checkAuth(AdminResources::retrieve($parentType), AccessManager::UPDATE)) { return $response; } @@ -413,7 +414,7 @@ class FileController extends BaseAdminController */ public function updateDocumentAction($documentId, $parentType) { - if (null !== $response = $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'))) { + if (null !== $response = $this->checkAuth(AdminResources::retrieve($parentType), AccessManager::UPDATE)) { return $response; } @@ -490,7 +491,7 @@ class FileController extends BaseAdminController */ public function deleteImageAction($imageId, $parentType) { - $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update')); + $this->checkAuth(AdminResources::retrieve($parentType), AccessManager::UPDATE); $this->checkXmlHttpRequest(); $fileManager = new FileManager($this->container); @@ -533,7 +534,7 @@ class FileController extends BaseAdminController */ public function deleteDocumentAction($documentId, $parentType) { - $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update')); + $this->checkAuth(AdminResources::retrieve($parentType), AccessManager::UPDATE); $this->checkXmlHttpRequest(); $fileManager = new FileManager($this->container); diff --git a/core/lib/Thelia/Controller/Admin/FolderController.php b/core/lib/Thelia/Controller/Admin/FolderController.php index a5dd5c8eb..8b709dbbe 100644 --- a/core/lib/Thelia/Controller/Admin/FolderController.php +++ b/core/lib/Thelia/Controller/Admin/FolderController.php @@ -22,7 +22,7 @@ /*************************************************************************************/ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Folder\FolderCreateEvent; use Thelia\Core\Event\Folder\FolderDeleteEvent; use Thelia\Core\Event\Folder\FolderToggleVisibilityEvent; diff --git a/core/lib/Thelia/Controller/Admin/LanguageController.php b/core/lib/Thelia/Controller/Admin/LanguageController.php index e6ea4890b..834a4cbed 100644 --- a/core/lib/Thelia/Controller/Admin/LanguageController.php +++ b/core/lib/Thelia/Controller/Admin/LanguageController.php @@ -23,7 +23,8 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; +use Thelia\Core\Security\AccessManager; /** * Class LanguageController @@ -34,7 +35,7 @@ class LanguageController extends BaseAdminController { public function defaultAction() { - if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE_VIEW)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::VIEW)) return $response; return $this->render("languages"); } diff --git a/core/lib/Thelia/Controller/Admin/MailingSystemController.php b/core/lib/Thelia/Controller/Admin/MailingSystemController.php index 7cc1a6727..dba5d2417 100644 --- a/core/lib/Thelia/Controller/Admin/MailingSystemController.php +++ b/core/lib/Thelia/Controller/Admin/MailingSystemController.php @@ -23,7 +23,8 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; +use Thelia\Core\Security\AccessManager; /** * Class MailingSystemController @@ -34,7 +35,7 @@ class MailingSystemController extends BaseAdminController { public function defaultAction() { - if (null !== $response = $this->checkAuth(AdminResources::MAILING_SYSTEM_VIEW)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::MAILING_SYSTEM, AccessManager::VIEW)) return $response; return $this->render("mailing-system"); } diff --git a/core/lib/Thelia/Controller/Admin/MessageController.php b/core/lib/Thelia/Controller/Admin/MessageController.php index 71da8b9cf..c0bce7918 100644 --- a/core/lib/Thelia/Controller/Admin/MessageController.php +++ b/core/lib/Thelia/Controller/Admin/MessageController.php @@ -23,7 +23,7 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Message\MessageDeleteEvent; use Thelia\Core\Event\TheliaEvents;use Thelia\Core\Event\Message\MessageUpdateEvent; use Thelia\Core\Event\Message\MessageCreateEvent; diff --git a/core/lib/Thelia/Controller/Admin/ModuleController.php b/core/lib/Thelia/Controller/Admin/ModuleController.php index a2079cee7..44a1c2a24 100644 --- a/core/lib/Thelia/Controller/Admin/ModuleController.php +++ b/core/lib/Thelia/Controller/Admin/ModuleController.php @@ -23,11 +23,12 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Module\ModuleDeleteEvent; use Thelia\Core\Event\Module\ModuleToggleActivationEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Security\AccessManager; use Thelia\Module\ModuleManagement; /** @@ -39,7 +40,7 @@ class ModuleController extends BaseAdminController { public function indexAction() { - if (null !== $response = $this->checkAuth(AdminResources::MODULE_VIEW)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::MODULE, AccessManager::VIEW)) return $response; $modulemanagement = new ModuleManagement(); $modulemanagement->updateModules(); @@ -56,7 +57,7 @@ class ModuleController extends BaseAdminController public function toggleActivationAction($module_id) { - if (null !== $response = $this->checkAuth("admin.module.update")) return $response; + if (null !== $response = $this->checkAuth(AdminResources::MODULE, AccessManager::UPDATE)) return $response; $message = null; try { $event = new ModuleToggleActivationEvent($module_id); @@ -88,7 +89,7 @@ class ModuleController extends BaseAdminController public function deleteAction() { - if (null !== $response = $this->checkAuth("admin.module.delete")) return $response; + if (null !== $response = $this->checkAuth(AdminResources::MODULE, AccessManager::DELETE)) return $response; $message = null; try { diff --git a/core/lib/Thelia/Controller/Admin/OrderController.php b/core/lib/Thelia/Controller/Admin/OrderController.php index 1756582cc..429d9837e 100644 --- a/core/lib/Thelia/Controller/Admin/OrderController.php +++ b/core/lib/Thelia/Controller/Admin/OrderController.php @@ -24,11 +24,12 @@ namespace Thelia\Controller\Admin; use Symfony\Component\HttpFoundation\Response; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Order\OrderAddressEvent; use Thelia\Core\Event\Order\OrderEvent; use Thelia\Core\Event\PdfEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Security\AccessManager; use Thelia\Form\OrderUpdateAddress; use Thelia\Model\ConfigQuery; use Thelia\Model\Base\OrderAddressQuery; @@ -45,7 +46,7 @@ class OrderController extends BaseAdminController { public function indexAction() { - if (null !== $response = $this->checkAuth(AdminResources::ORDER_VIEW)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::ORDER, AccessManager::VIEW)) return $response; return $this->render("orders", array("display_order" => 20)); } @@ -58,7 +59,7 @@ class OrderController extends BaseAdminController public function updateStatus($order_id = null) { - if (null !== $response = $this->checkAuth(AdminResources::ORDER_UPDATE)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::ORDER, AccessManager::UPDATE)) return $response; $message = null; @@ -109,7 +110,7 @@ class OrderController extends BaseAdminController public function updateDeliveryRef($order_id) { - if (null !== $response = $this->checkAuth(AdminResources::ORDER_UPDATE)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::ORDER, AccessManager::UPDATE)) return $response; $message = null; @@ -144,7 +145,7 @@ class OrderController extends BaseAdminController public function updateAddress($order_id) { - if (null !== $response = $this->checkAuth(AdminResources::ORDER_UPDATE)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::ORDER, AccessManager::UPDATE)) return $response; $message = null; @@ -210,7 +211,7 @@ class OrderController extends BaseAdminController protected function generatePdf($order_id, $fileName) { - if (null !== $response = $this->checkAuth(AdminResources::ORDER_UPDATE)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::ORDER, AccessManager::UPDATE)) return $response; $html = $this->renderRaw( $fileName, diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index 8c56ba55a..96a29de32 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -23,13 +23,14 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Product\ProductAddCategoryEvent; use Thelia\Core\Event\Product\ProductDeleteCategoryEvent; use Thelia\Core\Event\Product\ProductDeleteEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\Product\ProductUpdateEvent; use Thelia\Core\Event\Product\ProductCreateEvent; +use Thelia\Core\Security\AccessManager; use Thelia\Model\ProductQuery; use Thelia\Form\ProductModificationForm; use Thelia\Form\ProductCreationForm; @@ -62,10 +63,7 @@ class ProductController extends AbstractCrudController 'manual', 'product_order', - AdminResources::PRODUCT_VIEW, - AdminResources::PRODUCT_CREATE, - AdminResources::PRODUCT_UPDATE, - AdminResources::PRODUCT_DELETE, + AdminResources::PRODUCT, TheliaEvents::PRODUCT_CREATE, TheliaEvents::PRODUCT_UPDATE, @@ -281,7 +279,7 @@ class ProductController extends AbstractCrudController public function setToggleVisibilityAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $event = new ProductToggleVisibilityEvent($this->getExistingObject()); @@ -357,7 +355,7 @@ class ProductController extends AbstractCrudController { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $content_id = intval($this->getRequest()->get('content_id')); @@ -383,7 +381,7 @@ class ProductController extends AbstractCrudController { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $content_id = intval($this->getRequest()->get('content_id')); @@ -435,7 +433,7 @@ class ProductController extends AbstractCrudController public function addAccessoryAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $accessory_id = intval($this->getRequest()->get('accessory_id')); @@ -460,7 +458,7 @@ class ProductController extends AbstractCrudController public function deleteAccessoryAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $accessory_id = intval($this->getRequest()->get('accessory_id')); @@ -516,7 +514,7 @@ class ProductController extends AbstractCrudController public function setProductTemplateAction($productId) { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $product = ProductQuery::create()->findPk($productId); @@ -613,7 +611,7 @@ class ProductController extends AbstractCrudController public function addAdditionalCategoryAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $category_id = intval($this->getRequest()->request->get('additional_category_id')); @@ -638,7 +636,7 @@ class ProductController extends AbstractCrudController public function deleteAdditionalCategoryAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $category_id = intval($this->getRequest()->get('additional_category_id')); @@ -735,7 +733,7 @@ class ProductController extends AbstractCrudController public function addCombinationAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $event = new ProductCreateCombinationEvent( $this->getExistingObject(), @@ -760,7 +758,7 @@ class ProductController extends AbstractCrudController public function deleteCombinationAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $event = new ProductDeleteCombinationEvent( $this->getExistingObject(), diff --git a/core/lib/Thelia/Controller/Admin/ProfileController.php b/core/lib/Thelia/Controller/Admin/ProfileController.php index 345093303..b28c418e4 100644 --- a/core/lib/Thelia/Controller/Admin/ProfileController.php +++ b/core/lib/Thelia/Controller/Admin/ProfileController.php @@ -23,7 +23,7 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Profile\ProfileEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Form\ProfileCreationForm; @@ -40,10 +40,7 @@ class ProfileController extends AbstractCrudController 'manual', 'order', - AdminResources::PRODUCT_VIEW, - AdminResources::PRODUCT_CREATE, - AdminResources::PRODUCT_UPDATE, - AdminResources::PRODUCT_DELETE, + AdminResources::PROFILE, TheliaEvents::PROFILE_CREATE, TheliaEvents::PROFILE_UPDATE, diff --git a/core/lib/Thelia/Controller/Admin/ShippingZoneController.php b/core/lib/Thelia/Controller/Admin/ShippingZoneController.php index 5b0cd6dcc..2bd6363cc 100644 --- a/core/lib/Thelia/Controller/Admin/ShippingZoneController.php +++ b/core/lib/Thelia/Controller/Admin/ShippingZoneController.php @@ -22,10 +22,11 @@ /*************************************************************************************/ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\ShippingZone\ShippingZoneAddAreaEvent; use Thelia\Core\Event\ShippingZone\ShippingZoneRemoveAreaEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Security\AccessManager; use Thelia\Form\Exception\FormValidationException; use Thelia\Form\ShippingZone\ShippingZoneAddArea; use Thelia\Form\ShippingZone\ShippingZoneRemoveArea; @@ -41,13 +42,13 @@ class ShippingZoneController extends BaseAdminController public function indexAction() { - if (null !== $response = $this->checkAuth(AdminResources::SHIPPING_ZONE_VIEW)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::SHIPPING_ZONE, AccessManager::VIEW)) return $response; return $this->render("shipping-zones", array("display_shipping_zone" => 20)); } public function updateAction($shipping_zones_id) { - if (null !== $response = $this->checkAuth(AdminResources::SHIPPING_ZONE_VIEW)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::SHIPPING_ZONE, AccessManager::VIEW)) return $response; return $this->render("shipping-zones-edit", array( "shipping_zones_id" => $shipping_zones_id )); @@ -58,7 +59,7 @@ class ShippingZoneController extends BaseAdminController */ public function addArea() { - if (null !== $response = $this->checkAuth(AdminResources::SHIPPING_ZONE_UPDATE)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::SHIPPING_ZONE, AccessManager::UPDATE)) return $response; $shippingAreaForm = new ShippingZoneAddArea($this->getRequest()); $error_msg = null; @@ -93,7 +94,7 @@ class ShippingZoneController extends BaseAdminController public function removeArea() { - if (null !== $response = $this->checkAuth(AdminResources::SHIPPING_ZONE_UPDATE)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::SHIPPING_ZONE, AccessManager::UPDATE)) return $response; $shippingAreaForm = new ShippingZoneRemoveArea($this->getRequest()); $error_msg = null; diff --git a/core/lib/Thelia/Controller/Admin/TaxController.php b/core/lib/Thelia/Controller/Admin/TaxController.php index d0166c9c5..ec30dfdfa 100644 --- a/core/lib/Thelia/Controller/Admin/TaxController.php +++ b/core/lib/Thelia/Controller/Admin/TaxController.php @@ -23,7 +23,7 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Tax\TaxEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Form\TaxCreationForm; diff --git a/core/lib/Thelia/Controller/Admin/TaxRuleController.php b/core/lib/Thelia/Controller/Admin/TaxRuleController.php index 929df576e..db3eca4b4 100644 --- a/core/lib/Thelia/Controller/Admin/TaxRuleController.php +++ b/core/lib/Thelia/Controller/Admin/TaxRuleController.php @@ -23,9 +23,10 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Tax\TaxRuleEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Security\AccessManager; use Thelia\Form\TaxRuleCreationForm; use Thelia\Form\TaxRuleModificationForm; use Thelia\Form\TaxRuleTaxListUpdateForm; @@ -41,10 +42,7 @@ class TaxRuleController extends AbstractCrudController 'manual', 'order', - AdminResources::TAX_VIEW, - AdminResources::TAX_CREATE, - AdminResources::TAX_UPDATE, - AdminResources::TAX_DELETE, + AdminResources::TAX, TheliaEvents::TAX_RULE_CREATE, TheliaEvents::TAX_RULE_UPDATE, @@ -221,7 +219,7 @@ class TaxRuleController extends AbstractCrudController public function updateAction() { - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $object = $this->getExistingObject(); @@ -239,7 +237,7 @@ class TaxRuleController extends AbstractCrudController public function setDefaultAction() { - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $setDefaultEvent = new TaxRuleEvent(); @@ -257,7 +255,7 @@ class TaxRuleController extends AbstractCrudController public function processUpdateTaxesAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response; $error_msg = false; diff --git a/core/lib/Thelia/Controller/Admin/TemplateController.php b/core/lib/Thelia/Controller/Admin/TemplateController.php index ba4a1cccf..fd7df6bb2 100644 --- a/core/lib/Thelia/Controller/Admin/TemplateController.php +++ b/core/lib/Thelia/Controller/Admin/TemplateController.php @@ -23,11 +23,12 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Template\TemplateDeleteEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\Template\TemplateUpdateEvent; use Thelia\Core\Event\Template\TemplateCreateEvent; +use Thelia\Core\Security\AccessManager; use Thelia\Model\TemplateQuery; use Thelia\Form\TemplateModificationForm; use Thelia\Form\TemplateCreationForm; @@ -52,10 +53,7 @@ class TemplateController extends AbstractCrudController null, null, - AdminResources::TEMPLATE_VIEW, - AdminResources::TEMPLATE_CREATE, - AdminResources::TEMPLATE_UPDATE, - AdminResources::TEMPLATE_DELETE, + AdminResources::TEMPLATE, TheliaEvents::TEMPLATE_CREATE, TheliaEvents::TEMPLATE_UPDATE, @@ -213,7 +211,7 @@ class TemplateController extends AbstractCrudController public function addAttributeAction() { // Check current user authorization - if (null !== $response = $this->checkAuth(AdminResources::TEMPLATE_UPDATE)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::TEMPLATE, AccessManager::UPDATE)) return $response; $attribute_id = intval($this->getRequest()->get('attribute_id')); @@ -237,7 +235,7 @@ class TemplateController extends AbstractCrudController public function deleteAttributeAction() { // Check current user authorization - if (null !== $response = $this->checkAuth(AdminResources::TEMPLATE_UPDATE)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::TEMPLATE, AccessManager::UPDATE)) return $response; $event = new TemplateDeleteAttributeEvent( $this->getExistingObject(), @@ -272,7 +270,7 @@ class TemplateController extends AbstractCrudController public function addFeatureAction() { // Check current user authorization - if (null !== $response = $this->checkAuth(AdminResources::TEMPLATE_UPDATE)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::TEMPLATE, AccessManager::UPDATE)) return $response; $feature_id = intval($this->getRequest()->get('feature_id')); @@ -296,7 +294,7 @@ class TemplateController extends AbstractCrudController public function deleteFeatureAction() { // Check current user authorization - if (null !== $response = $this->checkAuth(AdminResources::TEMPLATE_UPDATE)) return $response; + if (null !== $response = $this->checkAuth(AdminResources::TEMPLATE, AccessManager::UPDATE)) return $response; $event = new TemplateDeleteFeatureEvent( $this->getExistingObject(), diff --git a/core/lib/Thelia/Core/Security/AccessManager.php b/core/lib/Thelia/Core/Security/AccessManager.php new file mode 100644 index 000000000..cdf7105a8 --- /dev/null +++ b/core/lib/Thelia/Core/Security/AccessManager.php @@ -0,0 +1,84 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Security\Resource\AdminResources; +use Thelia\Core\Security\User\UserInterface; +use Thelia\Core\HttpFoundation\Request; +use Thelia\Model\ProfileQuery; +use Thelia\Model\ProfileResourceQuery; + +/** + * A simple security manager, in charge of checking user + * + * @author Etienne Roudeix + */ +class AccessManager +{ + const VIEW = 'VIEW'; + const CREATE = 'CREATE'; + const UPDATE = 'UPDATE'; + const DELETE = 'DELETE'; + + protected $accessGranted = array( + self::VIEW => false, + self::CREATE => false, + self::UPDATE => false, + self::DELETE => false, + ); + + protected $accessPows = array( + self::VIEW => 3, + self::CREATE => 2, + self::UPDATE => 1, + self::DELETE => 0, + ); + + protected $accessValue; + + public function __construct($accessValue) + { + $this->accessValue = $accessValue; + + foreach($this->accessPows as $type => $value) { + if($accessValue >= $value) { + $accessValue -= $value; + $this->accessGranted[$type] = true; + } else { + $this->accessGranted[$type] = false; + } + } + } + + public function can($type) + { + if(!array_key_exists($type, $this->accessGranted)) { + return false; + } + + return $this->accessGranted[$type]; + + } +} diff --git a/core/lib/Thelia/Core/Security/Resource/AdminResources.php b/core/lib/Thelia/Core/Security/Resource/AdminResources.php index 8e8a24e3c..8ca3bdd82 100644 --- a/core/lib/Thelia/Core/Security/Resource/AdminResources.php +++ b/core/lib/Thelia/Core/Security/Resource/AdminResources.php @@ -21,7 +21,7 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Security\Resource; use Thelia\Core\Security\Exception\ResourceException; @@ -35,9 +35,9 @@ final class AdminResources { static private $selfReflection = null; - static public function retrieve($name, $action) + static public function retrieve($name) { - $contantName = strtoupper($name . '_' . $action); + $contantName = strtoupper($name); if(null === self::$selfReflection) { self::$selfReflection = new \ReflectionClass(__CLASS__); @@ -52,118 +52,49 @@ final class AdminResources const SUPERADMINISTRATOR = "SUPERADMINISTRATOR"; - const ADDRESS_VIEW = "admin.address.view"; - const ADDRESS_CREATE = "admin.address.create"; - const ADDRESS_UPDATE = "admin.address.update"; - const ADDRESS_DELETE = "admin.address.delete"; + const ADDRESS = "admin.address"; - const ADMIN_VIEW = "admin.configuration.admin.view"; - const ADMIN_CREATE = "admin.configuration.admin.create"; - const ADMIN_UPDATE = "admin.configuration.admin.update"; - const ADMIN_DELETE = "admin.configuration.admin.delete"; + const ADMIN = "admin.configuration.admin"; - const AREA_VIEW = "admin.configuration.area.view"; - const AREA_CREATE = "admin.configuration.area.create"; - const AREA_UPDATE = "admin.configuration.area.update"; - const AREA_DELETE = "admin.configuration.area.delete"; + const AREA = "admin.configuration.area"; - const ATTRIBUTE_VIEW = "admin.configuration.attribute.view"; - const ATTRIBUTE_CREATE = "admin.configuration.attribute.create"; - const ATTRIBUTE_UPDATE = "admin.configuration.attribute.update"; - const ATTRIBUTE_DELETE = "admin.configuration.attribute.delete"; + const ATTRIBUTE = "admin.configuration.attribute"; - const CATEGORY_VIEW = "admin.category.view"; - const CATEGORY_CREATE = "admin.category.create"; - const CATEGORY_UPDATE = "admin.category.update"; - const CATEGORY_DELETE = "admin.category.delete"; + const CATEGORY = "admin.category"; - const CONFIG_VIEW = "admin.configuration.view"; - const CONFIG_CREATE = "admin.configuration.create"; - const CONFIG_UPDATE = "admin.configuration.update"; - const CONFIG_DELETE = "admin.configuration.delete"; + const CONFIG = "admin.configuration"; - const CONTENT_VIEW = "admin.content.view"; - const CONTENT_CREATE = "admin.content.create"; - const CONTENT_UPDATE = "admin.content.update"; - const CONTENT_DELETE = "admin.content.delete"; + const CONTENT = "admin.content"; - const COUNTRY_VIEW = "admin.configuration.country.view"; - const COUNTRY_CREATE = "admin.configuration.country.create"; - const COUNTRY_UPDATE = "admin.configuration.country.update"; - const COUNTRY_DELETE = "admin.configuration.country.delete"; + const COUNTRY = "admin.configuration.country"; - const COUPON_VIEW = "admin.coupon.view"; - const COUPON_CREATE = "admin.coupon.create"; - const COUPON_UPDATE = "admin.coupon.update"; - const COUPON_DELETE = "admin.coupon.delete"; + const COUPON = "admin.coupon"; - const CURRENCY_VIEW = "admin.configuration.currency.view"; - const CURRENCY_CREATE = "admin.configuration.currency.create"; - const CURRENCY_UPDATE = "admin.configuration.currency.update"; - const CURRENCY_DELETE = "admin.configuration.currency.delete"; + const CURRENCY = "admin.configuration.currency"; - const CUSTOMER_VIEW = "admin.customer.view"; - const CUSTOMER_CREATE = "admin.customer.create"; - const CUSTOMER_UPDATE = "admin.customer.update"; - const CUSTOMER_DELETE = "admin.customer.delete"; + const CUSTOMER = "admin.customer"; - const FEATURE_VIEW = "admin.configuration.feature.view"; - const FEATURE_CREATE = "admin.configuration.feature.create"; - const FEATURE_UPDATE = "admin.configuration.feature.update"; - const FEATURE_DELETE = "admin.configuration.feature.delete"; + const FEATURE = "admin.configuration.feature"; - const FOLDER_VIEW = "admin.folder.view"; - const FOLDER_CREATE = "admin.folder.create"; - const FOLDER_UPDATE = "admin.folder.update"; - const FOLDER_DELETE = "admin.folder.delete"; + const FOLDER = "admin.folder"; - const LANGUAGE_VIEW = "admin.configuration.language.view"; - const LANGUAGE_CREATE = "admin.configuration.language.create"; - const LANGUAGE_UPDATE = "admin.configuration.language.update"; - const LANGUAGE_DELETE = "admin.configuration.language.delete"; + const LANGUAGE = "admin.configuration.language"; - const MAILING_SYSTEM_VIEW = "admin.configuration.mailing-system.view"; - const MAILING_SYSTEM_CREATE = "admin.configuration.mailing-system.create"; - const MAILING_SYSTEM_UPDATE = "admin.configuration.mailing-system.update"; - const MAILING_SYSTEM_DELETE = "admin.configuration.mailing-system.delete"; + const MAILING_SYSTEM = "admin.configuration.mailing-system"; - const MESSAGE_VIEW = "admin.configuration.message.view"; - const MESSAGE_CREATE = "admin.configuration.message.create"; - const MESSAGE_UPDATE = "admin.configuration.message.update"; - const MESSAGE_DELETE = "admin.configuration.message.delete"; + const MESSAGE = "admin.configuration.message"; - const MODULE_VIEW = "admin.configuration.module.view"; - const MODULE_CREATE = "admin.configuration.module.create"; - const MODULE_UPDATE = "admin.configuration.module.update"; - const MODULE_DELETE = "admin.configuration.module.delete"; + const MODULE = "admin.configuration.module"; - const ORDER_VIEW = "admin.order.view"; - const ORDER_CREATE = "admin.order.create"; - const ORDER_UPDATE = "admin.order.update"; - const ORDER_DELETE = "admin.order.delete"; + const ORDER = "admin.order"; - const PRODUCT_VIEW = "admin.product.view"; - const PRODUCT_CREATE = "admin.product.create"; - const PRODUCT_UPDATE = "admin.product.update"; - const PRODUCT_DELETE = "admin.product.delete"; + const PRODUCT = "admin.product"; - const PROFILE_VIEW = "admin.configuration.profile.view"; - const PROFILE_CREATE = "admin.configuration.profile.create"; - const PROFILE_UPDATE = "admin.configuration.profile.update"; - const PROFILE_DELETE = "admin.configuration.profile.delete"; + const PROFILE = "admin.configuration.profile"; - const SHIPPING_ZONE_VIEW = "admin.configuration.shipping-zone.view"; - const SHIPPING_ZONE_CREATE = "admin.configuration.shipping-zone.create"; - const SHIPPING_ZONE_UPDATE = "admin.configuration.shipping-zone.update"; - const SHIPPING_ZONE_DELETE = "admin.configuration.shipping-zone.delete"; + const SHIPPING_ZONE = "admin.configuration.shipping-zone"; - const TAX_VIEW = "admin.configuration.tax.view"; - const TAX_CREATE = "admin.configuration.tax.create"; - const TAX_UPDATE = "admin.configuration.tax.update"; - const TAX_DELETE = "admin.configuration.tax.delete"; + const TAX = "admin.configuration.tax"; - const TEMPLATE_VIEW = "admin.configuration.template.view"; - const TEMPLATE_CREATE = "admin.configuration.template.create"; - const TEMPLATE_UPDATE = "admin.configuration.template.update"; - const TEMPLATE_DELETE = "admin.configuration.template.delete"; + const TEMPLATE = "admin.configuration.template"; } diff --git a/core/lib/Thelia/Core/Security/SecurityContext.php b/core/lib/Thelia/Core/Security/SecurityContext.php index 1dc216dd7..087df8810 100755 --- a/core/lib/Thelia/Core/Security/SecurityContext.php +++ b/core/lib/Thelia/Core/Security/SecurityContext.php @@ -24,7 +24,7 @@ namespace Thelia\Core\Security; use Propel\Runtime\ActiveQuery\Criteria; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Security\User\UserInterface; use Thelia\Core\HttpFoundation\Request; use Thelia\Model\ProfileQuery; @@ -126,12 +126,8 @@ class SecurityContext * * @return Boolean */ - final public function isGranted(array $roles, array $permissions) + final public function isGranted(array $roles, array $resources, array $accesses) { - if (empty($permissions)) { - return true; - } - // Find a user which matches the required roles. $user = $this->getCustomerUser(); @@ -147,7 +143,11 @@ class SecurityContext return false; } - if( !method_exists($user, 'getProfileId') ) { + if (empty($resources) || empty($accesses)) { + return true; + } + + if( !method_exists($user, 'getPermissions') ) { return false; } @@ -157,14 +157,22 @@ class SecurityContext return true; } - foreach($permissions as $permission) { - if($permission === '') { + foreach($resources as $resource) { + if($resource === '') { continue; } - if(! in_array($permission, $userPermissions)) { + $resource = strtolower($resource); + + if(!array_key_exists($resource, $userPermissions)) { return false; } + + foreach($accesses as $access) { + if(!$userPermissions[$resource]->can($access)) { + return false; + } + } } return true; diff --git a/core/lib/Thelia/Core/Template/Loop/Auth.php b/core/lib/Thelia/Core/Template/Loop/Auth.php index ff9f3cfd3..f5691cbd6 100755 --- a/core/lib/Thelia/Core/Template/Loop/Auth.php +++ b/core/lib/Thelia/Core/Template/Loop/Auth.php @@ -29,6 +29,9 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Type\AlphaNumStringListType; +use Thelia\Type\EnumListType; +use Thelia\Type\TypeCollection; /** * @@ -41,40 +44,45 @@ class Auth extends BaseLoop public function getArgDefinitions() { return new ArgumentCollection( - Argument::createAnyTypeArgument('roles', null, true), - Argument::createAnyTypeArgument('permissions'), + new Argument( + 'roles', + new TypeCollection( + new AlphaNumStringListType() + ), + null, + true + ), + new Argument( + 'resource', + new TypeCollection( + new AlphaNumStringListType() + ) + ), + new Argument( + 'access', + new TypeCollection( + new EnumListType(array("view", "create", "update", "delete")) + ) + ), Argument::createAnyTypeArgument('context', 'front', false) ); } - private function _explode($commaSeparatedValues) - { - - $array = explode(',', $commaSeparatedValues); - - if (array_walk($array, function(&$item) { - $item = strtoupper(trim($item)); - })) { - return $array; - } - - return array(); - } - /** + * @param $pagination * - * - * @return \Thelia\Core\Template\Element\LoopResult + * @return LoopResult */ public function exec(&$pagination) { - $roles = $this->_explode($this->getRoles()); - $permissions = $this->_explode($this->getPermissions()); + $roles = $this->getRoles(); + $resource = $this->getResource(); + $access = $this->getAccess(); $loopResult = new LoopResult(); try { - if (true === $this->securityContext->isGranted($roles, $permissions == null ? array() : $permissions)) { + if (true === $this->securityContext->isGranted($roles, $resource === null ? array() : $resource, $access === null ? array() : $access)) { // Create an empty row: loop is no longer empty :) $loopResult->addRow(new LoopResultRow()); diff --git a/core/lib/Thelia/Core/Template/Smarty/AbstractSmartyPlugin.php b/core/lib/Thelia/Core/Template/Smarty/AbstractSmartyPlugin.php index 8a7cace29..8ef21f51e 100755 --- a/core/lib/Thelia/Core/Template/Smarty/AbstractSmartyPlugin.php +++ b/core/lib/Thelia/Core/Template/Smarty/AbstractSmartyPlugin.php @@ -40,6 +40,10 @@ abstract class AbstractSmartyPlugin */ protected function _explode($commaSeparatedValues) { + if(null === $commaSeparatedValues) { + return array(); + } + $array = explode(',', $commaSeparatedValues); if (array_walk($array, function(&$item) { diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php index a56bbff1c..244d09166 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php @@ -45,7 +45,8 @@ class AdminUtilities extends AbstractSmartyPlugin public function generatePositionChangeBlock($params, &$smarty) { // The required permissions - $permission = $this->getParam($params, 'permission'); + $resource = $this->getParam($params, 'resource'); + $access = $this->getParam($params, 'access'); // The base position change path $path = $this->getParam($params, 'path'); @@ -68,7 +69,7 @@ class AdminUtilities extends AbstractSmartyPlugin */ - if ($permissions == null || $this->securityContext->isGranted("ADMIN", array($permission))) { + if ($permissions == null || $this->securityContext->isGranted("ADMIN", array($resource), array($access))) { return sprintf( '%s', URL::getInstance()->absoluteUrl($path, array('mode' => 'up', $url_parameter => $id)), diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php index b6e31aef0..4f8b0ccc2 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php @@ -53,14 +53,15 @@ class Security extends AbstractSmartyPlugin */ public function checkAuthFunction($params, &$smarty) { - $roles = $this->_explode($this->getParam($params, 'roles')); - $permissions = $this->_explode($this->getParam($params, 'permissions')); + $roles = $this->_explode($this->getParam($params, 'role')); + $resources = $this->_explode($this->getParam($params, 'resource')); + $accesses = $this->_explode($this->getParam($params, 'access')); - if (! $this->securityContext->isGranted($roles, $permissions)) { + if (! $this->securityContext->isGranted($roles, $resources, $accesses)) { $ex = new AuthenticationException( - sprintf("User not granted for roles '%s', permissions '%s' in context '%s'.", - implode(',', $roles), implode(',', $permissions), $context + sprintf("User not granted for roles '%s', to access resources '%s' with %s in context '%s'.", + implode(',', $roles), implode(',', $resources), implode(',', $accesses), $context ) ); diff --git a/core/lib/Thelia/Model/Admin.php b/core/lib/Thelia/Model/Admin.php index d4fa2a02d..1c13ea6f1 100755 --- a/core/lib/Thelia/Model/Admin.php +++ b/core/lib/Thelia/Model/Admin.php @@ -3,7 +3,8 @@ namespace Thelia\Model; use Propel\Runtime\ActiveQuery\Criteria; -use Thelia\Core\Event\AdminResources; +use Thelia\Core\Security\Resource\AdminResources; +use Thelia\Core\Security\AccessManager; use Thelia\Core\Security\User\UserInterface; use Thelia\Core\Security\Role\Role; @@ -39,7 +40,7 @@ class Admin extends BaseAdmin implements UserInterface $userPermissions = array(); foreach($userPermissionsQuery as $userPermission) { - $userPermissions[] = $userPermission->getVirtualColumn('code'); + $userPermissions[$userPermission->getVirtualColumn('code')] = new AccessManager($userPermission->getAccess()); } return $userPermissions; diff --git a/core/lib/Thelia/Model/Base/ProfileResource.php b/core/lib/Thelia/Model/Base/ProfileResource.php index 9f3d246fc..bd62a76af 100644 --- a/core/lib/Thelia/Model/Base/ProfileResource.php +++ b/core/lib/Thelia/Model/Base/ProfileResource.php @@ -77,18 +77,11 @@ abstract class ProfileResource implements ActiveRecordInterface protected $resource_id; /** - * The value for the read field. + * The value for the access field. * Note: this column has a database default value of: 0 * @var int */ - protected $read; - - /** - * The value for the write field. - * Note: this column has a database default value of: 0 - * @var int - */ - protected $write; + protected $access; /** * The value for the created_at field. @@ -128,8 +121,7 @@ abstract class ProfileResource implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->read = 0; - $this->write = 0; + $this->access = 0; } /** @@ -426,25 +418,14 @@ abstract class ProfileResource implements ActiveRecordInterface } /** - * Get the [read] column value. + * Get the [access] column value. * * @return int */ - public function getRead() + public function getAccess() { - return $this->read; - } - - /** - * Get the [write] column value. - * - * @return int - */ - public function getWrite() - { - - return $this->write; + return $this->access; } /** @@ -559,46 +540,25 @@ abstract class ProfileResource implements ActiveRecordInterface } // setResourceId() /** - * Set the value of [read] column. + * Set the value of [access] column. * * @param int $v new value * @return \Thelia\Model\ProfileResource The current object (for fluent API support) */ - public function setRead($v) + public function setAccess($v) { if ($v !== null) { $v = (int) $v; } - if ($this->read !== $v) { - $this->read = $v; - $this->modifiedColumns[] = ProfileResourceTableMap::READ; + if ($this->access !== $v) { + $this->access = $v; + $this->modifiedColumns[] = ProfileResourceTableMap::ACCESS; } return $this; - } // setRead() - - /** - * Set the value of [write] column. - * - * @param int $v new value - * @return \Thelia\Model\ProfileResource The current object (for fluent API support) - */ - public function setWrite($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->write !== $v) { - $this->write = $v; - $this->modifiedColumns[] = ProfileResourceTableMap::WRITE; - } - - - return $this; - } // setWrite() + } // setAccess() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -652,11 +612,7 @@ abstract class ProfileResource implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->read !== 0) { - return false; - } - - if ($this->write !== 0) { + if ($this->access !== 0) { return false; } @@ -696,19 +652,16 @@ abstract class ProfileResource implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProfileResourceTableMap::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)]; $this->resource_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProfileResourceTableMap::translateFieldName('Read', TableMap::TYPE_PHPNAME, $indexType)]; - $this->read = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProfileResourceTableMap::translateFieldName('Access', TableMap::TYPE_PHPNAME, $indexType)]; + $this->access = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProfileResourceTableMap::translateFieldName('Write', TableMap::TYPE_PHPNAME, $indexType)]; - $this->write = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProfileResourceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProfileResourceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProfileResourceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProfileResourceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -721,7 +674,7 @@ abstract class ProfileResource implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 7; // 7 = ProfileResourceTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 6; // 6 = ProfileResourceTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\ProfileResource object", 0, $e); @@ -977,11 +930,8 @@ abstract class ProfileResource implements ActiveRecordInterface if ($this->isColumnModified(ProfileResourceTableMap::RESOURCE_ID)) { $modifiedColumns[':p' . $index++] = 'RESOURCE_ID'; } - if ($this->isColumnModified(ProfileResourceTableMap::READ)) { - $modifiedColumns[':p' . $index++] = 'READ'; - } - if ($this->isColumnModified(ProfileResourceTableMap::WRITE)) { - $modifiedColumns[':p' . $index++] = 'WRITE'; + if ($this->isColumnModified(ProfileResourceTableMap::ACCESS)) { + $modifiedColumns[':p' . $index++] = 'ACCESS'; } if ($this->isColumnModified(ProfileResourceTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -1009,11 +959,8 @@ abstract class ProfileResource implements ActiveRecordInterface case 'RESOURCE_ID': $stmt->bindValue($identifier, $this->resource_id, PDO::PARAM_INT); break; - case 'READ': - $stmt->bindValue($identifier, $this->read, PDO::PARAM_INT); - break; - case 'WRITE': - $stmt->bindValue($identifier, $this->write, PDO::PARAM_INT); + case 'ACCESS': + $stmt->bindValue($identifier, $this->access, PDO::PARAM_INT); break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); @@ -1093,15 +1040,12 @@ abstract class ProfileResource implements ActiveRecordInterface return $this->getResourceId(); break; case 3: - return $this->getRead(); + return $this->getAccess(); break; case 4: - return $this->getWrite(); - break; - case 5: return $this->getCreatedAt(); break; - case 6: + case 5: return $this->getUpdatedAt(); break; default: @@ -1136,10 +1080,9 @@ abstract class ProfileResource implements ActiveRecordInterface $keys[0] => $this->getId(), $keys[1] => $this->getProfileId(), $keys[2] => $this->getResourceId(), - $keys[3] => $this->getRead(), - $keys[4] => $this->getWrite(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), + $keys[3] => $this->getAccess(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1197,15 +1140,12 @@ abstract class ProfileResource implements ActiveRecordInterface $this->setResourceId($value); break; case 3: - $this->setRead($value); + $this->setAccess($value); break; case 4: - $this->setWrite($value); - break; - case 5: $this->setCreatedAt($value); break; - case 6: + case 5: $this->setUpdatedAt($value); break; } // switch() @@ -1235,10 +1175,9 @@ abstract class ProfileResource implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setProfileId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setResourceId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setRead($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setWrite($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); + if (array_key_exists($keys[3], $arr)) $this->setAccess($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); } /** @@ -1253,8 +1192,7 @@ abstract class ProfileResource implements ActiveRecordInterface if ($this->isColumnModified(ProfileResourceTableMap::ID)) $criteria->add(ProfileResourceTableMap::ID, $this->id); if ($this->isColumnModified(ProfileResourceTableMap::PROFILE_ID)) $criteria->add(ProfileResourceTableMap::PROFILE_ID, $this->profile_id); if ($this->isColumnModified(ProfileResourceTableMap::RESOURCE_ID)) $criteria->add(ProfileResourceTableMap::RESOURCE_ID, $this->resource_id); - if ($this->isColumnModified(ProfileResourceTableMap::READ)) $criteria->add(ProfileResourceTableMap::READ, $this->read); - if ($this->isColumnModified(ProfileResourceTableMap::WRITE)) $criteria->add(ProfileResourceTableMap::WRITE, $this->write); + if ($this->isColumnModified(ProfileResourceTableMap::ACCESS)) $criteria->add(ProfileResourceTableMap::ACCESS, $this->access); if ($this->isColumnModified(ProfileResourceTableMap::CREATED_AT)) $criteria->add(ProfileResourceTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(ProfileResourceTableMap::UPDATED_AT)) $criteria->add(ProfileResourceTableMap::UPDATED_AT, $this->updated_at); @@ -1332,8 +1270,7 @@ abstract class ProfileResource implements ActiveRecordInterface { $copyObj->setProfileId($this->getProfileId()); $copyObj->setResourceId($this->getResourceId()); - $copyObj->setRead($this->getRead()); - $copyObj->setWrite($this->getWrite()); + $copyObj->setAccess($this->getAccess()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1474,8 +1411,7 @@ abstract class ProfileResource implements ActiveRecordInterface $this->id = null; $this->profile_id = null; $this->resource_id = null; - $this->read = null; - $this->write = null; + $this->access = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/ProfileResourceQuery.php b/core/lib/Thelia/Model/Base/ProfileResourceQuery.php index 23794538f..ba4fca82d 100644 --- a/core/lib/Thelia/Model/Base/ProfileResourceQuery.php +++ b/core/lib/Thelia/Model/Base/ProfileResourceQuery.php @@ -24,16 +24,14 @@ use Thelia\Model\Map\ProfileResourceTableMap; * @method ChildProfileResourceQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildProfileResourceQuery orderByProfileId($order = Criteria::ASC) Order by the profile_id column * @method ChildProfileResourceQuery orderByResourceId($order = Criteria::ASC) Order by the resource_id column - * @method ChildProfileResourceQuery orderByRead($order = Criteria::ASC) Order by the read column - * @method ChildProfileResourceQuery orderByWrite($order = Criteria::ASC) Order by the write column + * @method ChildProfileResourceQuery orderByAccess($order = Criteria::ASC) Order by the access column * @method ChildProfileResourceQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildProfileResourceQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildProfileResourceQuery groupById() Group by the id column * @method ChildProfileResourceQuery groupByProfileId() Group by the profile_id column * @method ChildProfileResourceQuery groupByResourceId() Group by the resource_id column - * @method ChildProfileResourceQuery groupByRead() Group by the read column - * @method ChildProfileResourceQuery groupByWrite() Group by the write column + * @method ChildProfileResourceQuery groupByAccess() Group by the access column * @method ChildProfileResourceQuery groupByCreatedAt() Group by the created_at column * @method ChildProfileResourceQuery groupByUpdatedAt() Group by the updated_at column * @@ -55,16 +53,14 @@ use Thelia\Model\Map\ProfileResourceTableMap; * @method ChildProfileResource findOneById(int $id) Return the first ChildProfileResource filtered by the id column * @method ChildProfileResource findOneByProfileId(int $profile_id) Return the first ChildProfileResource filtered by the profile_id column * @method ChildProfileResource findOneByResourceId(int $resource_id) Return the first ChildProfileResource filtered by the resource_id column - * @method ChildProfileResource findOneByRead(int $read) Return the first ChildProfileResource filtered by the read column - * @method ChildProfileResource findOneByWrite(int $write) Return the first ChildProfileResource filtered by the write column + * @method ChildProfileResource findOneByAccess(int $access) Return the first ChildProfileResource filtered by the access column * @method ChildProfileResource findOneByCreatedAt(string $created_at) Return the first ChildProfileResource filtered by the created_at column * @method ChildProfileResource findOneByUpdatedAt(string $updated_at) Return the first ChildProfileResource filtered by the updated_at column * * @method array findById(int $id) Return ChildProfileResource objects filtered by the id column * @method array findByProfileId(int $profile_id) Return ChildProfileResource objects filtered by the profile_id column * @method array findByResourceId(int $resource_id) Return ChildProfileResource objects filtered by the resource_id column - * @method array findByRead(int $read) Return ChildProfileResource objects filtered by the read column - * @method array findByWrite(int $write) Return ChildProfileResource objects filtered by the write column + * @method array findByAccess(int $access) Return ChildProfileResource objects filtered by the access column * @method array findByCreatedAt(string $created_at) Return ChildProfileResource objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildProfileResource objects filtered by the updated_at column * @@ -155,7 +151,7 @@ abstract class ProfileResourceQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, PROFILE_ID, RESOURCE_ID, READ, WRITE, CREATED_AT, UPDATED_AT FROM profile_resource WHERE ID = :p0 AND PROFILE_ID = :p1 AND RESOURCE_ID = :p2'; + $sql = 'SELECT ID, PROFILE_ID, RESOURCE_ID, ACCESS, CREATED_AT, UPDATED_AT FROM profile_resource WHERE ID = :p0 AND PROFILE_ID = :p1 AND RESOURCE_ID = :p2'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -388,16 +384,16 @@ abstract class ProfileResourceQuery extends ModelCriteria } /** - * Filter the query on the read column + * Filter the query on the access column * * Example usage: * - * $query->filterByRead(1234); // WHERE read = 1234 - * $query->filterByRead(array(12, 34)); // WHERE read IN (12, 34) - * $query->filterByRead(array('min' => 12)); // WHERE read > 12 + * $query->filterByAccess(1234); // WHERE access = 1234 + * $query->filterByAccess(array(12, 34)); // WHERE access IN (12, 34) + * $query->filterByAccess(array('min' => 12)); // WHERE access > 12 * * - * @param mixed $read The value to use as filter. + * @param mixed $access The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -405,16 +401,16 @@ abstract class ProfileResourceQuery extends ModelCriteria * * @return ChildProfileResourceQuery The current query, for fluid interface */ - public function filterByRead($read = null, $comparison = null) + public function filterByAccess($access = null, $comparison = null) { - if (is_array($read)) { + if (is_array($access)) { $useMinMax = false; - if (isset($read['min'])) { - $this->addUsingAlias(ProfileResourceTableMap::READ, $read['min'], Criteria::GREATER_EQUAL); + if (isset($access['min'])) { + $this->addUsingAlias(ProfileResourceTableMap::ACCESS, $access['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($read['max'])) { - $this->addUsingAlias(ProfileResourceTableMap::READ, $read['max'], Criteria::LESS_EQUAL); + if (isset($access['max'])) { + $this->addUsingAlias(ProfileResourceTableMap::ACCESS, $access['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -425,48 +421,7 @@ abstract class ProfileResourceQuery extends ModelCriteria } } - return $this->addUsingAlias(ProfileResourceTableMap::READ, $read, $comparison); - } - - /** - * Filter the query on the write column - * - * Example usage: - * - * $query->filterByWrite(1234); // WHERE write = 1234 - * $query->filterByWrite(array(12, 34)); // WHERE write IN (12, 34) - * $query->filterByWrite(array('min' => 12)); // WHERE write > 12 - * - * - * @param mixed $write The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildProfileResourceQuery The current query, for fluid interface - */ - public function filterByWrite($write = null, $comparison = null) - { - if (is_array($write)) { - $useMinMax = false; - if (isset($write['min'])) { - $this->addUsingAlias(ProfileResourceTableMap::WRITE, $write['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($write['max'])) { - $this->addUsingAlias(ProfileResourceTableMap::WRITE, $write['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProfileResourceTableMap::WRITE, $write, $comparison); + return $this->addUsingAlias(ProfileResourceTableMap::ACCESS, $access, $comparison); } /** diff --git a/core/lib/Thelia/Model/Map/ProfileResourceTableMap.php b/core/lib/Thelia/Model/Map/ProfileResourceTableMap.php index 4e46d9c33..5a7f1e07e 100644 --- a/core/lib/Thelia/Model/Map/ProfileResourceTableMap.php +++ b/core/lib/Thelia/Model/Map/ProfileResourceTableMap.php @@ -57,7 +57,7 @@ class ProfileResourceTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 7; + const NUM_COLUMNS = 6; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class ProfileResourceTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 7; + const NUM_HYDRATE_COLUMNS = 6; /** * the column name for the ID field @@ -85,14 +85,9 @@ class ProfileResourceTableMap extends TableMap const RESOURCE_ID = 'profile_resource.RESOURCE_ID'; /** - * the column name for the READ field + * the column name for the ACCESS field */ - const READ = 'profile_resource.READ'; - - /** - * the column name for the WRITE field - */ - const WRITE = 'profile_resource.WRITE'; + const ACCESS = 'profile_resource.ACCESS'; /** * the column name for the CREATED_AT field @@ -116,12 +111,12 @@ class ProfileResourceTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'ProfileId', 'ResourceId', 'Read', 'Write', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'profileId', 'resourceId', 'read', 'write', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ProfileResourceTableMap::ID, ProfileResourceTableMap::PROFILE_ID, ProfileResourceTableMap::RESOURCE_ID, ProfileResourceTableMap::READ, ProfileResourceTableMap::WRITE, ProfileResourceTableMap::CREATED_AT, ProfileResourceTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'PROFILE_ID', 'RESOURCE_ID', 'READ', 'WRITE', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'profile_id', 'resource_id', 'read', 'write', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + self::TYPE_PHPNAME => array('Id', 'ProfileId', 'ResourceId', 'Access', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'profileId', 'resourceId', 'access', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProfileResourceTableMap::ID, ProfileResourceTableMap::PROFILE_ID, ProfileResourceTableMap::RESOURCE_ID, ProfileResourceTableMap::ACCESS, ProfileResourceTableMap::CREATED_AT, ProfileResourceTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PROFILE_ID', 'RESOURCE_ID', 'ACCESS', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'profile_id', 'resource_id', 'access', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -131,12 +126,12 @@ class ProfileResourceTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'ProfileId' => 1, 'ResourceId' => 2, 'Read' => 3, 'Write' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'profileId' => 1, 'resourceId' => 2, 'read' => 3, 'write' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - self::TYPE_COLNAME => array(ProfileResourceTableMap::ID => 0, ProfileResourceTableMap::PROFILE_ID => 1, ProfileResourceTableMap::RESOURCE_ID => 2, ProfileResourceTableMap::READ => 3, ProfileResourceTableMap::WRITE => 4, ProfileResourceTableMap::CREATED_AT => 5, ProfileResourceTableMap::UPDATED_AT => 6, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'PROFILE_ID' => 1, 'RESOURCE_ID' => 2, 'READ' => 3, 'WRITE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - self::TYPE_FIELDNAME => array('id' => 0, 'profile_id' => 1, 'resource_id' => 2, 'read' => 3, 'write' => 4, 'created_at' => 5, 'updated_at' => 6, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + self::TYPE_PHPNAME => array('Id' => 0, 'ProfileId' => 1, 'ResourceId' => 2, 'Access' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'profileId' => 1, 'resourceId' => 2, 'access' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(ProfileResourceTableMap::ID => 0, ProfileResourceTableMap::PROFILE_ID => 1, ProfileResourceTableMap::RESOURCE_ID => 2, ProfileResourceTableMap::ACCESS => 3, ProfileResourceTableMap::CREATED_AT => 4, ProfileResourceTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PROFILE_ID' => 1, 'RESOURCE_ID' => 2, 'ACCESS' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'profile_id' => 1, 'resource_id' => 2, 'access' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -159,8 +154,7 @@ class ProfileResourceTableMap extends TableMap $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignPrimaryKey('PROFILE_ID', 'ProfileId', 'INTEGER' , 'profile', 'ID', true, null, null); $this->addForeignPrimaryKey('RESOURCE_ID', 'ResourceId', 'INTEGER' , 'resource', 'ID', true, null, null); - $this->addColumn('READ', 'Read', 'TINYINT', false, null, 0); - $this->addColumn('WRITE', 'Write', 'TINYINT', false, null, 0); + $this->addColumn('ACCESS', 'Access', 'INTEGER', true, null, 0); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -377,16 +371,14 @@ class ProfileResourceTableMap extends TableMap $criteria->addSelectColumn(ProfileResourceTableMap::ID); $criteria->addSelectColumn(ProfileResourceTableMap::PROFILE_ID); $criteria->addSelectColumn(ProfileResourceTableMap::RESOURCE_ID); - $criteria->addSelectColumn(ProfileResourceTableMap::READ); - $criteria->addSelectColumn(ProfileResourceTableMap::WRITE); + $criteria->addSelectColumn(ProfileResourceTableMap::ACCESS); $criteria->addSelectColumn(ProfileResourceTableMap::CREATED_AT); $criteria->addSelectColumn(ProfileResourceTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.PROFILE_ID'); $criteria->addSelectColumn($alias . '.RESOURCE_ID'); - $criteria->addSelectColumn($alias . '.READ'); - $criteria->addSelectColumn($alias . '.WRITE'); + $criteria->addSelectColumn($alias . '.ACCESS'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Type/AlphaNumStringListType.php b/core/lib/Thelia/Type/AlphaNumStringListType.php index ccf21606d..474a615db 100755 --- a/core/lib/Thelia/Type/AlphaNumStringListType.php +++ b/core/lib/Thelia/Type/AlphaNumStringListType.php @@ -38,7 +38,7 @@ class AlphaNumStringListType extends BaseType public function isValid($values) { foreach (explode(',', $values) as $value) { - if(!preg_match('#^[a-zA-Z0-9\-_]+$#', $value)) + if(!preg_match('#^[a-zA-Z0-9\-_\.]+$#', $value)) return false; } diff --git a/core/lib/Thelia/Type/AlphaNumStringType.php b/core/lib/Thelia/Type/AlphaNumStringType.php index ad9595f20..db788d4d6 100755 --- a/core/lib/Thelia/Type/AlphaNumStringType.php +++ b/core/lib/Thelia/Type/AlphaNumStringType.php @@ -37,7 +37,7 @@ class AlphaNumStringType extends BaseType public function isValid($value) { - return preg_match('#^[a-zA-Z0-9\-_]+$#', $value) ? true : false; + return preg_match('#^[a-zA-Z0-9\-_\.]+$#', $value) ? true : false; } public function getFormattedValue($value) diff --git a/install/insert.sql b/install/insert.sql index 7a5b34ca9..80ab5a844 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -1198,95 +1198,26 @@ INSERT INTO `order_status_i18n` (`id`, `locale`, `title`, `description`, `chapo` generated with command : php Thelia thelia:generate-resources --output sql */ INSERT INTO resource (`id`, `code`, `created_at`, `updated_at`) VALUES -(NULL, 'admin.address.view', NOW(), NOW()), -(NULL, 'admin.address.create', NOW(), NOW()), -(NULL, 'admin.address.update', NOW(), NOW()), -(NULL, 'admin.address.delete', NOW(), NOW()), -(NULL, 'admin.configuration.admin.view', NOW(), NOW()), -(NULL, 'admin.configuration.admin.create', NOW(), NOW()), -(NULL, 'admin.configuration.admin.update', NOW(), NOW()), -(NULL, 'admin.configuration.admin.delete', NOW(), NOW()), -(NULL, 'admin.configuration.area.view', NOW(), NOW()), -(NULL, 'admin.configuration.area.create', NOW(), NOW()), -(NULL, 'admin.configuration.area.update', NOW(), NOW()), -(NULL, 'admin.configuration.area.delete', NOW(), NOW()), -(NULL, 'admin.configuration.attribute.view', NOW(), NOW()), -(NULL, 'admin.configuration.attribute.create', NOW(), NOW()), -(NULL, 'admin.configuration.attribute.update', NOW(), NOW()), -(NULL, 'admin.configuration.attribute.delete', NOW(), NOW()), -(NULL, 'admin.category.view', NOW(), NOW()), -(NULL, 'admin.category.create', NOW(), NOW()), -(NULL, 'admin.category.update', NOW(), NOW()), -(NULL, 'admin.category.delete', NOW(), NOW()), -(NULL, 'admin.configuration.view', NOW(), NOW()), -(NULL, 'admin.configuration.create', NOW(), NOW()), -(NULL, 'admin.configuration.update', NOW(), NOW()), -(NULL, 'admin.configuration.delete', NOW(), NOW()), -(NULL, 'admin.content.view', NOW(), NOW()), -(NULL, 'admin.content.create', NOW(), NOW()), -(NULL, 'admin.content.update', NOW(), NOW()), -(NULL, 'admin.content.delete', NOW(), NOW()), -(NULL, 'admin.configuration.country.view', NOW(), NOW()), -(NULL, 'admin.configuration.country.create', NOW(), NOW()), -(NULL, 'admin.configuration.country.update', NOW(), NOW()), -(NULL, 'admin.configuration.country.delete', NOW(), NOW()), -(NULL, 'admin.coupon.view', NOW(), NOW()), -(NULL, 'admin.coupon.create', NOW(), NOW()), -(NULL, 'admin.coupon.update', NOW(), NOW()), -(NULL, 'admin.coupon.delete', NOW(), NOW()), -(NULL, 'admin.configuration.currency.view', NOW(), NOW()), -(NULL, 'admin.configuration.currency.create', NOW(), NOW()), -(NULL, 'admin.configuration.currency.update', NOW(), NOW()), -(NULL, 'admin.configuration.currency.delete', NOW(), NOW()), -(NULL, 'admin.customer.view', NOW(), NOW()), -(NULL, 'admin.customer.create', NOW(), NOW()), -(NULL, 'admin.customer.update', NOW(), NOW()), -(NULL, 'admin.customer.delete', NOW(), NOW()), -(NULL, 'admin.configuration.feature.view', NOW(), NOW()), -(NULL, 'admin.configuration.feature.create', NOW(), NOW()), -(NULL, 'admin.configuration.feature.update', NOW(), NOW()), -(NULL, 'admin.configuration.feature.delete', NOW(), NOW()), -(NULL, 'admin.folder.view', NOW(), NOW()), -(NULL, 'admin.folder.create', NOW(), NOW()), -(NULL, 'admin.folder.update', NOW(), NOW()), -(NULL, 'admin.folder.delete', NOW(), NOW()), -(NULL, 'admin.configuration.language.view', NOW(), NOW()), -(NULL, 'admin.configuration.language.create', NOW(), NOW()), -(NULL, 'admin.configuration.language.update', NOW(), NOW()), -(NULL, 'admin.configuration.language.delete', NOW(), NOW()), -(NULL, 'admin.configuration.mailing-system.view', NOW(), NOW()), -(NULL, 'admin.configuration.mailing-system.create', NOW(), NOW()), -(NULL, 'admin.configuration.mailing-system.update', NOW(), NOW()), -(NULL, 'admin.configuration.mailing-system.delete', NOW(), NOW()), -(NULL, 'admin.configuration.message.view', NOW(), NOW()), -(NULL, 'admin.configuration.message.create', NOW(), NOW()), -(NULL, 'admin.configuration.message.update', NOW(), NOW()), -(NULL, 'admin.configuration.message.delete', NOW(), NOW()), -(NULL, 'admin.configuration.module.view', NOW(), NOW()), -(NULL, 'admin.configuration.module.create', NOW(), NOW()), -(NULL, 'admin.configuration.module.update', NOW(), NOW()), -(NULL, 'admin.configuration.module.delete', NOW(), NOW()), -(NULL, 'admin.order.view', NOW(), NOW()), -(NULL, 'admin.order.create', NOW(), NOW()), -(NULL, 'admin.order.update', NOW(), NOW()), -(NULL, 'admin.order.delete', NOW(), NOW()), -(NULL, 'admin.product.view', NOW(), NOW()), -(NULL, 'admin.product.create', NOW(), NOW()), -(NULL, 'admin.product.update', NOW(), NOW()), -(NULL, 'admin.product.delete', NOW(), NOW()), -(NULL, 'admin.configuration.profile.view', NOW(), NOW()), -(NULL, 'admin.configuration.profile.create', NOW(), NOW()), -(NULL, 'admin.configuration.profile.update', NOW(), NOW()), -(NULL, 'admin.configuration.profile.delete', NOW(), NOW()), -(NULL, 'admin.configuration.shipping-zone.view', NOW(), NOW()), -(NULL, 'admin.configuration.shipping-zone.create', NOW(), NOW()), -(NULL, 'admin.configuration.shipping-zone.update', NOW(), NOW()), -(NULL, 'admin.configuration.shipping-zone.delete', NOW(), NOW()), -(NULL, 'admin.configuration.tax.view', NOW(), NOW()), -(NULL, 'admin.configuration.tax.create', NOW(), NOW()), -(NULL, 'admin.configuration.tax.update', NOW(), NOW()), -(NULL, 'admin.configuration.tax.delete', NOW(), NOW()), -(NULL, 'admin.configuration.template.view', NOW(), NOW()), -(NULL, 'admin.configuration.template.create', NOW(), NOW()), -(NULL, 'admin.configuration.template.update', NOW(), NOW()), -(NULL, 'admin.configuration.template.delete', NOW(), NOW()); +(NULL, 'admin.address', NOW(), NOW()), +(NULL, 'admin.configuration.admin', NOW(), NOW()), +(NULL, 'admin.configuration.area', NOW(), NOW()), +(NULL, 'admin.configuration.attribute', NOW(), NOW()), +(NULL, 'admin.category', NOW(), NOW()), +(NULL, 'admin.configuration', NOW(), NOW()), +(NULL, 'admin.content', NOW(), NOW()), +(NULL, 'admin.configuration.country', NOW(), NOW()), +(NULL, 'admin.coupon', NOW(), NOW()), +(NULL, 'admin.configuration.currency', NOW(), NOW()), +(NULL, 'admin.customer', NOW(), NOW()), +(NULL, 'admin.configuration.feature', NOW(), NOW()), +(NULL, 'admin.folder', NOW(), NOW()), +(NULL, 'admin.configuration.language', NOW(), NOW()), +(NULL, 'admin.configuration.mailing-system', NOW(), NOW()), +(NULL, 'admin.configuration.message', NOW(), NOW()), +(NULL, 'admin.configuration.module', NOW(), NOW()), +(NULL, 'admin.order', NOW(), NOW()), +(NULL, 'admin.product', NOW(), NOW()), +(NULL, 'admin.configuration.profile', NOW(), NOW()), +(NULL, 'admin.configuration.shipping-zone', NOW(), NOW()), +(NULL, 'admin.configuration.tax', NOW(), NOW()), +(NULL, 'admin.configuration.template', NOW(), NOW()) diff --git a/install/thelia.sql b/install/thelia.sql index 1e96ee783..d8e0422cd 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -1002,8 +1002,7 @@ CREATE TABLE `profile_resource` `id` INTEGER NOT NULL AUTO_INCREMENT, `profile_id` INTEGER NOT NULL, `resource_id` INTEGER NOT NULL, - `read` TINYINT DEFAULT 0, - `write` TINYINT DEFAULT 0, + `access` INTEGER DEFAULT 0 NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`,`profile_id`,`resource_id`), diff --git a/local/config/schema.xml b/local/config/schema.xml index 7c2cf4b97..e7f7801f1 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -776,8 +776,7 @@ - - + diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index f66cc17e1..743264d7a 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -1,7 +1,7 @@ {* -- By default, check admin login ----------------------------------------- *} {block name="check-auth"} - {check_auth roles="ADMIN" permissions="{block name="check-permissions"}{/block}" login_tpl="/admin/login"} + {check_auth role="ADMIN" resource="{block name="check-resource"}{/block}" access="{block name="check-access"}{/block}" login_tpl="/admin/login"} {/block} {* -- Define some stuff for Smarty ----------------------------------------- *} diff --git a/templates/admin/default/admin-profiles.html b/templates/admin/default/admin-profiles.html deleted file mode 100644 index b0d84b04a..000000000 --- a/templates/admin/default/admin-profiles.html +++ /dev/null @@ -1,219 +0,0 @@ -{extends file="admin-layout.tpl"} - -{block name="page-title"}{intl l='Admin profiles'}{/block} - -{block name="check-permissions"}admin.admin-profiles.view{/block} - -{block name="main-content"} -
- -
- -
- - {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.admin-profiles.create"} - - - - {/loop} -
- - {module_include location='admin_profiles_top'} - -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
- {intl l="Profile"} -
- -
-
- - -
-
-
-
-
-
-
- -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- {intl l="General rights"} -
{intl l="Authorization"}{intl l="Description"}{intl l="Access"}
Access to customers - Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur, saepe, libero, veniam ab quod. - -
- -
-
Access to orders - Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur, saepe, libero, veniam ab quod. - -
- -
-
Access to catalog - Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur, saepe, libero, veniam ab quod. - -
- -
-
- -
-
-
-
-
-
- - {module_include location='admin_profiles_bottom'} - -
-
- -{* Creation dialog *} - -{form name="thelia.admin.admin-profile.creation"} - - {* Capture the dialog body, to pass it to the generic dialog *} - {capture "creation_dialog"} - - {form_hidden_fields form=$form} - - {* Be sure to get the language_id, even if the form could not be validated *} - - - {form_field form=$form field='success_url'} - {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} - - {/form_field} - - {form_field form=$form field='wording'} -
- - -
- {/form_field} - - {form_field form=$form field='name'} -
- - -
- {/form_field} - - {form_field form=$form field='description'} -
- - -
- {/form_field} - - {module_include location='admin_profile_create_form'} - - {/capture} - - {include - file = "includes/generic-create-dialog.html" - - dialog_id = "creation_dialog" - dialog_title = {intl l="Create a new admin profile"} - dialog_body = {$smarty.capture.creation_dialog nofilter} - - dialog_ok_label = {intl l="Create this admin profile"} - - form_action = {url path='/admin/configuration/admin_profile/create'} - form_enctype = {form_enctype form=$form} - form_error_message = $form_error_message - } -{/form} - -{/block} - -{block name="javascript-initialization"} - - {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} - - {/javascripts} - - {javascripts file='assets/js/bootstrap-select/bootstrap-select.js'} - - {/javascripts} - - {javascripts file='assets/js/main.js'} - - {/javascripts} -{/block} \ No newline at end of file diff --git a/templates/admin/default/ajax/product-related-tab.html b/templates/admin/default/ajax/product-related-tab.html index 3c909b390..24c8b71a1 100644 --- a/templates/admin/default/ajax/product-related-tab.html +++ b/templates/admin/default/ajax/product-related-tab.html @@ -90,7 +90,8 @@ {admin_position_block - permission="admin.products.edit" + resource="admin.product" + access="update" path={url path='/admin/product/update-content-position' product_id=$product_id current_tab="related"} url_parameter="content_id" in_place_edit_class="contentPositionChange" @@ -210,7 +211,8 @@ {admin_position_block - permission="admin.products.edit" + resource="admin.product" + access="update" path={url path='/admin/product/update-accessory-position' product_id=$product_id current_tab="related"} url_parameter="accessory_id" in_place_edit_class="accessoryPositionChange" diff --git a/templates/admin/default/ajax/template-attribute-list.html b/templates/admin/default/ajax/template-attribute-list.html index 7c0c2fdb9..27d4f9831 100644 --- a/templates/admin/default/ajax/template-attribute-list.html +++ b/templates/admin/default/ajax/template-attribute-list.html @@ -50,7 +50,8 @@ {admin_position_block - permission="admin.templates.edit" + resource="admin.configuration.template" + access="update" path={url path="admin/template/update-attribute-position" template_id=$template_id} url_parameter="attribute_id" in_place_edit_class="attributePositionChange" diff --git a/templates/admin/default/ajax/template-feature-list.html b/templates/admin/default/ajax/template-feature-list.html index 5c69f96ce..26b09baea 100644 --- a/templates/admin/default/ajax/template-feature-list.html +++ b/templates/admin/default/ajax/template-feature-list.html @@ -52,7 +52,8 @@ {admin_position_block - permission="admin.templates.edit" + resource="admin.configuration.template" + access="update" path={url path="/admin/template/update-feature-position" template_id=$template_id} url_parameter="feature_id" in_place_edit_class="featurePositionChange" diff --git a/templates/admin/default/attribute-edit.html b/templates/admin/default/attribute-edit.html index d15703910..1b3417ef6 100644 --- a/templates/admin/default/attribute-edit.html +++ b/templates/admin/default/attribute-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit an attribute'}{/block} -{block name="check-permissions"}admin.configuration.attributes.edit{/block} +{block name="check-resource"}admin.configuration.attribute{/block} +{block name="check-access"}update{/block} {block name="main-content"}
@@ -133,7 +134,8 @@ {admin_position_block - permission="admin.attributes.edit" + resource="admin.configuration.attribute" + access="update" path={url path='/admin/configuration/attributes-av/update-position' attribute_id=$attribute_id} url_parameter="attributeav_id" in_place_edit_class="positionChange" diff --git a/templates/admin/default/attributes.html b/templates/admin/default/attributes.html index dd2572a2b..28a927920 100644 --- a/templates/admin/default/attributes.html +++ b/templates/admin/default/attributes.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Thelia Product Attributes'}{/block} -{block name="check-permissions"}admin.configuration.attributes.view{/block} +{block name="check-resource"}admin.configuration.attribute{/block} +{block name="check-access"}view{/block} {block name="main-content"}
@@ -86,7 +87,8 @@ {admin_position_block - permission="admin.attributes.edit" + resource="admin.configuration.attribute" + access="update" path="/admin/configuration/attributes/update-position" url_parameter="attribute_id" in_place_edit_class="positionChange" diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html index 21161a386..89c0e6923 100755 --- a/templates/admin/default/categories.html +++ b/templates/admin/default/categories.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Categories'}{/block} -{block name="check-permissions"}admin.categories.view{/block} +{block name="check-resource"}admin.category{/block} +{block name="check-access"}view{/block} {block name="main-content"}
@@ -127,7 +128,8 @@ {admin_position_block - permission="admin.categories.edit" + resource="admin.category" + access="update" path={url path='admin/categories/update-position' category_id=$ID} url_parameter="category_id" in_place_edit_class="categoryPositionChange" @@ -294,7 +296,8 @@ {admin_position_block - permission="admin.product.edit" + resource="admin.product" + access="update" path={url path='/admin/products/update-position' product_id=$ID} url_parameter="product_id" in_place_edit_class="productPositionChange" diff --git a/templates/admin/default/category-edit.html b/templates/admin/default/category-edit.html index 78cb7b681..ceefa53bb 100755 --- a/templates/admin/default/category-edit.html +++ b/templates/admin/default/category-edit.html @@ -1,6 +1,7 @@ {extends file="admin-layout.tpl"} -{block name="check-permissions"}admin.catalog.view{/block} +{block name="check-resource"}admin.category{/block} +{block name="check-access"}update{/block} {block name="page-title"}{intl l='Edit category'}{/block} diff --git a/templates/admin/default/configuration.html b/templates/admin/default/configuration.html index f95b623da..16c09bac2 100644 --- a/templates/admin/default/configuration.html +++ b/templates/admin/default/configuration.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Configuration'}{/block} -{block name="check-permissions"}admin.configuration.view{/block} +{block name="check-resource"}admin.configuration{/block} +{block name="check-access"}view{/block} {block name="main-content"}
diff --git a/templates/admin/default/content-edit.html b/templates/admin/default/content-edit.html index a4a80acf8..c0d010287 100644 --- a/templates/admin/default/content-edit.html +++ b/templates/admin/default/content-edit.html @@ -1,6 +1,7 @@ {extends file="admin-layout.tpl"} -{block name="check-permissions"}admin.content.view{/block} +{block name="check-resource"}admin.content{/block} +{block name="check-access"}view{/block} {block name="page-title"}{intl l='Edit content'}{/block} diff --git a/templates/admin/default/countries.html b/templates/admin/default/countries.html index 6791131df..ec89063ee 100644 --- a/templates/admin/default/countries.html +++ b/templates/admin/default/countries.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Countries'}{/block} -{block name="check-permissions"}admin.configuration.countries.view{/block} +{block name="check-resource"}admin.configuration.country{/block} +{block name="check-access"}view{/block} {block name="main-content"}
diff --git a/templates/admin/default/country-edit.html b/templates/admin/default/country-edit.html index 447a6b355..524070ce4 100644 --- a/templates/admin/default/country-edit.html +++ b/templates/admin/default/country-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit a country'}{/block} -{block name="check-permissions"}admin.configuration.countries.edit{/block} +{block name="check-resource"}admin.configuration.country{/block} +{block name="check-access"}update{/block} {block name="main-content"}
diff --git a/templates/admin/default/coupon-create.html b/templates/admin/default/coupon-create.html index a5bb21c67..f82501916 100755 --- a/templates/admin/default/coupon-create.html +++ b/templates/admin/default/coupon-create.html @@ -1,5 +1,8 @@ {extends file="admin-layout.tpl"} -{block name="check-permissions"}admin.coupon.create{/block} + +{block name="check-resource"}admin.coupon{/block} +{block name="check-access"}create{/block} + {block name="page-title"}{intl l='Create coupon'}{/block} {block name="main-content"} diff --git a/templates/admin/default/coupon-list.html b/templates/admin/default/coupon-list.html index 73b108bd6..fb4005fb1 100755 --- a/templates/admin/default/coupon-list.html +++ b/templates/admin/default/coupon-list.html @@ -1,5 +1,8 @@ {extends file="admin-layout.tpl"} -{block name="check-permissions"}admin.coupon.view{/block} + +{block name="check-resource"}admin.coupon{/block} +{block name="check-access"}view{/block} + {block name="page-title"}{intl l='Coupons'}{/block} {block name="main-content"} diff --git a/templates/admin/default/coupon-read.html b/templates/admin/default/coupon-read.html index 6143fbded..75fd7f550 100755 --- a/templates/admin/default/coupon-read.html +++ b/templates/admin/default/coupon-read.html @@ -1,5 +1,8 @@ {extends file="admin-layout.tpl"} -{block name="check-permissions"}admin.coupon.view{/block} + +{block name="check-resource"}admin.coupon{/block} +{block name="check-access"}view{/block} + {block name="page-title"}{intl l='Coupon'}{/block} {block name="main-content"} diff --git a/templates/admin/default/coupon-update.html b/templates/admin/default/coupon-update.html index be9354362..9f5730ac3 100755 --- a/templates/admin/default/coupon-update.html +++ b/templates/admin/default/coupon-update.html @@ -1,5 +1,8 @@ {extends file="admin-layout.tpl"} -{block name="check-permissions"}admin.coupon.update{/block} + +{block name="check-resource"}admin.coupon{/block} +{block name="check-access"}update{/block} + {block name="page-title"}{intl l='Update coupon'}{/block} {block name="main-content"} diff --git a/templates/admin/default/currencies.html b/templates/admin/default/currencies.html index e53d86277..aeebad06a 100644 --- a/templates/admin/default/currencies.html +++ b/templates/admin/default/currencies.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Currencies'}{/block} -{block name="check-permissions"}admin.configuration.currencies.view{/block} +{block name="check-resource"}admin.configuration.currency{/block} +{block name="check-access"}view{/block} {block name="main-content"}
@@ -137,12 +138,13 @@ {admin_position_block - permission="admin.currencies.edit" - path="/admin/configuration/currencies/update-position" - url_parameter="currency_id" - in_place_edit_class="currencyPositionChange" - position="$POSITION" - id="$ID" + resource="admin.configuration.currency" + access="update" + path="/admin/configuration/currencies/update-position" + url_parameter="currency_id" + in_place_edit_class="currencyPositionChange" + position="$POSITION" + id="$ID" } diff --git a/templates/admin/default/currency-edit.html b/templates/admin/default/currency-edit.html index 57b511903..092a4283f 100644 --- a/templates/admin/default/currency-edit.html +++ b/templates/admin/default/currency-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit a currency'}{/block} -{block name="check-permissions"}admin.configuration.currencies.edit{/block} +{block name="check-resource"}admin.configuration.currency{/block} +{block name="check-access"}update{/block} {block name="main-content"}
diff --git a/templates/admin/default/customer-edit.html b/templates/admin/default/customer-edit.html index 69e1815f3..87b372ea5 100644 --- a/templates/admin/default/customer-edit.html +++ b/templates/admin/default/customer-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit a customer'}{/block} -{block name="check-permissions"}admin.customer.edit{/block} +{block name="check-resource"}admin.customer{/block} +{block name="check-access"}update{/block} {block name="main-content"}
diff --git a/templates/admin/default/customers.html b/templates/admin/default/customers.html index cfa332ae4..80f5e317f 100644 --- a/templates/admin/default/customers.html +++ b/templates/admin/default/customers.html @@ -3,7 +3,8 @@ {block name="page-title"}{intl l='Customer'}{/block} -{block name="check-permissions"}admin.customer.view{/block} +{block name="check-resource"}admin.customer{/block} +{block name="check-access"}view{/block} {block name="main-content"} {assign var=customer_page value={$smarty.get.page|default:1}} diff --git a/templates/admin/default/document-edit.html b/templates/admin/default/document-edit.html index 793fd14cf..79e2607c7 100644 --- a/templates/admin/default/document-edit.html +++ b/templates/admin/default/document-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit a document'}{/block} -{block name="check-permissions"}admin.document.edit{/block} +{block name="check-resource"}admin.document{/block} +{block name="check-access"}update{/block} {block name="main-content"}
diff --git a/templates/admin/default/feature-edit.html b/templates/admin/default/feature-edit.html index 25c2d6017..1d03e17ae 100644 --- a/templates/admin/default/feature-edit.html +++ b/templates/admin/default/feature-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit a feature'}{/block} -{block name="check-permissions"}admin.configuration.features.edit{/block} +{block name="check-resource"}admin.configuration.feature{/block} +{block name="check-access"}update{/block} {block name="main-content"}
@@ -133,12 +134,13 @@ {admin_position_block - permission="admin.features.edit" - path={url path='/admin/configuration/features-av/update-position' feature_id=$feature_id} - url_parameter="featureav_id" - in_place_edit_class="positionChange" - position="$POSITION" - id="$ID" + resource="admin.configuration.feature" + access="update" + path={url path='/admin/configuration/features-av/update-position' feature_id=$feature_id} + url_parameter="featureav_id" + in_place_edit_class="positionChange" + position="$POSITION" + id="$ID" } diff --git a/templates/admin/default/features.html b/templates/admin/default/features.html index f58a19bc2..649f7a9a3 100644 --- a/templates/admin/default/features.html +++ b/templates/admin/default/features.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Thelia Product Features'}{/block} -{block name="check-permissions"}admin.configuration.features.view{/block} +{block name="check-resource"}admin.configuration.feature{/block} +{block name="check-access"}view{/block} {block name="main-content"}
@@ -86,12 +87,13 @@ {admin_position_block - permission="admin.features.edit" - path="/admin/configuration/features/update-position" - url_parameter="feature_id" - in_place_edit_class="positionChange" - position="$POSITION" - id="$ID" + resource="admin.configuration.feature" + access="update" + path="/admin/configuration/features/update-position" + url_parameter="feature_id" + in_place_edit_class="positionChange" + position="$POSITION" + id="$ID" } diff --git a/templates/admin/default/folder-edit.html b/templates/admin/default/folder-edit.html index 6a0b962e4..ed1c89830 100644 --- a/templates/admin/default/folder-edit.html +++ b/templates/admin/default/folder-edit.html @@ -1,6 +1,7 @@ {extends file="admin-layout.tpl"} -{block name="check-permissions"}admin.folder.view{/block} +{block name="check-resource"}admin.folder{/block} +{block name="check-access"}update{/block} {block name="page-title"}{intl l='Edit folder'}{/block} diff --git a/templates/admin/default/folders.html b/templates/admin/default/folders.html index 7a68d5bf0..ba5fc7b8b 100644 --- a/templates/admin/default/folders.html +++ b/templates/admin/default/folders.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Folders'}{/block} -{block name="check-permissions"}admin.folders.view{/block} +{block name="check-resource"}admin.folder{/block} +{block name="check-access"}view{/block} {block name="main-content"}
@@ -132,12 +133,13 @@ {admin_position_block - permission="admin.folders.edit" - path={url path='admin/folders/update-position' folder_id=$ID} - url_parameter="folder_id" - in_place_edit_class="folderPositionChange" - position=$POSITION - id=$ID + resource="admin.folder" + access="update" + path={url path='admin/folders/update-position' folder_id=$ID} + url_parameter="folder_id" + in_place_edit_class="folderPositionChange" + position=$POSITION + id=$ID } @@ -287,12 +289,13 @@ {admin_position_block - permission="admin.content.edit" - path={url path='/admin/content/update-position' content_id=$ID} - url_parameter="content_id" - in_place_edit_class="contentPositionChange" - position=$POSITION - id=$ID + resource="admin.content" + access="update" + path={url path='/admin/content/update-position' content_id=$ID} + url_parameter="content_id" + in_place_edit_class="contentPositionChange" + position=$POSITION + id=$ID } diff --git a/templates/admin/default/image-edit.html b/templates/admin/default/image-edit.html index f95d2645f..810e8b445 100644 --- a/templates/admin/default/image-edit.html +++ b/templates/admin/default/image-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit an image'}{/block} -{block name="check-permissions"}admin.image.edit{/block} +{block name="check-resource"}admin.image{/block} +{block name="check-access"}update{/block} {block name="main-content"}
diff --git a/templates/admin/default/languages.html b/templates/admin/default/languages.html index 499e903d7..f6b259197 100644 --- a/templates/admin/default/languages.html +++ b/templates/admin/default/languages.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Thelia Languages'}{/block} -{block name="check-permissions"}admin.configuration.languages.view{/block} +{block name="check-resource"}admin.configuration.language{/block} +{block name="check-access"}view{/block} {block name="main-content"}
diff --git a/templates/admin/default/mailing-system.html b/templates/admin/default/mailing-system.html index 4f826e954..984dfd8bd 100644 --- a/templates/admin/default/mailing-system.html +++ b/templates/admin/default/mailing-system.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Thelia Mailing System'}{/block} -{block name="check-permissions"}admin.configuration.mailing-system.view{/block} +{block name="check-resource"}admin.configuration.mailing-system{/block} +{block name="check-access"}view{/block} {block name="main-content"}
diff --git a/templates/admin/default/message-edit.html b/templates/admin/default/message-edit.html index 51e97d61d..3911cf255 100644 --- a/templates/admin/default/message-edit.html +++ b/templates/admin/default/message-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit a mailing template'}{/block} -{block name="check-permissions"}admin.configuration.messages.edit{/block} +{block name="check-resource"}admin.configuration.message{/block} +{block name="check-access"}update{/block} {block name="main-content"}
diff --git a/templates/admin/default/messages.html b/templates/admin/default/messages.html index cf2a0d9e1..48d3383f1 100644 --- a/templates/admin/default/messages.html +++ b/templates/admin/default/messages.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Thelia Mailing Templates'}{/block} -{block name="check-permissions"}admin.configuration.messages.view{/block} +{block name="check-resource"}admin.configuration.message{/block} +{block name="check-access"}view{/block} {block name="main-content"}
diff --git a/templates/admin/default/modules.html b/templates/admin/default/modules.html index 86c336a04..9f9664e22 100644 --- a/templates/admin/default/modules.html +++ b/templates/admin/default/modules.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Modules'}{/block} -{block name="check-permissions"}admin.modules.view{/block} +{block name="check-resource"}admin.configuration.module{/block} +{block name="check-access"}view{/block} {block name="main-content"}
diff --git a/templates/admin/default/order-edit.html b/templates/admin/default/order-edit.html index f05bc2a05..1d5abf358 100644 --- a/templates/admin/default/order-edit.html +++ b/templates/admin/default/order-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit an order'}{/block} -{block name="check-permissions"}admin.order.edit{/block} +{block name="check-resource"}admin.order{/block} +{block name="check-access"}update{/block} {block name="main-content"} diff --git a/templates/admin/default/orders.html b/templates/admin/default/orders.html index 057a7610c..9edc56e9b 100644 --- a/templates/admin/default/orders.html +++ b/templates/admin/default/orders.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Orders'}{/block} -{block name="check-permissions"}admin.orders.view{/block} +{block name="check-resource"}admin.order{/block} +{block name="check-access"}view{/block} {block name="main-content"} {assign order_page {$smarty.get.page|default:1}} diff --git a/templates/admin/default/product-edit.html b/templates/admin/default/product-edit.html index 2e3ef3615..75b85c82b 100644 --- a/templates/admin/default/product-edit.html +++ b/templates/admin/default/product-edit.html @@ -1,6 +1,7 @@ {extends file="admin-layout.tpl"} -{block name="check-permissions"}admin.catalog.view{/block} +{block name="check-resource"}admin.product{/block} +{block name="check-access"}update{/block} {block name="page-title"}{intl l='Edit product'}{/block} diff --git a/templates/admin/default/profile-edit.html b/templates/admin/default/profile-edit.html index b2d5fd2a4..db3cbd0e2 100644 --- a/templates/admin/default/profile-edit.html +++ b/templates/admin/default/profile-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit a profile'}{/block} -{block name="check-permissions"}admin.configuration.profiles.edit{/block} +{block name="check-resource"}admin.configuration.profile{/block} +{block name="check-access"}update{/block} {block name="main-content"} diff --git a/templates/admin/default/profiles.html b/templates/admin/default/profiles.html index b076413d0..3bb18be31 100644 --- a/templates/admin/default/profiles.html +++ b/templates/admin/default/profiles.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Taxes rules'}{/block} -{block name="check-permissions"}admin.profile.view{/block} +{block name="check-resource"}admin.configuration.profile{/block} +{block name="check-access"}view{/block} {block name="main-content"}
diff --git a/templates/admin/default/shipping-configuration-edit.html b/templates/admin/default/shipping-configuration-edit.html index 9e0268d0f..8c24d2ff7 100644 --- a/templates/admin/default/shipping-configuration-edit.html +++ b/templates/admin/default/shipping-configuration-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit a shipping configuration'}{/block} -{block name="check-permissions"}admin.configuration.shipping-configuration.edit{/block} +{block name="check-resource"}admin.configuration.shipping-configuration{/block} +{block name="check-access"}update{/block} {block name="main-content"}
diff --git a/templates/admin/default/shipping-configuration.html b/templates/admin/default/shipping-configuration.html index d4c8147c2..b488b5eb1 100644 --- a/templates/admin/default/shipping-configuration.html +++ b/templates/admin/default/shipping-configuration.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Thelia Shipping configuration'}{/block} -{block name="check-permissions"}admin.configuration.shipping-configuration.view{/block} +{block name="check-resource"}admin.configuration.shipping-configuration{/block} +{block name="check-access"}view{/block} {block name="main-content"}
diff --git a/templates/admin/default/shipping-zones-edit.html b/templates/admin/default/shipping-zones-edit.html index 139e3d164..d18c4eea2 100644 --- a/templates/admin/default/shipping-zones-edit.html +++ b/templates/admin/default/shipping-zones-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit a shipping zone'}{/block} -{block name="check-permissions"}admin.configuration.shipping-zones.edit{/block} +{block name="check-resource"}admin.configuration.shipping-zone{/block} +{block name="check-access"}update{/block} {block name="main-content"}
diff --git a/templates/admin/default/shipping-zones.html b/templates/admin/default/shipping-zones.html index 5eeed61c4..bff616cf8 100644 --- a/templates/admin/default/shipping-zones.html +++ b/templates/admin/default/shipping-zones.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Thelia Shipping zones'}{/block} -{block name="check-permissions"}admin.configuration.shipping-zones.view{/block} +{block name="check-resource"}admin.configuration.shipping-zone{/block} +{block name="check-access"}view{/block} {block name="main-content"}
diff --git a/templates/admin/default/tax-edit.html b/templates/admin/default/tax-edit.html index 556955519..03c40b0a5 100644 --- a/templates/admin/default/tax-edit.html +++ b/templates/admin/default/tax-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit a tax'}{/block} -{block name="check-permissions"}admin.configuration.taxes.edit{/block} +{block name="check-resource"}admin.configuration.tax{/block} +{block name="check-access"}update{/block} {block name="main-content"} diff --git a/templates/admin/default/tax-rule-edit.html b/templates/admin/default/tax-rule-edit.html index 3996f4a61..0af295e63 100644 --- a/templates/admin/default/tax-rule-edit.html +++ b/templates/admin/default/tax-rule-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit a tax rule'}{/block} -{block name="check-permissions"}admin.configuration.taxes-rules.edit{/block} +{block name="check-resource"}admin.configuration.tax{/block} +{block name="check-access"}update{/block} {block name="main-content"} diff --git a/templates/admin/default/taxes-rules.html b/templates/admin/default/taxes-rules.html index 063cf564d..0a48d18a1 100644 --- a/templates/admin/default/taxes-rules.html +++ b/templates/admin/default/taxes-rules.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Taxes rules'}{/block} -{block name="check-permissions"}admin.taxes-rules.view{/block} +{block name="check-resource"}admin.configuration.tax{/block} +{block name="check-access"}view{/block} {block name="main-content"}
diff --git a/templates/admin/default/template-edit.html b/templates/admin/default/template-edit.html index 17e48b950..f9e1fd139 100644 --- a/templates/admin/default/template-edit.html +++ b/templates/admin/default/template-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit a template'}{/block} -{block name="check-permissions"}admin.configuration.templates.edit{/block} +{block name="check-resource"}admin.configuration.template{/block} +{block name="check-access"}update{/block} {block name="main-content"}
diff --git a/templates/admin/default/templates.html b/templates/admin/default/templates.html index 839f8b5ed..95d92d1a9 100644 --- a/templates/admin/default/templates.html +++ b/templates/admin/default/templates.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Thelia Product Templates'}{/block} -{block name="check-permissions"}admin.configuration.templates.view{/block} +{block name="check-resource"}admin.configuration.template{/block} +{block name="check-access"}view{/block} {block name="main-content"}
diff --git a/templates/admin/default/variable-edit.html b/templates/admin/default/variable-edit.html index 30d9ea7c5..dfc572ec2 100644 --- a/templates/admin/default/variable-edit.html +++ b/templates/admin/default/variable-edit.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Edit a system variable'}{/block} -{block name="check-permissions"}admin.configuration.variables.edit{/block} +{block name="check-resource"}admin.configuration.variable{/block} +{block name="check-access"}update{/block} {block name="main-content"}
diff --git a/templates/admin/default/variables.html b/templates/admin/default/variables.html index 0ce47727d..a7a2b9c09 100644 --- a/templates/admin/default/variables.html +++ b/templates/admin/default/variables.html @@ -2,7 +2,8 @@ {block name="page-title"}{intl l='Thelia System Variables'}{/block} -{block name="check-permissions"}admin.configuration.variables.view{/block} +{block name="check-resource"}admin.configuration.variable{/block} +{block name="check-access"}view{/block} {block name="main-content"}
diff --git a/templates/default/account.html b/templates/default/account.html index adbb4bf9e..50d37e7d3 100644 --- a/templates/default/account.html +++ b/templates/default/account.html @@ -1,7 +1,7 @@ {extends file="layout.tpl"} {block name="no-return-functions" prepend} - {check_auth context="front" roles="CUSTOMER" login_tpl="login"} + {check_auth context="front" role="CUSTOMER" login_tpl="login"} {/block} {* Breadcrumb *} diff --git a/templates/default/address-update.html b/templates/default/address-update.html index cd64ade1d..b2508610e 100644 --- a/templates/default/address-update.html +++ b/templates/default/address-update.html @@ -1,7 +1,7 @@ {extends file="layout.tpl"} {block name="no-return-functions"} - {check_auth context="front" roles="CUSTOMER" login_tpl="login"} + {check_auth context="front" role="CUSTOMER" login_tpl="login"} {/block} {* Body Class *} diff --git a/templates/default/address.html b/templates/default/address.html index 6b0245956..98363eb98 100644 --- a/templates/default/address.html +++ b/templates/default/address.html @@ -1,7 +1,7 @@ {extends file="layout.tpl"} {block name="no-return-functions"} - {check_auth context="front" roles="CUSTOMER" login_tpl="login"} + {check_auth context="front" role="CUSTOMER" login_tpl="login"} {/block} {* Body Class *} diff --git a/templates/default/order-delivery.html b/templates/default/order-delivery.html index ac8812fec..baf4cf9a7 100644 --- a/templates/default/order-delivery.html +++ b/templates/default/order-delivery.html @@ -1,7 +1,7 @@ {extends file="layout.tpl"} {block name="no-return-functions"} - {check_auth context="front" roles="CUSTOMER" login_tpl="login"} + {check_auth context="front" role="CUSTOMER" login_tpl="login"} {check_cart_not_empty} {/block} diff --git a/templates/default/order-invoice.html b/templates/default/order-invoice.html index 1037f0fe3..ce9b9a71a 100644 --- a/templates/default/order-invoice.html +++ b/templates/default/order-invoice.html @@ -1,7 +1,7 @@ {extends file="layout.tpl"} {block name="no-return-functions"} - {check_auth context="front" roles="CUSTOMER" login_tpl="login"} + {check_auth context="front" role="CUSTOMER" login_tpl="login"} {check_cart_not_empty} {check_valid_delivery} {/block} From 5755da1e8c6de3c81d12a1e8f5f8da7f923afa70 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 22 Oct 2013 11:22:23 +0200 Subject: [PATCH 15/22] change newsletter success message --- templates/default/newsletter-success.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/default/newsletter-success.html b/templates/default/newsletter-success.html index 8c6820fe8..d856d033e 100644 --- a/templates/default/newsletter-success.html +++ b/templates/default/newsletter-success.html @@ -8,8 +8,8 @@ {block name="main-content"}
-

{intl l="Thanks !"}

-

{intl l="Thanks for your subscrition to the newsletter"}

+

{intl l="Thanks for signing up!"}

+

{intl l="We'll keep you posted whenever we have any new updates. If you ever wish to unsubscribe, you can easily do so via the link that will be in every email."}

{/block} \ No newline at end of file From 42e8b3a596ea29d10828a5d37e6e82dd13162b08 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 22 Oct 2013 11:24:33 +0200 Subject: [PATCH 16/22] fix tests --- core/lib/Thelia/Tests/Type/AlphaNumStringTypeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Tests/Type/AlphaNumStringTypeTest.php b/core/lib/Thelia/Tests/Type/AlphaNumStringTypeTest.php index ae07cce6b..8f752432f 100755 --- a/core/lib/Thelia/Tests/Type/AlphaNumStringTypeTest.php +++ b/core/lib/Thelia/Tests/Type/AlphaNumStringTypeTest.php @@ -36,7 +36,7 @@ class AlphaNumStringTypeTest extends \PHPUnit_Framework_TestCase { $type = new AlphaNumStringType(); $this->assertTrue($type->isValid('azs_qs-0-9ds')); - $this->assertFalse($type->isValid('3.3')); + $this->assertTrue($type->isValid('3.3')); $this->assertFalse($type->isValid('3 3')); $this->assertFalse($type->isValid('3€3')); } From 77dbdce4e8a6066d188209e9be134d25c89df561 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 22 Oct 2013 11:33:01 +0200 Subject: [PATCH 17/22] fix tests --- core/lib/Thelia/Tests/Tools/FileManagerTest.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Tests/Tools/FileManagerTest.php b/core/lib/Thelia/Tests/Tools/FileManagerTest.php index 1228867a7..0b8e2f9de 100644 --- a/core/lib/Thelia/Tests/Tools/FileManagerTest.php +++ b/core/lib/Thelia/Tests/Tools/FileManagerTest.php @@ -14,6 +14,10 @@ use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent; use Thelia\Core\Translation\Translator; use Thelia\Exception\ImageException; use Thelia\Model\Admin; +use Thelia\Model\CategoryQuery; +use Thelia\Model\ContentQuery; +use Thelia\Model\FolderQuery; +use Thelia\Model\ProductQuery; use Thelia\Tools\FileManager; /** @@ -631,13 +635,13 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase ->getMock(); $fileManager = new FileManager($stubContainer); - $actual = $fileManager->getParentFileModel(FileManager::TYPE_PRODUCT, 1); + $actual = $fileManager->getParentFileModel(FileManager::TYPE_PRODUCT, ProductQuery::create()->findOne()->getId()); $this->assertInstanceOf('\Thelia\Model\Product', $actual); - $actual = $fileManager->getParentFileModel(FileManager::TYPE_CATEGORY, 1); + $actual = $fileManager->getParentFileModel(FileManager::TYPE_CATEGORY, CategoryQuery::create()->findOne()->getId()); $this->assertInstanceOf('\Thelia\Model\Category', $actual); - $actual = $fileManager->getParentFileModel(FileManager::TYPE_CONTENT, 1); + $actual = $fileManager->getParentFileModel(FileManager::TYPE_CONTENT, ContentQuery::create()->findOne()->getId()); $this->assertInstanceOf('\Thelia\Model\Content', $actual); - $actual = $fileManager->getParentFileModel(FileManager::TYPE_FOLDER, 1); + $actual = $fileManager->getParentFileModel(FileManager::TYPE_FOLDER, FolderQuery::create()->findOne()->getId()); $this->assertInstanceOf('\Thelia\Model\Folder', $actual, 1); $actual = $fileManager->getParentFileModel('bad', 1); $this->assertNull($actual); From c94fa9bc24ec189bda2f31f446a20bf77b05242b Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 22 Oct 2013 15:04:06 +0200 Subject: [PATCH 18/22] permission management --- core/lib/Thelia/Command/GenerateResources.php | 31 ++- core/lib/Thelia/Config/Resources/config.xml | 1 + .../Controller/Admin/BaseAdminController.php | 2 +- .../Thelia/Core/Security/AccessManager.php | 5 +- core/lib/Thelia/Core/Template/Loop/Admin.php | 21 +- .../lib/Thelia/Core/Template/Loop/Profile.php | 22 +- .../Thelia/Core/Template/Loop/Resource.php | 115 ++++++++++ install/insert.sql | 54 ++++- templates/admin/default/profile-edit.html | 213 +++++------------- 9 files changed, 278 insertions(+), 186 deletions(-) create mode 100755 core/lib/Thelia/Core/Template/Loop/Resource.php diff --git a/core/lib/Thelia/Command/GenerateResources.php b/core/lib/Thelia/Command/GenerateResources.php index 217672797..46924ac99 100644 --- a/core/lib/Thelia/Command/GenerateResources.php +++ b/core/lib/Thelia/Command/GenerateResources.php @@ -29,6 +29,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Thelia\Command\ContainerAwareCommand; use Thelia\Model\Admin; +use Thelia\Model\Map\ResourceI18nTableMap; use Thelia\Model\Map\ResourceTableMap; class GenerateResources extends ContainerAwareCommand @@ -46,7 +47,7 @@ class GenerateResources extends ContainerAwareCommand 'output', null, InputOption::VALUE_OPTIONAL, - 'Output format amid (string, sql)', + 'Output format amid (string, sql, sql-i18n)', null ) ; @@ -55,7 +56,7 @@ class GenerateResources extends ContainerAwareCommand protected function execute(InputInterface $input, OutputInterface $output) { - $class = new \ReflectionClass('Thelia\Core\Event\AdminResources'); + $class = new \ReflectionClass('Thelia\Core\Security\Resource\AdminResources'); $constants = $class->getConstants(); @@ -69,12 +70,36 @@ class GenerateResources extends ContainerAwareCommand $output->writeln( 'INSERT INTO ' . ResourceTableMap::TABLE_NAME . ' (`id`, `code`, `created_at`, `updated_at`) VALUES ' ); + $compteur = 0; foreach($constants as $constant => $value) { if($constant == 'SUPERADMINISTRATOR') { continue; } + $compteur++; $output->writeln( - "(NULL, '$value', NOW(), NOW())" . ($constant === key( array_slice( $constants, -1, 1, TRUE ) ) ? '' : ',') + "($compteur, '$value', NOW(), NOW())" . ($constant === key( array_slice( $constants, -1, 1, true ) ) ? ';' : ',') + ); + } + break; + case 'sql-i18n': + $output->writeln( + 'INSERT INTO ' . ResourceI18nTableMap::TABLE_NAME . ' (`id`, `locale`, `title`) VALUES ' + ); + $compteur = 0; + foreach($constants as $constant => $value) { + if($constant == 'SUPERADMINISTRATOR') { + continue; + } + + $compteur++; + + $title = ucwords( str_replace('.', ' / ', str_replace('admin.', '', $value) ) ); + + $output->writeln( + "($compteur, 'en_US', '$title')," + ); + $output->writeln( + "($compteur, 'fr_FR', '$title')" . ($constant === key( array_slice( $constants, -1, 1, true ) ) ? ';' : ',') ); } break; diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 493f9fbf8..9e7d86c3d 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -35,6 +35,7 @@ + diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 186727ed5..fdbb6c1c4 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -128,7 +128,7 @@ class BaseAdminController extends BaseController } // Log the problem - $this->adminLogAppend("User is not granted for permissions %s", implode(", ", $permArr)); + $this->adminLogAppend("User is not granted for resources %s with accesses %s", implode(", ", $resources), implode(", ", $accesses)); // Generate the proper response $response = new Response(); diff --git a/core/lib/Thelia/Core/Security/AccessManager.php b/core/lib/Thelia/Core/Security/AccessManager.php index cdf7105a8..229c07a00 100644 --- a/core/lib/Thelia/Core/Security/AccessManager.php +++ b/core/lib/Thelia/Core/Security/AccessManager.php @@ -63,8 +63,9 @@ class AccessManager $this->accessValue = $accessValue; foreach($this->accessPows as $type => $value) { - if($accessValue >= $value) { - $accessValue -= $value; + $pow = pow(2, $value); + if($accessValue >= $pow) { + $accessValue -= $pow; $this->accessGranted[$type] = true; } else { $this->accessGranted[$type] = false; diff --git a/core/lib/Thelia/Core/Template/Loop/Admin.php b/core/lib/Thelia/Core/Template/Loop/Admin.php index fe4b280ad..378bcaf31 100755 --- a/core/lib/Thelia/Core/Template/Loop/Admin.php +++ b/core/lib/Thelia/Core/Template/Loop/Admin.php @@ -25,6 +25,7 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; @@ -44,7 +45,7 @@ use Thelia\Type\BooleanOrBothType; * @package Thelia\Core\Template\Loop * @author Etienne Roudeix */ -class Admin extends BaseI18nLoop +class Admin extends BaseLoop { public $timestampable = true; @@ -83,17 +84,17 @@ class Admin extends BaseI18nLoop $search->orderByFirstname(Criteria::ASC); /* perform search */ - $features = $this->search($search, $pagination); + $admins = $this->search($search, $pagination); - $loopResult = new LoopResult($features); + $loopResult = new LoopResult($admins); - foreach ($features as $feature) { - $loopResultRow = new LoopResultRow($loopResult, $feature, $this->versionable, $this->timestampable, $this->countable); - $loopResultRow->set("ID", $feature->getId()) - ->set("PROFILE",$feature->getProfileId()) - ->set("FIRSTNAME",$feature->getFirstname()) - ->set("LASTNAME",$feature->getLastname()) - ->set("LOGIN",$feature->getLogin()) + foreach ($admins as $admin) { + $loopResultRow = new LoopResultRow($loopResult, $admin, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow->set("ID", $admin->getId()) + ->set("PROFILE",$admin->getProfileId()) + ->set("FIRSTNAME",$admin->getFirstname()) + ->set("LASTNAME",$admin->getLastname()) + ->set("LOGIN",$admin->getLogin()) ; $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/Profile.php b/core/lib/Thelia/Core/Template/Loop/Profile.php index a7a2e170e..4ac43d25a 100755 --- a/core/lib/Thelia/Core/Template/Loop/Profile.php +++ b/core/lib/Thelia/Core/Template/Loop/Profile.php @@ -79,20 +79,20 @@ class Profile extends BaseI18nLoop $search->orderById(Criteria::ASC); /* perform search */ - $features = $this->search($search, $pagination); + $profiles = $this->search($search, $pagination); - $loopResult = new LoopResult($features); + $loopResult = new LoopResult($profiles); - foreach ($features as $feature) { - $loopResultRow = new LoopResultRow($loopResult, $feature, $this->versionable, $this->timestampable, $this->countable); - $loopResultRow->set("ID", $feature->getId()) - ->set("IS_TRANSLATED",$feature->getVirtualColumn('IS_TRANSLATED')) + foreach ($profiles as $profile) { + $loopResultRow = new LoopResultRow($loopResult, $profile, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow->set("ID", $profile->getId()) + ->set("IS_TRANSLATED",$profile->getVirtualColumn('IS_TRANSLATED')) ->set("LOCALE",$locale) - ->set("CODE",$feature->getCode()) - ->set("TITLE",$feature->getVirtualColumn('i18n_TITLE')) - ->set("CHAPO", $feature->getVirtualColumn('i18n_CHAPO')) - ->set("DESCRIPTION", $feature->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $feature->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("CODE",$profile->getCode()) + ->set("TITLE",$profile->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $profile->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $profile->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $profile->getVirtualColumn('i18n_POSTSCRIPTUM')) ; $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/Resource.php b/core/lib/Thelia/Core/Template/Loop/Resource.php new file mode 100755 index 000000000..949cb5e00 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Resource.php @@ -0,0 +1,115 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Security\AccessManager; +use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\ResourceQuery; +use Thelia\Type; +use Thelia\Type\BooleanOrBothType; + +/** + * + * Resource loop + * + * + * Class Resource + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Resource extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntTypeArgument('profile') + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = ResourceQuery::create(); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search); + + $profile = $this->getProfile(); + + if (null !== $profile) { + $search->leftJoinProfileResource('profile_resource') + ->withColumn('profile_resource.access', 'access'); + //$search->filterById($id, Criteria::IN); + } + + $search->orderById(Criteria::ASC); + + /* perform search */ + $resources = $this->search($search, $pagination); + + $loopResult = new LoopResult($resources); + + foreach ($resources as $resource) { + $loopResultRow = new LoopResultRow($loopResult, $resource, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow->set("ID", $resource->getId()) + ->set("IS_TRANSLATED",$resource->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE",$locale) + ->set("CODE",$resource->getCode()) + ->set("TITLE",$resource->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $resource->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $resource->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $resource->getVirtualColumn('i18n_POSTSCRIPTUM')) + ; + + if (null !== $profile) { + $accessValue = $resource->getVirtualColumn('access'); + $manager = new AccessManager($accessValue); + $loopResultRow->set("VIEWABLE", $manager->can(AccessManager::VIEW)) + ->set("CREATABLE", $manager->can(AccessManager::CREATE)) + ->set("UPDATABLE", $manager->can(AccessManager::UPDATE)) + ->set("DELETABLE", $manager->can(AccessManager::DELETE)); + } + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/install/insert.sql b/install/insert.sql index 80ab5a844..b4b7a764f 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -1193,7 +1193,6 @@ INSERT INTO `order_status_i18n` (`id`, `locale`, `title`, `description`, `chapo` (5, 'en_US', 'Canceled', '', '', ''), (5, 'fr_FR', 'Annulée', '', '', ''); - /** generated with command : php Thelia thelia:generate-resources --output sql */ @@ -1220,4 +1219,55 @@ INSERT INTO resource (`id`, `code`, `created_at`, `updated_at`) VALUES (NULL, 'admin.configuration.profile', NOW(), NOW()), (NULL, 'admin.configuration.shipping-zone', NOW(), NOW()), (NULL, 'admin.configuration.tax', NOW(), NOW()), -(NULL, 'admin.configuration.template', NOW(), NOW()) +(NULL, 'admin.configuration.template', NOW(), NOW()); + +/** +generated with command : php Thelia thelia:generate-resources --output sql-i18n + */ +INSERT INTO resource_i18n (`id`, `locale`, `title`) VALUES +(1, 'en_US', 'Address'), +(1, 'fr_FR', 'Address'), +(2, 'en_US', 'Configuration / Admin'), +(2, 'fr_FR', 'Configuration / Admin'), +(3, 'en_US', 'Configuration / Area'), +(3, 'fr_FR', 'Configuration / Area'), +(4, 'en_US', 'Configuration / Attribute'), +(4, 'fr_FR', 'Configuration / Attribute'), +(5, 'en_US', 'Category'), +(5, 'fr_FR', 'Category'), +(6, 'en_US', 'Configuration'), +(6, 'fr_FR', 'Configuration'), +(7, 'en_US', 'Content'), +(7, 'fr_FR', 'Content'), +(8, 'en_US', 'Configuration / Country'), +(8, 'fr_FR', 'Configuration / Country'), +(9, 'en_US', 'Coupon'), +(9, 'fr_FR', 'Coupon'), +(10, 'en_US', 'Configuration / Currency'), +(10, 'fr_FR', 'Configuration / Currency'), +(11, 'en_US', 'Customer'), +(11, 'fr_FR', 'Customer'), +(12, 'en_US', 'Configuration / Feature'), +(12, 'fr_FR', 'Configuration / Feature'), +(13, 'en_US', 'Folder'), +(13, 'fr_FR', 'Folder'), +(14, 'en_US', 'Configuration / Language'), +(14, 'fr_FR', 'Configuration / Language'), +(15, 'en_US', 'Configuration / Mailing-system'), +(15, 'fr_FR', 'Configuration / Mailing-system'), +(16, 'en_US', 'Configuration / Message'), +(16, 'fr_FR', 'Configuration / Message'), +(17, 'en_US', 'Configuration / Module'), +(17, 'fr_FR', 'Configuration / Module'), +(18, 'en_US', 'Order'), +(18, 'fr_FR', 'Order'), +(19, 'en_US', 'Product'), +(19, 'fr_FR', 'Product'), +(20, 'en_US', 'Configuration / Profile'), +(20, 'fr_FR', 'Configuration / Profile'), +(21, 'en_US', 'Configuration / Shipping-zone'), +(21, 'fr_FR', 'Configuration / Shipping-zone'), +(22, 'en_US', 'Configuration / Tax'), +(22, 'fr_FR', 'Configuration / Tax'), +(23, 'en_US', 'Configuration / Template'), +(23, 'fr_FR', 'Configuration / Template'); diff --git a/templates/admin/default/profile-edit.html b/templates/admin/default/profile-edit.html index db3cbd0e2..92a88efe2 100644 --- a/templates/admin/default/profile-edit.html +++ b/templates/admin/default/profile-edit.html @@ -118,111 +118,60 @@
-
- {intl l="Manage permissions"} -
-{* -
- -
- - -
-
- -

{intl l="Countries that have the same profile"} :

-

- - {$matchedCountries.first=$asked_country} - - {loop type="profile-country" name="same-country-list" profile=$ID ask="countries" country=$asked_country} - {$matchedCountries[]=$COUNTRY} - {$COUNTRY_TITLE} - {/loop} - - {elseloop rel="same-country-list"} - {intl l="NONE"} - {/elseloop} -

- - -
-
- -
-
-

{intl l="Manage the profile taxes appliance order"}

-
-
- {assign lastPosition 0} - {loop type="profile-country" name="existing-tax-list" profile=$ID country=$asked_country} - {if $POSITION != $lastPosition} - {assign lastPosition $POSITION} - {if $LOOP_COUNT > 1} -
- {/if} -
-

- - {intl l="Add tax to this group"} -

- {/if} - -
{$TAX_TITLE}
- - {if $LOOP_COUNT == $LOOP_TOTAL} -
- {/if} - {/loop} - - {elseloop rel="existing-tax-list"} -
-

- - {intl l="Add tax to this group"} -

+ + + + + + + + + + + + + + + + + {loop type="resource" name="resource-list" profile=$ID backend_context="1"} + + + + + + + + + {/loop} + + + + + + +
+ {intl l="Manage permissions"} +
{intl l="Resource"}{intl l="Title"}{intl l="Rights"}
{intl l="View"}{intl l="Create"}{intl l="Update"}{intl l="Delete"}
{$CODE}{$TITLE} +
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+ +
- {/elseloop} - -
- -
- - {intl l="Apply"} - -
-
- -
-
-

Available taxes

-
-
- {loop type="tax" name="tax-list" exclude_profile=$ID country=$asked_country} -
{$TITLE}
- {/loop} -
- -
- -
- - *}
@@ -235,60 +184,6 @@
-{* Confirmation dialog *} - {*form name="thelia.admin.profile.taxlistupdate"} - - {if $form_error_message} - {$taxUpdateError = true} - {else} - {$taxUpdateError = false} - {/if} - - {* Capture the dialog body, to pass it to the generic dialog *} - {*capture "tax_list_update_dialog"} - - - - - {form_hidden_fields form=$form} - - {form_field form=$form field='country_list'} - -

{intl l="Profile taxes will be update for the following countries :"}

-
-
- - - - -
-
- - {/form_field} - - {/capture} - - {include - file = "includes/generic-create-dialog.html" - - dialog_id = "tax_list_update_dialog" - dialog_title = {intl l="Update profile taxes"} - dialog_body = {$smarty.capture.tax_list_update_dialog nofilter} - - dialog_ok_label = {intl l="Edit profile taxes"} - dialog_cancel_label = {intl l="Cancel"} - - form_action = {url path="/admin/configuration/profiles/saveTaxes"} - form_enctype = {form_enctype form=$form} - form_error_message = $form_error_message - } - - {/form*} - {/block} {block name="javascript-initialization"} @@ -297,6 +192,10 @@ {/javascripts} + {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + {/javascripts} + {javascripts file='assets/js/main.js'} {/javascripts} From ddd8c4f7a56ccf3e3122d6232a8ec2cc80c261b3 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 22 Oct 2013 15:57:31 +0200 Subject: [PATCH 19/22] fix auth loop --- core/lib/Thelia/Core/Template/Loop/Auth.php | 4 +-- templates/admin/default/admin-layout.tpl | 18 +++++----- .../default/ajax/product-related-tab.html | 6 ++-- .../default/ajax/template-attribute-list.html | 2 +- .../default/ajax/template-feature-list.html | 2 +- templates/admin/default/attribute-edit.html | 4 +-- templates/admin/default/attributes.html | 10 +++--- templates/admin/default/categories.html | 16 ++++----- templates/admin/default/category-edit.html | 2 +- templates/admin/default/configuration.html | 34 +++++++++---------- templates/admin/default/countries.html | 6 ++-- templates/admin/default/currencies.html | 8 ++--- templates/admin/default/customers.html | 8 ++--- templates/admin/default/feature-edit.html | 4 +-- templates/admin/default/features.html | 10 +++--- templates/admin/default/folder-edit.html | 2 +- templates/admin/default/folders.html | 16 ++++----- .../includes/content-folder-management.html | 2 +- .../admin/default/includes/module-block.html | 6 ++-- .../default/includes/product-details-tab.html | 2 +- templates/admin/default/languages.html | 2 +- templates/admin/default/messages.html | 8 ++--- templates/admin/default/modules.html | 2 +- templates/admin/default/orders.html | 2 +- templates/admin/default/profiles.html | 6 ++-- .../admin/default/shipping-configuration.html | 6 ++-- templates/admin/default/shipping-zones.html | 2 +- templates/admin/default/taxes-rules.html | 12 +++---- templates/admin/default/templates.html | 8 ++--- templates/admin/default/variables.html | 8 ++--- 30 files changed, 109 insertions(+), 109 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Auth.php b/core/lib/Thelia/Core/Template/Loop/Auth.php index f5691cbd6..a30eeacf0 100755 --- a/core/lib/Thelia/Core/Template/Loop/Auth.php +++ b/core/lib/Thelia/Core/Template/Loop/Auth.php @@ -45,7 +45,7 @@ class Auth extends BaseLoop { return new ArgumentCollection( new Argument( - 'roles', + 'role', new TypeCollection( new AlphaNumStringListType() ), @@ -75,7 +75,7 @@ class Auth extends BaseLoop */ public function exec(&$pagination) { - $roles = $this->getRoles(); + $roles = $this->getRole(); $resource = $this->getResource(); $access = $this->getAccess(); diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index 743264d7a..3d671ecb2 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -44,7 +44,7 @@ {* display top bar only if admin is connected *} - {loop name="top-bar-auth" type="auth" roles="ADMIN"} + {loop name="top-bar-auth" type="auth" role="ADMIN"} {* -- Brand bar section ------------------------------------------------- *} @@ -107,13 +107,13 @@ {intl l="Home"} - {loop name="menu-auth-customer" type="auth" roles="ADMIN" permissions="admin.customers.view"} + {loop name="menu-auth-customer" type="auth" role="ADMIN" resource="admin.customer" access="VIEW"}
  • {intl l="Customers"}
  • {/loop} - {loop name="menu-auth-order" type="auth" roles="ADMIN" permissions="admin.orders.view"} + {loop name="menu-auth-order" type="auth" role="ADMIN" resource="admin.order" access="VIEW"} {/loop} - {loop name="menu-auth-catalog" type="auth" roles="ADMIN" permissions="admin.catalog.view"} + {loop name="menu-auth-catalog" type="auth" role="ADMIN" resource="admin.category" access="VIEW"}
  • {intl l="Catalog"}
  • {/loop} - {loop name="menu-auth-content" type="auth" roles="ADMIN" permissions="admin.folders.view"} + {loop name="menu-auth-content" type="auth" role="ADMIN" resource="admin.folder" access="VIEW"}
  • {intl l="Folders"}
  • {/loop} - {loop name="menu-auth-coupon" type="auth" roles="ADMIN" permissions="admin.coupon.view"} + {loop name="menu-auth-coupon" type="auth" role="ADMIN" resource="admin.coupon" access="VIEW"}
  • {intl l="Coupons"}
  • {/loop} - {loop name="menu-auth-config" type="auth" roles="ADMIN" permissions="admin.config.view"} + {loop name="menu-auth-config" type="auth" role="ADMIN" resource="admin.config" access="VIEW"}
  • {intl l="Configuration"}
  • {/loop} - {loop name="menu-auth-modules" type="auth" roles="ADMIN" permissions="admin.modules.view"} + {loop name="menu-auth-modules" type="auth" role="ADMIN" resource="admin.module" access="VIEW"}
  • {intl l="Modules"}
  • @@ -174,7 +174,7 @@ {/loop} - {loop name="top-bar-search" type="auth" roles="ADMIN" permissions="admin.search"} + {loop name="top-bar-search" type="auth" role="ADMIN" resource="admin.search" access="VIEW"}