Merge branch 'frontend' of github.com:thelia/thelia into frontend

This commit is contained in:
badsuricate
2013-10-22 10:24:03 +02:00
252 changed files with 9365 additions and 8143 deletions

View File

@@ -39,7 +39,8 @@
"symfony/icu": "1.0",
"swiftmailer/swiftmailer": "5.0.*",
"symfony/serializer": "2.3.*",
"ensepar/html2pdf": "1.0.1"
"ensepar/html2pdf": "1.0.1",
"symfony/finder": "~2.2"
},
"require-dev" : {
"phpunit/phpunit": "3.7.*",

4
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": "852879ecc2e39e5cf283a3b1c5051a8e",
"hash": "4f3fabbb795a71df45ae9f6ccb6df355",
"packages": [
{
"name": "ensepar/html2pdf",
@@ -949,7 +949,7 @@
},
{
"name": "symfony/finder",
"version": "v2.3.5",
"version": "v2.3.6",
"target-dir": "Symfony/Component/Finder",
"source": {
"type": "git",

View File

@@ -34,7 +34,6 @@ use Thelia\Model\CountryQuery;
use Thelia\Action\BaseAction;
use Thelia\Model\Area as AreaModel;
/**
* Class Area
* @package Thelia\Action
@@ -97,7 +96,6 @@ class Area extends BaseAction implements EventSubscriberInterface
$event->setArea($area);
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
@@ -128,4 +126,4 @@ class Area extends BaseAction implements EventSubscriberInterface
TheliaEvents::AREA_CREATE => array('create', 128)
);
}
}
}

View File

@@ -0,0 +1,75 @@
<?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\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Filesystem\Filesystem;
use Thelia\Core\Event\Cache\CacheEvent;
use Thelia\Core\Event\TheliaEvents;
/**
* Class Cache
* @package Thelia\Action
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Cache extends BaseAction implements EventSubscriberInterface
{
public function cacheClear(CacheEvent $event)
{
$dir = $event->getDir();
$directoryBrowser = new \DirectoryIterator($dir);
$fs = new Filesystem();
$fs->remove($dir);
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
* The array keys are event names and the value can be:
*
* * The method name to call (priority defaults to 0)
* * An array composed of the method name to call and the priority
* * An array of arrays composed of the method names to call and respective
* priorities, or 0 if unset
*
* For instance:
*
* * array('eventName' => 'methodName')
* * array('eventName' => array('methodName', $priority))
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
*
* @return array The event names to listen to
*
* @api
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::CACHE_CLEAR => array('cacheClear', 128)
);
}
}

View File

@@ -160,7 +160,7 @@ class Content extends BaseAction implements EventSubscriberInterface
->filterByFolderId($event->getFolderId())
->findOne();
if(null !== $contentFolder) {
if (null !== $contentFolder) {
$contentFolder->delete();
}
}

View File

@@ -32,7 +32,6 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Country as CountryModel;
use Thelia\Model\CountryQuery;
/**
* Class Country
* @package Thelia\Action
@@ -85,15 +84,13 @@ class Country extends BaseAction implements EventSubscriberInterface
public function toggleDefault(CountryToggleDefaultEvent $event)
{
if( null !== $country = CountryQuery::create()->findPk($event->getCountryId()))
{
if ( null !== $country = CountryQuery::create()->findPk($event->getCountryId())) {
$country->toggleDefault();
$event->setCountry($country);
}
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
@@ -123,4 +120,4 @@ class Country extends BaseAction implements EventSubscriberInterface
TheliaEvents::COUNTRY_TOGGLE_DEFAULT => array('toggleDefault', 128)
);
}
}
}

View File

@@ -25,7 +25,6 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\Customer\CustomerAddressEvent;
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\Customer\CustomerEvent;
use Thelia\Core\Event\TheliaEvents;

View File

@@ -0,0 +1,136 @@
<?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\Action;
use Propel\Runtime\Propel;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Filesystem\Filesystem;
use Thelia\Core\Event\Cache\CacheEvent;
use Thelia\Core\Event\Module\ModuleDeleteEvent;
use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Map\ModuleTableMap;
use Thelia\Model\ModuleQuery;
use Thelia\Module\BaseModule;
/**
* Class Module
* @package Thelia\Action
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Module extends BaseAction implements EventSubscriberInterface
{
public function toggleActivation(ModuleToggleActivationEvent $event)
{
if (null !== $module = ModuleQuery::create()->findPk($event->getModuleId())) {
$moduleClass = new \ReflectionClass($module->getFullNamespace());
$moduleInstance = $moduleClass->newInstance();
if ( method_exists($moduleInstance, 'setContainer')) {
$moduleInstance->setContainer($this->container);
if ($module->getActivate() == BaseModule::IS_ACTIVATED) {
$moduleInstance->deActivate($module);
} else {
$moduleInstance->activate($module);
}
}
$event->setModule($module);
$this->cacheClear();
}
}
public function delete(ModuleDeleteEvent $event)
{
if (null !== $module = ModuleQuery::create()->findPk($event->getModuleId())) {
$con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
if(null === $module->getFullNamespace()) {
throw new \LogicException('can not instanciante this module if namespace is null. Maybe the model is not loaded ?');
}
$reflected = new \ReflectionClass($module->getFullNamespace());
$instance = $reflected->newInstance();
$instance->setContainer($this->container);
$path = dirname($reflected->getFileName());
$instance->destroy($con);
$fs = new Filesystem();
$fs->remove($path);
$module->delete($con);
$con->commit();
$event->setModule($module);
$this->cacheClear();
} catch (\Exception $e) {
$con->rollBack();
throw $e;
}
}
}
protected function cacheClear()
{
$cacheEvent = new CacheEvent($this->container->getParameter('kernel.cache_dir'));
$this->getDispatcher()->dispatch(TheliaEvents::CACHE_CLEAR, $cacheEvent);
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
* The array keys are event names and the value can be:
*
* * The method name to call (priority defaults to 0)
* * An array composed of the method name to call and the priority
* * An array of arrays composed of the method names to call and respective
* priorities, or 0 if unset
*
* For instance:
*
* * array('eventName' => 'methodName')
* * array('eventName' => array('methodName', $priority))
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
*
* @return array The event names to listen to
*
* @api
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::MODULE_TOGGLE_ACTIVATION => array('toggleActivation', 128),
TheliaEvents::MODULE_DELETE => array('delete', 128)
);
}
}

View File

@@ -26,7 +26,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\PdfEvent;
use Thelia\Core\Event\TheliaEvents;
/**
* Class Pdf
* @package Thelia\Action
@@ -72,4 +71,4 @@ class Pdf extends BaseAction implements EventSubscriberInterface
TheliaEvents::GENERATE_PDF => array("generatePdf", 128)
);
}
}
}

View File

@@ -0,0 +1,105 @@
<?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\Action;
use Propel\Runtime\ActiveQuery\Criteria;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Profile\ProfileEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Profile as ProfileModel;
use Thelia\Model\ProfileQuery;
class Profile extends BaseAction implements EventSubscriberInterface
{
/**
* @param ProfileEvent $event
*/
public function create(ProfileEvent $event)
{
$profile = new ProfileModel();
$profile
->setDispatcher($this->getDispatcher())
->setCode($event->getCode())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setChapo($event->getChapo())
->setDescription($event->getDescription())
->setPostscriptum($event->getPostscriptum())
;
$profile->save();
$event->setProfile($profile);
}
/**
* @param ProfileEvent $event
*/
public function update(ProfileEvent $event)
{
if (null !== $profile = ProfileQuery::create()->findPk($event->getId())) {
$profile
->setDispatcher($this->getDispatcher())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setChapo($event->getChapo())
->setDescription($event->getDescription())
->setPostscriptum($event->getPostscriptum())
;
$profile->save();
$event->setProfile($profile);
}
}
/**
* @param ProfileEvent $event
*/
public function delete(ProfileEvent $event)
{
if (null !== $profile = ProfileQuery::create()->findPk($event->getId())) {
$profile
->delete()
;
$event->setProfile($profile);
}
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::PROFILE_CREATE => array("create", 128),
TheliaEvents::PROFILE_UPDATE => array("update", 128),
TheliaEvents::PROFILE_DELETE => array("delete", 128),
);
}
}

View File

@@ -29,7 +29,6 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\AreaDeliveryModule;
use Thelia\Model\AreaDeliveryModuleQuery;
/**
* Class ShippingZone
* @package Thelia\Action
@@ -55,7 +54,7 @@ class ShippingZone extends BaseAction implements EventSubscriberInterface
->filterByDeliveryModuleId($event->getShoppingZoneId())
->findOne();
if($areaDelivery) {
if ($areaDelivery) {
$areaDelivery->delete();
} else {
throw new \RuntimeException(sprintf('areaDeliveryModule not found with area_id = %d and delivery_module_id = %d', $event->getAreaId(), $event->getShoppingZoneId()));
@@ -89,4 +88,4 @@ class ShippingZone extends BaseAction implements EventSubscriberInterface
TheliaEvents::SHIPPING_ZONE_REMOVE_AREA => array('removeArea', 128),
);
}
}
}

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\Action;
use Propel\Runtime\ActiveQuery\Criteria;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Tax\TaxEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Tax as TaxModel;
use Thelia\Model\TaxQuery;
class Tax extends BaseAction implements EventSubscriberInterface
{
/**
* @param TaxEvent $event
*/
public function create(TaxEvent $event)
{
$tax = new TaxModel();
$tax
->setDispatcher($this->getDispatcher())
->setRequirements($event->getRequirements())
->setType($event->getType())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
;
$tax->save();
$event->setTax($tax);
}
/**
* @param TaxEvent $event
*/
public function update(TaxEvent $event)
{
if (null !== $tax = TaxQuery::create()->findPk($event->getId())) {
$tax
->setDispatcher($this->getDispatcher())
->setRequirements($event->getRequirements())
->setType($event->getType())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
;
$tax->save();
$event->setTax($tax);
}
}
/**
* @param TaxEvent $event
*/
public function delete(TaxEvent $event)
{
if (null !== $tax = TaxQuery::create()->findPk($event->getId())) {
$tax
->delete()
;
$event->setTax($tax);
}
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::TAX_CREATE => array("create", 128),
TheliaEvents::TAX_UPDATE => array("update", 128),
TheliaEvents::TAX_DELETE => array("delete", 128),
);
}
}

View File

