Merge branch 'master' into loops

This commit is contained in:
Etienne Roudeix
2013-07-23 10:44:41 +02:00
218 changed files with 4272 additions and 3653 deletions

View File

@@ -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.

3
Thelia
View File

@@ -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);
$application->run($input, new TheliaConsoleOutput());

View File

@@ -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.*",

295
composer.lock generated
View File

@@ -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",
@@ -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,34 +198,34 @@
],
"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",
"version": "2.0.0-alpha1",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/propelorm/Propel2.git",
"reference": "2.0.0-alpha1"
"reference": "4cf5fca150ed93b33dc54206e3d9d943d0712621"
},
"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/4cf5fca150ed93b33dc54206e3d9d943d0712621",
"reference": "4cf5fca150ed93b33dc54206e3d9d943d0712621",
"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-10 11:32:06"
},
{
"name": "psr/log",
@@ -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",
@@ -1979,7 +1978,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,

View File

@@ -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";

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
@@ -32,23 +32,47 @@ 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;
use Thelia\Core\Template\ParserContext;
use Thelia\Core\Security\Exception\UsernameNotFoundException;
use Propel\Runtime\Exception\PropelException;
class Customer implements EventSubscriberInterface
{
/**
* @var Thelia\Core\Security\SecurityContext
*/
protected $securityContext;
/**
* @var Thelia\Core\Template\ParserContext
*/
protected $parserContext;
public function __construct(SecurityContext $securityContext, ParserContext $parserContext) {
$this->securityContext = $securityContext;
$this->parserContext = $parserContext;
}
public function create(ActionEvent $event)
{
$event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CREATECUSTOMER, $event);
$request = $event->getRequest();
$customerForm = new CustomerCreation($request);
$form = $customerForm->getForm();
$customerCreation = new CustomerCreation($request);
$form = $customerCreation->getForm();
if ($request->isMethod("post")) {
$form->bind($request);
if ($form->isValid()) {
@@ -68,26 +92,37 @@ class Customer implements EventSubscriberInterface
$data["country"],
$data["email"],
$data["password"],
$request->getSession()->get("lang")
$request->getSession()->getLang()
);
} catch (\PropelException $e) {
$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($form);
$message = "Failed to create your account, please try again.";
}
//Customer is create, he is automatically connected
} else {
$event->setFormError($form);
}
else {
$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);
@@ -115,20 +150,92 @@ 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($form);
$message = "Failed to change your account, please try again.";
}
} else {
$event->setFormError($form);
}
else {
$message = "Missing or invalid data";
}
}
else {
$message = "Wrong form method !";
}
$this->parserContext->set('customer_change_error_message', $message);
$event->setFormError($customerModification);
}
public function modifyPassword(ActionEvent $event)
{
/**
* 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();
}
/**
* 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();
$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 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
}
/**
@@ -155,8 +262,37 @@ 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),
"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
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;
}
}

View File

@@ -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 */

View File

@@ -27,11 +27,15 @@ 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;
use Thelia\Tools\URL;
use Thelia\Tools\Redirect;
/**
*
@@ -44,14 +48,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 +63,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 +71,79 @@ 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
// We user login_tpl as a path, not a template.
Redirect::exec(URL::absoluteUrl($ex->getLoginTemplate()));
}
}
/**
* 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 <NULL, \Symfony\Component\HttpFoundation\Session\SessionInterface>
*/
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;
}
@@ -121,24 +158,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
*/
public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
{
return "thelia2/$route"; //FIXME
//return $this->container->get('router')->generate($route, $parameters, $referenceType);
}
/**
* Forwards the request to another controller.
*
@@ -148,24 +167,11 @@ 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);
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
*/
public function redirect($url, $status = 302)
{
return new RedirectResponse($url, $status);
}
}

View File

@@ -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,39 +25,74 @@ namespace Thelia\Admin\Controller;
use Symfony\Component\HttpFoundation\Response;
use Thelia\Form\AdminLogin;
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 {
public function loginAction()
public function showLoginAction()
{
return $this->render("login.html");
}
public function checkLogoutAction()
{
$this->getSecurityContext()->clear();
// Go back to login page.
return Redirect::exec(URL::absoluteUrl('/admin/login')); // FIXME - should be a parameter
}
public function checkLoginAction()
{
$form = $this->getLoginForm();
$form = new AdminLogin($this->getRequest());
$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 successuful", $request, $user);
echo "valid"; exit;
}
}
// Redirect to the success URL
return Redirect::exec($form->getSuccessUrl());
}
catch (ValidatorException $ex) {
return $this->render("login.html", array(
"form" => $form->createView()
));
}
// Validation problem
$message = "Missing or invalid information. Please check your input.";
}
catch (AuthenticationException $ex) {
protected function getLoginForm()
{
$adminLogin = new AdminLogin($this->getRequest());
// Log authentication failure
AdminLog::append(sprintf("Authentication failure for username '%s'", $authenticator->getUsername()), $request);
return $adminLogin->getForm();
$message = "Login failed. Please check your username and password.";
}
catch (\Exception $ex) {
// 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());
// Display the login form again, with an error message if required
return $this->render("login.html", array(
"message" => $message
));
}
}

