diff --git a/Readme.md b/Readme.md index 2a3e9fece..93df8ab36 100755 --- a/Readme.md +++ b/Readme.md @@ -7,7 +7,6 @@ Thelia [Thelia](http://thelia.net/v2) is an open source tool for creating e-business websites and managing online content. This software is published under GPL. -Here is the current developping next major version. You can download this version for testing or see the code. Here is the most recent developed code for the next major version (v2). You can download this version for testing or having a look on the code (or anything you wish, respecting GPL). See http://thelia.net/v2 web site for more information. Most part of the code can possibly change, a large part will be refactor soon, graphical setup does not exist yet. diff --git a/core/bootstrap.php b/core/bootstrap.php index 99a24db72..72c003da9 100755 --- a/core/bootstrap.php +++ b/core/bootstrap.php @@ -15,7 +15,7 @@ define('DS' , DIRECTORY_SEPARATOR); $loader = require __DIR__ . "/vendor/autoload.php"; -if (!file_exists(THELIA_ROOT . '/local/config/database.yml') && !defined('THELIA_INSTALL_MODE')) { +if (!file_exists(THELIA_CONF_DIR . 'database.yml') && !defined('THELIA_INSTALL_MODE')) { $sapi = php_sapi_name(); if (substr($sapi, 0, 3) == 'cli') { define('THELIA_INSTALL_MODE', true); @@ -24,4 +24,4 @@ if (!file_exists(THELIA_ROOT . '/local/config/database.yml') && !defined('THELIA header('location: '.$request->getSchemeAndHttpHost() . '/install'); exit; } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Command/Install.php b/core/lib/Thelia/Command/Install.php index 21ebdcfdc..71c97e9a1 100755 --- a/core/lib/Thelia/Command/Install.php +++ b/core/lib/Thelia/Command/Install.php @@ -180,8 +180,8 @@ class Install extends ContainerAwareCommand { $fs = new Filesystem(); - $sampleConfigFile = THELIA_ROOT . "/local/config/database.yml.sample"; - $configFile = THELIA_ROOT . "/local/config/database.yml"; + $sampleConfigFile = THELIA_CONF_DIR . "database.yml.sample"; + $configFile = THELIA_CONF_DIR . "database.yml"; $fs->copy($sampleConfigFile, $configFile, true); diff --git a/core/lib/Thelia/Controller/Front/CustomerController.php b/core/lib/Thelia/Controller/Front/CustomerController.php index 2bb01a94a..7f956287e 100755 --- a/core/lib/Thelia/Controller/Front/CustomerController.php +++ b/core/lib/Thelia/Controller/Front/CustomerController.php @@ -104,6 +104,24 @@ class CustomerController extends BaseFrontController $this->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreateEvent); + $newCustomer = $customerCreateEvent->getCustomer(); + + // Newsletter + if (true === $form->get('newsletter')->getData()) { + $newsletterEmail = $newCustomer->getEmail(); + $nlEvent = new NewsletterEvent($newsletterEmail, $this->getRequest()->getSession()->getLang()->getLocale()); + $nlEvent->setFirstname($newCustomer->getFirstname()); + $nlEvent->setLastname($newCustomer->getLastname()); + + // Security : Check if this new Email address already exist + if (null !== $newsletter = NewsletterQuery::create()->findOneByEmail($newsletterEmail)) { + $nlEvent->setId($newsletter->getId()); + $this->dispatch(TheliaEvents::NEWSLETTER_UPDATE, $nlEvent); + } else { + $this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $nlEvent); + } + } + $this->processLogin($customerCreateEvent->getCustomer()); $cart = $this->getCart($this->getRequest()); diff --git a/core/lib/Thelia/Core/Template/TemplateHelper.php b/core/lib/Thelia/Core/Template/TemplateHelper.php index 10fe67a5b..f1a2ec8b9 100644 --- a/core/lib/Thelia/Core/Template/TemplateHelper.php +++ b/core/lib/Thelia/Core/Template/TemplateHelper.php @@ -62,7 +62,7 @@ class TemplateHelper public function getActiveFrontTemplate() { return new TemplateDefinition( - ConfigQuery::read('active-admin-template', 'default'), + ConfigQuery::read('active-front-template', 'default'), TemplateDefinition::FRONT_OFFICE ); } @@ -130,7 +130,7 @@ class TemplateHelper */ public function walkDir($directory, $walkMode, Translator $translator, $currentLocale, &$strings) { - $num_files = 0; + $num_texts = 0; if ($walkMode == self::WALK_MODE_PHP) { $prefix = '\-\>[\s]*trans[\s]*\('; @@ -155,7 +155,7 @@ class TemplateHelper if ($fileInfo->isDot()) continue; - if ($fileInfo->isDir()) $num_files += $this->walkDir($fileInfo->getPathName(), $walkMode, $translator, $currentLocale, $strings); + if ($fileInfo->isDir()) $num_texts += $this->walkDir($fileInfo->getPathName(), $walkMode, $translator, $currentLocale, $strings); if ($fileInfo->isFile()) { @@ -186,18 +186,19 @@ class TemplateHelper $strings[$hash]['files'][] = $short_path; } } - else - $num_files++; + else { + $num_texts++; - // remove \' - $match = str_replace("\\'", "'", $match); + // remove \' + $match = str_replace("\\'", "'", $match); - $strings[$hash] = array( - 'files' => array($short_path), - 'text' => $match, - 'translation' => $translator->trans($match, array(), 'messages', $currentLocale, false), - 'dollar' => strstr($match, '$') !== false - ); + $strings[$hash] = array( + 'files' => array($short_path), + 'text' => $match, + 'translation' => $translator->trans($match, array(), 'messages', $currentLocale, false), + 'dollar' => strstr($match, '$') !== false + ); + } } } } @@ -205,7 +206,7 @@ class TemplateHelper } } - return $num_files; + return $num_texts; } catch (\UnexpectedValueException $ex) { echo $ex; diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index c8cc02820..f4187b5a5 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -75,7 +75,7 @@ class Thelia extends Kernel } $definePropel = new DefinePropel(new DatabaseConfiguration(), - Yaml::parse(THELIA_ROOT . '/local/config/database.yml')); + Yaml::parse(THELIA_CONF_DIR . 'database.yml')); $serviceContainer = Propel::getServiceContainer(); $serviceContainer->setAdapterClass('thelia', 'mysql'); $manager = new ConnectionManagerSingle(); diff --git a/core/lib/Thelia/Core/TheliaHttpKernel.php b/core/lib/Thelia/Core/TheliaHttpKernel.php index 07dc15eed..94ad7f9de 100755 --- a/core/lib/Thelia/Core/TheliaHttpKernel.php +++ b/core/lib/Thelia/Core/TheliaHttpKernel.php @@ -215,7 +215,7 @@ class TheliaHttpKernel extends HttpKernel $storage = new Session\Storage\NativeSessionStorage(); if (Model\ConfigQuery::read("session_config.default")) { - $storage->setSaveHandler(new Session\Storage\Handler\NativeFileSessionHandler(Model\ConfigQuery::read("session_config.save_path", THELIA_ROOT . '/local/session/'))); + $storage->setSaveHandler(new Session\Storage\Handler\NativeFileSessionHandler(Model\ConfigQuery::read("session_config.save_path", THELIA_LOCAL_DIR . 'session/'))); } else { $handlerString = Model\ConfigQuery::read("session_config.handlers", 'Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler'); diff --git a/core/lib/Thelia/Form/CustomerCreateForm.php b/core/lib/Thelia/Form/CustomerCreateForm.php index 38da394cc..35954dc88 100755 --- a/core/lib/Thelia/Form/CustomerCreateForm.php +++ b/core/lib/Thelia/Form/CustomerCreateForm.php @@ -89,6 +89,14 @@ class CustomerCreateForm extends AddressCreateForm "for" => "password_confirmation" ) )) + // Add Newsletter + ->add("newsletter", "checkbox", array( + "label" => Translator::getInstance()->trans('I would like to receive the newsletter or the latest news.'), + "label_attr" => array( + "for" => "newsletter" + ), + "required" => false + )) // Add terms & conditions ->add("agreed", "checkbox", array( "constraints" => array( diff --git a/core/lib/Thelia/Form/CustomerProfileUpdateForm.php b/core/lib/Thelia/Form/CustomerProfileUpdateForm.php index c7ebd2c43..3bf0c372a 100755 --- a/core/lib/Thelia/Form/CustomerProfileUpdateForm.php +++ b/core/lib/Thelia/Form/CustomerProfileUpdateForm.php @@ -55,16 +55,7 @@ class CustomerProfileUpdateForm extends CustomerCreateForm ->remove("password") ->remove("password_confirm") // Remove Terms & conditions - ->remove("agreed") - - // Add Newsletter - ->add("newsletter", "checkbox", array( - "label" => Translator::getInstance()->trans('I would like to receive the newsletter or the latest news.'), - "label_attr" => array( - "for" => "newsletter" - ), - "required" => false - )); + ->remove("agreed"); } /** diff --git a/core/lib/Thelia/Form/NewsletterForm.php b/core/lib/Thelia/Form/NewsletterForm.php index ad0aab5a4..2dc910c1d 100644 --- a/core/lib/Thelia/Form/NewsletterForm.php +++ b/core/lib/Thelia/Form/NewsletterForm.php @@ -83,7 +83,7 @@ class NewsletterForm extends BaseForm { $customer = NewsletterQuery::create()->findOneByEmail($value); if ($customer) { - $context->addViolation("You are already subscribed!"); + $context->addViolation("You are already registered!"); } } diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index 15853a398..4575f5aac 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -27,6 +27,8 @@ namespace Thelia\Module; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Propel; use Symfony\Component\DependencyInjection\ContainerAware; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\HttpFoundation\Request; use Thelia\Model\Map\ModuleTableMap; use Thelia\Model\ModuleI18nQuery; use Thelia\Model\Map\ModuleImageTableMap; @@ -37,7 +39,8 @@ use Thelia\Model\Module; use Thelia\Model\ModuleImage; use Thelia\Model\ModuleQuery; -abstract class BaseModule extends ContainerAware + +class BaseModule extends ContainerAware implements BaseModuleInterface { const CLASSIC_MODULE_TYPE = 1; const DELIVERY_MODULE_TYPE = 2; @@ -48,10 +51,8 @@ abstract class BaseModule extends ContainerAware protected $reflected; - public function __construct() - { - - } + protected $dispatcher = null; + protected $request = null; public function activate($moduleModel = null) { @@ -102,7 +103,7 @@ abstract class BaseModule extends ContainerAware public function hasContainer() { - return null === $this->container; + return null !== $this->container; } public function getContainer() @@ -114,6 +115,41 @@ abstract class BaseModule extends ContainerAware return $this->container; } + + public function hasRequest() { + return null !== $this->request; + } + + public function setRequest(Request $request) { + $this->request = $request; + } + + public function getRequest() { + if ($this->hasRequest() === false) { + throw new \RuntimeException("Sorry, the request is not available in this context"); + } + + return $this->request; + } + + + public function hasDispatcher() { + return null !== $this->dispatcher; + } + + public function setDispatcher(EventDispatcherInterface $dispatcher) { + $this->dispatcher = $dispatcher; + } + + public function getDispatcher() { + if ($this->hasDispatcher() === false) { + throw new \RuntimeException("Sorry, the dispatcher is not available in this context"); + } + + return $this->dispatcher; + } + + public function setTitle(Module $module, $titles) { if (is_array($titles)) { @@ -226,6 +262,7 @@ abstract class BaseModule extends ContainerAware public function install(ConnectionInterface $con = null) { + // Implement this method to do something useful. } public function preActivation(ConnectionInterface $con = null) @@ -235,7 +272,7 @@ abstract class BaseModule extends ContainerAware public function postActivation(ConnectionInterface $con = null) { - + // Implement this method to do something useful. } public function preDeactivation(ConnectionInterface $con = null) @@ -245,12 +282,11 @@ abstract class BaseModule extends ContainerAware public function postDeactivation(ConnectionInterface $con = null) { - + // Implement this method to do something useful. } - public function destroy(ConnectionInterface $con = null) + public function destroy(ConnectionInterface $con = null, $deleteModuleData = false) { - + // Implement this method to do something useful. } - -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Module/BaseModuleInterface.php b/core/lib/Thelia/Module/BaseModuleInterface.php index 5cfd98409..694a4082c 100644 --- a/core/lib/Thelia/Module/BaseModuleInterface.php +++ b/core/lib/Thelia/Module/BaseModuleInterface.php @@ -23,14 +23,21 @@ namespace Thelia\Module; +use Propel\Runtime\Connection\ConnectionInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; interface BaseModuleInterface { - public function setRequest(Request $request); - public function getRequest(); + public function install(ConnectionInterface $con = null); - public function setDispatcher(EventDispatcherInterface $dispatcher); - public function getDispatcher(); + public function preActivation(ConnectionInterface $con = null); + + public function postActivation(ConnectionInterface $con = null); + + public function preDeactivation(ConnectionInterface $con = null); + + public function postDeactivation(ConnectionInterface $con = null); + + public function destroy(ConnectionInterface $con = null, $deleteModuleData = false); } diff --git a/core/lib/Thelia/Tests/Command/ModuleActivateCommandTest.php b/core/lib/Thelia/Tests/Command/ModuleActivateCommandTest.php index 680a487aa..d18c80a61 100755 --- a/core/lib/Thelia/Tests/Command/ModuleActivateCommandTest.php +++ b/core/lib/Thelia/Tests/Command/ModuleActivateCommandTest.php @@ -41,6 +41,9 @@ class ModuleActivateCommandTest extends \PHPUnit_Framework_TestCase $module = ModuleQuery::create()->findOne(); if (null !== $module) { + + $prev_activation_status = $module->getActivate(); + $application = new Application($this->getKernel()); $module->setActivate(BaseModule::IS_NOT_ACTIVATED); @@ -58,7 +61,12 @@ class ModuleActivateCommandTest extends \PHPUnit_Framework_TestCase "module" => $module->getCode(), )); - $this->assertEquals(BaseModule::IS_ACTIVATED, ModuleQuery::create()->findPk($module->getId())->getActivate()); + $activated = ModuleQuery::create()->findPk($module->getId())->getActivate(); + + // Restore activation status + $module->setActivate($prev_activation_status)->save(); + + $this->assertEquals(BaseModule::IS_ACTIVATED, $activated); } } diff --git a/install/insert.sql b/install/insert.sql index ea26fbd6f..c49f3e210 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -7,7 +7,7 @@ INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`date_format`,`time_format INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES ('session_config.default', '1', 1, 1, NOW(), NOW()), ('verifyStock', '1', 0, 0, NOW(), NOW()), -('active-template', 'default', 0, 0, NOW(), NOW()), +('active-front-template', 'default', 0, 0, NOW(), NOW()), ('active-admin-template', 'default', 0, 0, NOW(), NOW()), ('active-pdf-template', 'default', 0, 0, NOW(), NOW()), ('default_lang_without_translation', '1', 1, 1, NOW(), NOW()), diff --git a/templates/admin/default/I18n/fr_FR.php b/templates/admin/default/I18n/fr_FR.php index 2de503905..edccca64e 100755 --- a/templates/admin/default/I18n/fr_FR.php +++ b/templates/admin/default/I18n/fr_FR.php @@ -79,7 +79,7 @@ return array ( 'Address Line 2' => 'Adresse suite', 'Additional address' => 'Adresse complémentaire', 'Address Line 3' => 'Adresse suite', - 'Zip code' => 'Code posta', + 'Zip code' => 'Code postal', 'City' => 'Ville', 'Country' => 'Pays', 'Email Address' => 'Adresse e-mail', diff --git a/templates/admin/default/administrators.html b/templates/admin/default/administrators.html index c2b8fa521..a02846c0f 100644 --- a/templates/admin/default/administrators.html +++ b/templates/admin/default/administrators.html @@ -1,6 +1,6 @@ {extends file="admin-layout.tpl"} -{block name="page-title"}{intl l='Taxes rules'}{/block} +{block name="page-title"}{intl l='Back-office users'}{/block} {block name="check-resource"}admin.configuration.administrator{/block} {block name="check-access"}view{/block} @@ -9,12 +9,12 @@