@@ -27,6 +27,7 @@ use Propel\Runtime\ActiveQuery\Criteria;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Tax\TaxRuleEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Map\TaxRuleTableMap;
use Thelia\Model\TaxRuleCountry;
use Thelia\Model\TaxRuleCountryQuery;
use Thelia\Model\TaxRule as TaxRuleModel;
@@ -68,8 +69,6 @@ class TaxRule extends BaseAction implements EventSubscriberInterface
->save()
;
$event->setTaxRule($taxRule);
}
}
@@ -90,12 +89,12 @@ class TaxRule extends BaseAction implements EventSubscriberInterface
->delete();
/* for each country */
foreach($event->getCountryList() as $country) {
foreach ($event->getCountryList() as $country) {
$position = 1;
/* on applique les nouvelles regles */
foreach($taxList as $tax) {
if(is_array($tax)) {
foreach($tax as $samePositionTax) {
foreach ($taxList as $tax) {
if (is_array($tax)) {
foreach ($tax as $samePositionTax) {
$taxModel = new TaxRuleCountry();
$taxModel->setTaxRule($taxRule)
->setCountryId($country)
@@ -134,6 +133,23 @@ class TaxRule extends BaseAction implements EventSubscriberInterface
}
}
/**
* @param TaxRuleEvent $event
*/
public function setDefault(TaxRuleEvent $event)
{
if (null !== $taxRule = TaxRuleQuery::create()->findPk($event->getId())) {
TaxRuleQuery::create()->update(array(
"IsDefault" => 0
));
$taxRule->setIsDefault(1)->save();
$event->setTaxRule($taxRule);
}
}
/**
* {@inheritDoc}
*/
@@ -144,7 +160,7 @@ class TaxRule extends BaseAction implements EventSubscriberInterface
TheliaEvents::TAX_RULE_UPDATE => array("update", 128),
TheliaEvents::TAX_RULE_TAXES_UPDATE => array("updateTaxes", 128),
TheliaEvents::TAX_RULE_DELETE => array("delete", 128),
TheliaEvents::TAX_RULE_SET_DEFAULT => array("setDefault", 128),
);
}
}

View File

@@ -30,6 +30,8 @@ use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Exception\IOException;
use Thelia\Command\ContainerAwareCommand;
use Thelia\Core\Event\Cache\CacheEvent;
use Thelia\Core\Event\TheliaEvents;
/**
* clear the cache
@@ -72,7 +74,11 @@ class CacheClear extends ContainerAwareCommand
$output->writeln(sprintf("Clearing cache in <info>%s</info> directory", $dir));
try {
$directoryBrowser = new \DirectoryIterator($dir);
$cacheEvent = new CacheEvent($dir);
$this->
getContainer()
->get('event_dispatcher')
->dispatch(TheliaEvents::CACHE_CLEAR, $cacheEvent);
} catch (\UnexpectedValueException $e) {
// throws same exception code for does not exist and permission denied ...
if (!file_exists($dir)) {
@@ -82,15 +88,11 @@ class CacheClear extends ContainerAwareCommand
}
throw $e;
}
$fs = new Filesystem();
try {
$fs->remove($dir);
$output->writeln(sprintf("<info>%s cache dir cleared successfully</info>", $dir));
} catch (IOException $e) {
$output->writeln(sprintf("Error during clearing cache : %s", $e->getMessage()));
}
$output->writeln(sprintf("<info>%s cache dir cleared successfully</info>", $dir));
}
}

View File

@@ -135,6 +135,8 @@ class CreateAdminUser extends ContainerAwareCommand
$output->writeln("Passwords are different, please try again.");
} while (true);
$admin->setProfile(null);
return $admin;
}

View File

@@ -0,0 +1,92 @@
<?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\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Thelia\Command\ContainerAwareCommand;
use Thelia\Model\Admin;
use Thelia\Model\Map\ResourceTableMap;
class GenerateResources extends ContainerAwareCommand
{
/**
* Configure the command
*/
protected function configure()
{
$this
->setName("thelia:generate-resources")
->setDescription("Outputs admin resources")
->setHelp("The <info>thelia:generate-resources</info> outputs admin resources.")
->addOption(
'output',
null,
InputOption::VALUE_OPTIONAL,
'Output format amid (string, sql)',
null
)
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$class = new \ReflectionClass('Thelia\Core\Event\AdminResources');
$constants = $class->getConstants();
if(count($constants) == 0) {
$output->writeln('No resources found');
exit;
}
switch($input->getOption("output")) {
case 'sql':
$output->writeln(
'INSERT INTO ' . ResourceTableMap::TABLE_NAME . ' (`id`, `code`, `created_at`, `updated_at`) VALUES '
);
foreach($constants as $constant => $value) {
if($constant == 'SUPERADMINISTRATOR') {
continue;
}
$output->writeln(
"(NULL, '$value', NOW(), NOW())" . ($constant === key( array_slice( $constants, -1, 1, TRUE ) ) ? '' : ',')
);
}
break;
default :
foreach($constants as $constant => $value) {
if($constant == 'SUPERADMINISTRATOR') {
continue;
}
$output->writeln('[' . $constant . "] => " . $value);
}
break;
}
}
}

View File

@@ -143,8 +143,8 @@ class Install extends ContainerAwareCommand
$permissions = new CheckPermission(false, $this->getContainer()->get('thelia.translator'));
$isValid = $permissions->exec();
foreach($permissions->getValidationMessages() as $item => $data) {
if($data['status']) {
foreach ($permissions->getValidationMessages() as $item => $data) {
if ($data['status']) {
$output->writeln(array(
sprintf("<info>%s ...</info> %s",
$data['text'],
@@ -162,7 +162,7 @@ class Install extends ContainerAwareCommand
}
if(false === $isValid) {
if (false === $isValid) {
$output->writeln(array(
"",
"<error>Please put correct permissions and reload install process</error>"

View File

@@ -26,7 +26,6 @@ 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;
use Thelia\Model\ModuleQuery;

View File

@@ -62,7 +62,7 @@ class ModuleGenerateCommand extends BaseModuleGenerate
$output->renderBlock(array(
'',
sprintf("module %s create with success", $this->module),
"You can now configure your module and complete plugin.xml file",
"You can now configure your module and complete module.xml file",
''
), "bg=green;fg=black");
}
@@ -86,7 +86,7 @@ class ModuleGenerateCommand extends BaseModuleGenerate
$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");
$fs->copy($skeletonDir . "module.xml", $this->moduleDirectory . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "module.xml");
$classContent = file_get_contents($skeletonDir . "Class.php");

View File

@@ -25,7 +25,7 @@ namespace %%NAMESPACE%%;
use Thelia\Module\BaseModule;
class %%CLASSNAME%% extends BaseModule
class Class extends BaseModule
{
/**
* YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module>
<fullnamespace></fullnamespace>
<descriptive locale="en_US">
<title></title>
</descriptive>
<descriptive locale="fr_FR">
<title></title>
</descriptive>
<version></version>
<author>
<name></name>
<email></email>
</author>
<type></type>
<thelia></thelia>
<stability></stability>
</module>

View File

@@ -111,6 +111,11 @@
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.tax" class="Thelia\Action\Tax">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.content" class="Thelia\Action\Content">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
@@ -136,6 +141,21 @@
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.module" class="Thelia\Action\Module">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.cache" class="Thelia\Action\Cache">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.profile" class="Thelia\Action\Profile">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
</services>
</config>

View File

@@ -7,6 +7,7 @@
<loops>
<loop class="Thelia\Core\Template\Loop\Accessory" name="accessory"/>
<loop class="Thelia\Core\Template\Loop\Address" name="address"/>
<loop class="Thelia\Core\Template\Loop\Admin" name="admin"/>
<loop class="Thelia\Core\Template\Loop\Area" name="area"/>
<loop class="Thelia\Core\Template\Loop\AssociatedContent" name="associated_content"/>
<loop class="Thelia\Core\Template\Loop\Attribute" name="attribute"/>
@@ -33,6 +34,7 @@
<loop class="Thelia\Core\Template\Loop\Payment" name="payment"/>
<loop class="Thelia\Core\Template\Loop\Product" name="product"/>
<loop class="Thelia\Core\Template\Loop\ProductSaleElements" name="product_sale_elements"/>
<loop class="Thelia\Core\Template\Loop\Profile" name="profile"/>
<loop class="Thelia\Core\Template\Loop\Feed" name="feed"/>
<loop class="Thelia\Core\Template\Loop\Title" name="title"/>
<loop class="Thelia\Core\Template\Loop\Lang" name="lang"/>
@@ -52,18 +54,26 @@
</loops>
<forms>
<!-- Forms for Frontend -->
<form name="thelia.front.customer.login" class="Thelia\Form\CustomerLogin"/>
<form name="thelia.front.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/>
<form name="thelia.front.customer.create" class="Thelia\Form\CustomerCreateForm"/>
<form name="thelia.front.customer.profil.update" class="Thelia\Form\CustomerProfilUpdateForm"/>
<form name="thelia.front.customer.password.update" class="Thelia\Form\CustomerPasswordUpdateForm"/>
<form name="thelia.front.address.create" class="Thelia\Form\AddressCreateForm"/>
<form name="thelia.front.address.update" class="Thelia\Form\AddressUpdateForm"/>
<form name="thelia.front.contact" class="Thelia\Form\ContactForm"/>
<!-- Forms for Admin -->
<form name="thelia.install.step3" class="Thelia\Form\InstallStep3Form"/>
<form name="thelia.customer.creation" class="Thelia\Form\CustomerCreation"/>
<form name="thelia.customer.update" class="Thelia\Form\CustomerUpdateForm"/>
<form name="thelia.customer.modification" class="Thelia\Form\CustomerModification"/>
<form name="thelia.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/>
<form name="thelia.customer.login" class="Thelia\Form\CustomerLogin"/>
<form name="thelia.admin.login" class="Thelia\Form\AdminLogin"/>
<form name="thelia.address.create" class="Thelia\Form\AddressCreateForm" />
<form name="thelia.address.update" class="Thelia\Form\AddressUpdateForm" />
<form name="thelia.admin.customer.create" class="Thelia\Form\CustomerCreateForm"/>
<form name="thelia.admin.customer.update" class="Thelia\Form\CustomerUpdateForm"/>
<form name="thelia.admin.address.create" class="Thelia\Form\AddressCreateForm" />
<form name="thelia.admin.address.update" class="Thelia\Form\AddressUpdateForm" />
<form name="thelia.admin.category.creation" class="Thelia\Form\CategoryCreationForm"/>
<form name="thelia.admin.category.modification" class="Thelia\Form\CategoryModificationForm"/>
@@ -119,13 +129,18 @@
<form name="thelia.admin.taxrule.taxlistupdate" class="Thelia\Form\TaxRuleTaxListUpdateForm"/>
<form name="thelia.admin.taxrule.add" class="Thelia\Form\TaxRuleCreationForm"/>
<form name="thelia.admin.tax.modification" class="Thelia\Form\TaxModificationForm"/>
<form name="thelia.admin.tax.taxlistupdate" class="Thelia\Form\TaxTaxListUpdateForm"/>
<form name="thelia.admin.tax.add" class="Thelia\Form\TaxCreationForm"/>
<form name="thelia.admin.profile.add" class="Thelia\Form\ProfileCreationForm"/>
<form name="thelia.admin.profile.modification" class="Thelia\Form\ProfileModificationForm"/>
<form name="thelia.admin.template.creation" class="Thelia\Form\TemplateCreationForm"/>
<form name="thelia.admin.template.modification" class="Thelia\Form\TemplateModificationForm"/>
<form name="thelia.admin.country.creation" class="Thelia\Form\CountryCreationForm"/>
<form name="thelia.admin.country.modification" class="Thelia\Form\CountryModificationForm"/>
<form name="thelia.admin.profile.modification" class="Thelia\Form\ProfileModificationForm"/>
<form name="thelia.admin.language.creation" class="Thelia\Form\LanguageCreationForm"/>
@@ -151,6 +166,7 @@
<command class="Thelia\Command\ModuleActivateCommand"/>
<command class="Thelia\Command\CreateAdminUser"/>
<command class="Thelia\Command\ReloadDatabaseCommand"/>
<command class="Thelia\Command\GenerateResources"/>
</commands>
<services>

View File

@@ -757,6 +757,32 @@
<!-- end countries routes management -->
<!-- profiles management -->
<route id="admin.configuration.profiles.list" path="/admin/configuration/profiles">
<default key="_controller">Thelia\Controller\Admin\ProfileController::defaultAction</default>
<requirement key="address_id">\d+</requirement>
</route>
<route id="admin.configuration.profiles.update" path="/admin/configuration/profiles/update/{profile_id}">
<default key="_controller">Thelia\Controller\Admin\ProfileController::updateAction</default>
<requirement key="tax_id">\d+</requirement>
</route>
<route id="admin.configuration.profiles.add" path="/admin/configuration/profiles/add">
<default key="_controller">Thelia\Controller\Admin\ProfileController::createAction</default>
</route>
<route id="admin.configuration.profiles.save" path="/admin/configuration/profiles/save">
<default key="_controller">Thelia\Controller\Admin\ProfileController::processUpdateAction</default>
</route>
<route id="admin.configuration.profiles.delete" path="/admin/configuration/profiles/delete">
<default key="_controller">Thelia\Controller\Admin\ProfileController::deleteAction</default>
</route>
<!-- end profiles management -->
<!-- feature and features value management -->
<route id="admin.configuration.features.default" path="/admin/configuration/features">
@@ -816,13 +842,43 @@
<!-- Modules rule management -->
<route id="admin.module" path="/admin/modules">
<route id="admin.module" path="/admin/configuration/modules">
<default key="_controller">Thelia\Controller\Admin\ModuleController::indexAction</default>
</route>
<route id="admin.module.toggle-activation" path="/admin/configuration/modules/toggle-activation/{module_id}">
<default key="_controller">Thelia\Controller\Admin\ModuleController::toggleActivationAction</default>
<requirement key="module_id">\d+</requirement>
</route>
<route id="admin.module.delete" path="/admin/configuration/modules/delete">
<default key="_controller">Thelia\Controller\Admin\ModuleController::deleteAction</default>
</route>
<!-- end Modules rule management -->
<!-- taxe rules management -->
<!-- tax management -->
<route id="admin.configuration.taxes.update" path="/admin/configuration/taxes/update/{tax_id}">
<default key="_controller">Thelia\Controller\Admin\TaxController::updateAction</default>
<requirement key="tax_id">\d+</requirement>
</route>
<route id="admin.configuration.taxes.add" path="/admin/configuration/taxes/add">
<default key="_controller">Thelia\Controller\Admin\TaxController::createAction</default>
</route>
<route id="admin.configuration.taxes.save" path="/admin/configuration/taxes/save">
<default key="_controller">Thelia\Controller\Admin\TaxController::processUpdateAction</default>
</route>
<route id="admin.configuration.taxes.delete" path="/admin/configuration/taxes/delete">
<default key="_controller">Thelia\Controller\Admin\TaxController::deleteAction</default>
</route>
<!-- end tax management -->
<!-- tax rules management -->
<route id="admin.configuration.taxes-rules.list" path="/admin/configuration/taxes_rules">
<default key="_controller">Thelia\Controller\Admin\TaxRuleController::defaultAction</default>
@@ -849,6 +905,11 @@
<default key="_controller">Thelia\Controller\Admin\TaxRuleController::deleteAction</default>
</route>
<route id="admin.configuration.taxes-rules.set-default" path="/admin/configuration/taxes_rules/update/set_default/{tax_rule_id}">
<default key="_controller">Thelia\Controller\Admin\TaxRuleController::setDefaultAction</default>
<requirement key="tax_rule_id">\d+</requirement>
</route>
<!-- end tax rules management -->
@@ -859,4 +920,4 @@
<requirement key="template">.*</requirement>
</route>
</routes>
</routes>

View File

@@ -164,4 +164,23 @@
</route>
<!-- end order management process -->
<route id="mail.test" path="/mail/test">
<default key="_controller">Thelia\Controller\Front\Mail::test</default>
</route>
<route id="contact.display" path="/contact" methods="get">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">contact</default>
</route>
<route id="contact.send" path="/contact" methods="post">
<default key="_controller">Thelia\Controller\Front\ContactController::sendAction</default>
<default key="_view">contact</default>
</route>
<route id="contact.success" path="/contact/success">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">contact-success</default>
</route>
</routes>

View File

@@ -24,14 +24,13 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent;
use Thelia\Core\Event\Address\AddressEvent;
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\AddressCreateForm;
use Thelia\Form\AddressUpdateForm;
use Thelia\Model\AddressQuery;
use Thelia\Model\CustomerQuery;
/**
* Class AddressController
* @package Thelia\Controller\Admin
@@ -46,10 +45,10 @@ class AddressController extends AbstractCrudController
null,
null,
'admin.customer.update.view',
'admin.address.create',
'admin.address.update',
'admin.address.delete',
AdminResources::ADDRESS_VIEW,
AdminResources::ADDRESS_CREATE,
AdminResources::ADDRESS_UPDATE,
AdminResources::ADDRESS_DELETE,
TheliaEvents::ADDRESS_CREATE,
TheliaEvents::ADDRESS_UPDATE,
@@ -62,7 +61,7 @@ class AddressController extends AbstractCrudController
public function useAddressAction()
{
if (null !== $response = $this->checkAuth("admin.customer.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$address_id = $this->getRequest()->request->get('address_id');
@@ -78,7 +77,7 @@ class AddressController extends AbstractCrudController
$this->dispatch(TheliaEvents::ADDRESS_DEFAULT, $addressEvent);
$this->adminLogAppend(sprintf("address %d for customer %d removal", $address_id, $address->getCustomerId()));
} catch(\Exception $e) {
} catch (\Exception $e) {
\Thelia\Log\Tlog::getInstance()->error(sprintf("error during address removal with message %s", $e->getMessage()));
}
@@ -176,8 +175,6 @@ class AddressController extends AbstractCrudController
$formData["is_default"]
);
return $event;
}
@@ -279,8 +276,8 @@ class AddressController extends AbstractCrudController
/**
* Put in this method post object delete processing if required.
*
* @param \Thelia\Core\Event\AddressEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
* @param \Thelia\Core\Event\AddressEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalDeleteAction($deleteEvent)
{
@@ -291,8 +288,8 @@ class AddressController extends AbstractCrudController
/**
* Put in this method post object creation processing if required.
*
* @param AddressCreateOrUpdateEvent $createEvent the create event
* @return Response a response, or null to continue normal processing
* @param AddressCreateOrUpdateEvent $createEvent the create event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalCreateAction($createEvent)
{
@@ -303,4 +300,4 @@ class AddressController extends AbstractCrudController
{
$this->redirectToEditionTemplate();
}
}
}

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Area\AreaAddCountryEvent;
use Thelia\Core\Event\Area\AreaCreateEvent;
use Thelia\Core\Event\Area\AreaDeleteEvent;
@@ -52,10 +53,10 @@ class AreaController extends AbstractCrudController
null,
null,
'admin.area.default',
'admin.area.create',
'admin.area.update',
'admin.area.delete',
AdminResources::AREA_VIEW,
AdminResources::AREA_CREATE,
AdminResources::AREA_UPDATE,
AdminResources::AREA_DELETE,
TheliaEvents::AREA_CREATE,
TheliaEvents::AREA_UPDATE,

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Attribute\AttributeAvDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Attribute\AttributeAvUpdateEvent;
@@ -46,10 +47,10 @@ class AttributeAvController extends AbstractCrudController
'manual',
'order',
'admin.configuration.attributes-av.view',
'admin.configuration.attributes-av.create',
'admin.configuration.attributes-av.update',
'admin.configuration.attributes-av.delete',
AdminResources::ATTRIBUTE_VIEW,
AdminResources::ATTRIBUTE_CREATE,
AdminResources::ATTRIBUTE_UPDATE,
AdminResources::ATTRIBUTE_DELETE,
TheliaEvents::ATTRIBUTE_AV_CREATE,
TheliaEvents::ATTRIBUTE_AV_UPDATE,

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Attribute\AttributeDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Attribute\AttributeUpdateEvent;
@@ -50,10 +51,10 @@ class AttributeController extends AbstractCrudController
'manual',
'order',
'admin.configuration.attributes.view',
'admin.configuration.attributes.create',
'admin.configuration.attributes.update',
'admin.configuration.attributes.delete',
AdminResources::ATTRIBUTE_VIEW,
AdminResources::ATTRIBUTE_CREATE,
AdminResources::ATTRIBUTE_UPDATE,
AdminResources::ATTRIBUTE_DELETE,
TheliaEvents::ATTRIBUTE_CREATE,
TheliaEvents::ATTRIBUTE_UPDATE,
@@ -253,7 +254,7 @@ class AttributeController extends AbstractCrudController
protected function addRemoveFromAllTemplates($eventType)
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.attributes.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
try {
if (null !== $object = $this->getExistingObject()) {

View File

@@ -378,8 +378,8 @@ class BaseAdminController extends BaseController
* 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
* @param null $templateDir
* @param array $args the template arguments
* @param null $templateDir
*
* @return \Symfony\Component\HttpFoundation\Response
*/

View File

@@ -24,6 +24,7 @@
namespace Thelia\Controller\Admin;
use Symfony\Component\HttpFoundation\Response;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Category\CategoryDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Category\CategoryUpdateEvent;
@@ -54,10 +55,10 @@ class CategoryController extends AbstractCrudController
'manual',
'category_order',
'admin.categories.default',
'admin.categories.create',
'admin.categories.update',
'admin.categories.delete',
AdminResources::CATEGORY_VIEW,
AdminResources::CATEGORY_CREATE,
AdminResources::CATEGORY_UPDATE,
AdminResources::CATEGORY_DELETE,
TheliaEvents::CATEGORY_CREATE,
TheliaEvents::CATEGORY_UPDATE,
@@ -216,7 +217,7 @@ class CategoryController extends AbstractCrudController
public function setToggleVisibilityAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$event = new CategoryToggleVisibilityEvent($this->getExistingObject());
@@ -296,7 +297,7 @@ class CategoryController extends AbstractCrudController
public function addRelatedContentAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$content_id = intval($this->getRequest()->get('content_id'));
@@ -326,7 +327,7 @@ class CategoryController extends AbstractCrudController
public function addRelatedPictureAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) {
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) {
return $response;
}
@@ -354,7 +355,7 @@ class CategoryController extends AbstractCrudController
public function deleteRelatedContentAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$content_id = intval($this->getRequest()->get('content_id'));

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Config\ConfigDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Config\ConfigUpdateEvent;
@@ -45,10 +46,10 @@ class ConfigController extends AbstractCrudController
'name',
'order',
'admin.configuration.variables.view',
'admin.configuration.variables.create',
'admin.configuration.variables.update',
'admin.configuration.variables.delete',
AdminResources::CONFIG_VIEW,
AdminResources::CONFIG_CREATE,
AdminResources::CONFIG_UPDATE,
AdminResources::CONFIG_DELETE,
TheliaEvents::CONFIG_CREATE,
TheliaEvents::CONFIG_UPDATE,
@@ -187,7 +188,7 @@ class ConfigController extends AbstractCrudController
public function changeValuesAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.variables.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$variables = $this->getRequest()->get('variable', array());

View File

@@ -22,6 +22,7 @@
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Content\ContentAddFolderEvent;
use Thelia\Core\Event\Content\ContentCreateEvent;
use Thelia\Core\Event\Content\ContentDeleteEvent;
@@ -49,10 +50,10 @@ class ContentController extends AbstractCrudController
'manual',
'content_order',
'admin.content.default',
'admin.content.create',
'admin.content.update',
'admin.content.delete',
AdminResources::CONTENT_VIEW,
AdminResources::CONTENT_CREATE,
AdminResources::CONTENT_UPDATE,
AdminResources::CONTENT_DELETE,
TheliaEvents::CONTENT_CREATE,
TheliaEvents::CONTENT_UPDATE,
@@ -70,7 +71,7 @@ class ContentController extends AbstractCrudController
public function addAdditionalFolderAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth('admin.content.update')) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$folder_id = intval($this->getRequest()->request->get('additional_folder_id'));
@@ -98,7 +99,7 @@ class ContentController extends AbstractCrudController
public function removeAdditionalFolderAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth('admin.content.update')) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$folder_id = intval($this->getRequest()->request->get('additional_folder_id'));

View File

@@ -22,6 +22,7 @@
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Country\CountryCreateEvent;
use Thelia\Core\Event\Country\CountryDeleteEvent;
use Thelia\Core\Event\Country\CountryToggleDefaultEvent;
@@ -46,10 +47,10 @@ class CountryController extends AbstractCrudController
'manual',
'country_order',
'admin.country.default',
'admin.country.create',
'admin.country.update',
'admin.country.delete',
AdminResources::COUNTRY_VIEW,
AdminResources::COUNTRY_CREATE,
AdminResources::COUNTRY_UPDATE,
AdminResources::COUNTRY_DELETE,
TheliaEvents::COUNTRY_CREATE,
TheliaEvents::COUNTRY_UPDATE,
@@ -243,7 +244,7 @@ class CountryController extends AbstractCrudController
try {
$this->dispatch(TheliaEvents::COUNTRY_TOGGLE_DEFAULT, $toogleDefaultEvent);
if($toogleDefaultEvent->hasCountry()) {
if ($toogleDefaultEvent->hasCountry()) {
return $this->nullResponse();
}
} catch (\Exception $ex) {

View File

@@ -27,6 +27,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Router;
use Thelia\Condition\ConditionFactory;
use Thelia\Condition\ConditionManagerInterface;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Condition\ConditionCreateOrUpdateEvent;
use Thelia\Core\Event\Coupon\CouponConsumeEvent;
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
@@ -62,7 +63,7 @@ class CouponController extends BaseAdminController
*/
public function browseAction()
{
$this->checkAuth('ADMIN', 'admin.coupon.view');
$this->checkAuth('ADMIN', AdminResources::COUPON_VIEW);
$args['urlReadCoupon'] = $this->getRoute(
'admin.coupon.read',
@@ -94,7 +95,7 @@ class CouponController extends BaseAdminController
*/
public function readAction($couponId)
{
$this->checkAuth('ADMIN', 'admin.coupon.read');
$this->checkAuth('ADMIN', AdminResources::COUPON_VIEW);
// Database request repeated in the loop but cached
$search = CouponQuery::create();
@@ -122,7 +123,7 @@ class CouponController extends BaseAdminController
public function createAction()
{
// Check current user authorization
$response = $this->checkAuth('admin.coupon.create');
$response = $this->checkAuth(AdminResources::COUPON_CREATE);
if ($response !== null) {
return $response;
}
@@ -170,7 +171,7 @@ class CouponController extends BaseAdminController
public function updateAction($couponId)
{
// Check current user authorization
$response = $this->checkAuth('admin.coupon.update');
$response = $this->checkAuth(AdminResources::COUPON_UPDATE);
if ($response !== null) {
return $response;
}
@@ -277,7 +278,7 @@ var_dump($coupon->getIsRemovingPostage());;
*/
public function getConditionInputAction($conditionId)
{
$this->checkAuth('ADMIN', 'admin.coupon.read');
$this->checkAuth('ADMIN', AdminResources::COUPON_VIEW);
$this->checkXmlHttpRequest();
@@ -307,7 +308,7 @@ var_dump($coupon->getIsRemovingPostage());;
*/
public function updateConditionsAction($couponId)
{
$this->checkAuth('ADMIN', 'admin.coupon.read');
$this->checkAuth('ADMIN', AdminResources::COUPON_VIEW);
$this->checkXmlHttpRequest();

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Currency\CurrencyDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Currency\CurrencyUpdateEvent;
@@ -46,10 +47,10 @@ class CurrencyController extends AbstractCrudController
'manual',
'order',
'admin.configuration.currencies.view',
'admin.configuration.currencies.create',
'admin.configuration.currencies.update',
'admin.configuration.currencies.delete',
AdminResources::CURRENCY_VIEW,
AdminResources::CURRENCY_CREATE,
AdminResources::CURRENCY_UPDATE,
AdminResources::CURRENCY_DELETE,
TheliaEvents::CURRENCY_CREATE,
TheliaEvents::CURRENCY_UPDATE,
@@ -186,7 +187,7 @@ class CurrencyController extends AbstractCrudController
public function updateRatesAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
try {
$this->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES);
@@ -204,7 +205,7 @@ class CurrencyController extends AbstractCrudController
public function setDefaultAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$changeEvent = new CurrencyUpdateEvent($this->getRequest()->get('currency_id', 0));

View File

@@ -24,15 +24,13 @@
namespace Thelia\Controller\Admin;
use Propel\Runtime\Exception\PropelException;
use Symfony\Component\Form\Form;
use Thelia\Core\Event\Address\AddressEvent;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Customer\CustomerAddressEvent;
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\Customer\CustomerEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\CustomerModification;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\AddressQuery;
use Thelia\Model\CustomerQuery;
use Thelia\Core\Translation\Translator;
@@ -45,20 +43,18 @@ class CustomerController extends BaseAdminController
{
public function indexAction()
{
if (null !== $response = $this->checkAuth("admin.customer.view")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::CUSTOMER_VIEW)) return $response;
return $this->render("customers", array("display_customer" => 20));
}
public function viewAction($customer_id)
{
if (null !== $response = $this->checkAuth("admin.customer.view")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::CUSTOMER_VIEW)) return $response;
return $this->render("customer-edit", array(
"customer_id" => $customer_id
));
}
/**
* update customer action
*
@@ -67,7 +63,7 @@ class CustomerController extends BaseAdminController
*/
public function updateAction($customer_id)
{
if (null !== $response = $this->checkAuth("admin.customer.update")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::CUSTOMER_UPDATE)) return $response;
$message = false;
@@ -123,7 +119,7 @@ class CustomerController extends BaseAdminController
public function deleteAction()
{
if (null !== $response = $this->checkAuth("admin.customer.delete")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::CUSTOMER_DELETE)) return $response;
$message = null;

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Feature\FeatureAvDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Feature\FeatureAvUpdateEvent;
@@ -46,10 +47,10 @@ class FeatureAvController extends AbstractCrudController
'manual',
'order',
'admin.configuration.features-av.view',
'admin.configuration.features-av.create',
'admin.configuration.features-av.update',
'admin.configuration.features-av.delete',
AdminResources::FEATURE_VIEW,
AdminResources::FEATURE_CREATE,
AdminResources::FEATURE_UPDATE,
AdminResources::FEATURE_DELETE,
TheliaEvents::FEATURE_AV_CREATE,
TheliaEvents::FEATURE_AV_UPDATE,

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Feature\FeatureDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Feature\FeatureUpdateEvent;
@@ -50,10 +51,10 @@ class FeatureController extends AbstractCrudController
'manual',
'order',
'admin.configuration.features.view',
'admin.configuration.features.create',
'admin.configuration.features.update',
'admin.configuration.features.delete',
AdminResources::FEATURE_VIEW,
AdminResources::FEATURE_CREATE,
AdminResources::FEATURE_UPDATE,
AdminResources::FEATURE_DELETE,
TheliaEvents::FEATURE_CREATE,
TheliaEvents::FEATURE_UPDATE,
@@ -253,7 +254,7 @@ class FeatureController extends AbstractCrudController
protected function addRemoveFromAllTemplates($eventType)
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.features.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
try {
if (null !== $object = $this->getExistingObject()) {

View File

@@ -26,6 +26,7 @@ namespace Thelia\Controller\Admin;
use Propel\Runtime\Exception\PropelException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Response;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent;
use Thelia\Core\Event\Document\DocumentDeleteEvent;
use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent;
@@ -69,7 +70,7 @@ class FileController extends BaseAdminController
*/
public function saveImageAjaxAction($parentId, $parentType)
{
$this->checkAuth('ADMIN', 'admin.image.save');
$this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'));
$this->checkXmlHttpRequest();
if ($this->isParentTypeValid($parentType)) {
@@ -145,7 +146,7 @@ class FileController extends BaseAdminController
*/
public function saveDocumentAjaxAction($parentId, $parentType)
{
$this->checkAuth('ADMIN', 'admin.document.save');
$this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'));
$this->checkXmlHttpRequest();
if ($this->isParentTypeValid($parentType)) {
@@ -209,7 +210,7 @@ class FileController extends BaseAdminController
*/
public function getImageListAjaxAction($parentId, $parentType)
{
$this->checkAuth('ADMIN', 'admin.image.save');
$this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'));
$this->checkXmlHttpRequest();
$args = array('imageType' => $parentType, 'parentId' => $parentId);
@@ -226,7 +227,7 @@ class FileController extends BaseAdminController
*/
public function getDocumentListAjaxAction($parentId, $parentType)
{
$this->checkAuth('ADMIN', 'admin.document.save');
$this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'));
$this->checkXmlHttpRequest();
$args = array('documentType' => $parentType, 'parentId' => $parentId);
@@ -243,7 +244,7 @@ class FileController extends BaseAdminController
*/
public function getImageFormAjaxAction($parentId, $parentType)
{
$this->checkAuth('ADMIN', 'admin.image.save');
$this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'));
$this->checkXmlHttpRequest();
$args = array('imageType' => $parentType, 'parentId' => $parentId);
@@ -260,7 +261,7 @@ class FileController extends BaseAdminController
*/
public function getDocumentFormAjaxAction($parentId, $parentType)
{
$this->checkAuth('ADMIN', 'admin.document.save');
$this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'));
$this->checkXmlHttpRequest();
$args = array('documentType' => $parentType, 'parentId' => $parentId);
@@ -277,7 +278,7 @@ class FileController extends BaseAdminController
*/
public function viewImageAction($imageId, $parentType)
{
if (null !== $response = $this->checkAuth('admin.image.view')) {
if (null !== $response = $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'))) {
return $response;
}
try {
@@ -306,7 +307,7 @@ class FileController extends BaseAdminController
*/
public function viewDocumentAction($documentId, $parentType)
{
if (null !== $response = $this->checkAuth('admin.document.view')) {
if (null !== $response = $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'))) {
return $response;
}
try {
@@ -335,7 +336,7 @@ class FileController extends BaseAdminController
*/
public function updateImageAction($imageId, $parentType)
{
if (null !== $response = $this->checkAuth('admin.image.update')) {
if (null !== $response = $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'))) {
return $response;
}
@@ -412,7 +413,7 @@ class FileController extends BaseAdminController
*/
public function updateDocumentAction($documentId, $parentType)
{
if (null !== $response = $this->checkAuth('admin.document.update')) {
if (null !== $response = $this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'))) {
return $response;
}
@@ -489,7 +490,7 @@ class FileController extends BaseAdminController
*/
public function deleteImageAction($imageId, $parentType)
{
$this->checkAuth('ADMIN', 'admin.image.delete');
$this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'));
$this->checkXmlHttpRequest();
$fileManager = new FileManager($this->container);
@@ -532,7 +533,7 @@ class FileController extends BaseAdminController
*/
public function deleteDocumentAction($documentId, $parentType)
{
$this->checkAuth('ADMIN', 'admin.document.delete');
$this->checkAuth('ADMIN', AdminResources::retrieve($parentType, 'update'));
$this->checkXmlHttpRequest();
$fileManager = new FileManager($this->container);

View File

@@ -22,6 +22,7 @@
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Folder\FolderCreateEvent;
use Thelia\Core\Event\Folder\FolderDeleteEvent;
use Thelia\Core\Event\Folder\FolderToggleVisibilityEvent;
@@ -47,10 +48,10 @@ class FolderController extends AbstractCrudController
'manual',
'folder_order',
'admin.folder.default',
'admin.folder.create',
'admin.folder.update',
'admin.folder.delete',
AdminResources::FOLDER_VIEW,
AdminResources::FOLDER_CREATE,
AdminResources::FOLDER_UPDATE,
AdminResources::FOLDER_DELETE,
TheliaEvents::FOLDER_CREATE,
TheliaEvents::FOLDER_UPDATE,

View File

@@ -23,6 +23,8 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
/**
* Class LanguageController
* @package Thelia\Controller\Admin
@@ -32,7 +34,7 @@ class LanguageController extends BaseAdminController
{
public function defaultAction()
{
if (null !== $response = $this->checkAuth("admin.configuration.languages.view")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE_VIEW)) return $response;
return $this->render("languages");
}

View File

@@ -23,6 +23,8 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
/**
* Class MailingSystemController
* @package Thelia\Controller\Admin
@@ -32,7 +34,7 @@ class MailingSystemController extends BaseAdminController
{
public function defaultAction()
{
if (null !== $response = $this->checkAuth("admin.configuration.mailing-system.view")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::MAILING_SYSTEM_VIEW)) return $response;
return $this->render("mailing-system");
}

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Message\MessageDeleteEvent;
use Thelia\Core\Event\TheliaEvents;use Thelia\Core\Event\Message\MessageUpdateEvent;
use Thelia\Core\Event\Message\MessageCreateEvent;
@@ -44,10 +45,10 @@ class MessageController extends AbstractCrudController
null, // no sort order change
null, // no sort order change
'admin.configuration.messages.view',
'admin.configuration.messages.create',
'admin.configuration.messages.update',
'admin.configuration.messages.delete',
AdminResources::MESSAGE_VIEW,
AdminResources::MESSAGE_CREATE,
AdminResources::MESSAGE_UPDATE,
AdminResources::MESSAGE_DELETE,
TheliaEvents::MESSAGE_CREATE,
TheliaEvents::MESSAGE_UPDATE,

View File

@@ -23,6 +23,13 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Module\ModuleDeleteEvent;
use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Module\ModuleManagement;
/**
* Class ModuleController
* @package Thelia\Controller\Admin
@@ -32,8 +39,12 @@ class ModuleController extends BaseAdminController
{
public function indexAction()
{
if (null !== $response = $this->checkAuth("admin.module.view")) return $response;
return $this->render("modules", array("display_module" => 20));
if (null !== $response = $this->checkAuth(AdminResources::MODULE_VIEW)) return $response;
$modulemanagement = new ModuleManagement();
$modulemanagement->updateModules();
return $this->render("modules");
}
public function updateAction($module_id)
@@ -42,4 +53,68 @@ class ModuleController extends BaseAdminController
"module_id" => $module_id
));
}
public function toggleActivationAction($module_id)
{
if (null !== $response = $this->checkAuth("admin.module.update")) return $response;
$message = null;
try {
$event = new ModuleToggleActivationEvent($module_id);
$this->dispatch(TheliaEvents::MODULE_TOGGLE_ACTIVATION, $event);
if (null === $event->getModule()) {
throw new \LogicException(
$this->getTranslator()->trans("No %obj was updated.", array('%obj' => 'Module')));
}
} catch (\Exception $e) {
$message = $e->getMessage();
}
if ($this->getRequest()->isXmlHttpRequest()) {
if ($message) {
$response = $this->jsonResponse(json_encode(array(
"error" => $message
)), 500);
} else {
$response = $this->nullResponse();
}
} else {
$this->redirectToRoute('admin.module');
}
return $response;
}
public function deleteAction()
{
if (null !== $response = $this->checkAuth("admin.module.delete")) return $response;
$message = null;
try {
$module_id = $this->getRequest()->get('module_id');
$deleteEvent = new ModuleDeleteEvent($module_id);
$this->dispatch(TheliaEvents::MODULE_DELETE, $deleteEvent);
if($deleteEvent->hasModule() === false) {
throw new \LogicException(
$this->getTranslator()->trans("No %obj was updated.", array('%obj' => 'Module')));
}
} catch (\Exception $e) {
\Thelia\Log\Tlog::getInstance()->error(sprintf("error during module removal : %s", $message));
$message = $e->getMessage();
}
if($message) {
return $this->render("modules", array(
"error_message" => $message
));
} else {
$this->redirectToRoute('admin.module');
}
}
}

View File

@@ -24,6 +24,7 @@
namespace Thelia\Controller\Admin;
use Symfony\Component\HttpFoundation\Response;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Order\OrderAddressEvent;
use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\PdfEvent;
@@ -44,7 +45,7 @@ class OrderController extends BaseAdminController
{
public function indexAction()
{
if (null !== $response = $this->checkAuth("admin.orders.view")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::ORDER_VIEW)) return $response;
return $this->render("orders", array("display_order" => 20));
}
@@ -57,7 +58,7 @@ class OrderController extends BaseAdminController
public function updateStatus($order_id = null)
{
if (null !== $response = $this->checkAuth("admin.order.update")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::ORDER_UPDATE)) return $response;
$message = null;
@@ -108,7 +109,7 @@ class OrderController extends BaseAdminController
public function updateDeliveryRef($order_id)
{
if (null !== $response = $this->checkAuth("admin.order.update")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::ORDER_UPDATE)) return $response;
$message = null;
@@ -143,7 +144,7 @@ class OrderController extends BaseAdminController
public function updateAddress($order_id)
{
if (null !== $response = $this->checkAuth("admin.order.update")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::ORDER_UPDATE)) return $response;
$message = null;
@@ -209,8 +210,7 @@ class OrderController extends BaseAdminController
protected function generatePdf($order_id, $fileName)
{
if (null !== $response = $this->checkAuth("admin.order.update")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::ORDER_UPDATE)) return $response;
$html = $this->renderRaw(
$fileName,
@@ -227,7 +227,7 @@ class OrderController extends BaseAdminController
$this->dispatch(TheliaEvents::GENERATE_PDF, $pdfEvent);
if($pdfEvent->hasPdf()) {
if ($pdfEvent->hasPdf()) {
return Response::create($pdfEvent->getPdf(), 200,
array(
'Content-type' => "application/pdf",

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Product\ProductAddCategoryEvent;
use Thelia\Core\Event\Product\ProductDeleteCategoryEvent;
use Thelia\Core\Event\Product\ProductDeleteEvent;
@@ -61,10 +62,10 @@ class ProductController extends AbstractCrudController
'manual',
'product_order',
'admin.products.default',
'admin.products.create',
'admin.products.update',
'admin.products.delete',
AdminResources::PRODUCT_VIEW,
AdminResources::PRODUCT_CREATE,
AdminResources::PRODUCT_UPDATE,
AdminResources::PRODUCT_DELETE,
TheliaEvents::PRODUCT_CREATE,
TheliaEvents::PRODUCT_UPDATE,
@@ -280,7 +281,7 @@ class ProductController extends AbstractCrudController
public function setToggleVisibilityAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$event = new ProductToggleVisibilityEvent($this->getExistingObject());
@@ -356,7 +357,7 @@ class ProductController extends AbstractCrudController
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$content_id = intval($this->getRequest()->get('content_id'));
@@ -382,7 +383,7 @@ class ProductController extends AbstractCrudController
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$content_id = intval($this->getRequest()->get('content_id'));
@@ -434,7 +435,7 @@ class ProductController extends AbstractCrudController
public function addAccessoryAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$accessory_id = intval($this->getRequest()->get('accessory_id'));
@@ -459,7 +460,7 @@ class ProductController extends AbstractCrudController
public function deleteAccessoryAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$accessory_id = intval($this->getRequest()->get('accessory_id'));
@@ -515,7 +516,7 @@ class ProductController extends AbstractCrudController
public function setProductTemplateAction($productId)
{
// Check current user authorization
if (null !== $response = $this->checkAuth('admin.products.update')) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$product = ProductQuery::create()->findPk($productId);
@@ -612,7 +613,7 @@ class ProductController extends AbstractCrudController
public function addAdditionalCategoryAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$category_id = intval($this->getRequest()->request->get('additional_category_id'));
@@ -637,7 +638,7 @@ class ProductController extends AbstractCrudController
public function deleteAdditionalCategoryAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$category_id = intval($this->getRequest()->get('additional_category_id'));
@@ -734,7 +735,7 @@ class ProductController extends AbstractCrudController
public function addCombinationAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$event = new ProductCreateCombinationEvent(
$this->getExistingObject(),
@@ -759,7 +760,7 @@ class ProductController extends AbstractCrudController
public function deleteCombinationAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$event = new ProductDeleteCombinationEvent(
$this->getExistingObject(),

View File

@@ -0,0 +1,229 @@
<?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\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Profile\ProfileEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\ProfileCreationForm;
use Thelia\Form\ProfileModificationForm;
use Thelia\Form\ProfileProfileListUpdateForm;
use Thelia\Model\ProfileQuery;
class ProfileController extends AbstractCrudController
{
public function __construct()
{
parent::__construct(
'profile',
'manual',
'order',
AdminResources::PRODUCT_VIEW,
AdminResources::PRODUCT_CREATE,
AdminResources::PRODUCT_UPDATE,
AdminResources::PRODUCT_DELETE,
TheliaEvents::PROFILE_CREATE,
TheliaEvents::PROFILE_UPDATE,
TheliaEvents::PROFILE_DELETE
);
}
protected function getCreationForm()
{
return new ProfileCreationForm($this->getRequest());
}
protected function getUpdateForm()
{
return new ProfileModificationForm($this->getRequest());
}
protected function getCreationEvent($formData)
{
$event = new ProfileEvent();
$event->setLocale($formData['locale']);
$event->setCode($formData['code']);
$event->setTitle($formData['title']);
$event->setChapo($formData['chapo']);
$event->setDescription($formData['description']);
$event->setPostscriptum($formData['postscriptum']);
return $event;
}
protected function getUpdateEvent($formData)
{
$event = new ProfileEvent();
$event->setLocale($formData['locale']);
$event->setId($formData['id']);
$event->setTitle($formData['title']);
$event->setChapo($formData['chapo']);
$event->setDescription($formData['description']);
$event->setPostscriptum($formData['postscriptum']);
return $event;
}
protected function getDeleteEvent()
{
$event = new ProfileEvent();
$event->setId(
$this->getRequest()->get('profile_id', 0)
);
return $event;
}
protected function eventContainsObject($event)
{
return $event->hasProfile();
}
protected function hydrateObjectForm($object)
{
$data = array(
'id' => $object->getId(),
'locale' => $object->getLocale(),
'title' => $object->getTitle(),
'description' => $object->getDescription(),
'code' => $object->getCode(),
);
// Setup the object form
return new ProfileModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event)
{
return $event->hasProfile() ? $event->getProfile() : null;
}
protected function getExistingObject()
{
return ProfileQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('profile_id'));
}
protected function getObjectLabel($object)
{
return $object->getTitle();
}
protected function getObjectId($object)
{
return $object->getId();
}
protected function getViewArguments()
{
return array();
}
protected function getRouteArguments($profile_id = null)
{
return array(
'profile_id' => $profile_id === null ? $this->getRequest()->get('profile_id') : $profile_id,
);
}
protected function renderListTemplate($currentOrder)
{
// We always return to the feature edition form
return $this->render(
'profiles',
array()
);
}
protected function renderEditionTemplate()
{
// We always return to the feature edition form
return $this->render('profile-edit', array_merge($this->getViewArguments(), $this->getRouteArguments()));
}
protected function redirectToEditionTemplate($request = null, $country = null)
{
// We always return to the feature edition form
$this->redirectToRoute(
"admin.configuration.profiles.update",
$this->getViewArguments($country),
$this->getRouteArguments()
);
}
/**
* Put in this method post object creation processing if required.
*
* @param ProfileEvent $createEvent the create event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalCreateAction($createEvent)
{
$this->redirectToRoute(
"admin.configuration.profiles.update",
$this->getViewArguments(),
$this->getRouteArguments($createEvent->getProfile()->getId())
);
}
protected function redirectToListTemplate()
{
$this->redirectToRoute(
"admin.configuration.profiles.list"
);
}
protected function checkRequirements($formData)
{
$type = $formData['type'];
}
protected function getRequirements($type, $formData)
{
$requirements = array();
foreach($formData as $data => $value) {
if(!strstr($data, ':')) {
continue;
}
$couple = explode(':', $data);
if(count($couple) != 2 || $couple[0] != $type) {
continue;
}
$requirements[$couple[1]] = $value;
}
return $requirements;
}
}

View File

@@ -22,6 +22,7 @@
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\ShippingZone\ShippingZoneAddAreaEvent;
use Thelia\Core\Event\ShippingZone\ShippingZoneRemoveAreaEvent;
use Thelia\Core\Event\TheliaEvents;
@@ -40,13 +41,13 @@ class ShippingZoneController extends BaseAdminController
public function indexAction()
{
if (null !== $response = $this->checkAuth("admin.shipping-zones.view")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::SHIPPING_ZONE_VIEW)) return $response;
return $this->render("shipping-zones", array("display_shipping_zone" => 20));
}
public function updateAction($shipping_zones_id)
{
if (null !== $response = $this->checkAuth("admin.shipping-zones.view")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::SHIPPING_ZONE_VIEW)) return $response;
return $this->render("shipping-zones-edit", array(
"shipping_zones_id" => $shipping_zones_id
));
@@ -57,7 +58,7 @@ class ShippingZoneController extends BaseAdminController
*/
public function addArea()
{
if (null !== $response = $this->checkAuth("admin.shipping-zones.update")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::SHIPPING_ZONE_UPDATE)) return $response;
$shippingAreaForm = new ShippingZoneAddArea($this->getRequest());
$error_msg = null;
@@ -92,7 +93,7 @@ class ShippingZoneController extends BaseAdminController
public function removeArea()
{
if (null !== $response = $this->checkAuth("admin.shipping-zones.update")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::SHIPPING_ZONE_UPDATE)) return $response;
$shippingAreaForm = new ShippingZoneRemoveArea($this->getRequest());
$error_msg = null;
@@ -140,5 +141,4 @@ class ShippingZoneController extends BaseAdminController
return $this->getRequest()->get('shipping_zone_id', 0);
}
}

View File

@@ -0,0 +1,228 @@
<?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\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Tax\TaxEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\TaxCreationForm;
use Thelia\Form\TaxModificationForm;
use Thelia\Form\TaxTaxListUpdateForm;
use Thelia\Model\TaxQuery;
class TaxController extends AbstractCrudController
{
public function __construct()
{
parent::__construct(
'tax',
'manual',
'order',
AdminResources::TAX_VIEW,
AdminResources::TAX_CREATE,
AdminResources::TAX_UPDATE,
AdminResources::TAX_DELETE,
TheliaEvents::TAX_CREATE,
TheliaEvents::TAX_UPDATE,
TheliaEvents::TAX_DELETE
);
}
protected function getCreationForm()
{
return new TaxCreationForm($this->getRequest());
}
protected function getUpdateForm()
{
return new TaxModificationForm($this->getRequest());
}
protected function getCreationEvent($formData)
{
$event = new TaxEvent();
$event->setLocale($formData['locale']);
$event->setTitle($formData['title']);
$event->setDescription($formData['description']);
$event->setType($formData['type']);
$event->setRequirements($this->getRequirements($formData['type'], $formData));
return $event;
}
protected function getUpdateEvent($formData)
{
$event = new TaxEvent();
$event->setLocale($formData['locale']);
$event->setId($formData['id']);
$event->setTitle($formData['title']);
$event->setDescription($formData['description']);
$event->setType($formData['type']);
$event->setRequirements($this->getRequirements($formData['type'], $formData));
return $event;
}
protected function getDeleteEvent()
{
$event = new TaxEvent();
$event->setId(
$this->getRequest()->get('tax_id', 0)
);
return $event;
}
protected function eventContainsObject($event)
{
return $event->hasTax();
}
protected function hydrateObjectForm($object)
{
$data = array(
'id' => $object->getId(),
'locale' => $object->getLocale(),
'title' => $object->getTitle(),
'description' => $object->getDescription(),
'type' => $object->getType(),
);
// Setup the object form
return new TaxModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event)
{
return $event->hasTax() ? $event->getTax() : null;
}
protected function getExistingObject()
{
return TaxQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('tax_id'));
}
protected function getObjectLabel($object)
{
return $object->getTitle();
}
protected function getObjectId($object)
{
return $object->getId();
}
protected function getViewArguments()
{
return array();
}
protected function getRouteArguments($tax_id = null)
{
return array(
'tax_id' => $tax_id === null ? $this->getRequest()->get('tax_id') : $tax_id,
);
}
protected function renderListTemplate($currentOrder)
{
// We always return to the feature edition form
return $this->render(
'taxes-rules',
array()
);
}
protected function renderEditionTemplate()
{
// We always return to the feature edition form
return $this->render('tax-edit', array_merge($this->getViewArguments(), $this->getRouteArguments()));
}
protected function redirectToEditionTemplate($request = null, $country = null)
{
// We always return to the feature edition form
$this->redirectToRoute(
"admin.configuration.taxes.update",
$this->getViewArguments($country),
$this->getRouteArguments()
);
}
/**
* Put in this method post object creation processing if required.
*
* @param TaxEvent $createEvent the create event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalCreateAction($createEvent)
{
$this->redirectToRoute(
"admin.configuration.taxes.update",
$this->getViewArguments(),
$this->getRouteArguments($createEvent->getTax()->getId())
);
}
protected function redirectToListTemplate()
{
$this->redirectToRoute(
"admin.configuration.taxes-rules.list"
);
}
protected function checkRequirements($formData)
{
$type = $formData['type'];
}
protected function getRequirements($type, $formData)
{
$requirements = array();
foreach($formData as $data => $value) {
if(!strstr($data, ':')) {
continue;
}
$couple = explode(':', $data);
if(count($couple) != 2 || $couple[0] != $type) {
continue;
}
$requirements[$couple[1]] = $value;
}
return $requirements;
}
}

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Tax\TaxRuleEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\TaxRuleCreationForm;
@@ -40,10 +41,10 @@ class TaxRuleController extends AbstractCrudController
'manual',
'order',
'admin.configuration.taxrule.view',
'admin.configuration.taxrule.create',
'admin.configuration.taxrule.update',
'admin.configuration.taxrule.delete',
AdminResources::TAX_VIEW,
AdminResources::TAX_CREATE,
AdminResources::TAX_UPDATE,
AdminResources::TAX_DELETE,
TheliaEvents::TAX_RULE_CREATE,
TheliaEvents::TAX_RULE_UPDATE,
@@ -199,8 +200,8 @@ class TaxRuleController extends AbstractCrudController
/**
* Put in this method post object creation processing if required.
*
* @param TaxRuleEvent $createEvent the create event
* @return Response a response, or null to continue normal processing
* @param TaxRuleEvent $createEvent the create event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalCreateAction($createEvent)
{
@@ -236,10 +237,27 @@ class TaxRuleController extends AbstractCrudController
return parent::updateAction();
}
public function setDefaultAction()
{
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$setDefaultEvent = new TaxRuleEvent();
$taxRuleId = $this->getRequest()->attributes->get('tax_rule_id');
$setDefaultEvent->setId(
$taxRuleId
);
$this->dispatch(TheliaEvents::TAX_RULE_SET_DEFAULT, $setDefaultEvent);
$this->redirectToListTemplate();
}
public function processUpdateTaxesAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth('admin.configuration.taxrule.update')) return $response;
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$error_msg = false;
@@ -284,4 +302,4 @@ class TaxRuleController extends AbstractCrudController
// At this point, the form has errors, and should be redisplayed.
return $this->renderEditionTemplate();
}
}
}

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Event\Template\TemplateDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Template\TemplateUpdateEvent;
@@ -51,10 +52,10 @@ class TemplateController extends AbstractCrudController
null,
null,
'admin.configuration.templates.view',
'admin.configuration.templates.create',
'admin.configuration.templates.update',
'admin.configuration.templates.delete',
AdminResources::TEMPLATE_VIEW,
AdminResources::TEMPLATE_CREATE,
AdminResources::TEMPLATE_UPDATE,
AdminResources::TEMPLATE_DELETE,
TheliaEvents::TEMPLATE_CREATE,
TheliaEvents::TEMPLATE_UPDATE,
@@ -212,7 +213,7 @@ class TemplateController extends AbstractCrudController
public function addAttributeAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.add")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::TEMPLATE_UPDATE)) return $response;
$attribute_id = intval($this->getRequest()->get('attribute_id'));
@@ -236,7 +237,7 @@ class TemplateController extends AbstractCrudController
public function deleteAttributeAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.delete")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::TEMPLATE_UPDATE)) return $response;
$event = new TemplateDeleteAttributeEvent(
$this->getExistingObject(),
@@ -271,7 +272,7 @@ class TemplateController extends AbstractCrudController
public function addFeatureAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.add")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::TEMPLATE_UPDATE)) return $response;
$feature_id = intval($this->getRequest()->get('feature_id'));
@@ -295,7 +296,7 @@ class TemplateController extends AbstractCrudController
public function deleteFeatureAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.delete")) return $response;
if (null !== $response = $this->checkAuth(AdminResources::TEMPLATE_UPDATE)) return $response;
$event = new TemplateDeleteFeatureEvent(
$this->getExistingObject(),

View File

@@ -58,7 +58,7 @@ class BaseController extends ContainerAware
/**
* Return an empty response (after an ajax request, for example)
*/
protected function nullResponse($status = 200)
protected function nullResponse($content = null, $status = 200)
{
return new Response(null, $status);
}
@@ -66,9 +66,9 @@ class BaseController extends ContainerAware
/**
* Return a JSON response
*/
protected function jsonResponse($json_data)
protected function jsonResponse($json_data, $status = 200)
{
return new Response($json_data, 200, array('content-type' => 'application/json'));
return new Response($json_data, $status, array('content-type' => 'application/json'));
}
/**
@@ -303,4 +303,17 @@ class BaseController extends ContainerAware
return $mailer->getSwiftMailer();
}
/**
* @return ParserInterface instance parser
*/
protected function getParser()
{
return $this->container->get("thelia.parser");
}
protected function render($inline)
{
return $this->getParser()->fetch(sprintf("string:%s", $inline));
}
}

View File

@@ -0,0 +1,73 @@
<?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\Controller\Front;
use Thelia\Form\ContactForm;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\ConfigQuery;
/**
* Class ContactController
* @package Thelia\Controller\Front
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ContactController extends BaseFrontController
{
/**
* send contact message
*/
public function sendAction()
{
$error_message = false;
$contactForm = new ContactForm($this->getRequest());
try {
$form = $this->validateForm($contactForm);
$message = \Swift_Message::newInstance($form->get('subject')->getData())
->addFrom($form->get('email')->getData(), $form->get('firstname')->getData().' '.$form->get('lastname')->getData())
->addTo(ConfigQuery::read('contact_email'), ConfigQuery::read('company_name'))
->setBody($form->get('message')->getData())
;
$this->getMailer()->send($message);
} catch(FormValidationException $e) {
$error_message = $e->getMessage();
}
if ($error_message !== false) {
\Thelia\Log\Tlog::getInstance()->error(sprintf('Error during sending contact mail : %s', $error_message));
$contactForm->setErrorMessage($error_message);
$this->getParserContext()
->addForm($contactForm)
->setGeneralError($error_message)
;
} else {
$this->redirectToRoute('contact.success');
}
}
}

View File

@@ -0,0 +1,49 @@
<?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\Controller\Front;
/**
* Class Mail
* @package Thelia\Controller\Front
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Mail extends BaseFrontController
{
/**
* This is a demo how to send a mail using swiftmailer + smarty
*/
public function test()
{
$message = \Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('john@doe.com' => 'John Doe'))
->setTo(array('mraynaud@openstudio.fr' => 'name'))
->setBody($this->render('Here is the message itself'))
;
$this->getMailer()->send($message);
exit;
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Area;
/**
* Class AreaAddCountryEvent
* @package Thelia\Core\Event\Area
@@ -34,7 +33,7 @@ class AreaAddCountryEvent extends AreaEvent
protected $area_id;
protected $country_id;
function __construct($area_id, $country_id)
public function __construct($area_id, $country_id)
{
$this->area_id = $area_id;
$this->country_id = $country_id;
@@ -80,7 +79,4 @@ class AreaAddCountryEvent extends AreaEvent
return $this->country_id;
}
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Area;
/**
* Class AreaCreateEvent
* @package Thelia\Core\Event\Area
@@ -49,5 +48,4 @@ class AreaCreateEvent extends AreaEvent
return $this->name;
}
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Area;
/**
* Class AreaDeleteEvent
* @package Thelia\Core\Event\Area
@@ -61,5 +60,4 @@ class AreaDeleteEvent extends AreaEvent
return $this->area_id;
}
}
}

View File

@@ -24,7 +24,6 @@
namespace Thelia\Core\Event\Area;
use Thelia\Core\Event\ActionEvent;
/**
* Class AreaEvent
* @package Thelia\Core\Event\Shipping
@@ -63,4 +62,4 @@ class AreaEvent extends ActionEvent
{
return null !== $this->area;
}
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Area;
/**
* Class AreaRemoveCountryEvent
* @package Thelia\Core\Event\Area
@@ -32,4 +31,4 @@ namespace Thelia\Core\Event\Area;
class AreaRemoveCountryEvent extends AreaAddCountryEvent
{
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Area;
/**
* Class AreaUpdateEvent
* @package Thelia\Core\Event\Area
@@ -32,4 +31,4 @@ namespace Thelia\Core\Event\Area;
class AreaUpdateEvent extends AreaCreateEvent
{
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Area;
/**
* Class AreaUpdatePostageEvent
* @package Thelia\Core\Event\Area
@@ -34,7 +33,7 @@ class AreaUpdatePostageEvent extends AreaEvent
protected $area_id;
protected $postage;
function __construct($area_id)
public function __construct($area_id)
{
$this->area_id = $area_id;
}
@@ -79,7 +78,4 @@ class AreaUpdatePostageEvent extends AreaEvent
return $this->postage;
}
}
}

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\Event\Cache;
use Thelia\Core\Event\ActionEvent;
/**
* Class CacheEvent
* @package Thelia\Core\Event\Cache
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CacheEvent extends ActionEvent
{
/**
* @var string cache directory
*/
protected $dir;
public function __construct($dir)
{
$this->dir = $dir;
}
/**
* @param mixed $dir
*
* @return $this
*/
public function setDir($dir)
{
$this->dir = $dir;
return $this;
}
/**
* @return mixed
*/
public function getDir()
{
return $this->dir;
}
}

View File

@@ -24,7 +24,6 @@
namespace Thelia\Core\Event\Content;
use Thelia\Model\Content;
/**
* Class ContentAddFolderEvent
* @package Thelia\Core\Event\Content
@@ -61,6 +60,4 @@ class ContentAddFolderEvent extends ContentEvent
return $this->folderId;
}
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Content;
/**
* Class ContentRemoveFolderEvent
* @package Thelia\Core\Event\Content
@@ -31,4 +30,4 @@ namespace Thelia\Core\Event\Content;
*/
class ContentRemoveFolderEvent extends ContentAddFolderEvent
{
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Country;
/**
* Class CountryCreateEvent
* @package Thelia\Core\Event\Country
@@ -150,5 +149,4 @@ class CountryCreateEvent extends CountryEvent
return $this->area;
}
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Country;
/**
* Class CountryDeleteEvent
* @package Thelia\Core\Event\Country
@@ -36,7 +35,7 @@ class CountryDeleteEvent extends CountryEvent
*/
protected $country_id;
function __construct($country_id)
public function __construct($country_id)
{
$this->country_id = $country_id;
}
@@ -57,4 +56,4 @@ class CountryDeleteEvent extends CountryEvent
return $this->country_id;
}
}
}

View File

@@ -25,7 +25,6 @@ namespace Thelia\Core\Event\Country;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Country;
/**
* Class CountryEvent
* @package Thelia\Core\Event\Country
@@ -38,7 +37,7 @@ class CountryEvent extends ActionEvent
*/
protected $country;
function __construct(Country $country = null)
public function __construct(Country $country = null)
{
$this->country = $country;
}
@@ -69,5 +68,4 @@ class CountryEvent extends ActionEvent
return null !== $this->country;
}
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Country;
/**
* Class CountryToggleDefaultEvent
* @package Thelia\Core\Event\Country
@@ -33,7 +32,7 @@ class CountryToggleDefaultEvent extends CountryEvent
{
protected $country_id;
function __construct($country_id)
public function __construct($country_id)
{
$this->country_id = $country_id;
}
@@ -45,4 +44,4 @@ class CountryToggleDefaultEvent extends CountryEvent
{
return $this->country_id;
}
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Country;
/**
* Class CountryUpdateEvent
* @package Thelia\Core\Event\Country
@@ -37,7 +36,7 @@ class CountryUpdateEvent extends CountryCreateEvent
protected $description;
protected $postscriptum;
function __construct($country_id)
public function __construct($country_id)
{
$this->country_id = $country_id;
}
@@ -114,7 +113,4 @@ class CountryUpdateEvent extends CountryCreateEvent
return $this->country_id;
}
}
}

View File

@@ -0,0 +1,61 @@
<?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\Event\Module;
/**
* Class ModuleDeleteEvent
* @package Thelia\Core\Event\Module
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ModuleDeleteEvent extends ModuleEvent
{
/**
* @var int module id
*/
protected $module_id;
function __construct($module_id)
{
$this->module_id = $module_id;
}
/**
* @param int $module_id
*/
public function setModuleId($module_id)
{
$this->module_id = $module_id;
}
/**
* @return int
*/
public function getModuleId()
{
return $this->module_id;
}
}

View File

@@ -0,0 +1,70 @@
<?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\Event\Module;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Module;
/**
* Class ModuleEvent
* @package Thelia\Core\Event\Module
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ModuleEvent extends ActionEvent
{
/**
* @var \Thelia\Model\Module
*/
protected $module;
public function __construct(Module $module = null)
{
$this->module = $module;
}
/**
* @param \Thelia\Model\Module $module
*
* @return $this
*/
public function setModule(Module $module)
{
$this->module = $module;
return $this;
}
/**
* @return \Thelia\Model\Module
*/
public function getModule()
{
return $this->module;
}
public function hasModule()
{
return null !== $this->module;
}
}

View File

@@ -0,0 +1,63 @@
<?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\Event\Module;
/**
* Class ModuleToggleActivationEvent
* @package Thelia\Core\Event\Module
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ModuleToggleActivationEvent extends ModuleEvent
{
/**
* @var int
*/
protected $module_id;
public function __construct($module_id)
{
$this->module_id = $module_id;
}
/**
* @param int $module_id
*
* @return $this
*/
public function setModuleId($module_id)
{
$this->module_id = $module_id;
return $this;
}
/**
* @return int
*/
public function getModuleId()
{
return $this->module_id;
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event;
/**
* Class PdfEvent
* @package Thelia\Core\Event
@@ -44,12 +43,12 @@ class PdfEvent extends ActionEvent
/**
* @param $content html content to transform into pdf
* @param string $orientation page orientation, same as TCPDF
* @param string $format The format used for pages, same as TCPDF
* @param string $lang Lang : fr, en, it...
* @param bool $unicode TRUE means that the input text is unicode (default = true)
* @param string $encoding charset encoding; default is UTF-8
* @param array $marges Default marges (left, top, right, bottom)
* @param string $orientation page orientation, same as TCPDF
* @param string $format The format used for pages, same as TCPDF
* @param string $lang Lang : fr, en, it...
* @param bool $unicode TRUE means that the input text is unicode (default = true)
* @param string $encoding charset encoding; default is UTF-8
* @param array $marges Default marges (left, top, right, bottom)
*/
public function __construct($content, $orientation = 'P', $format = 'A4', $lang='fr', $unicode=true, $encoding='UTF-8',array $marges = array(0, 0, 0, 0))
{
@@ -189,5 +188,4 @@ class PdfEvent extends ActionEvent
return $this->unicode;
}
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Product;
class ProductCreateEvent extends ProductEvent
{
protected $ref;

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Product;
class ProductDeleteEvent extends ProductEvent
{
public function __construct($product_id)

View File

@@ -0,0 +1,131 @@
<?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\Event\Profile;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Profile;
class ProfileEvent extends ActionEvent
{
protected $profile = null;
protected $id = null;
protected $locale = null;
protected $code = null;
protected $title = null;
protected $chapo = null;
protected $description = null;
protected $postscriptum = null;
public function __construct(Profile $profile = null)
{
$this->profile = $profile;
}
public function hasProfile()
{
return ! is_null($this->profile);
}
public function getProfile()
{
return $this->profile;
}
public function setProfile(Profile $profile)
{
$this->profile = $profile;
return $this;
}
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
public function setCode($code)
{
$this->code = $code;
}
public function getCode()
{
return $this->code;
}
public function setChapo($chapo)
{
$this->chapo = $chapo;
}
public function getChapo()
{
return $this->chapo;
}
public function setDescription($description)
{
$this->description = $description;
}
public function getDescription()
{
return $this->description;
}
public function setLocale($locale)
{
$this->locale = $locale;
}
public function getLocale()
{
return $this->locale;
}
public function setPostscriptum($postscriptum)
{
$this->postscriptum = $postscriptum;
}
public function getPostscriptum()
{
return $this->postscriptum;
}
public function setTitle($title)
{
$this->title = $title;
}
public function getTitle()
{
return $this->title;
}
}

View File

@@ -24,7 +24,6 @@
namespace Thelia\Core\Event\ShippingZone;
use Thelia\Core\Event\ActionEvent;
/**
* Class ShippingZoneAddAreaEvent
* @package Thelia\Core\Event\ShippingZone
@@ -35,7 +34,7 @@ class ShippingZoneAddAreaEvent extends ActionEvent
protected $area_id;
protected $shopping_zone_id;
function __construct($area_id, $shopping_zone_id)
public function __construct($area_id, $shopping_zone_id)
{
$this->area_id = $area_id;
$this->shopping_zone_id = $shopping_zone_id;
@@ -81,7 +80,4 @@ class ShippingZoneAddAreaEvent extends ActionEvent
return $this->shopping_zone_id;
}
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\ShippingZone;
/**
* Class ShippingZoneRemoveAreaEvent
* @package Thelia\Core\Event\ShippingZone
@@ -32,4 +31,4 @@ namespace Thelia\Core\Event\ShippingZone;
class ShippingZoneRemoveAreaEvent extends ShippingZoneAddAreaEvent
{
}
}

View File

@@ -0,0 +1,120 @@
<?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\Event\Tax;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Tax;
class TaxEvent extends ActionEvent
{
protected $tax = null;
protected $locale;
protected $id;
protected $title;
protected $description;
protected $type;
protected $requirements;
public function __construct(Tax $tax = null)
{
$this->tax = $tax;
}
public function hasTax()
{
return ! is_null($this->tax);
}
public function getTax()
{
return $this->tax;
}
public function setTax(Tax $tax)
{
$this->tax = $tax;
return $this;
}
public function setDescription($description)
{
$this->description = $description;
}
public function getDescription()
{
return $this->description;
}
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
public function setTitle($title)
{
$this->title = $title;
}
public function getTitle()
{
return $this->title;
}
public function setLocale($locale)
{
$this->locale = $locale;
}
public function getLocale()
{
return $this->locale;
}
public function setType($type)
{
$this->type = $type;
}
public function getType()
{
return $this->type;
}
public function setRequirements($requirements)
{
$this->requirements = $requirements;
}
public function getRequirements()
{
return $this->requirements;
}
}

View File

@@ -118,5 +118,4 @@ class TaxRuleEvent extends ActionEvent
return $this->taxList;
}
}

View File

@@ -183,7 +183,6 @@ final class TheliaEvents
const FOLDER_TOGGLE_VISIBILITY = "action.toggleFolderVisibility";
const FOLDER_UPDATE_POSITION = "action.updateFolderPosition";
const BEFORE_CREATEFOLDER = "action.before_createFolder";
const AFTER_CREATEFOLDER = "action.after_createFolder";
@@ -204,7 +203,6 @@ final class TheliaEvents
const CONTENT_ADD_FOLDER = "action.contentAddFolder";
const CONTENT_REMOVE_FOLDER = "action.contentRemoveFolder";
const BEFORE_CREATECONTENT = "action.before_createContent";
const AFTER_CREATECONTENT = "action.after_createContent";
@@ -222,7 +220,6 @@ final class TheliaEvents
const COUNTRY_TOGGLE_DEFAULT = "action.toggleCountryDefault";
//const COUNTRY_UPDATE_POSITION = "action.updateFolderPosition";
const BEFORE_CREATECOUNTRY = "action.before_createCountry";
const AFTER_CREATECOUNTRY = "action.after_createCountry";
@@ -543,6 +540,19 @@ final class TheliaEvents
const CHANGE_DEFAULT_CURRENCY = 'action.changeDefaultCurrency';
// -- Tax management ---------------------------------------------
const TAX_CREATE = "action.createTax";
const TAX_UPDATE = "action.updateTax";
const TAX_DELETE = "action.deleteTax";
// -- Profile management ---------------------------------------------
const PROFILE_CREATE = "action.createProfile";
const PROFILE_UPDATE = "action.updateProfile";
const PROFILE_DELETE = "action.deleteProfile";
// -- Tax Rules management ---------------------------------------------
const TAX_RULE_CREATE = "action.createTaxRule";
@@ -657,4 +667,18 @@ final class TheliaEvents
const GENERATE_PDF = 'thelia.generatePdf';
/**
* sent when a module is activated or deactivated
*/
const MODULE_TOGGLE_ACTIVATION = 'thelia.module.toggleActivation';
/**
* sent when a module is deleted
*/
const MODULE_DELETE = 'thelia.module.delete';
/**
* sent for clearing cache
*/
const CACHE_CLEAR = 'thelia.cache.clear';
}

View File

@@ -0,0 +1,49 @@
<?php
namespace Thelia\Core\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class TheliaType extends AbstractType
{
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
//'instance' => false,
'type' => false,
'options' => false,
));
$resolver->setAllowedTypes(array(
//'instance' => array('Thelia\Type\TypeInterface'),
));
$resolver->setAllowedValues(array(
'type' => array('text', 'choice'),
));
}
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars = array_replace($view->vars, array(
//'instance' => $options['instance'],
'type' => $options['type'],
'options' => $options['options'],
));
}
public function getParent()
{
return 'text';
}
public function getName()
{
return 'thelia_type';
}
}

View File

@@ -20,33 +20,20 @@
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\TaxEngine\TaxType;
use Thelia\Type\FloatToFloatArrayType;
use Thelia\Type\ModelValidIdType;
namespace Thelia\Core\Security\Exception;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class featureSlicePercentTaxType extends BaseTaxType
class ResourceException extends \RuntimeException
{
public function pricePercentRetriever()
const UNKNOWN_EXCEPTION = 0;
const RESOURCE_NOT_FOUND = 404;
public function __construct($message, $code = null, $previous = null)
{
}
public function fixAmountRetriever(\Thelia\Model\Product $product)
{
}
public function getRequirementsList()
{
return array(
'featureId' => new ModelValidIdType('Currency'),
'slices' => new FloatToFloatArrayType(),
);
if ($code === null) {
$code = self::UNKNOWN_EXCEPTION;
}
parent::__construct($message, $code, $previous);
}
}

View File

@@ -0,0 +1,169 @@
<?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\Event;
use Thelia\Core\Security\Exception\ResourceException;
/**
*
* This class contains all Thelia admin resources
*
* @author Etienne roudeix <eroudeix@openstudio.fr>
*/
final class AdminResources
{
static private $selfReflection = null;
static public function retrieve($name, $action)
{
$contantName = strtoupper($name . '_' . $action);
if(null === self::$selfReflection) {
self::$selfReflection = new \ReflectionClass(__CLASS__);
}
if(self::$selfReflection->hasConstant($contantName)) {
return self::$selfReflection->getConstant($contantName);
} else {
throw new ResourceException(sprintf('Resource `%s` not found', $contantName), ResourceException::RESOURCE_NOT_FOUND);
}
}
const SUPERADMINISTRATOR = "SUPERADMINISTRATOR";
const ADDRESS_VIEW = "admin.address.view";
const ADDRESS_CREATE = "admin.address.create";
const ADDRESS_UPDATE = "admin.address.update";
const ADDRESS_DELETE = "admin.address.delete";
const ADMIN_VIEW = "admin.configuration.admin.view";
const ADMIN_CREATE = "admin.configuration.admin.create";
const ADMIN_UPDATE = "admin.configuration.admin.update";
const ADMIN_DELETE = "admin.configuration.admin.delete";
const AREA_VIEW = "admin.configuration.area.view";
const AREA_CREATE = "admin.configuration.area.create";
const AREA_UPDATE = "admin.configuration.area.update";
const AREA_DELETE = "admin.configuration.area.delete";
const ATTRIBUTE_VIEW = "admin.configuration.attribute.view";
const ATTRIBUTE_CREATE = "admin.configuration.attribute.create";
const ATTRIBUTE_UPDATE = "admin.configuration.attribute.update";
const ATTRIBUTE_DELETE = "admin.configuration.attribute.delete";
const CATEGORY_VIEW = "admin.category.view";
const CATEGORY_CREATE = "admin.category.create";
const CATEGORY_UPDATE = "admin.category.update";
const CATEGORY_DELETE = "admin.category.delete";
const CONFIG_VIEW = "admin.configuration.view";
const CONFIG_CREATE = "admin.configuration.create";
const CONFIG_UPDATE = "admin.configuration.update";
const CONFIG_DELETE = "admin.configuration.delete";
const CONTENT_VIEW = "admin.content.view";
const CONTENT_CREATE = "admin.content.create";
const CONTENT_UPDATE = "admin.content.update";
const CONTENT_DELETE = "admin.content.delete";
const COUNTRY_VIEW = "admin.configuration.country.view";
const COUNTRY_CREATE = "admin.configuration.country.create";
const COUNTRY_UPDATE = "admin.configuration.country.update";
const COUNTRY_DELETE = "admin.configuration.country.delete";
const COUPON_VIEW = "admin.coupon.view";
const COUPON_CREATE = "admin.coupon.create";
const COUPON_UPDATE = "admin.coupon.update";
const COUPON_DELETE = "admin.coupon.delete";
const CURRENCY_VIEW = "admin.configuration.currency.view";
const CURRENCY_CREATE = "admin.configuration.currency.create";
const CURRENCY_UPDATE = "admin.configuration.currency.update";
const CURRENCY_DELETE = "admin.configuration.currency.delete";
const CUSTOMER_VIEW = "admin.customer.view";
const CUSTOMER_CREATE = "admin.customer.create";
const CUSTOMER_UPDATE = "admin.customer.update";
const CUSTOMER_DELETE = "admin.customer.delete";
const FEATURE_VIEW = "admin.configuration.feature.view";
const FEATURE_CREATE = "admin.configuration.feature.create";
const FEATURE_UPDATE = "admin.configuration.feature.update";
const FEATURE_DELETE = "admin.configuration.feature.delete";
const FOLDER_VIEW = "admin.folder.view";
const FOLDER_CREATE = "admin.folder.create";
const FOLDER_UPDATE = "admin.folder.update";
const FOLDER_DELETE = "admin.folder.delete";
const LANGUAGE_VIEW = "admin.configuration.language.view";
const LANGUAGE_CREATE = "admin.configuration.language.create";
const LANGUAGE_UPDATE = "admin.configuration.language.update";
const LANGUAGE_DELETE = "admin.configuration.language.delete";
const MAILING_SYSTEM_VIEW = "admin.configuration.mailing-system.view";
const MAILING_SYSTEM_CREATE = "admin.configuration.mailing-system.create";
const MAILING_SYSTEM_UPDATE = "admin.configuration.mailing-system.update";
const MAILING_SYSTEM_DELETE = "admin.configuration.mailing-system.delete";
const MESSAGE_VIEW = "admin.configuration.message.view";
const MESSAGE_CREATE = "admin.configuration.message.create";
const MESSAGE_UPDATE = "admin.configuration.message.update";
const MESSAGE_DELETE = "admin.configuration.message.delete";
const MODULE_VIEW = "admin.configuration.module.view";
const MODULE_CREATE = "admin.configuration.module.create";
const MODULE_UPDATE = "admin.configuration.module.update";
const MODULE_DELETE = "admin.configuration.module.delete";
const ORDER_VIEW = "admin.order.view";
const ORDER_CREATE = "admin.order.create";
const ORDER_UPDATE = "admin.order.update";
const ORDER_DELETE = "admin.order.delete";
const PRODUCT_VIEW = "admin.product.view";
const PRODUCT_CREATE = "admin.product.create";
const PRODUCT_UPDATE = "admin.product.update";
const PRODUCT_DELETE = "admin.product.delete";
const PROFILE_VIEW = "admin.configuration.profile.view";
const PROFILE_CREATE = "admin.configuration.profile.create";
const PROFILE_UPDATE = "admin.configuration.profile.update";
const PROFILE_DELETE = "admin.configuration.profile.delete";
const SHIPPING_ZONE_VIEW = "admin.configuration.shipping-zone.view";
const SHIPPING_ZONE_CREATE = "admin.configuration.shipping-zone.create";
const SHIPPING_ZONE_UPDATE = "admin.configuration.shipping-zone.update";
const SHIPPING_ZONE_DELETE = "admin.configuration.shipping-zone.delete";
const TAX_VIEW = "admin.configuration.tax.view";
const TAX_CREATE = "admin.configuration.tax.create";
const TAX_UPDATE = "admin.configuration.tax.update";
const TAX_DELETE = "admin.configuration.tax.delete";
const TEMPLATE_VIEW = "admin.configuration.template.view";
const TEMPLATE_CREATE = "admin.configuration.template.create";
const TEMPLATE_UPDATE = "admin.configuration.template.update";
const TEMPLATE_DELETE = "admin.configuration.template.delete";
}

View File

@@ -23,8 +23,12 @@
namespace Thelia\Core\Security;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Event\AdminResources;
use Thelia\Core\Security\User\UserInterface;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Model\ProfileQuery;
use Thelia\Model\ProfileResourceQuery;
/**
* A simple security manager, in charge of checking user
@@ -124,6 +128,10 @@ class SecurityContext
*/
final public function isGranted(array $roles, array $permissions)
{
if (empty($permissions)) {
return true;
}
// Find a user which matches the required roles.
$user = $this->getCustomerUser();
@@ -135,38 +143,31 @@ class SecurityContext
}
}
if ($user != null) {
if (empty($permissions)) {
return true;
}
// Get permissions from profile
// $userPermissions = $user->getPermissions(); FIXME
// 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;
if (null === $user) {
return false;
}
return false;
if( !method_exists($user, 'getProfileId') ) {
return false;
}
$userPermissions = $user->getPermissions();
if($userPermissions === AdminResources::SUPERADMINISTRATOR) {
return true;
}
foreach($permissions as $permission) {
if($permission === '') {
continue;
}
if(! in_array($permission, $userPermissions)) {
return false;
}
}
return true;
}
/**

View File

@@ -254,7 +254,7 @@ abstract class BaseLoop
*
* @param $pagination
*
* @return mixed
* @return LoopResult
*/
abstract public function exec(&$pagination);

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\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\AdminQuery;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/**
*
* Admin loop
*
*
* Class Admin
* @package Thelia\Core\Template\Loop
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class Admin extends BaseI18nLoop
{
public $timestampable = true;
/**
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id'),
Argument::createIntListTypeArgument('profile')
);
}
/**
* @param $pagination
*
* @return \Thelia\Core\Template\Element\LoopResult
*/
public function exec(&$pagination)
{
$search = AdminQuery::create();
$id = $this->getId();
if (null !== $id) {
$search->filterById($id, Criteria::IN);
}
$profile = $this->getProfile();
if (null !== $profile) {
$search->filterByProfileId($profile, Criteria::IN);
}
$search->orderByFirstname(Criteria::ASC);
/* perform search */
$features = $this->search($search, $pagination);
$loopResult = new LoopResult($features);
foreach ($features as $feature) {
$loopResultRow = new LoopResultRow($loopResult, $feature, $this->versionable, $this->timestampable, $this->countable);
$loopResultRow->set("ID", $feature->getId())
->set("PROFILE",$feature->getProfileId())
->set("FIRSTNAME",$feature->getFirstname())
->set("LASTNAME",$feature->getLastname())
->set("LOGIN",$feature->getLogin())
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -30,7 +30,6 @@ use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\AreaQuery;
/**
* Class Area
* @package Thelia\Core\Template\Loop
@@ -112,8 +111,7 @@ class Area extends BaseLoop
$withoutZone = $this->getWithout_zone();
if($withoutZone)
{
if ($withoutZone) {
$search->joinAreaDeliveryModule('without_zone', Criteria::LEFT_JOIN)
->addJoinCondition('without_zone', 'delivery_module_id '.Criteria::EQUAL.' ?', $withoutZone, null, \PDO::PARAM_INT)
->where('`without_zone`.delivery_module_id '.Criteria::ISNULL);
@@ -140,5 +138,4 @@ class Area extends BaseLoop
return $loopResult;
}
}
}

View File

@@ -84,10 +84,14 @@ class CategoryTree extends BaseI18nLoop
$loopResultRow = new LoopResultRow();
$loopResultRow
->set("ID", $result->getId())->set("TITLE", $result->getVirtualColumn('i18n_TITLE'))
->set("PARENT", $result->getParent())->set("URL", $result->getUrl($locale))
->set("VISIBLE", $result->getVisible() ? "1" : "0")->set("LEVEL", $level)
->set('CHILD_COUNT', $result->countChild())->set('PREV_LEVEL', $previousLevel)
->set("ID", $result->getId())
->set("TITLE", $result->getVirtualColumn('i18n_TITLE'))
->set("PARENT", $result->getParent())
->set("URL", $result->getUrl($locale))
->set("VISIBLE", $result->getVisible() ? "1" : "0")
->set("LEVEL", $level)
->set('CHILD_COUNT', $result->countChild())
->set('PREV_LEVEL', $previousLevel)
;
$loopResult->addRow($loopResultRow);

View File

@@ -114,7 +114,7 @@ class Folder extends BaseI18nLoop
if (null !== $content) {
$obj = ContentQuery::create()->findPk($content);
if($obj) {
if ($obj) {
$search->filterByContent($obj, Criteria::IN);
}
}

View File

@@ -30,7 +30,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\FolderQuery;
use Thelia\Type\BooleanOrBothType;
/**
* Class FolderPath
* @package Thelia\Core\Template\Loop
@@ -156,5 +155,4 @@ class FolderPath extends BaseI18nLoop
return $loopResult;
}
}
}

View File

@@ -473,7 +473,7 @@ class Product extends BaseI18nLoop
$visible = $this->getVisible();
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
if ($visible !== BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
$exclude = $this->getExclude();

View File

@@ -0,0 +1,103 @@
<?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\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\ProfileQuery;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/**
*
* Profile loop
*
*
* Class Profile
* @package Thelia\Core\Template\Loop
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class Profile extends BaseI18nLoop
{
public $timestampable = true;
/**
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id')
);
}
/**
* @param $pagination
*
* @return \Thelia\Core\Template\Element\LoopResult
*/
public function exec(&$pagination)
{
$search = ProfileQuery::create();
/* manage translations */
$locale = $this->configureI18nProcessing($search);
$id = $this->getId();
if (null !== $id) {
$search->filterById($id, Criteria::IN);
}
$search->orderById(Criteria::ASC);
/* perform search */
$features = $this->search($search, $pagination);
$loopResult = new LoopResult($features);
foreach ($features as $feature) {
$loopResultRow = new LoopResultRow($loopResult, $feature, $this->versionable, $this->timestampable, $this->countable);
$loopResultRow->set("ID", $feature->getId())
->set("IS_TRANSLATED",$feature->getVirtualColumn('IS_TRANSLATED'))
->set("LOCALE",$locale)
->set("CODE",$feature->getCode())
->set("TITLE",$feature->getVirtualColumn('i18n_TITLE'))
->set("CHAPO", $feature->getVirtualColumn('i18n_CHAPO'))
->set("DESCRIPTION", $feature->getVirtualColumn('i18n_DESCRIPTION'))
->set("POSTSCRIPTUM", $feature->getVirtualColumn('i18n_POSTSCRIPTUM'))
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -97,7 +97,7 @@ class Tax extends BaseI18nLoop
$country = $this->getCountry();
$taxRule = $this->getTax_rule();
if(null !== $taxRule && null !== $country) {
if (null !== $taxRule && null !== $country) {
$search->filterByTaxRuleCountry(
TaxRuleCountryQuery::create()
->filterByCountryId($country, Criteria::EQUAL)
@@ -108,7 +108,7 @@ class Tax extends BaseI18nLoop
}
$excludeTaxRule = $this->getExclude_tax_rule();
if(null !== $excludeTaxRule && null !== $country) {
if (null !== $excludeTaxRule && null !== $country) {
$excludedTaxes = TaxRuleCountryQuery::create()
->filterByCountryId($country, Criteria::EQUAL)
->filterByTaxRuleId($excludeTaxRule, Criteria::IN)
@@ -118,7 +118,7 @@ class Tax extends BaseI18nLoop
$excludedTaxes,
Criteria::NOT_IN
);*/
foreach($excludedTaxes as $excludedTax) {
foreach ($excludedTaxes as $excludedTax) {
$search->filterByTaxRuleCountry($excludedTax, Criteria::NOT_EQUAL);
}
}
@@ -152,11 +152,13 @@ class Tax extends BaseI18nLoop
$loopResultRow = new LoopResultRow($loopResult, $tax, $this->versionable, $this->timestampable, $this->countable);
$loopResultRow
->set("ID" , $tax->getId())
->set("IS_TRANSLATED" , $tax->getVirtualColumn('IS_TRANSLATED'))
->set("LOCALE" , $locale)
->set("TITLE" , $tax->getVirtualColumn('i18n_TITLE'))
->set("DESCRIPTION" , $tax->getVirtualColumn('i18n_DESCRIPTION'))
->set("ID" , $tax->getId())
->set("TYPE" , $tax->getType())
->set("REQUIREMENTS" , $tax->getRequirements())
->set("IS_TRANSLATED" , $tax->getVirtualColumn('IS_TRANSLATED'))
->set("LOCALE" , $locale)
->set("TITLE" , $tax->getVirtualColumn('i18n_TITLE'))
->set("DESCRIPTION" , $tax->getVirtualColumn('i18n_DESCRIPTION'))
;
$loopResult->addRow($loopResultRow);

View File

@@ -32,6 +32,7 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\CountryQuery;
use Thelia\Model\Map\CountryTableMap;
use Thelia\Model\Map\TaxRuleCountryTableMap;
use Thelia\Model\Map\TaxTableMap;
@@ -58,8 +59,14 @@ class TaxRuleCountry extends BaseI18nLoop
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntTypeArgument('country'),
Argument::createIntListTypeArgument('taxes'),
Argument::createIntTypeArgument('country', null, true),
new Argument(
'ask',
new TypeCollection(
new Type\EnumType(array('taxes', 'countries'))
),
'taxes'
),
Argument::createIntTypeArgument('tax_rule', null, true)
);
}
@@ -73,40 +80,54 @@ class TaxRuleCountry extends BaseI18nLoop
{
$search = TaxRuleCountryQuery::create();
$ask = $this->getAsk();
$country = $this->getCountry();
$taxes = $this->getTaxes();
$taxRule = $this->getTax_rule();
if((null === $country && null === $taxes)) {
throw new \InvalidArgumentException('You must provide either `country` or `taxes` parameter in tax-rule-country loop');
}
if($ask === 'countries') {
$taxCountForOriginCountry = TaxRuleCountryQuery::create()->filterByCountryId($country)->count();
if((null === $country && null !== $taxes)) {
throw new \InvalidArgumentException('You must provide `country` parameter with `taxes` parameter in tax-rule-country loop');
}
if($taxCountForOriginCountry > 0) {
$search->groupByCountryId();
if(null !== $taxes) {
$search->groupByCountryId();
$originalCountryJoin = new Join();
$originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'TAX_RULE_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'TAX_RULE_ID', 'origin');
$originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'TAX_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'TAX_ID', 'origin');
$originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'POSITION', null, TaxRuleCountryTableMap::TABLE_NAME, 'POSITION', 'origin');
$originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'COUNTRY_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'COUNTRY_ID', 'origin', Criteria::NOT_EQUAL);
$originalCountryJoin->setJoinType(Criteria::LEFT_JOIN);
$originalCountryJoin = new Join();
$originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'TAX_RULE_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'TAX_RULE_ID', 'origin');
$originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'TAX_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'TAX_ID', 'origin');
$originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'POSITION', null, TaxRuleCountryTableMap::TABLE_NAME, 'POSITION', 'origin');
$originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'COUNTRY_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'COUNTRY_ID', 'origin', Criteria::NOT_EQUAL);
$originalCountryJoin->setJoinType(Criteria::LEFT_JOIN);
$search->addJoinObject($originalCountryJoin, 's_to_o');
$search->where('`origin`.`COUNTRY_ID`' . Criteria::EQUAL . '?', $country, \PDO::PARAM_INT);
$search->addJoinObject($originalCountryJoin, 's_to_o');
$search->where('`origin`.`COUNTRY_ID`' . Criteria::EQUAL . '?', $country, \PDO::PARAM_INT);
$search->having('COUNT(*)=?', $taxCountForOriginCountry, \PDO::PARAM_INT);
$search->having('COUNT(*)=?', count($taxes), \PDO::PARAM_INT);
$search->filterByTaxRuleId($taxRule);
/* manage tax translation */
$this->configureI18nProcessing(
$search,
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
CountryTableMap::TABLE_NAME,
'COUNTRY_ID'
);
} elseif(null !== $country) {
/* manage tax translation */
$this->configureI18nProcessing(
$search,
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
CountryTableMap::TABLE_NAME,
'COUNTRY_ID'
);
$search->addAscendingOrderByColumn('`' . CountryTableMap::TABLE_NAME . '_i18n_TITLE`');
} else {
$search = CountryQuery::create()
->joinTaxRuleCountry('trc', Criteria::LEFT_JOIN);
/* manage tax translation */
$this->configureI18nProcessing(
$search
);
$search->where('ISNULL(`trc`.`COUNTRY_ID`)');
$search->addAscendingOrderByColumn('i18n_TITLE');
}
} elseif($ask === 'taxes') {
$search->filterByCountryId($country);
/* manage tax translation */
@@ -116,13 +137,11 @@ class TaxRuleCountry extends BaseI18nLoop
TaxTableMap::TABLE_NAME,
'TAX_ID'
);
$search->filterByTaxRuleId($taxRule);
$search->orderByPosition(Criteria::ASC);
}
$taxRule = $this->getTax_rule();
$search->filterByTaxRuleId($taxRule);
$search->orderByPosition(Criteria::ASC);
/* perform search */
$taxRuleCountries = $this->search($search, $pagination);
@@ -132,16 +151,23 @@ class TaxRuleCountry extends BaseI18nLoop
$loopResultRow = new LoopResultRow($loopResult, $taxRuleCountry, $this->versionable, $this->timestampable, $this->countable);
if(null !== $taxes) {
$loopResultRow
->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId())
->set("COUNTRY" , $taxRuleCountry->getCountryId())
->set("COUNTRY_TITLE" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_TITLE'))
->set("COUNTRY_CHAPO" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_CHAPO'))
->set("COUNTRY_DESCRIPTION" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_DESCRIPTION'))
->set("COUNTRY_POSTSCRIPTUM" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM'))
;
}elseif(null !== $country) {
if($ask === 'countries') {
if($taxCountForOriginCountry > 0) {
$loopResultRow
->set("COUNTRY" , $taxRuleCountry->getCountryId())
->set("COUNTRY_TITLE" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_TITLE'))
->set("COUNTRY_CHAPO" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_CHAPO'))
->set("COUNTRY_DESCRIPTION" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_DESCRIPTION'))
->set("COUNTRY_POSTSCRIPTUM" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM'));
} else {
$loopResultRow
->set("COUNTRY" , $taxRuleCountry->getId())
->set("COUNTRY_TITLE" , $taxRuleCountry->getVirtualColumn('i18n_TITLE'))
->set("COUNTRY_CHAPO" , $taxRuleCountry->getVirtualColumn('i18n_CHAPO'))
->set("COUNTRY_DESCRIPTION" , $taxRuleCountry->getVirtualColumn('i18n_DESCRIPTION'))
->set("COUNTRY_POSTSCRIPTUM" , $taxRuleCountry->getVirtualColumn('i18n_POSTSCRIPTUM'));
}
} elseif($ask === 'taxes') {
$loopResultRow
->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId())
->set("COUNTRY" , $taxRuleCountry->getCountryId())

View File

@@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\Base\TemplateQuery;
use Thelia\Type;
/**
*

View File

@@ -172,6 +172,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
self::$dataAccessCache['defaultCountry'] = $defaultCountry;
}*/
$defaultCountry = CountryQuery::create()->filterByByDefault(1)->limit(1);
return $this->dataAccessWithI18n("defaultCountry", $params, $defaultCountry);
}
}
@@ -237,7 +238,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
public function ConfigDataAccess($params, $smarty)
{
if(false === array_key_exists("key", $params)) {
if (false === array_key_exists("key", $params)) {
return null;
}

View File

@@ -22,7 +22,11 @@
/*************************************************************************************/
namespace Thelia\Core\Template\Smarty\Plugins;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
use Symfony\Component\Form\FormView;
use Thelia\Core\Form\Type\TheliaType;
use Thelia\Form\BaseForm;
use Thelia\Core\Template\Element\Exception\ElementNotFoundException;
use Symfony\Component\HttpFoundation\Request;
@@ -56,6 +60,8 @@ use Thelia\Core\Template\ParserContext;
*/
class Form extends AbstractSmartyPlugin
{
static private $taggedFieldsStack = null;
static private $taggedFieldsStackPosition = null;
protected $request;
protected $parserContext;
@@ -117,8 +123,13 @@ class Form extends AbstractSmartyPlugin
$template->assign("name", $fieldName);
$template->assign("value", $fieldValue);
$template->assign("checked", isset($fieldVars['checked']) ? $fieldVars['checked'] : false);
//data
$template->assign("data", $fieldVars['data']);
$template->assign("label", $fieldVars["label"]);
$template->assign("label_attr", $fieldVars["label_attr"]);
@@ -139,20 +150,59 @@ class Form extends AbstractSmartyPlugin
}
$template->assign("attr", implode(" ", $attr));
$template->assign("attr_list", $fieldVars["attr"]);
}
protected function assignFormTypeValues($template, $formFieldConfig, $formFieldView)
{
$formFieldType = $formFieldConfig->getType()->getInnerType();
/* access to choices */
if($formFieldType instanceof ChoiceType) {
$template->assign("choices", $formFieldView->vars['choices']);
}
/* access to collections */
if($formFieldType instanceof CollectionType) {
if( true === $formFieldConfig->getOption('prototype') ) {
} else {
/* access to choices */
if (isset($formFieldView->vars['choices'])) {
$template->assign("choices", $formFieldView->vars['choices']);
}
}
}
/* access to thelia type */
if($formFieldType instanceof TheliaType) {
$template->assign("formType", $formFieldView->vars['type']);
switch($formFieldView->vars['type']) {
case "choice":
if(!isset($formFieldView->vars['options']['choices']) || !is_array($formFieldView->vars['options']['choices'])) {
//throw new
}
$choices = array();
foreach($formFieldView->vars['options']['choices'] as $value => $choice) {
$choices[] = new ChoiceView($value, $value, $choice);
}
$template->assign("choices", $choices);
break;
}
}
}
public function renderFormField($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
if ($repeat) {
if ($repeat) {
$formFieldView = $this->getFormFieldView($params);
$formFieldView = $this->getFormFieldView($params);
$formFieldConfig = $this->getFormFieldConfig($params);
$template->assign("options", $formFieldView->vars);
/* access to choices */
if (isset($formFieldView->vars['choices'])) {
$template->assign("choices", $formFieldView->vars['choices']);
}
$this->assignFormTypeValues($template, $formFieldConfig, $formFieldView);
$value = $formFieldView->vars["value"];
/* FIXME: doesnt work. We got "This form should not contain extra fields." error.
@@ -183,6 +233,38 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
}
}
public function renderTaggedFormFields($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
if(null === $content) {
self::$taggedFieldsStack = $this->getFormFieldsFromTag($params);
self::$taggedFieldsStackPosition = 0;
} else {
self::$taggedFieldsStackPosition++;
}
if(isset(self::$taggedFieldsStack[self::$taggedFieldsStackPosition])) {
$this->assignFieldValues(
$template,
self::$taggedFieldsStack[self::$taggedFieldsStackPosition]['view']->vars["full_name"],
self::$taggedFieldsStack[self::$taggedFieldsStackPosition]['view']->vars["value"],
self::$taggedFieldsStack[self::$taggedFieldsStackPosition]['view']->vars
);
$this->assignFormTypeValues($template, self::$taggedFieldsStack[self::$taggedFieldsStackPosition]['config'], self::$taggedFieldsStack[self::$taggedFieldsStackPosition]['view']);
self::$taggedFieldsStack[self::$taggedFieldsStackPosition]['view']->setRendered();
$repeat = true;
}
if (! $repeat) {
self::$taggedFieldsStack = null;
self::$taggedFieldsStackPosition = null;
}
return $content;
}
public function renderHiddenFormField($params, \Smarty_Internal_Template $template)
{
$attrFormat = '%s="%s"';
@@ -197,8 +279,8 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
foreach ($formView->getIterator() as $row) {
if ($this->isHidden($row) && $row->isRendered() === false) {
$attributeList = array();
if(isset($row->vars["attr"])) {
foreach($row->vars["attr"] as $attrKey => $attrValue) {
if (isset($row->vars["attr"])) {
foreach ($row->vars["attr"] as $attrKey => $attrValue) {
$attributeList[] = sprintf($attrFormat, $attrKey, $attrValue);
}
}
@@ -264,6 +346,48 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
return $instance->getView()[$fieldName];
}
protected function getFormFieldsFromTag($params)
{
$instance = $this->getInstanceFromParams($params);
$tag = $this->getParam($params, 'tag');
if (null == $tag)
throw new \InvalidArgumentException("'tag' parameter is missing");
$viewList = array();
foreach($instance->getView() as $view) {
if(isset($view->vars['attr']['tag']) && $tag == $view->vars['attr']['tag']) {
$fieldData = $instance->getForm()->all()[$view->vars['name']];
$viewList[] = array(
'view' => $view,
'config' => $fieldData->getConfig(),
);
}
}
return $viewList;
}
protected function getFormFieldConfig($params)
{
$instance = $this->getInstanceFromParams($params);
$fieldName = $this->getParam($params, 'field');
if (null == $fieldName) {
throw new \InvalidArgumentException("'field' parameter is missing");
}
$fieldData = $instance->getForm()->all()[$fieldName];
if (empty( $fieldData )) {
throw new \InvalidArgumentException(sprintf("Field name '%s' not found in form %s children", $fieldName, $instance->getName()));
}
return $fieldData->getConfig();
}
protected function getInstanceFromParams($params)
{
$instance = $this->getParam($params, 'form');
@@ -302,6 +426,7 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
return array(
new SmartyPluginDescriptor("block", "form", $this, "generateForm"),
new SmartyPluginDescriptor("block", "form_field", $this, "renderFormField"),
new SmartyPluginDescriptor("block", "form_tagged_fields", $this, "renderTaggedFormFields"),
new SmartyPluginDescriptor("function", "form_hidden_fields", $this, "renderHiddenFormField"),
new SmartyPluginDescriptor("function", "form_enctype", $this, "formEnctype"),
new SmartyPluginDescriptor("block", "form_error", $this, "formError")

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