View File

@@ -0,0 +1,58 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Command;
use Propel\Runtime\Propel;
use Symfony\Component\Console\Application;
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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
@@ -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 {

View File

@@ -0,0 +1,104 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
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 BaseModuleGenerate {
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();
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");
}
}
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);
$schemaContent = str_replace("%%NAMESPACE%%", $this->module, $schemaContent);
file_put_contents($this->moduleDirectory . DIRECTORY_SEPARATOR . "Config". DIRECTORY_SEPARATOR . "schema.xml", $schemaContent);
}
}

View File

@@ -0,0 +1,130 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
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\Input\InputOption;
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"
)
->addOption(
"generate-sql",
null,
InputOption::VALUE_NONE,
"with this option generate sql file at the same time"
)
;
}
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", $this->module));
}
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");
}
$this->generateModel($output);
$output->renderBlock(array(
'',
'Model generated successfuly',
''
), 'bg=green;fg=black');
if ($input->getOption("generate-sql")) {
$output->writeln(' ');
$this->generateSql($output);
}
}
protected function generateSql(OutputInterface $output)
{
$command = $this->getApplication()->find("module:generate:sql");
$command->run(
new ArrayInput(array(
"command" => $command->getName(),
"name" => $this->module
)),
$output
);
}
protected function generateModel(OutputInterface $output)
{
$fs = new Filesystem();
$moduleBuildPropel = new ModelBuildCommand();
$moduleBuildPropel->setApplication($this->getApplication());
$moduleBuildPropel->run(
new ArrayInput(array(
"command" => $moduleBuildPropel->getName(),
"--output-dir" => THELIA_MODULE_DIR,
"--input-dir" => $this->moduleDirectory . DS ."Config"
)),
$output
);
$verifyDirectories = array(
THELIA_MODULE_DIR . DS . "Thelia",
$this->moduleDirectory . DS . "Model" . DS . "Thelia"
);
foreach ($verifyDirectories as $directory) {
if ($fs->exists($directory)) {
$fs->remove($directory);
}
}
}
}

View File

@@ -0,0 +1,85 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
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", $this->module));
}
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"
)),
$output
);
$output->renderBlock(array(
'',
'Sql generated successfuly',
'File available in your module config directory',
''
), 'bg=green;fg=black');
}
}

View File

@@ -0,0 +1,56 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Command\Output;
use Symfony\Component\Console\Output\ConsoleOutput;
class TheliaConsoleOutput extends ConsoleOutput{
public function renderBlock(array $messages, $style = "info")
{
$strlen = function ($string) {
if (!function_exists('mb_strlen')) {
return strlen($string);
}
if (false === $encoding = mb_detect_encoding($string)) {
return strlen($string);
}
return mb_strlen($string, $encoding);
};
$length = 0;
foreach ($messages as $message) {
$length = ($strlen($message) > $length) ? $strlen($message) : $length;
}
$ouput = array();
foreach ($messages as $message) {
$output[] = "<" . $style . ">" . " " . $message . str_repeat(' ', $length - $strlen($message)) . " </" . $style . ">";
}
$this->writeln($output);
}
}

View File

@@ -0,0 +1,36 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace %%NAMESPACE%%;
use Thelia\Module\BaseModule;
class %%CLASSNAME%% extends BaseModule
{
/**
* YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class
* Like install and destroy
*/
}

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns="http://thelia.net/schema/dic/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
<loops>
<!-- sample definition
<loop name="MySuperLoop" class="MyModule\Loop\MySuperLoop" />
-->
</loops>
<forms>
<!--
<form name="MyFormName" class="MyModule\Form\MySuperForm" />
-->
</forms>
<commands>
<!--
<command class="MyModule\Command\MySuperCommand" />
-->
</commands>
<templateDirectives>
<!-- Sample definition
<templateDirectives class="MyModule\Directive\MyTemplateDirective" name="my_filter"/>
-->
</templateDirectives>
<!--
<services>
</services>
-->
</config>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<database defaultIdMethod="native" name="thelia" namespace="%%NAMESPACE%%\Model">
<!--
See propel documentation on http://propelorm.org for all information about schema file
-->
<external-schema filename="%%CONFIG_DIR%%schema.xml" referenceOnly="true" />
</database>

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -11,13 +11,18 @@
<parameter key="deleteArticle">Thelia\Core\Event\CartEvent</parameter>
</parameter>
</parameters>
<services>
<service id="thelia.action.cart" class="Thelia\Action\Cart">
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.customer" class="Thelia\Action\Customer">
<service id="thelia.action.customer" class="Thelia\Action\Customer" scope="request">
<tag name="kernel.event_subscriber"/>
<argument type="service" id="thelia.securityContext"/>
<argument type="service" id="thelia.parser.context"/>
</service>
</services>

