From 5d8977be9dd5b6ea4f0ebf5a8914f27c0d29d603 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 9 Jul 2013 12:02:42 +0200 Subject: [PATCH 01/36] change hour format --- core/lib/Thelia/Tests/Log/TlogTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Tests/Log/TlogTest.php b/core/lib/Thelia/Tests/Log/TlogTest.php index bde1cdb39..240a9b0cf 100755 --- a/core/lib/Thelia/Tests/Log/TlogTest.php +++ b/core/lib/Thelia/Tests/Log/TlogTest.php @@ -30,7 +30,7 @@ class TlogTest extends \PHPUnit_Framework_TestCase protected static $logger; //protected $regex = "/(\\d)(:)(\\s+)(%s)(\\s+)(\\[.*?\\])(\\s+)(\\{.*?\\})(\\s+)(\\d{4})(-)(\\d{2})(-)(\\d{2})(\\s+)(\\d{2})(:)(\\d{2})(:)(\\d{2})(:)(\\s+)(%s)([\n])/is"; - protected $regex = "/[0-9]+:[\s](%s)+[\s]\[[a-zA-Z\.]+:[a-zA-Z]+\(\)\][\s]\{[0-9]+\}[\s][0-9]{4}-[0-9]{2}-[0-9]{2}[\s][0-9]{2}:[0-9]{2}:[0-9]{2}:[\s](%s).*$/is"; + protected $regex = "/[0-9]+:[\s](%s)+[\s]\[[a-zA-Z\.]+:[a-zA-Z]+\(\)\][\s]\{[0-9]+\}[\s][0-9]{4}-[0-9]{2}-[0-9]{2}[\s][0-9]{1,2}:[0-9]{2}:[0-9]{2}:[\s](%s).*$/is"; public static function setUpBeforeClass() { From b45ebd88c531067729944f7b2d61c6db8abc47a7 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 9 Jul 2013 14:21:48 +0200 Subject: [PATCH 02/36] complete readme --- Readme.md | 3 ++- core/lib/Thelia/Tests/Log/TlogTest.php | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index b6c0945d0..791b61d1e 100755 --- a/Readme.md +++ b/Readme.md @@ -1,8 +1,9 @@ Readme ====== -Thelia +Thelia ------ +[![Build Status](https://travis-ci.org/thelia/thelia.png?branch=master)](https://travis-ci.org/thelia/thelia) Thelia is an open source tool for creating e-business websites and managing online content. This software is published under GPL. diff --git a/core/lib/Thelia/Tests/Log/TlogTest.php b/core/lib/Thelia/Tests/Log/TlogTest.php index 240a9b0cf..eabc18338 100755 --- a/core/lib/Thelia/Tests/Log/TlogTest.php +++ b/core/lib/Thelia/Tests/Log/TlogTest.php @@ -29,7 +29,6 @@ class TlogTest extends \PHPUnit_Framework_TestCase { protected static $logger; - //protected $regex = "/(\\d)(:)(\\s+)(%s)(\\s+)(\\[.*?\\])(\\s+)(\\{.*?\\})(\\s+)(\\d{4})(-)(\\d{2})(-)(\\d{2})(\\s+)(\\d{2})(:)(\\d{2})(:)(\\d{2})(:)(\\s+)(%s)([\n])/is"; protected $regex = "/[0-9]+:[\s](%s)+[\s]\[[a-zA-Z\.]+:[a-zA-Z]+\(\)\][\s]\{[0-9]+\}[\s][0-9]{4}-[0-9]{2}-[0-9]{2}[\s][0-9]{1,2}:[0-9]{2}:[0-9]{2}:[\s](%s).*$/is"; public static function setUpBeforeClass() From 0c1c4b1822725ee84ac161a3bcdf84849b3a42f6 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 10 Jul 2013 10:34:13 +0200 Subject: [PATCH 03/36] change default locale to en_US --- composer.json | 2 +- composer.lock | 30 +++--- .../Model/Map/AttributeAvI18nTableMap.php | 2 +- .../Thelia/Model/Map/AttributeAvTableMap.php | 2 +- .../Model/Map/AttributeI18nTableMap.php | 2 +- .../Thelia/Model/Map/AttributeTableMap.php | 2 +- .../Thelia/Model/Map/CategoryI18nTableMap.php | 2 +- .../lib/Thelia/Model/Map/CategoryTableMap.php | 2 +- .../Thelia/Model/Map/ConfigI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ConfigTableMap.php | 2 +- .../Thelia/Model/Map/ContentI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ContentTableMap.php | 2 +- .../Thelia/Model/Map/CountryI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/CountryTableMap.php | 2 +- .../Model/Map/CustomerTitleI18nTableMap.php | 2 +- .../Model/Map/CustomerTitleTableMap.php | 2 +- .../Thelia/Model/Map/DocumentI18nTableMap.php | 2 +- .../lib/Thelia/Model/Map/DocumentTableMap.php | 2 +- .../Model/Map/FeatureAvI18nTableMap.php | 2 +- .../Thelia/Model/Map/FeatureAvTableMap.php | 2 +- .../Thelia/Model/Map/FeatureI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/FeatureTableMap.php | 2 +- .../Thelia/Model/Map/FolderI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/FolderTableMap.php | 2 +- .../Thelia/Model/Map/GroupI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/GroupTableMap.php | 2 +- .../Thelia/Model/Map/ImageI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ImageTableMap.php | 2 +- .../Thelia/Model/Map/MessageI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/MessageTableMap.php | 2 +- .../Thelia/Model/Map/ModuleI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ModuleTableMap.php | 2 +- .../Model/Map/OrderStatusI18nTableMap.php | 2 +- .../Thelia/Model/Map/OrderStatusTableMap.php | 2 +- .../Thelia/Model/Map/ProductI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ProductTableMap.php | 2 +- .../Thelia/Model/Map/ResourceI18nTableMap.php | 2 +- .../lib/Thelia/Model/Map/ResourceTableMap.php | 2 +- core/lib/Thelia/Model/Map/TaxI18nTableMap.php | 2 +- .../Thelia/Model/Map/TaxRuleI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/TaxRuleTableMap.php | 2 +- core/lib/Thelia/Model/Map/TaxTableMap.php | 2 +- local/config/schema.xml | 102 +++++++++--------- 43 files changed, 107 insertions(+), 107 deletions(-) diff --git a/composer.json b/composer.json index 31739057b..04b020c18 100755 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "php": ">=5.4", "ezyang/htmlpurifier": "dev-master", "ircmaxell/password-compat": "dev-master", - "propel/propel": "2.0.0-alpha1", + "propel/propel": "dev-master", "psr/log" : "1.0", "symfony/class-loader": "2.2.*", "symfony/config" : "2.2.*", diff --git a/composer.lock b/composer.lock index 22158aa3c..455d88ca9 100755 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "449a98ad751df49842394b9e47f3f447", + "hash": "af923b61425810eacdb86a41df529feb", "packages": [ { "name": "ezyang/htmlpurifier", @@ -202,30 +202,30 @@ }, { "name": "propel/propel", - "version": "2.0.0-alpha1", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/propelorm/Propel2.git", - "reference": "2.0.0-alpha1" + "reference": "1781303780ee496eadebedcb8c4636e728b6ea65" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/propelorm/Propel2/zipball/2.0.0-alpha1", - "reference": "2.0.0-alpha1", + "url": "https://api.github.com/repos/propelorm/Propel2/zipball/1781303780ee496eadebedcb8c4636e728b6ea65", + "reference": "1781303780ee496eadebedcb8c4636e728b6ea65", "shasum": "" }, "require": { "php": ">=5.4", - "psr/log": ">=1.0,<2.0", - "symfony/console": ">=2.2,<3.0", - "symfony/filesystem": ">=2.2,<3.0", - "symfony/finder": ">=2.2,<3.0", - "symfony/validator": ">=2.2,<3.0", - "symfony/yaml": ">=2.2,<3.0" + "psr/log": "~1.0", + "symfony/console": "~2.2", + "symfony/filesystem": "~2.2", + "symfony/finder": "~2.2", + "symfony/validator": "~2.2", + "symfony/yaml": "~2.2" }, "require-dev": { - "behat/behat": ">=2.4,<3.0", - "monolog/monolog": ">=1.3,<2.0", + "behat/behat": "~2.4", + "monolog/monolog": "~1.3", "phpunit/phpunit": "3.7.*" }, "suggest": { @@ -258,7 +258,7 @@ "orm", "persistence" ], - "time": "2013-06-05 06:46:14" + "time": "2013-07-05 09:02:18" }, { "name": "psr/log", @@ -1979,7 +1979,7 @@ "stability-flags": { "ezyang/htmlpurifier": 20, "ircmaxell/password-compat": 20, - "propel/propel": 15, + "propel/propel": 20, "kriswallsmith/assetic": 20, "leafo/lessphp": 20, "ptachoire/cssembed": 20, diff --git a/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php b/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php index 14fc79eeb..02a20540e 100755 --- a/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php @@ -151,7 +151,7 @@ class AttributeAvI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_av', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/AttributeAvTableMap.php b/core/lib/Thelia/Model/Map/AttributeAvTableMap.php index 138f0fa9c..0c5c2e1c9 100755 --- a/core/lib/Thelia/Model/Map/AttributeAvTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeAvTableMap.php @@ -106,7 +106,7 @@ class AttributeAvTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php b/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php index b60cae5b8..8471d3e26 100755 --- a/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php @@ -151,7 +151,7 @@ class AttributeI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/AttributeTableMap.php b/core/lib/Thelia/Model/Map/AttributeTableMap.php index dca811cbc..773e13cab 100755 --- a/core/lib/Thelia/Model/Map/AttributeTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeTableMap.php @@ -101,7 +101,7 @@ class AttributeTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php index 1611b2ebf..8c52aa7b2 100755 --- a/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php @@ -151,7 +151,7 @@ class CategoryI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/CategoryTableMap.php b/core/lib/Thelia/Model/Map/CategoryTableMap.php index 83010e4fa..a301a5efe 100755 --- a/core/lib/Thelia/Model/Map/CategoryTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryTableMap.php @@ -131,7 +131,7 @@ class CategoryTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php b/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php index a83f87b76..b953b0ac9 100755 --- a/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php @@ -151,7 +151,7 @@ class ConfigI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'config', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ConfigTableMap.php b/core/lib/Thelia/Model/Map/ConfigTableMap.php index 8bd68a964..ebd5d6edf 100755 --- a/core/lib/Thelia/Model/Map/ConfigTableMap.php +++ b/core/lib/Thelia/Model/Map/ConfigTableMap.php @@ -116,7 +116,7 @@ class ConfigTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ContentI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php index ee9122a6c..f718623b0 100755 --- a/core/lib/Thelia/Model/Map/ContentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php @@ -151,7 +151,7 @@ class ContentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ContentTableMap.php b/core/lib/Thelia/Model/Map/ContentTableMap.php index 60b04ae36..b794c7244 100755 --- a/core/lib/Thelia/Model/Map/ContentTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentTableMap.php @@ -121,7 +121,7 @@ class ContentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CountryI18nTableMap.php b/core/lib/Thelia/Model/Map/CountryI18nTableMap.php index cc60b09d2..272231464 100755 --- a/core/lib/Thelia/Model/Map/CountryI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CountryI18nTableMap.php @@ -151,7 +151,7 @@ class CountryI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'country', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/CountryTableMap.php b/core/lib/Thelia/Model/Map/CountryTableMap.php index c4b96c8bd..3060da70f 100755 --- a/core/lib/Thelia/Model/Map/CountryTableMap.php +++ b/core/lib/Thelia/Model/Map/CountryTableMap.php @@ -116,7 +116,7 @@ class CountryTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php index d403756fa..5344099c5 100755 --- a/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php @@ -141,7 +141,7 @@ class CustomerTitleI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'customer_title', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('SHORT', 'Short', 'VARCHAR', false, 10, null); $this->addColumn('LONG', 'Long', 'VARCHAR', false, 45, null); } // initialize() diff --git a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php index a392ee4dd..8e91631cf 100755 --- a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php @@ -106,7 +106,7 @@ class CustomerTitleTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php index d0356e8c6..70314ea02 100755 --- a/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php @@ -151,7 +151,7 @@ class DocumentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'document', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/DocumentTableMap.php b/core/lib/Thelia/Model/Map/DocumentTableMap.php index 50bb37b95..d53263a06 100755 --- a/core/lib/Thelia/Model/Map/DocumentTableMap.php +++ b/core/lib/Thelia/Model/Map/DocumentTableMap.php @@ -126,7 +126,7 @@ class DocumentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php index b3114e7ba..ba592b4b0 100755 --- a/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php @@ -151,7 +151,7 @@ class FeatureAvI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_av', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FeatureAvTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvTableMap.php index f447f8dc5..972a25744 100755 --- a/core/lib/Thelia/Model/Map/FeatureAvTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureAvTableMap.php @@ -101,7 +101,7 @@ class FeatureAvTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php index af0dfc263..dba05fb67 100755 --- a/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php @@ -151,7 +151,7 @@ class FeatureI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FeatureTableMap.php b/core/lib/Thelia/Model/Map/FeatureTableMap.php index 8d851559e..b1f309603 100755 --- a/core/lib/Thelia/Model/Map/FeatureTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureTableMap.php @@ -106,7 +106,7 @@ class FeatureTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FolderI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php index fc85b17ec..d10344811 100755 --- a/core/lib/Thelia/Model/Map/FolderI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php @@ -151,7 +151,7 @@ class FolderI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FolderTableMap.php b/core/lib/Thelia/Model/Map/FolderTableMap.php index 794e3691c..c26e23dc8 100755 --- a/core/lib/Thelia/Model/Map/FolderTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderTableMap.php @@ -131,7 +131,7 @@ class FolderTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/GroupI18nTableMap.php b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php index 585127821..57788593a 100755 --- a/core/lib/Thelia/Model/Map/GroupI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php @@ -151,7 +151,7 @@ class GroupI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'group', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/GroupTableMap.php b/core/lib/Thelia/Model/Map/GroupTableMap.php index a8c830005..881a2fa84 100755 --- a/core/lib/Thelia/Model/Map/GroupTableMap.php +++ b/core/lib/Thelia/Model/Map/GroupTableMap.php @@ -101,7 +101,7 @@ class GroupTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ImageI18nTableMap.php b/core/lib/Thelia/Model/Map/ImageI18nTableMap.php index 4f3b197a6..a78e7667c 100755 --- a/core/lib/Thelia/Model/Map/ImageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ImageI18nTableMap.php @@ -151,7 +151,7 @@ class ImageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'image', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ImageTableMap.php b/core/lib/Thelia/Model/Map/ImageTableMap.php index 0f8d82b20..c49f24527 100755 --- a/core/lib/Thelia/Model/Map/ImageTableMap.php +++ b/core/lib/Thelia/Model/Map/ImageTableMap.php @@ -126,7 +126,7 @@ class ImageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/MessageI18nTableMap.php b/core/lib/Thelia/Model/Map/MessageI18nTableMap.php index f084515c0..bb9bfdd2e 100755 --- a/core/lib/Thelia/Model/Map/MessageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/MessageI18nTableMap.php @@ -146,7 +146,7 @@ class MessageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'message', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'LONGVARCHAR', false, null, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('DESCRIPTION_HTML', 'DescriptionHtml', 'CLOB', false, null, null); diff --git a/core/lib/Thelia/Model/Map/MessageTableMap.php b/core/lib/Thelia/Model/Map/MessageTableMap.php index de2a205f9..392dac824 100755 --- a/core/lib/Thelia/Model/Map/MessageTableMap.php +++ b/core/lib/Thelia/Model/Map/MessageTableMap.php @@ -126,7 +126,7 @@ class MessageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php b/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php index 67b7a34ef..a8e680f1c 100755 --- a/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php @@ -151,7 +151,7 @@ class ModuleI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'module', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ModuleTableMap.php b/core/lib/Thelia/Model/Map/ModuleTableMap.php index 5370c1da1..cccaa890a 100755 --- a/core/lib/Thelia/Model/Map/ModuleTableMap.php +++ b/core/lib/Thelia/Model/Map/ModuleTableMap.php @@ -116,7 +116,7 @@ class ModuleTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php index 5d78c474c..1b2052c2e 100755 --- a/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php @@ -151,7 +151,7 @@ class OrderStatusI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order_status', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php index eecfe5a03..18406d9aa 100755 --- a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php @@ -101,7 +101,7 @@ class OrderStatusTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php index 8da33f15d..79a01514a 100755 --- a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php @@ -151,7 +151,7 @@ class ProductI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php index b009a97af..40200ce10 100755 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -166,7 +166,7 @@ class ProductTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php b/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php index 8a8ce501a..ec22e2fd3 100755 --- a/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php @@ -151,7 +151,7 @@ class ResourceI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'resource', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ResourceTableMap.php b/core/lib/Thelia/Model/Map/ResourceTableMap.php index e56960892..8d7708ddd 100755 --- a/core/lib/Thelia/Model/Map/ResourceTableMap.php +++ b/core/lib/Thelia/Model/Map/ResourceTableMap.php @@ -101,7 +101,7 @@ class ResourceTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php index 2c4c92f4f..a06230c37 100755 --- a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php @@ -141,7 +141,7 @@ class TaxI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); } // initialize() diff --git a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php index 689f30728..1f0ed1e96 100755 --- a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php @@ -131,7 +131,7 @@ class TaxRuleI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); } // initialize() /** diff --git a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php index 9b862de99..cc5f628b9 100755 --- a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php @@ -111,7 +111,7 @@ class TaxRuleTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/TaxTableMap.php b/core/lib/Thelia/Model/Map/TaxTableMap.php index b941e7b52..6d43f20e9 100755 --- a/core/lib/Thelia/Model/Map/TaxTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxTableMap.php @@ -101,7 +101,7 @@ class TaxTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/local/config/schema.xml b/local/config/schema.xml index 8b97f4e8c..cae47a184 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1,6 +1,6 @@ - - + +
@@ -19,7 +19,7 @@
- +
@@ -54,7 +54,7 @@
- +
@@ -71,7 +71,7 @@
- +
@@ -92,7 +92,7 @@
- +
@@ -102,7 +102,7 @@
- +
@@ -110,7 +110,7 @@
- +
@@ -136,7 +136,7 @@
- +
@@ -149,7 +149,7 @@
- +
@@ -167,7 +167,7 @@
- +
@@ -194,7 +194,7 @@
- +
@@ -212,7 +212,7 @@
- +
@@ -224,7 +224,7 @@
- +
@@ -243,12 +243,12 @@
- +
- +
@@ -273,7 +273,7 @@
- +
@@ -293,7 +293,7 @@
- +
@@ -311,7 +311,7 @@
- +
@@ -326,7 +326,7 @@
- +
@@ -360,7 +360,7 @@
- +
@@ -389,7 +389,7 @@
- +
@@ -400,7 +400,7 @@
- +
@@ -409,7 +409,7 @@
- +
@@ -428,7 +428,7 @@
- +
@@ -445,7 +445,7 @@
- +
@@ -471,7 +471,7 @@
- +
@@ -512,7 +512,7 @@
- +
@@ -553,7 +553,7 @@
- +
@@ -602,7 +602,7 @@
- +
@@ -611,7 +611,7 @@
- +
@@ -626,7 +626,7 @@
- +
@@ -645,7 +645,7 @@
- +
@@ -657,7 +657,7 @@
- +
@@ -670,7 +670,7 @@
- +
@@ -688,7 +688,7 @@
- +
@@ -707,13 +707,13 @@
- +
- +
@@ -725,7 +725,7 @@
- +
@@ -740,7 +740,7 @@
- +
@@ -755,7 +755,7 @@
- +
@@ -765,7 +765,7 @@
- +
@@ -783,7 +783,7 @@
- +
@@ -803,7 +803,7 @@
- +
@@ -822,7 +822,7 @@
- +
@@ -839,7 +839,7 @@
- +
@@ -872,7 +872,7 @@
- +
@@ -886,7 +886,7 @@
- +
@@ -900,7 +900,7 @@
- +
@@ -913,7 +913,7 @@
- +
@@ -922,7 +922,7 @@
- +
From 945a97ae784478baea32f5336225457943ad9891 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 11 Jul 2013 10:28:58 +0200 Subject: [PATCH 04/36] initialize module part --- composer.lock | 8 +- .../Thelia/Command/ModuleGenerateCommand.php | 114 ++++++++++++++++++ .../Thelia/Command/Skeleton/Module/Class.php | 36 ++++++ .../Thelia/Command/Skeleton/Module/config.xml | 36 ++++++ .../Thelia/Command/Skeleton/Module/plugin.xml | 0 .../Thelia/Command/Skeleton/Module/schema.xml | 7 ++ core/lib/Thelia/Config/Resources/config.xml | 1 + core/lib/Thelia/Module/BaseModule.php | 43 +++++++ 8 files changed, 241 insertions(+), 4 deletions(-) create mode 100644 core/lib/Thelia/Command/ModuleGenerateCommand.php create mode 100644 core/lib/Thelia/Command/Skeleton/Module/Class.php create mode 100644 core/lib/Thelia/Command/Skeleton/Module/config.xml create mode 100644 core/lib/Thelia/Command/Skeleton/Module/plugin.xml create mode 100644 core/lib/Thelia/Command/Skeleton/Module/schema.xml create mode 100644 core/lib/Thelia/Module/BaseModule.php diff --git a/composer.lock b/composer.lock index 455d88ca9..0e44951da 100755 --- a/composer.lock +++ b/composer.lock @@ -206,12 +206,12 @@ "source": { "type": "git", "url": "https://github.com/propelorm/Propel2.git", - "reference": "1781303780ee496eadebedcb8c4636e728b6ea65" + "reference": "4cf5fca150ed93b33dc54206e3d9d943d0712621" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/propelorm/Propel2/zipball/1781303780ee496eadebedcb8c4636e728b6ea65", - "reference": "1781303780ee496eadebedcb8c4636e728b6ea65", + "url": "https://api.github.com/repos/propelorm/Propel2/zipball/4cf5fca150ed93b33dc54206e3d9d943d0712621", + "reference": "4cf5fca150ed93b33dc54206e3d9d943d0712621", "shasum": "" }, "require": { @@ -258,7 +258,7 @@ "orm", "persistence" ], - "time": "2013-07-05 09:02:18" + "time": "2013-07-10 11:32:06" }, { "name": "psr/log", diff --git a/core/lib/Thelia/Command/ModuleGenerateCommand.php b/core/lib/Thelia/Command/ModuleGenerateCommand.php new file mode 100644 index 000000000..5d54cf55e --- /dev/null +++ b/core/lib/Thelia/Command/ModuleGenerateCommand.php @@ -0,0 +1,114 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Command; + + +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Filesystem\Filesystem; + +class ModuleGenerateCommand extends ContainerAwareCommand { + + protected $module; + protected $moduleDirectory; + + private $reservedKeyWords = array( + "thelia" + ); + + private $neededDirectories = array( + "Config", + "Model", + "Loop" + ); + + protected function configure() + { + $this + ->setName("module:generate") + ->setDescription("generate all needed files for creating a new Module") + ->addArgument( + "name" , + InputArgument::REQUIRED, + "name wanted for your Module" + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->module = $this->formatModuleName($input->getArgument("name")); + $this->moduleDirectory = THELIA_MODULE_DIR . DIRECTORY_SEPARATOR . $this->module; + $this->verifyExistingModule(); + + $this->createDirectories(); + $this->createFiles(); + } + + private function createDirectories() + { + $fs = new Filesystem(); + + $fs->mkdir($this->moduleDirectory); + + foreach ($this->neededDirectories as $directory) { + $fs->mkdir($this->moduleDirectory . DIRECTORY_SEPARATOR . $directory); + } + + } + + private function createFiles() + { + $fs = new Filesystem(); + $skeletonDir = str_replace("/", DIRECTORY_SEPARATOR, THELIA_ROOT . "/core/lib/Thelia/Command/Skeleton/Module/"); + $fs->copy($skeletonDir . "config.xml", $this->moduleDirectory . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.xml"); + $fs->copy($skeletonDir . "plugin.xml", $this->moduleDirectory . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "plugin.xml"); + + $classContent = file_get_contents($skeletonDir . "Class.php"); + + $classContent = str_replace("%%CLASSNAME%%", $this->module, $classContent); + $classContent = str_replace("%%NAMESPACE%%", $this->module, $classContent); + + file_put_contents($this->moduleDirectory . DIRECTORY_SEPARATOR . $this->module.".php", $classContent); + + $schemaContent = file_get_contents($skeletonDir . "schema.xml"); + + $schemaContent = str_replace("%%CONFIG_DIR%%", THELIA_CONF_DIR, $schemaContent); + + file_put_contents($this->moduleDirectory . DIRECTORY_SEPARATOR . "Config". DIRECTORY_SEPARATOR . "schema.xml", $schemaContent); + } + + + private function verifyExistingModule() + { + if (file_exists($this->moduleDirectory)) { + throw new \RuntimeException(sprintf("%s module already exists", $this->module)); + } + } + + private function formatModuleName($name) + { + return ucfirst($name); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Command/Skeleton/Module/Class.php b/core/lib/Thelia/Command/Skeleton/Module/Class.php new file mode 100644 index 000000000..ccf061a48 --- /dev/null +++ b/core/lib/Thelia/Command/Skeleton/Module/Class.php @@ -0,0 +1,36 @@ +. */ +/* */ +/*************************************************************************************/ + + +namespace %%NAMESPACE%%; + +use Thelia\Module\BaseModule; + +class %%CLASSNAME%% extends BaseModule +{ + /** + * YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class + * Like install and destroy + */ + +} diff --git a/core/lib/Thelia/Command/Skeleton/Module/config.xml b/core/lib/Thelia/Command/Skeleton/Module/config.xml new file mode 100644 index 000000000..2430f5027 --- /dev/null +++ b/core/lib/Thelia/Command/Skeleton/Module/config.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/lib/Thelia/Command/Skeleton/Module/plugin.xml b/core/lib/Thelia/Command/Skeleton/Module/plugin.xml new file mode 100644 index 000000000..e69de29bb diff --git a/core/lib/Thelia/Command/Skeleton/Module/schema.xml b/core/lib/Thelia/Command/Skeleton/Module/schema.xml new file mode 100644 index 000000000..1ef803d36 --- /dev/null +++ b/core/lib/Thelia/Command/Skeleton/Module/schema.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index dee0b57b6..e70756adb 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -34,6 +34,7 @@ + diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php new file mode 100644 index 000000000..14777d331 --- /dev/null +++ b/core/lib/Thelia/Module/BaseModule.php @@ -0,0 +1,43 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Module; + +abstract class BaseModule +{ + + public function __construct() + { + + } + + protected function activate() + { + + } + + abstract public function install(); + abstract public function destroy(); + +} \ No newline at end of file From 6baac9e36c96525e1843798315f8ad4ad082feaa Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 11 Jul 2013 11:11:16 +0200 Subject: [PATCH 05/36] create test for module:generate command --- .../Thelia/Command/ModuleGenerateCommand.php | 7 +- .../Thelia/Tests/Command/BaseCommandTest.php | 20 ++++ .../Command/ModuleGenerateCommandTest.php | 108 ++++++++++++++++++ 3 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 core/lib/Thelia/Tests/Command/BaseCommandTest.php create mode 100644 core/lib/Thelia/Tests/Command/ModuleGenerateCommandTest.php diff --git a/core/lib/Thelia/Command/ModuleGenerateCommand.php b/core/lib/Thelia/Command/ModuleGenerateCommand.php index 5d54cf55e..4a31a74ab 100644 --- a/core/lib/Thelia/Command/ModuleGenerateCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateCommand.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Command; @@ -109,6 +109,9 @@ class ModuleGenerateCommand extends ContainerAwareCommand { private function formatModuleName($name) { + if (in_array(strtolower($name), $this->reservedKeyWords)) { + throw new \RuntimeException(sprintf("%s module name is a reserved keyword", $name)); + } return ucfirst($name); } } \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Command/BaseCommandTest.php b/core/lib/Thelia/Tests/Command/BaseCommandTest.php new file mode 100644 index 000000000..ca9d0a632 --- /dev/null +++ b/core/lib/Thelia/Tests/Command/BaseCommandTest.php @@ -0,0 +1,20 @@ +getMock("Symfony\Component\HttpKernel\KernelInterface"); + + return $kernel; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Command/ModuleGenerateCommandTest.php b/core/lib/Thelia/Tests/Command/ModuleGenerateCommandTest.php new file mode 100644 index 000000000..dcbc98fff --- /dev/null +++ b/core/lib/Thelia/Tests/Command/ModuleGenerateCommandTest.php @@ -0,0 +1,108 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Tests\Command; + + +use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\Filesystem\Filesystem; +use Thelia\Core\Application; +use Thelia\Command\ModuleGenerateCommand; + +class ModuleGenerateCommandTest extends BaseCommandTest { + + protected $command; + protected $commandTester; + + public static function clearTest() + { + $fs = new Filesystem(); + + if ($fs->exists(THELIA_MODULE_DIR . "Test")) { + $fs->remove(THELIA_MODULE_DIR . "Test"); + } + } + + public static function setUpBeforeClass() + { + self::clearTest(); + } + + public static function tearDownAfterClass() + { + self::clearTest(); + } + + public function setUp() + { + $application = new Application($this->getKernel()); + + $moduleGenerator = new ModuleGenerateCommand(); + + $application->add($moduleGenerator); + + $this->command = $application->find("module:generate"); + $this->commandTester = new CommandTester($this->command); + + } + + public function testGenerateModule() + { + $tester = $this->commandTester; + + $tester->execute(array( + "command" => $this->command->getName(), + "name" => "test" + )); + + $fs = new Filesystem(); + + $this->assertTrue($fs->exists(THELIA_MODULE_DIR . "Test")); + } + + /** + * @depends testGenerateModule + * @expectedException \RuntimeException + */ + public function testGenerateDuplicateModule() + { + $tester = $this->commandTester; + + $tester->execute(array( + "command" => $this->command->getName(), + "name" => "test" + )); + } + + /** + * @expectedException \RuntimeException + */ + public function testGenerateWithReservedKeyWord() + { + $tester = $this->commandTester; + + $tester->execute(array( + "command" => $this->command->getName(), + "name" => "thelia" + )); + } +} \ No newline at end of file From 6fa815d1743aeaa9b14d8ca118f8539a26c4a347 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 11 Jul 2013 12:54:38 +0200 Subject: [PATCH 06/36] add possibility to render a block on command output --- Thelia | 3 +- .../Thelia/Command/ModuleGenerateCommand.php | 7 ++++ .../Command/Output/TheliaConsoleOutput.php | 36 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 core/lib/Thelia/Command/Output/TheliaConsoleOutput.php diff --git a/Thelia b/Thelia index 2aaa3c3e5..a161b610f 100755 --- a/Thelia +++ b/Thelia @@ -7,6 +7,7 @@ require __DIR__ . '/core/bootstrap.php'; use Thelia\Core\Thelia; use Thelia\Core\Application; +use Thelia\Command\Output\TheliaConsoleOutput; use Symfony\Component\Console\Input\ArgvInput; $input = new ArgvInput(); @@ -15,4 +16,4 @@ $debug = getenv('THELIA_DEBUG') !== '0' && !$input->hasParameterOption(array('-- $thelia = new Thelia($env, $debug); $application = new Application($thelia); -$application->run($input); \ No newline at end of file +$application->run($input, new TheliaConsoleOutput()); \ No newline at end of file diff --git a/core/lib/Thelia/Command/ModuleGenerateCommand.php b/core/lib/Thelia/Command/ModuleGenerateCommand.php index 4a31a74ab..5edcd4d97 100644 --- a/core/lib/Thelia/Command/ModuleGenerateCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateCommand.php @@ -64,6 +64,13 @@ class ModuleGenerateCommand extends ContainerAwareCommand { $this->createDirectories(); $this->createFiles(); + + $output->renderBlock(array( + '', + sprintf("module %s create with success", $this->module), + "You can now configure your module and complete plugin.xml file", + '' + ), "bg=green;fg=black"); } private function createDirectories() diff --git a/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php b/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php new file mode 100644 index 000000000..ad40c6dbd --- /dev/null +++ b/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php @@ -0,0 +1,36 @@ + $length) ? $strlen($message) : $length; + } + $ouput = array(); + foreach ($messages as $message) { + $output[] = "<" . $style . ">" . " " . $message . str_repeat(' ', $length - $strlen($message)) . " "; + } + + $this->writeln($output); + } + +} \ No newline at end of file From 1a7c9b2fd2bd26b996d64275bea585346f55825a Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 11 Jul 2013 15:57:26 +0200 Subject: [PATCH 07/36] fix test issue --- .../lib/Thelia/Command/BaseModuleGenerate.php | 55 +++++++++++++++++++ .../Thelia/Command/ModuleGenerateCommand.php | 41 ++++---------- .../Command/Output/TheliaConsoleOutput.php | 22 +++++++- 3 files changed, 86 insertions(+), 32 deletions(-) create mode 100644 core/lib/Thelia/Command/BaseModuleGenerate.php diff --git a/core/lib/Thelia/Command/BaseModuleGenerate.php b/core/lib/Thelia/Command/BaseModuleGenerate.php new file mode 100644 index 000000000..e160f9dd2 --- /dev/null +++ b/core/lib/Thelia/Command/BaseModuleGenerate.php @@ -0,0 +1,55 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Command; + + + abstract class BaseModuleGenerate extends ContainerAwareCommand { + + protected $module; + protected $moduleDirectory; + + protected $reservedKeyWords = array( + "thelia" + ); + + protected $neededDirectories = array( + "Config", + "Model", + "Loop" + ); + + protected function verifyExistingModule() + { + if (file_exists($this->moduleDirectory)) { + throw new \RuntimeException(sprintf("%s module already exists", $this->module)); + } + } + + protected function formatModuleName($name) + { + if (in_array(strtolower($name), $this->reservedKeyWords)) { + throw new \RuntimeException(sprintf("%s module name is a reserved keyword", $name)); + } + return ucfirst($name); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Command/ModuleGenerateCommand.php b/core/lib/Thelia/Command/ModuleGenerateCommand.php index 5edcd4d97..8329b84e1 100644 --- a/core/lib/Thelia/Command/ModuleGenerateCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateCommand.php @@ -28,20 +28,9 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Filesystem\Filesystem; -class ModuleGenerateCommand extends ContainerAwareCommand { +class ModuleGenerateCommand extends BaseModuleGenerate { - protected $module; - protected $moduleDirectory; - private $reservedKeyWords = array( - "thelia" - ); - - private $neededDirectories = array( - "Config", - "Model", - "Loop" - ); protected function configure() { @@ -64,13 +53,16 @@ class ModuleGenerateCommand extends ContainerAwareCommand { $this->createDirectories(); $this->createFiles(); + if(method_exists($this, "renderBlock")) { + //impossible to change output class in CommandTester... + $output->renderBlock(array( + '', + sprintf("module %s create with success", $this->module), + "You can now configure your module and complete plugin.xml file", + '' + ), "bg=green;fg=black"); + } - $output->renderBlock(array( - '', - sprintf("module %s create with success", $this->module), - "You can now configure your module and complete plugin.xml file", - '' - ), "bg=green;fg=black"); } private function createDirectories() @@ -107,18 +99,5 @@ class ModuleGenerateCommand extends ContainerAwareCommand { } - private function verifyExistingModule() - { - if (file_exists($this->moduleDirectory)) { - throw new \RuntimeException(sprintf("%s module already exists", $this->module)); - } - } - private function formatModuleName($name) - { - if (in_array(strtolower($name), $this->reservedKeyWords)) { - throw new \RuntimeException(sprintf("%s module name is a reserved keyword", $name)); - } - return ucfirst($name); - } } \ No newline at end of file diff --git a/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php b/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php index ad40c6dbd..aa0a8a1e7 100644 --- a/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php +++ b/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php @@ -1,5 +1,25 @@ . */ +/* */ +/*************************************************************************************/ namespace Thelia\Command\Output; From 98589cc2b62aebec43376bae3f241b4ba189d321 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 11 Jul 2013 16:44:18 +0200 Subject: [PATCH 08/36] generate Model using Propel command in Thelia app --- core/bootstrap.php | 1 + .../lib/Thelia/Command/BaseModuleGenerate.php | 10 ++- .../Command/ModuleGenerateModelCommand.php | 88 +++++++++++++++++++ core/lib/Thelia/Config/Resources/config.xml | 1 + 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 core/lib/Thelia/Command/ModuleGenerateModelCommand.php diff --git a/core/bootstrap.php b/core/bootstrap.php index fd0dd80e9..8b53e72e5 100755 --- a/core/bootstrap.php +++ b/core/bootstrap.php @@ -11,6 +11,7 @@ define('THELIA_CONF_DIR' , THELIA_LOCAL_DIR . 'config/'); define('THELIA_MODULE_DIR' , THELIA_LOCAL_DIR . 'modules/'); define('THELIA_WEB_DIR' , THELIA_ROOT . '/web/'); define('THELIA_TEMPLATE_DIR' , THELIA_ROOT . '/templates/'); +define('DS', DIRECTORY_SEPARATOR); $loader = require __DIR__ . "/vendor/autoload.php"; diff --git a/core/lib/Thelia/Command/BaseModuleGenerate.php b/core/lib/Thelia/Command/BaseModuleGenerate.php index e160f9dd2..50938587d 100644 --- a/core/lib/Thelia/Command/BaseModuleGenerate.php +++ b/core/lib/Thelia/Command/BaseModuleGenerate.php @@ -22,8 +22,11 @@ /*************************************************************************************/ namespace Thelia\Command; +use Propel\Runtime\Propel; +use Symfony\Component\Console\Application; - abstract class BaseModuleGenerate extends ContainerAwareCommand { + +abstract class BaseModuleGenerate extends ContainerAwareCommand { protected $module; protected $moduleDirectory; @@ -52,4 +55,9 @@ namespace Thelia\Command; } return ucfirst($name); } + + protected function getPropelApplication() + { + return new Application("Propel", Propel::VERSION); + } } \ No newline at end of file diff --git a/core/lib/Thelia/Command/ModuleGenerateModelCommand.php b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php new file mode 100644 index 000000000..a29002b82 --- /dev/null +++ b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php @@ -0,0 +1,88 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Command; + + +use Propel\Generator\Command\ModelBuildCommand; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Output\StreamOutput; +use Symfony\Component\Filesystem\Filesystem; + +class ModuleGenerateModelCommand extends BaseModuleGenerate { + + protected function configure() + { + $this + ->setName("module:generate:model") + ->setDescription("generate model for a specific module") + ->addArgument( + "name", + InputArgument::REQUIRED, + "module name" + ) + ; + + } + + public function execute(InputInterface $input, OutputInterface $output) + { + $this->module = $this->formatModuleName($input->getArgument("name")); + $this->moduleDirectory = THELIA_MODULE_DIR . DS . $this->module; + + $fs = new Filesystem(); + + if ($fs->exists($this->moduleDirectory) === false) { + throw new \RuntimeException(sprintf("%s module does not exists")); + } + + if ($fs->exists($this->moduleDirectory . DS . "Config" . DS . "schema.xml") === false) { + throw new \RuntimeException("schema.xml not found in Config directory. Needed file for generating model"); + } + + + $propelApp = $this->getPropelApplication(); + + $moduleBuildPropel = new ModelBuildCommand(); + $moduleBuildPropel->setApplication($propelApp); + + $moduleBuildPropel->run( + new ArrayInput(array( + "command" => $moduleBuildPropel->getName(), + "--output-dir" => THELIA_MODULE_DIR, + "--input-dir" => $this->moduleDirectory . DS ."Config" + )), + new StreamOutput(fopen('php://memory', 'w', false)) + ); + + if ($fs->exists(THELIA_MODULE_DIR . DS . "Thelia")) { + $fs->remove(THELIA_MODULE_DIR . DS . "Thelia"); + } + + + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index e70756adb..c3efac45d 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -35,6 +35,7 @@ + From 3c18acb3fc210341a02958665e2a2517357c8a3d Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 11 Jul 2013 16:49:21 +0200 Subject: [PATCH 09/36] don't needed to call Propel Application --- core/lib/Thelia/Command/BaseModuleGenerate.php | 5 ----- core/lib/Thelia/Command/ModuleGenerateModelCommand.php | 4 +--- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/core/lib/Thelia/Command/BaseModuleGenerate.php b/core/lib/Thelia/Command/BaseModuleGenerate.php index 50938587d..420563c40 100644 --- a/core/lib/Thelia/Command/BaseModuleGenerate.php +++ b/core/lib/Thelia/Command/BaseModuleGenerate.php @@ -55,9 +55,4 @@ abstract class BaseModuleGenerate extends ContainerAwareCommand { } return ucfirst($name); } - - protected function getPropelApplication() - { - return new Application("Propel", Propel::VERSION); - } } \ No newline at end of file diff --git a/core/lib/Thelia/Command/ModuleGenerateModelCommand.php b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php index a29002b82..fd87fa48d 100644 --- a/core/lib/Thelia/Command/ModuleGenerateModelCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php @@ -64,10 +64,8 @@ class ModuleGenerateModelCommand extends BaseModuleGenerate { } - $propelApp = $this->getPropelApplication(); - $moduleBuildPropel = new ModelBuildCommand(); - $moduleBuildPropel->setApplication($propelApp); + $moduleBuildPropel->setApplication($this->getApplication()); $moduleBuildPropel->run( new ArrayInput(array( From 2d13a28fbfb224ea25ed178af83decadcea9558a Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 11 Jul 2013 17:06:12 +0200 Subject: [PATCH 10/36] create command for generating sql from mosule schema --- .../Command/ModuleGenerateSqlCommand.php | 77 +++++++++++++++++++ core/lib/Thelia/Config/Resources/config.xml | 1 + 2 files changed, 78 insertions(+) create mode 100644 core/lib/Thelia/Command/ModuleGenerateSqlCommand.php diff --git a/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php b/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php new file mode 100644 index 000000000..113e3288f --- /dev/null +++ b/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php @@ -0,0 +1,77 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Command; + + +use Propel\Generator\Command\SqlBuildCommand; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Output\StreamOutput; +use Symfony\Component\Filesystem\Filesystem; + +class ModuleGenerateSqlCommand extends BaseModuleGenerate { + + public function configure() + { + $this + ->setName("module:generate:sql") + ->setDescription("Generate the sql from schema.xml file") + ->addArgument( + "name", + InputArgument::REQUIRED, + "Module name" + ) + ; + } + + public function execute(InputInterface $input, OutputInterface $output) + { + $this->module = $this->formatModuleName($input->getArgument("name")); + $this->moduleDirectory = THELIA_MODULE_DIR . DS . $this->module; + + $fs = new Filesystem(); + + if ($fs->exists($this->moduleDirectory) === false) { + throw new \RuntimeException(sprintf("%s module does not exists")); + } + + if ($fs->exists($this->moduleDirectory . DS . "Config" . DS . "schema.xml") === false) { + throw new \RuntimeException("schema.xml not found in Config directory. Needed file for generating model"); + } + + $sqlBuild = new SqlBuildCommand(); + $sqlBuild->setApplication($this->getApplication()); + + $sqlBuild->run( + new ArrayInput(array( + "command" => $sqlBuild->getName(), + "--output-dir" => $this->moduleDirectory . DS ."Config", + "--input-dir" => $this->moduleDirectory . DS ."Config" + )), + new StreamOutput(fopen('php://memory', 'w', false)) + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index c3efac45d..2ef8585ef 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -36,6 +36,7 @@ + From ac170ac25f4a84fbdbd216c63715cf8b972fc34c Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 11 Jul 2013 17:15:32 +0200 Subject: [PATCH 11/36] generate sql from generat model command --- .../Command/ModuleGenerateModelCommand.php | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Command/ModuleGenerateModelCommand.php b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php index fd87fa48d..41638414e 100644 --- a/core/lib/Thelia/Command/ModuleGenerateModelCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php @@ -28,6 +28,7 @@ use Propel\Generator\Command\ModelBuildCommand; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\StreamOutput; use Symfony\Component\Filesystem\Filesystem; @@ -44,6 +45,12 @@ class ModuleGenerateModelCommand extends BaseModuleGenerate { InputArgument::REQUIRED, "module name" ) + ->addOption( + "generate-sql", + null, + InputOption::VALUE_NONE, + "with this option generate sql file at the same time" + ) ; } @@ -63,7 +70,30 @@ class ModuleGenerateModelCommand extends BaseModuleGenerate { throw new \RuntimeException("schema.xml not found in Config directory. Needed file for generating model"); } + $this->generateModel(); + if ($input->getOption("generate-sql")) { + $this->generateSql(); + } + } + + protected function generateSql() + { + $sqlBuild = new ModuleGenerateSqlCommand(); + $sqlBuild->setApplication($this->getApplication()); + + $sqlBuild->run( + new ArrayInput(array( + "command" => $sqlBuild->getName(), + "name" => $this->module + )), + new StreamOutput(fopen('php://memory', 'w', false)) + ); + } + + protected function generateModel() + { + $fs = new Filesystem(); $moduleBuildPropel = new ModelBuildCommand(); $moduleBuildPropel->setApplication($this->getApplication()); @@ -79,8 +109,6 @@ class ModuleGenerateModelCommand extends BaseModuleGenerate { if ($fs->exists(THELIA_MODULE_DIR . DS . "Thelia")) { $fs->remove(THELIA_MODULE_DIR . DS . "Thelia"); } - - } } \ No newline at end of file From 8e975a9b622324d4fef7fe68787d0dadb775e3fd Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 12 Jul 2013 09:08:51 +0200 Subject: [PATCH 12/36] fix missing argument for sprintf method --- core/lib/Thelia/Command/ModuleGenerateModelCommand.php | 2 +- core/lib/Thelia/Command/ModuleGenerateSqlCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Command/ModuleGenerateModelCommand.php b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php index 41638414e..0b278973e 100644 --- a/core/lib/Thelia/Command/ModuleGenerateModelCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php @@ -63,7 +63,7 @@ class ModuleGenerateModelCommand extends BaseModuleGenerate { $fs = new Filesystem(); if ($fs->exists($this->moduleDirectory) === false) { - throw new \RuntimeException(sprintf("%s module does not exists")); + throw new \RuntimeException(sprintf("%s module does not exists", $this->module)); } if ($fs->exists($this->moduleDirectory . DS . "Config" . DS . "schema.xml") === false) { diff --git a/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php b/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php index 113e3288f..0f8cad20e 100644 --- a/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php @@ -55,7 +55,7 @@ class ModuleGenerateSqlCommand extends BaseModuleGenerate { $fs = new Filesystem(); if ($fs->exists($this->moduleDirectory) === false) { - throw new \RuntimeException(sprintf("%s module does not exists")); + throw new \RuntimeException(sprintf("%s module does not exists", $this->module)); } if ($fs->exists($this->moduleDirectory . DS . "Config" . DS . "schema.xml") === false) { From 2941292fddfe4b373f8e2249c1bd5d0f6c07023d Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 12 Jul 2013 09:46:35 +0200 Subject: [PATCH 13/36] integrate namespace into schema.xml skeleton --- .../Thelia/Command/ModuleGenerateCommand.php | 1 + .../Command/ModuleGenerateModelCommand.php | 22 ++++++++++++++----- .../Thelia/Command/Skeleton/Module/schema.xml | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/core/lib/Thelia/Command/ModuleGenerateCommand.php b/core/lib/Thelia/Command/ModuleGenerateCommand.php index 8329b84e1..0f456ea63 100644 --- a/core/lib/Thelia/Command/ModuleGenerateCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateCommand.php @@ -94,6 +94,7 @@ class ModuleGenerateCommand extends BaseModuleGenerate { $schemaContent = file_get_contents($skeletonDir . "schema.xml"); $schemaContent = str_replace("%%CONFIG_DIR%%", THELIA_CONF_DIR, $schemaContent); + $schemaContent = str_replace("%%NAMESPACE%%", $this->module, $schemaContent); file_put_contents($this->moduleDirectory . DIRECTORY_SEPARATOR . "Config". DIRECTORY_SEPARATOR . "schema.xml", $schemaContent); } diff --git a/core/lib/Thelia/Command/ModuleGenerateModelCommand.php b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php index 0b278973e..27904400a 100644 --- a/core/lib/Thelia/Command/ModuleGenerateModelCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php @@ -72,6 +72,7 @@ class ModuleGenerateModelCommand extends BaseModuleGenerate { $this->generateModel(); + if ($input->getOption("generate-sql")) { $this->generateSql(); } @@ -79,12 +80,12 @@ class ModuleGenerateModelCommand extends BaseModuleGenerate { protected function generateSql() { - $sqlBuild = new ModuleGenerateSqlCommand(); - $sqlBuild->setApplication($this->getApplication()); - $sqlBuild->run( + $command = $this->getApplication()->find("module:generate:sql"); + + $command->run( new ArrayInput(array( - "command" => $sqlBuild->getName(), + "command" => $command->getName(), "name" => $this->module )), new StreamOutput(fopen('php://memory', 'w', false)) @@ -106,9 +107,18 @@ class ModuleGenerateModelCommand extends BaseModuleGenerate { new StreamOutput(fopen('php://memory', 'w', false)) ); - if ($fs->exists(THELIA_MODULE_DIR . DS . "Thelia")) { - $fs->remove(THELIA_MODULE_DIR . DS . "Thelia"); + $verifyDirectories = array( + THELIA_MODULE_DIR . DS . "Thelia", + $this->moduleDirectory . DS . "Model" . DS . "Thelia" + ); + + foreach ($verifyDirectories as $directory) { + if ($fs->exists($directory)) { + $fs->remove($directory); + } } + + } } \ No newline at end of file diff --git a/core/lib/Thelia/Command/Skeleton/Module/schema.xml b/core/lib/Thelia/Command/Skeleton/Module/schema.xml index 1ef803d36..3fcba0184 100644 --- a/core/lib/Thelia/Command/Skeleton/Module/schema.xml +++ b/core/lib/Thelia/Command/Skeleton/Module/schema.xml @@ -1,5 +1,5 @@ - + From b55833b2e20b9fd7b665c981971fc3c9f5ca2e7b Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 12 Jul 2013 10:22:59 +0200 Subject: [PATCH 14/36] add some output in module commands --- .../Command/ModuleGenerateModelCommand.php | 18 ++++++++++++------ .../Command/ModuleGenerateSqlCommand.php | 10 +++++++++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/core/lib/Thelia/Command/ModuleGenerateModelCommand.php b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php index 27904400a..348765ced 100644 --- a/core/lib/Thelia/Command/ModuleGenerateModelCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php @@ -70,15 +70,21 @@ class ModuleGenerateModelCommand extends BaseModuleGenerate { throw new \RuntimeException("schema.xml not found in Config directory. Needed file for generating model"); } - $this->generateModel(); + $this->generateModel($output); + $output->renderBlock(array( + '', + 'Model generated successfuly', + '' + ), 'bg=green;fg=black'); if ($input->getOption("generate-sql")) { - $this->generateSql(); + $output->writeln(' '); + $this->generateSql($output); } } - protected function generateSql() + protected function generateSql(OutputInterface $output) { $command = $this->getApplication()->find("module:generate:sql"); @@ -88,11 +94,11 @@ class ModuleGenerateModelCommand extends BaseModuleGenerate { "command" => $command->getName(), "name" => $this->module )), - new StreamOutput(fopen('php://memory', 'w', false)) + $output ); } - protected function generateModel() + protected function generateModel(OutputInterface $output) { $fs = new Filesystem(); $moduleBuildPropel = new ModelBuildCommand(); @@ -104,7 +110,7 @@ class ModuleGenerateModelCommand extends BaseModuleGenerate { "--output-dir" => THELIA_MODULE_DIR, "--input-dir" => $this->moduleDirectory . DS ."Config" )), - new StreamOutput(fopen('php://memory', 'w', false)) + $output ); $verifyDirectories = array( diff --git a/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php b/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php index 0f8cad20e..977075902 100644 --- a/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php @@ -71,7 +71,15 @@ class ModuleGenerateSqlCommand extends BaseModuleGenerate { "--output-dir" => $this->moduleDirectory . DS ."Config", "--input-dir" => $this->moduleDirectory . DS ."Config" )), - new StreamOutput(fopen('php://memory', 'w', false)) + $output ); + + $output->renderBlock(array( + '', + 'Sql generated successfuly', + 'File available in your module config directory', + '' + ), 'bg=green;fg=black'); + } } \ No newline at end of file From 385a83f896e2a9d8ef2299af5ef2c25d92ad4533 Mon Sep 17 00:00:00 2001 From: franck Date: Fri, 12 Jul 2013 14:22:08 +0200 Subject: [PATCH 15/36] Finalized admin security --- .../Admin/Controller/BaseAdminController.php | 84 +++++++--- .../Admin/Controller/SessionController.php | 65 ++++++-- core/lib/Thelia/Config/Resources/action.xml | 2 + core/lib/Thelia/Config/Resources/config.xml | 21 ++- .../Thelia/Config/Resources/routing/admin.xml | 20 ++- .../Core/HttpFoundation/Session/Session.php | 27 +++- .../AuthenticationProviderInterface.php | 60 ------- .../UsernamePasswordAuthenticator.php | 67 -------- .../Core/Security/AuthenticationProcessor.php | 35 ----- .../Encoder/PasswordEncoderInterface.php | 52 ------ .../Security/Encoder/PasswordHashEncoder.php | 66 -------- .../Encoder/PasswordPhpCompatEncoder.php | 58 ------- .../AuthenticationTokenNotFoundException.php | 28 ---- core/lib/Thelia/Core/Security/Role/Role.php | 2 +- .../Thelia/Core/Security/SecurityContext.php | 121 ++++++++++---- .../Core/Security/Token/AbstractToken.php | 148 ------------------ .../Core/Security/Token/TokenInterface.php | 81 ---------- .../Security/Token/UsernamePasswordToken.php | 75 --------- .../Core/Security/User/UserInterface.php | 9 +- .../UserProvider/AdminUserProvider.php | 7 +- .../UserProvider/CustomerUserProvider.php | 6 +- .../UserProvider/UserProviderInterface.php | 2 +- .../Smarty/Assets/SmartyAssetsManager.php | 3 +- .../Core/Template/Smarty/Plugins/Security.php | 19 ++- .../Template/Smarty/Plugins/Translation.php | 20 +-- core/lib/Thelia/Form/AdminLogin.php | 4 +- core/lib/Thelia/Model/Admin.php | 27 ++++ core/lib/Thelia/Model/AdminLog.php | 32 +++- core/lib/Thelia/Model/Customer.php | 13 +- .../Encoder/PasswordHashEncoderTest.php | 75 --------- .../Encoder/PasswordPhpCompatEncoderTest.php | 31 ---- templates/admin/default/home.html | 2 +- .../admin/default/includes/footer.inc.html | 2 +- templates/admin/default/login.html | 16 +- templates/smarty-sample/includes/header.html | 2 +- 35 files changed, 386 insertions(+), 896 deletions(-) delete mode 100644 core/lib/Thelia/Core/Security/Authentication/AuthenticationProviderInterface.php delete mode 100644 core/lib/Thelia/Core/Security/Authentication/UsernamePasswordAuthenticator.php delete mode 100644 core/lib/Thelia/Core/Security/AuthenticationProcessor.php delete mode 100644 core/lib/Thelia/Core/Security/Encoder/PasswordEncoderInterface.php delete mode 100644 core/lib/Thelia/Core/Security/Encoder/PasswordHashEncoder.php delete mode 100644 core/lib/Thelia/Core/Security/Encoder/PasswordPhpCompatEncoder.php delete mode 100644 core/lib/Thelia/Core/Security/Exception/AuthenticationTokenNotFoundException.php delete mode 100644 core/lib/Thelia/Core/Security/Token/AbstractToken.php delete mode 100644 core/lib/Thelia/Core/Security/Token/TokenInterface.php delete mode 100644 core/lib/Thelia/Core/Security/Token/UsernamePasswordToken.php delete mode 100644 core/lib/Thelia/Tests/Core/Security/Encoder/PasswordHashEncoderTest.php delete mode 100644 core/lib/Thelia/Tests/Core/Security/Encoder/PasswordPhpCompatEncoderTest.php diff --git a/core/lib/Thelia/Admin/Controller/BaseAdminController.php b/core/lib/Thelia/Admin/Controller/BaseAdminController.php index 7dc8f8a15..47258480b 100755 --- a/core/lib/Thelia/Admin/Controller/BaseAdminController.php +++ b/core/lib/Thelia/Admin/Controller/BaseAdminController.php @@ -27,11 +27,13 @@ use Symfony\Component\DependencyInjection\ContainerAware; use Symfony\Component\HttpFoundation\Response; use Thelia\Form\BaseForm; -use Thelia\Model\ConfigQuery; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Thelia\Core\Security\Exception\AuthenticationTokenNotFoundException; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Security\Exception\AuthenticationException; +use Thelia\Core\Security\SecurityContext; /** * @@ -44,14 +46,14 @@ use Thelia\Core\Security\Exception\AuthenticationTokenNotFoundException; class BaseAdminController extends ContainerAware { - const TEMPLATE_404 = "404.html"; - public function notFoundAction() + protected function undefinedAction() { return new Response($this->renderRaw(self::TEMPLATE_404), 404); } + /** * Render the givent template, and returns the result as an Http Response. * @@ -59,7 +61,7 @@ class BaseAdminController extends ContainerAware * @param array $args the template arguments * @return \Symfony\Component\HttpFoundation\Response */ - public function render($templateName, $args = array()) + protected function render($templateName, $args = array()) { $response = new Response(); @@ -67,46 +69,78 @@ class BaseAdminController extends ContainerAware } /** - * Render the givent template, and returns the result as a string. + * Render the given template, and returns the result as a string. * * @param $templateName the complete template name, with extension * @param array $args the template arguments * @return \Symfony\Component\HttpFoundation\Response */ - public function renderRaw($templateName, $args = array()) + protected function renderRaw($templateName, $args = array()) { - $args = array_merge($args, array('lang' => 'fr')); // FIXME + $session = $this->getSession(); + + $args = array_merge($args, array( + 'locale' => $session->getLocale(), + 'lang' => $session->getLang() + )); try { $data = $this->getParser()->render($templateName, $args); - } - catch (AuthenticationTokenNotFoundException $ex) { - // No auth token -> perform login - return new RedirectResponse($this->generateUrl('admin/login')); + return $data; } + catch (AuthenticationException $ex) { - return $data; + // User is not authenticated, and templates requires authentication -> redirect to login page + // (see Thelia\Core\Template\Smarty\Plugins\Security) + return new RedirectResponse($this->generateUrl('admin/login')); // FIXME shoud be a parameter + } + } + + /** + * Return the security context, by default in admin mode. + * + * @return Thelia\Core\Security\SecurityContext + */ + protected function getSecurityContext($context = false) + { + $securityContext = $this->container->get('thelia.securityContext'); + + $securityContext->setContext($context === false ? SecurityContext::CONTEXT_BACK_OFFICE : $context); + + return $securityContext; } /** * @return \Symfony\Component\HttpFoundation\Request */ - public function getRequest() + protected function getRequest() { return $this->container->get('request'); } + /** + * Returns the session from the current request + * + * @return Ambigous + */ + protected function getSession() { + + $request = $this->getRequest(); + + return $request->getSession(); + } + /** * * @return a ParserInterface instance parser, as configured. */ - public function getParser() + protected function getParser() { $parser = $this->container->get("thelia.parser"); - // FIXME: should be read from config - $parser->setTemplate('admin/default'); + // Define the template thant shoud be used + $parser->setTemplate(ConfigQuery::read('base_admin_template', 'admin/default')); return $parser; } @@ -132,11 +166,19 @@ class BaseAdminController extends ContainerAware * * @see UrlGeneratorInterface */ - public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) + protected function generateUrl($path, array $parameters = array()) { - return "thelia2/$route"; //FIXME + $base = ConfigQuery::read("base_url", "/").$path; //FIXME - //return $this->container->get('router')->generate($route, $parameters, $referenceType); + $queryString = ''; + + foreach($parameters as $name => $value) { + $queryString = sprintf("%s=%s&", urlencode($name), urlencode($value)); + } + + if ('' !== $queryString = rtrim($queryString, "&")) $queryString = '?' . $queryString; + + return $base . $queryString; } /** @@ -148,7 +190,7 @@ class BaseAdminController extends ContainerAware * * @return Response A Response instance */ - public function forward($controller, array $path = array(), array $query = array()) + protected function forward($controller, array $path = array(), array $query = array()) { $path['_controller'] = $controller; $subRequest = $this->container->get('request')->duplicate($query, null, $path); @@ -164,7 +206,7 @@ class BaseAdminController extends ContainerAware * * @return RedirectResponse */ - public function redirect($url, $status = 302) + protected function redirect($url, $status = 302) { return new RedirectResponse($url, $status); } diff --git a/core/lib/Thelia/Admin/Controller/SessionController.php b/core/lib/Thelia/Admin/Controller/SessionController.php index cba11a00e..e56af2d1b 100644 --- a/core/lib/Thelia/Admin/Controller/SessionController.php +++ b/core/lib/Thelia/Admin/Controller/SessionController.php @@ -25,33 +25,66 @@ namespace Thelia\Admin\Controller; use Symfony\Component\HttpFoundation\Response; use Thelia\Form\AdminLogin; +use Thelia\Core\Security\Token\UsernamePasswordToken; +use Thelia\Core\Security\Authentication\UsernamePasswordAuthenticator; +use Thelia\Core\Security\Encoder\PasswordPhpCompatEncoder; +use Thelia\Core\Security\Token\TokenInterface; +use Thelia\Core\Security\Authentication\AdminUsernamePasswordFormAuthenticator; +use Thelia\Model\AdminLog; +use Thelia\Core\Security\Exception\AuthenticationException; class SessionController extends BaseAdminController { - public function loginAction() + public function showLoginAction() + { + $form = $this->getLoginForm(); + + return $this->render("login.html", array( + "form" => $form->createView() + )); + } + + public function checkLogoutAction() + { + $this->getSecurityContext()->clear(); + + // Go back to login page. + return $this->redirect($this->generateUrl('admin/login')); + } + + public function checkLoginAction() { - $form = $this->getLoginForm(); + $form = $this->getLoginForm(); - $request = $this->getRequest(); + $request = $this->getRequest(); - if($request->isMethod("POST")) { + $authenticator = new AdminUsernamePasswordFormAuthenticator($request, $form); - $form->bind($request); + try { + $user = $authenticator->getAuthentifiedUser(); - if ($form->isValid()) { + // Success -> store user in security context + $this->getSecurityContext()->setUser($user); - $this->container->get('request')->authenticate( - $form->get('username')->getData(), - $form->get('password')->getData() - ); + // Log authentication success + AdminLog::append("Authentication successufull", $request, $user); - echo "valid"; exit; - } - } + // Redirect to home page - FIXME: requested URL, if we come from another page ? + return $this->redirect($this->generateUrl('admin')); + } + catch (AuthenticationException $ex) { - return $this->render("login.html", array( - "form" => $form->createView() - )); + // Log authentication failure + AdminLog::append(sprintf("Authentication failure for username '%s'", $authenticator->getUsername()), $request); + + $message = "Login failed. Please check your username and password."; + } + + // Display the login form again + return $this->render("login.html", array( + "form" => $authenticator->getLoginForm()->createView(), + "message" => $message + )); } protected function getLoginForm() diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 2f5583e94..5d4436891 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -11,11 +11,13 @@ Thelia\Core\Event\CartEvent + + diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index dee0b57b6..2ae1a668b 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -49,15 +49,23 @@ - + - + + + + + + + + + @@ -84,7 +92,7 @@ - + %thelia.parser.loops% @@ -102,15 +110,16 @@ + - + - + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index dc5e38a9b..fe5a0a283 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -4,14 +4,28 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> + Thelia\Admin\Controller\AdminController::indexAction + + - Thelia\Admin\Controller\SessionController::loginAction + Thelia\Admin\Controller\SessionController::showLoginAction - - Thelia\Admin\Controller\AdminController::notFoundAction + + + + Thelia\Admin\Controller\SessionController::checkLogoutAction + + + + + Thelia\Admin\Controller\SessionController::checkLoginAction + + + + Thelia\Admin\Controller\AdminController::undefinedAction .* \ No newline at end of file diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php index 4bd079685..63e07b2a7 100644 --- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -24,6 +24,7 @@ namespace Thelia\Core\HttpFoundation\Session; use Symfony\Component\HttpFoundation\Session\Session as BaseSession; +use Thelia\Core\Security\User\UserInterface; class Session extends BaseSession { @@ -35,7 +36,31 @@ class Session extends BaseSession { public function getLang() { - return $this->get("lang", "en"); + return substr($this->getLocale(), 0, 2); } + public function setCustomerUser(UserInterface $user) { + $this->set('customer_user', $user); + } + + public function getCustomerUser() { + return $this->get('customer_user'); + } + + public function clearCustomerUser() { + return $this->remove('customer_user'); + } + + + public function setAdminUser(UserInterface $user) { + $this->set('admin_user', $user); + } + + public function getAdminUser() { + return $this->get('admin_user'); + } + + public function clearAdminUser() { + return $this->remove('admin_user'); + } } diff --git a/core/lib/Thelia/Core/Security/Authentication/AuthenticationProviderInterface.php b/core/lib/Thelia/Core/Security/Authentication/AuthenticationProviderInterface.php deleted file mode 100644 index eb60f0482..000000000 --- a/core/lib/Thelia/Core/Security/Authentication/AuthenticationProviderInterface.php +++ /dev/null @@ -1,60 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ - -namespace Thelia\Core\Security\Authentication; - -use Thelia\Core\Security\UserNotFoundException; -use Thelia\Core\Security\IncorrectPasswordException; - -/** - * Aunthentication providers are in charge or retrieving users, and check their - * credentials. - * - * @author Franck - * - */ -interface AuthenticationProviderInterface { - - /** - * Set the authentication token - * - * @param TokenInterface $token the authentication token - */ - public function setToken(TokenInterface $token); - - - /** - * Set the authentication token - * - * @param unknown $key - */ - public function supportsToken(TokenInterface $token); - - /** - * Authenticate the token - * - *@throws Exception if authentication was not successful - */ - public function authenticate(); -} -?> \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordAuthenticator.php deleted file mode 100644 index f6161f038..000000000 --- a/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordAuthenticator.php +++ /dev/null @@ -1,67 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ - -namespace Thelia\Core\Security\Authentication; - -use Thelia\Core\Security\Authentication\AuthenticationProviderInterface; -use Thelia\Core\Security\Encoder\PasswordEncoderInterface; -use Thelia\Core\Security\User\UserProviderInterface; -use Thelia\Security\Token\TokenInterface; -use Thelia\Core\Security\Exception\IncorrectPasswordException; -use Thelia\Core\Security\Token\UsernamePasswordToken; - -class UsernamePasswordAuthenticator implements AuthenticationProviderInterface { - - protected $userProvider; - protected $encoder; - - private $token; - - public function __construct(UserProviderInterface $userProvider, PasswordEncoderInterface $encoder) { - $this->userProvider = $userProvider; - $this->encoder = $encoder; - } - - public function supportsToken(TokenInterface $token) { - - return $token instanceof UsernamePasswordToken; - } - - public function authenticate($token) { - - if (!$this->supports($token)) { - return null; - } - - // Retreive user - $user = $this->userProvider->getUser($this->token->getUsername()); - - // Check password - $authOk = $this->encoder->isEqual($password, $user->getPassword(), $user->getAlgo(), $user->getSalt()) === true; - - $authenticatedToken = new UsernamePasswordToken($user, $token->getCredentials(), $authOk); - - return $authenticatedToken; - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/AuthenticationProcessor.php b/core/lib/Thelia/Core/Security/AuthenticationProcessor.php deleted file mode 100644 index 77fd3bd77..000000000 --- a/core/lib/Thelia/Core/Security/AuthenticationProcessor.php +++ /dev/null @@ -1,35 +0,0 @@ -container = $container; - } - - public function createToken(Request $request) { - - $context = $request->get('_context'); - - try { - $securityContext = $this->container->get("security.$context"); - - $token = new UsernamePasswordToken( - $request->get('_username'), - $request->get('_password') - ); - - $securityContext->setToken($token); - } - catch (\Exception $ex) { - // Nothing to do - } - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Encoder/PasswordEncoderInterface.php b/core/lib/Thelia/Core/Security/Encoder/PasswordEncoderInterface.php deleted file mode 100644 index 3353969b8..000000000 --- a/core/lib/Thelia/Core/Security/Encoder/PasswordEncoderInterface.php +++ /dev/null @@ -1,52 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ - -namespace Thelia\Core\Security\Encoder; - -/** - * This interface defines a password encoder. - * - * @author Franck Allimant - * - */ -interface PasswordEncoderInterface { - - /** - * Encode a string. - * - * @param string $password the password to encode - * @param string $algorithm the hash() algorithm - * @return string $salt the salt - */ - public function encode($password, $algorithm, $salt); - - /** - * Check a string against an encoded password. - * - * @param string $string the string to compare against password - * @param string $password the encoded password - * @param string $algorithm the hash() algorithm - * @return string $salt the salt - */ - public function isEqual($string, $password, $algorithm, $salt); -} diff --git a/core/lib/Thelia/Core/Security/Encoder/PasswordHashEncoder.php b/core/lib/Thelia/Core/Security/Encoder/PasswordHashEncoder.php deleted file mode 100644 index 7a66812f5..000000000 --- a/core/lib/Thelia/Core/Security/Encoder/PasswordHashEncoder.php +++ /dev/null @@ -1,66 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ - -namespace Thelia\Core\Security\Encoder; - -/** - * This interface defines a hash based password encoder. - * - * @author Franck Allimant - */ - -class PasswordHashEncoder implements PasswordEncoderInterface { - - /** - * {@inheritdoc} - */ - public function encode($password, $algorithm, $salt) - { - if (!in_array($algorithm, hash_algos(), true)) { - throw new \LogicException(sprintf('The algorithm "%s" is not supported.', $algorithm)); - } - - // Salt the string - $salted = $password.$salt; - - // Create the hash - $digest = hash($algorithm, $salted, true); - - // "stretch" hash - for ($i = 1; $i < 5000; $i++) { - $digest = hash($algorithm, $digest.$salted, true); - } - - return base64_encode($digest); - } - - /** - * {@inheritdoc} - */ - public function isEqual($string, $password, $algorithm, $salt) - { - $encoded = $this->encode($password, $algorithm, $salt); - - return $encoded == $string; - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Encoder/PasswordPhpCompatEncoder.php b/core/lib/Thelia/Core/Security/Encoder/PasswordPhpCompatEncoder.php deleted file mode 100644 index 32b1c7fd0..000000000 --- a/core/lib/Thelia/Core/Security/Encoder/PasswordPhpCompatEncoder.php +++ /dev/null @@ -1,58 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ -namespace Thelia\Core\Security\Encoder; - -/** - * - * use password api include in php 5.5 and available throw the password_compat library. - * - * Class PasswordPhpCompatEncoder - * @package Thelia\Core\Security\Encoder - */ -class PasswordPhpCompatEncoder implements PasswordEncoderInterface { - - /** - * Encode a string. - * - * @param string $password the password to encode - * @param string $algorithm the hash() algorithm - * @return string $salt the salt, the salt is not used here. - */ - public function encode($password, $algorithm, $salt = null) - { - return password_hash($password, $algorithm); - } - - /** - * Check a string against an encoded password. - * - * @param string $string the string to compare against password - * @param string $password the encoded password - * @param string $algorithm the hash() algorithm, not used here - * @return string $salt the salt, not used here - */ - public function isEqual($string, $password, $algorithm = null, $salt = null) - { - return password_verify($string, $password); - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Exception/AuthenticationTokenNotFoundException.php b/core/lib/Thelia/Core/Security/Exception/AuthenticationTokenNotFoundException.php deleted file mode 100644 index 061b43257..000000000 --- a/core/lib/Thelia/Core/Security/Exception/AuthenticationTokenNotFoundException.php +++ /dev/null @@ -1,28 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ - -namespace Thelia\Core\Security\Exception; - -class AuthenticationTokenNotFoundException extends \Exception -{ -} diff --git a/core/lib/Thelia/Core/Security/Role/Role.php b/core/lib/Thelia/Core/Security/Role/Role.php index b47e1c089..c363d1c4c 100644 --- a/core/lib/Thelia/Core/Security/Role/Role.php +++ b/core/lib/Thelia/Core/Security/Role/Role.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace use Thelia\Core\Security\Role; +namespace Thelia\Core\Security\Role; /** * Role is a simple implementation of a RoleInterface where the role is a diff --git a/core/lib/Thelia/Core/Security/SecurityContext.php b/core/lib/Thelia/Core/Security/SecurityContext.php index 683431518..645d9a196 100644 --- a/core/lib/Thelia/Core/Security/SecurityContext.php +++ b/core/lib/Thelia/Core/Security/SecurityContext.php @@ -25,62 +25,125 @@ namespace Thelia\Core\Security; use Thelia\Core\Security\Authentication\AuthenticationProviderInterface; use Thelia\Core\Security\Exception\AuthenticationTokenNotFoundException; +use Thelia\Core\Security\Token\TokenInterface; +use Thelia\Core\Security\User\UserInterface; +use Thelia\Core\HttpFoundation\Request; /** - * A simple security manager, in charge of authenticating users using various authentication systems. + * A simple security manager, in charge of checking user * * @author Franck Allimant */ class SecurityContext { -/* - protected $authProvider; - public function __construct(AuthenticationProviderInterface $authProvider) { - $this->authProvider = $authProvider; - } -*/ + const CONTEXT_FRONT_OFFICE = 'front'; + const CONTEXT_BACK_OFFICE = 'admin'; + + private $request; + private $context; + + public function __construct(Request $request) { + + $this->request = $request; + + $this->context = null; + } + + public function setContext($context) { + if ($context !== self::CONTEXT_FRONT_OFFICE && $context !== self::CONTEXT_BACK_OFFICE) { + throw new \InvalidArgumentException(sprintf("Invalid or empty context identifier '%s'", $context)); + } + + $this->context = $context; + } + + public function getContext($exception_if_context_undefined = false) { + if (null === $this->context && $exception_if_context_undefined === true) + throw new \LogicException("No context defined. Please use setContext() first."); + + return $this->context; + } + + private function getSession() { + $session = $this->request->getSession(); + + if ($session === null) + throw new \LogicException("No session found."); + + return $session; + } + /** - * Checks if the current token is authenticated + * Gets the currently authenticated user in the current context, or null if none is defined * - * @throws AuthenticationCredentialsNotFoundException when the security context has no authentication token. + * @return UserInterface|null A UserInterface instance or null if no user is available + */ + public function getUser() { + $context = $this->getContext(true); + + if ($context === self::CONTEXT_FRONT_OFFICE) + $user = $this->getSession()->getCustomerUser(); + else if ($context == self::CONTEXT_BACK_OFFICE) + $user = $this->getSession()->getAdminUser(); + else + $user = null; + + return $user; + } + + final public function isAuthenticated() + { + if (null !== $this->getUser()) { + return true; + } + + return false; + } + + /** + * Checks if the current user is allowed * * @return Boolean - * @throws AuthenticationTokenNotFoundException if no thoken was found in context */ final public function isGranted($roles, $permissions) { - if (null === $this->token) { - throw new AuthenticationTokenNotFoundException('The security context contains no authentication token.'); - } + if ($this->isAuthenticated() === true) { - if (!$this->token->isAuthenticated()) { - $this->token = $this->authProvider->authenticate($this->token); - } + echo "TODO: check roles and permissions !"; - if ($this->token->isAuthenticated()) { - // Check user roles and permissions + // TODO : check roles and permissions + return true; } return false; } /** - * Gets the currently authenticated token. + * Sets the authenticated user. * - * @return TokenInterface|null A TokenInterface instance or null if no authentication information is available + * @param UserInterface $user A UserInterface, or null if no further user should be stored */ - public function getToken() + public function setUser(UserInterface $user) { - return $this->token; + $context = $this->getContext(true); + + $user->eraseCredentials(); + + if ($context === self::CONTEXT_FRONT_OFFICE) + $this->getSession()->setCustomerUser($user); + else if ($context == self::CONTEXT_BACK_OFFICE) + $this->getSession()->setAdminUser($user); } /** - * Sets the token. - * - * @param TokenInterface $token A TokenInterface token, or null if no further authentication information should be stored - */ - public function setToken(TokenInterface $token = null) - { - $this->token = $token; + * Clear the user from the security context + */ + public function clear() { + $context = $this->getContext(true); + + if ($context === self::CONTEXT_FRONT_OFFICE) + $this->getSession()->clearCustomerUser(); + else if ($context == self::CONTEXT_BACK_OFFICE) + $this->getSession()->clearAdminUser(); } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Token/AbstractToken.php b/core/lib/Thelia/Core/Security/Token/AbstractToken.php deleted file mode 100644 index be1f8cb8b..000000000 --- a/core/lib/Thelia/Core/Security/Token/AbstractToken.php +++ /dev/null @@ -1,148 +0,0 @@ - -* @author Johannes M. Schmitt -*/ -abstract class AbstractToken implements TokenInterface -{ - private $user; - private $authenticated; - - /** - * Constructor. - * - * @param RoleInterface[] $roles An array of roles - * - * @throws \InvalidArgumentException - */ - public function __construct() - { - $this->authenticated = false; - } - - /** - * {@inheritdoc} - */ - public function getUsername() - { - if ($this->user instanceof UserInterface) { - return $this->user->getUsername(); - } - - return (string) $this->user; - } - - public function getUser() - { - return $this->user; - } - - /** - * Sets the user in the token. - * - * The user can be a UserInterface instance, or an object implementing - * a __toString method or the username as a regular string. - * - * @param mixed $user The user - * @throws \InvalidArgumentException - */ - public function setUser($user) - { - if (!($user instanceof UserInterface || is_string($user))) { - throw new \InvalidArgumentException('$user must be an instanceof UserInterface, or a primitive string.'); - } - - if (null === $this->user) { - $changed = false; - } elseif ($this->user instanceof UserInterface) { - if (!$user instanceof UserInterface) { - $changed = true; - } else { - $changed = $this->hasUserChanged($user); - } - } elseif ($user instanceof UserInterface) { - $changed = true; - } else { - $changed = (string) $this->user !== (string) $user; - } - - if ($changed) { - $this->setAuthenticated(false); - } - - $this->user = $user; - } - - /** - * {@inheritdoc} - */ - public function isAuthenticated() - { - return $this->authenticated; - } - - /** - * {@inheritdoc} - */ - public function setAuthenticated($authenticated) - { - $this->authenticated = (Boolean) $authenticated; - } - - /** - * {@inheritdoc} - */ - public function eraseCredentials() - { - if ($this->getUser() instanceof UserInterface) { - $this->getUser()->eraseCredentials(); - } - } - - /** - * {@inheritdoc} - */ - public function serialize() - { - return serialize(array($this->user, $this->authenticated)); - } - - /** - * {@inheritdoc} - */ - public function unserialize($serialized) - { - list($this->user, $this->authenticated) = unserialize($serialized); - } - - private function hasUserChanged(UserInterface $user) - { - if (!($this->user instanceof UserInterface)) { - throw new \BadMethodCallException('Method "hasUserChanged" should be called when current user class is instance of "UserInterface".'); - } - - if ($this->user instanceof EquatableInterface) { - return ! (Boolean) $this->user->isEqualTo($user); - } - - if ($this->user->getPassword() !== $user->getPassword()) { - return true; - } - - if ($this->user->getSalt() !== $user->getSalt()) { - return true; - } - - if ($this->user->getUsername() !== $user->getUsername()) { - return true; - } - - return false; - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Token/TokenInterface.php b/core/lib/Thelia/Core/Security/Token/TokenInterface.php deleted file mode 100644 index d70c8eeea..000000000 --- a/core/lib/Thelia/Core/Security/Token/TokenInterface.php +++ /dev/null @@ -1,81 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ - -namespace Thelia\Core\Security\Token; - -/** - * TokenInterface is the interface for the user authentication information. - * - * Parts borrowed from Symfony Security Framework (Fabien Potencier / Johannes M. Schmitt ) - */ - -interface TokenInterface extends \Serializable -{ - /** - * Returns the user credentials. - * - * @return mixed The user credentials - */ - public function getCredentials(); - - /** - * Returns a user representation. - * - * @return mixed either returns an object which implements __toString(), or - * a primitive string is returned. - */ - public function getUser(); - - /** - * Sets a user instance - * - * @param mixed $user - */ - public function setUser($user); - - /** - * Returns the username. - * - * @return string - */ - public function getUsername(); - - /** - * Returns whether the user is authenticated or not. - * - * @return Boolean true if the token has been authenticated, false otherwise - */ - public function isAuthenticated(); - - /** - * Sets the authenticated flag. - * - * @param Boolean $isAuthenticated The authenticated flag - */ - public function setAuthenticated($isAuthenticated); - - /** - * Removes sensitive information from the token. - */ - public function eraseCredentials(); -} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Token/UsernamePasswordToken.php b/core/lib/Thelia/Core/Security/Token/UsernamePasswordToken.php deleted file mode 100644 index 03f73dbdd..000000000 --- a/core/lib/Thelia/Core/Security/Token/UsernamePasswordToken.php +++ /dev/null @@ -1,75 +0,0 @@ - -*/ -class UsernamePasswordToken extends AbstractToken -{ - private $credentials; - - /** - * Constructor. - * - * @param string $user The username (like a nickname, email address, etc.), or a UserInterface instance or an object implementing a __toString method. - * @param string $password The password of the user - * - * @throws \InvalidArgumentException - */ - public function __construct($username, $password, array $roles = array()) - { - $this->setUser($username); - $this->credentials = $password; - - parent::setAuthenticated(count($roles) > 0); - } - - /** - * {@inheritdoc} - */ - public function setAuthenticated($isAuthenticated) - { - if ($isAuthenticated) { - throw new \LogicException('Cannot set this token to trusted after instantiation.'); - } - - parent::setAuthenticated(false); - } - - public function getCredentials() - { - return $this->credentials; - } - - /** - * {@inheritdoc} - */ - public function eraseCredentials() - { - parent::eraseCredentials(); - - $this->credentials = null; - } - - /** - * {@inheritdoc} - */ - public function serialize() - { - return serialize(array($this->credentials, $this->providerKey, parent::serialize())); - } - - /** - * {@inheritdoc} - */ - public function unserialize($serialized) - { - list($this->credentials, $this->providerKey, $parentStr) = unserialize($serialized); - parent::unserialize($parentStr); - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/User/UserInterface.php b/core/lib/Thelia/Core/Security/User/UserInterface.php index be158e88c..b747fdffa 100644 --- a/core/lib/Thelia/Core/Security/User/UserInterface.php +++ b/core/lib/Thelia/Core/Security/User/UserInterface.php @@ -21,14 +21,9 @@ interface UserInterface { public function getPassword(); /** - * return the salt used to calculate the user password + * Check a string against a the user password */ - public function getSalt(); - - /** - * return the algorithm used to calculate the user password - */ - public function getAlgo(); + public function checkPassword($password); /** * Returns the roles granted to the user. diff --git a/core/lib/Thelia/Core/Security/UserProvider/AdminUserProvider.php b/core/lib/Thelia/Core/Security/UserProvider/AdminUserProvider.php index c9ae34a96..162edf299 100644 --- a/core/lib/Thelia/Core/Security/UserProvider/AdminUserProvider.php +++ b/core/lib/Thelia/Core/Security/UserProvider/AdminUserProvider.php @@ -1,12 +1,13 @@ filterByLogin($key) ->findOne(); diff --git a/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php b/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php index 3472bc013..642056f77 100644 --- a/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php +++ b/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php @@ -1,13 +1,13 @@ filterByEmail($key) ->findOne(); diff --git a/core/lib/Thelia/Core/Security/UserProvider/UserProviderInterface.php b/core/lib/Thelia/Core/Security/UserProvider/UserProviderInterface.php index f2a6d139b..931fa6923 100644 --- a/core/lib/Thelia/Core/Security/UserProvider/UserProviderInterface.php +++ b/core/lib/Thelia/Core/Security/UserProvider/UserProviderInterface.php @@ -1,6 +1,6 @@ assetic_manager->asseticize( $asset_dir.'/'.$asset_file, $this->web_root."/".$this->path_relative_to_web_root, - $this->path_relative_to_web_root, + ConfigQuery::read('base_url', '/') . $this->path_relative_to_web_root, $assetType, $filters, $debug diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php index 93367f341..28fd8e4cf 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php @@ -27,6 +27,7 @@ use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\SmartyPluginInterface; use Thelia\Core\Template\Smarty\Assets\SmartyAssetsManager; use Thelia\Core\Security\SecurityContext; +use Thelia\Core\Security\Exception\AuthenticationException; class Security implements SmartyPluginInterface { @@ -39,7 +40,6 @@ class Security implements SmartyPluginInterface private function _explode($commaSeparatedValues) { - $array = explode(',', $commaSeparatedValues); if (array_walk($array, function(&$item) { @@ -60,10 +60,23 @@ class Security implements SmartyPluginInterface */ public function checkAuthFunction($params, &$smarty) { - $roles = $this->_explode($params['role']); + // Context: 'front' or 'admin' + $context = strtolower(trim($params['context'])); + + $this->securityContext->setContext($context); + + $roles = $this->_explode($params['roles']); $permissions = $this->_explode($params['permissions']); - $this->securityContext->isGranted($roles, $permissions); + if (! $this->securityContext->isGranted($roles, $permissions)) { + throw new AuthenticationException( + sprintf("User not granted for roles '%s', permissions '%s' in context '%s'.", + implode(',', $roles), implode(',', $permissions), $context + ) + ); + } + + return ''; } /** diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Translation.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Translation.php index ec984613e..f03c34a7e 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Translation.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Translation.php @@ -25,9 +25,16 @@ namespace Thelia\Core\Template\Smarty\Plugins; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\SmartyPluginInterface; +use Symfony\Component\Translation\TranslatorInterface; class Translation implements SmartyPluginInterface { + protected $translator; + + public function __construct(TranslatorInterface $translator) { + $this->translator = $translator; + } + /** * Process translate function * @@ -35,16 +42,9 @@ class Translation implements SmartyPluginInterface * @param unknown $smarty * @return string */ - public function theliaTranslate($params, &$smarty) + public function translate($params, &$smarty) { - if (isset($params['l'])) { - $string = str_replace('\'', '\\\'', $params['l']); - } else { - $string = ''; - } - - // TODO - return "$string"; + return $this->translator->trans($params['l'], isset($params['p']) ? $params['p'] : array()); } /** @@ -55,7 +55,7 @@ class Translation implements SmartyPluginInterface public function getPluginDescriptors() { return array( - new SmartyPluginDescriptor('function', 'intl', $this, 'theliaTranslate'), + new SmartyPluginDescriptor('function', 'intl', $this, 'translate'), ); } } diff --git a/core/lib/Thelia/Form/AdminLogin.php b/core/lib/Thelia/Form/AdminLogin.php index 37efd05e7..6ba27830e 100644 --- a/core/lib/Thelia/Form/AdminLogin.php +++ b/core/lib/Thelia/Form/AdminLogin.php @@ -44,12 +44,12 @@ class AdminLogin extends BaseForm { new NotBlank() ) )) - ->add("remember_me", "checkbox"); + ->add("remember_me", "checkbox") + ; } public function getName() { return "admin_login"; } - } diff --git a/core/lib/Thelia/Model/Admin.php b/core/lib/Thelia/Model/Admin.php index 5dd4b9ed4..42d84ea93 100644 --- a/core/lib/Thelia/Model/Admin.php +++ b/core/lib/Thelia/Model/Admin.php @@ -3,6 +3,8 @@ namespace Thelia\Model; use Thelia\Core\Security\User\UserInterface; +use Thelia\Core\Security\Role\Role; + use Thelia\Model\Base\Admin as BaseAdmin; /** @@ -18,9 +20,34 @@ use Thelia\Model\Base\Admin as BaseAdmin; */ class Admin extends BaseAdmin implements UserInterface { + + public function setPassword($password) + { + \Thelia\Log\Tlog::getInstance()->debug($password); + + if ($this->isNew() && ($password === null || trim($password) == "")) { + throw new InvalidArgumentException("customer password is mandatory on creation"); + } + + if($password !== null && trim($password) != "") { + $this->setAlgo("PASSWORD_BCRYPT"); + return parent::setPassword(password_hash($password, PASSWORD_BCRYPT)); + } + + return $this; + } + /** * {@inheritDoc} */ + public function checkPassword($password) + { + return password_verify($password, $this->password); + } + + /** + * {@inheritDoc} + */ public function getUsername() { return $this->getLogin(); } diff --git a/core/lib/Thelia/Model/AdminLog.php b/core/lib/Thelia/Model/AdminLog.php index efa80209c..e5720fb35 100644 --- a/core/lib/Thelia/Model/AdminLog.php +++ b/core/lib/Thelia/Model/AdminLog.php @@ -3,7 +3,37 @@ namespace Thelia\Model; use Thelia\Model\Base\AdminLog as BaseAdminLog; +use Thelia\Core\HttpFoundation\Request; +use Thelia\Log\Tlog; +use Thelia\Model\Base\Admin as BaseAdminUser; class AdminLog extends BaseAdminLog { -} + /** + * A sdimple helper to insert an entry in the admin log + * + * @param unknown $actionLabel + * @param Request $request + * @param Admin $adminUser + */ + public static function append($actionLabel, Request $request, BaseAdminUser $adminUser = null) { + + $log = new AdminLog(); + + $log + ->setAdminLogin($adminUser !== null ? $adminUser->getLogin() : '') + ->setAdminFirstname($adminUser !== null ? $adminUser->getFirstname() : '') + ->setAdminLastname($adminUser !== null ? $adminUser->getLastname() : '') + ->setAction($actionLabel) + ->setRequest($request->__toString()) + ; + + try { + $log->save(); + } + catch (\Exception $ex) { + Tlog::getInstance()->err("Failed to insert new entry in AdminLog: {ex}", array('ex' => $ex)); + } + + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 13024996b..00acf0e83 100644 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -113,12 +113,19 @@ class Customer extends BaseCustomer implements UserInterface $this->dispatcher = $dispatcher; } + /** + * {@inheritDoc} + */ + public function getUsername() { + return $this->getEmail(); + } + /** * {@inheritDoc} */ - - public function getUsername() { - return $this->getEmail(); + public function checkPassword($password) + { + return password_verify($password, $this->password); } /** diff --git a/core/lib/Thelia/Tests/Core/Security/Encoder/PasswordHashEncoderTest.php b/core/lib/Thelia/Tests/Core/Security/Encoder/PasswordHashEncoderTest.php deleted file mode 100644 index 7590b3788..000000000 --- a/core/lib/Thelia/Tests/Core/Security/Encoder/PasswordHashEncoderTest.php +++ /dev/null @@ -1,75 +0,0 @@ -encode('password', 'sha512', 'a simple salt'); - - // echo "PASS=\{$pass\}"; - - $this->assertEquals("L3f/gGy4nBVhi8WSsC1a7E9JM8U+rtk6ZT+NiqX8M1UDJv6mahQEZ1z2cN/y9pixH+hgWbkBitONMiXWscomoQ==", $pass, "Expected password not found."); - } - - public function testIsEqual() - { - $encoder = new PasswordHashEncoder(); - - $exp = "L3f/gGy4nBVhi8WSsC1a7E9JM8U+rtk6ZT+NiqX8M1UDJv6mahQEZ1z2cN/y9pixH+hgWbkBitONMiXWscomoQ=="; - - $this->assertTrue($encoder->isEqual($exp, 'password', 'sha512', 'a simple salt')); - } - - public function testWrongPass() - { - $encoder = new PasswordHashEncoder(); - - $exp = "L3f/gGy4nBVhi8WSsC1a7E9JM8U+rtk6ZT+NiqX8M1UDJv6mahQEZ1z2cN/y9pixH+hgWbkBitONMiXWscomoQ=="; - - $this->assertFalse($encoder->isEqual($exp, 'grongron', 'sha512', 'a simple salt')); - } - - public function testWrongSalt() - { - $encoder = new PasswordHashEncoder(); - - $exp = "L3f/gGy4nBVhi8WSsC1a7E9JM8U+rtk6ZT+NiqX8M1UDJv6mahQEZ1z2cN/y9pixH+hgWbkBitONMiXWscomoQ=="; - - $this->assertFalse($encoder->isEqual($exp, 'password', 'sha512', 'another salt')); - } - - public function testWrongAlgo() - { - $encoder = new PasswordHashEncoder(); - - $exp = "L3f/gGy4nBVhi8WSsC1a7E9JM8U+rtk6ZT+NiqX8M1UDJv6mahQEZ1z2cN/y9pixH+hgWbkBitONMiXWscomoQ=="; - - $this->assertFalse($encoder->isEqual($exp, 'password', 'md5', 'another salt')); - } - - /** - * @expectedException LogicException - */ - public function testUnsupportedAlgo() - { - $encoder = new PasswordHashEncoder(); - - $exp = "L3f/gGy4nBVhi8WSsC1a7E9JM8U+rtk6ZT+NiqX8M1UDJv6mahQEZ1z2cN/y9pixH+hgWbkBitONMiXWscomoQ=="; - - $encoder->isEqual($exp, 'password', 'sbonk', 'another salt'); - } - - /** - * @expectedException LogicException - */ - public function testEncodeWrongAlgorithm() - { - $encoder = new PasswordHashEncoder(); - - $encoder->encode('password', 'pouët', 'a simple salt'); - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Core/Security/Encoder/PasswordPhpCompatEncoderTest.php b/core/lib/Thelia/Tests/Core/Security/Encoder/PasswordPhpCompatEncoderTest.php deleted file mode 100644 index 988be2360..000000000 --- a/core/lib/Thelia/Tests/Core/Security/Encoder/PasswordPhpCompatEncoderTest.php +++ /dev/null @@ -1,31 +0,0 @@ -encoder = new PasswordPhpCompatEncoder(); - } - - public function testEncode() - { - $hash = $this->encoder->encode("foo", PASSWORD_BCRYPT); - - $this->assertEquals($hash, crypt("foo", $hash)); - } - -} \ No newline at end of file diff --git a/templates/admin/default/home.html b/templates/admin/default/home.html index 01e667a28..53f0a5b6b 100755 --- a/templates/admin/default/home.html +++ b/templates/admin/default/home.html @@ -1,4 +1,4 @@ -{check_auth roles="ADMIN"} +{check_auth context="admin" roles="ADMIN"} {$page_title={intl l='Home'}} {include file='includes/header.inc.html'} diff --git a/templates/admin/default/includes/footer.inc.html b/templates/admin/default/includes/footer.inc.html index 5fd1a6b8f..aca554da2 100755 --- a/templates/admin/default/includes/footer.inc.html +++ b/templates/admin/default/includes/footer.inc.html @@ -1,7 +1,7 @@
-

{intl l='© Thelia 2012'} +

{intl l='© Thelia 2013'} - {intl l='Édité par OpenStudio'} - {intl l='Forum Thelia'} - {intl l='Contributions Thelia'} diff --git a/templates/admin/default/login.html b/templates/admin/default/login.html index 9c64612ac..55cc345b7 100755 --- a/templates/admin/default/login.html +++ b/templates/admin/default/login.html @@ -13,23 +13,27 @@

{intl l='Thelia Back Office'}

-
+ + + {if isset($message)}
{$message}
{/if} + {form_field_hidden form=$form} + {form_field form=$form.username} - {form_error form=$form.username} - {$message} - {/form_error} + {form_error form=$form.username}{$message}{/form_error} {/form_field} + {form_field form=$form.password} + {form_error form=$form.password}{$message}{/form_error} {/form_field} {form_field form=$form.remember_me} - + {/form_field} -
+
diff --git a/templates/smarty-sample/includes/header.html b/templates/smarty-sample/includes/header.html index 10c64a072..7dbd94ecc 100755 --- a/templates/smarty-sample/includes/header.html +++ b/templates/smarty-sample/includes/header.html @@ -1,7 +1,7 @@ - {intl l='Hi, I\'m a Thelia TPex template'} + {intl l="Hi, I'm a Thelia TPex template"} {stylesheets file='../assets/css/*' filters='less,cssembed'} From f6cb11961645527d3b8faab5513d2a00d6ccfce2 Mon Sep 17 00:00:00 2001 From: franck Date: Fri, 12 Jul 2013 14:24:55 +0200 Subject: [PATCH 16/36] Initiated translation system --- ...AdminUsernamePasswordFormAuthenticator.php | 45 +++++++++ .../Authentication/AuthenticatorInterface.php | 32 +++++++ ...tomerUsernamePasswordFormAuthenticator.php | 40 ++++++++ .../UsernamePasswordFormAuthenticator.php | 91 +++++++++++++++++++ .../Exception/AuthenticationException.php | 28 ++++++ .../Exception/UsernameNotFoundException.php | 28 ++++++ .../Exception/WrongPasswordException.php | 28 ++++++ .../Thelia/Core/Translation/Translator.php | 28 ++++++ core/lib/Thelia/Form/CustomerLogin.php | 55 +++++++++++ install/INSTALL-TODO.txt | 9 ++ 10 files changed, 384 insertions(+) create mode 100644 core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php create mode 100644 core/lib/Thelia/Core/Security/Authentication/AuthenticatorInterface.php create mode 100644 core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php create mode 100644 core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php create mode 100644 core/lib/Thelia/Core/Security/Exception/AuthenticationException.php create mode 100644 core/lib/Thelia/Core/Security/Exception/UsernameNotFoundException.php create mode 100644 core/lib/Thelia/Core/Security/Exception/WrongPasswordException.php create mode 100644 core/lib/Thelia/Core/Translation/Translator.php create mode 100644 core/lib/Thelia/Form/CustomerLogin.php create mode 100644 install/INSTALL-TODO.txt diff --git a/core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php new file mode 100644 index 000000000..81db900d8 --- /dev/null +++ b/core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php @@ -0,0 +1,45 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\Authentication; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Form\Form; + +use Thelia\Core\Security\UserProvider\AdminUserProvider; +use Thelia\Core\Security\Authentication\UsernamePasswordFormAuthenticator; + +class AdminUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuthenticator { + + public function __construct(Request $request, Form $loginForm) { + parent::__construct( + $request, + $loginForm, + new AdminUserProvider(), + array( + 'username_field_name', 'email' + ) + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Authentication/AuthenticatorInterface.php b/core/lib/Thelia/Core/Security/Authentication/AuthenticatorInterface.php new file mode 100644 index 000000000..05d850bee --- /dev/null +++ b/core/lib/Thelia/Core/Security/Authentication/AuthenticatorInterface.php @@ -0,0 +1,32 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\Authentication; + +interface AuthenticatorInterface { + + /** + * Returns a UserInterface instance, authentified using the authenticator specific method + */ + public function getAuthentifiedUser(); +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php new file mode 100644 index 000000000..483894b93 --- /dev/null +++ b/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php @@ -0,0 +1,40 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\Authentication; + +use Symfony\Component\HttpFoundation\Request; +use Thelia\Core\Security\Authentication\UsernamePasswordFormAuthenticator; +use Thelia\Form\CustomerLogin; + +class CustomerUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuthenticator { + + public function __construct(Request $request, AdminLogin $loginForm) { + parent::__construct( + $request, + $loginForm, + new AdminUserProvider(), + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php new file mode 100644 index 000000000..37156786c --- /dev/null +++ b/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php @@ -0,0 +1,91 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\Authentication; + +use Thelia\Core\Security\Authentication\AuthenticatorInterface; +use Symfony\Component\HttpFoundation\Request; +use Thelia\Core\Security\UserProvider\UserProviderInterface; +use Symfony\Component\Form\Form; +use Thelia\Core\Security\Exception\WrongPasswordException; +use Thelia\Core\Security\Exception\UsernameNotFoundException; + +class UsernamePasswordFormAuthenticator implements AuthenticatorInterface { + + protected $request; + protected $loginForm; + protected $userProvider; + protected $options; + + + public function __construct(Request $request, Form $loginForm, UserProviderInterface $userProvider, array $options = array()) { + $this->request = $request; + $this->loginForm = $loginForm; + $this->userProvider = $userProvider; + + $defaults = array( + 'required_method' => 'POST', + 'username_field_name' => 'username', + 'password_field_name' => 'password' + ); + + $this->options = array_merge($defaults, $options); + + $this->loginForm->bind($this->request); + } + + public function getLoginForm() { + return $this->loginForm; + } + + public function getUsername() { + return $this->loginForm->get($this->options['username_field_name'])->getData(); + } + + public function getAuthentifiedUser() { + + if ($this->request->isMethod($this->options['required_method'])) { + + if ($this->loginForm->isValid()) { + + // Retreive user + $username = $this->getUsername(); + $password = $this->loginForm->get($this->options['password_field_name'])->getData(); + + $user = $this->userProvider->getUser($username); + + if ($user === null) throw new UsernameNotFoundException(sprintf("Username '%s' was not found.", $username)); + + // Check user password + $authOk = $user->checkPassword($password) === true; + + if ($authOk !== true) throw new WrongPasswordException(sprintf("Wrong password for user '%s'.", $username)); + + return $user; + } + } + else { + throw new \RuntimeException("Invalid method."); + } + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Exception/AuthenticationException.php b/core/lib/Thelia/Core/Security/Exception/AuthenticationException.php new file mode 100644 index 000000000..2e3e496a3 --- /dev/null +++ b/core/lib/Thelia/Core/Security/Exception/AuthenticationException.php @@ -0,0 +1,28 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\Exception; + +class AuthenticationException extends \Exception +{ +} diff --git a/core/lib/Thelia/Core/Security/Exception/UsernameNotFoundException.php b/core/lib/Thelia/Core/Security/Exception/UsernameNotFoundException.php new file mode 100644 index 000000000..2168e63ca --- /dev/null +++ b/core/lib/Thelia/Core/Security/Exception/UsernameNotFoundException.php @@ -0,0 +1,28 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\Exception; + +class UsernameNotFoundException extends AuthenticationException +{ +} diff --git a/core/lib/Thelia/Core/Security/Exception/WrongPasswordException.php b/core/lib/Thelia/Core/Security/Exception/WrongPasswordException.php new file mode 100644 index 000000000..6088f43ad --- /dev/null +++ b/core/lib/Thelia/Core/Security/Exception/WrongPasswordException.php @@ -0,0 +1,28 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Security\Exception; + +class WrongPasswordException extends AuthenticationException +{ +} diff --git a/core/lib/Thelia/Core/Translation/Translator.php b/core/lib/Thelia/Core/Translation/Translator.php new file mode 100644 index 000000000..f884b0c98 --- /dev/null +++ b/core/lib/Thelia/Core/Translation/Translator.php @@ -0,0 +1,28 @@ +getLocale(); + } + + if (!isset($this->catalogues[$locale])) { + $this->loadCatalogue($locale); + } + + if ($this->catalogues[$locale]->has((string) $id, $domain)) + return parent::trans($id, $parameters, $domain = 'messages', $locale = null); + else + return strtr($id, $parameters); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/CustomerLogin.php b/core/lib/Thelia/Form/CustomerLogin.php new file mode 100644 index 000000000..e18947d1b --- /dev/null +++ b/core/lib/Thelia/Form/CustomerLogin.php @@ -0,0 +1,55 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + + +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Validator\Constraints\Length; +use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\Constraints\Choice; + +class CustomerLogin extends BaseForm { + + protected function buildForm() + { + $this->form + ->add("username", "text", array( + "constraints" => array( + new NotBlank(), + new Length(array("min" => 3)) + ) + )) + ->add("password", "password", array( + "constraints" => array( + new NotBlank() + ) + )) + ->add("remember_me", "checkbox") + ; + } + + public function getName() + { + return "customer_login"; + } +} diff --git a/install/INSTALL-TODO.txt b/install/INSTALL-TODO.txt new file mode 100644 index 000000000..91662f2b7 --- /dev/null +++ b/install/INSTALL-TODO.txt @@ -0,0 +1,9 @@ +A faire dans la procédure d'install +----------------------------------- + +Variables Config à initialiser: + +- base_url : url de base de la boutique avec / final (ex. http://www.boutique.com/, ou http://www.boutique.com/path/to/thelia2/ ) +- base_admin_template : chemin du template admin relatif au repertoire template (ex. admin/default) +- default_locale : la locale par défaut (ex. en_US), à utiliser pour les fichiers de traduction +- asset_dir_from_web_root : le chemin relatif à /web du repertoires des assets (ex. assets) From 3857827b980fc2c2858c7f8a33a6e0ce99fcf008 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 12 Jul 2013 15:58:36 +0200 Subject: [PATCH 17/36] check if database name is not empty in install process --- core/lib/Thelia/Command/Install.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/lib/Thelia/Command/Install.php b/core/lib/Thelia/Command/Install.php index 9d4d4d1fd..53a573375 100755 --- a/core/lib/Thelia/Command/Install.php +++ b/core/lib/Thelia/Command/Install.php @@ -272,6 +272,10 @@ class Install extends ContainerAwareCommand protected function tryConnection($connectionInfo, OutputInterface $output) { + if (is_null($connectionInfo["dbName"])) { + return false; + } + $dsn = "mysql:host=%s"; try { From dc22d5bf597e3f55926ff5f19aac58ccdd5029e3 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 12 Jul 2013 16:23:06 +0200 Subject: [PATCH 18/36] change customer model --- core/lib/Thelia/Model/Base/Address.php | 153 ++- core/lib/Thelia/Model/Base/AddressQuery.php | 80 +- core/lib/Thelia/Model/Base/Customer.php | 924 +----------------- core/lib/Thelia/Model/Base/CustomerQuery.php | 536 +--------- core/lib/Thelia/Model/Base/CustomerTitle.php | 273 ------ .../Thelia/Model/Base/CustomerTitleQuery.php | 77 -- core/lib/Thelia/Model/Map/AddressTableMap.php | 44 +- .../lib/Thelia/Model/Map/CustomerTableMap.php | 133 +-- .../Model/Map/CustomerTitleTableMap.php | 2 - install/thelia.sql | 33 +- local/config/schema.xml | 21 +- 11 files changed, 322 insertions(+), 1954 deletions(-) diff --git a/core/lib/Thelia/Model/Base/Address.php b/core/lib/Thelia/Model/Base/Address.php index fe734960b..208d43cdb 100755 --- a/core/lib/Thelia/Model/Base/Address.php +++ b/core/lib/Thelia/Model/Base/Address.php @@ -142,6 +142,19 @@ abstract class Address implements ActiveRecordInterface */ protected $phone; + /** + * The value for the cellphone field. + * @var string + */ + protected $cellphone; + + /** + * The value for the default field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $default; + /** * The value for the created_at field. * @var string @@ -172,11 +185,24 @@ abstract class Address implements ActiveRecordInterface */ protected $alreadyInSave = false; + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->default = 0; + } + /** * Initializes internal state of Thelia\Model\Base\Address object. + * @see applyDefaults() */ public function __construct() { + $this->applyDefaultValues(); } /** @@ -580,6 +606,28 @@ abstract class Address implements ActiveRecordInterface return $this->phone; } + /** + * Get the [cellphone] column value. + * + * @return string + */ + public function getCellphone() + { + + return $this->cellphone; + } + + /** + * Get the [default] column value. + * + * @return int + */ + public function getDefault() + { + + return $this->default; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -922,6 +970,48 @@ abstract class Address implements ActiveRecordInterface return $this; } // setPhone() + /** + * Set the value of [cellphone] column. + * + * @param string $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) + */ + public function setCellphone($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->cellphone !== $v) { + $this->cellphone = $v; + $this->modifiedColumns[] = AddressTableMap::CELLPHONE; + } + + + return $this; + } // setCellphone() + + /** + * Set the value of [default] column. + * + * @param int $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) + */ + public function setDefault($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->default !== $v) { + $this->default = $v; + $this->modifiedColumns[] = AddressTableMap::DEFAULT; + } + + + return $this; + } // setDefault() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -974,6 +1064,10 @@ abstract class Address implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { + if ($this->default !== 0) { + return false; + } + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -1043,13 +1137,19 @@ abstract class Address implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : AddressTableMap::translateFieldName('Phone', TableMap::TYPE_PHPNAME, $indexType)]; $this->phone = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : AddressTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : AddressTableMap::translateFieldName('Cellphone', TableMap::TYPE_PHPNAME, $indexType)]; + $this->cellphone = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : AddressTableMap::translateFieldName('Default', TableMap::TYPE_PHPNAME, $indexType)]; + $this->default = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : AddressTableMap::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 ? 15 + $startcol : AddressTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : AddressTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -1062,7 +1162,7 @@ abstract class Address implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 16; // 16 = AddressTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 18; // 18 = AddressTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Address object", 0, $e); @@ -1351,6 +1451,12 @@ abstract class Address implements ActiveRecordInterface if ($this->isColumnModified(AddressTableMap::PHONE)) { $modifiedColumns[':p' . $index++] = 'PHONE'; } + if ($this->isColumnModified(AddressTableMap::CELLPHONE)) { + $modifiedColumns[':p' . $index++] = 'CELLPHONE'; + } + if ($this->isColumnModified(AddressTableMap::DEFAULT)) { + $modifiedColumns[':p' . $index++] = 'DEFAULT'; + } if ($this->isColumnModified(AddressTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1410,6 +1516,12 @@ abstract class Address implements ActiveRecordInterface case 'PHONE': $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); break; + case 'CELLPHONE': + $stmt->bindValue($identifier, $this->cellphone, PDO::PARAM_STR); + break; + case 'DEFAULT': + $stmt->bindValue($identifier, $this->default, 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); break; @@ -1521,9 +1633,15 @@ abstract class Address implements ActiveRecordInterface return $this->getPhone(); break; case 14: - return $this->getCreatedAt(); + return $this->getCellphone(); break; case 15: + return $this->getDefault(); + break; + case 16: + return $this->getCreatedAt(); + break; + case 17: return $this->getUpdatedAt(); break; default: @@ -1569,8 +1687,10 @@ abstract class Address implements ActiveRecordInterface $keys[11] => $this->getCity(), $keys[12] => $this->getCountryId(), $keys[13] => $this->getPhone(), - $keys[14] => $this->getCreatedAt(), - $keys[15] => $this->getUpdatedAt(), + $keys[14] => $this->getCellphone(), + $keys[15] => $this->getDefault(), + $keys[16] => $this->getCreatedAt(), + $keys[17] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1662,9 +1782,15 @@ abstract class Address implements ActiveRecordInterface $this->setPhone($value); break; case 14: - $this->setCreatedAt($value); + $this->setCellphone($value); break; case 15: + $this->setDefault($value); + break; + case 16: + $this->setCreatedAt($value); + break; + case 17: $this->setUpdatedAt($value); break; } // switch() @@ -1705,8 +1831,10 @@ abstract class Address implements ActiveRecordInterface if (array_key_exists($keys[11], $arr)) $this->setCity($arr[$keys[11]]); if (array_key_exists($keys[12], $arr)) $this->setCountryId($arr[$keys[12]]); if (array_key_exists($keys[13], $arr)) $this->setPhone($arr[$keys[13]]); - if (array_key_exists($keys[14], $arr)) $this->setCreatedAt($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setUpdatedAt($arr[$keys[15]]); + if (array_key_exists($keys[14], $arr)) $this->setCellphone($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setDefault($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setCreatedAt($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setUpdatedAt($arr[$keys[17]]); } /** @@ -1732,6 +1860,8 @@ abstract class Address implements ActiveRecordInterface if ($this->isColumnModified(AddressTableMap::CITY)) $criteria->add(AddressTableMap::CITY, $this->city); if ($this->isColumnModified(AddressTableMap::COUNTRY_ID)) $criteria->add(AddressTableMap::COUNTRY_ID, $this->country_id); if ($this->isColumnModified(AddressTableMap::PHONE)) $criteria->add(AddressTableMap::PHONE, $this->phone); + if ($this->isColumnModified(AddressTableMap::CELLPHONE)) $criteria->add(AddressTableMap::CELLPHONE, $this->cellphone); + if ($this->isColumnModified(AddressTableMap::DEFAULT)) $criteria->add(AddressTableMap::DEFAULT, $this->default); if ($this->isColumnModified(AddressTableMap::CREATED_AT)) $criteria->add(AddressTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(AddressTableMap::UPDATED_AT)) $criteria->add(AddressTableMap::UPDATED_AT, $this->updated_at); @@ -1810,6 +1940,8 @@ abstract class Address implements ActiveRecordInterface $copyObj->setCity($this->getCity()); $copyObj->setCountryId($this->getCountryId()); $copyObj->setPhone($this->getPhone()); + $copyObj->setCellphone($this->getCellphone()); + $copyObj->setDefault($this->getDefault()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1961,10 +2093,13 @@ abstract class Address implements ActiveRecordInterface $this->city = null; $this->country_id = null; $this->phone = null; + $this->cellphone = null; + $this->default = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; $this->clearAllReferences(); + $this->applyDefaultValues(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); diff --git a/core/lib/Thelia/Model/Base/AddressQuery.php b/core/lib/Thelia/Model/Base/AddressQuery.php index 8611f14a8..c0b32975d 100755 --- a/core/lib/Thelia/Model/Base/AddressQuery.php +++ b/core/lib/Thelia/Model/Base/AddressQuery.php @@ -35,6 +35,8 @@ use Thelia\Model\Map\AddressTableMap; * @method ChildAddressQuery orderByCity($order = Criteria::ASC) Order by the city column * @method ChildAddressQuery orderByCountryId($order = Criteria::ASC) Order by the country_id column * @method ChildAddressQuery orderByPhone($order = Criteria::ASC) Order by the phone column + * @method ChildAddressQuery orderByCellphone($order = Criteria::ASC) Order by the cellphone column + * @method ChildAddressQuery orderByDefault($order = Criteria::ASC) Order by the default column * @method ChildAddressQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildAddressQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -52,6 +54,8 @@ use Thelia\Model\Map\AddressTableMap; * @method ChildAddressQuery groupByCity() Group by the city column * @method ChildAddressQuery groupByCountryId() Group by the country_id column * @method ChildAddressQuery groupByPhone() Group by the phone column + * @method ChildAddressQuery groupByCellphone() Group by the cellphone column + * @method ChildAddressQuery groupByDefault() Group by the default column * @method ChildAddressQuery groupByCreatedAt() Group by the created_at column * @method ChildAddressQuery groupByUpdatedAt() Group by the updated_at column * @@ -84,6 +88,8 @@ use Thelia\Model\Map\AddressTableMap; * @method ChildAddress findOneByCity(string $city) Return the first ChildAddress filtered by the city column * @method ChildAddress findOneByCountryId(int $country_id) Return the first ChildAddress filtered by the country_id column * @method ChildAddress findOneByPhone(string $phone) Return the first ChildAddress filtered by the phone column + * @method ChildAddress findOneByCellphone(string $cellphone) Return the first ChildAddress filtered by the cellphone column + * @method ChildAddress findOneByDefault(int $default) Return the first ChildAddress filtered by the default column * @method ChildAddress findOneByCreatedAt(string $created_at) Return the first ChildAddress filtered by the created_at column * @method ChildAddress findOneByUpdatedAt(string $updated_at) Return the first ChildAddress filtered by the updated_at column * @@ -101,6 +107,8 @@ use Thelia\Model\Map\AddressTableMap; * @method array findByCity(string $city) Return ChildAddress objects filtered by the city column * @method array findByCountryId(int $country_id) Return ChildAddress objects filtered by the country_id column * @method array findByPhone(string $phone) Return ChildAddress objects filtered by the phone column + * @method array findByCellphone(string $cellphone) Return ChildAddress objects filtered by the cellphone column + * @method array findByDefault(int $default) Return ChildAddress objects filtered by the default column * @method array findByCreatedAt(string $created_at) Return ChildAddress objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildAddress objects filtered by the updated_at column * @@ -191,7 +199,7 @@ abstract class AddressQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, TITLE, CUSTOMER_ID, CUSTOMER_TITLE_ID, COMPANY, FIRSTNAME, LASTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ZIPCODE, CITY, COUNTRY_ID, PHONE, CREATED_AT, UPDATED_AT FROM address WHERE ID = :p0'; + $sql = 'SELECT ID, TITLE, CUSTOMER_ID, CUSTOMER_TITLE_ID, COMPANY, FIRSTNAME, LASTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ZIPCODE, CITY, COUNTRY_ID, PHONE, CELLPHONE, DEFAULT, CREATED_AT, UPDATED_AT FROM address WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -738,6 +746,76 @@ abstract class AddressQuery extends ModelCriteria return $this->addUsingAlias(AddressTableMap::PHONE, $phone, $comparison); } + /** + * Filter the query on the cellphone column + * + * Example usage: + * + * $query->filterByCellphone('fooValue'); // WHERE cellphone = 'fooValue' + * $query->filterByCellphone('%fooValue%'); // WHERE cellphone LIKE '%fooValue%' + * + * + * @param string $cellphone 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 ChildAddressQuery The current query, for fluid interface + */ + public function filterByCellphone($cellphone = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($cellphone)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $cellphone)) { + $cellphone = str_replace('*', '%', $cellphone); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(AddressTableMap::CELLPHONE, $cellphone, $comparison); + } + + /** + * Filter the query on the default column + * + * Example usage: + * + * $query->filterByDefault(1234); // WHERE default = 1234 + * $query->filterByDefault(array(12, 34)); // WHERE default IN (12, 34) + * $query->filterByDefault(array('min' => 12)); // WHERE default > 12 + * + * + * @param mixed $default 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 ChildAddressQuery The current query, for fluid interface + */ + public function filterByDefault($default = null, $comparison = null) + { + if (is_array($default)) { + $useMinMax = false; + if (isset($default['min'])) { + $this->addUsingAlias(AddressTableMap::DEFAULT, $default['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($default['max'])) { + $this->addUsingAlias(AddressTableMap::DEFAULT, $default['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AddressTableMap::DEFAULT, $default, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Customer.php b/core/lib/Thelia/Model/Base/Customer.php index 6941594a0..5fe9080fd 100755 --- a/core/lib/Thelia/Model/Base/Customer.php +++ b/core/lib/Thelia/Model/Base/Customer.php @@ -21,8 +21,6 @@ use Thelia\Model\Address as ChildAddress; use Thelia\Model\AddressQuery as ChildAddressQuery; use Thelia\Model\Customer as ChildCustomer; use Thelia\Model\CustomerQuery as ChildCustomerQuery; -use Thelia\Model\CustomerTitle as ChildCustomerTitle; -use Thelia\Model\CustomerTitleQuery as ChildCustomerTitleQuery; use Thelia\Model\Order as ChildOrder; use Thelia\Model\OrderQuery as ChildOrderQuery; use Thelia\Model\Map\CustomerTableMap; @@ -73,78 +71,6 @@ abstract class Customer implements ActiveRecordInterface */ protected $ref; - /** - * The value for the customer_title_id field. - * @var int - */ - protected $customer_title_id; - - /** - * The value for the company field. - * @var string - */ - protected $company; - - /** - * The value for the firstname field. - * @var string - */ - protected $firstname; - - /** - * The value for the lastname field. - * @var string - */ - protected $lastname; - - /** - * The value for the address1 field. - * @var string - */ - protected $address1; - - /** - * The value for the address2 field. - * @var string - */ - protected $address2; - - /** - * The value for the address3 field. - * @var string - */ - protected $address3; - - /** - * The value for the zipcode field. - * @var string - */ - protected $zipcode; - - /** - * The value for the city field. - * @var string - */ - protected $city; - - /** - * The value for the country_id field. - * @var int - */ - protected $country_id; - - /** - * The value for the phone field. - * @var string - */ - protected $phone; - - /** - * The value for the cellphone field. - * @var string - */ - protected $cellphone; - /** * The value for the email field. * @var string @@ -163,12 +89,6 @@ abstract class Customer implements ActiveRecordInterface */ protected $algo; - /** - * The value for the salt field. - * @var string - */ - protected $salt; - /** * The value for the reseller field. * @var int @@ -205,11 +125,6 @@ abstract class Customer implements ActiveRecordInterface */ protected $updated_at; - /** - * @var CustomerTitle - */ - protected $aCustomerTitle; - /** * @var ObjectCollection|ChildAddress[] Collection to store aggregation of ChildAddress objects. */ @@ -518,138 +433,6 @@ abstract class Customer implements ActiveRecordInterface return $this->ref; } - /** - * Get the [customer_title_id] column value. - * - * @return int - */ - public function getCustomerTitleId() - { - - return $this->customer_title_id; - } - - /** - * Get the [company] column value. - * - * @return string - */ - public function getCompany() - { - - return $this->company; - } - - /** - * 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 [address1] column value. - * - * @return string - */ - public function getAddress1() - { - - return $this->address1; - } - - /** - * Get the [address2] column value. - * - * @return string - */ - public function getAddress2() - { - - return $this->address2; - } - - /** - * Get the [address3] column value. - * - * @return string - */ - public function getAddress3() - { - - return $this->address3; - } - - /** - * Get the [zipcode] column value. - * - * @return string - */ - public function getZipcode() - { - - return $this->zipcode; - } - - /** - * Get the [city] column value. - * - * @return string - */ - public function getCity() - { - - return $this->city; - } - - /** - * Get the [country_id] column value. - * - * @return int - */ - public function getCountryId() - { - - return $this->country_id; - } - - /** - * Get the [phone] column value. - * - * @return string - */ - public function getPhone() - { - - return $this->phone; - } - - /** - * Get the [cellphone] column value. - * - * @return string - */ - public function getCellphone() - { - - return $this->cellphone; - } - /** * Get the [email] column value. * @@ -683,17 +466,6 @@ abstract class Customer implements ActiveRecordInterface return $this->algo; } - /** - * Get the [salt] column value. - * - * @return string - */ - public function getSalt() - { - - return $this->salt; - } - /** * Get the [reseller] column value. * @@ -820,262 +592,6 @@ abstract class Customer implements ActiveRecordInterface return $this; } // setRef() - /** - * Set the value of [customer_title_id] column. - * - * @param int $v new value - * @return \Thelia\Model\Customer The current object (for fluent API support) - */ - public function setCustomerTitleId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->customer_title_id !== $v) { - $this->customer_title_id = $v; - $this->modifiedColumns[] = CustomerTableMap::CUSTOMER_TITLE_ID; - } - - if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) { - $this->aCustomerTitle = null; - } - - - return $this; - } // setCustomerTitleId() - - /** - * Set the value of [company] column. - * - * @param string $v new value - * @return \Thelia\Model\Customer The current object (for fluent API support) - */ - public function setCompany($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->company !== $v) { - $this->company = $v; - $this->modifiedColumns[] = CustomerTableMap::COMPANY; - } - - - return $this; - } // setCompany() - - /** - * Set the value of [firstname] column. - * - * @param string $v new value - * @return \Thelia\Model\Customer 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[] = CustomerTableMap::FIRSTNAME; - } - - - return $this; - } // setFirstname() - - /** - * Set the value of [lastname] column. - * - * @param string $v new value - * @return \Thelia\Model\Customer 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[] = CustomerTableMap::LASTNAME; - } - - - return $this; - } // setLastname() - - /** - * Set the value of [address1] column. - * - * @param string $v new value - * @return \Thelia\Model\Customer The current object (for fluent API support) - */ - public function setAddress1($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->address1 !== $v) { - $this->address1 = $v; - $this->modifiedColumns[] = CustomerTableMap::ADDRESS1; - } - - - return $this; - } // setAddress1() - - /** - * Set the value of [address2] column. - * - * @param string $v new value - * @return \Thelia\Model\Customer The current object (for fluent API support) - */ - public function setAddress2($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->address2 !== $v) { - $this->address2 = $v; - $this->modifiedColumns[] = CustomerTableMap::ADDRESS2; - } - - - return $this; - } // setAddress2() - - /** - * Set the value of [address3] column. - * - * @param string $v new value - * @return \Thelia\Model\Customer The current object (for fluent API support) - */ - public function setAddress3($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->address3 !== $v) { - $this->address3 = $v; - $this->modifiedColumns[] = CustomerTableMap::ADDRESS3; - } - - - return $this; - } // setAddress3() - - /** - * Set the value of [zipcode] column. - * - * @param string $v new value - * @return \Thelia\Model\Customer The current object (for fluent API support) - */ - public function setZipcode($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->zipcode !== $v) { - $this->zipcode = $v; - $this->modifiedColumns[] = CustomerTableMap::ZIPCODE; - } - - - return $this; - } // setZipcode() - - /** - * Set the value of [city] column. - * - * @param string $v new value - * @return \Thelia\Model\Customer The current object (for fluent API support) - */ - public function setCity($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->city !== $v) { - $this->city = $v; - $this->modifiedColumns[] = CustomerTableMap::CITY; - } - - - return $this; - } // setCity() - - /** - * Set the value of [country_id] column. - * - * @param int $v new value - * @return \Thelia\Model\Customer The current object (for fluent API support) - */ - public function setCountryId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->country_id !== $v) { - $this->country_id = $v; - $this->modifiedColumns[] = CustomerTableMap::COUNTRY_ID; - } - - - return $this; - } // setCountryId() - - /** - * Set the value of [phone] column. - * - * @param string $v new value - * @return \Thelia\Model\Customer The current object (for fluent API support) - */ - public function setPhone($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->phone !== $v) { - $this->phone = $v; - $this->modifiedColumns[] = CustomerTableMap::PHONE; - } - - - return $this; - } // setPhone() - - /** - * Set the value of [cellphone] column. - * - * @param string $v new value - * @return \Thelia\Model\Customer The current object (for fluent API support) - */ - public function setCellphone($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->cellphone !== $v) { - $this->cellphone = $v; - $this->modifiedColumns[] = CustomerTableMap::CELLPHONE; - } - - - return $this; - } // setCellphone() - /** * Set the value of [email] column. * @@ -1139,27 +655,6 @@ abstract class Customer implements ActiveRecordInterface return $this; } // setAlgo() - /** - * Set the value of [salt] column. - * - * @param string $v new value - * @return \Thelia\Model\Customer The current object (for fluent API support) - */ - public function setSalt($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->salt !== $v) { - $this->salt = $v; - $this->modifiedColumns[] = CustomerTableMap::SALT; - } - - - return $this; - } // setSalt() - /** * Set the value of [reseller] column. * @@ -1329,73 +824,34 @@ abstract class Customer implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)]; $this->ref = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerTableMap::translateFieldName('CustomerTitleId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->customer_title_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTableMap::translateFieldName('Company', TableMap::TYPE_PHPNAME, $indexType)]; - $this->company = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)]; - $this->firstname = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CustomerTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)]; - $this->lastname = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CustomerTableMap::translateFieldName('Address1', TableMap::TYPE_PHPNAME, $indexType)]; - $this->address1 = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CustomerTableMap::translateFieldName('Address2', TableMap::TYPE_PHPNAME, $indexType)]; - $this->address2 = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CustomerTableMap::translateFieldName('Address3', TableMap::TYPE_PHPNAME, $indexType)]; - $this->address3 = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CustomerTableMap::translateFieldName('Zipcode', TableMap::TYPE_PHPNAME, $indexType)]; - $this->zipcode = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CustomerTableMap::translateFieldName('City', TableMap::TYPE_PHPNAME, $indexType)]; - $this->city = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CustomerTableMap::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->country_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CustomerTableMap::translateFieldName('Phone', TableMap::TYPE_PHPNAME, $indexType)]; - $this->phone = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CustomerTableMap::translateFieldName('Cellphone', TableMap::TYPE_PHPNAME, $indexType)]; - $this->cellphone = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CustomerTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)]; $this->email = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CustomerTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)]; $this->password = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CustomerTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)]; $this->algo = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : CustomerTableMap::translateFieldName('Salt', TableMap::TYPE_PHPNAME, $indexType)]; - $this->salt = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 18 + $startcol : CustomerTableMap::translateFieldName('Reseller', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CustomerTableMap::translateFieldName('Reseller', TableMap::TYPE_PHPNAME, $indexType)]; $this->reseller = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 19 + $startcol : CustomerTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CustomerTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)]; $this->lang = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 20 + $startcol : CustomerTableMap::translateFieldName('Sponsor', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CustomerTableMap::translateFieldName('Sponsor', TableMap::TYPE_PHPNAME, $indexType)]; $this->sponsor = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 21 + $startcol : CustomerTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CustomerTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)]; $this->discount = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 22 + $startcol : CustomerTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CustomerTableMap::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 ? 23 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -1408,7 +864,7 @@ abstract class Customer implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 24; // 24 = CustomerTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 11; // 11 = CustomerTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Customer object", 0, $e); @@ -1430,9 +886,6 @@ abstract class Customer implements ActiveRecordInterface */ public function ensureConsistency() { - if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) { - $this->aCustomerTitle = null; - } } // ensureConsistency /** @@ -1472,7 +925,6 @@ abstract class Customer implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->aCustomerTitle = null; $this->collAddresses = null; $this->collOrders = null; @@ -1599,18 +1051,6 @@ abstract class Customer implements ActiveRecordInterface if (!$this->alreadyInSave) { $this->alreadyInSave = true; - // We call the save method on the following object(s) if they - // were passed to this object by their corresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCustomerTitle !== null) { - if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) { - $affectedRows += $this->aCustomerTitle->save($con); - } - $this->setCustomerTitle($this->aCustomerTitle); - } - if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -1688,42 +1128,6 @@ abstract class Customer implements ActiveRecordInterface if ($this->isColumnModified(CustomerTableMap::REF)) { $modifiedColumns[':p' . $index++] = 'REF'; } - if ($this->isColumnModified(CustomerTableMap::CUSTOMER_TITLE_ID)) { - $modifiedColumns[':p' . $index++] = 'CUSTOMER_TITLE_ID'; - } - if ($this->isColumnModified(CustomerTableMap::COMPANY)) { - $modifiedColumns[':p' . $index++] = 'COMPANY'; - } - if ($this->isColumnModified(CustomerTableMap::FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = 'FIRSTNAME'; - } - if ($this->isColumnModified(CustomerTableMap::LASTNAME)) { - $modifiedColumns[':p' . $index++] = 'LASTNAME'; - } - if ($this->isColumnModified(CustomerTableMap::ADDRESS1)) { - $modifiedColumns[':p' . $index++] = 'ADDRESS1'; - } - if ($this->isColumnModified(CustomerTableMap::ADDRESS2)) { - $modifiedColumns[':p' . $index++] = 'ADDRESS2'; - } - if ($this->isColumnModified(CustomerTableMap::ADDRESS3)) { - $modifiedColumns[':p' . $index++] = 'ADDRESS3'; - } - if ($this->isColumnModified(CustomerTableMap::ZIPCODE)) { - $modifiedColumns[':p' . $index++] = 'ZIPCODE'; - } - if ($this->isColumnModified(CustomerTableMap::CITY)) { - $modifiedColumns[':p' . $index++] = 'CITY'; - } - if ($this->isColumnModified(CustomerTableMap::COUNTRY_ID)) { - $modifiedColumns[':p' . $index++] = 'COUNTRY_ID'; - } - if ($this->isColumnModified(CustomerTableMap::PHONE)) { - $modifiedColumns[':p' . $index++] = 'PHONE'; - } - if ($this->isColumnModified(CustomerTableMap::CELLPHONE)) { - $modifiedColumns[':p' . $index++] = 'CELLPHONE'; - } if ($this->isColumnModified(CustomerTableMap::EMAIL)) { $modifiedColumns[':p' . $index++] = 'EMAIL'; } @@ -1733,9 +1137,6 @@ abstract class Customer implements ActiveRecordInterface if ($this->isColumnModified(CustomerTableMap::ALGO)) { $modifiedColumns[':p' . $index++] = 'ALGO'; } - if ($this->isColumnModified(CustomerTableMap::SALT)) { - $modifiedColumns[':p' . $index++] = 'SALT'; - } if ($this->isColumnModified(CustomerTableMap::RESELLER)) { $modifiedColumns[':p' . $index++] = 'RESELLER'; } @@ -1771,42 +1172,6 @@ abstract class Customer implements ActiveRecordInterface case 'REF': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case 'CUSTOMER_TITLE_ID': - $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT); - break; - case 'COMPANY': - $stmt->bindValue($identifier, $this->company, 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 'ADDRESS1': - $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR); - break; - case 'ADDRESS2': - $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR); - break; - case 'ADDRESS3': - $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR); - break; - case 'ZIPCODE': - $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR); - break; - case 'CITY': - $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR); - break; - case 'COUNTRY_ID': - $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT); - break; - case 'PHONE': - $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); - break; - case 'CELLPHONE': - $stmt->bindValue($identifier, $this->cellphone, PDO::PARAM_STR); - break; case 'EMAIL': $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR); break; @@ -1816,9 +1181,6 @@ abstract class Customer implements ActiveRecordInterface case 'ALGO': $stmt->bindValue($identifier, $this->algo, PDO::PARAM_STR); break; - case 'SALT': - $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR); - break; case 'RESELLER': $stmt->bindValue($identifier, $this->reseller, PDO::PARAM_INT); break; @@ -1906,69 +1268,30 @@ abstract class Customer implements ActiveRecordInterface return $this->getRef(); break; case 2: - return $this->getCustomerTitleId(); - break; - case 3: - return $this->getCompany(); - break; - case 4: - return $this->getFirstname(); - break; - case 5: - return $this->getLastname(); - break; - case 6: - return $this->getAddress1(); - break; - case 7: - return $this->getAddress2(); - break; - case 8: - return $this->getAddress3(); - break; - case 9: - return $this->getZipcode(); - break; - case 10: - return $this->getCity(); - break; - case 11: - return $this->getCountryId(); - break; - case 12: - return $this->getPhone(); - break; - case 13: - return $this->getCellphone(); - break; - case 14: return $this->getEmail(); break; - case 15: + case 3: return $this->getPassword(); break; - case 16: + case 4: return $this->getAlgo(); break; - case 17: - return $this->getSalt(); - break; - case 18: + case 5: return $this->getReseller(); break; - case 19: + case 6: return $this->getLang(); break; - case 20: + case 7: return $this->getSponsor(); break; - case 21: + case 8: return $this->getDiscount(); break; - case 22: + case 9: return $this->getCreatedAt(); break; - case 23: + case 10: return $this->getUpdatedAt(); break; default: @@ -2002,28 +1325,15 @@ abstract class Customer implements ActiveRecordInterface $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getRef(), - $keys[2] => $this->getCustomerTitleId(), - $keys[3] => $this->getCompany(), - $keys[4] => $this->getFirstname(), - $keys[5] => $this->getLastname(), - $keys[6] => $this->getAddress1(), - $keys[7] => $this->getAddress2(), - $keys[8] => $this->getAddress3(), - $keys[9] => $this->getZipcode(), - $keys[10] => $this->getCity(), - $keys[11] => $this->getCountryId(), - $keys[12] => $this->getPhone(), - $keys[13] => $this->getCellphone(), - $keys[14] => $this->getEmail(), - $keys[15] => $this->getPassword(), - $keys[16] => $this->getAlgo(), - $keys[17] => $this->getSalt(), - $keys[18] => $this->getReseller(), - $keys[19] => $this->getLang(), - $keys[20] => $this->getSponsor(), - $keys[21] => $this->getDiscount(), - $keys[22] => $this->getCreatedAt(), - $keys[23] => $this->getUpdatedAt(), + $keys[2] => $this->getEmail(), + $keys[3] => $this->getPassword(), + $keys[4] => $this->getAlgo(), + $keys[5] => $this->getReseller(), + $keys[6] => $this->getLang(), + $keys[7] => $this->getSponsor(), + $keys[8] => $this->getDiscount(), + $keys[9] => $this->getCreatedAt(), + $keys[10] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -2032,9 +1342,6 @@ abstract class Customer implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->aCustomerTitle) { - $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } if (null !== $this->collAddresses) { $result['Addresses'] = $this->collAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -2082,69 +1389,30 @@ abstract class Customer implements ActiveRecordInterface $this->setRef($value); break; case 2: - $this->setCustomerTitleId($value); - break; - case 3: - $this->setCompany($value); - break; - case 4: - $this->setFirstname($value); - break; - case 5: - $this->setLastname($value); - break; - case 6: - $this->setAddress1($value); - break; - case 7: - $this->setAddress2($value); - break; - case 8: - $this->setAddress3($value); - break; - case 9: - $this->setZipcode($value); - break; - case 10: - $this->setCity($value); - break; - case 11: - $this->setCountryId($value); - break; - case 12: - $this->setPhone($value); - break; - case 13: - $this->setCellphone($value); - break; - case 14: $this->setEmail($value); break; - case 15: + case 3: $this->setPassword($value); break; - case 16: + case 4: $this->setAlgo($value); break; - case 17: - $this->setSalt($value); - break; - case 18: + case 5: $this->setReseller($value); break; - case 19: + case 6: $this->setLang($value); break; - case 20: + case 7: $this->setSponsor($value); break; - case 21: + case 8: $this->setDiscount($value); break; - case 22: + case 9: $this->setCreatedAt($value); break; - case 23: + case 10: $this->setUpdatedAt($value); break; } // switch() @@ -2173,28 +1441,15 @@ abstract class Customer implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCustomerTitleId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCompany($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setFirstname($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setLastname($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setAddress1($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setAddress2($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setAddress3($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setZipcode($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setCity($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setCountryId($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setPhone($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setCellphone($arr[$keys[13]]); - if (array_key_exists($keys[14], $arr)) $this->setEmail($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setPassword($arr[$keys[15]]); - if (array_key_exists($keys[16], $arr)) $this->setAlgo($arr[$keys[16]]); - if (array_key_exists($keys[17], $arr)) $this->setSalt($arr[$keys[17]]); - if (array_key_exists($keys[18], $arr)) $this->setReseller($arr[$keys[18]]); - if (array_key_exists($keys[19], $arr)) $this->setLang($arr[$keys[19]]); - if (array_key_exists($keys[20], $arr)) $this->setSponsor($arr[$keys[20]]); - if (array_key_exists($keys[21], $arr)) $this->setDiscount($arr[$keys[21]]); - if (array_key_exists($keys[22], $arr)) $this->setCreatedAt($arr[$keys[22]]); - if (array_key_exists($keys[23], $arr)) $this->setUpdatedAt($arr[$keys[23]]); + if (array_key_exists($keys[2], $arr)) $this->setEmail($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPassword($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setAlgo($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setReseller($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setLang($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setSponsor($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDiscount($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setUpdatedAt($arr[$keys[10]]); } /** @@ -2208,22 +1463,9 @@ abstract class Customer implements ActiveRecordInterface if ($this->isColumnModified(CustomerTableMap::ID)) $criteria->add(CustomerTableMap::ID, $this->id); if ($this->isColumnModified(CustomerTableMap::REF)) $criteria->add(CustomerTableMap::REF, $this->ref); - if ($this->isColumnModified(CustomerTableMap::CUSTOMER_TITLE_ID)) $criteria->add(CustomerTableMap::CUSTOMER_TITLE_ID, $this->customer_title_id); - if ($this->isColumnModified(CustomerTableMap::COMPANY)) $criteria->add(CustomerTableMap::COMPANY, $this->company); - if ($this->isColumnModified(CustomerTableMap::FIRSTNAME)) $criteria->add(CustomerTableMap::FIRSTNAME, $this->firstname); - if ($this->isColumnModified(CustomerTableMap::LASTNAME)) $criteria->add(CustomerTableMap::LASTNAME, $this->lastname); - if ($this->isColumnModified(CustomerTableMap::ADDRESS1)) $criteria->add(CustomerTableMap::ADDRESS1, $this->address1); - if ($this->isColumnModified(CustomerTableMap::ADDRESS2)) $criteria->add(CustomerTableMap::ADDRESS2, $this->address2); - if ($this->isColumnModified(CustomerTableMap::ADDRESS3)) $criteria->add(CustomerTableMap::ADDRESS3, $this->address3); - if ($this->isColumnModified(CustomerTableMap::ZIPCODE)) $criteria->add(CustomerTableMap::ZIPCODE, $this->zipcode); - if ($this->isColumnModified(CustomerTableMap::CITY)) $criteria->add(CustomerTableMap::CITY, $this->city); - if ($this->isColumnModified(CustomerTableMap::COUNTRY_ID)) $criteria->add(CustomerTableMap::COUNTRY_ID, $this->country_id); - if ($this->isColumnModified(CustomerTableMap::PHONE)) $criteria->add(CustomerTableMap::PHONE, $this->phone); - if ($this->isColumnModified(CustomerTableMap::CELLPHONE)) $criteria->add(CustomerTableMap::CELLPHONE, $this->cellphone); if ($this->isColumnModified(CustomerTableMap::EMAIL)) $criteria->add(CustomerTableMap::EMAIL, $this->email); if ($this->isColumnModified(CustomerTableMap::PASSWORD)) $criteria->add(CustomerTableMap::PASSWORD, $this->password); if ($this->isColumnModified(CustomerTableMap::ALGO)) $criteria->add(CustomerTableMap::ALGO, $this->algo); - if ($this->isColumnModified(CustomerTableMap::SALT)) $criteria->add(CustomerTableMap::SALT, $this->salt); if ($this->isColumnModified(CustomerTableMap::RESELLER)) $criteria->add(CustomerTableMap::RESELLER, $this->reseller); if ($this->isColumnModified(CustomerTableMap::LANG)) $criteria->add(CustomerTableMap::LANG, $this->lang); if ($this->isColumnModified(CustomerTableMap::SPONSOR)) $criteria->add(CustomerTableMap::SPONSOR, $this->sponsor); @@ -2294,22 +1536,9 @@ abstract class Customer implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setRef($this->getRef()); - $copyObj->setCustomerTitleId($this->getCustomerTitleId()); - $copyObj->setCompany($this->getCompany()); - $copyObj->setFirstname($this->getFirstname()); - $copyObj->setLastname($this->getLastname()); - $copyObj->setAddress1($this->getAddress1()); - $copyObj->setAddress2($this->getAddress2()); - $copyObj->setAddress3($this->getAddress3()); - $copyObj->setZipcode($this->getZipcode()); - $copyObj->setCity($this->getCity()); - $copyObj->setCountryId($this->getCountryId()); - $copyObj->setPhone($this->getPhone()); - $copyObj->setCellphone($this->getCellphone()); $copyObj->setEmail($this->getEmail()); $copyObj->setPassword($this->getPassword()); $copyObj->setAlgo($this->getAlgo()); - $copyObj->setSalt($this->getSalt()); $copyObj->setReseller($this->getReseller()); $copyObj->setLang($this->getLang()); $copyObj->setSponsor($this->getSponsor()); @@ -2364,57 +1593,6 @@ abstract class Customer implements ActiveRecordInterface return $copyObj; } - /** - * Declares an association between this object and a ChildCustomerTitle object. - * - * @param ChildCustomerTitle $v - * @return \Thelia\Model\Customer The current object (for fluent API support) - * @throws PropelException - */ - public function setCustomerTitle(ChildCustomerTitle $v = null) - { - if ($v === null) { - $this->setCustomerTitleId(NULL); - } else { - $this->setCustomerTitleId($v->getId()); - } - - $this->aCustomerTitle = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildCustomerTitle object, it will not be re-added. - if ($v !== null) { - $v->addCustomer($this); - } - - - return $this; - } - - - /** - * Get the associated ChildCustomerTitle object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildCustomerTitle The associated ChildCustomerTitle object. - * @throws PropelException - */ - public function getCustomerTitle(ConnectionInterface $con = null) - { - if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) { - $this->aCustomerTitle = ChildCustomerTitleQuery::create()->findPk($this->customer_title_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCustomerTitle->addCustomers($this); - */ - } - - return $this->aCustomerTitle; - } - /** * Initializes a collection based on the name of a relation. @@ -3002,22 +2180,9 @@ abstract class Customer implements ActiveRecordInterface { $this->id = null; $this->ref = null; - $this->customer_title_id = null; - $this->company = null; - $this->firstname = null; - $this->lastname = null; - $this->address1 = null; - $this->address2 = null; - $this->address3 = null; - $this->zipcode = null; - $this->city = null; - $this->country_id = null; - $this->phone = null; - $this->cellphone = null; $this->email = null; $this->password = null; $this->algo = null; - $this->salt = null; $this->reseller = null; $this->lang = null; $this->sponsor = null; @@ -3063,7 +2228,6 @@ abstract class Customer implements ActiveRecordInterface $this->collOrders->clearIterator(); } $this->collOrders = null; - $this->aCustomerTitle = null; } /** diff --git a/core/lib/Thelia/Model/Base/CustomerQuery.php b/core/lib/Thelia/Model/Base/CustomerQuery.php index eb6371592..5bc89fa3b 100755 --- a/core/lib/Thelia/Model/Base/CustomerQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerQuery.php @@ -23,22 +23,9 @@ use Thelia\Model\Map\CustomerTableMap; * * @method ChildCustomerQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildCustomerQuery orderByRef($order = Criteria::ASC) Order by the ref column - * @method ChildCustomerQuery orderByCustomerTitleId($order = Criteria::ASC) Order by the customer_title_id column - * @method ChildCustomerQuery orderByCompany($order = Criteria::ASC) Order by the company column - * @method ChildCustomerQuery orderByFirstname($order = Criteria::ASC) Order by the firstname column - * @method ChildCustomerQuery orderByLastname($order = Criteria::ASC) Order by the lastname column - * @method ChildCustomerQuery orderByAddress1($order = Criteria::ASC) Order by the address1 column - * @method ChildCustomerQuery orderByAddress2($order = Criteria::ASC) Order by the address2 column - * @method ChildCustomerQuery orderByAddress3($order = Criteria::ASC) Order by the address3 column - * @method ChildCustomerQuery orderByZipcode($order = Criteria::ASC) Order by the zipcode column - * @method ChildCustomerQuery orderByCity($order = Criteria::ASC) Order by the city column - * @method ChildCustomerQuery orderByCountryId($order = Criteria::ASC) Order by the country_id column - * @method ChildCustomerQuery orderByPhone($order = Criteria::ASC) Order by the phone column - * @method ChildCustomerQuery orderByCellphone($order = Criteria::ASC) Order by the cellphone column * @method ChildCustomerQuery orderByEmail($order = Criteria::ASC) Order by the email column * @method ChildCustomerQuery orderByPassword($order = Criteria::ASC) Order by the password column * @method ChildCustomerQuery orderByAlgo($order = Criteria::ASC) Order by the algo column - * @method ChildCustomerQuery orderBySalt($order = Criteria::ASC) Order by the salt column * @method ChildCustomerQuery orderByReseller($order = Criteria::ASC) Order by the reseller column * @method ChildCustomerQuery orderByLang($order = Criteria::ASC) Order by the lang column * @method ChildCustomerQuery orderBySponsor($order = Criteria::ASC) Order by the sponsor column @@ -48,22 +35,9 @@ use Thelia\Model\Map\CustomerTableMap; * * @method ChildCustomerQuery groupById() Group by the id column * @method ChildCustomerQuery groupByRef() Group by the ref column - * @method ChildCustomerQuery groupByCustomerTitleId() Group by the customer_title_id column - * @method ChildCustomerQuery groupByCompany() Group by the company column - * @method ChildCustomerQuery groupByFirstname() Group by the firstname column - * @method ChildCustomerQuery groupByLastname() Group by the lastname column - * @method ChildCustomerQuery groupByAddress1() Group by the address1 column - * @method ChildCustomerQuery groupByAddress2() Group by the address2 column - * @method ChildCustomerQuery groupByAddress3() Group by the address3 column - * @method ChildCustomerQuery groupByZipcode() Group by the zipcode column - * @method ChildCustomerQuery groupByCity() Group by the city column - * @method ChildCustomerQuery groupByCountryId() Group by the country_id column - * @method ChildCustomerQuery groupByPhone() Group by the phone column - * @method ChildCustomerQuery groupByCellphone() Group by the cellphone column * @method ChildCustomerQuery groupByEmail() Group by the email column * @method ChildCustomerQuery groupByPassword() Group by the password column * @method ChildCustomerQuery groupByAlgo() Group by the algo column - * @method ChildCustomerQuery groupBySalt() Group by the salt column * @method ChildCustomerQuery groupByReseller() Group by the reseller column * @method ChildCustomerQuery groupByLang() Group by the lang column * @method ChildCustomerQuery groupBySponsor() Group by the sponsor column @@ -75,10 +49,6 @@ use Thelia\Model\Map\CustomerTableMap; * @method ChildCustomerQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildCustomerQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildCustomerQuery leftJoinCustomerTitle($relationAlias = null) Adds a LEFT JOIN clause to the query using the CustomerTitle relation - * @method ChildCustomerQuery rightJoinCustomerTitle($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerTitle relation - * @method ChildCustomerQuery innerJoinCustomerTitle($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerTitle relation - * * @method ChildCustomerQuery leftJoinAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the Address relation * @method ChildCustomerQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation * @method ChildCustomerQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation @@ -92,22 +62,9 @@ use Thelia\Model\Map\CustomerTableMap; * * @method ChildCustomer findOneById(int $id) Return the first ChildCustomer filtered by the id column * @method ChildCustomer findOneByRef(string $ref) Return the first ChildCustomer filtered by the ref column - * @method ChildCustomer findOneByCustomerTitleId(int $customer_title_id) Return the first ChildCustomer filtered by the customer_title_id column - * @method ChildCustomer findOneByCompany(string $company) Return the first ChildCustomer filtered by the company column - * @method ChildCustomer findOneByFirstname(string $firstname) Return the first ChildCustomer filtered by the firstname column - * @method ChildCustomer findOneByLastname(string $lastname) Return the first ChildCustomer filtered by the lastname column - * @method ChildCustomer findOneByAddress1(string $address1) Return the first ChildCustomer filtered by the address1 column - * @method ChildCustomer findOneByAddress2(string $address2) Return the first ChildCustomer filtered by the address2 column - * @method ChildCustomer findOneByAddress3(string $address3) Return the first ChildCustomer filtered by the address3 column - * @method ChildCustomer findOneByZipcode(string $zipcode) Return the first ChildCustomer filtered by the zipcode column - * @method ChildCustomer findOneByCity(string $city) Return the first ChildCustomer filtered by the city column - * @method ChildCustomer findOneByCountryId(int $country_id) Return the first ChildCustomer filtered by the country_id column - * @method ChildCustomer findOneByPhone(string $phone) Return the first ChildCustomer filtered by the phone column - * @method ChildCustomer findOneByCellphone(string $cellphone) Return the first ChildCustomer filtered by the cellphone column * @method ChildCustomer findOneByEmail(string $email) Return the first ChildCustomer filtered by the email column * @method ChildCustomer findOneByPassword(string $password) Return the first ChildCustomer filtered by the password column * @method ChildCustomer findOneByAlgo(string $algo) Return the first ChildCustomer filtered by the algo column - * @method ChildCustomer findOneBySalt(string $salt) Return the first ChildCustomer filtered by the salt column * @method ChildCustomer findOneByReseller(int $reseller) Return the first ChildCustomer filtered by the reseller column * @method ChildCustomer findOneByLang(string $lang) Return the first ChildCustomer filtered by the lang column * @method ChildCustomer findOneBySponsor(string $sponsor) Return the first ChildCustomer filtered by the sponsor column @@ -117,22 +74,9 @@ use Thelia\Model\Map\CustomerTableMap; * * @method array findById(int $id) Return ChildCustomer objects filtered by the id column * @method array findByRef(string $ref) Return ChildCustomer objects filtered by the ref column - * @method array findByCustomerTitleId(int $customer_title_id) Return ChildCustomer objects filtered by the customer_title_id column - * @method array findByCompany(string $company) Return ChildCustomer objects filtered by the company column - * @method array findByFirstname(string $firstname) Return ChildCustomer objects filtered by the firstname column - * @method array findByLastname(string $lastname) Return ChildCustomer objects filtered by the lastname column - * @method array findByAddress1(string $address1) Return ChildCustomer objects filtered by the address1 column - * @method array findByAddress2(string $address2) Return ChildCustomer objects filtered by the address2 column - * @method array findByAddress3(string $address3) Return ChildCustomer objects filtered by the address3 column - * @method array findByZipcode(string $zipcode) Return ChildCustomer objects filtered by the zipcode column - * @method array findByCity(string $city) Return ChildCustomer objects filtered by the city column - * @method array findByCountryId(int $country_id) Return ChildCustomer objects filtered by the country_id column - * @method array findByPhone(string $phone) Return ChildCustomer objects filtered by the phone column - * @method array findByCellphone(string $cellphone) Return ChildCustomer objects filtered by the cellphone column * @method array findByEmail(string $email) Return ChildCustomer objects filtered by the email column * @method array findByPassword(string $password) Return ChildCustomer objects filtered by the password column * @method array findByAlgo(string $algo) Return ChildCustomer objects filtered by the algo column - * @method array findBySalt(string $salt) Return ChildCustomer objects filtered by the salt column * @method array findByReseller(int $reseller) Return ChildCustomer objects filtered by the reseller column * @method array findByLang(string $lang) Return ChildCustomer objects filtered by the lang column * @method array findBySponsor(string $sponsor) Return ChildCustomer objects filtered by the sponsor column @@ -227,7 +171,7 @@ abstract class CustomerQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, REF, CUSTOMER_TITLE_ID, COMPANY, FIRSTNAME, LASTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ZIPCODE, CITY, COUNTRY_ID, PHONE, CELLPHONE, EMAIL, PASSWORD, ALGO, SALT, RESELLER, LANG, SPONSOR, DISCOUNT, CREATED_AT, UPDATED_AT FROM customer WHERE ID = :p0'; + $sql = 'SELECT ID, REF, EMAIL, PASSWORD, ALGO, RESELLER, LANG, SPONSOR, DISCOUNT, CREATED_AT, UPDATED_AT FROM customer WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -386,380 +330,6 @@ abstract class CustomerQuery extends ModelCriteria return $this->addUsingAlias(CustomerTableMap::REF, $ref, $comparison); } - /** - * Filter the query on the customer_title_id column - * - * Example usage: - * - * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234 - * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34) - * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12 - * - * - * @see filterByCustomerTitle() - * - * @param mixed $customerTitleId 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 ChildCustomerQuery The current query, for fluid interface - */ - public function filterByCustomerTitleId($customerTitleId = null, $comparison = null) - { - if (is_array($customerTitleId)) { - $useMinMax = false; - if (isset($customerTitleId['min'])) { - $this->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($customerTitleId['max'])) { - $this->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitleId, $comparison); - } - - /** - * Filter the query on the company column - * - * Example usage: - * - * $query->filterByCompany('fooValue'); // WHERE company = 'fooValue' - * $query->filterByCompany('%fooValue%'); // WHERE company LIKE '%fooValue%' - * - * - * @param string $company 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 ChildCustomerQuery The current query, for fluid interface - */ - public function filterByCompany($company = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($company)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $company)) { - $company = str_replace('*', '%', $company); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerTableMap::COMPANY, $company, $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 ChildCustomerQuery 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(CustomerTableMap::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 ChildCustomerQuery 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(CustomerTableMap::LASTNAME, $lastname, $comparison); - } - - /** - * Filter the query on the address1 column - * - * Example usage: - * - * $query->filterByAddress1('fooValue'); // WHERE address1 = 'fooValue' - * $query->filterByAddress1('%fooValue%'); // WHERE address1 LIKE '%fooValue%' - * - * - * @param string $address1 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 ChildCustomerQuery The current query, for fluid interface - */ - public function filterByAddress1($address1 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($address1)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $address1)) { - $address1 = str_replace('*', '%', $address1); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerTableMap::ADDRESS1, $address1, $comparison); - } - - /** - * Filter the query on the address2 column - * - * Example usage: - * - * $query->filterByAddress2('fooValue'); // WHERE address2 = 'fooValue' - * $query->filterByAddress2('%fooValue%'); // WHERE address2 LIKE '%fooValue%' - * - * - * @param string $address2 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 ChildCustomerQuery The current query, for fluid interface - */ - public function filterByAddress2($address2 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($address2)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $address2)) { - $address2 = str_replace('*', '%', $address2); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerTableMap::ADDRESS2, $address2, $comparison); - } - - /** - * Filter the query on the address3 column - * - * Example usage: - * - * $query->filterByAddress3('fooValue'); // WHERE address3 = 'fooValue' - * $query->filterByAddress3('%fooValue%'); // WHERE address3 LIKE '%fooValue%' - * - * - * @param string $address3 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 ChildCustomerQuery The current query, for fluid interface - */ - public function filterByAddress3($address3 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($address3)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $address3)) { - $address3 = str_replace('*', '%', $address3); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerTableMap::ADDRESS3, $address3, $comparison); - } - - /** - * Filter the query on the zipcode column - * - * Example usage: - * - * $query->filterByZipcode('fooValue'); // WHERE zipcode = 'fooValue' - * $query->filterByZipcode('%fooValue%'); // WHERE zipcode LIKE '%fooValue%' - * - * - * @param string $zipcode 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 ChildCustomerQuery The current query, for fluid interface - */ - public function filterByZipcode($zipcode = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($zipcode)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $zipcode)) { - $zipcode = str_replace('*', '%', $zipcode); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerTableMap::ZIPCODE, $zipcode, $comparison); - } - - /** - * Filter the query on the city column - * - * Example usage: - * - * $query->filterByCity('fooValue'); // WHERE city = 'fooValue' - * $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%' - * - * - * @param string $city 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 ChildCustomerQuery The current query, for fluid interface - */ - public function filterByCity($city = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($city)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $city)) { - $city = str_replace('*', '%', $city); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerTableMap::CITY, $city, $comparison); - } - - /** - * Filter the query on the country_id column - * - * Example usage: - * - * $query->filterByCountryId(1234); // WHERE country_id = 1234 - * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34) - * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12 - * - * - * @param mixed $countryId 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 ChildCustomerQuery The current query, for fluid interface - */ - public function filterByCountryId($countryId = null, $comparison = null) - { - if (is_array($countryId)) { - $useMinMax = false; - if (isset($countryId['min'])) { - $this->addUsingAlias(CustomerTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($countryId['max'])) { - $this->addUsingAlias(CustomerTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerTableMap::COUNTRY_ID, $countryId, $comparison); - } - - /** - * Filter the query on the phone column - * - * Example usage: - * - * $query->filterByPhone('fooValue'); // WHERE phone = 'fooValue' - * $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%' - * - * - * @param string $phone 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 ChildCustomerQuery The current query, for fluid interface - */ - public function filterByPhone($phone = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($phone)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $phone)) { - $phone = str_replace('*', '%', $phone); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerTableMap::PHONE, $phone, $comparison); - } - - /** - * Filter the query on the cellphone column - * - * Example usage: - * - * $query->filterByCellphone('fooValue'); // WHERE cellphone = 'fooValue' - * $query->filterByCellphone('%fooValue%'); // WHERE cellphone LIKE '%fooValue%' - * - * - * @param string $cellphone 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 ChildCustomerQuery The current query, for fluid interface - */ - public function filterByCellphone($cellphone = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($cellphone)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $cellphone)) { - $cellphone = str_replace('*', '%', $cellphone); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerTableMap::CELLPHONE, $cellphone, $comparison); - } - /** * Filter the query on the email column * @@ -847,35 +417,6 @@ abstract class CustomerQuery extends ModelCriteria return $this->addUsingAlias(CustomerTableMap::ALGO, $algo, $comparison); } - /** - * Filter the query on the salt column - * - * Example usage: - * - * $query->filterBySalt('fooValue'); // WHERE salt = 'fooValue' - * $query->filterBySalt('%fooValue%'); // WHERE salt LIKE '%fooValue%' - * - * - * @param string $salt 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 ChildCustomerQuery The current query, for fluid interface - */ - public function filterBySalt($salt = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($salt)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $salt)) { - $salt = str_replace('*', '%', $salt); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerTableMap::SALT, $salt, $comparison); - } - /** * Filter the query on the reseller column * @@ -1102,81 +643,6 @@ abstract class CustomerQuery extends ModelCriteria return $this->addUsingAlias(CustomerTableMap::UPDATED_AT, $updatedAt, $comparison); } - /** - * Filter the query by a related \Thelia\Model\CustomerTitle object - * - * @param \Thelia\Model\CustomerTitle|ObjectCollection $customerTitle The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCustomerQuery The current query, for fluid interface - */ - public function filterByCustomerTitle($customerTitle, $comparison = null) - { - if ($customerTitle instanceof \Thelia\Model\CustomerTitle) { - return $this - ->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison); - } elseif ($customerTitle instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCustomerTitle() only accepts arguments of type \Thelia\Model\CustomerTitle or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the CustomerTitle relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildCustomerQuery The current query, for fluid interface - */ - public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CustomerTitle'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'CustomerTitle'); - } - - return $this; - } - - /** - * Use the CustomerTitle relation CustomerTitle object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query - */ - public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCustomerTitle($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery'); - } - /** * Filter the query by a related \Thelia\Model\Address object * diff --git a/core/lib/Thelia/Model/Base/CustomerTitle.php b/core/lib/Thelia/Model/Base/CustomerTitle.php index d126839d0..459940747 100755 --- a/core/lib/Thelia/Model/Base/CustomerTitle.php +++ b/core/lib/Thelia/Model/Base/CustomerTitle.php @@ -19,8 +19,6 @@ use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Address as ChildAddress; use Thelia\Model\AddressQuery as ChildAddressQuery; -use Thelia\Model\Customer as ChildCustomer; -use Thelia\Model\CustomerQuery as ChildCustomerQuery; use Thelia\Model\CustomerTitle as ChildCustomerTitle; use Thelia\Model\CustomerTitleI18n as ChildCustomerTitleI18n; use Thelia\Model\CustomerTitleI18nQuery as ChildCustomerTitleI18nQuery; @@ -92,12 +90,6 @@ abstract class CustomerTitle implements ActiveRecordInterface */ protected $updated_at; - /** - * @var ObjectCollection|ChildCustomer[] Collection to store aggregation of ChildCustomer objects. - */ - protected $collCustomers; - protected $collCustomersPartial; - /** * @var ObjectCollection|ChildAddress[] Collection to store aggregation of ChildAddress objects. */ @@ -132,12 +124,6 @@ abstract class CustomerTitle implements ActiveRecordInterface */ protected $currentTranslations; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $customersScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -725,8 +711,6 @@ abstract class CustomerTitle implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->collCustomers = null; - $this->collAddresses = null; $this->collCustomerTitleI18ns = null; @@ -864,24 +848,6 @@ abstract class CustomerTitle implements ActiveRecordInterface $this->resetModified(); } - if ($this->customersScheduledForDeletion !== null) { - if (!$this->customersScheduledForDeletion->isEmpty()) { - foreach ($this->customersScheduledForDeletion as $customer) { - // need to save related object because we set the relation to null - $customer->save($con); - } - $this->customersScheduledForDeletion = null; - } - } - - if ($this->collCustomers !== null) { - foreach ($this->collCustomers as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->addressesScheduledForDeletion !== null) { if (!$this->addressesScheduledForDeletion->isEmpty()) { foreach ($this->addressesScheduledForDeletion as $address) { @@ -1103,9 +1069,6 @@ abstract class CustomerTitle implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->collCustomers) { - $result['Customers'] = $this->collCustomers->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collAddresses) { $result['Addresses'] = $this->collAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1279,12 +1242,6 @@ abstract class CustomerTitle implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getCustomers() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCustomer($relObj->copy($deepCopy)); - } - } - foreach ($this->getAddresses() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addAddress($relObj->copy($deepCopy)); @@ -1338,9 +1295,6 @@ abstract class CustomerTitle implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('Customer' == $relationName) { - return $this->initCustomers(); - } if ('Address' == $relationName) { return $this->initAddresses(); } @@ -1349,224 +1303,6 @@ abstract class CustomerTitle implements ActiveRecordInterface } } - /** - * Clears out the collCustomers collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addCustomers() - */ - public function clearCustomers() - { - $this->collCustomers = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collCustomers collection loaded partially. - */ - public function resetPartialCustomers($v = true) - { - $this->collCustomersPartial = $v; - } - - /** - * Initializes the collCustomers collection. - * - * By default this just sets the collCustomers collection to an empty array (like clearcollCustomers()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initCustomers($overrideExisting = true) - { - if (null !== $this->collCustomers && !$overrideExisting) { - return; - } - $this->collCustomers = new ObjectCollection(); - $this->collCustomers->setModel('\Thelia\Model\Customer'); - } - - /** - * Gets an array of ChildCustomer objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildCustomerTitle is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildCustomer[] List of ChildCustomer objects - * @throws PropelException - */ - public function getCustomers($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collCustomersPartial && !$this->isNew(); - if (null === $this->collCustomers || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCustomers) { - // return empty collection - $this->initCustomers(); - } else { - $collCustomers = ChildCustomerQuery::create(null, $criteria) - ->filterByCustomerTitle($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collCustomersPartial && count($collCustomers)) { - $this->initCustomers(false); - - foreach ($collCustomers as $obj) { - if (false == $this->collCustomers->contains($obj)) { - $this->collCustomers->append($obj); - } - } - - $this->collCustomersPartial = true; - } - - $collCustomers->getInternalIterator()->rewind(); - - return $collCustomers; - } - - if ($partial && $this->collCustomers) { - foreach ($this->collCustomers as $obj) { - if ($obj->isNew()) { - $collCustomers[] = $obj; - } - } - } - - $this->collCustomers = $collCustomers; - $this->collCustomersPartial = false; - } - } - - return $this->collCustomers; - } - - /** - * Sets a collection of Customer objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $customers A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildCustomerTitle The current object (for fluent API support) - */ - public function setCustomers(Collection $customers, ConnectionInterface $con = null) - { - $customersToDelete = $this->getCustomers(new Criteria(), $con)->diff($customers); - - - $this->customersScheduledForDeletion = $customersToDelete; - - foreach ($customersToDelete as $customerRemoved) { - $customerRemoved->setCustomerTitle(null); - } - - $this->collCustomers = null; - foreach ($customers as $customer) { - $this->addCustomer($customer); - } - - $this->collCustomers = $customers; - $this->collCustomersPartial = false; - - return $this; - } - - /** - * Returns the number of related Customer objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related Customer objects. - * @throws PropelException - */ - public function countCustomers(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collCustomersPartial && !$this->isNew(); - if (null === $this->collCustomers || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCustomers) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getCustomers()); - } - - $query = ChildCustomerQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCustomerTitle($this) - ->count($con); - } - - return count($this->collCustomers); - } - - /** - * Method called to associate a ChildCustomer object to this object - * through the ChildCustomer foreign key attribute. - * - * @param ChildCustomer $l ChildCustomer - * @return \Thelia\Model\CustomerTitle The current object (for fluent API support) - */ - public function addCustomer(ChildCustomer $l) - { - if ($this->collCustomers === null) { - $this->initCustomers(); - $this->collCustomersPartial = true; - } - - if (!in_array($l, $this->collCustomers->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddCustomer($l); - } - - return $this; - } - - /** - * @param Customer $customer The customer object to add. - */ - protected function doAddCustomer($customer) - { - $this->collCustomers[]= $customer; - $customer->setCustomerTitle($this); - } - - /** - * @param Customer $customer The customer object to remove. - * @return ChildCustomerTitle The current object (for fluent API support) - */ - public function removeCustomer($customer) - { - if ($this->getCustomers()->contains($customer)) { - $this->collCustomers->remove($this->collCustomers->search($customer)); - if (null === $this->customersScheduledForDeletion) { - $this->customersScheduledForDeletion = clone $this->collCustomers; - $this->customersScheduledForDeletion->clear(); - } - $this->customersScheduledForDeletion[]= $customer; - $customer->setCustomerTitle(null); - } - - return $this; - } - /** * Clears out the collAddresses collection * @@ -2065,11 +1801,6 @@ abstract class CustomerTitle implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collCustomers) { - foreach ($this->collCustomers as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collAddresses) { foreach ($this->collAddresses as $o) { $o->clearAllReferences($deep); @@ -2086,10 +1817,6 @@ abstract class CustomerTitle implements ActiveRecordInterface $this->currentLocale = 'en_US'; $this->currentTranslations = null; - if ($this->collCustomers instanceof Collection) { - $this->collCustomers->clearIterator(); - } - $this->collCustomers = null; if ($this->collAddresses instanceof Collection) { $this->collAddresses->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php index 940db1425..95b2a8326 100755 --- a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php @@ -38,10 +38,6 @@ use Thelia\Model\Map\CustomerTitleTableMap; * @method ChildCustomerTitleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildCustomerTitleQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildCustomerTitleQuery leftJoinCustomer($relationAlias = null) Adds a LEFT JOIN clause to the query using the Customer relation - * @method ChildCustomerTitleQuery rightJoinCustomer($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Customer relation - * @method ChildCustomerTitleQuery innerJoinCustomer($relationAlias = null) Adds a INNER JOIN clause to the query using the Customer relation - * * @method ChildCustomerTitleQuery leftJoinAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the Address relation * @method ChildCustomerTitleQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation * @method ChildCustomerTitleQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation @@ -438,79 +434,6 @@ abstract class CustomerTitleQuery extends ModelCriteria return $this->addUsingAlias(CustomerTitleTableMap::UPDATED_AT, $updatedAt, $comparison); } - /** - * Filter the query by a related \Thelia\Model\Customer object - * - * @param \Thelia\Model\Customer|ObjectCollection $customer the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCustomerTitleQuery The current query, for fluid interface - */ - public function filterByCustomer($customer, $comparison = null) - { - if ($customer instanceof \Thelia\Model\Customer) { - return $this - ->addUsingAlias(CustomerTitleTableMap::ID, $customer->getCustomerTitleId(), $comparison); - } elseif ($customer instanceof ObjectCollection) { - return $this - ->useCustomerQuery() - ->filterByPrimaryKeys($customer->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByCustomer() only accepts arguments of type \Thelia\Model\Customer or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Customer relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildCustomerTitleQuery The current query, for fluid interface - */ - public function joinCustomer($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Customer'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Customer'); - } - - return $this; - } - - /** - * Use the Customer relation Customer object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CustomerQuery A secondary query class using the current class as primary query - */ - public function useCustomerQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCustomer($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery'); - } - /** * Filter the query by a related \Thelia\Model\Address object * diff --git a/core/lib/Thelia/Model/Map/AddressTableMap.php b/core/lib/Thelia/Model/Map/AddressTableMap.php index 8a6126964..5a360f08e 100755 --- a/core/lib/Thelia/Model/Map/AddressTableMap.php +++ b/core/lib/Thelia/Model/Map/AddressTableMap.php @@ -57,7 +57,7 @@ class AddressTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 16; + const NUM_COLUMNS = 18; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class AddressTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 16; + const NUM_HYDRATE_COLUMNS = 18; /** * the column name for the ID field @@ -139,6 +139,16 @@ class AddressTableMap extends TableMap */ const PHONE = 'address.PHONE'; + /** + * the column name for the CELLPHONE field + */ + const CELLPHONE = 'address.CELLPHONE'; + + /** + * the column name for the DEFAULT field + */ + const DEFAULT = 'address.DEFAULT'; + /** * the column name for the CREATED_AT field */ @@ -161,12 +171,12 @@ class AddressTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Title', 'CustomerId', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'title', 'customerId', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AddressTableMap::ID, AddressTableMap::TITLE, AddressTableMap::CUSTOMER_ID, AddressTableMap::CUSTOMER_TITLE_ID, AddressTableMap::COMPANY, AddressTableMap::FIRSTNAME, AddressTableMap::LASTNAME, AddressTableMap::ADDRESS1, AddressTableMap::ADDRESS2, AddressTableMap::ADDRESS3, AddressTableMap::ZIPCODE, AddressTableMap::CITY, AddressTableMap::COUNTRY_ID, AddressTableMap::PHONE, AddressTableMap::CREATED_AT, AddressTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'TITLE', 'CUSTOMER_ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'title', 'customer_id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ) + self::TYPE_PHPNAME => array('Id', 'Title', 'CustomerId', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'Default', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'title', 'customerId', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'default', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AddressTableMap::ID, AddressTableMap::TITLE, AddressTableMap::CUSTOMER_ID, AddressTableMap::CUSTOMER_TITLE_ID, AddressTableMap::COMPANY, AddressTableMap::FIRSTNAME, AddressTableMap::LASTNAME, AddressTableMap::ADDRESS1, AddressTableMap::ADDRESS2, AddressTableMap::ADDRESS3, AddressTableMap::ZIPCODE, AddressTableMap::CITY, AddressTableMap::COUNTRY_ID, AddressTableMap::PHONE, AddressTableMap::CELLPHONE, AddressTableMap::DEFAULT, AddressTableMap::CREATED_AT, AddressTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'TITLE', 'CUSTOMER_ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'title', 'customer_id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'default', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); /** @@ -176,12 +186,12 @@ class AddressTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Title' => 1, 'CustomerId' => 2, 'CustomerTitleId' => 3, 'Company' => 4, 'Firstname' => 5, 'Lastname' => 6, 'Address1' => 7, 'Address2' => 8, 'Address3' => 9, 'Zipcode' => 10, 'City' => 11, 'CountryId' => 12, 'Phone' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'title' => 1, 'customerId' => 2, 'customerTitleId' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'countryId' => 12, 'phone' => 13, 'createdAt' => 14, 'updatedAt' => 15, ), - self::TYPE_COLNAME => array(AddressTableMap::ID => 0, AddressTableMap::TITLE => 1, AddressTableMap::CUSTOMER_ID => 2, AddressTableMap::CUSTOMER_TITLE_ID => 3, AddressTableMap::COMPANY => 4, AddressTableMap::FIRSTNAME => 5, AddressTableMap::LASTNAME => 6, AddressTableMap::ADDRESS1 => 7, AddressTableMap::ADDRESS2 => 8, AddressTableMap::ADDRESS3 => 9, AddressTableMap::ZIPCODE => 10, AddressTableMap::CITY => 11, AddressTableMap::COUNTRY_ID => 12, AddressTableMap::PHONE => 13, AddressTableMap::CREATED_AT => 14, AddressTableMap::UPDATED_AT => 15, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'TITLE' => 1, 'CUSTOMER_ID' => 2, 'CUSTOMER_TITLE_ID' => 3, 'COMPANY' => 4, 'FIRSTNAME' => 5, 'LASTNAME' => 6, 'ADDRESS1' => 7, 'ADDRESS2' => 8, 'ADDRESS3' => 9, 'ZIPCODE' => 10, 'CITY' => 11, 'COUNTRY_ID' => 12, 'PHONE' => 13, 'CREATED_AT' => 14, 'UPDATED_AT' => 15, ), - self::TYPE_FIELDNAME => array('id' => 0, 'title' => 1, 'customer_id' => 2, 'customer_title_id' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'country_id' => 12, 'phone' => 13, 'created_at' => 14, 'updated_at' => 15, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Title' => 1, 'CustomerId' => 2, 'CustomerTitleId' => 3, 'Company' => 4, 'Firstname' => 5, 'Lastname' => 6, 'Address1' => 7, 'Address2' => 8, 'Address3' => 9, 'Zipcode' => 10, 'City' => 11, 'CountryId' => 12, 'Phone' => 13, 'Cellphone' => 14, 'Default' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'title' => 1, 'customerId' => 2, 'customerTitleId' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'countryId' => 12, 'phone' => 13, 'cellphone' => 14, 'default' => 15, 'createdAt' => 16, 'updatedAt' => 17, ), + self::TYPE_COLNAME => array(AddressTableMap::ID => 0, AddressTableMap::TITLE => 1, AddressTableMap::CUSTOMER_ID => 2, AddressTableMap::CUSTOMER_TITLE_ID => 3, AddressTableMap::COMPANY => 4, AddressTableMap::FIRSTNAME => 5, AddressTableMap::LASTNAME => 6, AddressTableMap::ADDRESS1 => 7, AddressTableMap::ADDRESS2 => 8, AddressTableMap::ADDRESS3 => 9, AddressTableMap::ZIPCODE => 10, AddressTableMap::CITY => 11, AddressTableMap::COUNTRY_ID => 12, AddressTableMap::PHONE => 13, AddressTableMap::CELLPHONE => 14, AddressTableMap::DEFAULT => 15, AddressTableMap::CREATED_AT => 16, AddressTableMap::UPDATED_AT => 17, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'TITLE' => 1, 'CUSTOMER_ID' => 2, 'CUSTOMER_TITLE_ID' => 3, 'COMPANY' => 4, 'FIRSTNAME' => 5, 'LASTNAME' => 6, 'ADDRESS1' => 7, 'ADDRESS2' => 8, 'ADDRESS3' => 9, 'ZIPCODE' => 10, 'CITY' => 11, 'COUNTRY_ID' => 12, 'PHONE' => 13, 'CELLPHONE' => 14, 'DEFAULT' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ), + self::TYPE_FIELDNAME => array('id' => 0, 'title' => 1, 'customer_id' => 2, 'customer_title_id' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'country_id' => 12, 'phone' => 13, 'cellphone' => 14, 'default' => 15, 'created_at' => 16, 'updated_at' => 17, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); /** @@ -214,6 +224,8 @@ class AddressTableMap extends TableMap $this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null); $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null); $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null); + $this->addColumn('CELLPHONE', 'Cellphone', 'VARCHAR', false, 20, null); + $this->addColumn('DEFAULT', 'Default', 'TINYINT', false, null, 0); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -392,6 +404,8 @@ class AddressTableMap extends TableMap $criteria->addSelectColumn(AddressTableMap::CITY); $criteria->addSelectColumn(AddressTableMap::COUNTRY_ID); $criteria->addSelectColumn(AddressTableMap::PHONE); + $criteria->addSelectColumn(AddressTableMap::CELLPHONE); + $criteria->addSelectColumn(AddressTableMap::DEFAULT); $criteria->addSelectColumn(AddressTableMap::CREATED_AT); $criteria->addSelectColumn(AddressTableMap::UPDATED_AT); } else { @@ -409,6 +423,8 @@ class AddressTableMap extends TableMap $criteria->addSelectColumn($alias . '.CITY'); $criteria->addSelectColumn($alias . '.COUNTRY_ID'); $criteria->addSelectColumn($alias . '.PHONE'); + $criteria->addSelectColumn($alias . '.CELLPHONE'); + $criteria->addSelectColumn($alias . '.DEFAULT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/CustomerTableMap.php b/core/lib/Thelia/Model/Map/CustomerTableMap.php index 030d233d9..011ecc549 100755 --- a/core/lib/Thelia/Model/Map/CustomerTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTableMap.php @@ -57,7 +57,7 @@ class CustomerTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 24; + const NUM_COLUMNS = 11; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CustomerTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 24; + const NUM_HYDRATE_COLUMNS = 11; /** * the column name for the ID field @@ -79,66 +79,6 @@ class CustomerTableMap extends TableMap */ const REF = 'customer.REF'; - /** - * the column name for the CUSTOMER_TITLE_ID field - */ - const CUSTOMER_TITLE_ID = 'customer.CUSTOMER_TITLE_ID'; - - /** - * the column name for the COMPANY field - */ - const COMPANY = 'customer.COMPANY'; - - /** - * the column name for the FIRSTNAME field - */ - const FIRSTNAME = 'customer.FIRSTNAME'; - - /** - * the column name for the LASTNAME field - */ - const LASTNAME = 'customer.LASTNAME'; - - /** - * the column name for the ADDRESS1 field - */ - const ADDRESS1 = 'customer.ADDRESS1'; - - /** - * the column name for the ADDRESS2 field - */ - const ADDRESS2 = 'customer.ADDRESS2'; - - /** - * the column name for the ADDRESS3 field - */ - const ADDRESS3 = 'customer.ADDRESS3'; - - /** - * the column name for the ZIPCODE field - */ - const ZIPCODE = 'customer.ZIPCODE'; - - /** - * the column name for the CITY field - */ - const CITY = 'customer.CITY'; - - /** - * the column name for the COUNTRY_ID field - */ - const COUNTRY_ID = 'customer.COUNTRY_ID'; - - /** - * the column name for the PHONE field - */ - const PHONE = 'customer.PHONE'; - - /** - * the column name for the CELLPHONE field - */ - const CELLPHONE = 'customer.CELLPHONE'; - /** * the column name for the EMAIL field */ @@ -154,11 +94,6 @@ class CustomerTableMap extends TableMap */ const ALGO = 'customer.ALGO'; - /** - * the column name for the SALT field - */ - const SALT = 'customer.SALT'; - /** * the column name for the RESELLER field */ @@ -201,12 +136,12 @@ class CustomerTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Ref', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'Email', 'Password', 'Algo', 'Salt', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'email', 'password', 'algo', 'salt', 'reseller', 'lang', 'sponsor', 'discount', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::CUSTOMER_TITLE_ID, CustomerTableMap::COMPANY, CustomerTableMap::FIRSTNAME, CustomerTableMap::LASTNAME, CustomerTableMap::ADDRESS1, CustomerTableMap::ADDRESS2, CustomerTableMap::ADDRESS3, CustomerTableMap::ZIPCODE, CustomerTableMap::CITY, CustomerTableMap::COUNTRY_ID, CustomerTableMap::PHONE, CustomerTableMap::CELLPHONE, CustomerTableMap::EMAIL, CustomerTableMap::PASSWORD, CustomerTableMap::ALGO, CustomerTableMap::SALT, CustomerTableMap::RESELLER, CustomerTableMap::LANG, CustomerTableMap::SPONSOR, CustomerTableMap::DISCOUNT, CustomerTableMap::CREATED_AT, CustomerTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'EMAIL', 'PASSWORD', 'ALGO', 'SALT', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'ref', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'email', 'password', 'algo', 'salt', 'reseller', 'lang', 'sponsor', 'discount', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, ) + self::TYPE_PHPNAME => array('Id', 'Ref', 'Email', 'Password', 'Algo', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::EMAIL, CustomerTableMap::PASSWORD, CustomerTableMap::ALGO, CustomerTableMap::RESELLER, CustomerTableMap::LANG, CustomerTableMap::SPONSOR, CustomerTableMap::DISCOUNT, CustomerTableMap::CREATED_AT, CustomerTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'REF', 'EMAIL', 'PASSWORD', 'ALGO', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'ref', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -216,12 +151,12 @@ class CustomerTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CustomerTitleId' => 2, 'Company' => 3, 'Firstname' => 4, 'Lastname' => 5, 'Address1' => 6, 'Address2' => 7, 'Address3' => 8, 'Zipcode' => 9, 'City' => 10, 'CountryId' => 11, 'Phone' => 12, 'Cellphone' => 13, 'Email' => 14, 'Password' => 15, 'Algo' => 16, 'Salt' => 17, 'Reseller' => 18, 'Lang' => 19, 'Sponsor' => 20, 'Discount' => 21, 'CreatedAt' => 22, 'UpdatedAt' => 23, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'customerTitleId' => 2, 'company' => 3, 'firstname' => 4, 'lastname' => 5, 'address1' => 6, 'address2' => 7, 'address3' => 8, 'zipcode' => 9, 'city' => 10, 'countryId' => 11, 'phone' => 12, 'cellphone' => 13, 'email' => 14, 'password' => 15, 'algo' => 16, 'salt' => 17, 'reseller' => 18, 'lang' => 19, 'sponsor' => 20, 'discount' => 21, 'createdAt' => 22, 'updatedAt' => 23, ), - self::TYPE_COLNAME => array(CustomerTableMap::ID => 0, CustomerTableMap::REF => 1, CustomerTableMap::CUSTOMER_TITLE_ID => 2, CustomerTableMap::COMPANY => 3, CustomerTableMap::FIRSTNAME => 4, CustomerTableMap::LASTNAME => 5, CustomerTableMap::ADDRESS1 => 6, CustomerTableMap::ADDRESS2 => 7, CustomerTableMap::ADDRESS3 => 8, CustomerTableMap::ZIPCODE => 9, CustomerTableMap::CITY => 10, CustomerTableMap::COUNTRY_ID => 11, CustomerTableMap::PHONE => 12, CustomerTableMap::CELLPHONE => 13, CustomerTableMap::EMAIL => 14, CustomerTableMap::PASSWORD => 15, CustomerTableMap::ALGO => 16, CustomerTableMap::SALT => 17, CustomerTableMap::RESELLER => 18, CustomerTableMap::LANG => 19, CustomerTableMap::SPONSOR => 20, CustomerTableMap::DISCOUNT => 21, CustomerTableMap::CREATED_AT => 22, CustomerTableMap::UPDATED_AT => 23, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CUSTOMER_TITLE_ID' => 2, 'COMPANY' => 3, 'FIRSTNAME' => 4, 'LASTNAME' => 5, 'ADDRESS1' => 6, 'ADDRESS2' => 7, 'ADDRESS3' => 8, 'ZIPCODE' => 9, 'CITY' => 10, 'COUNTRY_ID' => 11, 'PHONE' => 12, 'CELLPHONE' => 13, 'EMAIL' => 14, 'PASSWORD' => 15, 'ALGO' => 16, 'SALT' => 17, 'RESELLER' => 18, 'LANG' => 19, 'SPONSOR' => 20, 'DISCOUNT' => 21, 'CREATED_AT' => 22, 'UPDATED_AT' => 23, ), - self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'customer_title_id' => 2, 'company' => 3, 'firstname' => 4, 'lastname' => 5, 'address1' => 6, 'address2' => 7, 'address3' => 8, 'zipcode' => 9, 'city' => 10, 'country_id' => 11, 'phone' => 12, 'cellphone' => 13, 'email' => 14, 'password' => 15, 'algo' => 16, 'salt' => 17, 'reseller' => 18, 'lang' => 19, 'sponsor' => 20, 'discount' => 21, 'created_at' => 22, 'updated_at' => 23, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'Email' => 2, 'Password' => 3, 'Algo' => 4, 'Reseller' => 5, 'Lang' => 6, 'Sponsor' => 7, 'Discount' => 8, 'CreatedAt' => 9, 'UpdatedAt' => 10, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'email' => 2, 'password' => 3, 'algo' => 4, 'reseller' => 5, 'lang' => 6, 'sponsor' => 7, 'discount' => 8, 'createdAt' => 9, 'updatedAt' => 10, ), + self::TYPE_COLNAME => array(CustomerTableMap::ID => 0, CustomerTableMap::REF => 1, CustomerTableMap::EMAIL => 2, CustomerTableMap::PASSWORD => 3, CustomerTableMap::ALGO => 4, CustomerTableMap::RESELLER => 5, CustomerTableMap::LANG => 6, CustomerTableMap::SPONSOR => 7, CustomerTableMap::DISCOUNT => 8, CustomerTableMap::CREATED_AT => 9, CustomerTableMap::UPDATED_AT => 10, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'EMAIL' => 2, 'PASSWORD' => 3, 'ALGO' => 4, 'RESELLER' => 5, 'LANG' => 6, 'SPONSOR' => 7, 'DISCOUNT' => 8, 'CREATED_AT' => 9, 'UPDATED_AT' => 10, ), + self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'email' => 2, 'password' => 3, 'algo' => 4, 'reseller' => 5, 'lang' => 6, 'sponsor' => 7, 'discount' => 8, 'created_at' => 9, 'updated_at' => 10, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -242,22 +177,9 @@ class CustomerTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('REF', 'Ref', 'VARCHAR', true, 50, null); - $this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null); - $this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null); - $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null); - $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null); - $this->addColumn('ADDRESS1', 'Address1', 'VARCHAR', true, 255, null); - $this->addColumn('ADDRESS2', 'Address2', 'VARCHAR', false, 255, null); - $this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', false, 255, null); - $this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', false, 10, null); - $this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null); - $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null); - $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null); - $this->addColumn('CELLPHONE', 'Cellphone', 'VARCHAR', false, 20, null); $this->addColumn('EMAIL', 'Email', 'VARCHAR', false, 50, null); $this->addColumn('PASSWORD', 'Password', 'VARCHAR', false, 255, null); $this->addColumn('ALGO', 'Algo', 'VARCHAR', false, 128, null); - $this->addColumn('SALT', 'Salt', 'VARCHAR', false, 128, null); $this->addColumn('RESELLER', 'Reseller', 'TINYINT', false, null, null); $this->addColumn('LANG', 'Lang', 'VARCHAR', false, 10, null); $this->addColumn('SPONSOR', 'Sponsor', 'VARCHAR', false, 50, null); @@ -271,7 +193,6 @@ class CustomerTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'SET NULL', 'RESTRICT'); $this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Addresses'); $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Orders'); } // buildRelations() @@ -439,22 +360,9 @@ class CustomerTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(CustomerTableMap::ID); $criteria->addSelectColumn(CustomerTableMap::REF); - $criteria->addSelectColumn(CustomerTableMap::CUSTOMER_TITLE_ID); - $criteria->addSelectColumn(CustomerTableMap::COMPANY); - $criteria->addSelectColumn(CustomerTableMap::FIRSTNAME); - $criteria->addSelectColumn(CustomerTableMap::LASTNAME); - $criteria->addSelectColumn(CustomerTableMap::ADDRESS1); - $criteria->addSelectColumn(CustomerTableMap::ADDRESS2); - $criteria->addSelectColumn(CustomerTableMap::ADDRESS3); - $criteria->addSelectColumn(CustomerTableMap::ZIPCODE); - $criteria->addSelectColumn(CustomerTableMap::CITY); - $criteria->addSelectColumn(CustomerTableMap::COUNTRY_ID); - $criteria->addSelectColumn(CustomerTableMap::PHONE); - $criteria->addSelectColumn(CustomerTableMap::CELLPHONE); $criteria->addSelectColumn(CustomerTableMap::EMAIL); $criteria->addSelectColumn(CustomerTableMap::PASSWORD); $criteria->addSelectColumn(CustomerTableMap::ALGO); - $criteria->addSelectColumn(CustomerTableMap::SALT); $criteria->addSelectColumn(CustomerTableMap::RESELLER); $criteria->addSelectColumn(CustomerTableMap::LANG); $criteria->addSelectColumn(CustomerTableMap::SPONSOR); @@ -464,22 +372,9 @@ class CustomerTableMap extends TableMap } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.REF'); - $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID'); - $criteria->addSelectColumn($alias . '.COMPANY'); - $criteria->addSelectColumn($alias . '.FIRSTNAME'); - $criteria->addSelectColumn($alias . '.LASTNAME'); - $criteria->addSelectColumn($alias . '.ADDRESS1'); - $criteria->addSelectColumn($alias . '.ADDRESS2'); - $criteria->addSelectColumn($alias . '.ADDRESS3'); - $criteria->addSelectColumn($alias . '.ZIPCODE'); - $criteria->addSelectColumn($alias . '.CITY'); - $criteria->addSelectColumn($alias . '.COUNTRY_ID'); - $criteria->addSelectColumn($alias . '.PHONE'); - $criteria->addSelectColumn($alias . '.CELLPHONE'); $criteria->addSelectColumn($alias . '.EMAIL'); $criteria->addSelectColumn($alias . '.PASSWORD'); $criteria->addSelectColumn($alias . '.ALGO'); - $criteria->addSelectColumn($alias . '.SALT'); $criteria->addSelectColumn($alias . '.RESELLER'); $criteria->addSelectColumn($alias . '.LANG'); $criteria->addSelectColumn($alias . '.SPONSOR'); diff --git a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php index 8e91631cf..341f2a420 100755 --- a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php @@ -166,7 +166,6 @@ class CustomerTitleTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'SET NULL', 'RESTRICT', 'Customers'); $this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'RESTRICT', 'RESTRICT', 'Addresses'); $this->addRelation('CustomerTitleI18n', '\\Thelia\\Model\\CustomerTitleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CustomerTitleI18ns'); } // buildRelations() @@ -191,7 +190,6 @@ class CustomerTitleTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CustomerTableMap::clearInstancePool(); CustomerTitleI18nTableMap::clearInstancePool(); } diff --git a/install/thelia.sql b/install/thelia.sql index 94d933587..d3e6e4f7e 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -453,22 +453,9 @@ CREATE TABLE `customer` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `ref` VARCHAR(50) NOT NULL, - `customer_title_id` INTEGER, - `company` VARCHAR(255), - `firstname` VARCHAR(255) NOT NULL, - `lastname` VARCHAR(255) NOT NULL, - `address1` VARCHAR(255) NOT NULL, - `address2` VARCHAR(255) COMMENT ' ', - `address3` VARCHAR(255), - `zipcode` VARCHAR(10), - `city` VARCHAR(255) NOT NULL, - `country_id` INTEGER NOT NULL, - `phone` VARCHAR(20), - `cellphone` VARCHAR(20), `email` VARCHAR(50), `password` VARCHAR(255), `algo` VARCHAR(128), - `salt` VARCHAR(128), `reseller` TINYINT, `lang` VARCHAR(10), `sponsor` VARCHAR(50), @@ -476,13 +463,7 @@ CREATE TABLE `customer` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - UNIQUE INDEX `ref_UNIQUE` (`ref`), - INDEX `idx_customer_customer_title_id` (`customer_title_id`), - CONSTRAINT `fk_customer_customer_title_id` - FOREIGN KEY (`customer_title_id`) - REFERENCES `customer_title` (`id`) - ON UPDATE RESTRICT - ON DELETE SET NULL + UNIQUE INDEX `ref_UNIQUE` (`ref`) ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -507,6 +488,8 @@ CREATE TABLE `address` `city` VARCHAR(255) NOT NULL, `country_id` INTEGER NOT NULL, `phone` VARCHAR(20), + `cellphone` VARCHAR(20), + `default` TINYINT DEFAULT 0, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), @@ -1040,11 +1023,11 @@ DROP TABLE IF EXISTS `admin_group`; CREATE TABLE `admin_group` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `group_id` INTEGER, - `admin_id` INTEGER, + `group_id` INTEGER NOT NULL, + `admin_id` INTEGER NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`,`group_id`,`admin_id`), INDEX `idx_admin_group_group_id` (`group_id`), INDEX `idx_admin_group_admin_id` (`admin_id`), CONSTRAINT `fk_admin_group_group_id` @@ -1074,8 +1057,8 @@ CREATE TABLE `group_resource` `write` TINYINT DEFAULT 0, `created_at` DATETIME, `updated_at` DATETIME, - PRIMARY KEY (`id`), - INDEX `id_idx` (`group_id`), + PRIMARY KEY (`id`,`group_id`,`resource_id`), + INDEX `id_group_resource_group_id` (`group_id`), INDEX `idx_group_resource_resource_id` (`resource_id`), CONSTRAINT `fk_group_resource_group_id` FOREIGN KEY (`group_id`) diff --git a/local/config/schema.xml b/local/config/schema.xml index cae47a184..7afc015d7 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -329,35 +329,16 @@
- - - - - - - - - - - - - - - - - - -
@@ -375,6 +356,8 @@ + + From 541e63521dc9de1f4df7efc69cdee6e373dfb5c8 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 12 Jul 2013 16:33:30 +0200 Subject: [PATCH 19/36] create default address on customer creation --- core/lib/Thelia/Model/Customer.php | 57 ++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 00acf0e83..cc213046c 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -2,6 +2,7 @@ namespace Thelia\Model; +use Symfony\Component\Config\Definition\Exception\Exception; use Thelia\Model\Base\Customer as BaseCustomer; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; @@ -12,6 +13,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Security\User\UserInterface; use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Model\Map\CustomerTableMap; /** * Skeleton subclass for representing a row from the 'customer' table. @@ -52,16 +54,7 @@ class Customer extends BaseCustomer implements UserInterface public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0) { $this - ->setCustomerTitleId($titleId) - ->setFirstname($firstname) - ->setLastname($lastname) - ->setAddress1($address1) - ->setAddress2($address2) - ->setAddress3($address3) - ->setPhone($phone) - ->setCellphone($cellphone) - ->setZipcode($zipcode) - ->setCountryId($countryId) + ->setEmail($email) ->setPassword($plainPassword) ->setReseller($reseller) @@ -73,7 +66,49 @@ class Customer extends BaseCustomer implements UserInterface $this->setLang($lang); } - $this->save(); + + $con = Propel::getWriteConnection(CustomerTableMap::DATABASE_NAME); + $con->beginTransaction(); + try { + $this->save($con); + + $address = new Address(); + + $address + ->setCustomerTitleId($titleId) + ->setFirstname($firstname) + ->setLastname($lastname) + ->setAddress1($address1) + ->setAddress2($address2) + ->setAddress3($address3) + ->setPhone($phone) + ->setCellphone($cellphone) + ->setZipcode($zipcode) + ->setCountryId($countryId) + ->setDefault(1) + ->setCustomer($this) + ->save($con); + + $con->commit(); + + + } catch(Exception $e) { + $con->rollback(); + } + + + /** + * ->setCustomerTitleId($titleId) + ->setFirstname($firstname) + ->setLastname($lastname) + ->setAddress1($address1) + ->setAddress2($address2) + ->setAddress3($address3) + ->setPhone($phone) + ->setCellphone($cellphone) + ->setZipcode($zipcode) + ->setCountryId($countryId) + */ } From d14e4202084ec1aade6a42ea03c478b1dbb7a870 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 12 Jul 2013 16:37:04 +0200 Subject: [PATCH 20/36] throw the exception again if catch when creating customer --- core/lib/Thelia/Model/Customer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index cc213046c..101e0672f 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -94,6 +94,7 @@ class Customer extends BaseCustomer implements UserInterface } catch(Exception $e) { $con->rollback(); + throw $e; } From 9356a1e46df51a4d66cfb3b87fbf2621a6c591e4 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 12 Jul 2013 16:38:18 +0200 Subject: [PATCH 21/36] missing use statement --- core/lib/Thelia/Model/Customer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 101e0672f..94159d2fb 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -13,6 +13,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Security\User\UserInterface; use Propel\Runtime\Connection\ConnectionInterface; +use Propel\Runtime\Propel; use Thelia\Model\Map\CustomerTableMap; /** From 38355a6401bf016b891d011757998c43e34fe4a9 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 12 Jul 2013 16:45:29 +0200 Subject: [PATCH 22/36] remove some comment --- core/lib/Thelia/Model/Customer.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 94159d2fb..c417c4a0f 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -97,21 +97,6 @@ class Customer extends BaseCustomer implements UserInterface $con->rollback(); throw $e; } - - - /** - * ->setCustomerTitleId($titleId) - ->setFirstname($firstname) - ->setLastname($lastname) - ->setAddress1($address1) - ->setAddress2($address2) - ->setAddress3($address3) - ->setPhone($phone) - ->setCellphone($cellphone) - ->setZipcode($zipcode) - ->setCountryId($countryId) - */ - } public function preInsert(ConnectionInterface $con = null) From 72df28f43966f2d8b30affb71f607ae821360c19 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 12 Jul 2013 16:48:25 +0200 Subject: [PATCH 23/36] update schema for customer --- core/lib/Thelia/Model/Base/Customer.php | 204 ++++++++++++++---- core/lib/Thelia/Model/Base/CustomerQuery.php | 68 +++++- .../lib/Thelia/Model/Map/CustomerTableMap.php | 44 ++-- install/thelia.sql | 2 + local/config/schema.xml | 2 + 5 files changed, 261 insertions(+), 59 deletions(-) diff --git a/core/lib/Thelia/Model/Base/Customer.php b/core/lib/Thelia/Model/Base/Customer.php index 5fe9080fd..b8b3b1f32 100755 --- a/core/lib/Thelia/Model/Base/Customer.php +++ b/core/lib/Thelia/Model/Base/Customer.php @@ -71,6 +71,18 @@ abstract class Customer implements ActiveRecordInterface */ protected $ref; + /** + * The value for the firstname field. + * @var string + */ + protected $firstname; + + /** + * The value for the lastname field. + * @var string + */ + protected $lastname; + /** * The value for the email field. * @var string @@ -433,6 +445,28 @@ abstract class Customer implements ActiveRecordInterface return $this->ref; } + /** + * 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 [email] column value. * @@ -592,6 +626,48 @@ abstract class Customer implements ActiveRecordInterface return $this; } // setRef() + /** + * Set the value of [firstname] column. + * + * @param string $v new value + * @return \Thelia\Model\Customer 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[] = CustomerTableMap::FIRSTNAME; + } + + + return $this; + } // setFirstname() + + /** + * Set the value of [lastname] column. + * + * @param string $v new value + * @return \Thelia\Model\Customer 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[] = CustomerTableMap::LASTNAME; + } + + + return $this; + } // setLastname() + /** * Set the value of [email] column. * @@ -824,34 +900,40 @@ abstract class Customer implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)]; $this->ref = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->firstname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->lastname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)]; $this->email = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CustomerTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)]; $this->password = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CustomerTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)]; $this->algo = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CustomerTableMap::translateFieldName('Reseller', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CustomerTableMap::translateFieldName('Reseller', TableMap::TYPE_PHPNAME, $indexType)]; $this->reseller = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CustomerTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CustomerTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)]; $this->lang = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CustomerTableMap::translateFieldName('Sponsor', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CustomerTableMap::translateFieldName('Sponsor', TableMap::TYPE_PHPNAME, $indexType)]; $this->sponsor = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CustomerTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CustomerTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)]; $this->discount = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CustomerTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CustomerTableMap::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 ? 10 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -864,7 +946,7 @@ abstract class Customer implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 11; // 11 = CustomerTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 13; // 13 = CustomerTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Customer object", 0, $e); @@ -1128,6 +1210,12 @@ abstract class Customer implements ActiveRecordInterface if ($this->isColumnModified(CustomerTableMap::REF)) { $modifiedColumns[':p' . $index++] = 'REF'; } + if ($this->isColumnModified(CustomerTableMap::FIRSTNAME)) { + $modifiedColumns[':p' . $index++] = 'FIRSTNAME'; + } + if ($this->isColumnModified(CustomerTableMap::LASTNAME)) { + $modifiedColumns[':p' . $index++] = 'LASTNAME'; + } if ($this->isColumnModified(CustomerTableMap::EMAIL)) { $modifiedColumns[':p' . $index++] = 'EMAIL'; } @@ -1172,6 +1260,12 @@ abstract class Customer implements ActiveRecordInterface case 'REF': $stmt->bindValue($identifier, $this->ref, 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 'EMAIL': $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR); break; @@ -1268,30 +1362,36 @@ abstract class Customer implements ActiveRecordInterface return $this->getRef(); break; case 2: - return $this->getEmail(); + return $this->getFirstname(); break; case 3: - return $this->getPassword(); + return $this->getLastname(); break; case 4: - return $this->getAlgo(); + return $this->getEmail(); break; case 5: - return $this->getReseller(); + return $this->getPassword(); break; case 6: - return $this->getLang(); + return $this->getAlgo(); break; case 7: - return $this->getSponsor(); + return $this->getReseller(); break; case 8: - return $this->getDiscount(); + return $this->getLang(); break; case 9: - return $this->getCreatedAt(); + return $this->getSponsor(); break; case 10: + return $this->getDiscount(); + break; + case 11: + return $this->getCreatedAt(); + break; + case 12: return $this->getUpdatedAt(); break; default: @@ -1325,15 +1425,17 @@ abstract class Customer implements ActiveRecordInterface $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getRef(), - $keys[2] => $this->getEmail(), - $keys[3] => $this->getPassword(), - $keys[4] => $this->getAlgo(), - $keys[5] => $this->getReseller(), - $keys[6] => $this->getLang(), - $keys[7] => $this->getSponsor(), - $keys[8] => $this->getDiscount(), - $keys[9] => $this->getCreatedAt(), - $keys[10] => $this->getUpdatedAt(), + $keys[2] => $this->getFirstname(), + $keys[3] => $this->getLastname(), + $keys[4] => $this->getEmail(), + $keys[5] => $this->getPassword(), + $keys[6] => $this->getAlgo(), + $keys[7] => $this->getReseller(), + $keys[8] => $this->getLang(), + $keys[9] => $this->getSponsor(), + $keys[10] => $this->getDiscount(), + $keys[11] => $this->getCreatedAt(), + $keys[12] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1389,30 +1491,36 @@ abstract class Customer implements ActiveRecordInterface $this->setRef($value); break; case 2: - $this->setEmail($value); + $this->setFirstname($value); break; case 3: - $this->setPassword($value); + $this->setLastname($value); break; case 4: - $this->setAlgo($value); + $this->setEmail($value); break; case 5: - $this->setReseller($value); + $this->setPassword($value); break; case 6: - $this->setLang($value); + $this->setAlgo($value); break; case 7: - $this->setSponsor($value); + $this->setReseller($value); break; case 8: - $this->setDiscount($value); + $this->setLang($value); break; case 9: - $this->setCreatedAt($value); + $this->setSponsor($value); break; case 10: + $this->setDiscount($value); + break; + case 11: + $this->setCreatedAt($value); + break; + case 12: $this->setUpdatedAt($value); break; } // switch() @@ -1441,15 +1549,17 @@ abstract class Customer implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setEmail($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setPassword($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setAlgo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setReseller($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setLang($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setSponsor($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDiscount($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setUpdatedAt($arr[$keys[10]]); + 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->setEmail($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPassword($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setAlgo($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setReseller($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setLang($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setSponsor($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setDiscount($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setCreatedAt($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setUpdatedAt($arr[$keys[12]]); } /** @@ -1463,6 +1573,8 @@ abstract class Customer implements ActiveRecordInterface if ($this->isColumnModified(CustomerTableMap::ID)) $criteria->add(CustomerTableMap::ID, $this->id); if ($this->isColumnModified(CustomerTableMap::REF)) $criteria->add(CustomerTableMap::REF, $this->ref); + if ($this->isColumnModified(CustomerTableMap::FIRSTNAME)) $criteria->add(CustomerTableMap::FIRSTNAME, $this->firstname); + if ($this->isColumnModified(CustomerTableMap::LASTNAME)) $criteria->add(CustomerTableMap::LASTNAME, $this->lastname); if ($this->isColumnModified(CustomerTableMap::EMAIL)) $criteria->add(CustomerTableMap::EMAIL, $this->email); if ($this->isColumnModified(CustomerTableMap::PASSWORD)) $criteria->add(CustomerTableMap::PASSWORD, $this->password); if ($this->isColumnModified(CustomerTableMap::ALGO)) $criteria->add(CustomerTableMap::ALGO, $this->algo); @@ -1536,6 +1648,8 @@ abstract class Customer implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setRef($this->getRef()); + $copyObj->setFirstname($this->getFirstname()); + $copyObj->setLastname($this->getLastname()); $copyObj->setEmail($this->getEmail()); $copyObj->setPassword($this->getPassword()); $copyObj->setAlgo($this->getAlgo()); @@ -2180,6 +2294,8 @@ abstract class Customer implements ActiveRecordInterface { $this->id = null; $this->ref = null; + $this->firstname = null; + $this->lastname = null; $this->email = null; $this->password = null; $this->algo = null; diff --git a/core/lib/Thelia/Model/Base/CustomerQuery.php b/core/lib/Thelia/Model/Base/CustomerQuery.php index 5bc89fa3b..3997cd0b6 100755 --- a/core/lib/Thelia/Model/Base/CustomerQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerQuery.php @@ -23,6 +23,8 @@ use Thelia\Model\Map\CustomerTableMap; * * @method ChildCustomerQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildCustomerQuery orderByRef($order = Criteria::ASC) Order by the ref column + * @method ChildCustomerQuery orderByFirstname($order = Criteria::ASC) Order by the firstname column + * @method ChildCustomerQuery orderByLastname($order = Criteria::ASC) Order by the lastname column * @method ChildCustomerQuery orderByEmail($order = Criteria::ASC) Order by the email column * @method ChildCustomerQuery orderByPassword($order = Criteria::ASC) Order by the password column * @method ChildCustomerQuery orderByAlgo($order = Criteria::ASC) Order by the algo column @@ -35,6 +37,8 @@ use Thelia\Model\Map\CustomerTableMap; * * @method ChildCustomerQuery groupById() Group by the id column * @method ChildCustomerQuery groupByRef() Group by the ref column + * @method ChildCustomerQuery groupByFirstname() Group by the firstname column + * @method ChildCustomerQuery groupByLastname() Group by the lastname column * @method ChildCustomerQuery groupByEmail() Group by the email column * @method ChildCustomerQuery groupByPassword() Group by the password column * @method ChildCustomerQuery groupByAlgo() Group by the algo column @@ -62,6 +66,8 @@ use Thelia\Model\Map\CustomerTableMap; * * @method ChildCustomer findOneById(int $id) Return the first ChildCustomer filtered by the id column * @method ChildCustomer findOneByRef(string $ref) Return the first ChildCustomer filtered by the ref column + * @method ChildCustomer findOneByFirstname(string $firstname) Return the first ChildCustomer filtered by the firstname column + * @method ChildCustomer findOneByLastname(string $lastname) Return the first ChildCustomer filtered by the lastname column * @method ChildCustomer findOneByEmail(string $email) Return the first ChildCustomer filtered by the email column * @method ChildCustomer findOneByPassword(string $password) Return the first ChildCustomer filtered by the password column * @method ChildCustomer findOneByAlgo(string $algo) Return the first ChildCustomer filtered by the algo column @@ -74,6 +80,8 @@ use Thelia\Model\Map\CustomerTableMap; * * @method array findById(int $id) Return ChildCustomer objects filtered by the id column * @method array findByRef(string $ref) Return ChildCustomer objects filtered by the ref column + * @method array findByFirstname(string $firstname) Return ChildCustomer objects filtered by the firstname column + * @method array findByLastname(string $lastname) Return ChildCustomer objects filtered by the lastname column * @method array findByEmail(string $email) Return ChildCustomer objects filtered by the email column * @method array findByPassword(string $password) Return ChildCustomer objects filtered by the password column * @method array findByAlgo(string $algo) Return ChildCustomer objects filtered by the algo column @@ -171,7 +179,7 @@ abstract class CustomerQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, REF, EMAIL, PASSWORD, ALGO, RESELLER, LANG, SPONSOR, DISCOUNT, CREATED_AT, UPDATED_AT FROM customer WHERE ID = :p0'; + $sql = 'SELECT ID, REF, FIRSTNAME, LASTNAME, EMAIL, PASSWORD, ALGO, RESELLER, LANG, SPONSOR, DISCOUNT, CREATED_AT, UPDATED_AT FROM customer WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -330,6 +338,64 @@ abstract class CustomerQuery extends ModelCriteria return $this->addUsingAlias(CustomerTableMap::REF, $ref, $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 ChildCustomerQuery 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(CustomerTableMap::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 ChildCustomerQuery 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(CustomerTableMap::LASTNAME, $lastname, $comparison); + } + /** * Filter the query on the email column * diff --git a/core/lib/Thelia/Model/Map/CustomerTableMap.php b/core/lib/Thelia/Model/Map/CustomerTableMap.php index 011ecc549..a86453adc 100755 --- a/core/lib/Thelia/Model/Map/CustomerTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTableMap.php @@ -57,7 +57,7 @@ class CustomerTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 11; + const NUM_COLUMNS = 13; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CustomerTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 11; + const NUM_HYDRATE_COLUMNS = 13; /** * the column name for the ID field @@ -79,6 +79,16 @@ class CustomerTableMap extends TableMap */ const REF = 'customer.REF'; + /** + * the column name for the FIRSTNAME field + */ + const FIRSTNAME = 'customer.FIRSTNAME'; + + /** + * the column name for the LASTNAME field + */ + const LASTNAME = 'customer.LASTNAME'; + /** * the column name for the EMAIL field */ @@ -136,12 +146,12 @@ class CustomerTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Ref', 'Email', 'Password', 'Algo', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::EMAIL, CustomerTableMap::PASSWORD, CustomerTableMap::ALGO, CustomerTableMap::RESELLER, CustomerTableMap::LANG, CustomerTableMap::SPONSOR, CustomerTableMap::DISCOUNT, CustomerTableMap::CREATED_AT, CustomerTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'REF', 'EMAIL', 'PASSWORD', 'ALGO', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'ref', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + self::TYPE_PHPNAME => array('Id', 'Ref', 'Firstname', 'Lastname', 'Email', 'Password', 'Algo', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'firstname', 'lastname', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::FIRSTNAME, CustomerTableMap::LASTNAME, CustomerTableMap::EMAIL, CustomerTableMap::PASSWORD, CustomerTableMap::ALGO, CustomerTableMap::RESELLER, CustomerTableMap::LANG, CustomerTableMap::SPONSOR, CustomerTableMap::DISCOUNT, CustomerTableMap::CREATED_AT, CustomerTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'REF', 'FIRSTNAME', 'LASTNAME', 'EMAIL', 'PASSWORD', 'ALGO', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'ref', 'firstname', 'lastname', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) ); /** @@ -151,12 +161,12 @@ class CustomerTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'Email' => 2, 'Password' => 3, 'Algo' => 4, 'Reseller' => 5, 'Lang' => 6, 'Sponsor' => 7, 'Discount' => 8, 'CreatedAt' => 9, 'UpdatedAt' => 10, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'email' => 2, 'password' => 3, 'algo' => 4, 'reseller' => 5, 'lang' => 6, 'sponsor' => 7, 'discount' => 8, 'createdAt' => 9, 'updatedAt' => 10, ), - self::TYPE_COLNAME => array(CustomerTableMap::ID => 0, CustomerTableMap::REF => 1, CustomerTableMap::EMAIL => 2, CustomerTableMap::PASSWORD => 3, CustomerTableMap::ALGO => 4, CustomerTableMap::RESELLER => 5, CustomerTableMap::LANG => 6, CustomerTableMap::SPONSOR => 7, CustomerTableMap::DISCOUNT => 8, CustomerTableMap::CREATED_AT => 9, CustomerTableMap::UPDATED_AT => 10, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'EMAIL' => 2, 'PASSWORD' => 3, 'ALGO' => 4, 'RESELLER' => 5, 'LANG' => 6, 'SPONSOR' => 7, 'DISCOUNT' => 8, 'CREATED_AT' => 9, 'UPDATED_AT' => 10, ), - self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'email' => 2, 'password' => 3, 'algo' => 4, 'reseller' => 5, 'lang' => 6, 'sponsor' => 7, 'discount' => 8, 'created_at' => 9, 'updated_at' => 10, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'Firstname' => 2, 'Lastname' => 3, 'Email' => 4, 'Password' => 5, 'Algo' => 6, 'Reseller' => 7, 'Lang' => 8, 'Sponsor' => 9, 'Discount' => 10, 'CreatedAt' => 11, 'UpdatedAt' => 12, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'firstname' => 2, 'lastname' => 3, 'email' => 4, 'password' => 5, 'algo' => 6, 'reseller' => 7, 'lang' => 8, 'sponsor' => 9, 'discount' => 10, 'createdAt' => 11, 'updatedAt' => 12, ), + self::TYPE_COLNAME => array(CustomerTableMap::ID => 0, CustomerTableMap::REF => 1, CustomerTableMap::FIRSTNAME => 2, CustomerTableMap::LASTNAME => 3, CustomerTableMap::EMAIL => 4, CustomerTableMap::PASSWORD => 5, CustomerTableMap::ALGO => 6, CustomerTableMap::RESELLER => 7, CustomerTableMap::LANG => 8, CustomerTableMap::SPONSOR => 9, CustomerTableMap::DISCOUNT => 10, CustomerTableMap::CREATED_AT => 11, CustomerTableMap::UPDATED_AT => 12, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'FIRSTNAME' => 2, 'LASTNAME' => 3, 'EMAIL' => 4, 'PASSWORD' => 5, 'ALGO' => 6, 'RESELLER' => 7, 'LANG' => 8, 'SPONSOR' => 9, 'DISCOUNT' => 10, 'CREATED_AT' => 11, 'UPDATED_AT' => 12, ), + self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'firstname' => 2, 'lastname' => 3, 'email' => 4, 'password' => 5, 'algo' => 6, 'reseller' => 7, 'lang' => 8, 'sponsor' => 9, 'discount' => 10, 'created_at' => 11, 'updated_at' => 12, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) ); /** @@ -177,6 +187,8 @@ class CustomerTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('REF', 'Ref', 'VARCHAR', true, 50, 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('PASSWORD', 'Password', 'VARCHAR', false, 255, null); $this->addColumn('ALGO', 'Algo', 'VARCHAR', false, 128, null); @@ -360,6 +372,8 @@ class CustomerTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(CustomerTableMap::ID); $criteria->addSelectColumn(CustomerTableMap::REF); + $criteria->addSelectColumn(CustomerTableMap::FIRSTNAME); + $criteria->addSelectColumn(CustomerTableMap::LASTNAME); $criteria->addSelectColumn(CustomerTableMap::EMAIL); $criteria->addSelectColumn(CustomerTableMap::PASSWORD); $criteria->addSelectColumn(CustomerTableMap::ALGO); @@ -372,6 +386,8 @@ class CustomerTableMap extends TableMap } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.REF'); + $criteria->addSelectColumn($alias . '.FIRSTNAME'); + $criteria->addSelectColumn($alias . '.LASTNAME'); $criteria->addSelectColumn($alias . '.EMAIL'); $criteria->addSelectColumn($alias . '.PASSWORD'); $criteria->addSelectColumn($alias . '.ALGO'); diff --git a/install/thelia.sql b/install/thelia.sql index d3e6e4f7e..c7d750778 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -453,6 +453,8 @@ CREATE TABLE `customer` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `ref` VARCHAR(50) NOT NULL, + `firstname` VARCHAR(255) NOT NULL, + `lastname` VARCHAR(255) NOT NULL, `email` VARCHAR(50), `password` VARCHAR(255), `algo` VARCHAR(128), diff --git a/local/config/schema.xml b/local/config/schema.xml index 7afc015d7..4b9b99de6 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -329,6 +329,8 @@
+ + From d250e0c6600c6001894658429e279bfd8d49eb3c Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 12 Jul 2013 16:48:51 +0200 Subject: [PATCH 24/36] change customer creation, integrate firstname and lastname --- core/lib/Thelia/Model/Customer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index c417c4a0f..a6bd5f07c 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -55,7 +55,8 @@ class Customer extends BaseCustomer implements UserInterface public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0) { $this - + ->setFirstname($firstname) + ->setLastname($lastname) ->setEmail($email) ->setPassword($plainPassword) ->setReseller($reseller) From e8bf47b92968c122dae4f36e651ed624d1a9401f Mon Sep 17 00:00:00 2001 From: franck Date: Tue, 16 Jul 2013 16:34:47 +0200 Subject: [PATCH 25/36] Refactored Form system to get simple error handling and a clearer interface --- core/lib/Thelia/Action/Customer.php | 15 +- .../Admin/Controller/BaseAdminController.php | 29 +--- .../Admin/Controller/SessionController.php | 46 ++--- core/lib/Thelia/Config/Resources/config.xml | 6 +- core/lib/Thelia/Core/Event/ActionEvent.php | 20 ++- .../Core/EventListener/ControllerListener.php | 4 +- .../Core/HttpFoundation/Session/Session.php | 37 +++- ...AdminUsernamePasswordFormAuthenticator.php | 8 +- ...tomerUsernamePasswordFormAuthenticator.php | 7 +- .../UsernamePasswordFormAuthenticator.php | 44 ++--- .../Thelia/Core/Security/SecurityContext.php | 47 +++++- core/lib/Thelia/Core/Template/Loop/Auth.php | 13 +- .../Smarty/Assets/SmartyAssetsManager.php | 3 +- .../Core/Template/Smarty/Plugins/Form.php | 159 +++++++++++------- .../Template/Smarty/Plugins/UrlGenerator.php | 59 +++++++ core/lib/Thelia/Form/AdminLogin.php | 10 +- core/lib/Thelia/Form/BaseForm.php | 25 ++- core/lib/Thelia/Form/CustomerCreation.php | 2 +- core/lib/Thelia/Form/CustomerLogin.php | 2 +- core/lib/Thelia/Form/CustomerModification.php | 2 +- core/lib/Thelia/Tools/URL.php | 57 +++++++ templates/admin/default/assets/css/admin.less | 158 +++++++++++++++++ templates/admin/default/home.html | 2 +- templates/admin/default/login.html | 26 ++- templates/smarty-sample/connexion.html | 62 +++---- templates/smarty-sample/index.html | 3 +- 26 files changed, 626 insertions(+), 220 deletions(-) create mode 100644 core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php create mode 100644 core/lib/Thelia/Tools/URL.php diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 9241fd89f..09c3246fd 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -43,10 +43,9 @@ class Customer implements EventSubscriberInterface $request = $event->getRequest(); - $customerForm = new CustomerCreation($request); - - $form = $customerForm->getForm(); + $customerCreation = new CustomerCreation($request); + $form = $customerCreation->getForm(); if ($request->isMethod("post")) { $form->bind($request); @@ -68,18 +67,18 @@ class Customer implements EventSubscriberInterface $data["country"], $data["email"], $data["password"], - $request->getSession()->get("lang") + $request->getSession()->getLang() ); } catch (\PropelException $e) { Tlog::getInstance()->error(sprintf('error during creating customer on action/createCustomer with message "%s"', $e->getMessage())); - $event->setFormError($form); + $event->setFormError($customerCreation); } //Customer is create, he is automatically connected } else { - $event->setFormError($form); + $event->setFormError($customerCreation); } } @@ -117,10 +116,10 @@ class Customer implements EventSubscriberInterface ); } catch(\PropelException $e) { Tlog::getInstance()->error(sprintf('error during modifying customer on action/modifyCustomer with message "%s"', $e->getMessage())); - $event->setFormError($form); + $event->setFormError($customerModification); } } else { - $event->setFormError($form); + $event->setFormError($customerModification); } } diff --git a/core/lib/Thelia/Admin/Controller/BaseAdminController.php b/core/lib/Thelia/Admin/Controller/BaseAdminController.php index 47258480b..15a9753f3 100755 --- a/core/lib/Thelia/Admin/Controller/BaseAdminController.php +++ b/core/lib/Thelia/Admin/Controller/BaseAdminController.php @@ -34,6 +34,7 @@ use Thelia\Core\Security\Exception\AuthenticationTokenNotFoundException; use Thelia\Model\ConfigQuery; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\SecurityContext; +use Thelia\Tools\URL; /** * @@ -93,7 +94,7 @@ class BaseAdminController extends ContainerAware // User is not authenticated, and templates requires authentication -> redirect to login page // (see Thelia\Core\Template\Smarty\Plugins\Security) - return new RedirectResponse($this->generateUrl('admin/login')); // FIXME shoud be a parameter + return new RedirectResponse(URL::absoluteUrl('admin/login')); // FIXME shoud be a parameter } } @@ -155,32 +156,6 @@ class BaseAdminController extends ContainerAware return $this->getFormFactory()->createBuilder("form"); } - /** - * Generates a URL from the given parameters. - * - * @param string $route The name of the route - * @param mixed $parameters An array of parameters - * @param Boolean|string $referenceType The type of reference (one of the constants in UrlGeneratorInterface) - * - * @return string The generated URL - * - * @see UrlGeneratorInterface - */ - protected function generateUrl($path, array $parameters = array()) - { - $base = ConfigQuery::read("base_url", "/").$path; //FIXME - - $queryString = ''; - - foreach($parameters as $name => $value) { - $queryString = sprintf("%s=%s&", urlencode($name), urlencode($value)); - } - - if ('' !== $queryString = rtrim($queryString, "&")) $queryString = '?' . $queryString; - - return $base . $queryString; - } - /** * Forwards the request to another controller. * diff --git a/core/lib/Thelia/Admin/Controller/SessionController.php b/core/lib/Thelia/Admin/Controller/SessionController.php index e56af2d1b..457b6798e 100755 --- a/core/lib/Thelia/Admin/Controller/SessionController.php +++ b/core/lib/Thelia/Admin/Controller/SessionController.php @@ -32,16 +32,14 @@ use Thelia\Core\Security\Token\TokenInterface; use Thelia\Core\Security\Authentication\AdminUsernamePasswordFormAuthenticator; use Thelia\Model\AdminLog; use Thelia\Core\Security\Exception\AuthenticationException; +use Symfony\Component\Validator\Exception\ValidatorException; +use Thelia\Tools\URL; class SessionController extends BaseAdminController { public function showLoginAction() { - $form = $this->getLoginForm(); - - return $this->render("login.html", array( - "form" => $form->createView() - )); + return $this->render("login.html"); } public function checkLogoutAction() @@ -49,12 +47,12 @@ class SessionController extends BaseAdminController { $this->getSecurityContext()->clear(); // Go back to login page. - return $this->redirect($this->generateUrl('admin/login')); + return $this->redirect(URL::absoluteUrl('admin/login')); } public function checkLoginAction() { - $form = $this->getLoginForm(); + $form = new AdminLogin($this->getRequest()); $request = $this->getRequest(); @@ -69,8 +67,17 @@ class SessionController extends BaseAdminController { // Log authentication success AdminLog::append("Authentication successufull", $request, $user); + // Get the success URL to redirect the user to + $successUrl = $form->getForm()->get('success_url')->getData(); + + if (null == $successUrl) $successUrl = 'admin/home'; + // Redirect to home page - FIXME: requested URL, if we come from another page ? - return $this->redirect($this->generateUrl('admin')); + return $this->redirect(URL::absoluteUrl($successUrl)); + } + catch (ValidatorException $ex) { + + $message = "Missing or invalid information. Please check your input."; } catch (AuthenticationException $ex) { @@ -80,17 +87,18 @@ class SessionController extends BaseAdminController { $message = "Login failed. Please check your username and password."; } - // Display the login form again - return $this->render("login.html", array( - "form" => $authenticator->getLoginForm()->createView(), - "message" => $message - )); - } + // Store the form in session (see Form Smlarty plugin to find usage of this parameter) + $request->getSession()->setErrorFormName($form->getName()); - protected function getLoginForm() - { - $adminLogin = new AdminLogin($this->getRequest()); - - return $adminLogin->getForm(); + if (empty($failureUrl)) { + // Display the login form again, with an error message if required + return $this->render("login.html", array( + "message" => $message + )); + } + else { + // Redirect to the provided URL + return $this->redirect(URL::absoluteUrl($failureUrl)); + } } } \ No newline at end of file diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index ce63ace02..bb680aeac 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -27,7 +27,7 @@
- +
@@ -120,6 +120,10 @@ + + + + diff --git a/core/lib/Thelia/Core/Event/ActionEvent.php b/core/lib/Thelia/Core/Event/ActionEvent.php index 32074c559..fc5822a93 100755 --- a/core/lib/Thelia/Core/Event/ActionEvent.php +++ b/core/lib/Thelia/Core/Event/ActionEvent.php @@ -25,6 +25,7 @@ namespace Thelia\Core\Event; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\HttpFoundation\Request; +use Thelia\Form\BaseForm; /** * * Class thrown on Thelia.action event @@ -47,7 +48,7 @@ abstract class ActionEvent extends Event */ protected $action; - protected $form; + protected $form = null; /** * @@ -78,17 +79,30 @@ abstract class ActionEvent extends Event return $this->request; } - public function setFormError($form) + /** + * Store a form taht contains error, to pass it to the current session. + * + * @param BaseForm $form + */ + public function setFormError(BaseForm $form) { $this->form = $form; $this->stopPropagation(); } - public function getForm() + /** + * @return BaseForm the errored form, or null + */ + public function getFormError() { return $this->form; } + /** + * Check if theis event contains a form with errors + * + * @return boolean + */ public function hasFormError() { return $this->form !== null; diff --git a/core/lib/Thelia/Core/EventListener/ControllerListener.php b/core/lib/Thelia/Core/EventListener/ControllerListener.php index 93c827c09..96d249e69 100755 --- a/core/lib/Thelia/Core/EventListener/ControllerListener.php +++ b/core/lib/Thelia/Core/EventListener/ControllerListener.php @@ -50,9 +50,7 @@ class ControllerListener implements EventSubscriberInterface $dispatcher->dispatch("action.".$action, $actionEvent); if ($actionEvent->hasFormError()) { - $request->getSession()->set("form_error", true); - $request->getSession()->set("form_name", $actionEvent->getForm()->createView() - ->vars["attr"]["thelia_name"]); + $request->getSession()->setErrorFormName($actionEvent->getFormError()->getName()); } } diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php index 63e07b2a7..564c4b1c6 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -25,6 +25,7 @@ namespace Thelia\Core\HttpFoundation\Session; use Symfony\Component\HttpFoundation\Session\Session as BaseSession; use Thelia\Core\Security\User\UserInterface; +use Thelia\Form\BaseForm; class Session extends BaseSession { @@ -39,28 +40,52 @@ class Session extends BaseSession { return substr($this->getLocale(), 0, 2); } - public function setCustomerUser(UserInterface $user) { + public function setCustomerUser(UserInterface $user) + { $this->set('customer_user', $user); } - public function getCustomerUser() { + public function getCustomerUser() + { return $this->get('customer_user'); } - public function clearCustomerUser() { + public function clearCustomerUser() + { return $this->remove('customer_user'); } - public function setAdminUser(UserInterface $user) { + public function setAdminUser(UserInterface $user) + { $this->set('admin_user', $user); } - public function getAdminUser() { + public function getAdminUser() + { return $this->get('admin_user'); } - public function clearAdminUser() { + public function clearAdminUser() + { return $this->remove('admin_user'); } + + /** + * @param string $formName the form name + */ + public function setErrorFormName($formName) + { + $this->set('error_form', $formName); + } + + public function getErrorFormName() + { + return $this->get('error_form', null); + } + + public function clearErrorFormName() + { + return $this->remove('error_form'); + } } diff --git a/core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php index 81db900d8..b1427f0fd 100644 --- a/core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php +++ b/core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php @@ -29,17 +29,15 @@ use Symfony\Component\Form\Form; use Thelia\Core\Security\UserProvider\AdminUserProvider; use Thelia\Core\Security\Authentication\UsernamePasswordFormAuthenticator; +use Thelia\Form\AdminLogin; class AdminUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuthenticator { - public function __construct(Request $request, Form $loginForm) { + public function __construct(Request $request, AdminLogin $loginForm) { parent::__construct( $request, $loginForm, - new AdminUserProvider(), - array( - 'username_field_name', 'email' - ) + new AdminUserProvider() ); } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php index 483894b93..8f3836119 100644 --- a/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php +++ b/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php @@ -30,11 +30,14 @@ use Thelia\Form\CustomerLogin; class CustomerUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuthenticator { - public function __construct(Request $request, AdminLogin $loginForm) { + public function __construct(Request $request, CustomerLogin $loginForm) { parent::__construct( $request, $loginForm, - new AdminUserProvider(), + new CustomerUserProvider(), + array( + 'username_field_name', 'email' + ) ); } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php index 37156786c..77d54d682 100644 --- a/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php +++ b/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php @@ -29,6 +29,8 @@ use Thelia\Core\Security\UserProvider\UserProviderInterface; use Symfony\Component\Form\Form; use Thelia\Core\Security\Exception\WrongPasswordException; use Thelia\Core\Security\Exception\UsernameNotFoundException; +use Symfony\Component\Validator\Exception\ValidatorException; +use Thelia\Form\BaseForm; class UsernamePasswordFormAuthenticator implements AuthenticatorInterface { @@ -37,10 +39,12 @@ class UsernamePasswordFormAuthenticator implements AuthenticatorInterface { protected $userProvider; protected $options; + protected $baseLoginForm; - public function __construct(Request $request, Form $loginForm, UserProviderInterface $userProvider, array $options = array()) { + public function __construct(Request $request, BaseForm $loginForm, UserProviderInterface $userProvider, array $options = array()) { $this->request = $request; - $this->loginForm = $loginForm; + $this->baseLoginForm = $loginForm; + $this->loginForm = $this->baseLoginForm->getForm(); $this->userProvider = $userProvider; $defaults = array( @@ -54,38 +58,38 @@ class UsernamePasswordFormAuthenticator implements AuthenticatorInterface { $this->loginForm->bind($this->request); } - public function getLoginForm() { - return $this->loginForm; - } - + /** + * @return string the username value + */ public function getUsername() { return $this->loginForm->get($this->options['username_field_name'])->getData(); } + /** + * @see \Thelia\Core\Security\Authentication\AuthenticatorInterface::getAuthentifiedUser() + */ public function getAuthentifiedUser() { if ($this->request->isMethod($this->options['required_method'])) { - if ($this->loginForm->isValid()) { + if (! $this->loginForm->isValid()) throw new ValidatorException("Form is not valid."); - // Retreive user - $username = $this->getUsername(); - $password = $this->loginForm->get($this->options['password_field_name'])->getData(); + // Retreive user + $username = $this->getUsername(); + $password = $this->loginForm->get($this->options['password_field_name'])->getData(); - $user = $this->userProvider->getUser($username); + $user = $this->userProvider->getUser($username); - if ($user === null) throw new UsernameNotFoundException(sprintf("Username '%s' was not found.", $username)); + if ($user === null) throw new UsernameNotFoundException(sprintf("Username '%s' was not found.", $username)); - // Check user password - $authOk = $user->checkPassword($password) === true; + // Check user password + $authOk = $user->checkPassword($password) === true; - if ($authOk !== true) throw new WrongPasswordException(sprintf("Wrong password for user '%s'.", $username)); + if ($authOk !== true) throw new WrongPasswordException(sprintf("Wrong password for user '%s'.", $username)); - return $user; - } - } - else { - throw new \RuntimeException("Invalid method."); + return $user; } + + throw new \RuntimeException("Invalid method."); } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/SecurityContext.php b/core/lib/Thelia/Core/Security/SecurityContext.php index 645d9a196..a4409afd8 100755 --- a/core/lib/Thelia/Core/Security/SecurityContext.php +++ b/core/lib/Thelia/Core/Security/SecurityContext.php @@ -109,10 +109,51 @@ class SecurityContext { { if ($this->isAuthenticated() === true) { - echo "TODO: check roles and permissions !"; + $user = $this->getUser(); - // TODO : check roles and permissions - return true; + // Check if user's roles matches required roles + $userRoles = $user->getRoles(); + + $roleFound = false; + + foreach($userRoles as $role) { + if (in_array($role, $roles)) { + $roleFound = true; + + break; + } + } + + if ($roleFound) { + + if (empty($permissions)) { + return true; + } + + // Get permissions from profile + // $userPermissions = $user->getPermissions(); + + echo "TODO: Finalize permissions system !"; + + $userPermissions = array('*'); // FIXME ! + + $permissionsFound = true; + + // User have all permissions ? + if (in_array('*', $userPermissions)) + return true; + + // Check that user's permissions matches required permissions + foreach($permissions as $permission) { + if (! in_array($permission, $userPermissions)) { + $permissionsFound = false; + + break; + } + } + + return $permissionsFound; + } } return false; diff --git a/core/lib/Thelia/Core/Template/Loop/Auth.php b/core/lib/Thelia/Core/Template/Loop/Auth.php index d0c477ef9..5adaf8286 100755 --- a/core/lib/Thelia/Core/Template/Loop/Auth.php +++ b/core/lib/Thelia/Core/Template/Loop/Auth.php @@ -47,7 +47,8 @@ class Auth extends BaseLoop { return new ArgumentCollection( Argument::createAnyTypeArgument('roles', null, true), - Argument::createAnyTypeArgument('permissions') + Argument::createAnyTypeArgument('permissions'), + Argument::createAnyTypeArgument('context', 'front', false) ); } @@ -72,16 +73,20 @@ class Auth extends BaseLoop */ public function exec(&$pagination) { + $context = $this->getContext(); $roles = $this->_explode($this->getRoles()); $permissions = $this->_explode($this->getPermissions()); $loopResult = new LoopResult(); try { - $this->securityContext->isGranted($roles, $permissions == null ? array() : $permissions); + $this->securityContext->setContext($context); - // Create an empty row: loop is no longer empty :) - $loopResult->addRow(new LoopResultRow()); + if (true === $this->securityContext->isGranted($roles, $permissions == null ? array() : $permissions)) { + + // Create an empty row: loop is no longer empty :) + $loopResult->addRow(new LoopResultRow()); + } } catch (\Exception $ex) { // Not granted, loop is empty diff --git a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php index 63a9a90e4..5610785d8 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php +++ b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php @@ -25,6 +25,7 @@ namespace Thelia\Core\Template\Smarty\Assets; use Thelia\Core\Template\Assets\AsseticHelper; use Thelia\Model\ConfigQuery; +use Thelia\Tools\URL; class SmartyAssetsManager { @@ -72,7 +73,7 @@ class SmartyAssetsManager $url = $this->assetic_manager->asseticize( $asset_dir.'/'.$asset_file, $this->web_root."/".$this->path_relative_to_web_root, - ConfigQuery::read('base_url', '/') . $this->path_relative_to_web_root, + URL::absoluteUrl($this->path_relative_to_web_root), $assetType, $filters, $debug diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 2ff6be8e3..db71484ed 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -58,7 +58,6 @@ class Form implements SmartyPluginInterface { protected $request; - protected $form; protected $formDefinition = array(); public function __construct(Request $request) @@ -87,67 +86,74 @@ class Form implements SmartyPluginInterface throw new \InvalidArgumentException("Missing 'name' parameter in form arguments"); } - $instance = $this->getInstance($params['name']); - $form = $instance->getForm(); + $instance = $this->createInstance($params['name']); - if ( - true === $this->request->getSession()->get("form_error", false) && - $this->request->getSession()->get("form_name") == $instance->getName()) - { - $form->bind($this->request); - $this->request->getSession()->set("form_error", false); + // Check if session contains our form + $errorForm = $this->request->getSession()->getErrorFormName(); + + if ($errorForm == $instance->getName()) { + + // Bind form with current request to get error messages and field values. + $instance->getForm()->bind($this->request); + + // Remove the form from the session + $this->request->getSession()->clearErrorFormName(); } - $template->assign("form", $form->createView()); - } else { + $instance->createView(); + + $template->assign("form", $instance); + } + else { return $content; } } - public function formRender($params, $content, \Smarty_Internal_Template $template, &$repeat) + public function renderFormField($params, $content, \Smarty_Internal_Template $template, &$repeat) { if ($repeat) { - $form = $params["form"]; + $formFieldView = $this->getFormFieldView($params); - if (! $form instanceof \Symfony\Component\Form\FormView) { - throw new \InvalidArgumentException("form parameter in form_field block must be an instance of - Symfony\Component\Form\FormView"); + $template->assign("options", $formFieldView->vars); + $template->assign("name", $formFieldView->vars["full_name"]); + $template->assign("value", $formFieldView->vars["value"]); + $template->assign("label", $formFieldView->vars["label"]); + + $errors = $formFieldView->vars["errors"]; + + $template->assign("error", empty($errors) ? false : true); + + if (! empty($errors)) { + $this->assignFieldErrorVars($template, $errors); } - - $template->assign("options", $form->vars); - $template->assign("name", $form->vars["full_name"]); - $template->assign("value", $form->vars["value"]); - $template->assign("label", $form->vars["label"]); - $template->assign("error", empty($form->vars["errors"]) ? false : true); $attr = array(); - foreach ($form->vars["attr"] as $key => $value) { + + foreach ($formFieldView->vars["attr"] as $key => $value) { $attr[] = sprintf('%s="%s"', $key, $value); } + $template->assign("attr", implode(" ", $attr)); - $form->setRendered(); - - } else { + $formFieldView->setRendered(); + } + else { return $content; } } - public function formRenderHidden($params, \Smarty_Internal_Template $template) + public function renderHiddenFormField($params, \Smarty_Internal_Template $template) { - $form = $params["form"]; - $field = ''; - if (! $form instanceof \Symfony\Component\Form\FormView) { - throw new \InvalidArgumentException("form parameter in form_field_hidden function must be an instance of - Symfony\Component\Form\FormView"); - } + $instance = $this->getInstanceFromParams($params); + + $formView = $instance->getView(); $return = ""; - foreach ($form->getIterator() as $row) { + foreach ($formView->getIterator() as $row) { if ($this->isHidden($row) && $row->isRendered() === false) { $return .= sprintf($field, $row->vars["full_name"], $row->vars["value"]); } @@ -156,53 +162,79 @@ class Form implements SmartyPluginInterface return $return; } - protected function isHidden(FormView $formView) - { - return array_search("hidden", $formView->vars["block_prefixes"]); - } - public function formEnctype($params, \Smarty_Internal_Template $template) { - $form = $params["form"]; + $instance = $this->getInstanceFromParams($params); - if (! $form instanceof \Symfony\Component\Form\FormView) { - throw new \InvalidArgumentException("form parameter in form_enctype function must be an instance of - Symfony\Component\Form\FormView"); - } + $formView = $instance->getForm(); - if ($form->vars["multipart"]) { + if ($formView->vars["multipart"]) { return sprintf('%s="%s"',"enctype", "multipart/form-data"); } } public function formError($params, $content, \Smarty_Internal_Template $template, &$repeat) { + $formFieldView = $this->getFormFieldView($params); - $form = $params["form"]; - if (! $form instanceof \Symfony\Component\Form\FormView) { - throw new \InvalidArgumentException("form parameter in form_error block must be an instance of - Symfony\Component\Form\FormView"); - } + $errors = $formFieldView->vars["errors"]; - if (empty($form->vars["errors"])) { + if (empty($errors)) { return ""; } if ($repeat) { - - $error = $form->vars["errors"]; - - $template->assign("message", $error[0]->getMessage()); - $template->assign("parameters", $error[0]->getMessageParameters()); - $template->assign("pluralization", $error[0]->getMessagePluralization()); - - - } else { + $this->assignFieldErrorVars($template, $errors); + } + else { return $content; } } - public function getInstance($name) + + protected function assignFieldErrorVars(\Smarty_Internal_Template $template, array $errors) + { + $template->assign("message", $errors[0]->getMessage()); + $template->assign("parameters", $errors[0]->getMessageParameters()); + $template->assign("pluralization", $errors[0]->getMessagePluralization()); + } + + protected function isHidden(FormView $formView) + { + return array_search("hidden", $formView->vars["block_prefixes"]); + } + + protected function getFormFieldView($params) { + $instance = $this->getInstanceFromParams($params); + + if (! isset($params['field'])) + throw new \InvalidArgumentException("'field' parameter is missing"); + + $fieldName = $params['field']; + + if (empty($instance->getView()[$fieldName])) + throw new \InvalidArgumentException(sprintf("Field name '%s' not found in form %s", $fieldName, $instance->getName())); + + return $instance->getView()[$fieldName]; + } + + protected function getInstanceFromParams($params) { + + if (empty($params['form'])) { + throw new \InvalidArgumentException("Missing 'form' parameter in form arguments"); + } + + $instance = $params["form"]; + + if (! $instance instanceof \Thelia\Form\BaseForm) { + throw new \InvalidArgumentException(sprintf("form parameter in form_field block must be an instance of + \Thelia\Form\BaseForm, instance of %s found", get_class($instance))); + } + + return $instance; + } + + protected function createInstance($name) { if (!isset($this->formDefinition[$name])) { throw new ElementNotFoundException(sprintf("%s form does not exists", $name)); @@ -210,7 +242,6 @@ class Form implements SmartyPluginInterface $class = new \ReflectionClass($this->formDefinition[$name]); - return $class->newInstance( $this->request, "form" @@ -224,8 +255,8 @@ class Form implements SmartyPluginInterface { return array( new SmartyPluginDescriptor("block", "form", $this, "generateForm"), - new SmartyPluginDescriptor("block", "form_field", $this, "formRender"), - new SmartyPluginDescriptor("function", "form_field_hidden", $this, "formRenderHidden"), + new SmartyPluginDescriptor("block", "form_field", $this, "renderFormField"), + new SmartyPluginDescriptor("function", "form_hidden_fields", $this, "renderHiddenFormField"), new SmartyPluginDescriptor("function", "form_enctype", $this, "formEnctype"), new SmartyPluginDescriptor("block", "form_error", $this, "formError") ); diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php new file mode 100644 index 000000000..adcee9579 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php @@ -0,0 +1,59 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Smarty\Plugins; + +use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; +use Thelia\Core\Template\Smarty\SmartyPluginInterface; +use Thelia\Tools\URL; + +class UrlGenerator implements SmartyPluginInterface +{ + /** + * Process url generator function + * + * @param array $params + * @param unknown $smarty + * @return string no text is returned. + */ + public function generateUrlFunction($params, &$smarty) + { + // the path to process + $path =trim($params['path']); + + return URL::absoluteUrl($path); + } + + /** + * Define the various smarty plugins hendled by this class + * + * @return an array of smarty plugin descriptors + */ + public function getPluginDescriptors() + { + return array( + new SmartyPluginDescriptor('function', 'url', $this, 'generateUrlFunction') + ); + } +} diff --git a/core/lib/Thelia/Form/AdminLogin.php b/core/lib/Thelia/Form/AdminLogin.php index 6ba27830e..b67e788fc 100755 --- a/core/lib/Thelia/Form/AdminLogin.php +++ b/core/lib/Thelia/Form/AdminLogin.php @@ -23,7 +23,6 @@ namespace Thelia\Form; -use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Choice; @@ -32,7 +31,7 @@ class AdminLogin extends BaseForm { protected function buildForm() { - $this->form + $this->formBuilder ->add("username", "text", array( "constraints" => array( new NotBlank(), @@ -44,12 +43,15 @@ class AdminLogin extends BaseForm { new NotBlank() ) )) - ->add("remember_me", "checkbox") + ->add("remember_me", "checkbox", array( + 'value' => 'yes' + )) + ->add("success_url", "text") ; } public function getName() { - return "admin_login"; + return "adminLogin"; } } diff --git a/core/lib/Thelia/Form/BaseForm.php b/core/lib/Thelia/Form/BaseForm.php index b53747a5d..a3220fa8b 100755 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -36,9 +36,14 @@ abstract class BaseForm { /** * @var \Symfony\Component\Form\FormFactoryInterface */ + protected $formBuilder; + + /** + * @var \Symfony\Component\Form\Form + */ protected $form; - public $name; + private $view = null; public function __construct(Request $request, $type= "form", $data = array(), $options = array()) { @@ -48,7 +53,7 @@ abstract class BaseForm { $options["attr"]["thelia_name"] = $this->getName(); } - $this->form = Forms::createFormFactoryBuilder() + $this->formBuilder = Forms::createFormFactoryBuilder() ->addExtension(new HttpFoundationExtension()) ->addExtension( new CsrfExtension( @@ -63,9 +68,19 @@ abstract class BaseForm { ->createNamedBuilder($this->getName(), $type, $data, $options); ; + $this->buildForm(); + $this->form = $this->formBuilder->getForm(); + } - $this->buildForm(); + public function createView() { + $this->view = $this->form->createView(); + } + + public function getView() { + if ($this->view === null) throw new \LogicException("View was not created. Please call BaseForm::createView() first."); + + return $this->view; } /** @@ -73,13 +88,13 @@ abstract class BaseForm { */ public function getForm() { - return $this->form->getForm(); + return $this->form; } /** * * in this function you add all the fields you need for your Form. - * Form this you have to call add method on $this->form attribute : + * Form this you have to call add method on $this->formBuilder attribute : * * $this->form->add("name", "text") * ->add("email", "email", array( diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index 2ba80f362..9f675e74e 100755 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -33,7 +33,7 @@ class CustomerCreation extends BaseForm protected function buildForm() { - $this->form + $this->formBuilder ->add("firstname", "text", array( "constraints" => array( new Constraints\NotBlank() diff --git a/core/lib/Thelia/Form/CustomerLogin.php b/core/lib/Thelia/Form/CustomerLogin.php index e18947d1b..e1096f9b4 100644 --- a/core/lib/Thelia/Form/CustomerLogin.php +++ b/core/lib/Thelia/Form/CustomerLogin.php @@ -32,7 +32,7 @@ class CustomerLogin extends BaseForm { protected function buildForm() { - $this->form + $this->formBuilder ->add("username", "text", array( "constraints" => array( new NotBlank(), diff --git a/core/lib/Thelia/Form/CustomerModification.php b/core/lib/Thelia/Form/CustomerModification.php index cb21be2fa..c87e5fece 100755 --- a/core/lib/Thelia/Form/CustomerModification.php +++ b/core/lib/Thelia/Form/CustomerModification.php @@ -52,7 +52,7 @@ class CustomerModification extends BaseForm { protected function buildForm() { - $this->form + $this->formBuilder ->add("firstname", "text", array( "constraints" => array( new Constraints\NotBlank() diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php new file mode 100644 index 000000000..b1c8964d4 --- /dev/null +++ b/core/lib/Thelia/Tools/URL.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tools; + +use Thelia\Model\ConfigQuery; + +class URL +{ + /** + * Returns the Absolute URL for a given path relative to web root + * + * @param string $path the relative path + * @param mixed $parameters An array of parameters + * @param Boolean|string $referenceType The type of reference (one of the constants in UrlGeneratorInterface) + * + * @return string The generated URL + */ + public static function absoluteUrl($path, array $parameters = array()) + { + // Already absolute ? + if (substr($path, 0, 4) != 'http') + $base = ConfigQuery::read('base_url', '/') . ltrim($path, '/'); + else + $base = $path; + + $queryString = ''; + + foreach($parameters as $name => $value) { + $queryString = sprintf("%s=%s&", urlencode($name), urlencode($value)); + } + + if ('' !== $queryString = rtrim($queryString, "&")) $queryString = '?' . $queryString; + + return $base . $queryString; + } +} diff --git a/templates/admin/default/assets/css/admin.less b/templates/admin/default/assets/css/admin.less index fb3b8f8b7..c19e623f6 100755 --- a/templates/admin/default/assets/css/admin.less +++ b/templates/admin/default/assets/css/admin.less @@ -235,4 +235,162 @@ hr { border: 1px solid #e5e5e5; .border-radius; .box-shadow; +} + +// -- Allow inline forms validation states ------------------------------------ + +.form-inline .warning .control-label, +.form-inline .warning .help-block, +.form-inline .warning .help-inline { + color: #c09853; +} + +.form-inline .warning .checkbox, +.form-inline .warning .radio, +.form-inline .warning input, +.form-inline .warning select, +.form-inline .warning textarea { + color: #c09853; +} + +.form-inline .warning input, +.form-inline .warning select, +.form-inline .warning textarea { + border-color: #c09853; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} + +.form-inline .warning input:focus, +.form-inline .warning select:focus, +.form-inline .warning textarea:focus { + border-color: #a47e3c; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e; + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e; +} + +.form-inline .warning .input-prepend .add-on, +.form-inline .warning .input-append .add-on { + color: #c09853; + background-color: #fcf8e3; + border-color: #c09853; +} + +.form-inline .error .control-label, +.form-inline .error .help-block, +.form-inline .error .help-inline { + color: #b94a48; +} + +.form-inline .error .checkbox, +.form-inline .error .radio, +.form-inline .error input, +.form-inline .error select, +.form-inline .error textarea { + color: #b94a48; +} + +.form-inline .error input, +.form-inline .error select, +.form-inline .error textarea { + border-color: #b94a48; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} + +.form-inline .error input:focus, +.form-inline .error select:focus, +.form-inline .error textarea:focus { + border-color: #953b39; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392; + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392; +} + +.form-inline .error .input-prepend .add-on, +.form-inline .error .input-append .add-on { + color: #b94a48; + background-color: #f2dede; + border-color: #b94a48; +} + +.form-inline .success .control-label, +.form-inline .success .help-block, +.form-inline .success .help-inline { + color: #468847; +} + +.form-inline .success .checkbox, +.form-inline .success .radio, +.form-inline .success input, +.form-inline .success select, +.form-inline .success textarea { + color: #468847; +} + +.form-inline .success input, +.form-inline .success select, +.form-inline .success textarea { + border-color: #468847; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} + +.form-inline .success input:focus, +.form-inline .success select:focus, +.form-inline .success textarea:focus { + border-color: #356635; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b; + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b; +} + +.form-inline .success .input-prepend .add-on, +.form-inline .success .input-append .add-on { + color: #468847; + background-color: #dff0d8; + border-color: #468847; +} + +.form-inline .info .control-label, +.form-inline .info .help-block, +.form-inline .info .help-inline { + color: #3a87ad; +} + +.form-inline .info .checkbox, +.form-inline .info .radio, +.form-inline .info input, +.form-inline .info select, +.form-inline .info textarea { + color: #3a87ad; +} + +.form-inline .info input, +.form-inline .info select, +.form-inline .info textarea { + border-color: #3a87ad; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} + +.form-inline .info input:focus, +.form-inline .info select:focus, +.form-inline .info textarea:focus { + border-color: #2d6987; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3; + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3; +} + +.form-inline .info .input-prepend .add-on, +.form-inline .info .input-append .add-on { + color: #3a87ad; + background-color: #d9edf7; + border-color: #3a87ad; } \ No newline at end of file diff --git a/templates/admin/default/home.html b/templates/admin/default/home.html index 53f0a5b6b..f49172464 100755 --- a/templates/admin/default/home.html +++ b/templates/admin/default/home.html @@ -1,4 +1,4 @@ -{check_auth context="admin" roles="ADMIN"} +{check_auth context="admin" roles="ADMIN" login_url="login"} {$page_title={intl l='Home'}} {include file='includes/header.inc.html'} diff --git a/templates/admin/default/login.html b/templates/admin/default/login.html index 55cc345b7..b674a1dc5 100755 --- a/templates/admin/default/login.html +++ b/templates/admin/default/login.html @@ -13,28 +13,36 @@

{intl l='Thelia Back Office'}

+ {form name="thelia.admin.login" success_url="home" error_url="login"} {if isset($message)}
{$message}
{/if} - {form_field_hidden form=$form} + {form_hidden_fields form=$form} - {form_field form=$form.username} - {form_error form=$form.username}{$message}{/form_error} - + {form_field form=$form field='success_url'} + {* redirect to /admin *} + {/form_field} + + {form_field form=$form field='username'} + + + {/form_field} - {form_field form=$form.password} - {form_error form=$form.password}{$message}{/form_error} - + {form_field form=$form field='password'} + + + {/form_field} - {form_field form=$form.remember_me} - + {form_field form=$form field='remember_me'} + {/form_field} + {/form}
{module_include location='index_middle'} diff --git a/templates/smarty-sample/connexion.html b/templates/smarty-sample/connexion.html index 44b13386e..a2f9120dd 100755 --- a/templates/smarty-sample/connexion.html +++ b/templates/smarty-sample/connexion.html @@ -3,10 +3,10 @@ {form name="thelia.customer.creation"}
- {form_field_hidden form=$form} + {form_hidden_fields form=$form} - {form_field form=$form.title} - {form_error form=$form.title} + {form_field form=$form field="title"} + {form_error form=$form field="title"} {$message} {/form_error} @@ -19,64 +19,64 @@
{/form_field} - {form_field form=$form.firstname} - {form_error form=$form.firstname} + {form_field form=$form field="firstname"} + {form_error form=$form field="firstname"} {$message} {/form_error}
{/form_field} - {form_field form=$form.lastname} - {form_error form=$form.lastname} + {form_field form=$form field="lastname"} + {form_error form=$form field="lastname"} {$message} {/form_error}
{/form_field} - {form_field form=$form.address1} - {form_error form=$form.address1} + {form_field form=$form field="address1"} + {form_error form=$form field="address1"} {$message} {/form_error}
{/form_field} - {form_field form=$form.address2} - {form_error form=$form.address2} + {form_field form=$form field="address2"} + {form_error form=$form field="address2"} {$message} {/form_error}
{/form_field} - {form_field form=$form.address3} - {form_error form=$form.address3} + {form_field form=$form field="address3"} + {form_error form=$form field="address3"} {$message} {/form_error}
{/form_field} - {form_field form=$form.zipcode} - {form_error form=$form.zipcode} + {form_field form=$form field="zipcode"} + {form_error form=$form field="zipcode"} {$message} {/form_error}
{/form_field} - {form_field form=$form.city} - {form_error form=$form.city} + {form_field form=$form field="city"} + {form_error form=$form field="city"} {$message} {/form_error}
{/form_field} - {form_field form=$form.country} - {form_error form=$form.country} + {form_field form=$form field="country"} + {form_error form=$form field="country"} {$message} {/form_error} @@ -89,43 +89,43 @@
{/form_field} - {form_field form=$form.phone} - {form_error form=$form.phone} + {form_field form=$form field="phone"} + {form_error form=$form field="phone"} {$message} {/form_error}
{/form_field} - {form_field form=$form.cellphone} - {form_error form=$form.cellphone} + {form_field form=$form field="cellphone"} + {form_error form=$form field="cellphone"} {$message} {/form_error}
{/form_field} - {form_field form=$form.email} - {form_error form=$form.email} + {form_field form=$form field="email"} + {form_error form=$form field="email"} {#message} {/form_error}
{/form_field} - {form_field form=$form.email_confirm} - {form_error form=$form.email_confirm} + {form_field form=$form field="email_confirm"} + {form_error form=$form field="email_confirm"} {#message} {/form_error}
{/form_field} - {form_field form=$form.password} - {form_error form=$form.password} + {form_field form=$form field="password"} + {form_error form=$form field="password"} {#message} {/form_error}
{/form_field} - {form_field form=$form.password_confirm} - {form_error form=$form.password_confirm} + {form_field form=$form field="password_confirm"} + {form_error form=$form field="password_confirm"} {#message} {/form_error}
diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html index 87efeeb4d..53834febf 100755 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -1,7 +1,8 @@ {include file="includes/header.html"}
-{loop type="auth" name="auth_test" roles="CUSTOMER"} +{loop type="auth" name="auth_test" context="front" roles="CUSTOMER"} +

Customer is authentified :-)

{/loop} From a84e63e457f99e17a95f4336238a62342a770571 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 17 Jul 2013 10:35:16 +0200 Subject: [PATCH 26/36] verify if file template really exists --- .../Core/Template/Smarty/SmartyParser.php | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index 8e34a89ed..82ef5858c 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -7,6 +7,7 @@ use \Symfony\Component\EventDispatcher\EventDispatcherInterface; use \Smarty; +use Symfony\Component\HttpFoundation\Response; use Thelia\Core\Template\ParserInterface; use Thelia\Core\Template\Smarty\SmartyPluginInterface; @@ -117,7 +118,13 @@ class SmartyParser extends Smarty implements ParserInterface */ public function getContent() { - return $this->fetch($this->getTemplateFilePath()); + try { + $templateFile = $this->getTemplateFilePath(); + } catch(\RuntimeException $e) { + return new Response($e->getMessage(), "404"); + } + + return $this->fetch($templateFile); } /** @@ -181,11 +188,23 @@ class SmartyParser extends Smarty implements ParserInterface protected function getTemplateFilePath() { $file = $this->request->attributes->get('_view'); + $fileName = THELIA_TEMPLATE_DIR . rtrim($this->template, "/") . "/" . $file; - $fileName = THELIA_TEMPLATE_DIR . rtrim($this->template, "/") . "/" . $file . ".html"; + $pathFileName = realpath(dirname(THELIA_TEMPLATE_DIR . rtrim($this->template, "/") . "/" . $file)); + $templateDir = realpath(THELIA_TEMPLATE_DIR . rtrim($this->template, "/") . "/"); - if (file_exists($fileName)) return $fileName; + if (strpos($pathFileName, $templateDir) !== 0) { + throw new ResourceNotFoundException(sprintf("%s view does not exists", $file)); + } - throw new ResourceNotFoundException(sprintf("%s file not found in %s template", $file, $this->template)); + if (!file_exists($fileName)) { + $fileName .= ".html"; + + if(!file_exists($fileName)) { + throw new ResourceNotFoundException(sprintf("%s file not found in %s template", $file, $this->template)); + } + } + + return $fileName; } } From 0dfee8331bb54c39e5b25a2de856a0e3651042ad Mon Sep 17 00:00:00 2001 From: franck Date: Wed, 17 Jul 2013 11:34:48 +0200 Subject: [PATCH 27/36] Added an output filter to remove blank lines from generated HTML --- .../lib/Thelia/Core/Template/Smarty/SmartyParser.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index 8e34a89ed..4f1060055 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -74,14 +74,20 @@ class SmartyParser extends Smarty implements ParserInterface $this->status = 200; $this->registerFilter('pre', array($this, "preThelia")); + $this->registerFilter('output', array($this, "removeBlankLines")); } public function preThelia($tpl_source, \Smarty_Internal_Template $template) { - $new_source = preg_replace('`{#([a-zA-Z][a-zA-Z0-9\-_]*)(.*)}`', '{\$$1$2}', $tpl_source); - $new_source = preg_replace('`#([a-zA-Z][a-zA-Z0-9\-_]*)`', '{\$$1|dieseCanceller:\'#$1\'}', $new_source); + $new_source = preg_replace('`{#([a-zA-Z][a-zA-Z0-9\-_]*)(.*)}`', '{\$$1$2}', $tpl_source); + $new_source = preg_replace('`#([a-zA-Z][a-zA-Z0-9\-_]*)`', '{\$$1|dieseCanceller:\'#$1\'}', $new_source); - return $new_source; + return $new_source; + } + + public function removeBlankLines($tpl_source, \Smarty_Internal_Template $template) + { + return preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $tpl_source); } public function setTemplate($template_path_from_template_base) From 21068f4c1fa280ffed0469d4d863de1689ac3df7 Mon Sep 17 00:00:00 2001 From: franck Date: Wed, 17 Jul 2013 11:36:28 +0200 Subject: [PATCH 28/36] Added UrlGenerator smarty plugin, to allow templates and url manipulation in templates. --- core/lib/Thelia/Config/Resources/config.xml | 4 +- .../Core/Template/Smarty/Plugins/Security.php | 8 ++- .../Template/Smarty/Plugins/UrlGenerator.php | 59 +++++++++++++++++-- core/lib/Thelia/Tools/URL.php | 15 ++++- 4 files changed, 79 insertions(+), 7 deletions(-) diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index bb680aeac..b91428f6c 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -27,6 +27,7 @@ + @@ -120,8 +121,9 @@ - + + diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php index 28fd8e4cf..cd19576b1 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php @@ -69,11 +69,17 @@ class Security implements SmartyPluginInterface $permissions = $this->_explode($params['permissions']); if (! $this->securityContext->isGranted($roles, $permissions)) { - throw new AuthenticationException( + $ex = new AuthenticationException( sprintf("User not granted for roles '%s', permissions '%s' in context '%s'.", implode(',', $roles), implode(',', $permissions), $context ) ); + + if (! empty($params['login_tpl'])) { + $ex->setLoginTemplate($params['login_tpl']); + } + + throw $ex; } return ''; diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php index adcee9579..cef25cc33 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php @@ -1,5 +1,4 @@ request = $request; + } + + /** * Process url generator function * * @param array $params @@ -42,7 +49,49 @@ class UrlGenerator implements SmartyPluginInterface // the path to process $path =trim($params['path']); - return URL::absoluteUrl($path); + return URL::absoluteUrl($path, $this->getArgsFromParam($params)); + } + + /** + * Process view url generator function + * + * @param array $params + * @param unknown $smarty + * @return string no text is returned. + */ + public function generateViewUrlFunction($params, &$smarty) + { + // the path to process + $view = trim($params['view']); + + return URL::viewUrl($view, $this->getArgsFromParam($params)); + } + + /** + * Get URL parameters array from a comma separated list or arguments in the + * parameters. + * + * @param array $params Smarty function params + * @return array the parameters array (either emply, of valued) + */ + private function getArgsFromParam($params) { + + if (isset($params['args'])) + return explode($params['args'], ','); + + return array(); + } + + /** + * Process view url generator function + * + * @param array $params + * @param unknown $smarty + * @return string no text is returned. + */ + public function generateReturnToUrl($params, &$smarty) + { + return URL::absoluteUrl($this->request->getSession()->getReturnToUrl()); } /** @@ -53,7 +102,9 @@ class UrlGenerator implements SmartyPluginInterface public function getPluginDescriptors() { return array( - new SmartyPluginDescriptor('function', 'url', $this, 'generateUrlFunction') + new SmartyPluginDescriptor('function', 'url', $this, 'generateUrlFunction'), + new SmartyPluginDescriptor('function', 'viewurl', $this, 'generateViewUrlFunction'), + new SmartyPluginDescriptor('function', 'return_to_url', $this, 'generateReturnToUrl') ); } } diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index b1c8964d4..ae30d7280 100644 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -32,7 +32,6 @@ class URL * * @param string $path the relative path * @param mixed $parameters An array of parameters - * @param Boolean|string $referenceType The type of reference (one of the constants in UrlGeneratorInterface) * * @return string The generated URL */ @@ -54,4 +53,18 @@ class URL return $base . $queryString; } + + /** + * Returns the Absolute URL to a view + * + * @param string $viewName the view name (e.g. login for login.html) + * @param mixed $parameters An array of parameters + * + * @return string The generated URL + */ + public static function viewUrl($viewName, array $parameters = array()) { + $path = sprintf("%s?view=%s", ConfigQuery::read('base_url', '/'), $viewName); + + return self::absoluteUrl($path, $parameters); + } } From 3d5caa2341d5bd67ed654984e30b5b05e41d33ef Mon Sep 17 00:00:00 2001 From: franck Date: Wed, 17 Jul 2013 15:06:53 +0200 Subject: [PATCH 29/36] Fix source header alignment --- core/lib/Thelia/Action/Cart.php | 4 +- core/lib/Thelia/Action/Customer.php | 82 ++++++++++++++++++- .../Admin/Controller/AdminController.php | 2 +- .../Admin/Controller/BaseAdminController.php | 16 +--- .../Admin/Controller/SessionController.php | 37 ++++----- core/lib/Thelia/Command/CacheClear.php | 4 +- .../Thelia/Command/ContainerAwareCommand.php | 4 +- core/lib/Thelia/Command/Install.php | 4 +- .../Command/ModuleGenerateModelCommand.php | 4 +- .../Command/ModuleGenerateSqlCommand.php | 4 +- .../Command/Output/TheliaConsoleOutput.php | 4 +- .../Thelia/Command/Skeleton/Module/Class.php | 4 +- .../Thelia/Config/DatabaseConfiguration.php | 4 +- core/lib/Thelia/Config/DefinePropel.php | 4 +- core/lib/Thelia/Config/Resources/action.xml | 7 +- core/lib/Thelia/Config/Resources/config.xml | 13 --- .../Thelia/Controller/DefaultController.php | 4 +- core/lib/Thelia/Core/Application.php | 4 +- .../Compiler/RegisterListenersPass.php | 4 +- .../Loader/XmlFileLoader.php | 4 +- core/lib/Thelia/Core/Event/ActionEvent.php | 6 +- core/lib/Thelia/Core/Event/CustomRefEvent.php | 4 +- core/lib/Thelia/Core/Event/TheliaEvents.php | 4 +- .../Core/EventListener/ControllerListener.php | 8 +- .../Core/EventListener/ViewListener.php | 16 +++- .../Core/Factory/ActionEventFactory.php | 4 +- .../Core/HttpFoundation/Session/Session.php | 28 ++++++- ...tomerUsernamePasswordFormAuthenticator.php | 1 + .../Exception/AuthenticationException.php | 20 +++++ core/lib/Thelia/Core/Security/Role/Role.php | 4 + .../Thelia/Core/Template/BaseParam/Secure.php | 4 +- .../Thelia/Core/Template/Element/BaseLoop.php | 2 +- .../Exception/ElementNotFoundException.php | 4 +- .../Exception/InvalidElementException.php | 4 +- .../Core/Template/Element/LoopResult.php | 2 +- .../Core/Template/Element/LoopResultRow.php | 2 +- .../Exception/ResourceNotFoundException.php | 4 +- .../Core/Template/Loop/Argument/Argument.php | 4 +- .../Loop/Argument/ArgumentCollection.php | 4 +- .../Thelia/Core/Template/Loop/Category.php | 4 +- .../lib/Thelia/Core/Template/Loop/Product.php | 4 +- .../Thelia/Core/Template/ParserInterface.php | 4 +- core/lib/Thelia/Core/Thelia.php | 4 +- .../Thelia/Core/TheliaContainerBuilder.php | 4 +- .../Exception/MemberAccessException.php | 4 +- core/lib/Thelia/Form/AdminLogin.php | 2 +- core/lib/Thelia/Form/CustomerCreation.php | 2 +- core/lib/Thelia/Form/CustomerLogin.php | 10 ++- .../Thelia/Log/AbstractTlogDestination.php | 4 +- .../Log/Destination/TlogDestinationFile.php | 4 +- .../Log/Destination/TlogDestinationHtml.php | 4 +- .../Log/Destination/TlogDestinationNull.php | 4 +- .../Log/Destination/TlogDestinationText.php | 4 +- core/lib/Thelia/Log/Tlog.php | 4 +- core/lib/Thelia/Log/TlogDestinationConfig.php | 4 +- .../Thelia/Routing/Matcher/DefaultMatcher.php | 4 +- core/lib/Thelia/Routing/NullUrlGenerator.php | 4 +- .../Routing/TheliaMatcherCollection.php | 4 +- .../Thelia/Tests/Command/CacheClearTest.php | 4 +- .../Controller/DefaultControllerTest.php | 4 +- .../Loop/Argument/ArgumentCollectionTest.php | 4 +- core/lib/Thelia/Tests/Log/TlogTest.php | 4 +- .../Tests/Type/AlphaNumStringListTypeTest.php | 4 +- .../Tests/Type/AlphaNumStringTypeTest.php | 4 +- core/lib/Thelia/Tests/Type/AnyTypeTest.php | 4 +- .../lib/Thelia/Tests/Type/BooleanTypeTest.php | 4 +- .../Thelia/Tests/Type/EnumListTypeTest.php | 4 +- core/lib/Thelia/Tests/Type/EnumTypeTest.php | 4 +- core/lib/Thelia/Tests/Type/FloatTypeTest.php | 4 +- .../lib/Thelia/Tests/Type/IntListTypeTest.php | 4 +- core/lib/Thelia/Tests/Type/IntTypeTest.php | 4 +- core/lib/Thelia/Tests/Type/JsonTypeTest.php | 4 +- .../Thelia/Tests/Type/TypeCollectionTest.php | 4 +- core/lib/Thelia/Tools/DIGenerator.php | 4 +- core/lib/Thelia/Tools/Redirect.php | 16 ++-- .../Thelia/Type/AlphaNumStringListType.php | 4 +- core/lib/Thelia/Type/AlphaNumStringType.php | 4 +- core/lib/Thelia/Type/AnyType.php | 4 +- core/lib/Thelia/Type/BooleanType.php | 4 +- core/lib/Thelia/Type/EnumListType.php | 4 +- core/lib/Thelia/Type/EnumType.php | 4 +- core/lib/Thelia/Type/FloatType.php | 4 +- core/lib/Thelia/Type/IntListType.php | 4 +- core/lib/Thelia/Type/IntType.php | 4 +- core/lib/Thelia/Type/JsonType.php | 4 +- core/lib/Thelia/Type/TypeCollection.php | 4 +- core/lib/Thelia/Type/TypeInterface.php | 4 +- templates/admin/default/home.html | 2 +- templates/admin/default/login.html | 2 +- templates/smarty-sample/includes/header.html | 2 +- templates/smarty-sample/index.html | 2 +- web/index_dev.php | 2 +- 92 files changed, 332 insertions(+), 222 deletions(-) diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 5d85f774f..c06ade935 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 09c3246fd..0d95b54be 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -32,9 +32,33 @@ use Thelia\Form\CustomerModification; use Thelia\Model\Customer as CustomerModel; use Thelia\Log\Tlog; use Thelia\Model\CustomerQuery; +use Thelia\Form\CustomerLogin; +use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator; +use Thelia\Core\Security\SecurityContext; +use Thelia\Model\ConfigQuery; +use Thelia\Tools\Redirect; +use Symfony\Component\Validator\Exception\ValidatorException; +use Thelia\Core\Security\Exception\AuthenticationException; class Customer implements EventSubscriberInterface { + /** + * @var Thelia\Core\Security\SecurityContext + */ + private $securityContext; + + public function __construct(SecurityContext $context) { + $this->securityContext = $context; + + $context->setContext(SecurityContext::CONTEXT_FRONT_OFFICE); + } + + + private function getSecurityContext($context) { + $this->securityContext->setContext($context === false ? SecurityContext::CONTEXT_FRONT_OFFICE : $context); + + return $securityContext; + } public function create(ActionEvent $event) { @@ -48,6 +72,7 @@ class Customer implements EventSubscriberInterface $form = $customerCreation->getForm(); if ($request->isMethod("post")) { + $form->bind($request); if ($form->isValid()) { @@ -76,7 +101,8 @@ class Customer implements EventSubscriberInterface //Customer is create, he is automatically connected - } else { + } + else { $event->setFormError($customerCreation); } @@ -125,7 +151,56 @@ class Customer implements EventSubscriberInterface } - public function modifyPassword(ActionEvent $event) + /** + * Perform user login. On a successful login, the user is redirected to the URL + * found in the success_url form parameter, or / if none was found. + * + * If login is not successfull, the same view is dispolyed again. + * + * @param ActionEvent $event + */ + public function login(ActionEvent $event) + { + $request = $event->getRequest(); + + $form = new CustomerLogin($request); + + $authenticator = new CustomerUsernamePasswordFormAuthenticator($request, $form); + + try { + $user = $authenticator->getAuthentifiedUser(); + + // Success -> store user in security context + $this->getSecurityContext()->setUser($user); + + // Log authentication success + AdminLog::append("Authentication successufull", $request, $user); + + // Get the success URL to redirect the user to + $successUrl = $form->getForm()->get('success_url')->getData(); + + if (null == $successUrl) $successUrl = ConfigQuery::read('base_url', '/'); + + // Redirect to the success URL + return Redirect::exec(URL::absoluteUrl($successUrl)); + } + catch (ValidatorException $ex) { + $message = "Missing or invalid information. Please check your input."; + } + catch (AuthenticationException $ex) { + $message = "Login failed. Please check your username and password."; + } + catch (\Exception $ex) { + $message = sprintf("Unable to process your request. Please try again (%s).", $ex->getMessage()); + } + + // Store the form name in session (see Form Smarty plugin to find usage of this parameter) + $request->getSession()->setErrorFormName($form->getName()); + + // A this point, the same view is displayed again. + } + + public function changePassword(ActionEvent $event) { } @@ -154,7 +229,8 @@ class Customer implements EventSubscriberInterface { return array( "action.createCustomer" => array("create", 128), - "action.modifyCustomer" => array("modify", 128) + "action.modifyCustomer" => array("modify", 128), + "action.loginCustomer" => array("login", 128) ); } diff --git a/core/lib/Thelia/Admin/Controller/AdminController.php b/core/lib/Thelia/Admin/Controller/AdminController.php index 1b5212cd2..57421825e 100755 --- a/core/lib/Thelia/Admin/Controller/AdminController.php +++ b/core/lib/Thelia/Admin/Controller/AdminController.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ diff --git a/core/lib/Thelia/Admin/Controller/BaseAdminController.php b/core/lib/Thelia/Admin/Controller/BaseAdminController.php index 15a9753f3..773f9cccc 100755 --- a/core/lib/Thelia/Admin/Controller/BaseAdminController.php +++ b/core/lib/Thelia/Admin/Controller/BaseAdminController.php @@ -35,6 +35,7 @@ use Thelia\Model\ConfigQuery; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\SecurityContext; use Thelia\Tools\URL; +use Thelia\Tools\Redirect; /** * @@ -94,7 +95,7 @@ class BaseAdminController extends ContainerAware // User is not authenticated, and templates requires authentication -> redirect to login page // (see Thelia\Core\Template\Smarty\Plugins\Security) - return new RedirectResponse(URL::absoluteUrl('admin/login')); // FIXME shoud be a parameter + Redirect::exec(URL::absoluteUrl('admin/login')); // FIXME shoud be a parameter } } @@ -172,17 +173,4 @@ class BaseAdminController extends ContainerAware return $this->container->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); } - - /** - * Returns a RedirectResponse to the given URL. - * - * @param string $url The URL to redirect to - * @param integer $status The status code to use for the Response - * - * @return RedirectResponse - */ - protected function redirect($url, $status = 302) - { - return new RedirectResponse($url, $status); - } } \ No newline at end of file diff --git a/core/lib/Thelia/Admin/Controller/SessionController.php b/core/lib/Thelia/Admin/Controller/SessionController.php index 457b6798e..d2febe089 100755 --- a/core/lib/Thelia/Admin/Controller/SessionController.php +++ b/core/lib/Thelia/Admin/Controller/SessionController.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -25,15 +25,12 @@ namespace Thelia\Admin\Controller; use Symfony\Component\HttpFoundation\Response; use Thelia\Form\AdminLogin; -use Thelia\Core\Security\Token\UsernamePasswordToken; -use Thelia\Core\Security\Authentication\UsernamePasswordAuthenticator; -use Thelia\Core\Security\Encoder\PasswordPhpCompatEncoder; -use Thelia\Core\Security\Token\TokenInterface; use Thelia\Core\Security\Authentication\AdminUsernamePasswordFormAuthenticator; use Thelia\Model\AdminLog; use Thelia\Core\Security\Exception\AuthenticationException; use Symfony\Component\Validator\Exception\ValidatorException; use Thelia\Tools\URL; +use Thelia\Tools\Redirect; class SessionController extends BaseAdminController { @@ -47,7 +44,7 @@ class SessionController extends BaseAdminController { $this->getSecurityContext()->clear(); // Go back to login page. - return $this->redirect(URL::absoluteUrl('admin/login')); + return Redirect::exec(URL::absoluteUrl('admin/login')); } public function checkLoginAction() @@ -72,11 +69,12 @@ class SessionController extends BaseAdminController { if (null == $successUrl) $successUrl = 'admin/home'; - // Redirect to home page - FIXME: requested URL, if we come from another page ? - return $this->redirect(URL::absoluteUrl($successUrl)); + // Redirect to the success URL + return Redirect::exec(URL::absoluteUrl($successUrl)); } catch (ValidatorException $ex) { + // Validation problem $message = "Missing or invalid information. Please check your input."; } catch (AuthenticationException $ex) { @@ -86,19 +84,20 @@ class SessionController extends BaseAdminController { $message = "Login failed. Please check your username and password."; } + catch (\Exception $ex) { - // Store the form in session (see Form Smlarty plugin to find usage of this parameter) + // Log authentication failure + AdminLog::append(sprintf("Undefined error: %s", $ex->getMessage()), $request); + + $message = "Unable to process your request. Please try again."; + } + + // Store the form name in session (see Form Smarty plugin to find usage of this parameter) $request->getSession()->setErrorFormName($form->getName()); - if (empty($failureUrl)) { - // Display the login form again, with an error message if required - return $this->render("login.html", array( - "message" => $message - )); - } - else { - // Redirect to the provided URL - return $this->redirect(URL::absoluteUrl($failureUrl)); - } + // Display the login form again, with an error message if required + return $this->render("login.html", array( + "message" => $message + )); } } \ No newline at end of file diff --git a/core/lib/Thelia/Command/CacheClear.php b/core/lib/Thelia/Command/CacheClear.php index eba228da8..485f479ce 100755 --- a/core/lib/Thelia/Command/CacheClear.php +++ b/core/lib/Thelia/Command/CacheClear.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Command/ContainerAwareCommand.php b/core/lib/Thelia/Command/ContainerAwareCommand.php index abd8f9960..2dc455edb 100755 --- a/core/lib/Thelia/Command/ContainerAwareCommand.php +++ b/core/lib/Thelia/Command/ContainerAwareCommand.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Command/Install.php b/core/lib/Thelia/Command/Install.php index 53a573375..48903c2a0 100755 --- a/core/lib/Thelia/Command/Install.php +++ b/core/lib/Thelia/Command/Install.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Command/ModuleGenerateModelCommand.php b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php index 348765ced..a42cb9065 100644 --- a/core/lib/Thelia/Command/ModuleGenerateModelCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateModelCommand.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php b/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php index 977075902..95ee7a931 100644 --- a/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateSqlCommand.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php b/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php index aa0a8a1e7..667a18087 100644 --- a/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php +++ b/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Command/Skeleton/Module/Class.php b/core/lib/Thelia/Command/Skeleton/Module/Class.php index ccf061a48..ecf67646d 100644 --- a/core/lib/Thelia/Command/Skeleton/Module/Class.php +++ b/core/lib/Thelia/Command/Skeleton/Module/Class.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Config/DatabaseConfiguration.php b/core/lib/Thelia/Config/DatabaseConfiguration.php index 376c16609..16d273738 100755 --- a/core/lib/Thelia/Config/DatabaseConfiguration.php +++ b/core/lib/Thelia/Config/DatabaseConfiguration.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Config/DefinePropel.php b/core/lib/Thelia/Config/DefinePropel.php index 06d33ebfc..434187144 100755 --- a/core/lib/Thelia/Config/DefinePropel.php +++ b/core/lib/Thelia/Config/DefinePropel.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 5d4436891..1fd380425 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -11,15 +11,16 @@ Thelia\Core\Event\CartEvent - + - - + + + diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index b91428f6c..4315d2844 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -11,19 +11,6 @@ - - - - - - - - - diff --git a/core/lib/Thelia/Controller/DefaultController.php b/core/lib/Thelia/Controller/DefaultController.php index 2c8a4ca62..646d3b27a 100755 --- a/core/lib/Thelia/Controller/DefaultController.php +++ b/core/lib/Thelia/Controller/DefaultController.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Controller; diff --git a/core/lib/Thelia/Core/Application.php b/core/lib/Thelia/Core/Application.php index b6b07614c..531d8802c 100755 --- a/core/lib/Thelia/Core/Application.php +++ b/core/lib/Thelia/Core/Application.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterListenersPass.php b/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterListenersPass.php index 786093e15..9f7e9f31f 100755 --- a/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterListenersPass.php +++ b/core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterListenersPass.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php index 8de39f095..a95e7d668 100755 --- a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php +++ b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/Event/ActionEvent.php b/core/lib/Thelia/Core/Event/ActionEvent.php index fc5822a93..486b80ee8 100755 --- a/core/lib/Thelia/Core/Event/ActionEvent.php +++ b/core/lib/Thelia/Core/Event/ActionEvent.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ @@ -26,6 +26,7 @@ namespace Thelia\Core\Event; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\HttpFoundation\Request; use Thelia\Form\BaseForm; +use Thelia\Core\Security\SecurityContext; /** * * Class thrown on Thelia.action event @@ -107,5 +108,4 @@ abstract class ActionEvent extends Event { return $this->form !== null; } - } diff --git a/core/lib/Thelia/Core/Event/CustomRefEvent.php b/core/lib/Thelia/Core/Event/CustomRefEvent.php index 15113c218..000f46153 100755 --- a/core/lib/Thelia/Core/Event/CustomRefEvent.php +++ b/core/lib/Thelia/Core/Event/CustomRefEvent.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Core\Event; diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index aca4e106a..46dd89ee6 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/EventListener/ControllerListener.php b/core/lib/Thelia/Core/EventListener/ControllerListener.php index 96d249e69..3ae9c77bb 100755 --- a/core/lib/Thelia/Core/EventListener/ControllerListener.php +++ b/core/lib/Thelia/Core/EventListener/ControllerListener.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Core\EventListener; @@ -29,7 +29,7 @@ use Thelia\Core\Factory\ActionEventFactory; /** * - * Action are dispatch here. + * Action are dispatched here. * * A factory is used for creating appropriate action object * @@ -43,6 +43,7 @@ class ControllerListener implements EventSubscriberInterface { $dispatcher = $event->getDispatcher(); $request = $event->getRequest(); + if (false !== $action = $request->get("action")) { //search corresponding action $event = new ActionEventFactory($request, $action, $event->getKernel()->getContainer()->getParameter("thelia.actionEvent")); @@ -53,7 +54,6 @@ class ControllerListener implements EventSubscriberInterface $request->getSession()->setErrorFormName($actionEvent->getFormError()->getName()); } } - } public static function getSubscribedEvents() diff --git a/core/lib/Thelia/Core/EventListener/ViewListener.php b/core/lib/Thelia/Core/EventListener/ViewListener.php index 50acd044d..a67d7f0e2 100755 --- a/core/lib/Thelia/Core/EventListener/ViewListener.php +++ b/core/lib/Thelia/Core/EventListener/ViewListener.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Core\EventListener; @@ -30,6 +30,9 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Thelia\Core\Template\Exception\ResourceNotFoundException; use Thelia\Core\Template\ParserInterface; +use Thelia\Tools\Redirect; +use Thelia\Tools\URL; +use Thelia\Core\Security\Exception\AuthenticationException; /** * @@ -78,10 +81,17 @@ class ViewListener implements EventSubscriberInterface } else { $event->setResponse(new Response($content, $parser->getStatus() ?: 200)); } - } catch (ResourceNotFoundException $e) { + } + catch (ResourceNotFoundException $e) { $event->setResponse(new Response($e->getMessage(), 404)); } + catch (AuthenticationException $ex) { + // Redirect to the login template + $event->setResponse(Redirect::exec(URL::viewUrl($ex->getLoginTemplate()))); + } + + throw new \Exception("toto !"); } public function beforeKernelView(GetResponseForControllerResultEvent $event) diff --git a/core/lib/Thelia/Core/Factory/ActionEventFactory.php b/core/lib/Thelia/Core/Factory/ActionEventFactory.php index 7cda0a083..af41edecd 100755 --- a/core/lib/Thelia/Core/Factory/ActionEventFactory.php +++ b/core/lib/Thelia/Core/Factory/ActionEventFactory.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php index 564c4b1c6..bf47310b2 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ @@ -26,9 +26,11 @@ namespace Thelia\Core\HttpFoundation\Session; use Symfony\Component\HttpFoundation\Session\Session as BaseSession; use Thelia\Core\Security\User\UserInterface; use Thelia\Form\BaseForm; +use Thelia\Model\ConfigQuery; class Session extends BaseSession { + // -- Language ------------------------------------------------------------ public function getLocale() { @@ -40,6 +42,8 @@ class Session extends BaseSession { return substr($this->getLocale(), 0, 2); } + // -- Customer user -------------------------------------------------------- + public function setCustomerUser(UserInterface $user) { $this->set('customer_user', $user); @@ -55,6 +59,7 @@ class Session extends BaseSession { return $this->remove('customer_user'); } + // -- Admin user ----------------------------------------------------------- public function setAdminUser(UserInterface $user) { @@ -71,6 +76,8 @@ class Session extends BaseSession { return $this->remove('admin_user'); } + // -- Error form ----------------------------------------------------------- + /** * @param string $formName the form name */ @@ -88,4 +95,21 @@ class Session extends BaseSession { { return $this->remove('error_form'); } + + // -- Return page ---------------------------------------------------------- + + public function setReturnToUrl($url) + { + $this->set('return_to_url', $url); + } + + /** + * + * @return the return-to URL, or the index page if none is defined. + */ + public function getReturnToUrl() + { + return $this->get('return_to_url', ConfigQuery::read('base_url')); + } + } diff --git a/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php index 8f3836119..1097edf5a 100644 --- a/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php +++ b/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php @@ -27,6 +27,7 @@ namespace Thelia\Core\Security\Authentication; use Symfony\Component\HttpFoundation\Request; use Thelia\Core\Security\Authentication\UsernamePasswordFormAuthenticator; use Thelia\Form\CustomerLogin; +use Thelia\Core\Security\UserProvider\CustomerUserProvider; class CustomerUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuthenticator { diff --git a/core/lib/Thelia/Core/Security/Exception/AuthenticationException.php b/core/lib/Thelia/Core/Security/Exception/AuthenticationException.php index 2e3e496a3..ad0e01a3b 100644 --- a/core/lib/Thelia/Core/Security/Exception/AuthenticationException.php +++ b/core/lib/Thelia/Core/Security/Exception/AuthenticationException.php @@ -25,4 +25,24 @@ namespace Thelia\Core\Security\Exception; class AuthenticationException extends \Exception { + /** + * @var string The login template name + */ + protected $loginTemplate = "login"; + + /** + * @return string the login template name + */ + public function getLoginTemplate() { + return $this->loginTemplate; + } + + /** + * Set the login template name + * + * @param string $loginPath the login template name + */ + public function setLoginTemplate($loginTemplate) { + $this->loginTemplate = $loginTemplate; + } } diff --git a/core/lib/Thelia/Core/Security/Role/Role.php b/core/lib/Thelia/Core/Security/Role/Role.php index c363d1c4c..8776f9752 100755 --- a/core/lib/Thelia/Core/Security/Role/Role.php +++ b/core/lib/Thelia/Core/Security/Role/Role.php @@ -38,4 +38,8 @@ class Role implements RoleInterface { return $this->role; } + + public function __toString() { + return $this->role; + } } diff --git a/core/lib/Thelia/Core/Template/BaseParam/Secure.php b/core/lib/Thelia/Core/Template/BaseParam/Secure.php index 43713b150..ecc36299e 100755 --- a/core/lib/Thelia/Core/Template/BaseParam/Secure.php +++ b/core/lib/Thelia/Core/Template/BaseParam/Secure.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 59747eec1..80e0a85f6 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/Template/Element/Exception/ElementNotFoundException.php b/core/lib/Thelia/Core/Template/Element/Exception/ElementNotFoundException.php index a2695ce6b..0f9972e97 100755 --- a/core/lib/Thelia/Core/Template/Element/Exception/ElementNotFoundException.php +++ b/core/lib/Thelia/Core/Template/Element/Exception/ElementNotFoundException.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/Template/Element/Exception/InvalidElementException.php b/core/lib/Thelia/Core/Template/Element/Exception/InvalidElementException.php index 5a4983aa2..b77f76a09 100755 --- a/core/lib/Thelia/Core/Template/Element/Exception/InvalidElementException.php +++ b/core/lib/Thelia/Core/Template/Element/Exception/InvalidElementException.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/Template/Element/LoopResult.php b/core/lib/Thelia/Core/Template/Element/LoopResult.php index f01c74210..c3a97983f 100755 --- a/core/lib/Thelia/Core/Template/Element/LoopResult.php +++ b/core/lib/Thelia/Core/Template/Element/LoopResult.php @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/Template/Element/LoopResultRow.php b/core/lib/Thelia/Core/Template/Element/LoopResultRow.php index 3ac05fe5c..24fa67c7e 100755 --- a/core/lib/Thelia/Core/Template/Element/LoopResultRow.php +++ b/core/lib/Thelia/Core/Template/Element/LoopResultRow.php @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/Template/Exception/ResourceNotFoundException.php b/core/lib/Thelia/Core/Template/Exception/ResourceNotFoundException.php index 87b41ebc5..37856c620 100755 --- a/core/lib/Thelia/Core/Template/Exception/ResourceNotFoundException.php +++ b/core/lib/Thelia/Core/Template/Exception/ResourceNotFoundException.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Core\Template\Exception; diff --git a/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php b/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php index 5b8b99f03..265fdbdf2 100755 --- a/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php +++ b/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Core\Template\Loop\Argument; diff --git a/core/lib/Thelia/Core/Template/Loop/Argument/ArgumentCollection.php b/core/lib/Thelia/Core/Template/Loop/Argument/ArgumentCollection.php index b4b680e08..e4fca8549 100755 --- a/core/lib/Thelia/Core/Template/Loop/Argument/ArgumentCollection.php +++ b/core/lib/Thelia/Core/Template/Loop/Argument/ArgumentCollection.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Core\Template\Loop\Argument; diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 96809f5dc..4c915ae1f 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 001c5c750..c90111c8f 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/Template/ParserInterface.php b/core/lib/Thelia/Core/Template/ParserInterface.php index 08308659c..bbf926812 100755 --- a/core/lib/Thelia/Core/Template/ParserInterface.php +++ b/core/lib/Thelia/Core/Template/ParserInterface.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Core\Template; diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index b023a4eab..526024707 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Core/TheliaContainerBuilder.php b/core/lib/Thelia/Core/TheliaContainerBuilder.php index fb765ebb2..a97019b60 100755 --- a/core/lib/Thelia/Core/TheliaContainerBuilder.php +++ b/core/lib/Thelia/Core/TheliaContainerBuilder.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Exception/MemberAccessException.php b/core/lib/Thelia/Exception/MemberAccessException.php index 9ceea565e..e1f65e590 100755 --- a/core/lib/Thelia/Exception/MemberAccessException.php +++ b/core/lib/Thelia/Exception/MemberAccessException.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Exception; diff --git a/core/lib/Thelia/Form/AdminLogin.php b/core/lib/Thelia/Form/AdminLogin.php index b67e788fc..6a96d4c78 100755 --- a/core/lib/Thelia/Form/AdminLogin.php +++ b/core/lib/Thelia/Form/AdminLogin.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index 9f675e74e..df2fb1c2c 100755 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ diff --git a/core/lib/Thelia/Form/CustomerLogin.php b/core/lib/Thelia/Form/CustomerLogin.php index e1096f9b4..64937cbf6 100644 --- a/core/lib/Thelia/Form/CustomerLogin.php +++ b/core/lib/Thelia/Form/CustomerLogin.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -27,16 +27,17 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Choice; +use Symfony\Component\Validator\Constraints\Email; class CustomerLogin extends BaseForm { protected function buildForm() { $this->formBuilder - ->add("username", "text", array( + ->add("email", "text", array( "constraints" => array( new NotBlank(), - new Length(array("min" => 3)) + new Email() ) )) ->add("password", "password", array( @@ -45,7 +46,8 @@ class CustomerLogin extends BaseForm { ) )) ->add("remember_me", "checkbox") - ; + ->add("success_url", "text") + ; } public function getName() diff --git a/core/lib/Thelia/Log/AbstractTlogDestination.php b/core/lib/Thelia/Log/AbstractTlogDestination.php index 4b859df20..5241bcdd8 100755 --- a/core/lib/Thelia/Log/AbstractTlogDestination.php +++ b/core/lib/Thelia/Log/AbstractTlogDestination.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationFile.php b/core/lib/Thelia/Log/Destination/TlogDestinationFile.php index d7fa4f5c2..2f9a0e5bc 100755 --- a/core/lib/Thelia/Log/Destination/TlogDestinationFile.php +++ b/core/lib/Thelia/Log/Destination/TlogDestinationFile.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationHtml.php b/core/lib/Thelia/Log/Destination/TlogDestinationHtml.php index d0896cd26..a510e18ef 100755 --- a/core/lib/Thelia/Log/Destination/TlogDestinationHtml.php +++ b/core/lib/Thelia/Log/Destination/TlogDestinationHtml.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationNull.php b/core/lib/Thelia/Log/Destination/TlogDestinationNull.php index b5bd3dcbb..1fa8eaf3a 100755 --- a/core/lib/Thelia/Log/Destination/TlogDestinationNull.php +++ b/core/lib/Thelia/Log/Destination/TlogDestinationNull.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationText.php b/core/lib/Thelia/Log/Destination/TlogDestinationText.php index 379794ce4..b03f03f65 100755 --- a/core/lib/Thelia/Log/Destination/TlogDestinationText.php +++ b/core/lib/Thelia/Log/Destination/TlogDestinationText.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Log/Tlog.php b/core/lib/Thelia/Log/Tlog.php index 76b813944..907c0d8e7 100755 --- a/core/lib/Thelia/Log/Tlog.php +++ b/core/lib/Thelia/Log/Tlog.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Log; diff --git a/core/lib/Thelia/Log/TlogDestinationConfig.php b/core/lib/Thelia/Log/TlogDestinationConfig.php index b945b9dfd..1f60ba08e 100755 --- a/core/lib/Thelia/Log/TlogDestinationConfig.php +++ b/core/lib/Thelia/Log/TlogDestinationConfig.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Routing/Matcher/DefaultMatcher.php b/core/lib/Thelia/Routing/Matcher/DefaultMatcher.php index b0ce6b841..6042a7cad 100755 --- a/core/lib/Thelia/Routing/Matcher/DefaultMatcher.php +++ b/core/lib/Thelia/Routing/Matcher/DefaultMatcher.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Routing\Matcher; diff --git a/core/lib/Thelia/Routing/NullUrlGenerator.php b/core/lib/Thelia/Routing/NullUrlGenerator.php index 0206a7f2e..f43f4ee5a 100755 --- a/core/lib/Thelia/Routing/NullUrlGenerator.php +++ b/core/lib/Thelia/Routing/NullUrlGenerator.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Routing/TheliaMatcherCollection.php b/core/lib/Thelia/Routing/TheliaMatcherCollection.php index bf1c8e2f2..b6769c148 100755 --- a/core/lib/Thelia/Routing/TheliaMatcherCollection.php +++ b/core/lib/Thelia/Routing/TheliaMatcherCollection.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Routing; diff --git a/core/lib/Thelia/Tests/Command/CacheClearTest.php b/core/lib/Thelia/Tests/Command/CacheClearTest.php index 019414b02..f29d600ed 100755 --- a/core/lib/Thelia/Tests/Command/CacheClearTest.php +++ b/core/lib/Thelia/Tests/Command/CacheClearTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Tests\Command; diff --git a/core/lib/Thelia/Tests/Controller/DefaultControllerTest.php b/core/lib/Thelia/Tests/Controller/DefaultControllerTest.php index 84bc6c1a7..27255c089 100755 --- a/core/lib/Thelia/Tests/Controller/DefaultControllerTest.php +++ b/core/lib/Thelia/Tests/Controller/DefaultControllerTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/Argument/ArgumentCollectionTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/Argument/ArgumentCollectionTest.php index 21d1f132b..e8dc69d99 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/Argument/ArgumentCollectionTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/Argument/ArgumentCollectionTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tests/Log/TlogTest.php b/core/lib/Thelia/Tests/Log/TlogTest.php index eabc18338..f94b759be 100755 --- a/core/lib/Thelia/Tests/Log/TlogTest.php +++ b/core/lib/Thelia/Tests/Log/TlogTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tests/Type/AlphaNumStringListTypeTest.php b/core/lib/Thelia/Tests/Type/AlphaNumStringListTypeTest.php index 2a8ba5fa0..2a4409860 100755 --- a/core/lib/Thelia/Tests/Type/AlphaNumStringListTypeTest.php +++ b/core/lib/Thelia/Tests/Type/AlphaNumStringListTypeTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tests/Type/AlphaNumStringTypeTest.php b/core/lib/Thelia/Tests/Type/AlphaNumStringTypeTest.php index 46526715b..ae07cce6b 100755 --- a/core/lib/Thelia/Tests/Type/AlphaNumStringTypeTest.php +++ b/core/lib/Thelia/Tests/Type/AlphaNumStringTypeTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tests/Type/AnyTypeTest.php b/core/lib/Thelia/Tests/Type/AnyTypeTest.php index 8e959d154..e4750000e 100755 --- a/core/lib/Thelia/Tests/Type/AnyTypeTest.php +++ b/core/lib/Thelia/Tests/Type/AnyTypeTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tests/Type/BooleanTypeTest.php b/core/lib/Thelia/Tests/Type/BooleanTypeTest.php index d91cc6bc9..03765d541 100755 --- a/core/lib/Thelia/Tests/Type/BooleanTypeTest.php +++ b/core/lib/Thelia/Tests/Type/BooleanTypeTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tests/Type/EnumListTypeTest.php b/core/lib/Thelia/Tests/Type/EnumListTypeTest.php index a992fb0bd..a225464c1 100755 --- a/core/lib/Thelia/Tests/Type/EnumListTypeTest.php +++ b/core/lib/Thelia/Tests/Type/EnumListTypeTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tests/Type/EnumTypeTest.php b/core/lib/Thelia/Tests/Type/EnumTypeTest.php index 5ed4637e9..10660ee38 100755 --- a/core/lib/Thelia/Tests/Type/EnumTypeTest.php +++ b/core/lib/Thelia/Tests/Type/EnumTypeTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tests/Type/FloatTypeTest.php b/core/lib/Thelia/Tests/Type/FloatTypeTest.php index 82bf9bfe2..600c696f8 100755 --- a/core/lib/Thelia/Tests/Type/FloatTypeTest.php +++ b/core/lib/Thelia/Tests/Type/FloatTypeTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tests/Type/IntListTypeTest.php b/core/lib/Thelia/Tests/Type/IntListTypeTest.php index 80ffa3e2e..a10d124e4 100755 --- a/core/lib/Thelia/Tests/Type/IntListTypeTest.php +++ b/core/lib/Thelia/Tests/Type/IntListTypeTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tests/Type/IntTypeTest.php b/core/lib/Thelia/Tests/Type/IntTypeTest.php index 2f9ce8a40..7d39093dc 100755 --- a/core/lib/Thelia/Tests/Type/IntTypeTest.php +++ b/core/lib/Thelia/Tests/Type/IntTypeTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tests/Type/JsonTypeTest.php b/core/lib/Thelia/Tests/Type/JsonTypeTest.php index 79b2c59b8..1f4b0162b 100755 --- a/core/lib/Thelia/Tests/Type/JsonTypeTest.php +++ b/core/lib/Thelia/Tests/Type/JsonTypeTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tests/Type/TypeCollectionTest.php b/core/lib/Thelia/Tests/Type/TypeCollectionTest.php index 5cef59215..0aaec01df 100755 --- a/core/lib/Thelia/Tests/Type/TypeCollectionTest.php +++ b/core/lib/Thelia/Tests/Type/TypeCollectionTest.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ diff --git a/core/lib/Thelia/Tools/DIGenerator.php b/core/lib/Thelia/Tools/DIGenerator.php index a17586a55..f18338d5b 100755 --- a/core/lib/Thelia/Tools/DIGenerator.php +++ b/core/lib/Thelia/Tools/DIGenerator.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Tools; diff --git a/core/lib/Thelia/Tools/Redirect.php b/core/lib/Thelia/Tools/Redirect.php index b4c89fcce..92ae28fa9 100755 --- a/core/lib/Thelia/Tools/Redirect.php +++ b/core/lib/Thelia/Tools/Redirect.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,28 +17,26 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Tools; -use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\RedirectResponse; class Redirect { - + public static function unauthorize($url) { self::exec($url, 401); } - + public static function exec($url, $status = 302) { - $response = new Response('', $status, array( - "location" => $url - )); - + $response = new RedirectResponse($url, $status); + $response->send(); exit; } diff --git a/core/lib/Thelia/Type/AlphaNumStringListType.php b/core/lib/Thelia/Type/AlphaNumStringListType.php index 41af21e07..4f24eb274 100755 --- a/core/lib/Thelia/Type/AlphaNumStringListType.php +++ b/core/lib/Thelia/Type/AlphaNumStringListType.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Type; diff --git a/core/lib/Thelia/Type/AlphaNumStringType.php b/core/lib/Thelia/Type/AlphaNumStringType.php index 963237cb0..726e6eb67 100755 --- a/core/lib/Thelia/Type/AlphaNumStringType.php +++ b/core/lib/Thelia/Type/AlphaNumStringType.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Type; diff --git a/core/lib/Thelia/Type/AnyType.php b/core/lib/Thelia/Type/AnyType.php index ca0a14616..5cdbb1272 100755 --- a/core/lib/Thelia/Type/AnyType.php +++ b/core/lib/Thelia/Type/AnyType.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Type; diff --git a/core/lib/Thelia/Type/BooleanType.php b/core/lib/Thelia/Type/BooleanType.php index 0c85d3ba8..ecbf6cfe3 100755 --- a/core/lib/Thelia/Type/BooleanType.php +++ b/core/lib/Thelia/Type/BooleanType.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Type; diff --git a/core/lib/Thelia/Type/EnumListType.php b/core/lib/Thelia/Type/EnumListType.php index 1603dc89f..55b78fe5c 100755 --- a/core/lib/Thelia/Type/EnumListType.php +++ b/core/lib/Thelia/Type/EnumListType.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Type; diff --git a/core/lib/Thelia/Type/EnumType.php b/core/lib/Thelia/Type/EnumType.php index 0221f8b8e..416f9714a 100755 --- a/core/lib/Thelia/Type/EnumType.php +++ b/core/lib/Thelia/Type/EnumType.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Type; diff --git a/core/lib/Thelia/Type/FloatType.php b/core/lib/Thelia/Type/FloatType.php index 3c10df86c..f82f34b58 100755 --- a/core/lib/Thelia/Type/FloatType.php +++ b/core/lib/Thelia/Type/FloatType.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Type; diff --git a/core/lib/Thelia/Type/IntListType.php b/core/lib/Thelia/Type/IntListType.php index cd4eadf22..d07e5e18f 100755 --- a/core/lib/Thelia/Type/IntListType.php +++ b/core/lib/Thelia/Type/IntListType.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Type; diff --git a/core/lib/Thelia/Type/IntType.php b/core/lib/Thelia/Type/IntType.php index c2d6dcfa8..8e2ec4fd8 100755 --- a/core/lib/Thelia/Type/IntType.php +++ b/core/lib/Thelia/Type/IntType.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Type; diff --git a/core/lib/Thelia/Type/JsonType.php b/core/lib/Thelia/Type/JsonType.php index 39ee57d53..5a195b291 100755 --- a/core/lib/Thelia/Type/JsonType.php +++ b/core/lib/Thelia/Type/JsonType.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Type; diff --git a/core/lib/Thelia/Type/TypeCollection.php b/core/lib/Thelia/Type/TypeCollection.php index 460d9b96e..64e6c8c28 100755 --- a/core/lib/Thelia/Type/TypeCollection.php +++ b/core/lib/Thelia/Type/TypeCollection.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Type; diff --git a/core/lib/Thelia/Type/TypeInterface.php b/core/lib/Thelia/Type/TypeInterface.php index b2ba11a4b..b293b1783 100755 --- a/core/lib/Thelia/Type/TypeInterface.php +++ b/core/lib/Thelia/Type/TypeInterface.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ namespace Thelia\Type; diff --git a/templates/admin/default/home.html b/templates/admin/default/home.html index f49172464..79266eadb 100755 --- a/templates/admin/default/home.html +++ b/templates/admin/default/home.html @@ -1,4 +1,4 @@ -{check_auth context="admin" roles="ADMIN" login_url="login"} +{check_auth context="admin" roles="ROLE_ADMIN" login_url="login"} {$page_title={intl l='Home'}} {include file='includes/header.inc.html'} diff --git a/templates/admin/default/login.html b/templates/admin/default/login.html index b674a1dc5..1f8146993 100755 --- a/templates/admin/default/login.html +++ b/templates/admin/default/login.html @@ -21,7 +21,7 @@ {form_hidden_fields form=$form} {form_field form=$form field='success_url'} - {* redirect to /admin *} + {* on success, redirect to /admin *} {/form_field} {form_field form=$form field='username'} diff --git a/templates/smarty-sample/includes/header.html b/templates/smarty-sample/includes/header.html index 7dbd94ecc..b48cbc770 100755 --- a/templates/smarty-sample/includes/header.html +++ b/templates/smarty-sample/includes/header.html @@ -1,7 +1,7 @@ - {intl l="Hi, I'm a Thelia TPex template"} + {$page_title|default:{intl l="Thelia II"}} {stylesheets file='../assets/css/*' filters='less,cssembed'} diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html index 53834febf..6ee109b9e 100755 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -1,7 +1,7 @@ {include file="includes/header.html"}
-{loop type="auth" name="auth_test" context="front" roles="CUSTOMER"} +{loop type="auth" name="auth_test" context="front" roles="ROLE_CUSTOMER"}

Customer is authentified :-)

{/loop} diff --git a/web/index_dev.php b/web/index_dev.php index 5e5bc0e96..1251c012f 100755 --- a/web/index_dev.php +++ b/web/index_dev.php @@ -24,4 +24,4 @@ $response = $thelia->handle($request)->prepare($request)->send(); $thelia->terminate($request, $response); -echo ""; \ No newline at end of file +echo "\n"; \ No newline at end of file From 4842d0c0063010fec69787617457e0c87fe3fa3a Mon Sep 17 00:00:00 2001 From: franck Date: Wed, 17 Jul 2013 15:26:51 +0200 Subject: [PATCH 30/36] Added the success_url parameter to BaseForm, so that all forms will hace this parameter. --- core/lib/Thelia/Form/BaseForm.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Form/BaseForm.php b/core/lib/Thelia/Form/BaseForm.php index a3220fa8b..40753b256 100755 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -70,9 +70,35 @@ abstract class BaseForm { $this->buildForm(); + // If not already set, define the success_url field + if (! $this->formBuilder->has('success_url')) { + $this->formBuilder->add("success_url", "text") + } + $this->form = $this->formBuilder->getForm(); } + /** + * Returns the absolute URL to redirect the user to if the form is successfully processed. + * + * @param string $default the default URL. If not given, the configured base URL is used. + * + * @return string an absolute URL + */ + public function getSuccessUrl($default = null) { + + $successUrl = $this->form->get('success_url')->getData(); + + if (empty($successUrl)) { + + if ($default === null) $default = ConfigQuery::read('base_url', '/'); + + $successUrl = $default; + } + + return URL::absoluteUrl($successUrl); + } + public function createView() { $this->view = $this->form->createView(); } @@ -96,7 +122,7 @@ abstract class 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->form->add("name", "text") + * $this->formBuilder->add("name", "text") * ->add("email", "email", array( * "attr" => array( * "class" => "field" From 8296051937a9f3219bb0017acd17d3654cb8c876 Mon Sep 17 00:00:00 2001 From: franck Date: Wed, 17 Jul 2013 18:49:23 +0200 Subject: [PATCH 31/36] Implemented front-office login --- composer.lock | 265 ++- core/lib/Thelia/Action/Customer.php | 143 +- .../Admin/Controller/BaseAdminController.php | 5 +- .../Admin/Controller/SessionController.php | 11 +- core/lib/Thelia/Config/Resources/action.xml | 2 + core/lib/Thelia/Config/Resources/config.xml | 8 + core/lib/Thelia/Core/Event/TheliaEvents.php | 9 +- .../Core/EventListener/ViewListener.php | 2 - .../Core/HttpFoundation/Session/Session.php | 3 +- ...tomerUsernamePasswordFormAuthenticator.php | 2 +- .../Thelia/Core/Template/ParserContext.php | 62 + .../Smarty/Assets/SmartyAssetsManager.php | 2 +- .../Template/Smarty/Plugins/UrlGenerator.php | 28 +- .../Core/Template/Smarty/SmartyParser.php | 27 +- core/lib/Thelia/Form/AdminLogin.php | 1 - core/lib/Thelia/Form/BaseForm.php | 3 +- core/lib/Thelia/Form/CustomerLogin.php | 1 - core/lib/Thelia/Model/Base/Address.php | 52 +- core/lib/Thelia/Model/Base/AddressQuery.php | 34 +- core/lib/Thelia/Model/Customer.php | 5 +- core/lib/Thelia/Model/Map/AddressTableMap.php | 30 +- core/lib/Thelia/Tools/URL.php | 30 +- install/INSTALL-TODO.txt | 1 + install/thelia.sql | 2 +- local/config/schema.xml | 1852 ++++++++--------- templates/admin/default/home.html | 2 +- templates/admin/default/login.html | 4 +- .../bootstrap/css/bootstrap-responsive.css | 0 .../css/bootstrap-responsive.min.css | 0 .../assets/bootstrap/css/bootstrap.css | 0 .../assets/bootstrap/css/bootstrap.min.css | 0 .../img/glyphicons-halflings-white.png | Bin .../bootstrap/img/glyphicons-halflings.png | Bin .../assets/bootstrap/js/bootstrap.js | 0 .../assets/bootstrap/js/bootstrap.min.js | 0 .../assets/css/img/bg.jpg | Bin .../assets/css/style.less | 0 .../assets/img/logo-thelia-34px.png | Bin .../assets/img/test-background.jpg | Bin .../assets/js/jquery.min.js | 0 .../{smarty-sample => default}/category.html | 0 .../{smarty-sample => default}/connexion.html | 26 +- .../{smarty-sample => default}/i18n/en.php | 0 .../{smarty-sample => default}/i18n/fr.php | 0 templates/default/include1.html | 2 - .../{smarty-sample => default}/included.html | 0 .../includes/footer.html | 0 .../includes/footer.inc.tpl | 0 templates/default/includes/header.html | 25 + .../includes/header.inc.tpl | 0 .../includes/menu.tpl | 0 templates/default/index.html | 173 +- templates/default/login.html | 52 + templates/default/myaccount.html | 6 + .../pagination.html | 0 templates/default/subinclude1.html | 1 - templates/smarty-sample/includes/header.html | 11 - templates/smarty-sample/index.html | 151 -- 58 files changed, 1626 insertions(+), 1407 deletions(-) create mode 100644 core/lib/Thelia/Core/Template/ParserContext.php rename templates/{smarty-sample => default}/assets/bootstrap/css/bootstrap-responsive.css (100%) rename templates/{smarty-sample => default}/assets/bootstrap/css/bootstrap-responsive.min.css (100%) rename templates/{smarty-sample => default}/assets/bootstrap/css/bootstrap.css (100%) rename templates/{smarty-sample => default}/assets/bootstrap/css/bootstrap.min.css (100%) rename templates/{smarty-sample => default}/assets/bootstrap/img/glyphicons-halflings-white.png (100%) rename templates/{smarty-sample => default}/assets/bootstrap/img/glyphicons-halflings.png (100%) rename templates/{smarty-sample => default}/assets/bootstrap/js/bootstrap.js (100%) rename templates/{smarty-sample => default}/assets/bootstrap/js/bootstrap.min.js (100%) rename templates/{smarty-sample => default}/assets/css/img/bg.jpg (100%) rename templates/{smarty-sample => default}/assets/css/style.less (100%) rename templates/{smarty-sample => default}/assets/img/logo-thelia-34px.png (100%) rename templates/{smarty-sample => default}/assets/img/test-background.jpg (100%) rename templates/{smarty-sample => default}/assets/js/jquery.min.js (100%) rename templates/{smarty-sample => default}/category.html (100%) rename templates/{smarty-sample => default}/connexion.html (80%) rename templates/{smarty-sample => default}/i18n/en.php (100%) rename templates/{smarty-sample => default}/i18n/fr.php (100%) delete mode 100755 templates/default/include1.html rename templates/{smarty-sample => default}/included.html (100%) rename templates/{smarty-sample => default}/includes/footer.html (100%) rename templates/{smarty-sample => default}/includes/footer.inc.tpl (100%) create mode 100755 templates/default/includes/header.html rename templates/{smarty-sample => default}/includes/header.inc.tpl (100%) rename templates/{smarty-sample => default}/includes/menu.tpl (100%) create mode 100644 templates/default/login.html create mode 100644 templates/default/myaccount.html rename templates/{smarty-sample => default}/pagination.html (100%) delete mode 100755 templates/default/subinclude1.html delete mode 100755 templates/smarty-sample/includes/header.html delete mode 100755 templates/smarty-sample/index.html diff --git a/composer.lock b/composer.lock index 0e44951da..b49c21e6f 100755 --- a/composer.lock +++ b/composer.lock @@ -11,12 +11,12 @@ "source": { "type": "git", "url": "https://github.com/ezyang/htmlpurifier.git", - "reference": "v4.5.0" + "reference": "107b3055a10eb824701463602f77fbc8129180a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/v4.5.0", - "reference": "v4.5.0", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/107b3055a10eb824701463602f77fbc8129180a2", + "reference": "107b3055a10eb824701463602f77fbc8129180a2", "shasum": "" }, "require": { @@ -47,7 +47,7 @@ "keywords": [ "html" ], - "time": "2013-02-18 00:04:08" + "time": "2013-07-17 04:56:29" }, { "name": "ircmaxell/password-compat", @@ -94,12 +94,12 @@ "source": { "type": "git", "url": "https://github.com/kriswallsmith/assetic.git", - "reference": "82e8fc20a3b043b378a7efbda9e3d406d420f00e" + "reference": "f9f754dc7524acd6daf0bf510d22c055b4967e08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/82e8fc20a3b043b378a7efbda9e3d406d420f00e", - "reference": "82e8fc20a3b043b378a7efbda9e3d406d420f00e", + "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/f9f754dc7524acd6daf0bf510d22c055b4967e08", + "reference": "f9f754dc7524acd6daf0bf510d22c055b4967e08", "shasum": "" }, "require": { @@ -114,9 +114,9 @@ "leafo/scssphp": "*", "leafo/scssphp-compass": "*", "mrclay/minify": "*", - "phpunit/phpunit": ">=3.7,<4.0", + "phpunit/phpunit": "~3.7", "ptachoire/cssembed": "*", - "twig/twig": ">=1.6,<2.0" + "twig/twig": "~1.6" }, "suggest": { "leafo/lessphp": "Assetic provides the integration with the lessphp LESS compiler", @@ -157,7 +157,7 @@ "compression", "minification" ], - "time": "2013-06-13 16:47:03" + "time": "2013-07-11 15:56:23" }, { "name": "leafo/lessphp", @@ -165,12 +165,12 @@ "source": { "type": "git", "url": "https://github.com/leafo/lessphp.git", - "reference": "ff86f2941c3f3d67d56acad2f8902ca57c73b359" + "reference": "366fb52798d4f120503af0703da11cba4ad06f8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/leafo/lessphp/zipball/ff86f2941c3f3d67d56acad2f8902ca57c73b359", - "reference": "ff86f2941c3f3d67d56acad2f8902ca57c73b359", + "url": "https://api.github.com/repos/leafo/lessphp/zipball/366fb52798d4f120503af0703da11cba4ad06f8d", + "reference": "366fb52798d4f120503af0703da11cba4ad06f8d", "shasum": "" }, "type": "library", @@ -198,7 +198,7 @@ ], "description": "lessphp is a compiler for LESS written in PHP.", "homepage": "http://leafo.net/lessphp/", - "time": "2013-05-22 17:52:29" + "time": "2013-07-09 16:25:09" }, { "name": "propel/propel", @@ -487,24 +487,24 @@ }, { "name": "symfony/class-loader", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/ClassLoader", "source": { "type": "git", "url": "https://github.com/symfony/ClassLoader.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/finder": ">=2.0,<3.0" + "symfony/finder": "~2.0" }, "type": "library", "extra": { @@ -537,17 +537,17 @@ }, { "name": "symfony/config", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/Config", "source": { "type": "git", "url": "https://github.com/symfony/Config.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/Config/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { @@ -580,21 +580,21 @@ ], "description": "Symfony Config Component", "homepage": "http://symfony.com", - "time": "2013-05-10 18:08:31" + "time": "2013-07-10 14:03:01" }, { "name": "symfony/console", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/Console/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { @@ -627,21 +627,21 @@ ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2013-06-13 07:47:06" + "time": "2013-07-08 14:34:53" }, { "name": "symfony/dependency-injection", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { @@ -649,7 +649,7 @@ }, "require-dev": { "symfony/config": ">=2.2,<2.3-dev", - "symfony/yaml": ">=2.0,<3.0" + "symfony/yaml": "~2.0" }, "suggest": { "symfony/config": "2.2.*", @@ -686,24 +686,24 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/dependency-injection": ">=2.0,<3.0" + "symfony/dependency-injection": "~2.0" }, "suggest": { "symfony/dependency-injection": "2.2.*", @@ -740,17 +740,17 @@ }, { "name": "symfony/filesystem", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/Filesystem", "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { @@ -787,17 +787,17 @@ }, { "name": "symfony/finder", - "version": "v2.3.1", + "version": "v2.3.2", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "v2.3.1" + "reference": "v2.3.2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/v2.3.1", - "reference": "v2.3.1", + "url": "https://api.github.com/repos/symfony/Finder/zipball/v2.3.2", + "reference": "v2.3.2", "shasum": "" }, "require": { @@ -830,27 +830,27 @@ ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2013-06-02 12:05:51" + "time": "2013-07-01 12:17:23" }, { "name": "symfony/form", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/Form", "source": { "type": "git", "url": "https://github.com/symfony/Form.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Form/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/Form/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/event-dispatcher": ">=2.1,<3.0", - "symfony/locale": ">=2.0,<3.0", + "symfony/event-dispatcher": "~2.1", + "symfony/locale": "~2.0", "symfony/options-resolver": ">=2.1,<2.3-dev", "symfony/property-access": ">=2.2,<2.3-dev" }, @@ -889,21 +889,21 @@ ], "description": "Symfony Form Component", "homepage": "http://symfony.com", - "time": "2013-06-13 07:35:18" + "time": "2013-06-23 07:35:41" }, { "name": "symfony/http-foundation", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { @@ -939,37 +939,37 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com", - "time": "2013-06-13 12:48:26" + "time": "2013-07-15 12:12:07" }, { "name": "symfony/http-kernel", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { "php": ">=5.3.3", - "psr/log": ">=1.0,<2.0", - "symfony/event-dispatcher": ">=2.1,<3.0", + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.1", "symfony/http-foundation": ">=2.2,<2.3-dev" }, "require-dev": { "symfony/browser-kit": "2.2.*", - "symfony/class-loader": ">=2.1,<3.0", - "symfony/config": ">=2.0,<3.0", + "symfony/class-loader": "~2.1", + "symfony/config": "~2.0", "symfony/console": "2.2.*", - "symfony/dependency-injection": ">=2.0,<3.0", - "symfony/finder": ">=2.0,<3.0", - "symfony/process": ">=2.0,<3.0", + "symfony/dependency-injection": "~2.0", + "symfony/finder": "~2.0", + "symfony/process": "~2.0", "symfony/routing": ">=2.2,<2.3-dev", "symfony/stopwatch": ">=2.2,<2.3-dev" }, @@ -1008,25 +1008,24 @@ ], "description": "Symfony HttpKernel Component", "homepage": "http://symfony.com", - "time": "2013-06-19 12:09:49" + "time": "2013-07-15 12:28:01" }, { "name": "symfony/icu", - "version": "v1.2.0", + "version": "v1.0.0", "target-dir": "Symfony/Component/Icu", "source": { "type": "git", "url": "https://github.com/symfony/Icu.git", - "reference": "v1.2.0" + "reference": "v1.0.0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Icu/zipball/v1.2.0", - "reference": "v1.2.0", + "url": "https://api.github.com/repos/symfony/Icu/zipball/v1.0.0", + "reference": "v1.0.0", "shasum": "" }, "require": { - "lib-icu": ">=4.4", "php": ">=5.3.3", "symfony/intl": ">=2.3,<3.0" }, @@ -1056,26 +1055,26 @@ "icu", "intl" ], - "time": "2013-06-03 18:32:58" + "time": "2013-06-03 18:32:07" }, { "name": "symfony/intl", - "version": "v2.3.1", + "version": "v2.3.2", "target-dir": "Symfony/Component/Intl", "source": { "type": "git", "url": "https://github.com/symfony/Intl.git", - "reference": "v2.3.1" + "reference": "v2.3.2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Intl/zipball/v2.3.1", - "reference": "v2.3.1", + "url": "https://api.github.com/repos/symfony/Intl/zipball/v2.3.2", + "reference": "v2.3.2", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/icu": ">=1.0-RC,<2.0" + "symfony/icu": "~1.0-RC" }, "require-dev": { "symfony/filesystem": ">=2.1" @@ -1133,21 +1132,21 @@ "l10n", "localization" ], - "time": "2013-05-18 11:21:22" + "time": "2013-07-08 13:00:35" }, { "name": "symfony/locale", - "version": "v2.3.1", + "version": "v2.3.2", "target-dir": "Symfony/Component/Locale", "source": { "type": "git", "url": "https://github.com/symfony/Locale.git", - "reference": "v2.3.1" + "reference": "v2.3.2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Locale/zipball/v2.3.1", - "reference": "v2.3.1", + "url": "https://api.github.com/repos/symfony/Locale/zipball/v2.3.2", + "reference": "v2.3.2", "shasum": "" }, "require": { @@ -1181,21 +1180,21 @@ ], "description": "Symfony Locale Component", "homepage": "http://symfony.com", - "time": "2013-04-11 09:29:25" + "time": "2013-07-01 12:24:43" }, { "name": "symfony/options-resolver", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/OptionsResolver", "source": { "type": "git", "url": "https://github.com/symfony/OptionsResolver.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/OptionsResolver/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/OptionsResolver/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { @@ -1237,17 +1236,17 @@ }, { "name": "symfony/process", - "version": "v2.3.1", + "version": "v2.3.2", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "v2.3.1" + "reference": "v2.3.2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/v2.3.1", - "reference": "v2.3.1", + "url": "https://api.github.com/repos/symfony/Process/zipball/v2.3.2", + "reference": "v2.3.2", "shasum": "" }, "require": { @@ -1280,21 +1279,21 @@ ], "description": "Symfony Process Component", "homepage": "http://symfony.com", - "time": "2013-05-06 20:03:44" + "time": "2013-07-01 12:24:43" }, { "name": "symfony/property-access", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/PropertyAccess", "source": { "type": "git", "url": "https://github.com/symfony/PropertyAccess.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/PropertyAccess/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/PropertyAccess/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { @@ -1342,27 +1341,27 @@ }, { "name": "symfony/routing", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony/Routing.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Routing/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/Routing/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "doctrine/common": ">=2.2,<3.0", - "psr/log": ">=1.0,<2.0", + "doctrine/common": "~2.2", + "psr/log": "~1.0", "symfony/config": ">=2.2,<2.3-dev", - "symfony/yaml": ">=2.0,<3.0" + "symfony/yaml": "~2.0" }, "suggest": { "doctrine/common": "~2.2", @@ -1396,21 +1395,21 @@ ], "description": "Symfony Routing Component", "homepage": "http://symfony.com", - "time": "2013-05-10 16:49:00" + "time": "2013-06-23 06:56:04" }, { "name": "symfony/translation", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/Translation", "source": { "type": "git", "url": "https://github.com/symfony/Translation.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/Translation/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { @@ -1418,7 +1417,7 @@ }, "require-dev": { "symfony/config": ">=2.0,<2.3-dev", - "symfony/yaml": ">=2.2,<3.0" + "symfony/yaml": "~2.2" }, "suggest": { "symfony/config": "2.2.*", @@ -1455,28 +1454,28 @@ }, { "name": "symfony/validator", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/Validator", "source": { "type": "git", "url": "https://github.com/symfony/Validator.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Validator/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/Validator/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/translation": ">=2.0,<3.0" + "symfony/translation": "~2.0" }, "require-dev": { "symfony/config": ">=2.2,<2.3-dev", - "symfony/http-foundation": ">=2.1,<3.0", - "symfony/locale": ">=2.0,<3.0", - "symfony/yaml": ">=2.0,<3.0" + "symfony/http-foundation": "~2.1", + "symfony/locale": "~2.0", + "symfony/yaml": "~2.0" }, "suggest": { "doctrine/common": "~2.2", @@ -1512,21 +1511,21 @@ ], "description": "Symfony Validator Component", "homepage": "http://symfony.com", - "time": "2013-06-02 12:05:41" + "time": "2013-07-02 07:41:45" }, { "name": "symfony/yaml", - "version": "v2.2.3", + "version": "v2.2.4", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "v2.2.3" + "reference": "v2.2.4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.2.3", - "reference": "v2.2.3", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.2.4", + "reference": "v2.2.4", "shasum": "" }, "require": { @@ -1559,7 +1558,7 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2013-05-10 18:08:31" + "time": "2013-07-11 09:28:01" } ], "packages-dev": [ @@ -1569,12 +1568,12 @@ "source": { "type": "git", "url": "https://github.com/fzaninotto/Faker.git", - "reference": "8b9bb44bbf864a63c2eece6744fc40240877b0c6" + "reference": "3613b1466d5e9518b83f87d828f93f962ff0f997" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/8b9bb44bbf864a63c2eece6744fc40240877b0c6", - "reference": "8b9bb44bbf864a63c2eece6744fc40240877b0c6", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/3613b1466d5e9518b83f87d828f93f962ff0f997", + "reference": "3613b1466d5e9518b83f87d828f93f962ff0f997", "shasum": "" }, "require": { @@ -1607,7 +1606,7 @@ "faker", "fixtures" ], - "time": "2013-07-08 09:31:33" + "time": "2013-07-15 16:26:12" }, { "name": "phpunit/php-code-coverage", diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 0d95b54be..c4561964c 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ @@ -39,30 +39,28 @@ use Thelia\Model\ConfigQuery; use Thelia\Tools\Redirect; use Symfony\Component\Validator\Exception\ValidatorException; use Thelia\Core\Security\Exception\AuthenticationException; +use Thelia\Core\Template\ParserContext; +use Thelia\Core\Security\Exception\UsernameNotFoundException; class Customer implements EventSubscriberInterface { /** * @var Thelia\Core\Security\SecurityContext */ - private $securityContext; + protected $securityContext; - public function __construct(SecurityContext $context) { - $this->securityContext = $context; + /** + * @var Thelia\Core\Template\ParserContext + */ + protected $parserContext; - $context->setContext(SecurityContext::CONTEXT_FRONT_OFFICE); + public function __construct(SecurityContext $securityContext, ParserContext $parserContext) { + $this->securityContext = $securityContext; + $this->parserContext = $parserContext; } - - private function getSecurityContext($context) { - $this->securityContext->setContext($context === false ? SecurityContext::CONTEXT_FRONT_OFFICE : $context); - - return $securityContext; - } - public function create(ActionEvent $event) { - $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CREATECUSTOMER, $event); $request = $event->getRequest(); @@ -94,25 +92,35 @@ class Customer implements EventSubscriberInterface $data["password"], $request->getSession()->getLang() ); + + $event->getDispatcher()->dispatch(TheliaEvents::AFTER_CREATECUSTOMER, $event); + + // Connect the newly created user,and redirect to the success URL + $this->processSuccessfulLogin($event, $customer, $customerCreation, true); + } catch (\PropelException $e) { Tlog::getInstance()->error(sprintf('error during creating customer on action/createCustomer with message "%s"', $e->getMessage())); - $event->setFormError($customerCreation); + + $message = "Failed to create your account, please try again."; } - - //Customer is create, he is automatically connected - } else { - - $event->setFormError($customerCreation); + $message = "Missing or invalid data"; } } + else { + $message = "Wrong form method !"; + } - $event->getDispatcher()->dispatch(TheliaEvents::AFTER_CREATECUSTOMER, $event); + $this->parserContext->set('customer_creation_error_message', $message); + + $event->setFormError($customerCreation); } public function modify(ActionEvent $event) { + $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CHANGECUSTOMER, $event); + $request = $event->getRequest(); $customerModification = new CustomerModification($request); @@ -140,15 +148,44 @@ class Customer implements EventSubscriberInterface $data["zipcode"], $data["country"] ); - } catch(\PropelException $e) { + + $event->getDispatcher()->dispatch(TheliaEvents::AFTER_CHANGECUSTOMER, $event); + + // Update the logged-in user, and redirect to the success URL (exits) + // We don-t send the login event, as the customer si already logged. + $this->processSuccessfulLogin($event, $customer, $customerModification); + } + catch(\PropelException $e) { + Tlog::getInstance()->error(sprintf('error during modifying customer on action/modifyCustomer with message "%s"', $e->getMessage())); - $event->setFormError($customerModification); + + $message = "Failed to change your account, please try again."; } - } else { - $event->setFormError($customerModification); + } + else { + $message = "Missing or invalid data"; } } + else { + $message = "Wrong form method !"; + } + $this->parserContext->set('customer_change_error_message', $message); + + $event->setFormError($customerModification); + } + + + /** + * Perform user logout. The user is redirected to the provided view, if any. + * + * @param ActionEvent $event + */ + public function logout(ActionEvent $event) + { + $event->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_LOGOUT, $event); + + $this->getSecurityContext()->clear(); } /** @@ -170,39 +207,33 @@ class Customer implements EventSubscriberInterface try { $user = $authenticator->getAuthentifiedUser(); - // Success -> store user in security context - $this->getSecurityContext()->setUser($user); - - // Log authentication success - AdminLog::append("Authentication successufull", $request, $user); - - // Get the success URL to redirect the user to - $successUrl = $form->getForm()->get('success_url')->getData(); - - if (null == $successUrl) $successUrl = ConfigQuery::read('base_url', '/'); - - // Redirect to the success URL - return Redirect::exec(URL::absoluteUrl($successUrl)); - } + $this->processSuccessfulLogin($event, $user, $form); + } catch (ValidatorException $ex) { $message = "Missing or invalid information. Please check your input."; } + catch (UsernameNotFoundException $ex) { + $message = "This email address was not found."; + } catch (AuthenticationException $ex) { $message = "Login failed. Please check your username and password."; } catch (\Exception $ex) { - $message = sprintf("Unable to process your request. Please try again (%s).", $ex->getMessage()); + $message = sprintf("Unable to process your request. Please try again (%s in %s).", $ex->getMessage(), $ex->getFile()); } // Store the form name in session (see Form Smarty plugin to find usage of this parameter) $request->getSession()->setErrorFormName($form->getName()); + // Put the message in the ParserContext to make it available to the template + $this->parserContext->set('customer_login_error_message', $message); + // A this point, the same view is displayed again. } public function changePassword(ActionEvent $event) { - + // TODO } /** @@ -230,8 +261,36 @@ class Customer implements EventSubscriberInterface return array( "action.createCustomer" => array("create", 128), "action.modifyCustomer" => array("modify", 128), - "action.loginCustomer" => array("login", 128) + "action.loginCustomer" => array("login", 128), + "action.logoutCustomer" => array("logout", 128), ); } + /** + * Stores the current user in the security context, and redirect to the + * success_url. + * + * @param CustomerModel $user the logged user + */ + protected function processSuccessfulLogin(ActionEvent $event, CustomerModel $user, BaseForm $form, $sendLoginEvent = false) + { + // Success -> store user in security context + $this->getSecurityContext()->setUser($user); + + if ($sendLoginEvent) $event->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_LOGIN, $event); + + // Redirect to the success URL + return Redirect::exec($form->getSuccessUrl()); + } + + /** + * Return the security context, beeing sure that we're in the CONTEXT_FRONT_OFFICE context + * + * @return SecurityContext the security context + */ + protected function getSecurityContext() { + $this->securityContext->setContext(SecurityContext::CONTEXT_FRONT_OFFICE); + + return $this->securityContext; + } } diff --git a/core/lib/Thelia/Admin/Controller/BaseAdminController.php b/core/lib/Thelia/Admin/Controller/BaseAdminController.php index 773f9cccc..e13f10da2 100755 --- a/core/lib/Thelia/Admin/Controller/BaseAdminController.php +++ b/core/lib/Thelia/Admin/Controller/BaseAdminController.php @@ -94,8 +94,9 @@ class BaseAdminController extends ContainerAware catch (AuthenticationException $ex) { // User is not authenticated, and templates requires authentication -> redirect to login page - // (see Thelia\Core\Template\Smarty\Plugins\Security) - Redirect::exec(URL::absoluteUrl('admin/login')); // FIXME shoud be a parameter + // We user login_tpl as a path, not a template. + + Redirect::exec(URL::absoluteUrl($ex->getLoginTemplate())); } } diff --git a/core/lib/Thelia/Admin/Controller/SessionController.php b/core/lib/Thelia/Admin/Controller/SessionController.php index d2febe089..115f9700c 100755 --- a/core/lib/Thelia/Admin/Controller/SessionController.php +++ b/core/lib/Thelia/Admin/Controller/SessionController.php @@ -44,7 +44,7 @@ class SessionController extends BaseAdminController { $this->getSecurityContext()->clear(); // Go back to login page. - return Redirect::exec(URL::absoluteUrl('admin/login')); + return Redirect::exec(URL::absoluteUrl('/admin/login')); // FIXME - should be a parameter } public function checkLoginAction() @@ -62,15 +62,10 @@ class SessionController extends BaseAdminController { $this->getSecurityContext()->setUser($user); // Log authentication success - AdminLog::append("Authentication successufull", $request, $user); - - // Get the success URL to redirect the user to - $successUrl = $form->getForm()->get('success_url')->getData(); - - if (null == $successUrl) $successUrl = 'admin/home'; + AdminLog::append("Authentication successuful", $request, $user); // Redirect to the success URL - return Redirect::exec(URL::absoluteUrl($successUrl)); + return Redirect::exec($form->getSuccessUrl()); } catch (ValidatorException $ex) { diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 1fd380425..935faa8c3 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -20,7 +20,9 @@ + + diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 4315d2844..94cae432a 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -58,16 +58,24 @@ + + + + + + + false %kernel.environment% %kernel.debug% + diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 46dd89ee6..d570c22a1 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -48,9 +48,14 @@ final class TheliaEvents */ const INCLUSION = "thelia.include"; - const BEFORE_CREATECUSTOMER = "action.before_createcustomer"; + const CUSTOMER_LOGOUT = "action.customer_logout"; + const CUSTOMER_LOGIN = "action.customer_login"; - const AFTER_CREATECUSTOMER = "action.after_createcustomer"; + const BEFORE_CREATECUSTOMER = "action.before_createcustomer"; + const AFTER_CREATECUSTOMER = "action.after_createcustomer"; + + const BEFORE_CHANGECUSTOMER = "action.before_changecustomer"; + const AFTER_CHANGECUSTOMER = "action.after_changecustomer"; const CREATECUSTOMER_CUSTOMREF = "customer.creation.customref"; } diff --git a/core/lib/Thelia/Core/EventListener/ViewListener.php b/core/lib/Thelia/Core/EventListener/ViewListener.php index a67d7f0e2..2017fe6ae 100755 --- a/core/lib/Thelia/Core/EventListener/ViewListener.php +++ b/core/lib/Thelia/Core/EventListener/ViewListener.php @@ -90,8 +90,6 @@ class ViewListener implements EventSubscriberInterface // Redirect to the login template $event->setResponse(Redirect::exec(URL::viewUrl($ex->getLoginTemplate()))); } - - throw new \Exception("toto !"); } public function beforeKernelView(GetResponseForControllerResultEvent $event) diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php index bf47310b2..ac684f6c6 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -27,6 +27,7 @@ use Symfony\Component\HttpFoundation\Session\Session as BaseSession; use Thelia\Core\Security\User\UserInterface; use Thelia\Form\BaseForm; use Thelia\Model\ConfigQuery; +use Thelia\Tools\URL; class Session extends BaseSession { @@ -109,7 +110,7 @@ class Session extends BaseSession { */ public function getReturnToUrl() { - return $this->get('return_to_url', ConfigQuery::read('base_url')); + return $this->get('return_to_url', URL::getIndexPage()); } } diff --git a/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php index 1097edf5a..a5b1b32e4 100644 --- a/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php +++ b/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php @@ -37,7 +37,7 @@ class CustomerUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuth $loginForm, new CustomerUserProvider(), array( - 'username_field_name', 'email' + 'username_field_name' => 'email' ) ); } diff --git a/core/lib/Thelia/Core/Template/ParserContext.php b/core/lib/Thelia/Core/Template/ParserContext.php new file mode 100644 index 000000000..8d1d50fdc --- /dev/null +++ b/core/lib/Thelia/Core/Template/ParserContext.php @@ -0,0 +1,62 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template; + +use Thelia\Model\ConfigQuery; +use Thelia\Core\HttpFoundation\Request; +use Thelia\Tools\URL; +/** + * The parser context is an application-wide context, which stores var-value pairs. + * Theses pairs are injected in the parser and becomes available to the templates. + * + * @author Franck Allimant + */ +class ParserContext implements \IteratorAggregate +{ + private $store = array(); + + public function __construct(Request $request) { + + // Setup basic variables + $this + ->set('base_url' , ConfigQuery::read('base_url', '/')) + ->set('index_page' , URL::getIndexPage()) + ->set('return_to_url' , URL::absoluteUrl($request->getSession()->getReturnToUrl())) + ; + } + + public function set($name, $value) { + $this->store[$name] = $value; + + return $this; + } + + public function get($name) { + return $this->store[$name]; + } + + public function getIterator() { + return new \ArrayIterator( $this->store ); + } +} diff --git a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php index 5610785d8..1f8a3cb2e 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php +++ b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php @@ -73,7 +73,7 @@ class SmartyAssetsManager $url = $this->assetic_manager->asseticize( $asset_dir.'/'.$asset_file, $this->web_root."/".$this->path_relative_to_web_root, - URL::absoluteUrl($this->path_relative_to_web_root), + URL::absoluteUrl($this->path_relative_to_web_root, array(), true /* path only */), $assetType, $filters, $debug diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php index cef25cc33..c2c75dffc 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php @@ -47,7 +47,7 @@ class UrlGenerator implements SmartyPluginInterface public function generateUrlFunction($params, &$smarty) { // the path to process - $path =trim($params['path']); + $path = trim($params['path']); return URL::absoluteUrl($path, $this->getArgsFromParam($params)); } @@ -61,10 +61,17 @@ class UrlGenerator implements SmartyPluginInterface */ public function generateViewUrlFunction($params, &$smarty) { - // the path to process + // the view name (without .html) $view = trim($params['view']); - return URL::viewUrl($view, $this->getArgsFromParam($params)); + // the related action (optionale) + $action = trim($params['action']); + + $args = $this->getArgsFromParam($params); + + if (! empty($action)) $args['action'] = $action; + + return URL::viewUrl($view, $args); } /** @@ -82,18 +89,6 @@ class UrlGenerator implements SmartyPluginInterface return array(); } - /** - * Process view url generator function - * - * @param array $params - * @param unknown $smarty - * @return string no text is returned. - */ - public function generateReturnToUrl($params, &$smarty) - { - return URL::absoluteUrl($this->request->getSession()->getReturnToUrl()); - } - /** * Define the various smarty plugins hendled by this class * @@ -103,8 +98,7 @@ class UrlGenerator implements SmartyPluginInterface { return array( new SmartyPluginDescriptor('function', 'url', $this, 'generateUrlFunction'), - new SmartyPluginDescriptor('function', 'viewurl', $this, 'generateViewUrlFunction'), - new SmartyPluginDescriptor('function', 'return_to_url', $this, 'generateReturnToUrl') + new SmartyPluginDescriptor('function', 'viewurl', $this, 'generateViewUrlFunction') ); } } diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index e39094088..a1e63dbf8 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -12,6 +12,8 @@ use Thelia\Core\Template\ParserInterface; use Thelia\Core\Template\Smarty\SmartyPluginInterface; use Thelia\Core\Template\Exception\ResourceNotFoundException; +use Thelia\Core\Template\ParserContext; +use Thelia\Model\ConfigQuery; /** * @@ -23,7 +25,9 @@ class SmartyParser extends Smarty implements ParserInterface public $plugins = array(); - protected $request, $dispatcher; + protected $request; + protected $dispatcher; + protected $parserContext; protected $template = ""; @@ -36,12 +40,15 @@ class SmartyParser extends Smarty implements ParserInterface * @param string $env * @param bool $debug */ - public function __construct(Request $request, EventDispatcherInterface $dispatcher, $template = false, $env = "prod", $debug = false) + public function __construct( + Request $request, EventDispatcherInterface $dispatcher, ParserContext $parserContext, + $template = false, $env = "prod", $debug = false) { parent::__construct(); $this->request = $request; $this->dispatcher = $dispatcher; + $this->parserContext = $parserContext; // Configure basic Smarty parameters @@ -51,11 +58,11 @@ class SmartyParser extends Smarty implements ParserInterface $cache_dir = THELIA_ROOT . 'cache/'. $env .'/smarty/cache'; if (! is_dir($cache_dir)) @mkdir($cache_dir, 0777, true); - $this->setTemplate($template ?: 'smarty-sample'); // FIXME: put this in configuration - $this->setCompileDir($compile_dir); $this->setCacheDir($cache_dir); + $this->setTemplate($template ?: ConfigQuery::read('active-template', 'default')); + $this->debugging = $debug; // Prevent smarty ErrorException: Notice: Undefined index bla bla bla... @@ -110,8 +117,13 @@ class SmartyParser extends Smarty implements ParserInterface * @param array $parameters an associative array of names / value pairs * @return string the rendered template text */ - public function render($realTemplateName, array $parameters) + public function render($realTemplateName, array $parameters = array()) { + // Assign the parserContext variables + foreach($this->parserContext as $var => $value) { + $this->assign($var, $value); + } + $this->assign($parameters); return $this->fetch($realTemplateName); @@ -126,11 +138,12 @@ class SmartyParser extends Smarty implements ParserInterface { try { $templateFile = $this->getTemplateFilePath(); - } catch(\RuntimeException $e) { + } + catch(\RuntimeException $e) { return new Response($e->getMessage(), "404"); } - return $this->fetch($templateFile); + return $this->render($templateFile); } /** diff --git a/core/lib/Thelia/Form/AdminLogin.php b/core/lib/Thelia/Form/AdminLogin.php index 6a96d4c78..5ed78a575 100755 --- a/core/lib/Thelia/Form/AdminLogin.php +++ b/core/lib/Thelia/Form/AdminLogin.php @@ -46,7 +46,6 @@ class AdminLogin extends BaseForm { ->add("remember_me", "checkbox", array( 'value' => 'yes' )) - ->add("success_url", "text") ; } diff --git a/core/lib/Thelia/Form/BaseForm.php b/core/lib/Thelia/Form/BaseForm.php index 40753b256..cebdd1f0b 100755 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -31,6 +31,7 @@ use Symfony\Component\Form\Extension\Csrf\CsrfExtension; use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider; use Symfony\Component\Validator\Validation; use Thelia\Model\ConfigQuery; +use Thelia\Tools\URL; abstract class BaseForm { /** @@ -72,7 +73,7 @@ abstract class BaseForm { // If not already set, define the success_url field if (! $this->formBuilder->has('success_url')) { - $this->formBuilder->add("success_url", "text") + $this->formBuilder->add("success_url", "text"); } $this->form = $this->formBuilder->getForm(); diff --git a/core/lib/Thelia/Form/CustomerLogin.php b/core/lib/Thelia/Form/CustomerLogin.php index 64937cbf6..52357dbd6 100644 --- a/core/lib/Thelia/Form/CustomerLogin.php +++ b/core/lib/Thelia/Form/CustomerLogin.php @@ -46,7 +46,6 @@ class CustomerLogin extends BaseForm { ) )) ->add("remember_me", "checkbox") - ->add("success_url", "text") ; } diff --git a/core/lib/Thelia/Model/Base/Address.php b/core/lib/Thelia/Model/Base/Address.php index 208d43cdb..e0864f269 100755 --- a/core/lib/Thelia/Model/Base/Address.php +++ b/core/lib/Thelia/Model/Base/Address.php @@ -149,11 +149,11 @@ abstract class Address implements ActiveRecordInterface protected $cellphone; /** - * The value for the default field. + * The value for the is_default field. * Note: this column has a database default value of: 0 * @var int */ - protected $default; + protected $is_default; /** * The value for the created_at field. @@ -193,7 +193,7 @@ abstract class Address implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->default = 0; + $this->is_default = 0; } /** @@ -618,14 +618,14 @@ abstract class Address implements ActiveRecordInterface } /** - * Get the [default] column value. + * Get the [is_default] column value. * * @return int */ - public function getDefault() + public function getIsDefault() { - return $this->default; + return $this->is_default; } /** @@ -992,25 +992,25 @@ abstract class Address implements ActiveRecordInterface } // setCellphone() /** - * Set the value of [default] column. + * Set the value of [is_default] column. * * @param int $v new value * @return \Thelia\Model\Address The current object (for fluent API support) */ - public function setDefault($v) + public function setIsDefault($v) { if ($v !== null) { $v = (int) $v; } - if ($this->default !== $v) { - $this->default = $v; - $this->modifiedColumns[] = AddressTableMap::DEFAULT; + if ($this->is_default !== $v) { + $this->is_default = $v; + $this->modifiedColumns[] = AddressTableMap::IS_DEFAULT; } return $this; - } // setDefault() + } // setIsDefault() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -1064,7 +1064,7 @@ abstract class Address implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->default !== 0) { + if ($this->is_default !== 0) { return false; } @@ -1140,8 +1140,8 @@ abstract class Address implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : AddressTableMap::translateFieldName('Cellphone', TableMap::TYPE_PHPNAME, $indexType)]; $this->cellphone = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : AddressTableMap::translateFieldName('Default', TableMap::TYPE_PHPNAME, $indexType)]; - $this->default = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : AddressTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_default = (null !== $col) ? (int) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : AddressTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { @@ -1454,8 +1454,8 @@ abstract class Address implements ActiveRecordInterface if ($this->isColumnModified(AddressTableMap::CELLPHONE)) { $modifiedColumns[':p' . $index++] = 'CELLPHONE'; } - if ($this->isColumnModified(AddressTableMap::DEFAULT)) { - $modifiedColumns[':p' . $index++] = 'DEFAULT'; + if ($this->isColumnModified(AddressTableMap::IS_DEFAULT)) { + $modifiedColumns[':p' . $index++] = 'IS_DEFAULT'; } if ($this->isColumnModified(AddressTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -1519,8 +1519,8 @@ abstract class Address implements ActiveRecordInterface case 'CELLPHONE': $stmt->bindValue($identifier, $this->cellphone, PDO::PARAM_STR); break; - case 'DEFAULT': - $stmt->bindValue($identifier, $this->default, PDO::PARAM_INT); + case 'IS_DEFAULT': + $stmt->bindValue($identifier, $this->is_default, 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); @@ -1636,7 +1636,7 @@ abstract class Address implements ActiveRecordInterface return $this->getCellphone(); break; case 15: - return $this->getDefault(); + return $this->getIsDefault(); break; case 16: return $this->getCreatedAt(); @@ -1688,7 +1688,7 @@ abstract class Address implements ActiveRecordInterface $keys[12] => $this->getCountryId(), $keys[13] => $this->getPhone(), $keys[14] => $this->getCellphone(), - $keys[15] => $this->getDefault(), + $keys[15] => $this->getIsDefault(), $keys[16] => $this->getCreatedAt(), $keys[17] => $this->getUpdatedAt(), ); @@ -1785,7 +1785,7 @@ abstract class Address implements ActiveRecordInterface $this->setCellphone($value); break; case 15: - $this->setDefault($value); + $this->setIsDefault($value); break; case 16: $this->setCreatedAt($value); @@ -1832,7 +1832,7 @@ abstract class Address implements ActiveRecordInterface if (array_key_exists($keys[12], $arr)) $this->setCountryId($arr[$keys[12]]); if (array_key_exists($keys[13], $arr)) $this->setPhone($arr[$keys[13]]); if (array_key_exists($keys[14], $arr)) $this->setCellphone($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setDefault($arr[$keys[15]]); + if (array_key_exists($keys[15], $arr)) $this->setIsDefault($arr[$keys[15]]); if (array_key_exists($keys[16], $arr)) $this->setCreatedAt($arr[$keys[16]]); if (array_key_exists($keys[17], $arr)) $this->setUpdatedAt($arr[$keys[17]]); } @@ -1861,7 +1861,7 @@ abstract class Address implements ActiveRecordInterface if ($this->isColumnModified(AddressTableMap::COUNTRY_ID)) $criteria->add(AddressTableMap::COUNTRY_ID, $this->country_id); if ($this->isColumnModified(AddressTableMap::PHONE)) $criteria->add(AddressTableMap::PHONE, $this->phone); if ($this->isColumnModified(AddressTableMap::CELLPHONE)) $criteria->add(AddressTableMap::CELLPHONE, $this->cellphone); - if ($this->isColumnModified(AddressTableMap::DEFAULT)) $criteria->add(AddressTableMap::DEFAULT, $this->default); + if ($this->isColumnModified(AddressTableMap::IS_DEFAULT)) $criteria->add(AddressTableMap::IS_DEFAULT, $this->is_default); if ($this->isColumnModified(AddressTableMap::CREATED_AT)) $criteria->add(AddressTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(AddressTableMap::UPDATED_AT)) $criteria->add(AddressTableMap::UPDATED_AT, $this->updated_at); @@ -1941,7 +1941,7 @@ abstract class Address implements ActiveRecordInterface $copyObj->setCountryId($this->getCountryId()); $copyObj->setPhone($this->getPhone()); $copyObj->setCellphone($this->getCellphone()); - $copyObj->setDefault($this->getDefault()); + $copyObj->setIsDefault($this->getIsDefault()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -2094,7 +2094,7 @@ abstract class Address implements ActiveRecordInterface $this->country_id = null; $this->phone = null; $this->cellphone = null; - $this->default = null; + $this->is_default = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/AddressQuery.php b/core/lib/Thelia/Model/Base/AddressQuery.php index c0b32975d..f9dc30efc 100755 --- a/core/lib/Thelia/Model/Base/AddressQuery.php +++ b/core/lib/Thelia/Model/Base/AddressQuery.php @@ -36,7 +36,7 @@ use Thelia\Model\Map\AddressTableMap; * @method ChildAddressQuery orderByCountryId($order = Criteria::ASC) Order by the country_id column * @method ChildAddressQuery orderByPhone($order = Criteria::ASC) Order by the phone column * @method ChildAddressQuery orderByCellphone($order = Criteria::ASC) Order by the cellphone column - * @method ChildAddressQuery orderByDefault($order = Criteria::ASC) Order by the default column + * @method ChildAddressQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column * @method ChildAddressQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildAddressQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -55,7 +55,7 @@ use Thelia\Model\Map\AddressTableMap; * @method ChildAddressQuery groupByCountryId() Group by the country_id column * @method ChildAddressQuery groupByPhone() Group by the phone column * @method ChildAddressQuery groupByCellphone() Group by the cellphone column - * @method ChildAddressQuery groupByDefault() Group by the default column + * @method ChildAddressQuery groupByIsDefault() Group by the is_default column * @method ChildAddressQuery groupByCreatedAt() Group by the created_at column * @method ChildAddressQuery groupByUpdatedAt() Group by the updated_at column * @@ -89,7 +89,7 @@ use Thelia\Model\Map\AddressTableMap; * @method ChildAddress findOneByCountryId(int $country_id) Return the first ChildAddress filtered by the country_id column * @method ChildAddress findOneByPhone(string $phone) Return the first ChildAddress filtered by the phone column * @method ChildAddress findOneByCellphone(string $cellphone) Return the first ChildAddress filtered by the cellphone column - * @method ChildAddress findOneByDefault(int $default) Return the first ChildAddress filtered by the default column + * @method ChildAddress findOneByIsDefault(int $is_default) Return the first ChildAddress filtered by the is_default column * @method ChildAddress findOneByCreatedAt(string $created_at) Return the first ChildAddress filtered by the created_at column * @method ChildAddress findOneByUpdatedAt(string $updated_at) Return the first ChildAddress filtered by the updated_at column * @@ -108,7 +108,7 @@ use Thelia\Model\Map\AddressTableMap; * @method array findByCountryId(int $country_id) Return ChildAddress objects filtered by the country_id column * @method array findByPhone(string $phone) Return ChildAddress objects filtered by the phone column * @method array findByCellphone(string $cellphone) Return ChildAddress objects filtered by the cellphone column - * @method array findByDefault(int $default) Return ChildAddress objects filtered by the default column + * @method array findByIsDefault(int $is_default) Return ChildAddress objects filtered by the is_default column * @method array findByCreatedAt(string $created_at) Return ChildAddress objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildAddress objects filtered by the updated_at column * @@ -199,7 +199,7 @@ abstract class AddressQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, TITLE, CUSTOMER_ID, CUSTOMER_TITLE_ID, COMPANY, FIRSTNAME, LASTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ZIPCODE, CITY, COUNTRY_ID, PHONE, CELLPHONE, DEFAULT, CREATED_AT, UPDATED_AT FROM address WHERE ID = :p0'; + $sql = 'SELECT ID, TITLE, CUSTOMER_ID, CUSTOMER_TITLE_ID, COMPANY, FIRSTNAME, LASTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ZIPCODE, CITY, COUNTRY_ID, PHONE, CELLPHONE, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM address WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -776,16 +776,16 @@ abstract class AddressQuery extends ModelCriteria } /** - * Filter the query on the default column + * Filter the query on the is_default column * * Example usage: * - * $query->filterByDefault(1234); // WHERE default = 1234 - * $query->filterByDefault(array(12, 34)); // WHERE default IN (12, 34) - * $query->filterByDefault(array('min' => 12)); // WHERE default > 12 + * $query->filterByIsDefault(1234); // WHERE is_default = 1234 + * $query->filterByIsDefault(array(12, 34)); // WHERE is_default IN (12, 34) + * $query->filterByIsDefault(array('min' => 12)); // WHERE is_default > 12 * * - * @param mixed $default The value to use as filter. + * @param mixed $isDefault 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. @@ -793,16 +793,16 @@ abstract class AddressQuery extends ModelCriteria * * @return ChildAddressQuery The current query, for fluid interface */ - public function filterByDefault($default = null, $comparison = null) + public function filterByIsDefault($isDefault = null, $comparison = null) { - if (is_array($default)) { + if (is_array($isDefault)) { $useMinMax = false; - if (isset($default['min'])) { - $this->addUsingAlias(AddressTableMap::DEFAULT, $default['min'], Criteria::GREATER_EQUAL); + if (isset($isDefault['min'])) { + $this->addUsingAlias(AddressTableMap::IS_DEFAULT, $isDefault['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($default['max'])) { - $this->addUsingAlias(AddressTableMap::DEFAULT, $default['max'], Criteria::LESS_EQUAL); + if (isset($isDefault['max'])) { + $this->addUsingAlias(AddressTableMap::IS_DEFAULT, $isDefault['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -813,7 +813,7 @@ abstract class AddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressTableMap::DEFAULT, $default, $comparison); + return $this->addUsingAlias(AddressTableMap::IS_DEFAULT, $isDefault, $comparison); } /** diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index a6bd5f07c..38bdc1dab 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -15,6 +15,7 @@ use Thelia\Core\Security\User\UserInterface; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Propel; use Thelia\Model\Map\CustomerTableMap; +use Thelia\Core\Security\Role\Role; /** * Skeleton subclass for representing a row from the 'customer' table. @@ -87,7 +88,7 @@ class Customer extends BaseCustomer implements UserInterface ->setCellphone($cellphone) ->setZipcode($zipcode) ->setCountryId($countryId) - ->setDefault(1) + ->setIsDefault(1) ->setCustomer($this) ->save($con); @@ -114,7 +115,7 @@ class Customer extends BaseCustomer implements UserInterface protected function generateRef() { - return date("YmdHI"); + return date("YmdHisu"); } public function setPassword($password) diff --git a/core/lib/Thelia/Model/Map/AddressTableMap.php b/core/lib/Thelia/Model/Map/AddressTableMap.php index 5a360f08e..a67d383fb 100755 --- a/core/lib/Thelia/Model/Map/AddressTableMap.php +++ b/core/lib/Thelia/Model/Map/AddressTableMap.php @@ -145,9 +145,9 @@ class AddressTableMap extends TableMap const CELLPHONE = 'address.CELLPHONE'; /** - * the column name for the DEFAULT field + * the column name for the IS_DEFAULT field */ - const DEFAULT = 'address.DEFAULT'; + const IS_DEFAULT = 'address.IS_DEFAULT'; /** * the column name for the CREATED_AT field @@ -171,11 +171,11 @@ class AddressTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Title', 'CustomerId', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'Default', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'title', 'customerId', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'default', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AddressTableMap::ID, AddressTableMap::TITLE, AddressTableMap::CUSTOMER_ID, AddressTableMap::CUSTOMER_TITLE_ID, AddressTableMap::COMPANY, AddressTableMap::FIRSTNAME, AddressTableMap::LASTNAME, AddressTableMap::ADDRESS1, AddressTableMap::ADDRESS2, AddressTableMap::ADDRESS3, AddressTableMap::ZIPCODE, AddressTableMap::CITY, AddressTableMap::COUNTRY_ID, AddressTableMap::PHONE, AddressTableMap::CELLPHONE, AddressTableMap::DEFAULT, AddressTableMap::CREATED_AT, AddressTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'TITLE', 'CUSTOMER_ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'title', 'customer_id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'default', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'Title', 'CustomerId', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'IsDefault', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'title', 'customerId', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'isDefault', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AddressTableMap::ID, AddressTableMap::TITLE, AddressTableMap::CUSTOMER_ID, AddressTableMap::CUSTOMER_TITLE_ID, AddressTableMap::COMPANY, AddressTableMap::FIRSTNAME, AddressTableMap::LASTNAME, AddressTableMap::ADDRESS1, AddressTableMap::ADDRESS2, AddressTableMap::ADDRESS3, AddressTableMap::ZIPCODE, AddressTableMap::CITY, AddressTableMap::COUNTRY_ID, AddressTableMap::PHONE, AddressTableMap::CELLPHONE, AddressTableMap::IS_DEFAULT, AddressTableMap::CREATED_AT, AddressTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'TITLE', 'CUSTOMER_ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'title', 'customer_id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'is_default', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); @@ -186,11 +186,11 @@ class AddressTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Title' => 1, 'CustomerId' => 2, 'CustomerTitleId' => 3, 'Company' => 4, 'Firstname' => 5, 'Lastname' => 6, 'Address1' => 7, 'Address2' => 8, 'Address3' => 9, 'Zipcode' => 10, 'City' => 11, 'CountryId' => 12, 'Phone' => 13, 'Cellphone' => 14, 'Default' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'title' => 1, 'customerId' => 2, 'customerTitleId' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'countryId' => 12, 'phone' => 13, 'cellphone' => 14, 'default' => 15, 'createdAt' => 16, 'updatedAt' => 17, ), - self::TYPE_COLNAME => array(AddressTableMap::ID => 0, AddressTableMap::TITLE => 1, AddressTableMap::CUSTOMER_ID => 2, AddressTableMap::CUSTOMER_TITLE_ID => 3, AddressTableMap::COMPANY => 4, AddressTableMap::FIRSTNAME => 5, AddressTableMap::LASTNAME => 6, AddressTableMap::ADDRESS1 => 7, AddressTableMap::ADDRESS2 => 8, AddressTableMap::ADDRESS3 => 9, AddressTableMap::ZIPCODE => 10, AddressTableMap::CITY => 11, AddressTableMap::COUNTRY_ID => 12, AddressTableMap::PHONE => 13, AddressTableMap::CELLPHONE => 14, AddressTableMap::DEFAULT => 15, AddressTableMap::CREATED_AT => 16, AddressTableMap::UPDATED_AT => 17, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'TITLE' => 1, 'CUSTOMER_ID' => 2, 'CUSTOMER_TITLE_ID' => 3, 'COMPANY' => 4, 'FIRSTNAME' => 5, 'LASTNAME' => 6, 'ADDRESS1' => 7, 'ADDRESS2' => 8, 'ADDRESS3' => 9, 'ZIPCODE' => 10, 'CITY' => 11, 'COUNTRY_ID' => 12, 'PHONE' => 13, 'CELLPHONE' => 14, 'DEFAULT' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ), - self::TYPE_FIELDNAME => array('id' => 0, 'title' => 1, 'customer_id' => 2, 'customer_title_id' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'country_id' => 12, 'phone' => 13, 'cellphone' => 14, 'default' => 15, 'created_at' => 16, 'updated_at' => 17, ), + self::TYPE_PHPNAME => array('Id' => 0, 'Title' => 1, 'CustomerId' => 2, 'CustomerTitleId' => 3, 'Company' => 4, 'Firstname' => 5, 'Lastname' => 6, 'Address1' => 7, 'Address2' => 8, 'Address3' => 9, 'Zipcode' => 10, 'City' => 11, 'CountryId' => 12, 'Phone' => 13, 'Cellphone' => 14, 'IsDefault' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'title' => 1, 'customerId' => 2, 'customerTitleId' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'countryId' => 12, 'phone' => 13, 'cellphone' => 14, 'isDefault' => 15, 'createdAt' => 16, 'updatedAt' => 17, ), + self::TYPE_COLNAME => array(AddressTableMap::ID => 0, AddressTableMap::TITLE => 1, AddressTableMap::CUSTOMER_ID => 2, AddressTableMap::CUSTOMER_TITLE_ID => 3, AddressTableMap::COMPANY => 4, AddressTableMap::FIRSTNAME => 5, AddressTableMap::LASTNAME => 6, AddressTableMap::ADDRESS1 => 7, AddressTableMap::ADDRESS2 => 8, AddressTableMap::ADDRESS3 => 9, AddressTableMap::ZIPCODE => 10, AddressTableMap::CITY => 11, AddressTableMap::COUNTRY_ID => 12, AddressTableMap::PHONE => 13, AddressTableMap::CELLPHONE => 14, AddressTableMap::IS_DEFAULT => 15, AddressTableMap::CREATED_AT => 16, AddressTableMap::UPDATED_AT => 17, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'TITLE' => 1, 'CUSTOMER_ID' => 2, 'CUSTOMER_TITLE_ID' => 3, 'COMPANY' => 4, 'FIRSTNAME' => 5, 'LASTNAME' => 6, 'ADDRESS1' => 7, 'ADDRESS2' => 8, 'ADDRESS3' => 9, 'ZIPCODE' => 10, 'CITY' => 11, 'COUNTRY_ID' => 12, 'PHONE' => 13, 'CELLPHONE' => 14, 'IS_DEFAULT' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ), + self::TYPE_FIELDNAME => array('id' => 0, 'title' => 1, 'customer_id' => 2, 'customer_title_id' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'country_id' => 12, 'phone' => 13, 'cellphone' => 14, 'is_default' => 15, 'created_at' => 16, 'updated_at' => 17, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); @@ -225,7 +225,7 @@ class AddressTableMap extends TableMap $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null); $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null); $this->addColumn('CELLPHONE', 'Cellphone', 'VARCHAR', false, 20, null); - $this->addColumn('DEFAULT', 'Default', 'TINYINT', false, null, 0); + $this->addColumn('IS_DEFAULT', 'IsDefault', 'TINYINT', false, null, 0); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -405,7 +405,7 @@ class AddressTableMap extends TableMap $criteria->addSelectColumn(AddressTableMap::COUNTRY_ID); $criteria->addSelectColumn(AddressTableMap::PHONE); $criteria->addSelectColumn(AddressTableMap::CELLPHONE); - $criteria->addSelectColumn(AddressTableMap::DEFAULT); + $criteria->addSelectColumn(AddressTableMap::IS_DEFAULT); $criteria->addSelectColumn(AddressTableMap::CREATED_AT); $criteria->addSelectColumn(AddressTableMap::UPDATED_AT); } else { @@ -424,7 +424,7 @@ class AddressTableMap extends TableMap $criteria->addSelectColumn($alias . '.COUNTRY_ID'); $criteria->addSelectColumn($alias . '.PHONE'); $criteria->addSelectColumn($alias . '.CELLPHONE'); - $criteria->addSelectColumn($alias . '.DEFAULT'); + $criteria->addSelectColumn($alias . '.IS_DEFAULT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index ae30d7280..4f8480eab 100644 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -27,19 +27,30 @@ use Thelia\Model\ConfigQuery; class URL { + public static function getIndexPage() { + return ConfigQuery::read('base_url', '/') . "index_dev.php"; // FIXME ! + } + /** - * Returns the Absolute URL for a given path relative to web root + * Returns the Absolute URL for a given path relative to web root. By default, + * the index.php (or index_dev.php) script name is added to the URL, use + * $path_only = true to get a path without the index script. * - * @param string $path the relative path - * @param mixed $parameters An array of parameters + * @param string $path the relative path + * @param array $parameters An array of parameters + * @param boolean $path_only if true, getIndexPage() will not be added * * @return string The generated URL */ - public static function absoluteUrl($path, array $parameters = array()) + public static function absoluteUrl($path, array $parameters = array(), $path_only = false) { // Already absolute ? - if (substr($path, 0, 4) != 'http') - $base = ConfigQuery::read('base_url', '/') . ltrim($path, '/'); + if (substr($path, 0, 4) != 'http') { + + $root = $path_only ? ConfigQuery::read('base_url', '/') : self::getIndexPage(); + + $base = $root . $path; + } else $base = $path; @@ -49,7 +60,9 @@ class URL $queryString = sprintf("%s=%s&", urlencode($name), urlencode($value)); } - if ('' !== $queryString = rtrim($queryString, "&")) $queryString = '?' . $queryString; + $sepChar = strstr($base, '?') === false ? '?' : '&'; + + if ('' !== $queryString = rtrim($queryString, "&")) $queryString = $sepChar . $queryString; return $base . $queryString; } @@ -63,7 +76,8 @@ class URL * @return string The generated URL */ public static function viewUrl($viewName, array $parameters = array()) { - $path = sprintf("%s?view=%s", ConfigQuery::read('base_url', '/'), $viewName); + + $path = sprintf("%s?view=%s", self::getIndexPage(), $viewName); return self::absoluteUrl($path, $parameters); } diff --git a/install/INSTALL-TODO.txt b/install/INSTALL-TODO.txt index 91662f2b7..772946a7c 100644 --- a/install/INSTALL-TODO.txt +++ b/install/INSTALL-TODO.txt @@ -7,3 +7,4 @@ Variables Config à initialiser: - base_admin_template : chemin du template admin relatif au repertoire template (ex. admin/default) - default_locale : la locale par défaut (ex. en_US), à utiliser pour les fichiers de traduction - asset_dir_from_web_root : le chemin relatif à /web du repertoires des assets (ex. assets) +- active_template: chemin du template front relatif au repertoire template (ex. default) diff --git a/install/thelia.sql b/install/thelia.sql index c7d750778..36b041e11 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -491,7 +491,7 @@ CREATE TABLE `address` `country_id` INTEGER NOT NULL, `phone` VARCHAR(20), `cellphone` VARCHAR(20), - `default` TINYINT DEFAULT 0, + `is_default` TINYINT DEFAULT 0, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), diff --git a/local/config/schema.xml b/local/config/schema.xml index 4b9b99de6..7c005fd56 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1,927 +1,927 @@ - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - - - - - - - -
-
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + +
+
diff --git a/templates/admin/default/home.html b/templates/admin/default/home.html index 79266eadb..ebd61a7d1 100755 --- a/templates/admin/default/home.html +++ b/templates/admin/default/home.html @@ -1,4 +1,4 @@ -{check_auth context="admin" roles="ROLE_ADMIN" login_url="login"} +{check_auth context="admin" roles="ROLE_ADMIN" login_tpl="/admin/login"} {$page_title={intl l='Home'}} {include file='includes/header.inc.html'} diff --git a/templates/admin/default/login.html b/templates/admin/default/login.html index 1f8146993..782073640 100755 --- a/templates/admin/default/login.html +++ b/templates/admin/default/login.html @@ -14,14 +14,14 @@

{intl l='Thelia Back Office'}

{form name="thelia.admin.login" success_url="home" error_url="login"} - + {if isset($message)}
{$message}
{/if} {form_hidden_fields form=$form} {form_field form=$form field='success_url'} - {* on success, redirect to /admin *} + {* on success, redirect to /admin *} {/form_field} {form_field form=$form field='username'} diff --git a/templates/smarty-sample/assets/bootstrap/css/bootstrap-responsive.css b/templates/default/assets/bootstrap/css/bootstrap-responsive.css similarity index 100% rename from templates/smarty-sample/assets/bootstrap/css/bootstrap-responsive.css rename to templates/default/assets/bootstrap/css/bootstrap-responsive.css diff --git a/templates/smarty-sample/assets/bootstrap/css/bootstrap-responsive.min.css b/templates/default/assets/bootstrap/css/bootstrap-responsive.min.css similarity index 100% rename from templates/smarty-sample/assets/bootstrap/css/bootstrap-responsive.min.css rename to templates/default/assets/bootstrap/css/bootstrap-responsive.min.css diff --git a/templates/smarty-sample/assets/bootstrap/css/bootstrap.css b/templates/default/assets/bootstrap/css/bootstrap.css similarity index 100% rename from templates/smarty-sample/assets/bootstrap/css/bootstrap.css rename to templates/default/assets/bootstrap/css/bootstrap.css diff --git a/templates/smarty-sample/assets/bootstrap/css/bootstrap.min.css b/templates/default/assets/bootstrap/css/bootstrap.min.css similarity index 100% rename from templates/smarty-sample/assets/bootstrap/css/bootstrap.min.css rename to templates/default/assets/bootstrap/css/bootstrap.min.css diff --git a/templates/smarty-sample/assets/bootstrap/img/glyphicons-halflings-white.png b/templates/default/assets/bootstrap/img/glyphicons-halflings-white.png similarity index 100% rename from templates/smarty-sample/assets/bootstrap/img/glyphicons-halflings-white.png rename to templates/default/assets/bootstrap/img/glyphicons-halflings-white.png diff --git a/templates/smarty-sample/assets/bootstrap/img/glyphicons-halflings.png b/templates/default/assets/bootstrap/img/glyphicons-halflings.png similarity index 100% rename from templates/smarty-sample/assets/bootstrap/img/glyphicons-halflings.png rename to templates/default/assets/bootstrap/img/glyphicons-halflings.png diff --git a/templates/smarty-sample/assets/bootstrap/js/bootstrap.js b/templates/default/assets/bootstrap/js/bootstrap.js similarity index 100% rename from templates/smarty-sample/assets/bootstrap/js/bootstrap.js rename to templates/default/assets/bootstrap/js/bootstrap.js diff --git a/templates/smarty-sample/assets/bootstrap/js/bootstrap.min.js b/templates/default/assets/bootstrap/js/bootstrap.min.js similarity index 100% rename from templates/smarty-sample/assets/bootstrap/js/bootstrap.min.js rename to templates/default/assets/bootstrap/js/bootstrap.min.js diff --git a/templates/smarty-sample/assets/css/img/bg.jpg b/templates/default/assets/css/img/bg.jpg similarity index 100% rename from templates/smarty-sample/assets/css/img/bg.jpg rename to templates/default/assets/css/img/bg.jpg diff --git a/templates/smarty-sample/assets/css/style.less b/templates/default/assets/css/style.less similarity index 100% rename from templates/smarty-sample/assets/css/style.less rename to templates/default/assets/css/style.less diff --git a/templates/smarty-sample/assets/img/logo-thelia-34px.png b/templates/default/assets/img/logo-thelia-34px.png similarity index 100% rename from templates/smarty-sample/assets/img/logo-thelia-34px.png rename to templates/default/assets/img/logo-thelia-34px.png diff --git a/templates/smarty-sample/assets/img/test-background.jpg b/templates/default/assets/img/test-background.jpg similarity index 100% rename from templates/smarty-sample/assets/img/test-background.jpg rename to templates/default/assets/img/test-background.jpg diff --git a/templates/smarty-sample/assets/js/jquery.min.js b/templates/default/assets/js/jquery.min.js similarity index 100% rename from templates/smarty-sample/assets/js/jquery.min.js rename to templates/default/assets/js/jquery.min.js diff --git a/templates/smarty-sample/category.html b/templates/default/category.html similarity index 100% rename from templates/smarty-sample/category.html rename to templates/default/category.html diff --git a/templates/smarty-sample/connexion.html b/templates/default/connexion.html similarity index 80% rename from templates/smarty-sample/connexion.html rename to templates/default/connexion.html index a2f9120dd..e5d8641cf 100755 --- a/templates/smarty-sample/connexion.html +++ b/templates/default/connexion.html @@ -1,7 +1,31 @@ {include file="includes/header.html"} {form name="thelia.customer.creation"} - +{* We use $index_page as form action to avoid mixing post and get data *} + + {* + The two fields below are not par of the Login form, they are here to defines + the action to process, and the view to render once the form is submited + *} + {* the action triggered by this form *} + {* the view to return to if the form cannot be validated *} + + {* + This field is common to all BaseForm instances (thus, this one), and defines + the URL the customer is redirected to once the form has been successfully + processed + *} + + {form_field form=$form field='success_url'} + {* the url the user is redirected to on login success *} + {/form_field} + + {* + customer_creation_error_message is defined in Customer action processor class, + and passed the parser through the ParserContext service. + *} + + {if isset($customer_creation_error_message)}
{$customer_creation_error_message}
{/if} {form_hidden_fields form=$form} diff --git a/templates/smarty-sample/i18n/en.php b/templates/default/i18n/en.php similarity index 100% rename from templates/smarty-sample/i18n/en.php rename to templates/default/i18n/en.php diff --git a/templates/smarty-sample/i18n/fr.php b/templates/default/i18n/fr.php similarity index 100% rename from templates/smarty-sample/i18n/fr.php rename to templates/default/i18n/fr.php diff --git a/templates/default/include1.html b/templates/default/include1.html deleted file mode 100755 index c4e876fb4..000000000 --- a/templates/default/include1.html +++ /dev/null @@ -1,2 +0,0 @@ -include 1 success
-#INCLUDE "subinclude1.html" diff --git a/templates/smarty-sample/included.html b/templates/default/included.html similarity index 100% rename from templates/smarty-sample/included.html rename to templates/default/included.html diff --git a/templates/smarty-sample/includes/footer.html b/templates/default/includes/footer.html similarity index 100% rename from templates/smarty-sample/includes/footer.html rename to templates/default/includes/footer.html diff --git a/templates/smarty-sample/includes/footer.inc.tpl b/templates/default/includes/footer.inc.tpl similarity index 100% rename from templates/smarty-sample/includes/footer.inc.tpl rename to templates/default/includes/footer.inc.tpl diff --git a/templates/default/includes/header.html b/templates/default/includes/header.html new file mode 100755 index 000000000..e18f75232 --- /dev/null +++ b/templates/default/includes/header.html @@ -0,0 +1,25 @@ + + + + {$page_title|default:{intl l="Thelia II"}} + + + {stylesheets file='../assets/css/*' filters='less,cssembed'} + + {/stylesheets} + + +
+{loop type="auth" name="customer_info_block" roles="ROLE_CUSTOMER" context="front"} +

Your are logged in ! Logout

+{/loop} + +{loop type="auth" name="admin_info_block" roles="ROLE_ADMIN" context="admin"} +

You are logged as administrator

+{/loop} + +{elseloop rel="customer_info_block"} +You are not logged in. Login now or create your account +{/elseloop} +
+
\ No newline at end of file diff --git a/templates/smarty-sample/includes/header.inc.tpl b/templates/default/includes/header.inc.tpl similarity index 100% rename from templates/smarty-sample/includes/header.inc.tpl rename to templates/default/includes/header.inc.tpl diff --git a/templates/smarty-sample/includes/menu.tpl b/templates/default/includes/menu.tpl similarity index 100% rename from templates/smarty-sample/includes/menu.tpl rename to templates/default/includes/menu.tpl diff --git a/templates/default/index.html b/templates/default/index.html index 0023dd36b..6ee109b9e 100755 --- a/templates/default/index.html +++ b/templates/default/index.html @@ -1,26 +1,151 @@ - - - - - - - -
TODO write content
- - #__COUNT__ - #TITLE
- nb child : #NB_CHILD

-
+{include file="includes/header.html"} +
- - test vrai - - test faux - -
- - Compteur = #INDEX
-
+{loop type="auth" name="auth_test" context="front" roles="ROLE_CUSTOMER"} -
- - +

Customer is authentified :-)

+{/loop} + +{elseloop rel="auth_test"} +

Customer is not authentified :-(

+{/elseloop} + +An image from asset directory : +{images file='assets/img/logo-thelia-34px.png'}{intl l='Thelia, solution e-commerce libre'}{/images} +
+ +
+{intl l='An internationalized string'} +
+ + +
+ jQuery data: +
+ +
+

Category loop example

+
    + {loop type="category" name="catloop1"} +
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}, children: {$NB_CHILD} + {ifloop rel="inner1"} +
      + {loop type="category" name="inner1" parent="{$ID}"} +
    • Sub cat {$ID} (parent is {$PARENT}): {$TITLE}
    • + {/loop} +
    + {/ifloop} +
  • + {/loop} +
+
+ + + + +
+

Conditional example #1

+ + {ifloop rel="catloop2"} + Hey ! Loop catloop2 is not empty: +
    + {loop type="category" name="catloop2" parent="12"} +
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • + {/loop} +
+ {/ifloop} + + {elseloop rel="catloop2"} +

Loop catloop2 is empty

+ {/elseloop} +
+ +
+

Conditional example #2

+ + {ifloop rel="catloop3"} + Loop catloop3 is not empty: +
    + {loop type="category" name="catloop3" parent="0"} +
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • + {/loop} +
+ {/ifloop} + + {elseloop rel="catloop3"} +

Loop catloop3 is empty

+ {/elseloop} + + {elseloop rel="catloop2"} +

... but catloop2 is still empty :-)

+ {/elseloop} + +
+ +
+

Traditional for loop

+ {for $index=5 to 12 step 1} + Compteur = {$index}
+ {/for} +
+ + + +
+

Some pagination

+

PAGE 1

+
    + {loop type="category" name="catloopwithpagination1" limit="2" page="1"} +
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • + {/loop} +
+

PAGE 2

+
    + {loop type="category" name="catloopwithpagination2" limit="2" page="2"} +
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • + {/loop} +
+

PAGE 1000

+
    + + {loop type="category" name="catloopwithpagination1000" limit="2" page="1000"} +
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • + {/loop} + + {elseloop rel="catloopwithpagination1000"} + NO RESULTS + {/elseloop} +
+
+ +
+

Some pagination with page choice

+ {assign var=current_page value=2} +

PAGE {$current_page} :

+
    + {loop type="category" name="catloopwithpaginationchoice" limit="2" page="{$current_page}"} +
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • + {/loop} +
+

page choice

+ {pageloop rel="catloopwithpaginationchoice"} + {if ${PAGE} != {$current_page}} + {if {$PAGE} > {$current_page}-10 AND {$PAGE} < {$current_page}+10} + {$PAGE} + {/if} + {if {$PAGE} == {$current_page}-10 OR {$PAGE} == {$current_page}+10} + ... + {/if} + {if ({$PAGE} < {$current_page}-10 OR {$PAGE} > {$current_page}+10) AND ({$PAGE}%10 == 0 OR ${PAGE} == {$LAST} OR ${PAGE} == 1)} + {$PAGE} + {/if} + {else} + { {$PAGE} } + {/if} + {if {$PAGE} != {$LAST}} + - + {/if} + {/pageloop} +
+ +{include file="includes/footer.html"} \ No newline at end of file diff --git a/templates/default/login.html b/templates/default/login.html new file mode 100644 index 000000000..4e17a86aa --- /dev/null +++ b/templates/default/login.html @@ -0,0 +1,52 @@ +{include file="includes/header.html"} + +

{intl l='Please login'}

+ +{form name="thelia.customer.login" } +{* We use $index_page as form action to avoid mixing post and get data *} + + + {* + The two fields below are not par of the Login form, they are here to defines + the action to process, and the view to render once the form is submited + *} + {* the action triggered by this form *} + {* the view to return to if the form cannot be validated *} + + {* + This field is common to all BaseForm instances (thus, this one), and defines + the URL the customer is redirected to once the form has been successfully + processed + *} + + {form_field form=$form field='success_url'} + {* the url the user is redirected to on login success *} + {/form_field} + + {* + customer_login_error_message is defined in Customer action processor class, + and passed the parser through the ParserContext service. + *} + + {if isset($customer_login_error_message)}
{$customer_login_error_message}
{/if} + + {form_hidden_fields form=$form} + + {form_field form=$form field="email"} + {if #error}{#message}{/if} +
+ {/form_field} + + {form_field form=$form field='password'} +
+ {/form_field} + + {form_field form=$form field='remember_me'} + + {/form_field} + + + +{/form} + +{include file='includes/footer.html'} \ No newline at end of file diff --git a/templates/default/myaccount.html b/templates/default/myaccount.html new file mode 100644 index 000000000..2b712f71d --- /dev/null +++ b/templates/default/myaccount.html @@ -0,0 +1,6 @@ +{check_auth context="front" roles="ROLE_CUSTOMER" login_tpl="login"} + +{$page_title="{intl l='My Account'}"} + +{include file="includes/header.html"} +{include file="includes/footer.html"} diff --git a/templates/smarty-sample/pagination.html b/templates/default/pagination.html similarity index 100% rename from templates/smarty-sample/pagination.html rename to templates/default/pagination.html diff --git a/templates/default/subinclude1.html b/templates/default/subinclude1.html deleted file mode 100755 index d777eec92..000000000 --- a/templates/default/subinclude1.html +++ /dev/null @@ -1 +0,0 @@ -subinclude1 success \ No newline at end of file diff --git a/templates/smarty-sample/includes/header.html b/templates/smarty-sample/includes/header.html deleted file mode 100755 index b48cbc770..000000000 --- a/templates/smarty-sample/includes/header.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - {$page_title|default:{intl l="Thelia II"}} - - - {stylesheets file='../assets/css/*' filters='less,cssembed'} - - {/stylesheets} - - \ No newline at end of file diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html deleted file mode 100755 index 6ee109b9e..000000000 --- a/templates/smarty-sample/index.html +++ /dev/null @@ -1,151 +0,0 @@ -{include file="includes/header.html"} -
- -{loop type="auth" name="auth_test" context="front" roles="ROLE_CUSTOMER"} - -

Customer is authentified :-)

-{/loop} - -{elseloop rel="auth_test"} -

Customer is not authentified :-(

-{/elseloop} - -An image from asset directory : -{images file='assets/img/logo-thelia-34px.png'}{intl l='Thelia, solution e-commerce libre'}{/images} -
- -
-{intl l='An internationalized string'} -
- - -
- jQuery data: -
- -
-

Category loop example

-
    - {loop type="category" name="catloop1"} -
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}, children: {$NB_CHILD} - {ifloop rel="inner1"} -
      - {loop type="category" name="inner1" parent="{$ID}"} -
    • Sub cat {$ID} (parent is {$PARENT}): {$TITLE}
    • - {/loop} -
    - {/ifloop} -
  • - {/loop} -
-
- - - - -
-

Conditional example #1

- - {ifloop rel="catloop2"} - Hey ! Loop catloop2 is not empty: -
    - {loop type="category" name="catloop2" parent="12"} -
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • - {/loop} -
- {/ifloop} - - {elseloop rel="catloop2"} -

Loop catloop2 is empty

- {/elseloop} -
- -
-

Conditional example #2

- - {ifloop rel="catloop3"} - Loop catloop3 is not empty: -
    - {loop type="category" name="catloop3" parent="0"} -
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • - {/loop} -
- {/ifloop} - - {elseloop rel="catloop3"} -

Loop catloop3 is empty

- {/elseloop} - - {elseloop rel="catloop2"} -

... but catloop2 is still empty :-)

- {/elseloop} - -
- -
-

Traditional for loop

- {for $index=5 to 12 step 1} - Compteur = {$index}
- {/for} -
- - - -
-

Some pagination

-

PAGE 1

-
    - {loop type="category" name="catloopwithpagination1" limit="2" page="1"} -
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • - {/loop} -
-

PAGE 2

-
    - {loop type="category" name="catloopwithpagination2" limit="2" page="2"} -
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • - {/loop} -
-

PAGE 1000

-
    - - {loop type="category" name="catloopwithpagination1000" limit="2" page="1000"} -
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • - {/loop} - - {elseloop rel="catloopwithpagination1000"} - NO RESULTS - {/elseloop} -
-
- -
-

Some pagination with page choice

- {assign var=current_page value=2} -

PAGE {$current_page} :

-
    - {loop type="category" name="catloopwithpaginationchoice" limit="2" page="{$current_page}"} -
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • - {/loop} -
-

page choice

- {pageloop rel="catloopwithpaginationchoice"} - {if ${PAGE} != {$current_page}} - {if {$PAGE} > {$current_page}-10 AND {$PAGE} < {$current_page}+10} - {$PAGE} - {/if} - {if {$PAGE} == {$current_page}-10 OR {$PAGE} == {$current_page}+10} - ... - {/if} - {if ({$PAGE} < {$current_page}-10 OR {$PAGE} > {$current_page}+10) AND ({$PAGE}%10 == 0 OR ${PAGE} == {$LAST} OR ${PAGE} == 1)} - {$PAGE} - {/if} - {else} - { {$PAGE} } - {/if} - {if {$PAGE} != {$LAST}} - - - {/if} - {/pageloop} -
- -{include file="includes/footer.html"} \ No newline at end of file From 10bf529f59cf8a378ef4a219d1476fafbbfae320 Mon Sep 17 00:00:00 2001 From: franck Date: Wed, 17 Jul 2013 19:02:33 +0200 Subject: [PATCH 32/36] Removed obsolete templates --- templates/default/includes/footer.inc.tpl | 13 ------------- templates/default/includes/header.inc.tpl | 21 --------------------- templates/default/includes/menu.tpl | 0 3 files changed, 34 deletions(-) delete mode 100755 templates/default/includes/footer.inc.tpl delete mode 100755 templates/default/includes/header.inc.tpl delete mode 100755 templates/default/includes/menu.tpl diff --git a/templates/default/includes/footer.inc.tpl b/templates/default/includes/footer.inc.tpl deleted file mode 100755 index 3d0e58427..000000000 --- a/templates/default/includes/footer.inc.tpl +++ /dev/null @@ -1,13 +0,0 @@ - {* Include required JS files *} - - {javascripts file='../assets/js/jquery.min.js'} - - {/javascripts} - - {javascripts file='../assets/bootstrap/js/bootstrap.min.js'} - - {/javascripts} - - {* TODO allow modules to include JS here *} - - \ No newline at end of file diff --git a/templates/default/includes/header.inc.tpl b/templates/default/includes/header.inc.tpl deleted file mode 100755 index b1ddcf952..000000000 --- a/templates/default/includes/header.inc.tpl +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - {stylesheets file='../assets/css/*' filters='less,cssrewrite'} - - {/stylesheets} - - {stylesheets file='../assets/bootstrap/css/bootstrap.min.css' filters='cssrewrite'} - - {/stylesheets} - - {stylesheets file='../assets/bootstrap/css/bootstrap-responsive.min.css' filters='cssrewrite'} - - {/stylesheets} - - {* TODO allow modules to include CSS here *} - - \ No newline at end of file diff --git a/templates/default/includes/menu.tpl b/templates/default/includes/menu.tpl deleted file mode 100755 index e69de29bb..000000000 From b177367893a50339408c62134f68777fc3c6bf5d Mon Sep 17 00:00:00 2001 From: franck Date: Thu, 18 Jul 2013 09:32:50 +0200 Subject: [PATCH 33/36] Capitalized template variables (index_page -> INDEX_PAGE) --- core/lib/Thelia/Core/Template/ParserContext.php | 6 +++--- templates/default/connexion.html | 6 +++--- templates/default/login.html | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/lib/Thelia/Core/Template/ParserContext.php b/core/lib/Thelia/Core/Template/ParserContext.php index 8d1d50fdc..e5d635fda 100644 --- a/core/lib/Thelia/Core/Template/ParserContext.php +++ b/core/lib/Thelia/Core/Template/ParserContext.php @@ -40,9 +40,9 @@ class ParserContext implements \IteratorAggregate // Setup basic variables $this - ->set('base_url' , ConfigQuery::read('base_url', '/')) - ->set('index_page' , URL::getIndexPage()) - ->set('return_to_url' , URL::absoluteUrl($request->getSession()->getReturnToUrl())) + ->set('BASE_URL' , ConfigQuery::read('base_url', '/')) + ->set('INDEX_PAGE' , URL::getIndexPage()) + ->set('RETURN_TO_URL' , URL::absoluteUrl($request->getSession()->getReturnToUrl())) ; } diff --git a/templates/default/connexion.html b/templates/default/connexion.html index e5d8641cf..e8a88e655 100755 --- a/templates/default/connexion.html +++ b/templates/default/connexion.html @@ -1,8 +1,8 @@ {include file="includes/header.html"} {form name="thelia.customer.creation"} -{* We use $index_page as form action to avoid mixing post and get data *} -
+{* We use $INDEX_PAGE as form action to avoid mixing post and get data *} + {* The two fields below are not par of the Login form, they are here to defines the action to process, and the view to render once the form is submited @@ -17,7 +17,7 @@ *} {form_field form=$form field='success_url'} - {* the url the user is redirected to on login success *} + {* the url the user is redirected to on login success *} {/form_field} {* diff --git a/templates/default/login.html b/templates/default/login.html index 4e17a86aa..7f79a3b53 100644 --- a/templates/default/login.html +++ b/templates/default/login.html @@ -3,8 +3,8 @@

{intl l='Please login'}

{form name="thelia.customer.login" } -{* We use $index_page as form action to avoid mixing post and get data *} - +{* We use $INDEX_PAGE as form action to avoid mixing post and get data *} + {* The two fields below are not par of the Login form, they are here to defines @@ -20,7 +20,7 @@ *} {form_field form=$form field='success_url'} - {* the url the user is redirected to on login success *} + {* the url the user is redirected to on login success *} {/form_field} {* From 2c52df1034a514440a644cf568ef0adf17b487f5 Mon Sep 17 00:00:00 2001 From: franck Date: Thu, 18 Jul 2013 09:40:21 +0200 Subject: [PATCH 34/36] Added title_id column in customer table --- .../Thelia/Core/Template/ParserContext.php | 9 +- core/lib/Thelia/Model/Base/Customer.php | 248 ++++++++++++---- core/lib/Thelia/Model/Base/CustomerQuery.php | 128 +++++++- core/lib/Thelia/Model/Base/CustomerTitle.php | 273 ++++++++++++++++++ .../Thelia/Model/Base/CustomerTitleQuery.php | 77 +++++ core/lib/Thelia/Model/Customer.php | 1 + .../lib/Thelia/Model/Map/CustomerTableMap.php | 37 ++- .../Model/Map/CustomerTitleTableMap.php | 1 + local/config/schema.xml | 4 + 9 files changed, 706 insertions(+), 72 deletions(-) diff --git a/core/lib/Thelia/Core/Template/ParserContext.php b/core/lib/Thelia/Core/Template/ParserContext.php index e5d635fda..b1574d156 100644 --- a/core/lib/Thelia/Core/Template/ParserContext.php +++ b/core/lib/Thelia/Core/Template/ParserContext.php @@ -46,17 +46,20 @@ class ParserContext implements \IteratorAggregate ; } - public function set($name, $value) { + public function set($name, $value) + { $this->store[$name] = $value; return $this; } - public function get($name) { + public function get($name) + { return $this->store[$name]; } - public function getIterator() { + public function getIterator() + { return new \ArrayIterator( $this->store ); } } diff --git a/core/lib/Thelia/Model/Base/Customer.php b/core/lib/Thelia/Model/Base/Customer.php index b8b3b1f32..71708ab1b 100755 --- a/core/lib/Thelia/Model/Base/Customer.php +++ b/core/lib/Thelia/Model/Base/Customer.php @@ -21,6 +21,8 @@ use Thelia\Model\Address as ChildAddress; use Thelia\Model\AddressQuery as ChildAddressQuery; use Thelia\Model\Customer as ChildCustomer; use Thelia\Model\CustomerQuery as ChildCustomerQuery; +use Thelia\Model\CustomerTitle as ChildCustomerTitle; +use Thelia\Model\CustomerTitleQuery as ChildCustomerTitleQuery; use Thelia\Model\Order as ChildOrder; use Thelia\Model\OrderQuery as ChildOrderQuery; use Thelia\Model\Map\CustomerTableMap; @@ -71,6 +73,12 @@ abstract class Customer implements ActiveRecordInterface */ protected $ref; + /** + * The value for the title_id field. + * @var int + */ + protected $title_id; + /** * The value for the firstname field. * @var string @@ -137,6 +145,11 @@ abstract class Customer implements ActiveRecordInterface */ protected $updated_at; + /** + * @var CustomerTitle + */ + protected $aCustomerTitle; + /** * @var ObjectCollection|ChildAddress[] Collection to store aggregation of ChildAddress objects. */ @@ -445,6 +458,17 @@ abstract class Customer implements ActiveRecordInterface return $this->ref; } + /** + * Get the [title_id] column value. + * + * @return int + */ + public function getTitleId() + { + + return $this->title_id; + } + /** * Get the [firstname] column value. * @@ -626,6 +650,31 @@ abstract class Customer implements ActiveRecordInterface return $this; } // setRef() + /** + * Set the value of [title_id] column. + * + * @param int $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) + */ + public function setTitleId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->title_id !== $v) { + $this->title_id = $v; + $this->modifiedColumns[] = CustomerTableMap::TITLE_ID; + } + + if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) { + $this->aCustomerTitle = null; + } + + + return $this; + } // setTitleId() + /** * Set the value of [firstname] column. * @@ -900,40 +949,43 @@ abstract class Customer implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)]; $this->ref = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerTableMap::translateFieldName('TitleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)]; $this->firstname = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)]; $this->lastname = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CustomerTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)]; $this->email = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CustomerTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CustomerTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)]; $this->password = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CustomerTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CustomerTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)]; $this->algo = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CustomerTableMap::translateFieldName('Reseller', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CustomerTableMap::translateFieldName('Reseller', TableMap::TYPE_PHPNAME, $indexType)]; $this->reseller = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CustomerTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CustomerTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)]; $this->lang = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CustomerTableMap::translateFieldName('Sponsor', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CustomerTableMap::translateFieldName('Sponsor', TableMap::TYPE_PHPNAME, $indexType)]; $this->sponsor = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CustomerTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CustomerTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)]; $this->discount = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CustomerTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CustomerTableMap::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 ? 12 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -946,7 +998,7 @@ abstract class Customer implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 13; // 13 = CustomerTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 14; // 14 = CustomerTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Customer object", 0, $e); @@ -968,6 +1020,9 @@ abstract class Customer implements ActiveRecordInterface */ public function ensureConsistency() { + if ($this->aCustomerTitle !== null && $this->title_id !== $this->aCustomerTitle->getId()) { + $this->aCustomerTitle = null; + } } // ensureConsistency /** @@ -1007,6 +1062,7 @@ abstract class Customer implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? + $this->aCustomerTitle = null; $this->collAddresses = null; $this->collOrders = null; @@ -1133,6 +1189,18 @@ abstract class Customer implements ActiveRecordInterface if (!$this->alreadyInSave) { $this->alreadyInSave = true; + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCustomerTitle !== null) { + if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) { + $affectedRows += $this->aCustomerTitle->save($con); + } + $this->setCustomerTitle($this->aCustomerTitle); + } + if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -1210,6 +1278,9 @@ abstract class Customer implements ActiveRecordInterface if ($this->isColumnModified(CustomerTableMap::REF)) { $modifiedColumns[':p' . $index++] = 'REF'; } + if ($this->isColumnModified(CustomerTableMap::TITLE_ID)) { + $modifiedColumns[':p' . $index++] = 'TITLE_ID'; + } if ($this->isColumnModified(CustomerTableMap::FIRSTNAME)) { $modifiedColumns[':p' . $index++] = 'FIRSTNAME'; } @@ -1260,6 +1331,9 @@ abstract class Customer implements ActiveRecordInterface case 'REF': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; + case 'TITLE_ID': + $stmt->bindValue($identifier, $this->title_id, PDO::PARAM_INT); + break; case 'FIRSTNAME': $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); break; @@ -1362,36 +1436,39 @@ abstract class Customer implements ActiveRecordInterface return $this->getRef(); break; case 2: - return $this->getFirstname(); + return $this->getTitleId(); break; case 3: - return $this->getLastname(); + return $this->getFirstname(); break; case 4: - return $this->getEmail(); + return $this->getLastname(); break; case 5: - return $this->getPassword(); + return $this->getEmail(); break; case 6: - return $this->getAlgo(); + return $this->getPassword(); break; case 7: - return $this->getReseller(); + return $this->getAlgo(); break; case 8: - return $this->getLang(); + return $this->getReseller(); break; case 9: - return $this->getSponsor(); + return $this->getLang(); break; case 10: - return $this->getDiscount(); + return $this->getSponsor(); break; case 11: - return $this->getCreatedAt(); + return $this->getDiscount(); break; case 12: + return $this->getCreatedAt(); + break; + case 13: return $this->getUpdatedAt(); break; default: @@ -1425,17 +1502,18 @@ abstract class Customer implements ActiveRecordInterface $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getRef(), - $keys[2] => $this->getFirstname(), - $keys[3] => $this->getLastname(), - $keys[4] => $this->getEmail(), - $keys[5] => $this->getPassword(), - $keys[6] => $this->getAlgo(), - $keys[7] => $this->getReseller(), - $keys[8] => $this->getLang(), - $keys[9] => $this->getSponsor(), - $keys[10] => $this->getDiscount(), - $keys[11] => $this->getCreatedAt(), - $keys[12] => $this->getUpdatedAt(), + $keys[2] => $this->getTitleId(), + $keys[3] => $this->getFirstname(), + $keys[4] => $this->getLastname(), + $keys[5] => $this->getEmail(), + $keys[6] => $this->getPassword(), + $keys[7] => $this->getAlgo(), + $keys[8] => $this->getReseller(), + $keys[9] => $this->getLang(), + $keys[10] => $this->getSponsor(), + $keys[11] => $this->getDiscount(), + $keys[12] => $this->getCreatedAt(), + $keys[13] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1444,6 +1522,9 @@ abstract class Customer implements ActiveRecordInterface } if ($includeForeignObjects) { + if (null !== $this->aCustomerTitle) { + $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } if (null !== $this->collAddresses) { $result['Addresses'] = $this->collAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1491,36 +1572,39 @@ abstract class Customer implements ActiveRecordInterface $this->setRef($value); break; case 2: - $this->setFirstname($value); + $this->setTitleId($value); break; case 3: - $this->setLastname($value); + $this->setFirstname($value); break; case 4: - $this->setEmail($value); + $this->setLastname($value); break; case 5: - $this->setPassword($value); + $this->setEmail($value); break; case 6: - $this->setAlgo($value); + $this->setPassword($value); break; case 7: - $this->setReseller($value); + $this->setAlgo($value); break; case 8: - $this->setLang($value); + $this->setReseller($value); break; case 9: - $this->setSponsor($value); + $this->setLang($value); break; case 10: - $this->setDiscount($value); + $this->setSponsor($value); break; case 11: - $this->setCreatedAt($value); + $this->setDiscount($value); break; case 12: + $this->setCreatedAt($value); + break; + case 13: $this->setUpdatedAt($value); break; } // switch() @@ -1549,17 +1633,18 @@ abstract class Customer implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setRef($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->setEmail($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPassword($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setAlgo($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setReseller($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setLang($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setSponsor($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setDiscount($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setCreatedAt($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setUpdatedAt($arr[$keys[12]]); + if (array_key_exists($keys[2], $arr)) $this->setTitleId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setFirstname($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setLastname($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setEmail($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setPassword($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setAlgo($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setReseller($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setLang($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setSponsor($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setDiscount($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]); } /** @@ -1573,6 +1658,7 @@ abstract class Customer implements ActiveRecordInterface if ($this->isColumnModified(CustomerTableMap::ID)) $criteria->add(CustomerTableMap::ID, $this->id); if ($this->isColumnModified(CustomerTableMap::REF)) $criteria->add(CustomerTableMap::REF, $this->ref); + if ($this->isColumnModified(CustomerTableMap::TITLE_ID)) $criteria->add(CustomerTableMap::TITLE_ID, $this->title_id); if ($this->isColumnModified(CustomerTableMap::FIRSTNAME)) $criteria->add(CustomerTableMap::FIRSTNAME, $this->firstname); if ($this->isColumnModified(CustomerTableMap::LASTNAME)) $criteria->add(CustomerTableMap::LASTNAME, $this->lastname); if ($this->isColumnModified(CustomerTableMap::EMAIL)) $criteria->add(CustomerTableMap::EMAIL, $this->email); @@ -1648,6 +1734,7 @@ abstract class Customer implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setRef($this->getRef()); + $copyObj->setTitleId($this->getTitleId()); $copyObj->setFirstname($this->getFirstname()); $copyObj->setLastname($this->getLastname()); $copyObj->setEmail($this->getEmail()); @@ -1707,6 +1794,57 @@ abstract class Customer implements ActiveRecordInterface return $copyObj; } + /** + * Declares an association between this object and a ChildCustomerTitle object. + * + * @param ChildCustomerTitle $v + * @return \Thelia\Model\Customer The current object (for fluent API support) + * @throws PropelException + */ + public function setCustomerTitle(ChildCustomerTitle $v = null) + { + if ($v === null) { + $this->setTitleId(NULL); + } else { + $this->setTitleId($v->getId()); + } + + $this->aCustomerTitle = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCustomerTitle object, it will not be re-added. + if ($v !== null) { + $v->addCustomer($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCustomerTitle object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCustomerTitle The associated ChildCustomerTitle object. + * @throws PropelException + */ + public function getCustomerTitle(ConnectionInterface $con = null) + { + if ($this->aCustomerTitle === null && ($this->title_id !== null)) { + $this->aCustomerTitle = ChildCustomerTitleQuery::create()->findPk($this->title_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCustomerTitle->addCustomers($this); + */ + } + + return $this->aCustomerTitle; + } + /** * Initializes a collection based on the name of a relation. @@ -2294,6 +2432,7 @@ abstract class Customer implements ActiveRecordInterface { $this->id = null; $this->ref = null; + $this->title_id = null; $this->firstname = null; $this->lastname = null; $this->email = null; @@ -2344,6 +2483,7 @@ abstract class Customer implements ActiveRecordInterface $this->collOrders->clearIterator(); } $this->collOrders = null; + $this->aCustomerTitle = null; } /** diff --git a/core/lib/Thelia/Model/Base/CustomerQuery.php b/core/lib/Thelia/Model/Base/CustomerQuery.php index 3997cd0b6..16fa65016 100755 --- a/core/lib/Thelia/Model/Base/CustomerQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerQuery.php @@ -23,6 +23,7 @@ use Thelia\Model\Map\CustomerTableMap; * * @method ChildCustomerQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildCustomerQuery orderByRef($order = Criteria::ASC) Order by the ref column + * @method ChildCustomerQuery orderByTitleId($order = Criteria::ASC) Order by the title_id column * @method ChildCustomerQuery orderByFirstname($order = Criteria::ASC) Order by the firstname column * @method ChildCustomerQuery orderByLastname($order = Criteria::ASC) Order by the lastname column * @method ChildCustomerQuery orderByEmail($order = Criteria::ASC) Order by the email column @@ -37,6 +38,7 @@ use Thelia\Model\Map\CustomerTableMap; * * @method ChildCustomerQuery groupById() Group by the id column * @method ChildCustomerQuery groupByRef() Group by the ref column + * @method ChildCustomerQuery groupByTitleId() Group by the title_id column * @method ChildCustomerQuery groupByFirstname() Group by the firstname column * @method ChildCustomerQuery groupByLastname() Group by the lastname column * @method ChildCustomerQuery groupByEmail() Group by the email column @@ -53,6 +55,10 @@ use Thelia\Model\Map\CustomerTableMap; * @method ChildCustomerQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildCustomerQuery innerJoin($relation) Adds a INNER JOIN clause to the query * + * @method ChildCustomerQuery leftJoinCustomerTitle($relationAlias = null) Adds a LEFT JOIN clause to the query using the CustomerTitle relation + * @method ChildCustomerQuery rightJoinCustomerTitle($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerTitle relation + * @method ChildCustomerQuery innerJoinCustomerTitle($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerTitle relation + * * @method ChildCustomerQuery leftJoinAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the Address relation * @method ChildCustomerQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation * @method ChildCustomerQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation @@ -66,6 +72,7 @@ use Thelia\Model\Map\CustomerTableMap; * * @method ChildCustomer findOneById(int $id) Return the first ChildCustomer filtered by the id column * @method ChildCustomer findOneByRef(string $ref) Return the first ChildCustomer filtered by the ref column + * @method ChildCustomer findOneByTitleId(int $title_id) Return the first ChildCustomer filtered by the title_id column * @method ChildCustomer findOneByFirstname(string $firstname) Return the first ChildCustomer filtered by the firstname column * @method ChildCustomer findOneByLastname(string $lastname) Return the first ChildCustomer filtered by the lastname column * @method ChildCustomer findOneByEmail(string $email) Return the first ChildCustomer filtered by the email column @@ -80,6 +87,7 @@ use Thelia\Model\Map\CustomerTableMap; * * @method array findById(int $id) Return ChildCustomer objects filtered by the id column * @method array findByRef(string $ref) Return ChildCustomer objects filtered by the ref column + * @method array findByTitleId(int $title_id) Return ChildCustomer objects filtered by the title_id column * @method array findByFirstname(string $firstname) Return ChildCustomer objects filtered by the firstname column * @method array findByLastname(string $lastname) Return ChildCustomer objects filtered by the lastname column * @method array findByEmail(string $email) Return ChildCustomer objects filtered by the email column @@ -179,7 +187,7 @@ abstract class CustomerQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, REF, FIRSTNAME, LASTNAME, EMAIL, PASSWORD, ALGO, RESELLER, LANG, SPONSOR, DISCOUNT, CREATED_AT, UPDATED_AT FROM customer WHERE ID = :p0'; + $sql = 'SELECT ID, REF, TITLE_ID, FIRSTNAME, LASTNAME, EMAIL, PASSWORD, ALGO, RESELLER, LANG, SPONSOR, DISCOUNT, CREATED_AT, UPDATED_AT FROM customer WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -338,6 +346,49 @@ abstract class CustomerQuery extends ModelCriteria return $this->addUsingAlias(CustomerTableMap::REF, $ref, $comparison); } + /** + * Filter the query on the title_id column + * + * Example usage: + * + * $query->filterByTitleId(1234); // WHERE title_id = 1234 + * $query->filterByTitleId(array(12, 34)); // WHERE title_id IN (12, 34) + * $query->filterByTitleId(array('min' => 12)); // WHERE title_id > 12 + * + * + * @see filterByCustomerTitle() + * + * @param mixed $titleId 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 ChildCustomerQuery The current query, for fluid interface + */ + public function filterByTitleId($titleId = null, $comparison = null) + { + if (is_array($titleId)) { + $useMinMax = false; + if (isset($titleId['min'])) { + $this->addUsingAlias(CustomerTableMap::TITLE_ID, $titleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($titleId['max'])) { + $this->addUsingAlias(CustomerTableMap::TITLE_ID, $titleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CustomerTableMap::TITLE_ID, $titleId, $comparison); + } + /** * Filter the query on the firstname column * @@ -709,6 +760,81 @@ abstract class CustomerQuery extends ModelCriteria return $this->addUsingAlias(CustomerTableMap::UPDATED_AT, $updatedAt, $comparison); } + /** + * Filter the query by a related \Thelia\Model\CustomerTitle object + * + * @param \Thelia\Model\CustomerTitle|ObjectCollection $customerTitle The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCustomerQuery The current query, for fluid interface + */ + public function filterByCustomerTitle($customerTitle, $comparison = null) + { + if ($customerTitle instanceof \Thelia\Model\CustomerTitle) { + return $this + ->addUsingAlias(CustomerTableMap::TITLE_ID, $customerTitle->getId(), $comparison); + } elseif ($customerTitle instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CustomerTableMap::TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCustomerTitle() only accepts arguments of type \Thelia\Model\CustomerTitle or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CustomerTitle relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCustomerQuery The current query, for fluid interface + */ + public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CustomerTitle'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CustomerTitle'); + } + + return $this; + } + + /** + * Use the CustomerTitle relation CustomerTitle object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query + */ + public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCustomerTitle($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery'); + } + /** * Filter the query by a related \Thelia\Model\Address object * diff --git a/core/lib/Thelia/Model/Base/CustomerTitle.php b/core/lib/Thelia/Model/Base/CustomerTitle.php index 459940747..d126839d0 100755 --- a/core/lib/Thelia/Model/Base/CustomerTitle.php +++ b/core/lib/Thelia/Model/Base/CustomerTitle.php @@ -19,6 +19,8 @@ use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Address as ChildAddress; use Thelia\Model\AddressQuery as ChildAddressQuery; +use Thelia\Model\Customer as ChildCustomer; +use Thelia\Model\CustomerQuery as ChildCustomerQuery; use Thelia\Model\CustomerTitle as ChildCustomerTitle; use Thelia\Model\CustomerTitleI18n as ChildCustomerTitleI18n; use Thelia\Model\CustomerTitleI18nQuery as ChildCustomerTitleI18nQuery; @@ -90,6 +92,12 @@ abstract class CustomerTitle implements ActiveRecordInterface */ protected $updated_at; + /** + * @var ObjectCollection|ChildCustomer[] Collection to store aggregation of ChildCustomer objects. + */ + protected $collCustomers; + protected $collCustomersPartial; + /** * @var ObjectCollection|ChildAddress[] Collection to store aggregation of ChildAddress objects. */ @@ -124,6 +132,12 @@ abstract class CustomerTitle implements ActiveRecordInterface */ protected $currentTranslations; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $customersScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -711,6 +725,8 @@ abstract class CustomerTitle implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? + $this->collCustomers = null; + $this->collAddresses = null; $this->collCustomerTitleI18ns = null; @@ -848,6 +864,24 @@ abstract class CustomerTitle implements ActiveRecordInterface $this->resetModified(); } + if ($this->customersScheduledForDeletion !== null) { + if (!$this->customersScheduledForDeletion->isEmpty()) { + foreach ($this->customersScheduledForDeletion as $customer) { + // need to save related object because we set the relation to null + $customer->save($con); + } + $this->customersScheduledForDeletion = null; + } + } + + if ($this->collCustomers !== null) { + foreach ($this->collCustomers as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->addressesScheduledForDeletion !== null) { if (!$this->addressesScheduledForDeletion->isEmpty()) { foreach ($this->addressesScheduledForDeletion as $address) { @@ -1069,6 +1103,9 @@ abstract class CustomerTitle implements ActiveRecordInterface } if ($includeForeignObjects) { + if (null !== $this->collCustomers) { + $result['Customers'] = $this->collCustomers->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collAddresses) { $result['Addresses'] = $this->collAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1242,6 +1279,12 @@ abstract class CustomerTitle implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); + foreach ($this->getCustomers() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCustomer($relObj->copy($deepCopy)); + } + } + foreach ($this->getAddresses() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addAddress($relObj->copy($deepCopy)); @@ -1295,6 +1338,9 @@ abstract class CustomerTitle implements ActiveRecordInterface */ public function initRelation($relationName) { + if ('Customer' == $relationName) { + return $this->initCustomers(); + } if ('Address' == $relationName) { return $this->initAddresses(); } @@ -1303,6 +1349,224 @@ abstract class CustomerTitle implements ActiveRecordInterface } } + /** + * Clears out the collCustomers collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCustomers() + */ + public function clearCustomers() + { + $this->collCustomers = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCustomers collection loaded partially. + */ + public function resetPartialCustomers($v = true) + { + $this->collCustomersPartial = $v; + } + + /** + * Initializes the collCustomers collection. + * + * By default this just sets the collCustomers collection to an empty array (like clearcollCustomers()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCustomers($overrideExisting = true) + { + if (null !== $this->collCustomers && !$overrideExisting) { + return; + } + $this->collCustomers = new ObjectCollection(); + $this->collCustomers->setModel('\Thelia\Model\Customer'); + } + + /** + * Gets an array of ChildCustomer objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildCustomerTitle is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCustomer[] List of ChildCustomer objects + * @throws PropelException + */ + public function getCustomers($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCustomersPartial && !$this->isNew(); + if (null === $this->collCustomers || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCustomers) { + // return empty collection + $this->initCustomers(); + } else { + $collCustomers = ChildCustomerQuery::create(null, $criteria) + ->filterByCustomerTitle($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCustomersPartial && count($collCustomers)) { + $this->initCustomers(false); + + foreach ($collCustomers as $obj) { + if (false == $this->collCustomers->contains($obj)) { + $this->collCustomers->append($obj); + } + } + + $this->collCustomersPartial = true; + } + + $collCustomers->getInternalIterator()->rewind(); + + return $collCustomers; + } + + if ($partial && $this->collCustomers) { + foreach ($this->collCustomers as $obj) { + if ($obj->isNew()) { + $collCustomers[] = $obj; + } + } + } + + $this->collCustomers = $collCustomers; + $this->collCustomersPartial = false; + } + } + + return $this->collCustomers; + } + + /** + * Sets a collection of Customer objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $customers A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCustomerTitle The current object (for fluent API support) + */ + public function setCustomers(Collection $customers, ConnectionInterface $con = null) + { + $customersToDelete = $this->getCustomers(new Criteria(), $con)->diff($customers); + + + $this->customersScheduledForDeletion = $customersToDelete; + + foreach ($customersToDelete as $customerRemoved) { + $customerRemoved->setCustomerTitle(null); + } + + $this->collCustomers = null; + foreach ($customers as $customer) { + $this->addCustomer($customer); + } + + $this->collCustomers = $customers; + $this->collCustomersPartial = false; + + return $this; + } + + /** + * Returns the number of related Customer objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related Customer objects. + * @throws PropelException + */ + public function countCustomers(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCustomersPartial && !$this->isNew(); + if (null === $this->collCustomers || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCustomers) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCustomers()); + } + + $query = ChildCustomerQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCustomerTitle($this) + ->count($con); + } + + return count($this->collCustomers); + } + + /** + * Method called to associate a ChildCustomer object to this object + * through the ChildCustomer foreign key attribute. + * + * @param ChildCustomer $l ChildCustomer + * @return \Thelia\Model\CustomerTitle The current object (for fluent API support) + */ + public function addCustomer(ChildCustomer $l) + { + if ($this->collCustomers === null) { + $this->initCustomers(); + $this->collCustomersPartial = true; + } + + if (!in_array($l, $this->collCustomers->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCustomer($l); + } + + return $this; + } + + /** + * @param Customer $customer The customer object to add. + */ + protected function doAddCustomer($customer) + { + $this->collCustomers[]= $customer; + $customer->setCustomerTitle($this); + } + + /** + * @param Customer $customer The customer object to remove. + * @return ChildCustomerTitle The current object (for fluent API support) + */ + public function removeCustomer($customer) + { + if ($this->getCustomers()->contains($customer)) { + $this->collCustomers->remove($this->collCustomers->search($customer)); + if (null === $this->customersScheduledForDeletion) { + $this->customersScheduledForDeletion = clone $this->collCustomers; + $this->customersScheduledForDeletion->clear(); + } + $this->customersScheduledForDeletion[]= $customer; + $customer->setCustomerTitle(null); + } + + return $this; + } + /** * Clears out the collAddresses collection * @@ -1801,6 +2065,11 @@ abstract class CustomerTitle implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { + if ($this->collCustomers) { + foreach ($this->collCustomers as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collAddresses) { foreach ($this->collAddresses as $o) { $o->clearAllReferences($deep); @@ -1817,6 +2086,10 @@ abstract class CustomerTitle implements ActiveRecordInterface $this->currentLocale = 'en_US'; $this->currentTranslations = null; + if ($this->collCustomers instanceof Collection) { + $this->collCustomers->clearIterator(); + } + $this->collCustomers = null; if ($this->collAddresses instanceof Collection) { $this->collAddresses->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php index 95b2a8326..42ba4bd98 100755 --- a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php @@ -38,6 +38,10 @@ use Thelia\Model\Map\CustomerTitleTableMap; * @method ChildCustomerTitleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildCustomerTitleQuery innerJoin($relation) Adds a INNER JOIN clause to the query * + * @method ChildCustomerTitleQuery leftJoinCustomer($relationAlias = null) Adds a LEFT JOIN clause to the query using the Customer relation + * @method ChildCustomerTitleQuery rightJoinCustomer($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Customer relation + * @method ChildCustomerTitleQuery innerJoinCustomer($relationAlias = null) Adds a INNER JOIN clause to the query using the Customer relation + * * @method ChildCustomerTitleQuery leftJoinAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the Address relation * @method ChildCustomerTitleQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation * @method ChildCustomerTitleQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation @@ -434,6 +438,79 @@ abstract class CustomerTitleQuery extends ModelCriteria return $this->addUsingAlias(CustomerTitleTableMap::UPDATED_AT, $updatedAt, $comparison); } + /** + * Filter the query by a related \Thelia\Model\Customer object + * + * @param \Thelia\Model\Customer|ObjectCollection $customer the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCustomerTitleQuery The current query, for fluid interface + */ + public function filterByCustomer($customer, $comparison = null) + { + if ($customer instanceof \Thelia\Model\Customer) { + return $this + ->addUsingAlias(CustomerTitleTableMap::ID, $customer->getTitleId(), $comparison); + } elseif ($customer instanceof ObjectCollection) { + return $this + ->useCustomerQuery() + ->filterByPrimaryKeys($customer->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCustomer() only accepts arguments of type \Thelia\Model\Customer or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Customer relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCustomerTitleQuery The current query, for fluid interface + */ + public function joinCustomer($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Customer'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Customer'); + } + + return $this; + } + + /** + * Use the Customer relation Customer object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CustomerQuery A secondary query class using the current class as primary query + */ + public function useCustomerQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCustomer($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery'); + } + /** * Filter the query by a related \Thelia\Model\Address object * diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 38bdc1dab..2b58787e0 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -56,6 +56,7 @@ class Customer extends BaseCustomer implements UserInterface public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0) { $this + ->setTitleId($titleId) ->setFirstname($firstname) ->setLastname($lastname) ->setEmail($email) diff --git a/core/lib/Thelia/Model/Map/CustomerTableMap.php b/core/lib/Thelia/Model/Map/CustomerTableMap.php index a86453adc..fbd2a9b98 100755 --- a/core/lib/Thelia/Model/Map/CustomerTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTableMap.php @@ -57,7 +57,7 @@ class CustomerTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 13; + const NUM_COLUMNS = 14; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CustomerTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 13; + const NUM_HYDRATE_COLUMNS = 14; /** * the column name for the ID field @@ -79,6 +79,11 @@ class CustomerTableMap extends TableMap */ const REF = 'customer.REF'; + /** + * the column name for the TITLE_ID field + */ + const TITLE_ID = 'customer.TITLE_ID'; + /** * the column name for the FIRSTNAME field */ @@ -146,12 +151,12 @@ class CustomerTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Ref', 'Firstname', 'Lastname', 'Email', 'Password', 'Algo', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'firstname', 'lastname', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::FIRSTNAME, CustomerTableMap::LASTNAME, CustomerTableMap::EMAIL, CustomerTableMap::PASSWORD, CustomerTableMap::ALGO, CustomerTableMap::RESELLER, CustomerTableMap::LANG, CustomerTableMap::SPONSOR, CustomerTableMap::DISCOUNT, CustomerTableMap::CREATED_AT, CustomerTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'REF', 'FIRSTNAME', 'LASTNAME', 'EMAIL', 'PASSWORD', 'ALGO', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'ref', 'firstname', 'lastname', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) + self::TYPE_PHPNAME => array('Id', 'Ref', 'TitleId', 'Firstname', 'Lastname', 'Email', 'Password', 'Algo', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'titleId', 'firstname', 'lastname', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::TITLE_ID, CustomerTableMap::FIRSTNAME, CustomerTableMap::LASTNAME, CustomerTableMap::EMAIL, CustomerTableMap::PASSWORD, CustomerTableMap::ALGO, CustomerTableMap::RESELLER, CustomerTableMap::LANG, CustomerTableMap::SPONSOR, CustomerTableMap::DISCOUNT, CustomerTableMap::CREATED_AT, CustomerTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'REF', 'TITLE_ID', 'FIRSTNAME', 'LASTNAME', 'EMAIL', 'PASSWORD', 'ALGO', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'ref', 'title_id', 'firstname', 'lastname', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) ); /** @@ -161,12 +166,12 @@ class CustomerTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'Firstname' => 2, 'Lastname' => 3, 'Email' => 4, 'Password' => 5, 'Algo' => 6, 'Reseller' => 7, 'Lang' => 8, 'Sponsor' => 9, 'Discount' => 10, 'CreatedAt' => 11, 'UpdatedAt' => 12, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'firstname' => 2, 'lastname' => 3, 'email' => 4, 'password' => 5, 'algo' => 6, 'reseller' => 7, 'lang' => 8, 'sponsor' => 9, 'discount' => 10, 'createdAt' => 11, 'updatedAt' => 12, ), - self::TYPE_COLNAME => array(CustomerTableMap::ID => 0, CustomerTableMap::REF => 1, CustomerTableMap::FIRSTNAME => 2, CustomerTableMap::LASTNAME => 3, CustomerTableMap::EMAIL => 4, CustomerTableMap::PASSWORD => 5, CustomerTableMap::ALGO => 6, CustomerTableMap::RESELLER => 7, CustomerTableMap::LANG => 8, CustomerTableMap::SPONSOR => 9, CustomerTableMap::DISCOUNT => 10, CustomerTableMap::CREATED_AT => 11, CustomerTableMap::UPDATED_AT => 12, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'FIRSTNAME' => 2, 'LASTNAME' => 3, 'EMAIL' => 4, 'PASSWORD' => 5, 'ALGO' => 6, 'RESELLER' => 7, 'LANG' => 8, 'SPONSOR' => 9, 'DISCOUNT' => 10, 'CREATED_AT' => 11, 'UPDATED_AT' => 12, ), - self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'firstname' => 2, 'lastname' => 3, 'email' => 4, 'password' => 5, 'algo' => 6, 'reseller' => 7, 'lang' => 8, 'sponsor' => 9, 'discount' => 10, 'created_at' => 11, 'updated_at' => 12, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'TitleId' => 2, 'Firstname' => 3, 'Lastname' => 4, 'Email' => 5, 'Password' => 6, 'Algo' => 7, 'Reseller' => 8, 'Lang' => 9, 'Sponsor' => 10, 'Discount' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'titleId' => 2, 'firstname' => 3, 'lastname' => 4, 'email' => 5, 'password' => 6, 'algo' => 7, 'reseller' => 8, 'lang' => 9, 'sponsor' => 10, 'discount' => 11, 'createdAt' => 12, 'updatedAt' => 13, ), + self::TYPE_COLNAME => array(CustomerTableMap::ID => 0, CustomerTableMap::REF => 1, CustomerTableMap::TITLE_ID => 2, CustomerTableMap::FIRSTNAME => 3, CustomerTableMap::LASTNAME => 4, CustomerTableMap::EMAIL => 5, CustomerTableMap::PASSWORD => 6, CustomerTableMap::ALGO => 7, CustomerTableMap::RESELLER => 8, CustomerTableMap::LANG => 9, CustomerTableMap::SPONSOR => 10, CustomerTableMap::DISCOUNT => 11, CustomerTableMap::CREATED_AT => 12, CustomerTableMap::UPDATED_AT => 13, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'TITLE_ID' => 2, 'FIRSTNAME' => 3, 'LASTNAME' => 4, 'EMAIL' => 5, 'PASSWORD' => 6, 'ALGO' => 7, 'RESELLER' => 8, 'LANG' => 9, 'SPONSOR' => 10, 'DISCOUNT' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, ), + self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'title_id' => 2, 'firstname' => 3, 'lastname' => 4, 'email' => 5, 'password' => 6, 'algo' => 7, 'reseller' => 8, 'lang' => 9, 'sponsor' => 10, 'discount' => 11, 'created_at' => 12, 'updated_at' => 13, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) ); /** @@ -187,6 +192,7 @@ class CustomerTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('REF', 'Ref', 'VARCHAR', true, 50, null); + $this->addForeignKey('TITLE_ID', 'TitleId', 'INTEGER', 'customer_title', 'ID', false, 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); @@ -205,6 +211,7 @@ class CustomerTableMap extends TableMap */ public function buildRelations() { + $this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('title_id' => 'id', ), 'RESTRICT', 'RESTRICT'); $this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Addresses'); $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Orders'); } // buildRelations() @@ -372,6 +379,7 @@ class CustomerTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(CustomerTableMap::ID); $criteria->addSelectColumn(CustomerTableMap::REF); + $criteria->addSelectColumn(CustomerTableMap::TITLE_ID); $criteria->addSelectColumn(CustomerTableMap::FIRSTNAME); $criteria->addSelectColumn(CustomerTableMap::LASTNAME); $criteria->addSelectColumn(CustomerTableMap::EMAIL); @@ -386,6 +394,7 @@ class CustomerTableMap extends TableMap } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.REF'); + $criteria->addSelectColumn($alias . '.TITLE_ID'); $criteria->addSelectColumn($alias . '.FIRSTNAME'); $criteria->addSelectColumn($alias . '.LASTNAME'); $criteria->addSelectColumn($alias . '.EMAIL'); diff --git a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php index 341f2a420..44b16fafd 100755 --- a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php @@ -166,6 +166,7 @@ class CustomerTitleTableMap extends TableMap */ public function buildRelations() { + $this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::ONE_TO_MANY, array('id' => 'title_id', ), 'RESTRICT', 'RESTRICT', 'Customers'); $this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'RESTRICT', 'RESTRICT', 'Addresses'); $this->addRelation('CustomerTitleI18n', '\\Thelia\\Model\\CustomerTitleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CustomerTitleI18ns'); } // buildRelations() diff --git a/local/config/schema.xml b/local/config/schema.xml index 7c005fd56..db538dacf 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -329,6 +329,7 @@ + @@ -338,6 +339,9 @@ + + + From 9a1ee565de45683ca1806bb9e6db667d4b480cd3 Mon Sep 17 00:00:00 2001 From: franck Date: Thu, 18 Jul 2013 13:01:33 +0200 Subject: [PATCH 35/36] changed role names to XXXX instead of ROLE_XXXX --- core/lib/Thelia/Core/Security/User/UserInterface.php | 2 +- core/lib/Thelia/Model/Admin.php | 2 +- core/lib/Thelia/Model/Customer.php | 2 +- templates/admin/default/home.html | 2 +- templates/default/includes/header.html | 4 ++-- templates/default/index.html | 2 +- templates/default/myaccount.html | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/lib/Thelia/Core/Security/User/UserInterface.php b/core/lib/Thelia/Core/Security/User/UserInterface.php index b747fdffa..b6642ba47 100755 --- a/core/lib/Thelia/Core/Security/User/UserInterface.php +++ b/core/lib/Thelia/Core/Security/User/UserInterface.php @@ -31,7 +31,7 @@ interface UserInterface { * * public function getRoles() * { - * return array('ROLE_USER'); + * return array('USER'); * } * * diff --git a/core/lib/Thelia/Model/Admin.php b/core/lib/Thelia/Model/Admin.php index 42d84ea93..34dc7fbfd 100755 --- a/core/lib/Thelia/Model/Admin.php +++ b/core/lib/Thelia/Model/Admin.php @@ -63,6 +63,6 @@ class Admin extends BaseAdmin implements UserInterface * {@inheritDoc} */ public function getRoles() { - return array(new Role('ROLE_ADMIN')); + return array(new Role('ADMIN')); } } diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 2b58787e0..4d9a78ea0 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -164,6 +164,6 @@ class Customer extends BaseCustomer implements UserInterface * {@inheritDoc} */ public function getRoles() { - return array(new Role('ROLE_CUSTOMER')); + return array(new Role('CUSTOMER')); } } diff --git a/templates/admin/default/home.html b/templates/admin/default/home.html index ebd61a7d1..1f1e7b4e5 100755 --- a/templates/admin/default/home.html +++ b/templates/admin/default/home.html @@ -1,4 +1,4 @@ -{check_auth context="admin" roles="ROLE_ADMIN" login_tpl="/admin/login"} +{check_auth context="admin" roles="ADMIN" login_tpl="/admin/login"} {$page_title={intl l='Home'}} {include file='includes/header.inc.html'} diff --git a/templates/default/includes/header.html b/templates/default/includes/header.html index e18f75232..0b93b6a1c 100755 --- a/templates/default/includes/header.html +++ b/templates/default/includes/header.html @@ -10,11 +10,11 @@
-{loop type="auth" name="customer_info_block" roles="ROLE_CUSTOMER" context="front"} +{loop type="auth" name="customer_info_block" roles="CUSTOMER" context="front"}

Your are logged in ! Logout

{/loop} -{loop type="auth" name="admin_info_block" roles="ROLE_ADMIN" context="admin"} +{loop type="auth" name="admin_info_block" roles="ADMIN" context="admin"}

You are logged as administrator

{/loop} diff --git a/templates/default/index.html b/templates/default/index.html index 6ee109b9e..53834febf 100755 --- a/templates/default/index.html +++ b/templates/default/index.html @@ -1,7 +1,7 @@ {include file="includes/header.html"}
-{loop type="auth" name="auth_test" context="front" roles="ROLE_CUSTOMER"} +{loop type="auth" name="auth_test" context="front" roles="CUSTOMER"}

Customer is authentified :-)

{/loop} diff --git a/templates/default/myaccount.html b/templates/default/myaccount.html index 2b712f71d..01cefa850 100644 --- a/templates/default/myaccount.html +++ b/templates/default/myaccount.html @@ -1,4 +1,4 @@ -{check_auth context="front" roles="ROLE_CUSTOMER" login_tpl="login"} +{check_auth context="front" roles="CUSTOMER" login_tpl="login"} {$page_title="{intl l='My Account'}"} From ba0143866b08d7c5d9d7baa903a9274ebb837182 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 23 Jul 2013 09:40:07 +0200 Subject: [PATCH 36/36] add use statement --- core/lib/Thelia/Action/Customer.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index c4561964c..4339ba4e3 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -41,6 +41,8 @@ use Symfony\Component\Validator\Exception\ValidatorException; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Template\ParserContext; use Thelia\Core\Security\Exception\UsernameNotFoundException; +use Propel\Runtime\Exception\PropelException; + class Customer implements EventSubscriberInterface { @@ -98,7 +100,7 @@ class Customer implements EventSubscriberInterface // Connect the newly created user,and redirect to the success URL $this->processSuccessfulLogin($event, $customer, $customerCreation, true); - } catch (\PropelException $e) { + } catch (PropelException $e) { Tlog::getInstance()->error(sprintf('error during creating customer on action/createCustomer with message "%s"', $e->getMessage())); $message = "Failed to create your account, please try again."; @@ -155,7 +157,7 @@ class Customer implements EventSubscriberInterface // We don-t send the login event, as the customer si already logged. $this->processSuccessfulLogin($event, $customer, $customerModification); } - catch(\PropelException $e) { + catch(PropelException $e) { Tlog::getInstance()->error(sprintf('error during modifying customer on action/modifyCustomer with message "%s"', $e->getMessage())); @@ -280,7 +282,7 @@ class Customer implements EventSubscriberInterface if ($sendLoginEvent) $event->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_LOGIN, $event); // Redirect to the success URL - return Redirect::exec($form->getSuccessUrl()); + Redirect::exec($form->getSuccessUrl()); } /**