View File

@@ -12,29 +12,20 @@
<loop class="Thelia\Core\Template\Loop\Auth" name="auth"/>
</loops>
<filters>
<!-- Sample definition
<filter class="Thelia\Core\Template\Filter\SomeFilterClass" name="my_filter"/>
-->
</filters>
<templateDirectives>
<!-- Sample definition
<templateDirectives class="Thelia\Core\Template\Filter\SomeFilterClass" name="my_filter"/>
-->
</templateDirectives>
<forms>
<form name="thelia.customer.creation" class="Thelia\Form\CustomerCreation"/>
<form name="thelia.customer.modification" class="Thelia\Form\CustomerModification"/>
<form name="thelia.admin_login" class="Thelia\Form\AdminLogin"/>
<form name="thelia.customer.login" class="Thelia\Form\CustomerLogin"/>
<form name="thelia.admin.login" class="Thelia\Form\AdminLogin"/>
</forms>
<commands>
<command class="Thelia\Command\CacheClear"/>
<command class="Thelia\Command\Install"/>
<command class="Thelia\Command\ModuleGenerateCommand"/>
<command class="Thelia\Command\ModuleGenerateModelCommand"/>
<command class="Thelia\Command\ModuleGenerateSqlCommand"/>
</commands>
<services>
@@ -50,26 +41,42 @@
<!--
A ControllerResolver that supports "a:b:c", "service:method" and class::method" notations,
thus allowing the definition of controllers as service (see http://symfony.com/fr/doc/current/cookbook/controller/service.html)
We use it here to inject the servi ce container in the admin base controller.
We use it here to inject the service container in the admin base controller.
-->
<service id="controller_resolver" class="Thelia\Core\Controller\ControllerResolver">
<argument type="service" id="service_container"/>
</service>
<!-- Security -->
<!-- Translation and internationalisation -->
<service id="thelia.security" class="Thelia\Core\Security\SecurityContext" />
<service id="thelia.translator" class="Thelia\Core\Translation\Translator">
<argument type="string" id="en_US"></argument>
</service>
<!-- Security context for front and back office -->
<service id="thelia.securityContext" class="Thelia\Core\Security\SecurityContext" scope="request">
<argument type="service" id="request" />
</service>
<!-- Parser context -->
<service id="thelia.parser.context" class="Thelia\Core\Template\ParserContext" scope="request">
<argument type="service" id="request" />
</service>
<!-- Parser configuration -->
<service id="thelia.parser" class="Thelia\Core\Template\Smarty\SmartyParser" scope="request">
<argument type="service" id="request" />
<argument type="service" id="event_dispatcher"/>
<argument type="service" id="thelia.parser.context"/>
<argument >false</argument>
<argument >%kernel.environment%</argument>
<argument >%kernel.debug%</argument>
</service>
<!-- Smarty parser plugins -->
<service id="smarty.plugin.assetic" class="Thelia\Core\Template\Smarty\Plugins\Assetic" >
@@ -85,7 +92,7 @@
<argument type="service" id="request" />
<argument type="service" id="event_dispatcher"/>
<argument type="service" id="thelia.security"/>
<argument type="service" id="thelia.securityContext"/>
<call method="setLoopList">
<argument>%thelia.parser.loops%</argument>
@@ -103,15 +110,21 @@
<service id="smarty.plugin.translation" class="Thelia\Core\Template\Smarty\Plugins\Translation" >
<tag name="thelia.parser.register_plugin"/>
<argument type="service" id="thelia.translator" />
</service>
<service id="smarty.plugin.module" class="Thelia\Core\Template\Smarty\Plugins\Module" >
<tag name="thelia.parser.register_plugin"/>
</service>
<service id="smarty.plugin.security" class="Thelia\Core\Template\Smarty\Plugins\Security" >
<service id="smarty.url.module" class="Thelia\Core\Template\Smarty\Plugins\UrlGenerator" scope="request">
<tag name="thelia.parser.register_plugin"/>
<argument type="service" id="thelia.security" />
<argument type="service" id="request"/>
</service>
<service id="smarty.plugin.security" class="Thelia\Core\Template\Smarty\Plugins\Security" scope="request">
<tag name="thelia.parser.register_plugin"/>
<argument type="service" id="thelia.securityContext" />
</service>
<service id="http_kernel" class="Thelia\Core\TheliaHttpKernel">

View File

@@ -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">
<!-- Route to administration base -->
<route id="admin" path="/admin">
<default key="_controller">Thelia\Admin\Controller\AdminController::indexAction</default>
</route>
<!-- Route to the administration login page -->
<route id="admin.login" path="/admin/login">
<default key="_controller">Thelia\Admin\Controller\SessionController::loginAction</default>
<default key="_controller">Thelia\Admin\Controller\SessionController::showLoginAction</default>
</route>
<route id="admin.notfound" path="/admin/{everything}">
<default key="_controller">Thelia\Admin\Controller\AdminController::notFoundAction</default>
<!-- Route to the administration logout page -->
<route id="admin.logout" path="/admin/logout">
<default key="_controller">Thelia\Admin\Controller\SessionController::checkLogoutAction</default>
</route>
<!-- Route to the login check controller -->
<route id="admin.checklogin" path="/admin/checklogin">
<default key="_controller">Thelia\Admin\Controller\SessionController::checkLoginAction</default>
</route>
<route id="admin.undefined" path="/admin/{everything}">
<default key="_controller">Thelia\Admin\Controller\AdminController::undefinedAction</default>
<requirement key="everything">.*</requirement>
</route>
</routes>

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Controller;

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
@@ -25,6 +25,8 @@ 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
@@ -47,7 +49,7 @@ abstract class ActionEvent extends Event
*/
protected $action;
protected $form;
protected $form = null;
/**
*
@@ -78,20 +80,32 @@ 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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
@@ -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";
}

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
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"));
@@ -50,12 +51,9 @@ 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());
}
}
}
public static function getSubscribedEvents()

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
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,15 @@ 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())));
}
}
public function beforeKernelView(GetResponseForControllerResultEvent $event)

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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,16 +17,21 @@
/* 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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
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;
use Thelia\Tools\URL;
class Session extends BaseSession {
// -- Language ------------------------------------------------------------
public function getLocale()
{
@@ -35,7 +40,77 @@ class Session extends BaseSession {
public function getLang()
{
return $this->get("lang", "en");
return substr($this->getLocale(), 0, 2);
}
// -- Customer user --------------------------------------------------------
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');
}
// -- Admin 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');
}
// -- Error form -----------------------------------------------------------
/**
* @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');
}
// -- 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', URL::getIndexPage());
}
}

View File

@@ -1,4 +1,5 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
@@ -23,38 +24,20 @@
namespace Thelia\Core\Security\Authentication;
use Thelia\Core\Security\UserNotFoundException;
use Thelia\Core\Security\IncorrectPasswordException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Form;
/**
* Aunthentication providers are in charge or retrieving users, and check their
* credentials.
*
* @author Franck
*
*/
interface AuthenticationProviderInterface {
use Thelia\Core\Security\UserProvider\AdminUserProvider;
use Thelia\Core\Security\Authentication\UsernamePasswordFormAuthenticator;
use Thelia\Form\AdminLogin;
/**
* Set the authentication token
*
* @param TokenInterface $token the authentication token
*/
public function setToken(TokenInterface $token);
class AdminUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuthenticator {
/**
* 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();
}
?>
public function __construct(Request $request, AdminLogin $loginForm) {
parent::__construct(
$request,
$loginForm,
new AdminUserProvider()
);
}
}

View File

@@ -0,0 +1,32 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Security\Authentication;
interface AuthenticatorInterface {
/**
* Returns a UserInterface instance, authentified using the authenticator specific method
*/
public function getAuthentifiedUser();
}

View File

@@ -0,0 +1,44 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
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 {
public function __construct(Request $request, CustomerLogin $loginForm) {
parent::__construct(
$request,
$loginForm,
new CustomerUserProvider(),
array(
'username_field_name' => 'email'
)
);
}
}

View File

@@ -1,67 +0,0 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
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;
}
}

View File

@@ -0,0 +1,95 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
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;
use Symfony\Component\Validator\Exception\ValidatorException;
use Thelia\Form\BaseForm;
class UsernamePasswordFormAuthenticator implements AuthenticatorInterface {
protected $request;
protected $loginForm;
protected $userProvider;
protected $options;
protected $baseLoginForm;
public function __construct(Request $request, BaseForm $loginForm, UserProviderInterface $userProvider, array $options = array()) {
$this->request = $request;
$this->baseLoginForm = $loginForm;
$this->loginForm = $this->baseLoginForm->getForm();
$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);
}
/**
* @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()) throw new ValidatorException("Form is not valid.");
// 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;
}
throw new \RuntimeException("Invalid method.");
}
}

View File

@@ -1,35 +0,0 @@
<?php
use Thelia\Core\Security\Token\UsernamePasswordToken;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Core\Security\Authentication\UsernamePasswordAuthenticator;
use Thelia\Core\Security\User\UserProvider\CustomerUserProvider;
use Thelia\Core\Security\Encoder\PasswordHashEncoder;
use Symfony\Component\DependencyInjection\ContainerInterface;
class AuthenticationProcessor {
private $container;
public function __construct(ContainerInterface $container) {
$this->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
}
}
}

View File

@@ -21,32 +21,28 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Security\Encoder;
namespace Thelia\Core\Security\Exception;
/**
* This interface defines a password encoder.
*
* @author Franck Allimant <franck@cqfdev.fr>
*
*/
interface PasswordEncoderInterface {
class AuthenticationException extends \Exception
{
/**
* @var string The login template name
*/
protected $loginTemplate = "login";
/**
* Encode a string.
*
* @param string $password the password to encode
* @param string $algorithm the hash() algorithm
* @return string $salt the salt
* @return string the login template name
*/
public function encode($password, $algorithm, $salt);
public function getLoginTemplate() {
return $this->loginTemplate;
}
/**
* Check a string against an encoded password.
* Set the login template name
*
* @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
* @param string $loginPath the login template name
*/
public function isEqual($string, $password, $algorithm, $salt);
public function setLoginTemplate($loginTemplate) {
$this->loginTemplate = $loginTemplate;
}
}

View File

@@ -0,0 +1,28 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Security\Exception;
class UsernameNotFoundException extends AuthenticationException
{
}

View File

@@ -23,6 +23,6 @@
namespace Thelia\Core\Security\Exception;
class AuthenticationTokenNotFoundException extends \Exception
class WrongPasswordException extends AuthenticationException
{
}

View File

@@ -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
@@ -38,4 +38,8 @@ class Role implements RoleInterface
{
return $this->role;
}
public function __toString() {
return $this->role;
}
}

View File

@@ -25,62 +25,166 @@ 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 <franck@cqfdev.fr>
*/
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);
}
$user = $this->getUser();
if ($this->token->isAuthenticated()) {
// Check user roles and permissions
// 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;
}
/**
* 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();
}
}

View File

@@ -1,148 +0,0 @@
<?php
namespace Thelia\Core\Security\Token;
use Thelia\Core\Security\User\UserInterface;
/**
* Base class for Token instances.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
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;
}
}

View File

@@ -1,81 +0,0 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Security\Token;
/**
* TokenInterface is the interface for the user authentication information.
*
* Parts borrowed from Symfony Security Framework (Fabien Potencier <fabien@symfony.com> / Johannes M. Schmitt <schmittjoh@gmail.com>)
*/
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();
}

View File

@@ -1,75 +0,0 @@
<?php
namespace Thelia\Core\Security\Token;
use Thelia\Core\Security\User\UserInterface;
/**
* UsernamePasswordToken implements a username and password token.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
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);
}
}

View File

@@ -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.
@@ -36,7 +31,7 @@ interface UserInterface {
* <code>
* public function getRoles()
* {
* return array('ROLE_USER');
* return array('USER');
* }
* </code>
*

View File

@@ -1,12 +1,13 @@
<?php
namespace Thelia\Core\Security\User\UserProvider;
namespace Thelia\Core\Security\UserProvider;
use Thelia\Model\Admin;
use Thelia\Model\AdminQuery;
class AdminUserProvider implements UserProviderInterface {
public function getUser($key) {
$admin = new Admin();
$admin = AdminQuery::create()
->filterByLogin($key)
->findOne();

View File

@@ -1,13 +1,13 @@
<?php
namespace Thelia\Core\Security\User\UserProvider;
namespace Thelia\Core\Security\UserProvider;
use Thelia\Action\Customer;
use Thelia\Model\CustomerQuery;
class CustomerUserProvider implements UserProviderInterface {
public function getUser($key) {
$customer = new Customer();
$customer = CustomerQuery::create()
->filterByEmail($key)
->findOne();

View File

@@ -1,6 +1,6 @@
<?php
namespace Thelia\Core\Security\User\UserProvider;
namespace Thelia\Core\Security\UserProvider;
interface UserProviderInterface {
/**

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Template\Exception;

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Template\Loop\Argument;

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Template\Loop\Argument;

View File

@@ -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

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -0,0 +1,65 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
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 <franck@cqfdev.fr>
*/
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 );
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Template;

View File

@@ -24,6 +24,8 @@
namespace Thelia\Core\Template\Smarty\Assets;
use Thelia\Core\Template\Assets\AsseticHelper;
use Thelia\Model\ConfigQuery;
use Thelia\Tools\URL;
class SmartyAssetsManager
{
@@ -71,7 +73,7 @@ class SmartyAssetsManager
$url = $this->assetic_manager->asseticize(
$asset_dir.'/'.$asset_file,
$this->web_root."/".$this->path_relative_to_web_root,
$this->path_relative_to_web_root,
URL::absoluteUrl($this->path_relative_to_web_root, array(), true /* path only */),
$assetType,
$filters,
$debug

View File

@@ -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 = '<input type="hidden" name="%s" value="%s">';
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")
);

View File

@@ -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,29 @@ 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)) {
$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 '';
}
/**

View File

@@ -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'),
);
}
}

View File

@@ -0,0 +1,104 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Template\Smarty\Plugins;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Smarty\SmartyPluginInterface;
use Thelia\Tools\URL;
use Thelia\Core\HttpFoundation\Request;
class UrlGenerator implements SmartyPluginInterface
{
protected $request;
public function __construct(Request $request)
{
$this->request = $request;
}
/**
* 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, $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 view name (without .html)
$view = trim($params['view']);
// the related action (optionale)
$action = trim($params['action']);
$args = $this->getArgsFromParam($params);
if (! empty($action)) $args['action'] = $action;
return URL::viewUrl($view, $args);
}
/**
* 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();
}
/**
* 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'),
new SmartyPluginDescriptor('function', 'viewurl', $this, 'generateViewUrlFunction')
);
}
}

View File

@@ -7,10 +7,13 @@ use \Symfony\Component\EventDispatcher\EventDispatcherInterface;
use \Smarty;
use Symfony\Component\HttpFoundation\Response;
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;
/**
*
@@ -22,7 +25,9 @@ class SmartyParser extends Smarty implements ParserInterface
public $plugins = array();
protected $request, $dispatcher;
protected $request;
protected $dispatcher;
protected $parserContext;
protected $template = "";
@@ -35,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
@@ -50,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...
@@ -74,14 +82,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)
@@ -103,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);
@@ -117,7 +136,14 @@ 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->render($templateFile);
}
/**
@@ -181,11 +207,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;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -0,0 +1,28 @@
<?php
namespace Thelia\Core\Translation;
use Symfony\Component\Translation\Translator as BaseTranslator;
class Translator extends BaseTranslator {
/**
* {@inheritdoc}
*
* @api
*/
public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null)
{
if (null === $locale) {
$locale = $this->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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Exception;

View File

@@ -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 */
@@ -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,14 @@ class AdminLogin extends BaseForm {
new NotBlank()
)
))
->add("remember_me", "checkbox");
->add("remember_me", "checkbox", array(
'value' => 'yes'
))
;
}
public function getName()
{
return "admin_login";
return "adminLogin";
}
}

View File

@@ -31,14 +31,20 @@ 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 {
/**
* @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 +54,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 +69,45 @@ abstract class BaseForm {
->createNamedBuilder($this->getName(), $type, $data, $options);
;
$this->buildForm();
// If not already set, define the success_url field
if (! $this->formBuilder->has('success_url')) {
$this->formBuilder->add("success_url", "text");
}
$this->buildForm();
$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();
}
public function getView() {
if ($this->view === null) throw new \LogicException("View was not created. Please call BaseForm::createView() first.");
return $this->view;
}
/**
@@ -73,15 +115,15 @@ 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")
* $this->formBuilder->add("name", "text")
* ->add("email", "email", array(
* "attr" => array(
* "class" => "field"

View File

@@ -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 */
@@ -33,7 +33,7 @@ class CustomerCreation extends BaseForm
protected function buildForm()
{
$this->form
$this->formBuilder
->add("firstname", "text", array(
"constraints" => array(
new Constraints\NotBlank()

View File

@@ -0,0 +1,56 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* 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 <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
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;
use Symfony\Component\Validator\Constraints\Email;
class CustomerLogin extends BaseForm {
protected function buildForm()
{
$this->formBuilder
->add("email", "text", array(
"constraints" => array(
new NotBlank(),
new Email()
)
))
->add("password", "password", array(
"constraints" => array(
new NotBlank()
)
))
->add("remember_me", "checkbox")
;
}
public function getName()
{
return "customer_login";
}
}

View File

@@ -52,7 +52,7 @@ class CustomerModification extends BaseForm {
protected function buildForm()
{
$this->form
$this->formBuilder
->add("firstname", "text", array(
"constraints" => array(
new Constraints\NotBlank()

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Log;

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

View File

@@ -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();
}
@@ -36,6 +63,6 @@ class Admin extends BaseAdmin implements UserInterface
* {@inheritDoc}
*/
public function getRoles() {
return array(new Role('ROLE_ADMIN'));
return array(new Role('ADMIN'));
}
}

View File

@@ -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() : '<no login>')
->setAdminFirstname($adminUser !== null ? $adminUser->getFirstname() : '<no first name>')
->setAdminLastname($adminUser !== null ? $adminUser->getLastname() : '<no last name>')
->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));
}
}
}

View File

@@ -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 is_default field.
* Note: this column has a database default value of: 0
* @var int
*/
protected $is_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->is_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 [is_default] column value.
*
* @return int
*/
public function getIsDefault()
{
return $this->is_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 [is_default] column.
*
* @param int $v new value
* @return \Thelia\Model\Address The current object (for fluent API support)
*/
public function setIsDefault($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->is_default !== $v) {
$this->is_default = $v;
$this->modifiedColumns[] = AddressTableMap::IS_DEFAULT;
}
return $this;
} // setIsDefault()
/**
* 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->is_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('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') {
$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::IS_DEFAULT)) {
$modifiedColumns[':p' . $index++] = 'IS_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 '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);
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->getIsDefault();
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->getIsDefault(),
$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->setIsDefault($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->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]]);
}
/**
@@ -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::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);
@@ -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->setIsDefault($this->getIsDefault());
$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->is_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);

View File

@@ -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 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
*
@@ -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 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
*
@@ -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 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
*
@@ -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 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
*
@@ -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, IS_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:
* <code>
* $query->filterByCellphone('fooValue'); // WHERE cellphone = 'fooValue'
* $query->filterByCellphone('%fooValue%'); // WHERE cellphone LIKE '%fooValue%'
* </code>
*
* @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 is_default column
*
* Example usage:
* <code>
* $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
* </code>
*
* @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.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildAddressQuery The current query, for fluid interface
*/
public function filterByIsDefault($isDefault = null, $comparison = null)
{
if (is_array($isDefault)) {
$useMinMax = false;
if (isset($isDefault['min'])) {
$this->addUsingAlias(AddressTableMap::IS_DEFAULT, $isDefault['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($isDefault['max'])) {
$this->addUsingAlias(AddressTableMap::IS_DEFAULT, $isDefault['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(AddressTableMap::IS_DEFAULT, $isDefault, $comparison);
}
/**
* Filter the query on the created_at column
*

File diff suppressed because it is too large Load Diff

View File

@@ -23,22 +23,12 @@ 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 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 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 +38,12 @@ 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 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 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
@@ -92,22 +72,12 @@ 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 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 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 +87,12 @@ 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 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 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 +187,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, 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);
@@ -387,18 +347,18 @@ abstract class CustomerQuery extends ModelCriteria
}
/**
* Filter the query on the customer_title_id column
* Filter the query on the title_id column
*
* Example usage:
* <code>
* $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
* $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
* </code>
*
* @see filterByCustomerTitle()
*
* @param mixed $customerTitleId The value to use as filter.
* @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.
@@ -406,16 +366,16 @@ abstract class CustomerQuery extends ModelCriteria
*
* @return ChildCustomerQuery The current query, for fluid interface
*/
public function filterByCustomerTitleId($customerTitleId = null, $comparison = null)
public function filterByTitleId($titleId = null, $comparison = null)
{
if (is_array($customerTitleId)) {
if (is_array($titleId)) {
$useMinMax = false;
if (isset($customerTitleId['min'])) {
$this->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL);
if (isset($titleId['min'])) {
$this->addUsingAlias(CustomerTableMap::TITLE_ID, $titleId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($customerTitleId['max'])) {
$this->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL);
if (isset($titleId['max'])) {
$this->addUsingAlias(CustomerTableMap::TITLE_ID, $titleId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
@@ -426,36 +386,7 @@ abstract class CustomerQuery extends ModelCriteria
}
}
return $this->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitleId, $comparison);
}
/**
* Filter the query on the company column
*
* Example usage:
* <code>
* $query->filterByCompany('fooValue'); // WHERE company = 'fooValue'
* $query->filterByCompany('%fooValue%'); // WHERE company LIKE '%fooValue%'
* </code>
*
* @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);
return $this->addUsingAlias(CustomerTableMap::TITLE_ID, $titleId, $comparison);
}
/**
@@ -516,250 +447,6 @@ abstract class CustomerQuery extends ModelCriteria
return $this->addUsingAlias(CustomerTableMap::LASTNAME, $lastname, $comparison);
}
/**
* Filter the query on the address1 column
*
* Example usage:
* <code>
* $query->filterByAddress1('fooValue'); // WHERE address1 = 'fooValue'
* $query->filterByAddress1('%fooValue%'); // WHERE address1 LIKE '%fooValue%'
* </code>
*
* @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:
* <code>
* $query->filterByAddress2('fooValue'); // WHERE address2 = 'fooValue'
* $query->filterByAddress2('%fooValue%'); // WHERE address2 LIKE '%fooValue%'
* </code>
*
* @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:
* <code>
* $query->filterByAddress3('fooValue'); // WHERE address3 = 'fooValue'
* $query->filterByAddress3('%fooValue%'); // WHERE address3 LIKE '%fooValue%'
* </code>
*
* @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:
* <code>
* $query->filterByZipcode('fooValue'); // WHERE zipcode = 'fooValue'
* $query->filterByZipcode('%fooValue%'); // WHERE zipcode LIKE '%fooValue%'
* </code>
*
* @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:
* <code>
* $query->filterByCity('fooValue'); // WHERE city = 'fooValue'
* $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%'
* </code>
*
* @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:
* <code>
* $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
* </code>
*
* @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:
* <code>
* $query->filterByPhone('fooValue'); // WHERE phone = 'fooValue'
* $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%'
* </code>
*
* @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:
* <code>
* $query->filterByCellphone('fooValue'); // WHERE cellphone = 'fooValue'
* $query->filterByCellphone('%fooValue%'); // WHERE cellphone LIKE '%fooValue%'
* </code>
*
* @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 +534,6 @@ abstract class CustomerQuery extends ModelCriteria
return $this->addUsingAlias(CustomerTableMap::ALGO, $algo, $comparison);
}
/**
* Filter the query on the salt column
*
* Example usage:
* <code>
* $query->filterBySalt('fooValue'); // WHERE salt = 'fooValue'
* $query->filterBySalt('%fooValue%'); // WHERE salt LIKE '%fooValue%'
* </code>
*
* @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
*
@@ -1114,14 +772,14 @@ abstract class CustomerQuery extends ModelCriteria
{
if ($customerTitle instanceof \Thelia\Model\CustomerTitle) {
return $this
->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison);
->addUsingAlias(CustomerTableMap::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);
->addUsingAlias(CustomerTableMap::TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCustomerTitle() only accepts arguments of type \Thelia\Model\CustomerTitle or Collection');
}

View File

@@ -450,7 +450,7 @@ abstract class CustomerTitleQuery extends ModelCriteria
{
if ($customer instanceof \Thelia\Model\Customer) {
return $this
->addUsingAlias(CustomerTitleTableMap::ID, $customer->getCustomerTitleId(), $comparison);
->addUsingAlias(CustomerTitleTableMap::ID, $customer->getTitleId(), $comparison);
} elseif ($customer instanceof ObjectCollection) {
return $this
->useCustomerQuery()

View File

@@ -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,9 @@ 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;
use Thelia\Core\Security\Role\Role;
/**
* Skeleton subclass for representing a row from the 'customer' table.
@@ -52,16 +56,9 @@ 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)
->setTitleId($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,8 +70,36 @@ 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)
->setIsDefault(1)
->setCustomer($this)
->save($con);
$con->commit();
} catch(Exception $e) {
$con->rollback();
throw $e;
}
}
public function preInsert(ConnectionInterface $con = null)
@@ -91,7 +116,7 @@ class Customer extends BaseCustomer implements UserInterface
protected function generateRef()
{
return date("YmdHI");
return date("YmdHisu");
}
public function setPassword($password)
@@ -113,12 +138,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);
}
/**
@@ -132,6 +164,6 @@ class Customer extends BaseCustomer implements UserInterface
* {@inheritDoc}
*/
public function getRoles() {
return array(new Role('ROLE_CUSTOMER'));
return array(new Role('CUSTOMER'));
}
}

Some files were not shown because too many files have changed in this diff Show More