Merge with master
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -26,3 +26,4 @@ phpunit.phar
|
||||
phpmyadmin
|
||||
templates/default-esi
|
||||
local/modules/TemplateEsiModule
|
||||
composer.phar
|
||||
|
||||
BIN
composer.phar
BIN
composer.phar
Binary file not shown.
@@ -17,8 +17,10 @@ $loader = require __DIR__ . "/vendor/autoload.php";
|
||||
|
||||
|
||||
|
||||
if (!file_exists(THELIA_ROOT . '/local/config/database.yml')) {
|
||||
define('THELIA_INSTALL_MODE',true);
|
||||
if (!file_exists(THELIA_ROOT . '/local/config/database.yml') && !defined('THELIA_INSTALL_MODE')) {
|
||||
$request = \Thelia\Core\HttpFoundation\Request::createFromGlobals();
|
||||
header('location: '.$request->getSchemeAndHttpHost() . '/install');
|
||||
exit;
|
||||
}
|
||||
/*else {
|
||||
define('THELIA_INSTALL_MODE',true);
|
||||
|
||||
108
core/lib/Thelia/Action/Administrator.php
Normal file
108
core/lib/Thelia/Action/Administrator.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?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\Administrator\AdministratorEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Model\Admin as AdminModel;
|
||||
use Thelia\Model\AdminQuery;
|
||||
|
||||
class Administrator extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* @param AdministratorEvent $event
|
||||
*/
|
||||
public function create(AdministratorEvent $event)
|
||||
{
|
||||
$administrator = new AdminModel();
|
||||
|
||||
$administrator
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setFirstname($event->getFirstname())
|
||||
->setLastname($event->getLastname())
|
||||
->setLogin($event->getLogin())
|
||||
->setPassword($event->getPassword())
|
||||
->setProfileId($event->getProfile())
|
||||
;
|
||||
|
||||
$administrator->save();
|
||||
|
||||
$event->setAdministrator($administrator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AdministratorEvent $event
|
||||
*/
|
||||
public function update(AdministratorEvent $event)
|
||||
{
|
||||
if (null !== $administrator = AdminQuery::create()->findPk($event->getId())) {
|
||||
|
||||
$administrator
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setFirstname($event->getFirstname())
|
||||
->setLastname($event->getLastname())
|
||||
->setLogin($event->getLogin())
|
||||
->setProfileId($event->getProfile())
|
||||
;
|
||||
|
||||
if('' !== $event->getPassword()) {
|
||||
$administrator->setPassword($event->getPassword());
|
||||
}
|
||||
|
||||
$administrator->save();
|
||||
|
||||
$event->setAdministrator($administrator);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AdministratorEvent $event
|
||||
*/
|
||||
public function delete(AdministratorEvent $event)
|
||||
{
|
||||
if (null !== $administrator = AdminQuery::create()->findPk($event->getId())) {
|
||||
|
||||
$administrator
|
||||
->delete()
|
||||
;
|
||||
|
||||
$event->setAdministrator($administrator);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::ADMINISTRATOR_CREATE => array("create", 128),
|
||||
TheliaEvents::ADMINISTRATOR_UPDATE => array("update", 128),
|
||||
TheliaEvents::ADMINISTRATOR_DELETE => array("delete", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ namespace Thelia\Action;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Cart\CartEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\ProductPrice;
|
||||
use Thelia\Model\ProductPriceQuery;
|
||||
use Thelia\Model\CartItem;
|
||||
@@ -69,7 +70,8 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
if ($append && $cartItem !== null) {
|
||||
$this->updateQuantity($cartItem, $quantity);
|
||||
$cartItem->addQuantity($quantity)
|
||||
->save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +93,17 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cart
|
||||
* @param CartEvent $event
|
||||
*/
|
||||
public function clear(CartEvent $event)
|
||||
{
|
||||
if (null !== $cart = $event->getCart()) {
|
||||
$cart->delete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Modify article's quantity
|
||||
@@ -138,9 +151,10 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
"action.addArticle" => array("addItem", 128),
|
||||
"action.deleteArticle" => array("deleteItem", 128),
|
||||
"action.updateArticle" => array("changeItem", 128),
|
||||
TheliaEvents::CART_ADDITEM => array("addItem", 128),
|
||||
TheliaEvents::CART_DELETEITEM => array("deleteItem", 128),
|
||||
TheliaEvents::CART_UPDATEITEM => array("changeItem", 128),
|
||||
TheliaEvents::CART_CLEAR => array("clear", 128),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ use Thelia\Coupon\CouponManager;
|
||||
use Thelia\Coupon\ConditionCollection;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
use Thelia\Model\Coupon as CouponModel;
|
||||
use Thelia\Model\CouponQuery;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
@@ -68,7 +69,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
*/
|
||||
public function update(CouponCreateOrUpdateEvent $event)
|
||||
{
|
||||
$coupon = $event->getCoupon();
|
||||
$coupon = $event->getCouponModel();
|
||||
|
||||
$this->createOrUpdate($coupon, $event);
|
||||
}
|
||||
@@ -76,13 +77,13 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
/**
|
||||
* Occurring when a Coupon condition is about to be updated
|
||||
*
|
||||
* @param CouponCreateOrUpdateEvent $event Event creation or update Coupon Rule
|
||||
* @param CouponCreateOrUpdateEvent $event Event creation or update Coupon condition
|
||||
*/
|
||||
public function updateCondition(CouponCreateOrUpdateEvent $event)
|
||||
{
|
||||
$coupon = $event->getCoupon();
|
||||
$modelCoupon = $event->getCouponModel();
|
||||
|
||||
$this->createOrUpdateCondition($coupon, $event);
|
||||
$this->createOrUpdateCondition($modelCoupon, $event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,6 +105,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
$coupon = $couponFactory->buildCouponFromCode($event->getCode());
|
||||
|
||||
$isValid = $coupon->isMatching();
|
||||
|
||||
if ($isValid) {
|
||||
/** @var Request $request */
|
||||
$request = $this->container->get('request');
|
||||
@@ -119,8 +121,15 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
$request->getSession()->setConsumedCoupons($consumedCoupons);
|
||||
|
||||
$totalDiscount = $couponManager->getDiscount();
|
||||
// @todo insert false product in cart with the name of the coupon and the discount as negative price
|
||||
|
||||
// Decrement coupon quantity
|
||||
$couponQuery = CouponQuery::create();
|
||||
$couponModel = $couponQuery->findOneByCode($coupon->getCode());
|
||||
$couponManager->decrementeQuantity($couponModel);
|
||||
|
||||
$request->getSession()->getCart()->setDiscount($totalDiscount);
|
||||
|
||||
// @todo modify Cart total discount
|
||||
}
|
||||
|
||||
$event->setIsValid($isValid);
|
||||
@@ -153,7 +162,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
$event->getCode(),
|
||||
$event->getTitle(),
|
||||
$event->getAmount(),
|
||||
$event->getType(),
|
||||
$event->getServiceId(),
|
||||
$event->isRemovingPostage(),
|
||||
$event->getShortDescription(),
|
||||
$event->getDescription(),
|
||||
@@ -166,7 +175,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
$event->getLocale()
|
||||
);
|
||||
|
||||
$event->setCoupon($coupon);
|
||||
$event->setCouponModel($coupon);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +197,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
$event->getLocale()
|
||||
);
|
||||
|
||||
$event->setCoupon($coupon);
|
||||
$event->setCouponModel($coupon);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
146
core/lib/Thelia/Action/Lang.php
Normal file
146
core/lib/Thelia/Action/Lang.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?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 Thelia\Core\Event\Lang\LangCreateEvent;
|
||||
use Thelia\Core\Event\Lang\LangDefaultBehaviorEvent;
|
||||
use Thelia\Core\Event\Lang\LangDeleteEvent;
|
||||
use Thelia\Core\Event\Lang\LangToggleDefaultEvent;
|
||||
use Thelia\Core\Event\Lang\LangUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\Lang\LangUrlEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\LangQuery;
|
||||
use Thelia\Model\Lang as LangModel;
|
||||
|
||||
|
||||
/**
|
||||
* Class Lang
|
||||
* @package Thelia\Action
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class Lang extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
|
||||
public function update(LangUpdateEvent $event)
|
||||
{
|
||||
if (null !== $lang = LangQuery::create()->findPk($event->getId())) {
|
||||
$lang->setDispatcher($this->getDispatcher());
|
||||
|
||||
$lang->setTitle($event->getTitle())
|
||||
->setLocale($event->getLocale())
|
||||
->setCode($event->getCode())
|
||||
->setDateFormat($event->getDateFormat())
|
||||
->setTimeFormat($event->getTimeFormat())
|
||||
->save();
|
||||
|
||||
$event->setLang($lang);
|
||||
}
|
||||
}
|
||||
|
||||
public function toggleDefault(LangToggleDefaultEvent $event)
|
||||
{
|
||||
if (null !== $lang = LangQuery::create()->findPk($event->getLangId())) {
|
||||
$lang->setDispatcher($this->getDispatcher());
|
||||
|
||||
$lang->toggleDefault();
|
||||
|
||||
$event->setLang($lang);
|
||||
}
|
||||
}
|
||||
|
||||
public function create(LangCreateEvent $event)
|
||||
{
|
||||
$lang = new LangModel();
|
||||
|
||||
$lang
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setTitle($event->getTitle())
|
||||
->setCode($event->getCode())
|
||||
->setLocale($event->getLocale())
|
||||
->setDateFormat($event->getDateFormat())
|
||||
->setTimeFormat($event->getTimeFormat())
|
||||
->save();
|
||||
|
||||
$event->setLang($lang);
|
||||
}
|
||||
|
||||
public function delete(LangDeleteEvent $event)
|
||||
{
|
||||
if (null !== $lang = LangQuery::create()->findPk($event->getLangId())) {
|
||||
$lang->setDispatcher($this->getDispatcher())
|
||||
->delete();
|
||||
|
||||
$event->setLang($lang);
|
||||
}
|
||||
}
|
||||
|
||||
public function defaultBehavior(LangDefaultBehaviorEvent $event)
|
||||
{
|
||||
ConfigQuery::create()
|
||||
->filterByName('default_lang_without_translation')
|
||||
->update(array('Value' => $event->getDefaultBehavior()));
|
||||
}
|
||||
|
||||
public function langUrl(LangUrlEvent $event)
|
||||
{
|
||||
foreach($event->getUrl() as $id => $url){
|
||||
LangQuery::create()
|
||||
->filterById($id)
|
||||
->update(array('Url' => $url));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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::LANG_UPDATE => array('update', 128),
|
||||
TheliaEvents::LANG_TOGGLEDEFAULT => array('toggleDefault', 128),
|
||||
TheliaEvents::LANG_CREATE => array('create', 128),
|
||||
TheliaEvents::LANG_DELETE => array('delete', 128),
|
||||
TheliaEvents::LANG_DEFAULTBEHAVIOR => array('defaultBehavior', 128),
|
||||
TheliaEvents::LANG_URL => array('langUrl', 128)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Cart\CartTrait;
|
||||
use Thelia\Core\Event\Cart\CartEvent;
|
||||
use Thelia\Core\Event\Order\OrderAddressEvent;
|
||||
use Thelia\Core\Event\Order\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
@@ -47,6 +49,8 @@ use Thelia\Tools\I18n;
|
||||
*/
|
||||
class Order extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
use CartTrait;
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\Order\OrderEvent $event
|
||||
*/
|
||||
@@ -97,7 +101,9 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\Order\OrderEvent $event
|
||||
* @param OrderEvent $event
|
||||
*
|
||||
* @throws \Thelia\Exception\TheliaProcessException
|
||||
*/
|
||||
public function create(OrderEvent $event)
|
||||
{
|
||||
@@ -221,6 +227,7 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
->setWeight($pse->getWeight())
|
||||
->setTaxRuleTitle($taxRuleI18n->getTitle())
|
||||
->setTaxRuleDescription($taxRuleI18n->getDescription())
|
||||
->setEanCode($pse->getEanCode())
|
||||
;
|
||||
$orderProduct->setDispatcher($this->getDispatcher());
|
||||
$orderProduct->save($con);
|
||||
@@ -266,7 +273,8 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
$event->setPlacedOrder($placedOrder);
|
||||
$this->getSession()->setOrder($sessionOrder);
|
||||
|
||||
/* empty cart @todo */
|
||||
/* empty cart */
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_CLEAR, new CartEvent($this->getCart($this->getRequest())));
|
||||
|
||||
/* call pay method */
|
||||
$paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
|
||||
|
||||
@@ -54,10 +54,10 @@ use Thelia\Core\Event\Product\ProductDeleteCategoryEvent;
|
||||
use Thelia\Core\Event\Product\ProductAddCategoryEvent;
|
||||
use Thelia\Model\AttributeAvQuery;
|
||||
use Thelia\Model\AttributeCombination;
|
||||
use Thelia\Core\Event\Product\ProductCreateCombinationEvent;
|
||||
use Thelia\Core\Event\Product\ProductSaleElementCreateEvent;
|
||||
use Propel\Runtime\Propel;
|
||||
use Thelia\Model\Map\ProductTableMap;
|
||||
use Thelia\Core\Event\Product\ProductDeleteCombinationEvent;
|
||||
use Thelia\Core\Event\Product\ProductSaleElementDeleteEvent;
|
||||
use Thelia\Model\ProductPrice;
|
||||
use Thelia\Model\ProductSaleElements;
|
||||
use Thelia\Core\Event\Product\ProductAddAccessoryEvent;
|
||||
@@ -85,8 +85,6 @@ class Product extends BaseAction implements EventSubscriberInterface
|
||||
// Set the default tax rule to this product
|
||||
->setTaxRule(TaxRuleQuery::create()->findOneByIsDefault(true))
|
||||
|
||||
//public function create($defaultCategoryId, $basePrice, $priceCurrencyId, $taxRuleId, $baseWeight) {
|
||||
|
||||
->create(
|
||||
$event->getDefaultCategory(),
|
||||
$event->getBasePrice(),
|
||||
@@ -304,6 +302,11 @@ class Product extends BaseAction implements EventSubscriberInterface
|
||||
return $this->genericUpdatePosition(ProductAssociatedContentQuery::create(), $event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the value of a product feature.
|
||||
*
|
||||
* @param FeatureProductUpdateEvent $event
|
||||
*/
|
||||
public function updateFeatureProductValue(FeatureProductUpdateEvent $event)
|
||||
{
|
||||
// If the feature is not free text, it may have one ore more values.
|
||||
@@ -346,6 +349,11 @@ class Product extends BaseAction implements EventSubscriberInterface
|
||||
$event->setFeatureProduct($featureProduct);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a product feature value
|
||||
*
|
||||
* @param FeatureProductDeleteEvent $event
|
||||
*/
|
||||
public function deleteFeatureProductValue(FeatureProductDeleteEvent $event)
|
||||
{
|
||||
$featureProduct = FeatureProductQuery::create()
|
||||
@@ -355,76 +363,6 @@ class Product extends BaseAction implements EventSubscriberInterface
|
||||
;
|
||||
}
|
||||
|
||||
public function createProductCombination(ProductCreateCombinationEvent $event)
|
||||
{
|
||||
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
|
||||
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
$product = $event->getProduct();
|
||||
|
||||
// Create an empty product sale element
|
||||
$salesElement = new ProductSaleElements();
|
||||
|
||||
$salesElement
|
||||
->setProduct($product)
|
||||
->setRef($product->getRef())
|
||||
->setPromo(0)
|
||||
->setNewness(0)
|
||||
->setWeight(0)
|
||||
->setIsDefault(false)
|
||||
->save($con)
|
||||
;
|
||||
|
||||
// Create an empty product price in the default currency
|
||||
$product_price = new ProductPrice();
|
||||
|
||||
$product_price
|
||||
->setProductSaleElements($salesElement)
|
||||
->setPromoPrice(0)
|
||||
->setPrice(0)
|
||||
->setCurrencyId($event->getCurrencyId())
|
||||
->save($con)
|
||||
;
|
||||
|
||||
$combinationAttributes = $event->getAttributeAvList();
|
||||
|
||||
if (count($combinationAttributes) > 0) {
|
||||
|
||||
foreach ($combinationAttributes as $attributeAvId) {
|
||||
|
||||
$attributeAv = AttributeAvQuery::create()->findPk($attributeAvId);
|
||||
|
||||
if ($attributeAv !== null) {
|
||||
$attributeCombination = new AttributeCombination();
|
||||
|
||||
$attributeCombination
|
||||
->setAttributeAvId($attributeAvId)
|
||||
->setAttribute($attributeAv->getAttribute())
|
||||
->setProductSaleElements($salesElement)
|
||||
->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store all the stuff !
|
||||
$con->commit();
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
$con->rollback();
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteProductCombination(ProductDeleteCombinationEvent $event)
|
||||
{
|
||||
if (null !== $pse = ProductSaleElementsQuery::create()->findPk($event->getProductSaleElementId())) {
|
||||
$pse->delete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -436,18 +374,15 @@ class Product extends BaseAction implements EventSubscriberInterface
|
||||
TheliaEvents::PRODUCT_DELETE => array("delete", 128),
|
||||
TheliaEvents::PRODUCT_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
|
||||
|
||||
TheliaEvents::PRODUCT_UPDATE_POSITION => array("updatePosition", 128),
|
||||
TheliaEvents::PRODUCT_UPDATE_POSITION => array("updatePosition", 128),
|
||||
|
||||
TheliaEvents::PRODUCT_ADD_CONTENT => array("addContent", 128),
|
||||
TheliaEvents::PRODUCT_REMOVE_CONTENT => array("removeContent", 128),
|
||||
TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION => array("updateAccessoryPosition", 128),
|
||||
TheliaEvents::PRODUCT_UPDATE_CONTENT_POSITION => array("updateContentPosition", 128),
|
||||
|
||||
TheliaEvents::PRODUCT_ADD_COMBINATION => array("createProductCombination", 128),
|
||||
TheliaEvents::PRODUCT_DELETE_COMBINATION => array("deleteProductCombination", 128),
|
||||
|
||||
TheliaEvents::PRODUCT_ADD_ACCESSORY => array("addAccessory", 128),
|
||||
TheliaEvents::PRODUCT_REMOVE_ACCESSORY => array("removeAccessory", 128),
|
||||
TheliaEvents::PRODUCT_ADD_ACCESSORY => array("addAccessory", 128),
|
||||
TheliaEvents::PRODUCT_REMOVE_ACCESSORY => array("removeAccessory", 128),
|
||||
TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION => array("updateAccessoryPosition", 128),
|
||||
|
||||
TheliaEvents::PRODUCT_ADD_CATEGORY => array("addCategory", 128),
|
||||
TheliaEvents::PRODUCT_REMOVE_CATEGORY => array("removeCategory", 128),
|
||||
@@ -456,7 +391,6 @@ class Product extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE => array("updateFeatureProductValue", 128),
|
||||
TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE => array("deleteFeatureProductValue", 128),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
232
core/lib/Thelia/Action/ProductSaleElement.php
Normal file
232
core/lib/Thelia/Action/ProductSaleElement.php
Normal file
@@ -0,0 +1,232 @@
|
||||
<?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 Thelia\Model\ProductQuery;
|
||||
use Thelia\Model\Product as ProductModel;
|
||||
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\ProductSaleElement\ProductSaleElementCreateEvent;
|
||||
use Thelia\Model\Map\ProductSaleElementsTableMap;
|
||||
use Thelia\Model\ProductSaleElements;
|
||||
use Thelia\Model\ProductPrice;
|
||||
use Thelia\Model\AttributeCombination;
|
||||
use Thelia\Core\Event\ProductSaleElement\ProductSaleElementDeleteEvent;
|
||||
use Thelia\Model\ProductSaleElementsQuery;
|
||||
use Thelia\Core\Event\ProductSaleElement\ProductSaleElementUpdateEvent;
|
||||
use Thelia\Model\ProductPriceQuery;
|
||||
use Propel\Runtime\Propel;
|
||||
use Thelia\Model\AttributeAvQuery;
|
||||
use Thelia\Model\Currency;
|
||||
use Thelia\Model\Map\AttributeCombinationTableMap;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
|
||||
class ProductSaleElement extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Create a new product sale element, with or without combination
|
||||
*
|
||||
* @param ProductSaleElementCreateEvent $event
|
||||
* @throws Exception
|
||||
*/
|
||||
public function create(ProductSaleElementCreateEvent $event)
|
||||
{
|
||||
$con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME);
|
||||
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
// Check if we have a PSE without combination, this is the "default" PSE. Attach the combination to this PSE
|
||||
$salesElement = ProductSaleElementsQuery::create()
|
||||
->filterByProductId($event->getProduct()->getId())
|
||||
->joinAttributeCombination(null, Criteria::LEFT_JOIN)
|
||||
->add(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, null, Criteria::ISNULL)
|
||||
->findOne($con);
|
||||
|
||||
if ($salesElement == null) {
|
||||
// Create a new product sale element
|
||||
$salesElement = $event->getProduct()->createDefaultProductSaleElement($con, 0, 0, $event->getCurrencyId(), true);
|
||||
}
|
||||
else {
|
||||
// This one is the default
|
||||
$salesElement->setIsDefault(true)->save($con);
|
||||
}
|
||||
|
||||
// Attach combination, if defined.
|
||||
$combinationAttributes = $event->getAttributeAvList();
|
||||
|
||||
if (count($combinationAttributes) > 0) {
|
||||
|
||||
foreach ($combinationAttributes as $attributeAvId) {
|
||||
|
||||
$attributeAv = AttributeAvQuery::create()->findPk($attributeAvId);
|
||||
|
||||
if ($attributeAv !== null) {
|
||||
$attributeCombination = new AttributeCombination();
|
||||
|
||||
$attributeCombination
|
||||
->setAttributeAvId($attributeAvId)
|
||||
->setAttribute($attributeAv->getAttribute())
|
||||
->setProductSaleElements($salesElement)
|
||||
->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store all the stuff !
|
||||
$con->commit();
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
|
||||
$con->rollback();
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing product sale element
|
||||
*
|
||||
* @param ProductSaleElementUpdateEvent $event
|
||||
*/
|
||||
public function update(ProductSaleElementUpdateEvent $event)
|
||||
{
|
||||
$salesElement = ProductSaleElementsQuery::create()->findPk($event->getProductSaleElementId());
|
||||
|
||||
$con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME);
|
||||
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
|
||||
// If product sale element is not defined, create it.
|
||||
if ($salesElement == null) {
|
||||
$salesElement = new ProductSaleElements();
|
||||
|
||||
$salesElement->setProduct($event->getProduct());
|
||||
}
|
||||
|
||||
// Update sale element
|
||||
$salesElement
|
||||
->setRef($event->getReference())
|
||||
->setQuantity($event->getQuantity())
|
||||
->setPromo($event->getOnsale())
|
||||
->setNewness($event->getIsnew())
|
||||
->setWeight($event->getWeight())
|
||||
->setIsDefault($event->getIsDefault())
|
||||
->setEanCode($event->getEanCode())
|
||||
->save()
|
||||
;
|
||||
|
||||
// Update/create price for current currency
|
||||
$productPrice = ProductPriceQuery::create()
|
||||
->filterByCurrencyId($event->getCurrencyId())
|
||||
->filterByProductSaleElementsId($salesElement->getId())
|
||||
->findOne($con);
|
||||
|
||||
// If price is not defined, create it.
|
||||
if ($productPrice == null) {
|
||||
|
||||
$productPrice = new ProductPrice();
|
||||
|
||||
$productPrice
|
||||
->setProductSaleElements($salesElement)
|
||||
->setCurrencyId($event->getCurrencyId())
|
||||
;
|
||||
}
|
||||
|
||||
$productPrice
|
||||
->setPromoPrice($event->getSalePrice())
|
||||
->setPrice($event->getPrice())
|
||||
->save($con)
|
||||
;
|
||||
|
||||
// Store all the stuff !
|
||||
$con->commit();
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
|
||||
$con->rollback();
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a product sale element
|
||||
*
|
||||
* @param ProductSaleElementDeleteEvent $event
|
||||
*/
|
||||
public function delete(ProductSaleElementDeleteEvent $event)
|
||||
{
|
||||
if (null !== $pse = ProductSaleElementsQuery::create()->findPk($event->getProductSaleElementId())) {
|
||||
|
||||
$product = $pse->getProduct();
|
||||
|
||||
$con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME);
|
||||
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
|
||||
$pse->delete($con);
|
||||
|
||||
if ($product->countSaleElements() <= 0) {
|
||||
// If we just deleted the last PSE, create a default one
|
||||
$product->createDefaultProductSaleElement($con, 0, 0, $event->getCurrencyId(), true);
|
||||
}
|
||||
else if ($product->getDefaultSaleElements() == null) {
|
||||
|
||||
// If we deleted the default PSE, make the last created one the default
|
||||
$pse = ProductSaleElementsQuery::create()->filterByProductId($this->id)->orderByCreatedAt(Criteria::DESC)->findOne($con);
|
||||
|
||||
$pse->setIsDefault(true)->save($con);
|
||||
}
|
||||
|
||||
// Store all the stuff !
|
||||
$con->commit();
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
|
||||
$con->rollback();
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::PRODUCT_ADD_PRODUCT_SALE_ELEMENT => array("create", 128),
|
||||
TheliaEvents::PRODUCT_UPDATE_PRODUCT_SALE_ELEMENT => array("update", 128),
|
||||
TheliaEvents::PRODUCT_DELETE_PRODUCT_SALE_ELEMENT => array("delete", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -27,8 +27,15 @@ use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Profile\ProfileEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Model\Profile as ProfileModel;
|
||||
use Thelia\Model\ProfileModule;
|
||||
use Thelia\Model\ProfileModuleQuery;
|
||||
use Thelia\Model\ProfileQuery;
|
||||
use Thelia\Model\ProfileResource;
|
||||
use Thelia\Model\ProfileResourceQuery;
|
||||
use Thelia\Model\ResourceQuery;
|
||||
|
||||
class Profile extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
@@ -76,6 +83,54 @@ class Profile extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ProfileEvent $event
|
||||
*/
|
||||
public function updateResourceAccess(ProfileEvent $event)
|
||||
{
|
||||
if (null !== $profile = ProfileQuery::create()->findPk($event->getId())) {
|
||||
ProfileResourceQuery::create()->filterByProfileId($event->getId())->delete();
|
||||
foreach($event->getResourceAccess() as $resourceCode => $accesses) {
|
||||
$manager = new AccessManager(0);
|
||||
$manager->build($accesses);
|
||||
|
||||
$profileResource = new ProfileResource();
|
||||
$profileResource->setProfileId($event->getId())
|
||||
->setResource(ResourceQuery::create()->findOneByCode($resourceCode))
|
||||
->setAccess( $manager->getAccessValue() );
|
||||
|
||||
$profileResource->save();
|
||||
|
||||
}
|
||||
|
||||
$event->setProfile($profile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ProfileEvent $event
|
||||
*/
|
||||
public function updateModuleAccess(ProfileEvent $event)
|
||||
{
|
||||
if (null !== $profile = ProfileQuery::create()->findPk($event->getId())) {
|
||||
ProfileModuleQuery::create()->filterByProfileId($event->getId())->delete();
|
||||
foreach($event->getModuleAccess() as $moduleCode => $accesses) {
|
||||
$manager = new AccessManager(0);
|
||||
$manager->build($accesses);
|
||||
|
||||
$profileModule = new ProfileModule();
|
||||
$profileModule->setProfileId($event->getId())
|
||||
->setModule(ModuleQuery::create()->findOneByCode($moduleCode))
|
||||
->setAccess( $manager->getAccessValue() );
|
||||
|
||||
$profileModule->save();
|
||||
|
||||
}
|
||||
|
||||
$event->setProfile($profile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ProfileEvent $event
|
||||
*/
|
||||
@@ -97,9 +152,11 @@ class Profile extends BaseAction implements EventSubscriberInterface
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::PROFILE_CREATE => array("create", 128),
|
||||
TheliaEvents::PROFILE_UPDATE => array("update", 128),
|
||||
TheliaEvents::PROFILE_DELETE => array("delete", 128),
|
||||
TheliaEvents::PROFILE_CREATE => array("create", 128),
|
||||
TheliaEvents::PROFILE_UPDATE => array("update", 128),
|
||||
TheliaEvents::PROFILE_DELETE => array("delete", 128),
|
||||
TheliaEvents::PROFILE_RESOURCE_ACCESS_UPDATE => array("updateResourceAccess", 128),
|
||||
TheliaEvents::PROFILE_MODULE_ACCESS_UPDATE => array("updateModuleAccess", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,9 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Thelia\Command\ContainerAwareCommand;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Model\Admin;
|
||||
use Thelia\Model\Map\ResourceI18nTableMap;
|
||||
use Thelia\Model\Map\ResourceTableMap;
|
||||
|
||||
class GenerateResources extends ContainerAwareCommand
|
||||
@@ -46,7 +48,7 @@ class GenerateResources extends ContainerAwareCommand
|
||||
'output',
|
||||
null,
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'Output format amid (string, sql)',
|
||||
'Output format amid (string, sql, sql-i18n)',
|
||||
null
|
||||
)
|
||||
;
|
||||
@@ -55,7 +57,7 @@ class GenerateResources extends ContainerAwareCommand
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$class = new \ReflectionClass('Thelia\Core\Event\AdminResources');
|
||||
$class = new \ReflectionClass('Thelia\Core\Security\Resource\AdminResources');
|
||||
|
||||
$constants = $class->getConstants();
|
||||
|
||||
@@ -69,18 +71,42 @@ class GenerateResources extends ContainerAwareCommand
|
||||
$output->writeln(
|
||||
'INSERT INTO ' . ResourceTableMap::TABLE_NAME . ' (`id`, `code`, `created_at`, `updated_at`) VALUES '
|
||||
);
|
||||
$compteur = 0;
|
||||
foreach($constants as $constant => $value) {
|
||||
if($constant == 'SUPERADMINISTRATOR') {
|
||||
if($constant == AdminResources::SUPERADMINISTRATOR) {
|
||||
continue;
|
||||
}
|
||||
$compteur++;
|
||||
$output->writeln(
|
||||
"(NULL, '$value', NOW(), NOW())" . ($constant === key( array_slice( $constants, -1, 1, TRUE ) ) ? '' : ',')
|
||||
"($compteur, '$value', NOW(), NOW())" . ($constant === key( array_slice( $constants, -1, 1, true ) ) ? ';' : ',')
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'sql-i18n':
|
||||
$output->writeln(
|
||||
'INSERT INTO ' . ResourceI18nTableMap::TABLE_NAME . ' (`id`, `locale`, `title`) VALUES '
|
||||
);
|
||||
$compteur = 0;
|
||||
foreach($constants as $constant => $value) {
|
||||
if($constant == AdminResources::SUPERADMINISTRATOR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$compteur++;
|
||||
|
||||
$title = ucwords( str_replace('.', ' / ', str_replace('admin.', '', $value) ) );
|
||||
|
||||
$output->writeln(
|
||||
"($compteur, 'en_US', '$title'),"
|
||||
);
|
||||
$output->writeln(
|
||||
"($compteur, 'fr_FR', '$title')" . ($constant === key( array_slice( $constants, -1, 1, true ) ) ? ';' : ',')
|
||||
);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
foreach($constants as $constant => $value) {
|
||||
if($constant == 'SUPERADMINISTRATOR') {
|
||||
if($constant == AdminResources::SUPERADMINISTRATOR) {
|
||||
continue;
|
||||
}
|
||||
$output->writeln('[' . $constant . "] => " . $value);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
namespace Thelia\Condition;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Thelia\Coupon\AdapterInterface;
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
use Thelia\Coupon\ConditionCollection;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class ConditionFactory
|
||||
/** @var ContainerInterface Service Container */
|
||||
protected $container = null;
|
||||
|
||||
/** @var AdapterInterface Provide necessary value from Thelia */
|
||||
/** @var FacadeInterface Provide necessary value from Thelia */
|
||||
protected $adapter;
|
||||
|
||||
/** @var array ConditionCollection to process*/
|
||||
@@ -82,10 +82,6 @@ class ConditionFactory
|
||||
if ($conditions !== null) {
|
||||
/** @var $condition ConditionManagerInterface */
|
||||
foreach ($conditions as $condition) {
|
||||
// Remove all condition if the "no condition" condition is found
|
||||
// if ($condition->getServiceId() == 'thelia.condition.match_for_everyone') {
|
||||
// return base64_encode(json_encode(array($condition->getSerializableRule())));
|
||||
// }
|
||||
$serializableConditions[] = $condition->getSerializableCondition();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Thelia\Condition;
|
||||
|
||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Coupon\AdapterInterface;
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
use Thelia\Exception\InvalidConditionValueException;
|
||||
use Thelia\Model\Currency;
|
||||
use Thelia\Type\FloatType;
|
||||
@@ -43,10 +43,6 @@ use Thelia\Type\FloatType;
|
||||
*/
|
||||
abstract class ConditionManagerAbstract implements ConditionManagerInterface
|
||||
{
|
||||
// /** Operator key in $validators */
|
||||
// CONST OPERATOR = 'operator';
|
||||
// /** Value key in $validators */
|
||||
// CONST VALUE = 'value';
|
||||
|
||||
/** @var string Service Id from Resources/config.xml */
|
||||
protected $serviceId = null;
|
||||
@@ -57,10 +53,7 @@ abstract class ConditionManagerAbstract implements ConditionManagerInterface
|
||||
/** @var array Parameters validating parameters against */
|
||||
protected $validators = array();
|
||||
|
||||
// /** @var array Parameters to be validated */
|
||||
// protected $paramsToValidate = array();
|
||||
|
||||
/** @var AdapterInterface Provide necessary value from Thelia */
|
||||
/** @var FacadeInterface Provide necessary value from Thelia */
|
||||
protected $adapter = null;
|
||||
|
||||
/** @var Translator Service Translator */
|
||||
@@ -78,71 +71,15 @@ abstract class ConditionManagerAbstract implements ConditionManagerInterface
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param AdapterInterface $adapter Service adapter
|
||||
* @param FacadeInterface $adapter Service adapter
|
||||
*/
|
||||
public function __construct(AdapterInterface $adapter)
|
||||
public function __construct(FacadeInterface $adapter)
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
$this->translator = $adapter->getTranslator();
|
||||
$this->conditionValidator = $adapter->getConditionEvaluator();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Check validator relevancy and store them
|
||||
// *
|
||||
// * @param array $validators Array of RuleValidator
|
||||
// * validating $paramsToValidate against
|
||||
// *
|
||||
// * @return $this
|
||||
// * @throws InvalidConditionException
|
||||
// */
|
||||
// protected function setValidators(array $validators)
|
||||
// {
|
||||
// foreach ($validators as $validator) {
|
||||
// if (!$validator instanceof RuleValidator) {
|
||||
// throw new InvalidConditionException(get_class());
|
||||
// }
|
||||
// if (!in_array($validator->getOperator(), $this->availableOperators)) {
|
||||
// throw new InvalidConditionOperatorException(
|
||||
// get_class(),
|
||||
// $validator->getOperator()
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// $this->validators = $validators;
|
||||
//
|
||||
// return $this;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * Check if the current Checkout matches this condition
|
||||
// *
|
||||
// * @return bool
|
||||
// */
|
||||
// public function isMatching()
|
||||
// {
|
||||
// $this->checkBackOfficeInput();
|
||||
// $this->checkCheckoutInput();
|
||||
//
|
||||
// $isMatching = true;
|
||||
// /** @var $validator RuleValidator*/
|
||||
// foreach ($this->validators as $param => $validator) {
|
||||
// $a = $this->paramsToValidate[$param];
|
||||
// $operator = $validator->getOperator();
|
||||
// /** @var ComparableInterface, RuleParameterAbstract $b */
|
||||
// $b = $validator->getParam();
|
||||
//
|
||||
// if (!Operators::isValid($a, $operator, $b)) {
|
||||
// $isMatching = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return $isMatching;
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return all available Operators for this Condition
|
||||
*
|
||||
@@ -153,37 +90,6 @@ abstract class ConditionManagerAbstract implements ConditionManagerInterface
|
||||
return $this->availableOperators;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Check if Operators set for this Rule in the BackOffice are legit
|
||||
// *
|
||||
// * @throws InvalidConditionOperatorException if Operator is not allowed
|
||||
// * @return bool
|
||||
// */
|
||||
// protected function checkBackOfficeInputsOperators()
|
||||
// {
|
||||
// /** @var RuleValidator $param */
|
||||
// foreach ($this->validators as $key => $param) {
|
||||
// $operator = $param->getOperator();
|
||||
// if (!isset($operator)
|
||||
// ||!in_array($operator, $this->availableOperators)
|
||||
// ) {
|
||||
// throw new InvalidConditionOperatorException(get_class(), $key);
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Generate current Rule param to be validated from adapter
|
||||
// *
|
||||
// * @throws \Thelia\Exception\NotImplementedException
|
||||
// * @return $this
|
||||
// */
|
||||
// protected function setParametersToValidate()
|
||||
// {
|
||||
// throw new \Thelia\Exception\NotImplementedException();
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return all validators
|
||||
*
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
namespace Thelia\Condition;
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Coupon\AdapterInterface;
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
@@ -42,9 +42,9 @@ interface ConditionManagerInterface
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param AdapterInterface $adapter Service adapter
|
||||
* @param FacadeInterface $adapter Service adapter
|
||||
*/
|
||||
function __construct(AdapterInterface $adapter);
|
||||
function __construct(FacadeInterface $adapter);
|
||||
|
||||
/**
|
||||
* Get Rule Service id
|
||||
@@ -53,20 +53,6 @@ interface ConditionManagerInterface
|
||||
*/
|
||||
public function getServiceId();
|
||||
|
||||
// /**
|
||||
// * Check if backoffice inputs are relevant or not
|
||||
// *
|
||||
// * @return bool
|
||||
// */
|
||||
// public function checkBackOfficeInput();
|
||||
|
||||
// /**
|
||||
// * Check if Checkout inputs are relevant or not
|
||||
// *
|
||||
// * @return bool
|
||||
// */
|
||||
// public function checkCheckoutInput();
|
||||
|
||||
/**
|
||||
* Check validators relevancy and store them
|
||||
*
|
||||
@@ -78,13 +64,6 @@ interface ConditionManagerInterface
|
||||
*/
|
||||
public function setValidatorsFromForm(array $operators, array $values);
|
||||
|
||||
// /**
|
||||
// * Check if the current Checkout matches this condition
|
||||
// *
|
||||
// * @return bool
|
||||
// */
|
||||
// public function isMatching();
|
||||
|
||||
/**
|
||||
* Test if the current application state matches conditions
|
||||
*
|
||||
@@ -121,17 +100,6 @@ interface ConditionManagerInterface
|
||||
*/
|
||||
public function getValidators();
|
||||
|
||||
// /**
|
||||
// * Populate a Condition from a form admin
|
||||
// *
|
||||
// * @param array $operators Condition Operator set by the Admin
|
||||
// * @param array $values Condition Values set by the Admin
|
||||
// *
|
||||
// * @return bool
|
||||
// */
|
||||
// public function populateFromForm(array$operators, array $values);
|
||||
|
||||
|
||||
/**
|
||||
* Return a serializable Condition
|
||||
*
|
||||
|
||||
@@ -45,33 +45,4 @@ class SerializableCondition
|
||||
/** @var array Values set by Admin for this Condition */
|
||||
public $values = array();
|
||||
|
||||
// /**
|
||||
// * Get Operators set by Admin for this Condition
|
||||
// *
|
||||
// * @return array
|
||||
// */
|
||||
// public function getOperators()
|
||||
// {
|
||||
// return $this->operators;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get Condition Service id
|
||||
// *
|
||||
// * @return string
|
||||
// */
|
||||
// public function getConditionServiceId()
|
||||
// {
|
||||
// return $this->conditionServiceId;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get Values set by Admin for this Condition
|
||||
// *
|
||||
// * @return array
|
||||
// */
|
||||
// public function getValues()
|
||||
// {
|
||||
// return $this->values;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -44,7 +44,9 @@ class DefinePropel
|
||||
"dsn" => $connection["dsn"],
|
||||
"user" => $connection["user"],
|
||||
"password" => $connection["password"],
|
||||
"classname" => $connection["classname"]
|
||||
"classname" => $connection["classname"],
|
||||
'options' => array(
|
||||
\PDO::MYSQL_ATTR_INIT_COMMAND => array('value' =>'SET NAMES \'UTF8\''))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,11 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.product_sale_element" class="Thelia\Action\ProductSaleElement">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.config" class="Thelia\Action\Config">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
@@ -156,10 +161,20 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.administrator" class="Thelia\Action\Administrator">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.newsletter" class="Thelia\Action\Newsletter">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.lang" class="Thelia\Action\Lang">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
<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\Resource" name="resource"/>
|
||||
<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"/>
|
||||
@@ -87,6 +88,9 @@
|
||||
<form name="thelia.admin.product.image.modification" class="Thelia\Form\ProductImageModification"/>
|
||||
<form name="thelia.admin.product.document.modification" class="Thelia\Form\ProductDocumentModification"/>
|
||||
|
||||
<form name="thelia.admin.product_sale_element.update" class="Thelia\Form\ProductSaleElementUpdateForm"/>
|
||||
<form name="thelia.admin.product_default_sale_element.update" class="Thelia\Form\ProductDefaultSaleElementUpdateForm"/>
|
||||
|
||||
<form name="thelia.admin.product.deletion" class="Thelia\Form\ProductModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.folder.creation" class="Thelia\Form\FolderCreationForm"/>
|
||||
@@ -105,6 +109,8 @@
|
||||
<form name="thelia.order.payment" class="Thelia\Form\OrderPayment"/>
|
||||
<form name="thelia.order.update.address" class="Thelia\Form\OrderUpdateAddress"/>
|
||||
|
||||
<form name="thelia.order.coupon" class="Thelia\Form\CouponCode"/>
|
||||
|
||||
<form name="thelia.admin.config.creation" class="Thelia\Form\ConfigCreationForm"/>
|
||||
<form name="thelia.admin.config.modification" class="Thelia\Form\ConfigModificationForm"/>
|
||||
|
||||
@@ -136,16 +142,17 @@
|
||||
|
||||
<form name="thelia.admin.profile.add" class="Thelia\Form\ProfileCreationForm"/>
|
||||
<form name="thelia.admin.profile.modification" class="Thelia\Form\ProfileModificationForm"/>
|
||||
<form name="thelia.admin.profile.resource-access.modification" class="Thelia\Form\ProfileUpdateResourceAccessForm"/>
|
||||
<form name="thelia.admin.profile.module-access.modification" class="Thelia\Form\ProfileUpdateModuleAccessForm"/>
|
||||
|
||||
<form name="thelia.admin.administrator.add" class="Thelia\Form\AdministratorCreationForm"/>
|
||||
<form name="thelia.admin.administrator.update" class="Thelia\Form\AdministratorModificationForm"/>
|
||||
|
||||
<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.language.creation" class="Thelia\Form\LanguageCreationForm"/>
|
||||
|
||||
<form name="thelia.admin.admin-profile.creation" class="Thelia\Form\AdminProfileCreationForm"/>
|
||||
|
||||
<form name="thelia.admin.area.create" class="Thelia\Form\Area\AreaCreateForm"/>
|
||||
<form name="thelia.admin.area.modification" class="Thelia\Form\Area\AreaModificationForm"/>
|
||||
@@ -154,6 +161,11 @@
|
||||
|
||||
<form name="thelia.shopping_zone_area" class="Thelia\Form\ShippingZone\ShippingZoneAddArea"/>
|
||||
<form name="thelia.shopping_zone_remove_area" class="Thelia\Form\ShippingZone\ShippingZoneRemoveArea"/>
|
||||
|
||||
<form name="thelia.lang.update" class="Thelia\Form\Lang\LangUpdateForm"/>
|
||||
<form name="thelia.lang.create" class="Thelia\Form\Lang\LangCreateForm"/>
|
||||
<form name="thelia.lang.defaultBehavior" class="Thelia\Form\Lang\LangDefaultBehaviorForm"/>
|
||||
<form name="thelia.lang.url" class="Thelia\Form\Lang\LangUrlForm"/>
|
||||
</forms>
|
||||
|
||||
|
||||
@@ -312,7 +324,7 @@
|
||||
<service id="kernel" synthetic="true" />
|
||||
|
||||
<!-- Coupon module -->
|
||||
<service id="thelia.adapter" class="Thelia\Coupon\BaseAdapter">
|
||||
<service id="thelia.adapter" class="Thelia\Coupon\BaseFacade">
|
||||
<argument type="service" id="service_container" />
|
||||
</service>
|
||||
<service id="thelia.coupon.manager" class="Thelia\Coupon\CouponManager">
|
||||
|
||||
@@ -24,13 +24,6 @@
|
||||
<default key="_controller">Thelia\Controller\Admin\SessionController::checkLoginAction</default>
|
||||
</route>
|
||||
|
||||
<!-- Route to edit admin profile -->
|
||||
<route id="admin.profile.update.view" path="/admin/profile/update" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Admin\AdminController::updateAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
|
||||
<!-- Route to the catalog controller -->
|
||||
|
||||
<route id="admin.catalog" path="/admin/catalog">
|
||||
@@ -310,6 +303,10 @@
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updateContentPositionAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.product.update-content-position" path="/admin/product/calculate-price">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::priceCaclulator</default>
|
||||
</route>
|
||||
|
||||
<!-- accessories -->
|
||||
|
||||
<route id="admin.products.accessories.add" path="/admin/products/accessory/add">
|
||||
@@ -356,19 +353,19 @@
|
||||
</route>
|
||||
|
||||
<route id="admin.product.combination.add" path="/admin/product/combination/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::addCombinationAction</default>
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::addProductSaleElementAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.product.combination.delete" path="/admin/product/combination/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::deleteCombinationAction</default>
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::deleteProductSaleElementAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.product.combination.update" path="/admin/product/combination/update">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updateCombinationAction</default>
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updateProductSaleElementAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.product.combination.defaut-price.update" path="/admin/product/default-price/update">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updateDefaultPriceAction</default>
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updateProductDefaultSaleElementAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
@@ -777,12 +774,40 @@
|
||||
<default key="_controller">Thelia\Controller\Admin\ProfileController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.profiles.saveResourceAccess" path="/admin/configuration/profiles/saveResourceAccess">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProfileController::processUpdateResourceAccess</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.profiles.saveModuleAccess" path="/admin/configuration/profiles/saveModuleAccess">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProfileController::processUpdateModuleAccess</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 -->
|
||||
|
||||
<!-- administrator management -->
|
||||
|
||||
<route id="admin.configuration.administrators.view" path="/admin/configuration/administrators">
|
||||
<default key="_controller">Thelia\Controller\Admin\AdministratorController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.administrators.add" path="/admin/configuration/administrators/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\AdministratorController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.administrators.save" path="/admin/configuration/administrators/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\AdministratorController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.administrators.delete" path="/admin/configuration/administrators/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\AdministratorController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end administrator management -->
|
||||
|
||||
<!-- feature and features value management -->
|
||||
|
||||
<route id="admin.configuration.features.default" path="/admin/configuration/features">
|
||||
@@ -912,6 +937,50 @@
|
||||
|
||||
<!-- end tax rules management -->
|
||||
|
||||
<!-- language management -->
|
||||
|
||||
<route id="admin.configuration.languages" path="/admin/configuration/languages">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.languages.update" path="/admin/configuration/languages/update/{lang_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::updateAction</default>
|
||||
<requirement key="lang_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.languages.update.process" path="/admin/configuration/languages/save/{lang_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::processUpdateAction</default>
|
||||
<requirement key="lang_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.languages.toggleDefault" path="/admin/configuration/languages/toggleDefault/{lang_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::toggleDefaultAction</default>
|
||||
<requirement key="lang_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.languages.add" path="/admin/configuration/languages/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::addAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.languages.delete" path="/admin/configuration/languages/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.languages.defaultBehavior" path="/admin/configuration/languages/defaultBehavior">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::defaultBehaviorAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.languages.updateUrl" path="/admin/configuration/languages/updateUrl">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::domainAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.languages.domain.activation" path="/admin/configuration/languages/domain/activate">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::activateDomainAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.languages.domain.deactivation" path="/admin/configuration/languages/domain/deactivate">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::deactivateDomainAction</default>
|
||||
</route>
|
||||
|
||||
<!-- The default route, to display a template -->
|
||||
|
||||
|
||||
@@ -131,6 +131,11 @@
|
||||
<default key="_view">order-invoice</default>
|
||||
</route>
|
||||
|
||||
<route id="order.coupon.process" path="/order/coupon" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\CouponController::consumeAction</default>
|
||||
<default key="_view">order-invoice</default>
|
||||
</route>
|
||||
|
||||
<route id="order.payment.process" path="/order/pay">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::pay</default>
|
||||
</route>
|
||||
|
||||
201
core/lib/Thelia/Controller/Admin/AdministratorController.php
Normal file
201
core/lib/Thelia/Controller/Admin/AdministratorController.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?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\Security\AccessManager;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Core\Event\Administrator\AdministratorEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\AdministratorCreationForm;
|
||||
use Thelia\Form\AdministratorModificationForm;
|
||||
use Thelia\Model\AdminQuery;
|
||||
|
||||
|
||||
class AdministratorController extends AbstractCrudController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'administrator',
|
||||
'manual',
|
||||
'order',
|
||||
|
||||
AdminResources::ADMINISTRATOR,
|
||||
|
||||
TheliaEvents::ADMINISTRATOR_CREATE,
|
||||
TheliaEvents::ADMINISTRATOR_UPDATE,
|
||||
TheliaEvents::ADMINISTRATOR_DELETE
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new AdministratorCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new AdministratorModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$event = new AdministratorEvent();
|
||||
|
||||
$event->setLogin($formData['login']);
|
||||
$event->setFirstname($formData['firstname']);
|
||||
$event->setLastname($formData['lastname']);
|
||||
$event->setPassword($formData['password']);
|
||||
$event->setProfile($formData['profile'] ? : null);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$event = new AdministratorEvent();
|
||||
|
||||
$event->setId($formData['id']);
|
||||
$event->setLogin($formData['login']);
|
||||
$event->setFirstname($formData['firstname']);
|
||||
$event->setLastname($formData['lastname']);
|
||||
$event->setPassword($formData['password']);
|
||||
$event->setProfile($formData['profile'] ? : null);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
$event = new AdministratorEvent();
|
||||
|
||||
$event->setId(
|
||||
$this->getRequest()->get('administrator_id', 0)
|
||||
);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasAdministrator();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'firstname' => $object->getFirstname(),
|
||||
'lastname' => $object->getLastname(),
|
||||
'login' => $object->getLogin(),
|
||||
'profile' => $object->getProfileId(),
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new AdministratorModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function hydrateResourceUpdateForm($object)
|
||||
{
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new AdministratorUpdateResourceAccessForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function hydrateModuleUpdateForm($object)
|
||||
{
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new AdministratorUpdateModuleAccessForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasAdministrator() ? $event->getAdministrator() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return AdminQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('administrator_id'));
|
||||
}
|
||||
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getLogin();
|
||||
}
|
||||
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
return $this->render(
|
||||
'administrators',
|
||||
array()
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
return $this->render('administrators');
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
$this->redirectToListTemplate();
|
||||
}
|
||||
|
||||
protected function performAdditionalCreateAction($updateEvent)
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
$this->redirectToListTemplate();
|
||||
}
|
||||
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
$this->redirectToListTemplate();
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.administrators.view"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -97,14 +97,17 @@ class BaseAdminController extends BaseController
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected function errorPage($message)
|
||||
protected function errorPage($message, $status = 500)
|
||||
{
|
||||
if ($message instanceof \Exception) {
|
||||
$message = $this->getTranslator()->trans("Sorry, an error occured: %msg", array('%msg' => $message->getMessage()));
|
||||
}
|
||||
|
||||
return $this->render('general_error', array(
|
||||
"error_message" => $message)
|
||||
return $this->render('general_error',
|
||||
array(
|
||||
"error_message" => $message
|
||||
),
|
||||
$status
|
||||
);
|
||||
}
|
||||
|
||||
@@ -128,12 +131,12 @@ class BaseAdminController extends BaseController
|
||||
}
|
||||
|
||||
// Log the problem
|
||||
$this->adminLogAppend("User is not granted for permissions %s", implode(", ", $permArr));
|
||||
$this->adminLogAppend("User is not granted for resources %s with accesses %s", implode(", ", $resources), implode(", ", $accesses));
|
||||
|
||||
// Generate the proper response
|
||||
$response = new Response();
|
||||
|
||||
return $this->errorPage($this->getTranslator()->trans("Sorry, you're not allowed to perform this action"));
|
||||
return $this->errorPage($this->getTranslator()->trans("Sorry, you're not allowed to perform this action"), 403);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -366,14 +369,13 @@ class BaseAdminController extends BaseController
|
||||
* Render the given template, and returns the result as an Http Response.
|
||||
*
|
||||
* @param $templateName the complete template name, with extension
|
||||
* @param array $args the template arguments
|
||||
* @param array $args the template arguments
|
||||
* @param int $status http code status
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected function render($templateName, $args = array())
|
||||
protected function render($templateName, $args = array(), $status = 200)
|
||||
{
|
||||
$response = new Response();
|
||||
|
||||
return $response->setContent($this->renderRaw($templateName, $args));
|
||||
return Response::create($this->renderRaw($templateName, $args), $status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -430,7 +432,7 @@ class BaseAdminController extends BaseController
|
||||
Redirect::exec(URL::getInstance()->absoluteUrl($ex->getLoginTemplate()));
|
||||
} catch (AuthorizationException $ex) {
|
||||
// User is not allowed to perform the required action. Return the error page instead of the requested page.
|
||||
return $this->errorPage($this->getTranslator()->trans("Sorry, you are not allowed to perform this action."));
|
||||
return $this->errorPage($this->getTranslator()->trans("Sorry, you are not allowed to perform this action."), 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,6 +251,6 @@ class CountryController extends AbstractCrudController
|
||||
|
||||
}
|
||||
|
||||
return $this->nullResponse($content, 500);
|
||||
return $this->nullResponse(500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,6 @@ use Symfony\Component\Routing\Router;
|
||||
use Thelia\Condition\ConditionFactory;
|
||||
use Thelia\Condition\ConditionManagerInterface;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Core\Event\Condition\ConditionCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Coupon\CouponConsumeEvent;
|
||||
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
@@ -209,10 +207,7 @@ class CouponController extends BaseAdminController
|
||||
$conditions = $conditionFactory->unserializeConditionCollection(
|
||||
$coupon->getSerializedConditions()
|
||||
);
|
||||
var_dump($coupon->getIsEnabled());;
|
||||
var_dump($coupon->getIsAvailableOnSpecialOffers());;
|
||||
var_dump($coupon->getIsCumulative());;
|
||||
var_dump($coupon->getIsRemovingPostage());;
|
||||
|
||||
$data = array(
|
||||
'code' => $coupon->getCode(),
|
||||
'title' => $coupon->getTitle(),
|
||||
@@ -220,11 +215,11 @@ var_dump($coupon->getIsRemovingPostage());;
|
||||
'type' => $coupon->getType(),
|
||||
'shortDescription' => $coupon->getShortDescription(),
|
||||
'description' => $coupon->getDescription(),
|
||||
'isEnabled' => ($coupon->getIsEnabled() == 1),
|
||||
'isEnabled' => $coupon->getIsEnabled(),
|
||||
'expirationDate' => $coupon->getExpirationDate('Y-m-d'),
|
||||
'isAvailableOnSpecialOffers' => ($coupon->getIsAvailableOnSpecialOffers() == 1),
|
||||
'isCumulative' => ($coupon->getIsCumulative() == 1),
|
||||
'isRemovingPostage' => ($coupon->getIsRemovingPostage() == 1),
|
||||
'isAvailableOnSpecialOffers' => $coupon->getIsAvailableOnSpecialOffers(),
|
||||
'isCumulative' => $coupon->getIsCumulative(),
|
||||
'isRemovingPostage' => $coupon->getIsRemovingPostage(),
|
||||
'maxUsage' => $coupon->getMaxUsage(),
|
||||
'conditions' => $conditions,
|
||||
'locale' => $coupon->getLocale(),
|
||||
@@ -265,7 +260,7 @@ var_dump($coupon->getIsRemovingPostage());;
|
||||
Router::ABSOLUTE_URL
|
||||
);
|
||||
|
||||
$args['formAction'] = 'admin/coupon/update' . $couponId;
|
||||
$args['formAction'] = 'admin/coupon/update/' . $couponId;
|
||||
|
||||
return $this->render('coupon-update', $args);
|
||||
}
|
||||
@@ -335,27 +330,36 @@ var_dump($coupon->getIsRemovingPostage());;
|
||||
$conditions->add(clone $condition);
|
||||
}
|
||||
|
||||
// $coupon->setSerializedConditions(
|
||||
// $conditionFactory->serializeCouponConditionCollection($conditions)
|
||||
// );
|
||||
|
||||
$conditionEvent = new ConditionCreateOrUpdateEvent(
|
||||
$conditions
|
||||
$couponEvent = new CouponCreateOrUpdateEvent(
|
||||
$coupon->getCode(),
|
||||
$coupon->getTitle(),
|
||||
$coupon->getAmount(),
|
||||
$coupon->getType(),
|
||||
$coupon->getShortDescription(),
|
||||
$coupon->getDescription(),
|
||||
$coupon->getIsEnabled(),
|
||||
$coupon->getExpirationDate(),
|
||||
$coupon->getIsAvailableOnSpecialOffers(),
|
||||
$coupon->getIsCumulative(),
|
||||
$coupon->getIsRemovingPostage(),
|
||||
$coupon->getMaxUsage(),
|
||||
$coupon->getLocale()
|
||||
);
|
||||
$conditionEvent->setCouponModel($coupon);
|
||||
$couponEvent->setCouponModel($coupon);
|
||||
$couponEvent->setConditions($conditions);
|
||||
|
||||
$eventToDispatch = TheliaEvents::COUPON_CONDITION_UPDATE;
|
||||
// Dispatch Event to the Action
|
||||
$this->dispatch(
|
||||
$eventToDispatch,
|
||||
$conditionEvent
|
||||
$couponEvent
|
||||
);
|
||||
|
||||
$this->adminLogAppend(
|
||||
sprintf(
|
||||
'Coupon %s (ID %s) conditions updated',
|
||||
$conditionEvent->getCouponModel()->getTitle(),
|
||||
$conditionEvent->getCouponModel()->getServiceId()
|
||||
$couponEvent->getCouponModel()->getTitle(),
|
||||
$couponEvent->getCouponModel()->getType()
|
||||
)
|
||||
);
|
||||
|
||||
@@ -372,31 +376,6 @@ var_dump($coupon->getIsRemovingPostage());;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Coupon consuming
|
||||
*
|
||||
* @param string $couponCode Coupon code
|
||||
*
|
||||
* @todo remove (event dispatcher testing purpose)
|
||||
*
|
||||
*/
|
||||
public function consumeAction($couponCode)
|
||||
{
|
||||
// @todo remove (event dispatcher testing purpose)
|
||||
$couponConsumeEvent = new CouponConsumeEvent($couponCode);
|
||||
$eventToDispatch = TheliaEvents::COUPON_CONSUME;
|
||||
|
||||
// Dispatch Event to the Action
|
||||
$this->dispatch(
|
||||
$eventToDispatch,
|
||||
$couponConsumeEvent
|
||||
);
|
||||
|
||||
var_dump('test', $couponConsumeEvent->getCode(), $couponConsumeEvent->getDiscount(), $couponConsumeEvent->getIsValid());
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Coupon from its form
|
||||
*
|
||||
@@ -492,14 +471,14 @@ var_dump($coupon->getIsRemovingPostage());;
|
||||
sprintf(
|
||||
'Coupon %s (ID ) ' . $log,
|
||||
$couponEvent->getTitle(),
|
||||
$couponEvent->getCoupon()->getId()
|
||||
$couponEvent->getCouponModel()->getId()
|
||||
)
|
||||
);
|
||||
|
||||
$this->redirect(
|
||||
str_replace(
|
||||
'{id}',
|
||||
$couponEvent->getCoupon()->getId(),
|
||||
$couponEvent->getCouponModel()->getId(),
|
||||
$creationForm->getSuccessUrl()
|
||||
)
|
||||
);
|
||||
@@ -591,26 +570,4 @@ var_dump($coupon->getIsRemovingPostage());;
|
||||
return $cleanedConditions;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Validation Condition creation
|
||||
// *
|
||||
// * @param string $type Condition class type
|
||||
// * @param string $operator Condition operator (<, >, =, etc)
|
||||
// * @param array $values Condition values
|
||||
// *
|
||||
// * @return bool
|
||||
// */
|
||||
// protected function validateConditionsCreation($type, $operator, $values)
|
||||
// {
|
||||
// /** @var AdapterInterface $adapter */
|
||||
// $adapter = $this->container->get('thelia.adapter');
|
||||
// $validator = new PriceParam()
|
||||
// try {
|
||||
// $condition = new AvailableForTotalAmount($adapter, $validators);
|
||||
// $condition = new $type($adapter, $validators);
|
||||
// } catch (\Exception $e) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -48,10 +48,7 @@ class FolderController extends AbstractCrudController
|
||||
'manual',
|
||||
'folder_order',
|
||||
|
||||
AdminResources::FOLDER_VIEW,
|
||||
AdminResources::FOLDER_CREATE,
|
||||
AdminResources::FOLDER_UPDATE,
|
||||
AdminResources::FOLDER_DELETE,
|
||||
AdminResources::FOLDER,
|
||||
|
||||
TheliaEvents::FOLDER_CREATE,
|
||||
TheliaEvents::FOLDER_UPDATE,
|
||||
|
||||
329
core/lib/Thelia/Controller/Admin/LangController.php
Normal file
329
core/lib/Thelia/Controller/Admin/LangController.php
Normal file
@@ -0,0 +1,329 @@
|
||||
<?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 Symfony\Component\Form\Form;
|
||||
use Thelia\Core\Event\Lang\LangCreateEvent;
|
||||
use Thelia\Core\Event\Lang\LangDefaultBehaviorEvent;
|
||||
use Thelia\Core\Event\Lang\LangDeleteEvent;
|
||||
use Thelia\Core\Event\Lang\LangToggleDefaultEvent;
|
||||
use Thelia\Core\Event\Lang\LangUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Form\Lang\LangCreateForm;
|
||||
use Thelia\Form\Lang\LangDefaultBehaviorForm;
|
||||
use Thelia\Form\Lang\LangUpdateForm;
|
||||
use Thelia\Form\Lang\LangUrlEvent;
|
||||
use Thelia\Form\Lang\LangUrlForm;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\LangQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangController extends BaseAdminController
|
||||
{
|
||||
|
||||
public function defaultAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::VIEW)) return $response;
|
||||
|
||||
return $this->renderDefault();
|
||||
}
|
||||
|
||||
public function renderDefault(array $param = array())
|
||||
{
|
||||
$data = array();
|
||||
foreach (LangQuery::create()->find() as $lang) {
|
||||
$data[LangUrlForm::LANG_PREFIX.$lang->getId()] = $lang->getUrl();
|
||||
}
|
||||
$langUrlForm = new LangUrlForm($this->getRequest(), 'form', $data);
|
||||
$this->getParserContext()->addForm($langUrlForm);
|
||||
|
||||
return $this->render('languages', array_merge($param, array(
|
||||
'lang_without_translation' => ConfigQuery::getDefaultLangWhenNoTranslationAvailable(),
|
||||
'one_domain_per_lang' => ConfigQuery::read("one_domain_foreach_lang", false)
|
||||
)));
|
||||
}
|
||||
|
||||
public function updateAction($lang_id)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
$lang = LangQuery::create()->findPk($lang_id);
|
||||
|
||||
$langForm = new LangUpdateForm($this->getRequest(), 'form', array(
|
||||
'id' => $lang->getId(),
|
||||
'title' => $lang->getTitle(),
|
||||
'code' => $lang->getCode(),
|
||||
'locale' => $lang->getLocale(),
|
||||
'date_format' => $lang->getDateFormat(),
|
||||
'time_format' => $lang->getTimeFormat()
|
||||
));
|
||||
|
||||
$this->getParserContext()->addForm($langForm);
|
||||
|
||||
return $this->render('ajax/language-update-modal', array(
|
||||
'lang_id' => $lang_id
|
||||
));
|
||||
}
|
||||
|
||||
public function processUpdateAction($lang_id)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
$langForm = new LangUpdateForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($langForm);
|
||||
|
||||
$event = new LangUpdateEvent($form->get('id')->getData());
|
||||
$event = $this->hydrateEvent($event, $form);
|
||||
|
||||
$this->dispatch(TheliaEvents::LANG_UPDATE, $event);
|
||||
|
||||
if (false === $event->hasLang()) {
|
||||
throw new \LogicException(
|
||||
$this->getTranslator()->trans("No %obj was updated.", array('%obj', 'Lang')));
|
||||
}
|
||||
|
||||
$changedObject = $event->getLang();
|
||||
$this->adminLogAppend(sprintf("%s %s (ID %s) modified", 'Lang', $changedObject->getTitle(), $changedObject->getId()));
|
||||
$this->redirectToRoute('/admin/configuration/languages');
|
||||
} catch(\Exception $e) {
|
||||
$error_msg = $e->getMessage();
|
||||
}
|
||||
|
||||
return $this->renderDefault();
|
||||
}
|
||||
|
||||
protected function hydrateEvent($event,Form $form)
|
||||
{
|
||||
return $event
|
||||
->setTitle($form->get('title')->getData())
|
||||
->setCode($form->get('code')->getData())
|
||||
->setLocale($form->get('locale')->getData())
|
||||
->setDateFormat($form->get('date_format')->getData())
|
||||
->setTimeFormat($form->get('time_format')->getData())
|
||||
;
|
||||
}
|
||||
|
||||
public function toggleDefaultAction($lang_id)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$this->checkXmlHttpRequest();
|
||||
$error = false;
|
||||
try {
|
||||
$event = new LangToggleDefaultEvent($lang_id);
|
||||
|
||||
$this->dispatch(TheliaEvents::LANG_TOGGLEDEFAULT, $event);
|
||||
|
||||
if (false === $event->hasLang()) {
|
||||
throw new \LogicException(
|
||||
$this->getTranslator()->trans("No %obj was updated.", array('%obj', 'Lang')));
|
||||
}
|
||||
|
||||
$changedObject = $event->getLang();
|
||||
$this->adminLogAppend(sprintf("%s %s (ID %s) modified", 'Lang', $changedObject->getTitle(), $changedObject->getId()));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf("Error on changing default languages with message : %s", $e->getMessage()));
|
||||
$error = $e->getMessage();
|
||||
}
|
||||
|
||||
if($error) {
|
||||
return $this->nullResponse(500);
|
||||
} else {
|
||||
return $this->nullResponse();
|
||||
}
|
||||
}
|
||||
|
||||
public function addAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::CREATE)) return $response;
|
||||
|
||||
$createForm = new LangCreateForm($this->getRequest());
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($createForm);
|
||||
|
||||
$createEvent = new LangCreateEvent();
|
||||
$createEvent = $this->hydrateEvent($createEvent, $form);
|
||||
|
||||
$this->dispatch(TheliaEvents::LANG_CREATE, $createEvent);
|
||||
|
||||
if (false === $createEvent->hasLang()) {
|
||||
throw new \LogicException(
|
||||
$this->getTranslator()->trans("No %obj was updated.", array('%obj', 'Lang')));
|
||||
}
|
||||
|
||||
$createdObject = $createEvent->getLang();
|
||||
$this->adminLogAppend(sprintf("%s %s (ID %s) created", 'Lang', $createdObject->getTitle(), $createdObject->getId()));
|
||||
|
||||
$this->redirectToRoute('admin.configuration.languages');
|
||||
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext(
|
||||
$this->getTranslator()->trans("%obj creation", array('%obj' => 'Lang')), $error_msg, $createForm, $ex);
|
||||
|
||||
// At this point, the form has error, and should be redisplayed.
|
||||
return $this->renderDefault();
|
||||
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::DELETE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
try {
|
||||
|
||||
$deleteEvent = new LangDeleteEvent($this->getRequest()->get('language_id', 0));
|
||||
|
||||
$this->dispatch(TheliaEvents::LANG_DELETE, $deleteEvent);
|
||||
|
||||
$this->redirectToRoute('admin.configuration.languages');
|
||||
} catch (\Exception $ex) {
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf("error during language removal with message : %s", $ex->getMessage()));
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
return $this->renderDefault(array(
|
||||
'error_delete_message' => $error_msg
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function defaultBehaviorAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
$behaviorForm = new LangDefaultBehaviorForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($behaviorForm);
|
||||
|
||||
$event = new LangDefaultBehaviorEvent($form->get('behavior')->getData());
|
||||
|
||||
$this->dispatch(TheliaEvents::LANG_DEFAULTBEHAVIOR, $event);
|
||||
|
||||
$this->redirectToRoute('admin.configuration.languages');
|
||||
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext(
|
||||
$this->getTranslator()->trans("%obj creation", array('%obj' => 'Lang')), $error_msg, $behaviorForm, $ex);
|
||||
|
||||
// At this point, the form has error, and should be redisplayed.
|
||||
return $this->renderDefault();
|
||||
}
|
||||
|
||||
public function domainAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
$langUrlForm = new LangUrlForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($langUrlForm);
|
||||
|
||||
$data = $form->getData();
|
||||
$event = new LangUrlEvent();
|
||||
foreach ($data as $key => $value) {
|
||||
$pos= strpos($key, LangUrlForm::LANG_PREFIX);
|
||||
if(false !== strpos($key, LangUrlForm::LANG_PREFIX)) {
|
||||
$event->addUrl(substr($key,strlen(LangUrlForm::LANG_PREFIX)), $value);
|
||||
}
|
||||
}
|
||||
|
||||
$this->dispatch(TheliaEvents::LANG_URL, $event);
|
||||
|
||||
$this->redirectToRoute('admin.configuration.languages');
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext(
|
||||
$this->getTranslator()->trans("%obj creation", array('%obj' => 'Lang')), $error_msg, $langUrlForm, $ex);
|
||||
|
||||
// At this point, the form has error, and should be redisplayed.
|
||||
return $this->renderDefault();
|
||||
}
|
||||
|
||||
public function activateDomainAction()
|
||||
{
|
||||
$this->domainActivation(1);
|
||||
}
|
||||
|
||||
public function deactivateDomainAction()
|
||||
{
|
||||
$this->domainActivation(0);
|
||||
}
|
||||
|
||||
private function domainActivation($activate)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
ConfigQuery::create()
|
||||
->filterByName('one_domain_foreach_lang')
|
||||
->update(array('Value' => $activate));
|
||||
|
||||
$this->redirectToRoute('admin.configuration.languages');
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,23 @@ use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Core\Event\Product\ProductAddAccessoryEvent;
|
||||
use Thelia\Core\Event\Product\ProductDeleteAccessoryEvent;
|
||||
use Thelia\Model\ProductSaleElementsQuery;
|
||||
use Thelia\Core\Event\ProductSaleElement\ProductSaleElementDeleteEvent;
|
||||
use Thelia\Core\Event\ProductSaleElement\ProductSaleElementUpdateEvent;
|
||||
use Thelia\Core\Event\ProductSaleElement\ProductSaleElementCreateEvent;
|
||||
use Thelia\Model\AttributeQuery;
|
||||
use Thelia\Model\AttributeAvQuery;
|
||||
use Thelia\Form\ProductSaleElementUpdateForm;
|
||||
use Thelia\Model\ProductSaleElements;
|
||||
use Thelia\Model\ProductPriceQuery;
|
||||
use Thelia\Form\ProductDefaultSaleElementUpdateForm;
|
||||
use Thelia\Model\ProductPrice;
|
||||
use Thelia\Model\Currency;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Thelia\TaxEngine\Calculator;
|
||||
use Thelia\Model\Country;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
use Thelia\Tools\NumberFormat;
|
||||
|
||||
/**
|
||||
* Manages products
|
||||
@@ -172,10 +189,58 @@ class ProductController extends AbstractCrudController
|
||||
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
// Get the default produc sales element
|
||||
$salesElement = ProductSaleElementsQuery::create()->filterByProduct($object)->filterByIsDefault(true)->findOne();
|
||||
$defaultPseData = $combinationPseData = array();
|
||||
|
||||
// $prices = $salesElement->getProductPrices();
|
||||
// Find product's sale elements
|
||||
$saleElements = ProductSaleElementsQuery::create()
|
||||
->filterByProduct($object)
|
||||
->find();
|
||||
|
||||
foreach($saleElements as $saleElement) {
|
||||
|
||||
// Get the product price for the current currency
|
||||
|
||||
$productPrice = ProductPriceQuery::create()
|
||||
->filterByCurrency($this->getCurrentEditionCurrency())
|
||||
->filterByProductSaleElements($saleElement)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
if ($productPrice == null) $productPrice = new ProductPrice();
|
||||
|
||||
$isDefaultPse = count($saleElement->getAttributeCombinations()) == 0;
|
||||
|
||||
// If this PSE has no combination -> this is the default one
|
||||
// affect it to the thelia.admin.product_sale_element.update form
|
||||
if ($isDefaultPse) {
|
||||
|
||||
$defaultPseData = array(
|
||||
"product_id" => $object->getId(),
|
||||
"product_sale_element_id" => $saleElement->getId(),
|
||||
"reference" => $saleElement->getRef(),
|
||||
"price" => $productPrice->getPrice(),
|
||||
"use_exchange_rate" => $productPrice->getFromDefaultCurrency() ? 1 : 0,
|
||||
"tax_rule" => $object->getTaxRuleId(),
|
||||
"currency" => $productPrice->getCurrencyId(),
|
||||
"weight" => $saleElement->getWeight(),
|
||||
"quantity" => $saleElement->getQuantity(),
|
||||
"sale_price" => $productPrice->getPromoPrice(),
|
||||
"onsale" => $saleElement->getPromo() > 0 ? 1 : 0,
|
||||
"isnew" => $saleElement->getNewness() > 0 ? 1 : 0,
|
||||
"isdefault" => $saleElement->getIsDefault() > 0 ? 1 : 0,
|
||||
"ean_code" => $saleElement->getEanCode()
|
||||
);
|
||||
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
$defaultPseForm = new ProductDefaultSaleElementUpdateForm($this->getRequest(), "form", $defaultPseData);
|
||||
$this->getParserContext()->addForm($defaultPseForm);
|
||||
|
||||
$combinationPseForm = new ProductSaleElementUpdateForm($this->getRequest(), "form", $combinationPseData);
|
||||
$this->getParserContext()->addForm($combinationPseForm);
|
||||
}
|
||||
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
@@ -226,7 +291,7 @@ class ProductController extends AbstractCrudController
|
||||
'product_id' => $this->getRequest()->get('product_id', 0),
|
||||
'folder_id' => $this->getRequest()->get('folder_id', 0),
|
||||
'accessory_category_id' => $this->getRequest()->get('accessory_category_id', 0),
|
||||
'current_tab' => $this->getRequest()->get('current_tab', 'general')
|
||||
'current_tab' => $this->getRequest()->get('current_tab', 'general')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -730,20 +795,21 @@ class ProductController extends AbstractCrudController
|
||||
/**
|
||||
* A a new combination to a product
|
||||
*/
|
||||
public function addCombinationAction()
|
||||
public function addProductSaleElementAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$event = new ProductCreateCombinationEvent(
|
||||
$event = new ProductSaleElementCreateEvent(
|
||||
$this->getExistingObject(),
|
||||
$this->getRequest()->get('combination_attributes', array()),
|
||||
$this->getCurrentEditionCurrency()->getId()
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_ADD_COMBINATION, $event);
|
||||
} catch (\Exception $ex) {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_ADD_PRODUCT_SALE_ELEMENT, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
@@ -751,23 +817,23 @@ class ProductController extends AbstractCrudController
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A a new combination to a product
|
||||
*/
|
||||
public function deleteCombinationAction()
|
||||
public function deleteProductSaleElementAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$event = new ProductDeleteCombinationEvent(
|
||||
$this->getExistingObject(),
|
||||
$this->getRequest()->get('product_sale_element_id',0)
|
||||
$event = new ProductSaleElementDeleteEvent(
|
||||
$this->getRequest()->get('product_sale_element_id',0),
|
||||
$this->getCurrentEditionCurrency()->getId()
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_DELETE_COMBINATION, $event);
|
||||
} catch (\Exception $ex) {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_DELETE_PRODUCT_SALE_ELEMENT, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
@@ -775,4 +841,124 @@ class ProductController extends AbstractCrudController
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a product sale element
|
||||
*/
|
||||
protected function processProductSaleElementUpdate($changeForm) {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
try {
|
||||
|
||||
// Check the form against constraints violations
|
||||
$form = $this->validateForm($changeForm, "POST");
|
||||
|
||||
// Get the form field values
|
||||
$data = $form->getData();
|
||||
|
||||
$event = new ProductSaleElementUpdateEvent(
|
||||
$this->getExistingObject(),
|
||||
$data['product_sale_element_id']
|
||||
);
|
||||
|
||||
$event
|
||||
->setReference($data['reference'])
|
||||
->setPrice($data['price'])
|
||||
->setCurrencyId($data['currency'])
|
||||
->setWeight($data['weight'])
|
||||
->setQuantity($data['quantity'])
|
||||
->setSalePrice($data['sale_price'])
|
||||
->setOnsale($data['onsale'])
|
||||
->setIsnew($data['isnew'])
|
||||
->setIsdefault($data['isdefault'])
|
||||
->setEanCode($data['ean_code'])
|
||||
->setTaxrule($data['tax_rule'])
|
||||
;
|
||||
|
||||
$this->dispatch(TheliaEvents::PRODUCT_UPDATE_PRODUCT_SALE_ELEMENT, $event);
|
||||
|
||||
// Log object modification
|
||||
if (null !== $changedObject = $event->getProductSaleElement()) {
|
||||
$this->adminLogAppend(sprintf("Product Sale Element (ID %s) for product reference %s modified", $changedObject->getId(), $event->getProduct()->getRef()));
|
||||
}
|
||||
|
||||
// If we have to stay on the same page, do not redirect to the succesUrl, just redirect to the edit page again.
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
$this->redirectToEditionTemplate($this->getRequest());
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($changeForm->getSuccessUrl());
|
||||
}
|
||||
catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext(
|
||||
$this->getTranslator()->trans("ProductSaleElement modification"), $error_msg, $changeForm, $ex);
|
||||
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->renderEditionTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a product sale element attached to a combination
|
||||
*/
|
||||
public function updateProductSaleElementAction() {
|
||||
return $this->processProductSaleElementUpdate(
|
||||
new ProductSaleElementUpdateForm($this->getRequest())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update default product sale element (not attached to any combination)
|
||||
*/
|
||||
public function updateProductDefaultSaleElementAction() {
|
||||
|
||||
return $this->processProductSaleElementUpdate(
|
||||
new ProductDefaultSaleElementUpdateForm($this->getRequest())
|
||||
);
|
||||
}
|
||||
|
||||
public function priceCaclulator() {
|
||||
|
||||
$price = floatval($this->getRequest()->get('price', 0));
|
||||
$tax_rule = intval($this->getRequest()->get('tax_rule_id', 0)); // The tax rule ID
|
||||
$action = $this->getRequest()->get('action', ''); // With ot without tax
|
||||
$convert = intval($this->getRequest()->get('convert_from_default_currency', 0));
|
||||
|
||||
$calc = new Calculator();
|
||||
|
||||
$calc->loadTaxRule(
|
||||
TaxRuleQuery::create()->findPk($tax_rule),
|
||||
Country::getShopLocation()
|
||||
);
|
||||
|
||||
if ($action == 'to_tax') {
|
||||
$return_price = $calc->getTaxedPrice($price);
|
||||
}
|
||||
else if ($action == 'from_tax') {
|
||||
$return_price = $calc->getUntaxedPrice($price);
|
||||
}
|
||||
else {
|
||||
$return_price = $price;
|
||||
}
|
||||
|
||||
if ($convert != 0) {
|
||||
$return_price = $prix * Currency::getDefaultCurrency()->getRate();
|
||||
}
|
||||
|
||||
// Format the number using '.', to perform further calculation
|
||||
$return_price = NumberFormat::getInstance($this->getRequest())->format($return_price, null, '.');
|
||||
|
||||
return new JsonResponse(array('result' => $return_price));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,15 @@
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Security\Resource\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\Form\ProfileUpdateModuleAccessForm;
|
||||
use Thelia\Form\ProfileUpdateResourceAccessForm;
|
||||
use Thelia\Model\ProfileQuery;
|
||||
|
||||
class ProfileController extends AbstractCrudController
|
||||
@@ -116,6 +119,26 @@ class ProfileController extends AbstractCrudController
|
||||
return new ProfileModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function hydrateResourceUpdateForm($object)
|
||||
{
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new ProfileUpdateResourceAccessForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function hydrateModuleUpdateForm($object)
|
||||
{
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new ProfileUpdateModuleAccessForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasProfile() ? $event->getProfile() : null;
|
||||
@@ -197,14 +220,47 @@ class ProfileController extends AbstractCrudController
|
||||
);
|
||||
}
|
||||
|
||||
protected function checkRequirements($formData)
|
||||
public function updateAction()
|
||||
{
|
||||
$type = $formData['type'];
|
||||
if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$object = $this->getExistingObject();
|
||||
|
||||
if ($object != null) {
|
||||
|
||||
// Hydrate the form and pass it to the parser
|
||||
$resourceAccessForm = $this->hydrateResourceUpdateForm($object);
|
||||
$moduleAccessForm = $this->hydrateModuleUpdateForm($object);
|
||||
|
||||
// Pass it to the parser
|
||||
$this->getParserContext()->addForm($resourceAccessForm);
|
||||
$this->getParserContext()->addForm($moduleAccessForm);
|
||||
}
|
||||
|
||||
return parent::updateAction();
|
||||
}
|
||||
|
||||
protected function getRequirements($type, $formData)
|
||||
protected function getUpdateResourceAccessEvent($formData)
|
||||
{
|
||||
$event = new ProfileEvent();
|
||||
|
||||
$event->setId($formData['id']);
|
||||
$event->setResourceAccess($this->getResourceAccess($formData));
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
protected function getUpdateModuleAccessEvent($formData)
|
||||
{
|
||||
$event = new ProfileEvent();
|
||||
|
||||
$event->setId($formData['id']);
|
||||
$event->setModuleAccess($this->getModuleAccess($formData));
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
protected function getResourceAccess($formData)
|
||||
{
|
||||
$requirements = array();
|
||||
foreach($formData as $data => $value) {
|
||||
@@ -212,15 +268,137 @@ class ProfileController extends AbstractCrudController
|
||||
continue;
|
||||
}
|
||||
|
||||
$couple = explode(':', $data);
|
||||
$explosion = explode(':', $data);
|
||||
|
||||
if(count($couple) != 2 || $couple[0] != $type) {
|
||||
$prefix = array_shift ( $explosion );
|
||||
|
||||
if($prefix != ProfileUpdateResourceAccessForm::RESOURCE_ACCESS_FIELD_PREFIX) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$requirements[$couple[1]] = $value;
|
||||
$requirements[implode('.', $explosion)] = $value;
|
||||
}
|
||||
|
||||
return $requirements;
|
||||
}
|
||||
|
||||
protected function getModuleAccess($formData)
|
||||
{
|
||||
$requirements = array();
|
||||
foreach($formData as $data => $value) {
|
||||
if(!strstr($data, ':')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$explosion = explode(':', $data);
|
||||
|
||||
$prefix = array_shift ( $explosion );
|
||||
|
||||
if($prefix != ProfileUpdateModuleAccessForm::MODULE_ACCESS_FIELD_PREFIX) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$requirements[implode('.', $explosion)] = $value;
|
||||
}
|
||||
|
||||
return $requirements;
|
||||
}
|
||||
|
||||
public function processUpdateResourceAccess()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
// Create the form from the request
|
||||
$changeForm = new ProfileUpdateResourceAccessForm($this->getRequest());
|
||||
|
||||
try {
|
||||
// Check the form against constraints violations
|
||||
$form = $this->validateForm($changeForm, "POST");
|
||||
|
||||
// Get the form field values
|
||||
$data = $form->getData();
|
||||
|
||||
$changeEvent = $this->getUpdateResourceAccessEvent($data);
|
||||
|
||||
$this->dispatch(TheliaEvents::PROFILE_RESOURCE_ACCESS_UPDATE, $changeEvent);
|
||||
|
||||
if (! $this->eventContainsObject($changeEvent))
|
||||
throw new \LogicException(
|
||||
$this->getTranslator()->trans("No %obj was updated.", array('%obj', $this->objectName)));
|
||||
|
||||
// Log object modification
|
||||
if (null !== $changedObject = $this->getObjectFromEvent($changeEvent)) {
|
||||
$this->adminLogAppend(sprintf("%s %s (ID %s) modified", ucfirst($this->objectName), $this->getObjectLabel($changedObject), $this->getObjectId($changedObject)));
|
||||
}
|
||||
|
||||
if ($response == null) {
|
||||
$this->redirectToEditionTemplate($this->getRequest(), isset($data['country_list'][0]) ? $data['country_list'][0] : null);
|
||||
} else {
|
||||
return $response;
|
||||
}
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext($this->getTranslator()->trans("%obj modification", array('%obj' => 'taxrule')), $error_msg, $changeForm, $ex);
|
||||
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->renderEditionTemplate();
|
||||
}
|
||||
|
||||
public function processUpdateModuleAccess()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
// Create the form from the request
|
||||
$changeForm = new ProfileUpdateModuleAccessForm($this->getRequest());
|
||||
|
||||
try {
|
||||
// Check the form against constraints violations
|
||||
$form = $this->validateForm($changeForm, "POST");
|
||||
|
||||
// Get the form field values
|
||||
$data = $form->getData();
|
||||
|
||||
$changeEvent = $this->getUpdateModuleAccessEvent($data);
|
||||
|
||||
$this->dispatch(TheliaEvents::PROFILE_MODULE_ACCESS_UPDATE, $changeEvent);
|
||||
|
||||
if (! $this->eventContainsObject($changeEvent))
|
||||
throw new \LogicException(
|
||||
$this->getTranslator()->trans("No %obj was updated.", array('%obj', $this->objectName)));
|
||||
|
||||
// Log object modification
|
||||
if (null !== $changedObject = $this->getObjectFromEvent($changeEvent)) {
|
||||
$this->adminLogAppend(sprintf("%s %s (ID %s) modified", ucfirst($this->objectName), $this->getObjectLabel($changedObject), $this->getObjectId($changedObject)));
|
||||
}
|
||||
|
||||
if ($response == null) {
|
||||
$this->redirectToEditionTemplate($this->getRequest(), isset($data['country_list'][0]) ? $data['country_list'][0] : null);
|
||||
} else {
|
||||
return $response;
|
||||
}
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext($this->getTranslator()->trans("%obj modification", array('%obj' => 'taxrule')), $error_msg, $changeForm, $ex);
|
||||
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->renderEditionTemplate();
|
||||
}
|
||||
}
|
||||
93
core/lib/Thelia/Controller/Admin/TestController.php
Normal file
93
core/lib/Thelia/Controller/Admin/TestController.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?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\Form\TestForm;
|
||||
/**
|
||||
* Manages variables
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class TestController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* Load a object for modification, and display the edit template.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
public function updateAction()
|
||||
{
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'title' => "test title",
|
||||
'test' => array('a', 'b', 'toto' => 'c')
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
$changeForm = new TestForm($this->getRequest(), "form", $data);
|
||||
|
||||
// Pass it to the parser
|
||||
$this->getParserContext()->addForm($changeForm);
|
||||
|
||||
return $this->render('test-form');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save changes on a modified object, and either go back to the object list, or stay on the edition page.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
public function processUpdateAction()
|
||||
{
|
||||
$error_msg = false;
|
||||
|
||||
// Create the form from the request
|
||||
$changeForm = new TestForm($this->getRequest());
|
||||
|
||||
try {
|
||||
|
||||
// Check the form against constraints violations
|
||||
$form = $this->validateForm($changeForm, "POST");
|
||||
|
||||
// Get the form field values
|
||||
$data = $form->getData();
|
||||
|
||||
echo "data=";
|
||||
|
||||
var_dump($data);
|
||||
}
|
||||
catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
echo "Error = $error_msg";
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,10 @@ class BaseController extends ContainerAware
|
||||
|
||||
/**
|
||||
* Return an empty response (after an ajax request, for example)
|
||||
* @param int $status
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected function nullResponse($content = null, $status = 200)
|
||||
protected function nullResponse($status = 200)
|
||||
{
|
||||
return new Response(null, $status);
|
||||
}
|
||||
@@ -160,8 +162,12 @@ class BaseController extends ContainerAware
|
||||
}
|
||||
|
||||
foreach ($form->all() as $child) {
|
||||
|
||||
if (!$child->isValid()) {
|
||||
$errors .= $this->getErrorMessages($child) . ', ';
|
||||
|
||||
$fieldName = $child->getConfig()->getOption('label', $child->getName());
|
||||
|
||||
$errors .= sprintf("[%s] %s, ", $fieldName, $this->getErrorMessages($child));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,13 +196,15 @@ class BaseController extends ContainerAware
|
||||
$errorMessage = null;
|
||||
if ($form->get("error_message")->getData() != null) {
|
||||
$errorMessage = $form->get("error_message")->getData();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$errorMessage = sprintf("Missing or invalid data: %s", $this->getErrorMessages($form));
|
||||
}
|
||||
|
||||
throw new FormValidationException($errorMessage);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
throw new FormValidationException(sprintf("Wrong form method, %s expected.", $expectedMethod));
|
||||
}
|
||||
}
|
||||
@@ -221,7 +229,8 @@ class BaseController extends ContainerAware
|
||||
{
|
||||
if ($form != null) {
|
||||
$url = $form->getSuccessUrl();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$url = $this->getRequest()->get("success_url");
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class CartController extends BaseFrontController
|
||||
$cartEvent->setQuantity($this->getRequest()->get("quantity"));
|
||||
|
||||
try {
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_UPDATEITEM, $cartEvent);
|
||||
$this->dispatch(TheliaEvents::CART_UPDATEITEM, $cartEvent);
|
||||
|
||||
$this->redirectSuccess();
|
||||
} catch (PropelException $e) {
|
||||
|
||||
95
core/lib/Thelia/Controller/Front/CouponController.php
Executable file
95
core/lib/Thelia/Controller/Front/CouponController.php
Executable file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Controller\Front;
|
||||
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Core\Event\Coupon\CouponConsumeEvent;
|
||||
use Thelia\Exception\TheliaProcessException;
|
||||
use Thelia\Form\CouponCode;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Core\Event\Order\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Form\OrderDelivery;
|
||||
use Thelia\Form\OrderPayment;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\AreaDeliveryModuleQuery;
|
||||
use Thelia\Model\Base\OrderQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Model\Order;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class CouponController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*/
|
||||
class CouponController extends BaseFrontController
|
||||
{
|
||||
|
||||
/**
|
||||
* Test Coupon consuming
|
||||
*/
|
||||
public function consumeAction()
|
||||
{
|
||||
$this->checkAuth();
|
||||
$this->checkCartNotEmpty();
|
||||
|
||||
$message = false;
|
||||
$couponCodeForm = new CouponCode($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($couponCodeForm, 'post');
|
||||
|
||||
$couponCode = $form->get('coupon-code')->getData();
|
||||
|
||||
if (null === $couponCode || empty($couponCode)) {
|
||||
$message = true;
|
||||
throw new \Exception('Coupon code can\'t be empty');
|
||||
}
|
||||
|
||||
$couponConsumeEvent = new CouponConsumeEvent($couponCode);
|
||||
|
||||
// Dispatch Event to the Action
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::COUPON_CONSUME, $couponConsumeEvent);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf('Please check your coupon code: %s', $e->getMessage());
|
||||
} catch (PropelException $e) {
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf('Sorry, an error occurred: %s', $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
|
||||
$couponCodeForm->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($couponCodeForm)
|
||||
->setGeneralError($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ use Thelia\Core\DependencyInjection\Compiler\RegisterCouponPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterListenersPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterParserPluginPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterRouterPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterRulePass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterCouponConditionPass;
|
||||
|
||||
/**
|
||||
* First Bundle use in Thelia
|
||||
@@ -63,8 +63,6 @@ class TheliaBundle extends Bundle
|
||||
->addCompilerPass(new RegisterParserPluginPass())
|
||||
->addCompilerPass(new RegisterRouterPass())
|
||||
->addCompilerPass(new RegisterCouponPass())
|
||||
->addCompilerPass(new RegisterRulePass())
|
||||
;
|
||||
|
||||
->addCompilerPass(new RegisterCouponConditionPass());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,13 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
* Class RegisterListenersPass
|
||||
* Source code come from Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RegisterKernelListenersPass class
|
||||
*
|
||||
* Register all available Conditions for the coupon module
|
||||
*
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class RegisterRulePass implements CompilerPassInterface
|
||||
class RegisterCouponConditionPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* You can modify the container here before it is dumped to PHP code.
|
||||
@@ -55,11 +57,11 @@ class RegisterRulePass implements CompilerPassInterface
|
||||
}
|
||||
|
||||
$couponManager = $container->getDefinition('thelia.coupon.manager');
|
||||
$services = $container->findTaggedServiceIds("thelia.coupon.addRule");
|
||||
$services = $container->findTaggedServiceIds("thelia.coupon.addCondition");
|
||||
|
||||
foreach ($services as $id => $rule) {
|
||||
foreach ($services as $id => $condition) {
|
||||
$couponManager->addMethodCall(
|
||||
'addAvailableRule',
|
||||
'addAvailableCondition',
|
||||
array(
|
||||
new Reference($id)
|
||||
)
|
||||
120
core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.php
Normal file
120
core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.php
Normal 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\Administrator;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Admin;
|
||||
|
||||
class AdministratorEvent extends ActionEvent
|
||||
{
|
||||
protected $administrator = null;
|
||||
protected $id = null;
|
||||
protected $firstname = null;
|
||||
protected $lastname = null;
|
||||
protected $login = null;
|
||||
protected $password = null;
|
||||
protected $profile = null;
|
||||
|
||||
public function __construct(Admin $administrator = null)
|
||||
{
|
||||
$this->administrator = $administrator;
|
||||
}
|
||||
|
||||
public function hasAdministrator()
|
||||
{
|
||||
return ! is_null($this->administrator);
|
||||
}
|
||||
|
||||
public function getAdministrator()
|
||||
{
|
||||
return $this->administrator;
|
||||
}
|
||||
|
||||
public function setAdministrator(Admin $administrator)
|
||||
{
|
||||
$this->administrator = $administrator;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setFirstname($firstname)
|
||||
{
|
||||
$this->firstname = $firstname;
|
||||
}
|
||||
|
||||
public function getFirstname()
|
||||
{
|
||||
return $this->firstname;
|
||||
}
|
||||
|
||||
public function setLastname($lastname)
|
||||
{
|
||||
$this->lastname = $lastname;
|
||||
}
|
||||
|
||||
public function getLastname()
|
||||
{
|
||||
return $this->lastname;
|
||||
}
|
||||
|
||||
public function setLogin($login)
|
||||
{
|
||||
$this->login = $login;
|
||||
}
|
||||
|
||||
public function getLogin()
|
||||
{
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setProfile($profile)
|
||||
{
|
||||
$this->profile = $profile;
|
||||
}
|
||||
|
||||
public function getProfile()
|
||||
{
|
||||
return $this->profile;
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
/**********************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/**********************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Condition;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Coupon\ConditionCollection;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 8/29/13
|
||||
* Time: 3:45 PM
|
||||
*
|
||||
* Occurring when a Condition is created or updated
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class ConditionCreateOrUpdateEvent extends ActionEvent
|
||||
{
|
||||
/** @var ConditionCollection Array of ConditionManagerInterface */
|
||||
protected $conditions = null;
|
||||
|
||||
/** @var CouponInterface Coupon model associated with this conditions */
|
||||
protected $couponModel = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ConditionCollection $conditions Array of ConditionManagerInterface
|
||||
*/
|
||||
public function __construct(ConditionCollection $conditions)
|
||||
{
|
||||
$this->conditions = $conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Conditions
|
||||
*
|
||||
* @return null|ConditionCollection Array of ConditionManagerInterface
|
||||
*/
|
||||
public function getConditions()
|
||||
{
|
||||
return $this->conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Conditions
|
||||
*
|
||||
* @param ConditionCollection $conditions Array of ConditionManagerInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setConditions(ConditionCollection $conditions)
|
||||
{
|
||||
$this->conditions = $conditions;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Coupon Model associated to this condition
|
||||
*
|
||||
* @param CouponInterface $couponModel Coupon Model
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCouponModel($couponModel)
|
||||
{
|
||||
$this->couponModel = $couponModel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Coupon Model associated to this condition
|
||||
*
|
||||
* @return null|CouponInterface
|
||||
*/
|
||||
public function getCouponModel()
|
||||
{
|
||||
return $this->couponModel;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ use Thelia\Model\Coupon;
|
||||
* Date: 8/29/13
|
||||
* Time: 3:45 PM
|
||||
*
|
||||
* Occurring when a Coupon is created
|
||||
* Occurring when a Coupon is created or updated
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
@@ -76,10 +76,10 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
protected $isAvailableOnSpecialOffers = false;
|
||||
|
||||
/** @var Coupon Coupon model */
|
||||
protected $coupon = null;
|
||||
protected $couponModel = null;
|
||||
|
||||
/** @var string Coupon type */
|
||||
protected $type;
|
||||
/** @var string Coupon Service id */
|
||||
protected $serviceId;
|
||||
|
||||
/** @var string Language code ISO (ex: fr_FR) */
|
||||
protected $locale = null;
|
||||
@@ -90,7 +90,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
* @param string $code Coupon Code
|
||||
* @param string $title Coupon title
|
||||
* @param float $amount Amount removed from the Total Checkout
|
||||
* @param string $type Coupon type
|
||||
* @param string $serviceId Coupon Service id
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
* @param bool $isEnabled Enable/Disable
|
||||
@@ -102,7 +102,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
* @param string $locale Coupon Language code ISO (ex: fr_FR)
|
||||
*/
|
||||
public function __construct(
|
||||
$code, $title, $amount, $type, $shortDescription, $description, $isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $isRemovingPostage, $maxUsage, $locale
|
||||
$code, $title, $amount, $serviceId, $shortDescription, $description, $isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $isRemovingPostage, $maxUsage, $locale
|
||||
)
|
||||
{
|
||||
$this->amount = $amount;
|
||||
@@ -116,7 +116,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
$this->maxUsage = $maxUsage;
|
||||
$this->shortDescription = $shortDescription;
|
||||
$this->title = $title;
|
||||
$this->type = $type;
|
||||
$this->serviceId = $serviceId;
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
@@ -234,13 +234,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Coupon type (effect)
|
||||
* Get Coupon Service id (Type)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
public function getServiceId()
|
||||
{
|
||||
return $this->type;
|
||||
return $this->serviceId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,13 +256,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
/**
|
||||
* Set Coupon Model
|
||||
*
|
||||
* @param \Thelia\Model\Coupon $coupon Coupon Model
|
||||
* @param Coupon $couponModel Coupon Model
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCoupon($coupon)
|
||||
public function setCouponModel(Coupon $couponModel)
|
||||
{
|
||||
$this->coupon = $coupon;
|
||||
$this->couponModel = $couponModel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -272,13 +272,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
*
|
||||
* @return \Thelia\Model\Coupon
|
||||
*/
|
||||
public function getCoupon()
|
||||
public function getCouponModel()
|
||||
{
|
||||
return $this->coupon;
|
||||
return $this->couponModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rules
|
||||
* Get Conditions
|
||||
*
|
||||
* @return null|ConditionCollection Array of ConditionManagerInterface
|
||||
*/
|
||||
@@ -288,15 +288,15 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* set Rules
|
||||
* Set Conditions
|
||||
*
|
||||
* @param ConditionCollection $rules Array of ConditionManagerInterface
|
||||
* @param ConditionCollection $conditions Array of ConditionManagerInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setConditions(ConditionCollection $rules)
|
||||
public function setConditions(ConditionCollection $conditions)
|
||||
{
|
||||
$this->conditions = $rules;
|
||||
$this->conditions = $conditions;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
141
core/lib/Thelia/Core/Event/Lang/LangCreateEvent.php
Normal file
141
core/lib/Thelia/Core/Event/Lang/LangCreateEvent.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?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\Lang;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangCreateEvent
|
||||
* @package Thelia\Core\Event\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangCreateEvent extends LangEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $code;
|
||||
protected $locale;
|
||||
protected $date_format;
|
||||
protected $time_format;
|
||||
|
||||
/**
|
||||
* @param mixed $code
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCode($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $date_format
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDateFormat($date_format)
|
||||
{
|
||||
$this->date_format = $date_format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDateFormat()
|
||||
{
|
||||
return $this->date_format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $locale
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $time_format
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTimeFormat($time_format)
|
||||
{
|
||||
$this->time_format = $time_format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTimeFormat()
|
||||
{
|
||||
return $this->time_format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $title
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
64
core/lib/Thelia/Core/Event/Lang/LangDefaultBehaviorEvent.php
Normal file
64
core/lib/Thelia/Core/Event/Lang/LangDefaultBehaviorEvent.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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\Lang;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangDefaultBehaviorEvent
|
||||
* @package Thelia\Core\Event\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangDefaultBehaviorEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var int default behavior status
|
||||
*/
|
||||
protected $defaultBehavior;
|
||||
|
||||
function __construct($defaultBehavior)
|
||||
{
|
||||
$this->defaultBehavior = $defaultBehavior;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $defaultBehavior
|
||||
*/
|
||||
public function setDefaultBehavior($defaultBehavior)
|
||||
{
|
||||
$this->defaultBehavior = $defaultBehavior;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDefaultBehavior()
|
||||
{
|
||||
return $this->defaultBehavior;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
67
core/lib/Thelia/Core/Event/Lang/LangDeleteEvent.php
Normal file
67
core/lib/Thelia/Core/Event/Lang/LangDeleteEvent.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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\Lang;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangDeleteEvent
|
||||
* @package Thelia\Core\Event\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangDeleteEvent extends LangEvent
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $lang_id;
|
||||
|
||||
/**
|
||||
* @param int $lang_id
|
||||
*/
|
||||
function __construct($lang_id)
|
||||
{
|
||||
$this->lang_id = $lang_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $lang_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLangId($lang_id)
|
||||
{
|
||||
$this->lang_id = $lang_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLangId()
|
||||
{
|
||||
return $this->lang_id;
|
||||
}
|
||||
|
||||
}
|
||||
76
core/lib/Thelia/Core/Event/Lang/LangEvent.php
Normal file
76
core/lib/Thelia/Core/Event/Lang/LangEvent.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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\Lang;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Lang;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangEvent
|
||||
* @package Thelia\Core\Event\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Model\Lang
|
||||
*/
|
||||
protected $lang;
|
||||
|
||||
function __construct(Lang $lang = null)
|
||||
{
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Model\Lang $lang
|
||||
*/
|
||||
public function setLang(Lang $lang)
|
||||
{
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Lang
|
||||
*/
|
||||
public function getLang()
|
||||
{
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* check if lang object is present
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasLang()
|
||||
{
|
||||
return null !== $this->lang;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
69
core/lib/Thelia/Core/Event/Lang/LangToggleDefaultEvent.php
Normal file
69
core/lib/Thelia/Core/Event/Lang/LangToggleDefaultEvent.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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\Lang;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangToggleDefaultEvent
|
||||
* @package Thelia\Core\Event\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangToggleDefaultEvent extends LangEvent
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $lang_id;
|
||||
|
||||
/**
|
||||
* @param int $lang_id
|
||||
*/
|
||||
function __construct($lang_id)
|
||||
{
|
||||
$this->lang_id = $lang_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $lang_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLangId($lang_id)
|
||||
{
|
||||
$this->lang_id = $lang_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLangId()
|
||||
{
|
||||
return $this->lang_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
69
core/lib/Thelia/Core/Event/Lang/LangUpdateEvent.php
Normal file
69
core/lib/Thelia/Core/Event/Lang/LangUpdateEvent.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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\Lang;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangUpdateEvent
|
||||
* @package Thelia\Core\Event\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangUpdateEvent extends LangCreateEvent
|
||||
{
|
||||
/**
|
||||
* @var int lang id
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
function __construct($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -21,21 +21,24 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Product;
|
||||
namespace Thelia\Core\Event\ProductSaleElement;
|
||||
|
||||
use Thelia\Model\Product;
|
||||
use Thelia\Core\Event\Product\ProductEvent;
|
||||
|
||||
class ProductCreateCombinationEvent extends ProductEvent
|
||||
class ProductSaleElementCreateEvent extends ProductSaleElementEvent
|
||||
{
|
||||
protected $product;
|
||||
protected $attribute_av_list;
|
||||
protected $currency_id;
|
||||
|
||||
public function __construct(Product $product, $attribute_av_list, $currency_id)
|
||||
{
|
||||
parent::__construct($product);
|
||||
parent::__construct();
|
||||
|
||||
$this->attribute_av_list = $attribute_av_list;
|
||||
$this->currency_id = $currency_id;
|
||||
$this->setAttributeAvList($attribute_av_list);
|
||||
$this->setCurrencyId($currency_id);
|
||||
$this->setProduct($product);
|
||||
}
|
||||
|
||||
public function getAttributeAvList()
|
||||
@@ -62,4 +65,15 @@ class ProductCreateCombinationEvent extends ProductEvent
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProduct() {
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
public function setProduct($product) {
|
||||
$this->product = $product;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -21,19 +21,21 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Product;
|
||||
|
||||
namespace Thelia\Core\Event\ProductSaleElement;
|
||||
use Thelia\Model\Product;
|
||||
use Thelia\Core\Event\Product\ProductEvent;
|
||||
|
||||
class ProductDeleteCombinationEvent extends ProductEvent
|
||||
class ProductSaleElementDeleteEvent extends ProductSaleElementEvent
|
||||
{
|
||||
protected $product_sale_element_id;
|
||||
protected $currency_id;
|
||||
|
||||
public function __construct(Product $product, $product_sale_element_id)
|
||||
public function __construct($product_sale_element_id, $currency_id)
|
||||
{
|
||||
parent::__construct($product);
|
||||
parent::__construct();
|
||||
|
||||
$this->product_sale_element_id = $product_sale_element_id;
|
||||
$this->setCurrencyId($currency_id);
|
||||
}
|
||||
|
||||
public function getProductSaleElementId()
|
||||
@@ -44,5 +46,19 @@ class ProductDeleteCombinationEvent extends ProductEvent
|
||||
public function setProductSaleElementId($product_sale_element_id)
|
||||
{
|
||||
$this->product_sale_element_id = $product_sale_element_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCurrencyId()
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
public function setCurrencyId($currency_id)
|
||||
{
|
||||
$this->currency_id = $currency_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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\ProductSaleElement;
|
||||
|
||||
use Thelia\Model\ProductSaleElement;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class ProductSaleElementEvent extends ActionEvent
|
||||
{
|
||||
public $product_sale_element = null;
|
||||
|
||||
public function __construct(ProductSaleElement $product_sale_element = null)
|
||||
{
|
||||
$this->product_sale_element = $product_sale_element;
|
||||
}
|
||||
|
||||
public function hasProductSaleElement()
|
||||
{
|
||||
return ! is_null($this->product_sale_element);
|
||||
}
|
||||
|
||||
public function getProductSaleElement()
|
||||
{
|
||||
return $this->product_sale_element;
|
||||
}
|
||||
|
||||
public function setProductSaleElement(ProductSaleElement $product_sale_element)
|
||||
{
|
||||
$this->product_sale_element = $product_sale_element;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
<?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\ProductSaleElement;
|
||||
use Thelia\Core\Event\Product\ProductCreateEvent;
|
||||
use Thelia\Model\Product;
|
||||
use Thelia\Core\Event\Product\ProductEvent;
|
||||
|
||||
class ProductSaleElementUpdateEvent extends ProductSaleElementEvent
|
||||
{
|
||||
protected $product_sale_element_id;
|
||||
|
||||
protected $product;
|
||||
protected $reference;
|
||||
protected $price;
|
||||
protected $currency_id;
|
||||
protected $weight;
|
||||
protected $quantity;
|
||||
protected $sale_price;
|
||||
protected $onsale;
|
||||
protected $isnew;
|
||||
protected $isdefault;
|
||||
protected $ean_code;
|
||||
protected $taxrule;
|
||||
|
||||
public function __construct(Product $product, $product_sale_element_id)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->setProduct($product);
|
||||
|
||||
$this->setProductSaleElementId($product_sale_element_id);
|
||||
}
|
||||
|
||||
public function getProductSaleElementId()
|
||||
{
|
||||
return $this->product_sale_element_id;
|
||||
}
|
||||
|
||||
public function setProductSaleElementId($product_sale_element_id)
|
||||
{
|
||||
$this->product_sale_element_id = $product_sale_element_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrice()
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
public function setPrice($price)
|
||||
{
|
||||
$this->price = $price;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCurrencyId()
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
public function setCurrencyId($currency_id)
|
||||
{
|
||||
$this->currency_id = $currency_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWeight()
|
||||
{
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function setWeight($weight)
|
||||
{
|
||||
$this->weight = $weight;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getQuantity()
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
public function setQuantity($quantity)
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSalePrice()
|
||||
{
|
||||
return $this->sale_price;
|
||||
}
|
||||
|
||||
public function setSalePrice($sale_price)
|
||||
{
|
||||
$this->sale_price = $sale_price;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOnsale()
|
||||
{
|
||||
return $this->onsale;
|
||||
}
|
||||
|
||||
public function setOnsale($onsale)
|
||||
{
|
||||
$this->onsale = $onsale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIsnew()
|
||||
{
|
||||
return $this->isnew;
|
||||
}
|
||||
|
||||
public function setIsnew($isnew)
|
||||
{
|
||||
$this->isnew = $isnew;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEanCode()
|
||||
{
|
||||
return $this->ean_code;
|
||||
}
|
||||
|
||||
public function setEanCode($ean_code)
|
||||
{
|
||||
$this->ean_code = $ean_code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIsdefault()
|
||||
{
|
||||
return $this->isdefault;
|
||||
}
|
||||
|
||||
public function setIsdefault($isdefault)
|
||||
{
|
||||
$this->isdefault = $isdefault;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getReference()
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
public function setReference($reference)
|
||||
{
|
||||
$this->reference = $reference;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProduct()
|
||||
{
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
public function setProduct($product)
|
||||
{
|
||||
$this->product = $product;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTaxrule()
|
||||
{
|
||||
return $this->taxrule;
|
||||
}
|
||||
|
||||
public function setTaxrule($taxrule)
|
||||
{
|
||||
$this->taxrule = $taxrule;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,6 +36,8 @@ class ProfileEvent extends ActionEvent
|
||||
protected $chapo = null;
|
||||
protected $description = null;
|
||||
protected $postscriptum = null;
|
||||
protected $resourceAccess = null;
|
||||
protected $moduleAccess = null;
|
||||
|
||||
public function __construct(Profile $profile = null)
|
||||
{
|
||||
@@ -128,4 +130,24 @@ class ProfileEvent extends ActionEvent
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setResourceAccess($resourceAccess)
|
||||
{
|
||||
$this->resourceAccess = $resourceAccess;
|
||||
}
|
||||
|
||||
public function getResourceAccess()
|
||||
{
|
||||
return $this->resourceAccess;
|
||||
}
|
||||
|
||||
public function setModuleAccess($moduleAccess)
|
||||
{
|
||||
$this->moduleAccess = $moduleAccess;
|
||||
}
|
||||
|
||||
public function getModuleAccess()
|
||||
{
|
||||
return $this->moduleAccess;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,14 +260,14 @@ final class TheliaEvents
|
||||
|
||||
// -- Categories Associated Content ----------------------------------------
|
||||
|
||||
const BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT = "action.before_createCategoryAssociatedContent";
|
||||
const AFTER_CREATECATEGORY_ASSOCIATED_CONTENT = "action.after_createCategoryAssociatedContent";
|
||||
const BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT = "action.before_createCategoryAssociatedContent";
|
||||
const AFTER_CREATECATEGORY_ASSOCIATED_CONTENT = "action.after_createCategoryAssociatedContent";
|
||||
|
||||
const BEFORE_DELETECATEGORY_ASSOCIATED_CONTENT = "action.before_deleteCategoryAssociatedContent";
|
||||
const AFTER_DELETECATEGORY_ASSOCIATED_CONTENT = "action.after_deleteCategoryAssociatedContent";
|
||||
const BEFORE_DELETECATEGORY_ASSOCIATED_CONTENT = "action.before_deleteCategoryAssociatedContent";
|
||||
const AFTER_DELETECATEGORY_ASSOCIATED_CONTENT = "action.after_deleteCategoryAssociatedContent";
|
||||
|
||||
const BEFORE_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.before_updateCategoryAssociatedContent";
|
||||
const AFTER_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.after_updateCategoryAssociatedContent";
|
||||
const BEFORE_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.before_updateCategoryAssociatedContent";
|
||||
const AFTER_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.after_updateCategoryAssociatedContent";
|
||||
|
||||
// -- Product management -----------------------------------------------
|
||||
|
||||
@@ -281,8 +281,9 @@ final class TheliaEvents
|
||||
const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent";
|
||||
const PRODUCT_UPDATE_CONTENT_POSITION = "action.updateProductContentPosition";
|
||||
|
||||
const PRODUCT_ADD_COMBINATION = "action.productAddCombination";
|
||||
const PRODUCT_DELETE_COMBINATION = "action.productDeleteCombination";
|
||||
const PRODUCT_ADD_PRODUCT_SALE_ELEMENT = "action.addProductSaleElement";
|
||||
const PRODUCT_DELETE_PRODUCT_SALE_ELEMENT = "action.deleteProductSaleElement";
|
||||
const PRODUCT_UPDATE_PRODUCT_SALE_ELEMENT = "action.updateProductSaleElement";
|
||||
|
||||
const PRODUCT_SET_TEMPLATE = "action.productSetTemplate";
|
||||
|
||||
@@ -362,8 +363,8 @@ final class TheliaEvents
|
||||
* sent on modify article action
|
||||
*/
|
||||
const CART_UPDATEITEM = "action.updateArticle";
|
||||
|
||||
const CART_DELETEITEM = "action.deleteArticle";
|
||||
const CART_CLEAR = "action.clear";
|
||||
|
||||
/**
|
||||
* Order linked event
|
||||
@@ -554,9 +555,17 @@ final class TheliaEvents
|
||||
|
||||
// -- Profile management ---------------------------------------------
|
||||
|
||||
const PROFILE_CREATE = "action.createProfile";
|
||||
const PROFILE_UPDATE = "action.updateProfile";
|
||||
const PROFILE_DELETE = "action.deleteProfile";
|
||||
const PROFILE_CREATE = "action.createProfile";
|
||||
const PROFILE_UPDATE = "action.updateProfile";
|
||||
const PROFILE_DELETE = "action.deleteProfile";
|
||||
const PROFILE_RESOURCE_ACCESS_UPDATE = "action.updateProfileResourceAccess";
|
||||
const PROFILE_MODULE_ACCESS_UPDATE = "action.updateProfileModuleAccess";
|
||||
|
||||
// -- Administrator management ---------------------------------------------
|
||||
|
||||
const ADMINISTRATOR_CREATE = "action.createAdministrator";
|
||||
const ADMINISTRATOR_UPDATE = "action.updateAdministrator";
|
||||
const ADMINISTRATOR_DELETE = "action.deleteAdministrator";
|
||||
|
||||
// -- Tax Rules management ---------------------------------------------
|
||||
|
||||
@@ -693,4 +702,24 @@ final class TheliaEvents
|
||||
const NEWSLETTER_SUBSCRIBE = 'thelia.newsletter.subscribe';
|
||||
const NEWSLETTER_UPDATE = 'thelia.newsletter.update';
|
||||
const NEWSLETTER_UNSUBSCRIBE = 'thelia.newsletter.unsubscribe';
|
||||
|
||||
/************ LANG MANAGEMENT ****************************/
|
||||
|
||||
const LANG_UPDATE = 'action.lang.update';
|
||||
const LANG_CREATE = 'action.lang.create';
|
||||
const LANG_DELETE = 'action.lang.delete';
|
||||
|
||||
const LANG_DEFAULTBEHAVIOR = 'action.lang.defaultBehavior';
|
||||
const LANG_URL = 'action.lang.url';
|
||||
|
||||
const LANG_TOGGLEDEFAULT = 'action.lang.toggleDefault';
|
||||
|
||||
const BEFORE_UPDATELANG = 'action.lang.beforeUpdate';
|
||||
const AFTER_UPDATELANG = 'action.lang.afterUpdate';
|
||||
|
||||
const BEFORE_CREATELANG = 'action.lang.beforeCreate';
|
||||
const AFTER_CREATELANG = 'action.lang.afterCreate';
|
||||
|
||||
const BEFORE_DELETELANG = 'action.lang.beforeDelete';
|
||||
const AFTER_DELETELANG = 'action.lang.afterDelete';
|
||||
}
|
||||
|
||||
@@ -70,6 +70,13 @@ class Session extends BaseSession
|
||||
$this->set("thelia.current.currency", $currency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current currency
|
||||
*
|
||||
* @param bool $forceDefault If default currency forced
|
||||
*
|
||||
* @return Currency
|
||||
*/
|
||||
public function getCurrency($forceDefault = true)
|
||||
{
|
||||
$currency = $this->get("thelia.current.currency");
|
||||
|
||||
@@ -49,7 +49,7 @@ class AccessManager
|
||||
self::DELETE => false,
|
||||
);
|
||||
|
||||
protected $accessPows = array(
|
||||
static protected $accessPows = array(
|
||||
self::VIEW => 3,
|
||||
self::CREATE => 2,
|
||||
self::UPDATE => 1,
|
||||
@@ -62,14 +62,7 @@ class AccessManager
|
||||
{
|
||||
$this->accessValue = $accessValue;
|
||||
|
||||
foreach($this->accessPows as $type => $value) {
|
||||
if($accessValue >= $value) {
|
||||
$accessValue -= $value;
|
||||
$this->accessGranted[$type] = true;
|
||||
} else {
|
||||
$this->accessGranted[$type] = false;
|
||||
}
|
||||
}
|
||||
$this->fillGrantedAccess();
|
||||
}
|
||||
|
||||
public function can($type)
|
||||
@@ -81,4 +74,41 @@ class AccessManager
|
||||
return $this->accessGranted[$type];
|
||||
|
||||
}
|
||||
|
||||
static public function getMaxAccessValue()
|
||||
{
|
||||
return pow(2, current(array_slice( self::$accessPows, -1, 1, true ))) - 1;
|
||||
}
|
||||
|
||||
public function build($accesses)
|
||||
{
|
||||
$this->accessValue = 0;
|
||||
foreach($accesses as $access) {
|
||||
if(array_key_exists($access, self::$accessPows)) {
|
||||
$this->accessValue += pow(2, self::$accessPows[$access]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->fillGrantedAccess();
|
||||
}
|
||||
|
||||
protected function fillGrantedAccess()
|
||||
{
|
||||
$accessValue = $this->accessValue;
|
||||
foreach(self::$accessPows as $type => $value) {
|
||||
$pow = pow(2, $value);
|
||||
if($accessValue >= $pow) {
|
||||
$accessValue -= $pow;
|
||||
$this->accessGranted[$type] = true;
|
||||
} else {
|
||||
$this->accessGranted[$type] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getAccessValue()
|
||||
{
|
||||
return $this->accessValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,16 +37,16 @@ final class AdminResources
|
||||
|
||||
static public function retrieve($name)
|
||||
{
|
||||
$contantName = strtoupper($name);
|
||||
$constantName = strtoupper($name);
|
||||
|
||||
if(null === self::$selfReflection) {
|
||||
self::$selfReflection = new \ReflectionClass(__CLASS__);
|
||||
}
|
||||
|
||||
if(self::$selfReflection->hasConstant($contantName)) {
|
||||
return self::$selfReflection->getConstant($contantName);
|
||||
if(self::$selfReflection->hasConstant($constantName)) {
|
||||
return self::$selfReflection->getConstant($constantName);
|
||||
} else {
|
||||
throw new ResourceException(sprintf('Resource `%s` not found', $contantName), ResourceException::RESOURCE_NOT_FOUND);
|
||||
throw new ResourceException(sprintf('Resource `%s` not found', $constantName), ResourceException::RESOURCE_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ final class AdminResources
|
||||
|
||||
const ADDRESS = "admin.address";
|
||||
|
||||
const ADMIN = "admin.configuration.admin";
|
||||
const ADMINISTRATOR = "admin.configuration.administrator";
|
||||
|
||||
const AREA = "admin.configuration.area";
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
@@ -44,7 +45,7 @@ use Thelia\Type\BooleanOrBothType;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Admin extends BaseI18nLoop
|
||||
class Admin extends BaseLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
@@ -83,17 +84,17 @@ class Admin extends BaseI18nLoop
|
||||
$search->orderByFirstname(Criteria::ASC);
|
||||
|
||||
/* perform search */
|
||||
$features = $this->search($search, $pagination);
|
||||
$admins = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($features);
|
||||
$loopResult = new LoopResult($admins);
|
||||
|
||||
foreach ($features as $feature) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $feature, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $feature->getId())
|
||||
->set("PROFILE",$feature->getProfileId())
|
||||
->set("FIRSTNAME",$feature->getFirstname())
|
||||
->set("LASTNAME",$feature->getLastname())
|
||||
->set("LOGIN",$feature->getLogin())
|
||||
foreach ($admins as $admin) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $admin, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $admin->getId())
|
||||
->set("PROFILE",$admin->getProfileId())
|
||||
->set("FIRSTNAME",$admin->getFirstname())
|
||||
->set("LASTNAME",$admin->getLastname())
|
||||
->set("LOGIN",$admin->getLogin())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -45,7 +46,7 @@ class Auth extends BaseLoop
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
new Argument(
|
||||
'roles',
|
||||
'role',
|
||||
new TypeCollection(
|
||||
new AlphaNumStringListType()
|
||||
),
|
||||
@@ -61,7 +62,7 @@ class Auth extends BaseLoop
|
||||
new Argument(
|
||||
'access',
|
||||
new TypeCollection(
|
||||
new EnumListType(array("view", "create", "update", "delete"))
|
||||
new EnumListType(array(AccessManager::VIEW, AccessManager::CREATE, AccessManager::UPDATE, AccessManager::DELETE))
|
||||
)
|
||||
),
|
||||
Argument::createAnyTypeArgument('context', 'front', false)
|
||||
@@ -75,7 +76,7 @@ class Auth extends BaseLoop
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$roles = $this->getRoles();
|
||||
$roles = $this->getRole();
|
||||
$resource = $this->getResource();
|
||||
$access = $this->getAccess();
|
||||
|
||||
|
||||
@@ -113,13 +113,13 @@ class Country extends BaseI18nLoop
|
||||
->set("CHAPO", $country->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $country->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $country->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("IS_DEFAULT", $country->getByDefault() === 1 ? "1" : "0")
|
||||
->set("ISOCODE", $country->getIsocode())
|
||||
->set("ISOALPHA2", $country->getIsoalpha2())
|
||||
->set("ISOALPHA3", $country->getIsoalpha3())
|
||||
->set('IS_DEFAULT', $country->getByDefault())
|
||||
->set("IS_DEFAULT", $country->getByDefault() ? "1" : "0")
|
||||
->set("IS_SHOP_COUNTRY", $country->getShopCountry() ? "1" : "0")
|
||||
;
|
||||
|
||||
;
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,8 @@ class Lang extends BaseLoop
|
||||
->set("LOCALE", $result->getLocale())
|
||||
->set("URL", $result->getUrl())
|
||||
->set("IS_DEFAULT", $result->getByDefault())
|
||||
->set("URL", $result->getUrl())
|
||||
->set("DATE_FORMAT", $result->getDateFormat())
|
||||
->set("TIME_FORMAT", $result->getTimeFormat())
|
||||
->set("POSITION", $result->getPosition())
|
||||
;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -56,6 +57,13 @@ class Module extends BaseI18nLoop
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntTypeArgument('profile'),
|
||||
new Argument(
|
||||
'code',
|
||||
new Type\TypeCollection(
|
||||
new Type\AlphaNumStringListType()
|
||||
)
|
||||
),
|
||||
new Argument(
|
||||
'module_type',
|
||||
new Type\TypeCollection(
|
||||
@@ -89,6 +97,20 @@ class Module extends BaseI18nLoop
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$profile = $this->getProfile();
|
||||
|
||||
if (null !== $profile) {
|
||||
$search->leftJoinProfileModule('profile_module')
|
||||
->addJoinCondition('profile_module', 'profile_module.PROFILE_ID=?', $profile, null, \PDO::PARAM_INT)
|
||||
->withColumn('profile_module.access', 'access');
|
||||
}
|
||||
|
||||
$code = $this->getCode();
|
||||
|
||||
if(null !== $code) {
|
||||
$search->filterByCode($code, Criteria::IN);
|
||||
}
|
||||
|
||||
$moduleType = $this->getModule_type();
|
||||
|
||||
if (null !== $moduleType) {
|
||||
@@ -129,6 +151,16 @@ class Module extends BaseI18nLoop
|
||||
->set("CLASS", $module->getFullNamespace())
|
||||
->set("POSITION", $module->getPosition());
|
||||
|
||||
if (null !== $profile) {
|
||||
$accessValue = $module->getVirtualColumn('access');
|
||||
$manager = new AccessManager($accessValue);
|
||||
|
||||
$loopResultRow->set("VIEWABLE", $manager->can(AccessManager::VIEW)? 1 : 0)
|
||||
->set("CREATABLE", $manager->can(AccessManager::CREATE) ? 1 : 0)
|
||||
->set("UPDATABLE", $manager->can(AccessManager::UPDATE)? 1 : 0)
|
||||
->set("DELETABLE", $manager->can(AccessManager::DELETE)? 1 : 0);
|
||||
}
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ class OrderProduct extends BaseLoop
|
||||
->set("TAX_RULE_TITLE", $product->getTaxRuleTitle())
|
||||
->set("TAX_RULE_DESCRIPTION", $product->getTaxRuledescription())
|
||||
->set("PARENT", $product->getParent())
|
||||
->set("EAN_CODE", $product->getEanCode())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -177,6 +177,7 @@ class ProductSaleElements extends BaseLoop
|
||||
->set("IS_NEW" , $PSEValue->getNewness() === 1 ? 1 : 0)
|
||||
->set("IS_DEFAULT" , $PSEValue->getIsDefault() === 1 ? 1 : 0)
|
||||
->set("WEIGHT" , $PSEValue->getWeight())
|
||||
->set("EAN_CODE" , $PSEValue->getEanCode())
|
||||
->set("PRICE" , $price)
|
||||
->set("PRICE_TAX" , $taxedPrice - $price)
|
||||
->set("TAXED_PRICE" , $taxedPrice)
|
||||
|
||||
@@ -79,20 +79,20 @@ class Profile extends BaseI18nLoop
|
||||
$search->orderById(Criteria::ASC);
|
||||
|
||||
/* perform search */
|
||||
$features = $this->search($search, $pagination);
|
||||
$profiles = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($features);
|
||||
$loopResult = new LoopResult($profiles);
|
||||
|
||||
foreach ($features as $feature) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $feature, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $feature->getId())
|
||||
->set("IS_TRANSLATED",$feature->getVirtualColumn('IS_TRANSLATED'))
|
||||
foreach ($profiles as $profile) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $profile, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $profile->getId())
|
||||
->set("IS_TRANSLATED",$profile->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("CODE",$feature->getCode())
|
||||
->set("TITLE",$feature->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $feature->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $feature->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $feature->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("CODE",$profile->getCode())
|
||||
->set("TITLE",$profile->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $profile->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $profile->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $profile->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
128
core/lib/Thelia/Core/Template/Loop/Resource.php
Executable file
128
core/lib/Thelia/Core/Template/Loop/Resource.php
Executable file
@@ -0,0 +1,128 @@
|
||||
<?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\Security\AccessManager;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\ResourceQuery;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
/**
|
||||
*
|
||||
* Resource loop
|
||||
*
|
||||
*
|
||||
* Class Resource
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Resource extends BaseI18nLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('profile'),
|
||||
new Argument(
|
||||
'code',
|
||||
new Type\TypeCollection(
|
||||
new Type\AlphaNumStringListType()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = ResourceQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$profile = $this->getProfile();
|
||||
|
||||
if (null !== $profile) {
|
||||
$search->leftJoinProfileResource('profile_resource')
|
||||
->addJoinCondition('profile_resource', 'profile_resource.PROFILE_ID=?', $profile, null, \PDO::PARAM_INT)
|
||||
->withColumn('profile_resource.access', 'access');
|
||||
}
|
||||
|
||||
$code = $this->getCode();
|
||||
|
||||
if(null !== $code) {
|
||||
$search->filterByCode($code, Criteria::IN);
|
||||
}
|
||||
|
||||
$search->orderById(Criteria::ASC);
|
||||
|
||||
/* perform search */
|
||||
$resources = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($resources);
|
||||
|
||||
foreach ($resources as $resource) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $resource, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $resource->getId())
|
||||
->set("IS_TRANSLATED",$resource->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("CODE",$resource->getCode())
|
||||
->set("TITLE",$resource->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $resource->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $resource->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $resource->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
;
|
||||
|
||||
if (null !== $profile) {
|
||||
$accessValue = $resource->getVirtualColumn('access');
|
||||
$manager = new AccessManager($accessValue);
|
||||
|
||||
$loopResultRow->set("VIEWABLE", $manager->can(AccessManager::VIEW)? 1 : 0)
|
||||
->set("CREATABLE", $manager->can(AccessManager::CREATE) ? 1 : 0)
|
||||
->set("UPDATABLE", $manager->can(AccessManager::UPDATE)? 1 : 0)
|
||||
->set("DELETABLE", $manager->can(AccessManager::DELETE)? 1 : 0);
|
||||
}
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -22,9 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
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;
|
||||
@@ -33,6 +30,9 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Template\ParserContext;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -78,8 +78,8 @@ class Form extends AbstractSmartyPlugin
|
||||
{
|
||||
foreach ($formDefinition as $name => $className) {
|
||||
if (array_key_exists($name, $this->formDefinition)) {
|
||||
throw new \InvalidArgumentException(sprintf("%s form name already exists for %s class", $name,
|
||||
$className));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf("%s form name already exists for %s class", $name, $className));
|
||||
}
|
||||
|
||||
$this->formDefinition[$name] = $className;
|
||||
@@ -113,7 +113,8 @@ class Form extends AbstractSmartyPlugin
|
||||
|
||||
$template->assign("form_error", $instance->hasError() ? true : false);
|
||||
$template->assign("form_error_message", $instance->getErrorMessage());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -139,7 +140,7 @@ class Form extends AbstractSmartyPlugin
|
||||
|
||||
$template->assign("error", empty($errors) ? false : true);
|
||||
|
||||
if (! empty($errors)) {
|
||||
if (!empty($errors)) {
|
||||
$this->assignFieldErrorVars($template, $errors);
|
||||
}
|
||||
|
||||
@@ -205,30 +206,37 @@ class Form extends AbstractSmartyPlugin
|
||||
$this->assignFormTypeValues($template, $formFieldConfig, $formFieldView);
|
||||
|
||||
$value = $formFieldView->vars["value"];
|
||||
/* FIXME: doesnt work. We got "This form should not contain extra fields." error.
|
||||
// We have a collection
|
||||
if (is_array($value)) {
|
||||
|
||||
$key = $this->getParam($params, 'value_key');
|
||||
// We have a collection
|
||||
if (count($formFieldView->children) > 0) {
|
||||
|
||||
if ($key != null) {
|
||||
$key = $this->getParam($params, 'value_key');
|
||||
|
||||
if (isset($value[$key])) {
|
||||
if ($key != null) {
|
||||
|
||||
$name = sprintf("%s[%s]", $formFieldView->vars["full_name"], $key);
|
||||
$val = $value[$key];
|
||||
if (isset($value[$key])) {
|
||||
|
||||
$this->assignFieldValues($template, $name, $val, $formFieldView->vars);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVars["value"], $formFieldView->vars);
|
||||
}
|
||||
*/
|
||||
$this->assignFieldValues($template, $formFieldView->vars["full_name"], $formFieldView->vars["value"], $formFieldView->vars);
|
||||
$name = sprintf("%s[%s]", $formFieldView->vars["full_name"], $key);
|
||||
|
||||
$val = $value[$key];
|
||||
|
||||
$this->assignFieldValues($template, $name, $val, $formFieldView->vars);
|
||||
}
|
||||
else {
|
||||
throw new \LogicException(sprintf("Cannot find a value for key '%s' in field '%s'", $key, $formFieldView->vars["name"]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new \InvalidArgumentException(sprintf("Missing or empty parameter 'value_key' for field '%s'", $formFieldView->vars["name"]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->assignFieldValues($template, $formFieldView->vars["full_name"], $formFieldView->vars["value"], $formFieldView->vars);
|
||||
}
|
||||
|
||||
$formFieldView->setRendered();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -262,7 +270,9 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
self::$taggedFieldsStackPosition = null;
|
||||
}
|
||||
|
||||
return $content;
|
||||
if(null !== $content) {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
public function renderHiddenFormField($params, \Smarty_Internal_Template $template)
|
||||
@@ -298,7 +308,7 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
$formView = $instance->getView();
|
||||
|
||||
if ($formView->vars["multipart"]) {
|
||||
return sprintf('%s="%s"',"enctype", "multipart/form-data");
|
||||
return sprintf('%s="%s"', "enctype", "multipart/form-data");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +324,8 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
|
||||
if ($repeat) {
|
||||
$this->assignFieldErrorVars($template, $errors);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -337,11 +348,10 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
|
||||
$fieldName = $this->getParam($params, 'field');
|
||||
|
||||
if (null == $fieldName)
|
||||
throw new \InvalidArgumentException("'field' parameter is missing");
|
||||
if (null == $fieldName) throw new \InvalidArgumentException("'field' parameter is missing");
|
||||
|
||||
if (empty($instance->getView()[$fieldName]))
|
||||
throw new \InvalidArgumentException(sprintf("Field name '%s' not found in form %s", $fieldName, $instance->getName()));
|
||||
if (empty($instance->getView()[$fieldName])) throw new \InvalidArgumentException(
|
||||
sprintf("Field name '%s' not found in form %s", $fieldName, $instance->getName()));
|
||||
|
||||
return $instance->getView()[$fieldName];
|
||||
}
|
||||
@@ -396,8 +406,10 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
throw new \InvalidArgumentException("Missing 'form' parameter in form arguments");
|
||||
}
|
||||
|
||||
if (! $instance instanceof \Thelia\Form\BaseForm) {
|
||||
throw new \InvalidArgumentException(sprintf("form parameter in form_field block must be an instance of
|
||||
if (!$instance instanceof \Thelia\Form\BaseForm) {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
"form parameter in form_field block must be an instance of
|
||||
\Thelia\Form\BaseForm, instance of %s found", get_class($instance)));
|
||||
}
|
||||
|
||||
@@ -412,10 +424,7 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
|
||||
$class = new \ReflectionClass($this->formDefinition[$name]);
|
||||
|
||||
return $class->newInstance(
|
||||
$this->request,
|
||||
"form"
|
||||
);
|
||||
return $class->newInstance($this->request, "form");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Template\Smarty\Exception\SmartyPluginException;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Tools\DateTimeFormat;
|
||||
use Thelia\Tools\NumberFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -69,21 +70,20 @@ class Format extends AbstractSmartyPlugin
|
||||
*/
|
||||
public function formatDate($params, $template = null)
|
||||
{
|
||||
$date = $this->getParam($params, "date", false);
|
||||
|
||||
if (array_key_exists("date", $params) === false) {
|
||||
if ($date === false) {
|
||||
throw new SmartyPluginException("date is a mandatory parameter in format_date function");
|
||||
}
|
||||
|
||||
$date = $params["date"];
|
||||
|
||||
if (!$date instanceof \DateTime) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (array_key_exists("format", $params)) {
|
||||
$format = $params["format"];
|
||||
} else {
|
||||
$format = DateTimeFormat::getInstance($this->request)->getFormat(array_key_exists("output", $params) ? $params["output"] : null);
|
||||
$format = $this->getParam($params, "format", false);
|
||||
|
||||
if ($format === false) {
|
||||
$format = DateTimeFormat::getInstance($this->request)->getFormat($this->getParam($params, "output", null));
|
||||
}
|
||||
|
||||
return $date->format($format);
|
||||
@@ -109,23 +109,22 @@ class Format extends AbstractSmartyPlugin
|
||||
*/
|
||||
public function formatNumber($params, $template = null)
|
||||
{
|
||||
if (array_key_exists("number", $params) === false) {
|
||||
$number = $this->getParam($params, "number", false);
|
||||
|
||||
if ($number === false) {
|
||||
throw new SmartyPluginException("number is a mandatory parameter in format_number function");
|
||||
}
|
||||
|
||||
$number = $params["number"];
|
||||
|
||||
if (empty($number)) {
|
||||
if ($number == '') {
|
||||
return "";
|
||||
}
|
||||
|
||||
$lang = $this->request->getSession()->getLang();
|
||||
|
||||
$decimals = array_key_exists("decimals", $params) ? $params["decimals"] : $lang->getDecimals();
|
||||
$decPoint = array_key_exists("dec_point", $params) ? $params["dec_point"] : $lang->getDecimalSeparator();
|
||||
$thousandsSep = array_key_exists("thousands_sep", $params) ? $params["thousands_sep"] : $lang->getThousandsSeparator();
|
||||
|
||||
return number_format($number, $decimals, $decPoint, $thousandsSep);
|
||||
return NumberFormat::getInstance($this->request)->format(
|
||||
$number,
|
||||
$this->getParam($params, "decimals", null),
|
||||
$this->getParam($params, "dec_point", null),
|
||||
$this->getParam($params, "thousands_sep", null)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -96,7 +96,10 @@ class Thelia extends Kernel
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
$this->getContainer()->get("event_dispatcher")->dispatch(TheliaEvents::BOOT);
|
||||
if (file_exists(THELIA_ROOT . '/local/config/database.yml') === true) {
|
||||
$this->getContainer()->get("event_dispatcher")->dispatch(TheliaEvents::BOOT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,8 +27,8 @@ use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\Translation\Translator;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Thelia\Condition\ConditionEvaluator;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
use Thelia\Model\Coupon;
|
||||
use Thelia\Model\CouponQuery;
|
||||
use Thelia\Cart\CartTrait;
|
||||
@@ -44,10 +44,9 @@ use Thelia\Model\CurrencyQuery;
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
* @todo implements
|
||||
*
|
||||
*/
|
||||
class BaseAdapter implements AdapterInterface
|
||||
class BaseFacade implements FacadeInterface
|
||||
{
|
||||
use CartTrait {
|
||||
CartTrait::getCart as getCartFromTrait;
|
||||
@@ -86,7 +85,7 @@ class BaseAdapter implements AdapterInterface
|
||||
*/
|
||||
public function getDeliveryAddress()
|
||||
{
|
||||
// TODO: Implement getDeliveryAddress() method.
|
||||
// @todo: Implement getDeliveryAddress() method.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +105,7 @@ class BaseAdapter implements AdapterInterface
|
||||
*/
|
||||
public function getCheckoutTotalPrice()
|
||||
{
|
||||
// TODO: Implement getCheckoutTotalPrice() method.
|
||||
return $this->getRequest()->getSession()->getOrder()->getTotalAmount();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +115,7 @@ class BaseAdapter implements AdapterInterface
|
||||
*/
|
||||
public function getCheckoutPostagePrice()
|
||||
{
|
||||
// TODO: Implement getCheckoutPostagePrice() method.
|
||||
return $this->getRequest()->getSession()->getOrder()->getPostage();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +125,8 @@ class BaseAdapter implements AdapterInterface
|
||||
*/
|
||||
public function getCartTotalPrice()
|
||||
{
|
||||
// TODO: Implement getCartTotalPrice() method.
|
||||
return $this->getRequest()->getSession()->getCart()->getTotalAmount();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +136,7 @@ class BaseAdapter implements AdapterInterface
|
||||
*/
|
||||
public function getCheckoutCurrency()
|
||||
{
|
||||
$this->getRequest()->getSession()->getCurrency();
|
||||
return $this->getRequest()->getSession()->getCurrency()->getCode();
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ class BaseAdapter implements AdapterInterface
|
||||
*/
|
||||
public function getNbArticlesInCart()
|
||||
{
|
||||
// TODO: Implement getNbArticlesInCart() method.
|
||||
return count($this->getRequest()->getSession()->getCart()->getCartItems());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,16 +157,13 @@ class BaseAdapter implements AdapterInterface
|
||||
*/
|
||||
public function getCurrentCoupons()
|
||||
{
|
||||
// @todo implement
|
||||
// $consumedCoupons = $this->getRequest()->getSession()->getConsumedCoupons();
|
||||
// @todo convert coupon code to coupon Interface
|
||||
|
||||
$couponCodes = $this->getRequest()->getSession()->getConsumedCoupons();
|
||||
|
||||
if (null === $couponCodes) {
|
||||
return array();
|
||||
}
|
||||
$couponFactory = $this->container->get('thelia.coupon.factory');
|
||||
|
||||
// @todo get from cart
|
||||
$couponCodes = array('XMAS', 'SPRINGBREAK');
|
||||
|
||||
$coupons = array();
|
||||
foreach ($couponCodes as $couponCode) {
|
||||
$coupons[] = $couponFactory->buildCouponFromCode($couponCode);
|
||||
@@ -190,34 +187,7 @@ class BaseAdapter implements AdapterInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a Coupon in the database
|
||||
*
|
||||
* @param CouponInterface $coupon Coupon
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function saveCoupon(CouponInterface $coupon)
|
||||
{
|
||||
// $couponModel = new Coupon();
|
||||
// $couponModel->setCode($coupon->getCode());
|
||||
// $couponModel->setType(get_class($coupon));
|
||||
// $couponModel->setTitle($coupon->getTitle());
|
||||
// $couponModel->setShortDescription($coupon->getShortDescription());
|
||||
// $couponModel->setDescription($coupon->getDescription());
|
||||
// $couponModel->setAmount($coupon->getDiscount());
|
||||
// $couponModel->setIsUsed(0);
|
||||
// $couponModel->setIsEnabled(1);
|
||||
// $couponModel->set
|
||||
// $couponModel->set
|
||||
// $couponModel->set
|
||||
// $couponModel->set
|
||||
// $couponModel->set
|
||||
// $couponModel->set
|
||||
// $couponModel->set
|
||||
}
|
||||
|
||||
/**
|
||||
* Return plateform Container
|
||||
* Return platform Container
|
||||
*
|
||||
* @return Container
|
||||
*/
|
||||
@@ -245,7 +215,7 @@ class BaseAdapter implements AdapterInterface
|
||||
*/
|
||||
public function getMainCurrency()
|
||||
{
|
||||
// TODO: Implement getMainCurrency() method.
|
||||
return $this->getRequest()->getSession()->getCurrency();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,7 +231,7 @@ class BaseAdapter implements AdapterInterface
|
||||
/**
|
||||
* Return Constraint Validator
|
||||
*
|
||||
* @return ConditionValidator
|
||||
* @return ConditionEvaluator
|
||||
*/
|
||||
public function getConditionEvaluator()
|
||||
{
|
||||
@@ -25,8 +25,6 @@ namespace Thelia\Coupon;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Thelia\Condition\ConditionManagerInterface;
|
||||
use Thelia\Constraint\Rule\CouponRuleInterface;
|
||||
use Thelia\Constraint\Rule\SerializableRule;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
|
||||
@@ -47,7 +47,7 @@ class CouponFactory
|
||||
/** @var ContainerInterface Service Container */
|
||||
protected $container = null;
|
||||
|
||||
/** @var AdapterInterface Provide necessary value from Thelia*/
|
||||
/** @var FacadeInterface Provide necessary value from Thelia*/
|
||||
protected $adapter;
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Thelia\Coupon;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Thelia\Condition\ConditionManagerInterface;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
use Thelia\Model\Coupon;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
@@ -40,7 +41,7 @@ use Thelia\Coupon\Type\CouponInterface;
|
||||
*/
|
||||
class CouponManager
|
||||
{
|
||||
/** @var AdapterInterface Provides necessary value from Thelia */
|
||||
/** @var FacadeInterface Provides necessary value from Thelia */
|
||||
protected $adapter = null;
|
||||
|
||||
/** @var ContainerInterface Service Container */
|
||||
@@ -183,39 +184,12 @@ class CouponManager
|
||||
$discount = 0.00;
|
||||
/** @var CouponInterface $coupon */
|
||||
foreach ($coupons as $coupon) {
|
||||
// @todo modify Cart with discount for each cart item
|
||||
$discount += $coupon->getDiscount($this->adapter);
|
||||
$discount += $coupon->exec($this->adapter);
|
||||
}
|
||||
|
||||
return $discount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a ConditionManagerInterface from data coming from a form
|
||||
*
|
||||
* @param string $conditionServiceId Condition service id you want to instantiate
|
||||
* @param array $operators Condition Operator set by the Admin
|
||||
* @param array $values Condition Values set by the Admin
|
||||
*
|
||||
* @return ConditionManagerInterface
|
||||
*/
|
||||
public function buildRuleFromForm($conditionServiceId, array $operators, array $values)
|
||||
{
|
||||
$condition = false;
|
||||
try {
|
||||
|
||||
if ($this->container->has($conditionServiceId)) {
|
||||
/** @var ConditionManagerInterface $condition */
|
||||
$condition = $this->container->get($conditionServiceId);
|
||||
$condition->populateFromForm($operators, $values);
|
||||
}
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
|
||||
}
|
||||
|
||||
return $condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an available CouponManager (Services)
|
||||
*
|
||||
@@ -241,7 +215,7 @@ class CouponManager
|
||||
*
|
||||
* @param ConditionManagerInterface $condition ConditionManagerInterface
|
||||
*/
|
||||
public function addAvailableRule(ConditionManagerInterface $condition)
|
||||
public function addAvailableCondition(ConditionManagerInterface $condition)
|
||||
{
|
||||
$this->availableConditions[] = $condition;
|
||||
}
|
||||
@@ -255,4 +229,34 @@ class CouponManager
|
||||
{
|
||||
return $this->availableConditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement this coupon quantity
|
||||
*
|
||||
* To call when a coupon is consumed
|
||||
*
|
||||
* @param \Thelia\Model\Coupon $coupon Coupon consumed
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function decrementeQuantity(Coupon $coupon)
|
||||
{
|
||||
$ret = true;
|
||||
try {
|
||||
|
||||
$oldMaxUsage = $coupon->getMaxUsage();
|
||||
|
||||
if ($oldMaxUsage > 0) {
|
||||
$oldMaxUsage--;
|
||||
$coupon->setMaxUsage($$oldMaxUsage);
|
||||
|
||||
$coupon->save();
|
||||
}
|
||||
|
||||
} catch(\Exception $e) {
|
||||
$ret = false;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
@@ -25,11 +25,9 @@ namespace Thelia\Coupon;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\Translation\Translator;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Thelia\Condition\ConditionEvaluator;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
use Thelia\Model\Coupon;
|
||||
|
||||
/**
|
||||
@@ -43,7 +41,7 @@ use Thelia\Model\Coupon;
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
interface AdapterInterface
|
||||
interface FacadeInterface
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -126,15 +124,6 @@ interface AdapterInterface
|
||||
*/
|
||||
public function findOneCouponByCode($code);
|
||||
|
||||
/**
|
||||
* Save a Coupon in the database
|
||||
*
|
||||
* @param CouponInterface $coupon Coupon
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function saveCoupon(CouponInterface $coupon);
|
||||
|
||||
/**
|
||||
* Return platform Container
|
||||
*
|
||||
@@ -45,7 +45,7 @@ class RuleOrganizer implements RuleOrganizerInterface
|
||||
*/
|
||||
public function organize(array $conditions)
|
||||
{
|
||||
// TODO: Implement organize() method.
|
||||
// @todo: Implement organize() method.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace Thelia\Coupon\Type;
|
||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
||||
use Thelia\Condition\ConditionEvaluator;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Coupon\AdapterInterface;
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
use Thelia\Coupon\ConditionCollection;
|
||||
use Thelia\Coupon\RuleOrganizerInterface;
|
||||
use Thelia\Exception\InvalidConditionException;
|
||||
@@ -44,7 +44,7 @@ use Thelia\Exception\InvalidConditionException;
|
||||
*/
|
||||
abstract class CouponAbstract implements CouponInterface
|
||||
{
|
||||
/** @var AdapterInterface Provide necessary value from Thelia */
|
||||
/** @var FacadeInterface Provide necessary value from Thelia */
|
||||
protected $adapter = null;
|
||||
|
||||
/** @var Translator Service Translator */
|
||||
@@ -104,9 +104,9 @@ abstract class CouponAbstract implements CouponInterface
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param AdapterInterface $adapter Service adapter
|
||||
* @param FacadeInterface $adapter Service adapter
|
||||
*/
|
||||
public function __construct(AdapterInterface $adapter)
|
||||
public function __construct(FacadeInterface $adapter)
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
$this->translator = $adapter->getTranslator();
|
||||
@@ -195,7 +195,7 @@ abstract class CouponAbstract implements CouponInterface
|
||||
*
|
||||
* @return float Amount removed from the Total Checkout
|
||||
*/
|
||||
public function getDiscount()
|
||||
public function exec()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
@@ -298,7 +298,7 @@ abstract class CouponAbstract implements CouponInterface
|
||||
|
||||
/**
|
||||
* Check if the current state of the application is matching this Coupon conditions
|
||||
* Thelia variables are given by the AdapterInterface
|
||||
* Thelia variables are given by the FacadeInterface
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -307,5 +307,4 @@ abstract class CouponAbstract implements CouponInterface
|
||||
return $this->conditionEvaluator->isMatching($this->conditions);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace Thelia\Coupon\Type;
|
||||
|
||||
use Thelia\Coupon\AdapterInterface;
|
||||
use Thelia\Coupon\ConditionCollection;
|
||||
|
||||
/**
|
||||
@@ -205,11 +204,11 @@ interface CouponInterface
|
||||
*
|
||||
* @return float Amount removed from the Total Checkout
|
||||
*/
|
||||
public function getDiscount();
|
||||
public function exec();
|
||||
|
||||
/**
|
||||
* Check if the current Coupon is matching its conditions (Rules)
|
||||
* Thelia variables are given by the AdapterInterface
|
||||
* Thelia variables are given by the FacadeInterface
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
/**********************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/**********************************************************************************/
|
||||
|
||||
namespace Thelia\Coupon\Type;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 8/19/13
|
||||
* Time: 3:24 PM
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class RemoveXPercentForCategoryY extends RemoveXPercent
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
/**********************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/**********************************************************************************/
|
||||
|
||||
namespace Thelia\Coupon\Type;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 8/19/13
|
||||
* Time: 3:24 PM
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class RemoveXPercentForProductSaleElementIdY extends RemoveXPercent
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
/**********************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/**********************************************************************************/
|
||||
|
||||
namespace Thelia\Coupon\Type;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 8/19/13
|
||||
* Time: 3:24 PM
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class RemoveXPercentForProductY extends RemoveXPercent
|
||||
{
|
||||
|
||||
}
|
||||
@@ -98,7 +98,7 @@ class RemoveXPercentManager extends CouponAbstract
|
||||
* @throws \InvalidArgumentException
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount()
|
||||
public function exec()
|
||||
{
|
||||
if ($this->percent >= 100) {
|
||||
throw new \InvalidArgumentException(
|
||||
|
||||
138
core/lib/Thelia/Form/AdministratorCreationForm.php
Normal file
138
core/lib/Thelia/Form/AdministratorCreationForm.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\AdminQuery;
|
||||
use Thelia\Model\ProfileQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
class AdministratorCreationForm extends BaseForm
|
||||
{
|
||||
const PROFILE_FIELD_PREFIX = "profile";
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("login", "text", array(
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
new Constraints\Callback(array(
|
||||
"methods" => array(
|
||||
array($this, "verifyExistingLogin"),
|
||||
)
|
||||
)),
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Login"),
|
||||
"label_attr" => array(
|
||||
"for" => "login"
|
||||
),
|
||||
))
|
||||
->add("firstname", "text", array(
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("First Name"),
|
||||
"label_attr" => array(
|
||||
"for" => "firstname"
|
||||
),
|
||||
))
|
||||
->add("lastname", "text", array(
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Last Name"),
|
||||
"label_attr" => array(
|
||||
"for" => "lastname"
|
||||
)
|
||||
))
|
||||
->add("password", "password", array(
|
||||
"constraints" => array(),
|
||||
"label" => Translator::getInstance()->trans("Password"),
|
||||
"label_attr" => array(
|
||||
"for" => "password"
|
||||
),
|
||||
))
|
||||
->add("password_confirm", "password", array(
|
||||
"constraints" => array(
|
||||
new Constraints\Callback(array("methods" => array(
|
||||
array($this, "verifyPasswordField")
|
||||
)))
|
||||
),
|
||||
"label" => "Password confirmation",
|
||||
"label_attr" => array(
|
||||
"for" => "password_confirmation"
|
||||
),
|
||||
))
|
||||
->add(
|
||||
'profile',
|
||||
"choice",
|
||||
array(
|
||||
"choices" => ProfileQuery::getProfileList(),
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
),
|
||||
"label" => "Profile",
|
||||
"label_attr" => array(
|
||||
"for" => "profile"
|
||||
),
|
||||
)
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
public function verifyPasswordField($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$data = $context->getRoot()->getData();
|
||||
|
||||
if($data["password"] === '' && $data["password_confirm"] === '') {
|
||||
$context->addViolation("password can't be empty");
|
||||
}
|
||||
|
||||
if ($data["password"] != $data["password_confirm"]) {
|
||||
$context->addViolation("password confirmation is not the same as password field");
|
||||
}
|
||||
|
||||
if(strlen($data["password"]) < 4) {
|
||||
$context->addViolation("password must be composed of at least 4 characters");
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyExistingLogin($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$administrator = AdminQuery::create()->findOneByLogin($value);
|
||||
if ($administrator !== null) {
|
||||
$context->addViolation("This login already exists");
|
||||
}
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_admin_administrator_creation";
|
||||
}
|
||||
}
|
||||
97
core/lib/Thelia/Form/AdministratorModificationForm.php
Executable file
97
core/lib/Thelia/Form/AdministratorModificationForm.php
Executable file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\AdminQuery;
|
||||
|
||||
class AdministratorModificationForm extends AdministratorCreationForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
parent::buildForm();
|
||||
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array(
|
||||
"required" => true,
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
new Constraints\Callback(
|
||||
array(
|
||||
"methods" => array(
|
||||
array($this, "verifyAdministratorId"),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
"attr" => array(
|
||||
"id" => "administrator_update_id",
|
||||
),
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_admin_administrator_modification";
|
||||
}
|
||||
|
||||
public function verifyAdministratorId($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$administrator = AdminQuery::create()
|
||||
->findPk($value);
|
||||
|
||||
if (null === $administrator) {
|
||||
$context->addViolation("Administrator ID not found");
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyExistingLogin($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$data = $context->getRoot()->getData();
|
||||
|
||||
$administrator = AdminQuery::create()->findOneByLogin($value);
|
||||
if ($administrator !== null && $administrator->getId() != $data['id']) {
|
||||
$context->addViolation("This login already exists");
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyPasswordField($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$data = $context->getRoot()->getData();
|
||||
|
||||
if ($data["password"] != $data["password_confirm"]) {
|
||||
$context->addViolation("password confirmation is not the same as password field");
|
||||
}
|
||||
|
||||
if($data["password"] !== '' && strlen($data["password"]) < 4) {
|
||||
$context->addViolation("password must be composed of at least 4 characters");
|
||||
}
|
||||
}
|
||||
}
|
||||
58
core/lib/Thelia/Form/AdminProfileCreationForm.php → core/lib/Thelia/Form/CouponCode.php
Normal file → Executable file
58
core/lib/Thelia/Form/AdminProfileCreationForm.php → core/lib/Thelia/Form/CouponCode.php
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
@@ -17,49 +17,47 @@
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
class AdminProfileCreationForm extends BaseForm
|
||||
/**
|
||||
* Class CouponCode
|
||||
*
|
||||
* Manage how a coupon is entered by a customer
|
||||
*
|
||||
* @package Thelia\Form
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*/
|
||||
class CouponCode extends BaseForm
|
||||
{
|
||||
/**
|
||||
* Build form
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("wording" , "text" , array(
|
||||
->add("coupon-code", "text", array(
|
||||
"required" => true,
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Wording *"),
|
||||
"label_attr" => array(
|
||||
"for" => "wording"
|
||||
))
|
||||
new Constraints\NotBlank(),
|
||||
)
|
||||
)
|
||||
->add("name" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Name *"),
|
||||
"label_attr" => array(
|
||||
"for" => "name"
|
||||
))
|
||||
)
|
||||
->add("description" , "text" , array(
|
||||
"label" => Translator::getInstance()->trans("Description"),
|
||||
"label_attr" => array(
|
||||
"for" => "description"
|
||||
))
|
||||
)
|
||||
;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_admin_profile_creation";
|
||||
return "thelia_coupon_code";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ use Symfony\Component\Validator\Constraints\Date;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\NotEqualTo;
|
||||
use Symfony\Component\Validator\Constraints\Range;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
@@ -109,7 +110,7 @@ class CouponCreationForm extends BaseForm
|
||||
)
|
||||
->add(
|
||||
'isEnabled',
|
||||
'checkbox',
|
||||
'text',
|
||||
array()
|
||||
)
|
||||
->add(
|
||||
@@ -124,17 +125,17 @@ class CouponCreationForm extends BaseForm
|
||||
)
|
||||
->add(
|
||||
'isCumulative',
|
||||
'checkbox',
|
||||
'text',
|
||||
array()
|
||||
)
|
||||
->add(
|
||||
'isRemovingPostage',
|
||||
'checkbox',
|
||||
'text',
|
||||
array()
|
||||
)
|
||||
->add(
|
||||
'isAvailableOnSpecialOffers',
|
||||
'checkbox',
|
||||
'text',
|
||||
array()
|
||||
)
|
||||
->add(
|
||||
|
||||
116
core/lib/Thelia/Form/Lang/LangCreateForm.php
Normal file
116
core/lib/Thelia/Form/Lang/LangCreateForm.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\Lang;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangCreateForm
|
||||
* @package Thelia\Form\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangCreateForm extends BaseForm
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
* Form this you have to call add method on $this->formBuilder attribute :
|
||||
*
|
||||
* $this->formBuilder->add("name", "text")
|
||||
* ->add("email", "email", array(
|
||||
* "attr" => array(
|
||||
* "class" => "field"
|
||||
* ),
|
||||
* "label" => "email",
|
||||
* "constraints" => array(
|
||||
* new \Symfony\Component\Validator\Constraints\NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add('title', 'text', array(
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('Language name'),
|
||||
'label_attr' => array(
|
||||
'for' => 'title_lang'
|
||||
)
|
||||
))
|
||||
->add('code', 'text', array(
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('ISO 639 Code'),
|
||||
'label_attr' => array(
|
||||
'for' => 'code_lang'
|
||||
)
|
||||
))
|
||||
->add('locale', 'text', array(
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('language locale'),
|
||||
'label_attr' => array(
|
||||
'for' => 'locale_lang'
|
||||
)
|
||||
))
|
||||
->add('date_format', 'text', array(
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('date format'),
|
||||
'label_attr' => array(
|
||||
'for' => 'date_lang'
|
||||
)
|
||||
))
|
||||
->add('time_format', 'text', array(
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('time format'),
|
||||
'label_attr' => array(
|
||||
'for' => 'time_lang'
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_language_create';
|
||||
}
|
||||
}
|
||||
85
core/lib/Thelia/Form/Lang/LangDefaultBehaviorForm.php
Normal file
85
core/lib/Thelia/Form/Lang/LangDefaultBehaviorForm.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\Lang;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\Range;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangDefaultBehaviorForm
|
||||
* @package Thelia\Form\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangDefaultBehaviorForm extends BaseForm
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
* Form this you have to call add method on $this->formBuilder attribute :
|
||||
*
|
||||
* $this->formBuilder->add("name", "text")
|
||||
* ->add("email", "email", array(
|
||||
* "attr" => array(
|
||||
* "class" => "field"
|
||||
* ),
|
||||
* "label" => "email",
|
||||
* "constraints" => array(
|
||||
* new \Symfony\Component\Validator\Constraints\NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add('behavior', 'choice', array(
|
||||
'choices' => array(
|
||||
0 => Translator::getInstance()->trans("Strictly use the requested language"),
|
||||
1 => Translator::getInstance()->trans("Replace by the default language"),
|
||||
),
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans("If a translation is missing or incomplete :"),
|
||||
'label_attr' => array(
|
||||
'for' => 'defaultBehavior-form'
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_lang_defaultBehavior';
|
||||
}
|
||||
}
|
||||
@@ -20,39 +20,35 @@
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
namespace Thelia\Form\Lang;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class LanguageCreationForm extends BaseForm
|
||||
|
||||
/**
|
||||
* Class LangUpdateForm
|
||||
* @package Thelia\Form\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangUpdateForm extends LangCreateForm
|
||||
{
|
||||
protected function buildForm()
|
||||
|
||||
public function buildForm()
|
||||
{
|
||||
parent::buildForm();
|
||||
|
||||
$this->formBuilder
|
||||
->add("title", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Language title *"),
|
||||
"label_attr" => array(
|
||||
"for" => "title"
|
||||
->add('id', 'hidden', array(
|
||||
'constraints' => array(
|
||||
new NotBlank(),
|
||||
new GreaterThan(array('value' => 0))
|
||||
)
|
||||
))
|
||||
->add("isocode", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("ISO Code *"),
|
||||
"label_attr" => array(
|
||||
"for" => "isocode"
|
||||
)
|
||||
))
|
||||
;
|
||||
));
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_language_creation";
|
||||
return 'thelia_lang_update';
|
||||
}
|
||||
}
|
||||
}
|
||||
46
core/lib/Thelia/Form/Lang/LangUrlEvent.php
Normal file
46
core/lib/Thelia/Form/Lang/LangUrlEvent.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\Lang;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangUrlEvent
|
||||
* @package Thelia\Form\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangUrlEvent extends ActionEvent
|
||||
{
|
||||
protected $url = array();
|
||||
|
||||
public function addUrl($id, $url)
|
||||
{
|
||||
$this->url[$id] = $url;
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
}
|
||||
87
core/lib/Thelia/Form/Lang/LangUrlForm.php
Normal file
87
core/lib/Thelia/Form/Lang/LangUrlForm.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\Lang;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Thelia\Model\LangQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangUrlForm
|
||||
* @package Thelia\Form\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangUrlForm extends BaseForm
|
||||
{
|
||||
const LANG_PREFIX = 'url_';
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
* Form this you have to call add method on $this->formBuilder attribute :
|
||||
*
|
||||
* $this->formBuilder->add("name", "text")
|
||||
* ->add("email", "email", array(
|
||||
* "attr" => array(
|
||||
* "class" => "field"
|
||||
* ),
|
||||
* "label" => "email",
|
||||
* "constraints" => array(
|
||||
* new \Symfony\Component\Validator\Constraints\NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
foreach (LangQuery::create()->find() as $lang) {
|
||||
$this->formBuilder->add(
|
||||
self::LANG_PREFIX . $lang->getId(),
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"attr" => array(
|
||||
"tag" => "url",
|
||||
"url_id" => $lang->getId(),
|
||||
"url_title" => $lang->getTitle()
|
||||
),
|
||||
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_language_url';
|
||||
}
|
||||
}
|
||||
@@ -1,38 +1,31 @@
|
||||
<?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/>. */
|
||||
/* */
|
||||
/**********************************************************************************/
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
namespace Thelia\Coupon\Type;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 8/19/13
|
||||
* Time: 3:24 PM
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class RemoveXPercentForAttributeY extends RemoveXPercent
|
||||
class ProductDefaultSaleElementUpdateForm extends ProductSaleElementUpdateForm
|
||||
{
|
||||
|
||||
}
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_product_default_sale_element_update_form";
|
||||
}
|
||||
}
|
||||
@@ -25,28 +25,33 @@ namespace Thelia\Form;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Model\Currency;
|
||||
|
||||
class ProductDetailsModificationForm extends BaseForm
|
||||
class ProductSaleElementUpdateForm extends BaseForm
|
||||
{
|
||||
use StandardDescriptionFieldsTrait;
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("id", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("Prodcut ID *"),
|
||||
"label_attr" => array("for" => "product_id_field"),
|
||||
"constraints" => array(new GreaterThan(array('value' => 0)))
|
||||
->add("product_id", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("Product ID *"),
|
||||
"label_attr" => array("for" => "product_id_field"),
|
||||
"constraints" => array(new GreaterThan(array('value' => 0)))
|
||||
))
|
||||
->add("product_sale_element_id", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("Product sale element ID *"),
|
||||
"label_attr" => array("for" => "product_sale_element_id_field")
|
||||
))
|
||||
->add("reference", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Reference *"),
|
||||
"label_attr" => array("for" => "reference_field")
|
||||
))
|
||||
->add("price", "number", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Product base price excluding taxes *"),
|
||||
"label" => Translator::getInstance()->trans("Product price excluding taxes *"),
|
||||
"label_attr" => array("for" => "price_field")
|
||||
))
|
||||
->add("price_with_tax", "number", array(
|
||||
"label" => Translator::getInstance()->trans("Product base price including taxes *"),
|
||||
"label_attr" => array("for" => "price_with_tax_field")
|
||||
))
|
||||
->add("currency", "integer", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Price currency *"),
|
||||
@@ -64,11 +69,11 @@ class ProductDetailsModificationForm extends BaseForm
|
||||
))
|
||||
->add("quantity", "number", array(
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Current quantity *"),
|
||||
"label" => Translator::getInstance()->trans("Available quantity *"),
|
||||
"label_attr" => array("for" => "quantity_field")
|
||||
))
|
||||
->add("sale_price", "number", array(
|
||||
"label" => Translator::getInstance()->trans("Sale price *"),
|
||||
"label" => Translator::getInstance()->trans("Sale price without taxes *"),
|
||||
"label_attr" => array("for" => "price_with_tax_field")
|
||||
))
|
||||
->add("onsale", "integer", array(
|
||||
@@ -79,12 +84,23 @@ class ProductDetailsModificationForm extends BaseForm
|
||||
"label" => Translator::getInstance()->trans("Advertise this product as new"),
|
||||
"label_attr" => array("for" => "isnew_field")
|
||||
))
|
||||
|
||||
->add("isdefault", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("Is it the default product sale element ?"),
|
||||
"label_attr" => array("for" => "isdefault_field")
|
||||
))
|
||||
->add("ean_code", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("EAN Code"),
|
||||
"label_attr" => array("for" => "ean_code_field")
|
||||
))
|
||||
->add("use_exchange_rate", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("Apply exchange rates on price in %sym", array("%sym" => Currency::getDefaultCurrency()->getSymbol())),
|
||||
"label_attr" => array("for" => "use_exchange_rate_field")
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_product_details_modification";
|
||||
return "thelia_product_sale_element_update_form";
|
||||
}
|
||||
}
|
||||
98
core/lib/Thelia/Form/ProfileUpdateModuleAccessForm.php
Normal file
98
core/lib/Thelia/Form/ProfileUpdateModuleAccessForm.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\ProfileQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
/**
|
||||
* Class ProfileUpdateModuleAccessForm
|
||||
* @package Thelia\Form
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class ProfileUpdateModuleAccessForm extends BaseForm
|
||||
{
|
||||
const MODULE_ACCESS_FIELD_PREFIX = "module";
|
||||
|
||||
protected function buildForm($change_mode = false)
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array(
|
||||
"required" => true,
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
new Constraints\Callback(
|
||||
array(
|
||||
"methods" => array(
|
||||
array($this, "verifyProfileId"),
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
))
|
||||
;
|
||||
|
||||
foreach(ModuleQuery::create()->find() as $module) {
|
||||
$this->formBuilder->add(
|
||||
self::MODULE_ACCESS_FIELD_PREFIX . ':' . str_replace(".", ":", $module->getCode()),
|
||||
"choice",
|
||||
array(
|
||||
"choices" => array(
|
||||
AccessManager::VIEW => AccessManager::VIEW,
|
||||
AccessManager::CREATE => AccessManager::CREATE,
|
||||
AccessManager::UPDATE => AccessManager::UPDATE,
|
||||
AccessManager::DELETE => AccessManager::DELETE,
|
||||
),
|
||||
"attr" => array(
|
||||
"tag" => "modules",
|
||||
"module_code" => $module->getCode(),
|
||||
),
|
||||
"multiple" => true,
|
||||
"constraints" => array(
|
||||
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_profile_module_access_modification";
|
||||
}
|
||||
|
||||
public function verifyProfileId($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$profile = ProfileQuery::create()
|
||||
->findPk($value);
|
||||
|
||||
if (null === $profile) {
|
||||
$context->addViolation("Profile ID not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
98
core/lib/Thelia/Form/ProfileUpdateResourceAccessForm.php
Normal file
98
core/lib/Thelia/Form/ProfileUpdateResourceAccessForm.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\ProfileQuery;
|
||||
use Thelia\Model\ResourceQuery;
|
||||
|
||||
/**
|
||||
* Class ProfileUpdateResourceAccessForm
|
||||
* @package Thelia\Form
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class ProfileUpdateResourceAccessForm extends BaseForm
|
||||
{
|
||||
const RESOURCE_ACCESS_FIELD_PREFIX = "resource";
|
||||
|
||||
protected function buildForm($change_mode = false)
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array(
|
||||
"required" => true,
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
new Constraints\Callback(
|
||||
array(
|
||||
"methods" => array(
|
||||
array($this, "verifyProfileId"),
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
))
|
||||
;
|
||||
|
||||
foreach(ResourceQuery::create()->find() as $resource) {
|
||||
$this->formBuilder->add(
|
||||
self::RESOURCE_ACCESS_FIELD_PREFIX . ':' . str_replace(".", ":", $resource->getCode()),
|
||||
"choice",
|
||||
array(
|
||||
"choices" => array(
|
||||
AccessManager::VIEW => AccessManager::VIEW,
|
||||
AccessManager::CREATE => AccessManager::CREATE,
|
||||
AccessManager::UPDATE => AccessManager::UPDATE,
|
||||
AccessManager::DELETE => AccessManager::DELETE,
|
||||
),
|
||||
"attr" => array(
|
||||
"tag" => "resources",
|
||||
"resource_code" => $resource->getCode(),
|
||||
),
|
||||
"multiple" => true,
|
||||
"constraints" => array(
|
||||
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_profile_resource_access_modification";
|
||||
}
|
||||
|
||||
public function verifyProfileId($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$profile = ProfileQuery::create()
|
||||
->findPk($value);
|
||||
|
||||
if (null === $profile) {
|
||||
$context->addViolation("Profile ID not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ use Thelia\Core\Security\Role\Role;
|
||||
|
||||
use Thelia\Model\Base\Admin as BaseAdmin;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'admin' table.
|
||||
@@ -24,6 +25,8 @@ use Propel\Runtime\Connection\ConnectionInterface;
|
||||
*/
|
||||
class Admin extends BaseAdmin implements UserInterface
|
||||
{
|
||||
use ModelEventDispatcherTrait;
|
||||
|
||||
public function getPermissions()
|
||||
{
|
||||
$profileId = $this->getProfileId();
|
||||
|
||||
@@ -95,10 +95,18 @@ abstract class Country implements ActiveRecordInterface
|
||||
|
||||
/**
|
||||
* The value for the by_default field.
|
||||
* Note: this column has a database default value of: 0
|
||||
* @var int
|
||||
*/
|
||||
protected $by_default;
|
||||
|
||||
/**
|
||||
* The value for the shop_country field.
|
||||
* Note: this column has a database default value of: false
|
||||
* @var boolean
|
||||
*/
|
||||
protected $shop_country;
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
* @var string
|
||||
@@ -174,11 +182,25 @@ abstract class Country implements ActiveRecordInterface
|
||||
*/
|
||||
protected $countryI18nsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* Applies default values to this object.
|
||||
* This method should be called from the object's constructor (or
|
||||
* equivalent initialization method).
|
||||
* @see __construct()
|
||||
*/
|
||||
public function applyDefaultValues()
|
||||
{
|
||||
$this->by_default = 0;
|
||||
$this->shop_country = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes internal state of Thelia\Model\Base\Country object.
|
||||
* @see applyDefaults()
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->applyDefaultValues();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -498,6 +520,17 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this->by_default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [shop_country] column value.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShopCountry()
|
||||
{
|
||||
|
||||
return $this->shop_country;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [created_at] column value.
|
||||
*
|
||||
@@ -668,6 +701,35 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this;
|
||||
} // setByDefault()
|
||||
|
||||
/**
|
||||
* Sets the value of the [shop_country] column.
|
||||
* Non-boolean arguments are converted using the following rules:
|
||||
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
|
||||
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
|
||||
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
|
||||
*
|
||||
* @param boolean|integer|string $v The new value
|
||||
* @return \Thelia\Model\Country The current object (for fluent API support)
|
||||
*/
|
||||
public function setShopCountry($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
if (is_string($v)) {
|
||||
$v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
|
||||
} else {
|
||||
$v = (boolean) $v;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->shop_country !== $v) {
|
||||
$this->shop_country = $v;
|
||||
$this->modifiedColumns[] = CountryTableMap::SHOP_COUNTRY;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setShopCountry()
|
||||
|
||||
/**
|
||||
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
||||
*
|
||||
@@ -720,6 +782,14 @@ abstract class Country implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasOnlyDefaultValues()
|
||||
{
|
||||
if ($this->by_default !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->shop_country !== false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// otherwise, everything was equal, so return TRUE
|
||||
return true;
|
||||
} // hasOnlyDefaultValues()
|
||||
@@ -765,13 +835,16 @@ abstract class Country implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CountryTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->by_default = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CountryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CountryTableMap::translateFieldName('ShopCountry', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->shop_country = (null !== $col) ? (boolean) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CountryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
@@ -784,7 +857,7 @@ abstract class Country implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 8; // 8 = CountryTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 9; // 9 = CountryTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\Country object", 0, $e);
|
||||
@@ -1095,6 +1168,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(CountryTableMap::BY_DEFAULT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'BY_DEFAULT';
|
||||
}
|
||||
if ($this->isColumnModified(CountryTableMap::SHOP_COUNTRY)) {
|
||||
$modifiedColumns[':p' . $index++] = 'SHOP_COUNTRY';
|
||||
}
|
||||
if ($this->isColumnModified(CountryTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
}
|
||||
@@ -1130,6 +1206,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
case 'BY_DEFAULT':
|
||||
$stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'SHOP_COUNTRY':
|
||||
$stmt->bindValue($identifier, (int) $this->shop_country, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'CREATED_AT':
|
||||
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
@@ -1217,9 +1296,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this->getByDefault();
|
||||
break;
|
||||
case 6:
|
||||
return $this->getCreatedAt();
|
||||
return $this->getShopCountry();
|
||||
break;
|
||||
case 7:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 8:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
default:
|
||||
@@ -1257,8 +1339,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
$keys[3] => $this->getIsoalpha2(),
|
||||
$keys[4] => $this->getIsoalpha3(),
|
||||
$keys[5] => $this->getByDefault(),
|
||||
$keys[6] => $this->getCreatedAt(),
|
||||
$keys[7] => $this->getUpdatedAt(),
|
||||
$keys[6] => $this->getShopCountry(),
|
||||
$keys[7] => $this->getCreatedAt(),
|
||||
$keys[8] => $this->getUpdatedAt(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach ($virtualColumns as $key => $virtualColumn) {
|
||||
@@ -1331,9 +1414,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
$this->setByDefault($value);
|
||||
break;
|
||||
case 6:
|
||||
$this->setCreatedAt($value);
|
||||
$this->setShopCountry($value);
|
||||
break;
|
||||
case 7:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 8:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -1366,8 +1452,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
if (array_key_exists($keys[3], $arr)) $this->setIsoalpha2($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setIsoalpha3($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setByDefault($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setShopCountry($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
|
||||
if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1385,6 +1472,7 @@ abstract class Country implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(CountryTableMap::ISOALPHA2)) $criteria->add(CountryTableMap::ISOALPHA2, $this->isoalpha2);
|
||||
if ($this->isColumnModified(CountryTableMap::ISOALPHA3)) $criteria->add(CountryTableMap::ISOALPHA3, $this->isoalpha3);
|
||||
if ($this->isColumnModified(CountryTableMap::BY_DEFAULT)) $criteria->add(CountryTableMap::BY_DEFAULT, $this->by_default);
|
||||
if ($this->isColumnModified(CountryTableMap::SHOP_COUNTRY)) $criteria->add(CountryTableMap::SHOP_COUNTRY, $this->shop_country);
|
||||
if ($this->isColumnModified(CountryTableMap::CREATED_AT)) $criteria->add(CountryTableMap::CREATED_AT, $this->created_at);
|
||||
if ($this->isColumnModified(CountryTableMap::UPDATED_AT)) $criteria->add(CountryTableMap::UPDATED_AT, $this->updated_at);
|
||||
|
||||
@@ -1455,6 +1543,7 @@ abstract class Country implements ActiveRecordInterface
|
||||
$copyObj->setIsoalpha2($this->getIsoalpha2());
|
||||
$copyObj->setIsoalpha3($this->getIsoalpha3());
|
||||
$copyObj->setByDefault($this->getByDefault());
|
||||
$copyObj->setShopCountry($this->getShopCountry());
|
||||
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||
$copyObj->setUpdatedAt($this->getUpdatedAt());
|
||||
|
||||
@@ -2359,10 +2448,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
$this->isoalpha2 = null;
|
||||
$this->isoalpha3 = null;
|
||||
$this->by_default = null;
|
||||
$this->shop_country = null;
|
||||
$this->created_at = null;
|
||||
$this->updated_at = null;
|
||||
$this->alreadyInSave = false;
|
||||
$this->clearAllReferences();
|
||||
$this->applyDefaultValues();
|
||||
$this->resetModified();
|
||||
$this->setNew(true);
|
||||
$this->setDeleted(false);
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method ChildCountryQuery orderByIsoalpha2($order = Criteria::ASC) Order by the isoalpha2 column
|
||||
* @method ChildCountryQuery orderByIsoalpha3($order = Criteria::ASC) Order by the isoalpha3 column
|
||||
* @method ChildCountryQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column
|
||||
* @method ChildCountryQuery orderByShopCountry($order = Criteria::ASC) Order by the shop_country column
|
||||
* @method ChildCountryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildCountryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
@@ -37,6 +38,7 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method ChildCountryQuery groupByIsoalpha2() Group by the isoalpha2 column
|
||||
* @method ChildCountryQuery groupByIsoalpha3() Group by the isoalpha3 column
|
||||
* @method ChildCountryQuery groupByByDefault() Group by the by_default column
|
||||
* @method ChildCountryQuery groupByShopCountry() Group by the shop_country column
|
||||
* @method ChildCountryQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildCountryQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
@@ -69,6 +71,7 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method ChildCountry findOneByIsoalpha2(string $isoalpha2) Return the first ChildCountry filtered by the isoalpha2 column
|
||||
* @method ChildCountry findOneByIsoalpha3(string $isoalpha3) Return the first ChildCountry filtered by the isoalpha3 column
|
||||
* @method ChildCountry findOneByByDefault(int $by_default) Return the first ChildCountry filtered by the by_default column
|
||||
* @method ChildCountry findOneByShopCountry(boolean $shop_country) Return the first ChildCountry filtered by the shop_country column
|
||||
* @method ChildCountry findOneByCreatedAt(string $created_at) Return the first ChildCountry filtered by the created_at column
|
||||
* @method ChildCountry findOneByUpdatedAt(string $updated_at) Return the first ChildCountry filtered by the updated_at column
|
||||
*
|
||||
@@ -78,6 +81,7 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method array findByIsoalpha2(string $isoalpha2) Return ChildCountry objects filtered by the isoalpha2 column
|
||||
* @method array findByIsoalpha3(string $isoalpha3) Return ChildCountry objects filtered by the isoalpha3 column
|
||||
* @method array findByByDefault(int $by_default) Return ChildCountry objects filtered by the by_default column
|
||||
* @method array findByShopCountry(boolean $shop_country) Return ChildCountry objects filtered by the shop_country column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildCountry objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildCountry objects filtered by the updated_at column
|
||||
*
|
||||
@@ -168,7 +172,7 @@ abstract class CountryQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, AREA_ID, ISOCODE, ISOALPHA2, ISOALPHA3, BY_DEFAULT, CREATED_AT, UPDATED_AT FROM country WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, AREA_ID, ISOCODE, ISOALPHA2, ISOALPHA3, BY_DEFAULT, SHOP_COUNTRY, CREATED_AT, UPDATED_AT FROM country WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -469,6 +473,33 @@ abstract class CountryQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(CountryTableMap::BY_DEFAULT, $byDefault, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the shop_country column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByShopCountry(true); // WHERE shop_country = true
|
||||
* $query->filterByShopCountry('yes'); // WHERE shop_country = true
|
||||
* </code>
|
||||
*
|
||||
* @param boolean|string $shopCountry The value to use as filter.
|
||||
* Non-boolean arguments are converted using the following rules:
|
||||
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
|
||||
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
|
||||
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByShopCountry($shopCountry = null, $comparison = null)
|
||||
{
|
||||
if (is_string($shopCountry)) {
|
||||
$shop_country = in_array(strtolower($shopCountry), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CountryTableMap::SHOP_COUNTRY, $shopCountry, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the created_at column
|
||||
*
|
||||
|
||||
@@ -1008,10 +1008,9 @@ abstract class Currency implements ActiveRecordInterface
|
||||
|
||||
if ($this->cartsScheduledForDeletion !== null) {
|
||||
if (!$this->cartsScheduledForDeletion->isEmpty()) {
|
||||
foreach ($this->cartsScheduledForDeletion as $cart) {
|
||||
// need to save related object because we set the relation to null
|
||||
$cart->save($con);
|
||||
}
|
||||
\Thelia\Model\CartQuery::create()
|
||||
->filterByPrimaryKeys($this->cartsScheduledForDeletion->getPrimaryKeys(false))
|
||||
->delete($con);
|
||||
$this->cartsScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1350,10 +1350,9 @@ abstract class Customer implements ActiveRecordInterface
|
||||
|
||||
if ($this->cartsScheduledForDeletion !== null) {
|
||||
if (!$this->cartsScheduledForDeletion->isEmpty()) {
|
||||
foreach ($this->cartsScheduledForDeletion as $cart) {
|
||||
// need to save related object because we set the relation to null
|
||||
$cart->save($con);
|
||||
}
|
||||
\Thelia\Model\CartQuery::create()
|
||||
->filterByPrimaryKeys($this->cartsScheduledForDeletion->getPrimaryKeys(false))
|
||||
->delete($con);
|
||||
$this->cartsScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2733,7 +2733,10 @@ abstract class Module implements ActiveRecordInterface
|
||||
$profileModulesToDelete = $this->getProfileModules(new Criteria(), $con)->diff($profileModules);
|
||||
|
||||
|
||||
$this->profileModulesScheduledForDeletion = $profileModulesToDelete;
|
||||
//since at least one column in the foreign key is at the same time a PK
|
||||
//we can not just set a PK to NULL in the lines below. We have to store
|
||||
//a backup of all values, so we are able to manipulate these items based on the onDelete value later.
|
||||
$this->profileModulesScheduledForDeletion = clone $profileModulesToDelete;
|
||||
|
||||
foreach ($profileModulesToDelete as $profileModuleRemoved) {
|
||||
$profileModuleRemoved->setModule(null);
|
||||
@@ -2826,7 +2829,7 @@ abstract class Module implements ActiveRecordInterface
|
||||
$this->profileModulesScheduledForDeletion = clone $this->collProfileModules;
|
||||
$this->profileModulesScheduledForDeletion->clear();
|
||||
}
|
||||
$this->profileModulesScheduledForDeletion[]= $profileModule;
|
||||
$this->profileModulesScheduledForDeletion[]= clone $profileModule;
|
||||
$profileModule->setModule(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -823,7 +823,7 @@ abstract class ModuleQuery extends ModelCriteria
|
||||
*
|
||||
* @return ChildModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinProfileModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
public function joinProfileModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('ProfileModule');
|
||||
@@ -858,7 +858,7 @@ abstract class ModuleQuery extends ModelCriteria
|
||||
*
|
||||
* @return \Thelia\Model\ProfileModuleQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useProfileModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
public function useProfileModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinProfileModule($relationAlias, $joinType)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Thelia\Model\Base;
|
||||
|
||||
use \DateTime;
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Propel\Runtime\Propel;
|
||||
@@ -15,8 +14,6 @@ use Propel\Runtime\Exception\BadMethodCallException;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Map\TableMap;
|
||||
use Propel\Runtime\Parser\AbstractParser;
|
||||
use Propel\Runtime\Util\PropelDateTime;
|
||||
use Thelia\Model\Newsletter as ChildNewsletter;
|
||||
use Thelia\Model\NewsletterQuery as ChildNewsletterQuery;
|
||||
use Thelia\Model\Map\NewsletterTableMap;
|
||||
|
||||
@@ -78,24 +75,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
*/
|
||||
protected $lastname;
|
||||
|
||||
/**
|
||||
* The value for the locale field.
|
||||
* @var string
|
||||
*/
|
||||
protected $locale;
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
* @var string
|
||||
*/
|
||||
protected $created_at;
|
||||
|
||||
/**
|
||||
* The value for the updated_at field.
|
||||
* @var string
|
||||
*/
|
||||
protected $updated_at;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
@@ -406,57 +385,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
return $this->lastname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [locale] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [created_at] column value.
|
||||
*
|
||||
*
|
||||
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||
* If format is NULL, then the raw \DateTime object will be returned.
|
||||
*
|
||||
* @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
|
||||
*
|
||||
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||
*/
|
||||
public function getCreatedAt($format = NULL)
|
||||
{
|
||||
if ($format === null) {
|
||||
return $this->created_at;
|
||||
} else {
|
||||
return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [updated_at] column value.
|
||||
*
|
||||
*
|
||||
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||
* If format is NULL, then the raw \DateTime object will be returned.
|
||||
*
|
||||
* @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
|
||||
*
|
||||
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||
*/
|
||||
public function getUpdatedAt($format = NULL)
|
||||
{
|
||||
if ($format === null) {
|
||||
return $this->updated_at;
|
||||
} else {
|
||||
return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
@@ -541,69 +469,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
return $this;
|
||||
} // setLastname()
|
||||
|
||||
/**
|
||||
* Set the value of [locale] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return \Thelia\Model\Newsletter The current object (for fluent API support)
|
||||
*/
|
||||
public function setLocale($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->locale !== $v) {
|
||||
$this->locale = $v;
|
||||
$this->modifiedColumns[] = NewsletterTableMap::LOCALE;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setLocale()
|
||||
|
||||
/**
|
||||
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
||||
*
|
||||
* @param mixed $v string, integer (timestamp), or \DateTime value.
|
||||
* Empty strings are treated as NULL.
|
||||
* @return \Thelia\Model\Newsletter The current object (for fluent API support)
|
||||
*/
|
||||
public function setCreatedAt($v)
|
||||
{
|
||||
$dt = PropelDateTime::newInstance($v, null, '\DateTime');
|
||||
if ($this->created_at !== null || $dt !== null) {
|
||||
if ($dt !== $this->created_at) {
|
||||
$this->created_at = $dt;
|
||||
$this->modifiedColumns[] = NewsletterTableMap::CREATED_AT;
|
||||
}
|
||||
} // if either are not null
|
||||
|
||||
|
||||
return $this;
|
||||
} // setCreatedAt()
|
||||
|
||||
/**
|
||||
* Sets the value of [updated_at] column to a normalized version of the date/time value specified.
|
||||
*
|
||||
* @param mixed $v string, integer (timestamp), or \DateTime value.
|
||||
* Empty strings are treated as NULL.
|
||||
* @return \Thelia\Model\Newsletter The current object (for fluent API support)
|
||||
*/
|
||||
public function setUpdatedAt($v)
|
||||
{
|
||||
$dt = PropelDateTime::newInstance($v, null, '\DateTime');
|
||||
if ($this->updated_at !== null || $dt !== null) {
|
||||
if ($dt !== $this->updated_at) {
|
||||
$this->updated_at = $dt;
|
||||
$this->modifiedColumns[] = NewsletterTableMap::UPDATED_AT;
|
||||
}
|
||||
} // if either are not null
|
||||
|
||||
|
||||
return $this;
|
||||
} // setUpdatedAt()
|
||||
|
||||
/**
|
||||
* Indicates whether the columns in this object are only set to default values.
|
||||
*
|
||||
@@ -652,21 +517,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : NewsletterTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->lastname = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : NewsletterTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->locale = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : NewsletterTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : NewsletterTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
@@ -675,7 +525,7 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 7; // 7 = NewsletterTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 4; // 4 = NewsletterTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\Newsletter object", 0, $e);
|
||||
@@ -806,19 +656,8 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
$ret = $this->preSave($con);
|
||||
if ($isInsert) {
|
||||
$ret = $ret && $this->preInsert($con);
|
||||
// timestampable behavior
|
||||
if (!$this->isColumnModified(NewsletterTableMap::CREATED_AT)) {
|
||||
$this->setCreatedAt(time());
|
||||
}
|
||||
if (!$this->isColumnModified(NewsletterTableMap::UPDATED_AT)) {
|
||||
$this->setUpdatedAt(time());
|
||||
}
|
||||
} else {
|
||||
$ret = $ret && $this->preUpdate($con);
|
||||
// timestampable behavior
|
||||
if ($this->isModified() && !$this->isColumnModified(NewsletterTableMap::UPDATED_AT)) {
|
||||
$this->setUpdatedAt(time());
|
||||
}
|
||||
}
|
||||
if ($ret) {
|
||||
$affectedRows = $this->doSave($con);
|
||||
@@ -907,15 +746,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(NewsletterTableMap::LASTNAME)) {
|
||||
$modifiedColumns[':p' . $index++] = 'LASTNAME';
|
||||
}
|
||||
if ($this->isColumnModified(NewsletterTableMap::LOCALE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'LOCALE';
|
||||
}
|
||||
if ($this->isColumnModified(NewsletterTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
}
|
||||
if ($this->isColumnModified(NewsletterTableMap::UPDATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'UPDATED_AT';
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'INSERT INTO newsletter (%s) VALUES (%s)',
|
||||
@@ -939,15 +769,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
case 'LASTNAME':
|
||||
$stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'LOCALE':
|
||||
$stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'CREATED_AT':
|
||||
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'UPDATED_AT':
|
||||
$stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$stmt->execute();
|
||||
@@ -1022,15 +843,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
case 3:
|
||||
return $this->getLastname();
|
||||
break;
|
||||
case 4:
|
||||
return $this->getLocale();
|
||||
break;
|
||||
case 5:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 6:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
@@ -1063,9 +875,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
$keys[1] => $this->getEmail(),
|
||||
$keys[2] => $this->getFirstname(),
|
||||
$keys[3] => $this->getLastname(),
|
||||
$keys[4] => $this->getLocale(),
|
||||
$keys[5] => $this->getCreatedAt(),
|
||||
$keys[6] => $this->getUpdatedAt(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach ($virtualColumns as $key => $virtualColumn) {
|
||||
@@ -1117,15 +926,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
case 3:
|
||||
$this->setLastname($value);
|
||||
break;
|
||||
case 4:
|
||||
$this->setLocale($value);
|
||||
break;
|
||||
case 5:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 6:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
@@ -1154,9 +954,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
if (array_key_exists($keys[1], $arr)) $this->setEmail($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setFirstname($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setLastname($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setLocale($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1172,9 +969,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(NewsletterTableMap::EMAIL)) $criteria->add(NewsletterTableMap::EMAIL, $this->email);
|
||||
if ($this->isColumnModified(NewsletterTableMap::FIRSTNAME)) $criteria->add(NewsletterTableMap::FIRSTNAME, $this->firstname);
|
||||
if ($this->isColumnModified(NewsletterTableMap::LASTNAME)) $criteria->add(NewsletterTableMap::LASTNAME, $this->lastname);
|
||||
if ($this->isColumnModified(NewsletterTableMap::LOCALE)) $criteria->add(NewsletterTableMap::LOCALE, $this->locale);
|
||||
if ($this->isColumnModified(NewsletterTableMap::CREATED_AT)) $criteria->add(NewsletterTableMap::CREATED_AT, $this->created_at);
|
||||
if ($this->isColumnModified(NewsletterTableMap::UPDATED_AT)) $criteria->add(NewsletterTableMap::UPDATED_AT, $this->updated_at);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
@@ -1241,9 +1035,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
$copyObj->setEmail($this->getEmail());
|
||||
$copyObj->setFirstname($this->getFirstname());
|
||||
$copyObj->setLastname($this->getLastname());
|
||||
$copyObj->setLocale($this->getLocale());
|
||||
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||
$copyObj->setUpdatedAt($this->getUpdatedAt());
|
||||
if ($makeNew) {
|
||||
$copyObj->setNew(true);
|
||||
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
|
||||
@@ -1281,9 +1072,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
$this->email = null;
|
||||
$this->firstname = null;
|
||||
$this->lastname = null;
|
||||
$this->locale = null;
|
||||
$this->created_at = null;
|
||||
$this->updated_at = null;
|
||||
$this->alreadyInSave = false;
|
||||
$this->clearAllReferences();
|
||||
$this->resetModified();
|
||||
@@ -1317,20 +1105,6 @@ abstract class Newsletter implements ActiveRecordInterface
|
||||
return (string) $this->exportTo(NewsletterTableMap::DEFAULT_STRING_FORMAT);
|
||||
}
|
||||
|
||||
// timestampable behavior
|
||||
|
||||
/**
|
||||
* Mark the current object so that the update date doesn't get updated during next save
|
||||
*
|
||||
* @return ChildNewsletter The current object (for fluent API support)
|
||||
*/
|
||||
public function keepUpdateDateUnchanged()
|
||||
{
|
||||
$this->modifiedColumns[] = NewsletterTableMap::UPDATED_AT;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Code to be run before persisting the object
|
||||
* @param ConnectionInterface $con
|
||||
|
||||
@@ -22,17 +22,11 @@ use Thelia\Model\Map\NewsletterTableMap;
|
||||
* @method ChildNewsletterQuery orderByEmail($order = Criteria::ASC) Order by the email column
|
||||
* @method ChildNewsletterQuery orderByFirstname($order = Criteria::ASC) Order by the firstname column
|
||||
* @method ChildNewsletterQuery orderByLastname($order = Criteria::ASC) Order by the lastname column
|
||||
* @method ChildNewsletterQuery orderByLocale($order = Criteria::ASC) Order by the locale column
|
||||
* @method ChildNewsletterQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildNewsletterQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
* @method ChildNewsletterQuery groupById() Group by the id column
|
||||
* @method ChildNewsletterQuery groupByEmail() Group by the email column
|
||||
* @method ChildNewsletterQuery groupByFirstname() Group by the firstname column
|
||||
* @method ChildNewsletterQuery groupByLastname() Group by the lastname column
|
||||
* @method ChildNewsletterQuery groupByLocale() Group by the locale column
|
||||
* @method ChildNewsletterQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildNewsletterQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
* @method ChildNewsletterQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildNewsletterQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
@@ -45,17 +39,11 @@ use Thelia\Model\Map\NewsletterTableMap;
|
||||
* @method ChildNewsletter findOneByEmail(string $email) Return the first ChildNewsletter filtered by the email column
|
||||
* @method ChildNewsletter findOneByFirstname(string $firstname) Return the first ChildNewsletter filtered by the firstname column
|
||||
* @method ChildNewsletter findOneByLastname(string $lastname) Return the first ChildNewsletter filtered by the lastname column
|
||||
* @method ChildNewsletter findOneByLocale(string $locale) Return the first ChildNewsletter filtered by the locale column
|
||||
* @method ChildNewsletter findOneByCreatedAt(string $created_at) Return the first ChildNewsletter filtered by the created_at column
|
||||
* @method ChildNewsletter findOneByUpdatedAt(string $updated_at) Return the first ChildNewsletter filtered by the updated_at column
|
||||
*
|
||||
* @method array findById(int $id) Return ChildNewsletter objects filtered by the id column
|
||||
* @method array findByEmail(string $email) Return ChildNewsletter objects filtered by the email column
|
||||
* @method array findByFirstname(string $firstname) Return ChildNewsletter objects filtered by the firstname column
|
||||
* @method array findByLastname(string $lastname) Return ChildNewsletter objects filtered by the lastname column
|
||||
* @method array findByLocale(string $locale) Return ChildNewsletter objects filtered by the locale column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildNewsletter objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildNewsletter objects filtered by the updated_at column
|
||||
*
|
||||
*/
|
||||
abstract class NewsletterQuery extends ModelCriteria
|
||||
@@ -144,7 +132,7 @@ abstract class NewsletterQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, EMAIL, FIRSTNAME, LASTNAME, LOCALE, CREATED_AT, UPDATED_AT FROM newsletter WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, EMAIL, FIRSTNAME, LASTNAME FROM newsletter WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -361,121 +349,6 @@ abstract class NewsletterQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(NewsletterTableMap::LASTNAME, $lastname, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the locale column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
|
||||
* $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $locale The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByLocale($locale = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($locale)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $locale)) {
|
||||
$locale = str_replace('*', '%', $locale);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(NewsletterTableMap::LOCALE, $locale, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the created_at column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
|
||||
* $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
|
||||
* $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $createdAt The value to use as filter.
|
||||
* Values can be integers (unix timestamps), DateTime objects, or strings.
|
||||
* Empty strings are treated as NULL.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCreatedAt($createdAt = null, $comparison = null)
|
||||
{
|
||||
if (is_array($createdAt)) {
|
||||
$useMinMax = false;
|
||||
if (isset($createdAt['min'])) {
|
||||
$this->addUsingAlias(NewsletterTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($createdAt['max'])) {
|
||||
$this->addUsingAlias(NewsletterTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(NewsletterTableMap::CREATED_AT, $createdAt, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the updated_at column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
|
||||
* $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
|
||||
* $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $updatedAt The value to use as filter.
|
||||
* Values can be integers (unix timestamps), DateTime objects, or strings.
|
||||
* Empty strings are treated as NULL.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
|
||||
{
|
||||
if (is_array($updatedAt)) {
|
||||
$useMinMax = false;
|
||||
if (isset($updatedAt['min'])) {
|
||||
$this->addUsingAlias(NewsletterTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($updatedAt['max'])) {
|
||||
$this->addUsingAlias(NewsletterTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(NewsletterTableMap::UPDATED_AT, $updatedAt, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
@@ -567,70 +440,4 @@ abstract class NewsletterQuery extends ModelCriteria
|
||||
}
|
||||
}
|
||||
|
||||
// timestampable behavior
|
||||
|
||||
/**
|
||||
* Filter by the latest updated
|
||||
*
|
||||
* @param int $nbDays Maximum age of the latest update in days
|
||||
*
|
||||
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||
*/
|
||||
public function recentlyUpdated($nbDays = 7)
|
||||
{
|
||||
return $this->addUsingAlias(NewsletterTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter by the latest created
|
||||
*
|
||||
* @param int $nbDays Maximum age of in days
|
||||
*
|
||||
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||
*/
|
||||
public function recentlyCreated($nbDays = 7)
|
||||
{
|
||||
return $this->addUsingAlias(NewsletterTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by update date desc
|
||||
*
|
||||
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||
*/
|
||||
public function lastUpdatedFirst()
|
||||
{
|
||||
return $this->addDescendingOrderByColumn(NewsletterTableMap::UPDATED_AT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by update date asc
|
||||
*
|
||||
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||
*/
|
||||
public function firstUpdatedFirst()
|
||||
{
|
||||
return $this->addAscendingOrderByColumn(NewsletterTableMap::UPDATED_AT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by create date desc
|
||||
*
|
||||
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||
*/
|
||||
public function lastCreatedFirst()
|
||||
{
|
||||
return $this->addDescendingOrderByColumn(NewsletterTableMap::CREATED_AT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by create date asc
|
||||
*
|
||||
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||
*/
|
||||
public function firstCreatedFirst()
|
||||
{
|
||||
return $this->addAscendingOrderByColumn(NewsletterTableMap::CREATED_AT);
|
||||
}
|
||||
|
||||
} // NewsletterQuery
|
||||
|
||||
@@ -82,6 +82,13 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
*/
|
||||
protected $promo_price;
|
||||
|
||||
/**
|
||||
* The value for the from_default_currency field.
|
||||
* Note: this column has a database default value of: false
|
||||
* @var boolean
|
||||
*/
|
||||
protected $from_default_currency;
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
* @var string
|
||||
@@ -112,11 +119,24 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Applies default values to this object.
|
||||
* This method should be called from the object's constructor (or
|
||||
* equivalent initialization method).
|
||||
* @see __construct()
|
||||
*/
|
||||
public function applyDefaultValues()
|
||||
{
|
||||
$this->from_default_currency = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes internal state of Thelia\Model\Base\ProductPrice object.
|
||||
* @see applyDefaults()
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->applyDefaultValues();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -414,6 +434,17 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
return $this->promo_price;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [from_default_currency] column value.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getFromDefaultCurrency()
|
||||
{
|
||||
|
||||
return $this->from_default_currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [created_at] column value.
|
||||
*
|
||||
@@ -546,6 +577,35 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
return $this;
|
||||
} // setPromoPrice()
|
||||
|
||||
/**
|
||||
* Sets the value of the [from_default_currency] column.
|
||||
* Non-boolean arguments are converted using the following rules:
|
||||
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
|
||||
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
|
||||
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
|
||||
*
|
||||
* @param boolean|integer|string $v The new value
|
||||
* @return \Thelia\Model\ProductPrice The current object (for fluent API support)
|
||||
*/
|
||||
public function setFromDefaultCurrency($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
if (is_string($v)) {
|
||||
$v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
|
||||
} else {
|
||||
$v = (boolean) $v;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->from_default_currency !== $v) {
|
||||
$this->from_default_currency = $v;
|
||||
$this->modifiedColumns[] = ProductPriceTableMap::FROM_DEFAULT_CURRENCY;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setFromDefaultCurrency()
|
||||
|
||||
/**
|
||||
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
||||
*
|
||||
@@ -598,6 +658,10 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasOnlyDefaultValues()
|
||||
{
|
||||
if ($this->from_default_currency !== false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// otherwise, everything was equal, so return TRUE
|
||||
return true;
|
||||
} // hasOnlyDefaultValues()
|
||||
@@ -637,13 +701,16 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductPriceTableMap::translateFieldName('PromoPrice', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->promo_price = (null !== $col) ? (double) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductPriceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductPriceTableMap::translateFieldName('FromDefaultCurrency', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->from_default_currency = (null !== $col) ? (boolean) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductPriceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductPriceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductPriceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
@@ -656,7 +723,7 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 6; // 6 = ProductPriceTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 7; // 7 = ProductPriceTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\ProductPrice object", 0, $e);
|
||||
@@ -911,6 +978,9 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(ProductPriceTableMap::PROMO_PRICE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'PROMO_PRICE';
|
||||
}
|
||||
if ($this->isColumnModified(ProductPriceTableMap::FROM_DEFAULT_CURRENCY)) {
|
||||
$modifiedColumns[':p' . $index++] = 'FROM_DEFAULT_CURRENCY';
|
||||
}
|
||||
if ($this->isColumnModified(ProductPriceTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
}
|
||||
@@ -940,6 +1010,9 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
case 'PROMO_PRICE':
|
||||
$stmt->bindValue($identifier, $this->promo_price, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'FROM_DEFAULT_CURRENCY':
|
||||
$stmt->bindValue($identifier, (int) $this->from_default_currency, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'CREATED_AT':
|
||||
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
@@ -1014,9 +1087,12 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
return $this->getPromoPrice();
|
||||
break;
|
||||
case 4:
|
||||
return $this->getCreatedAt();
|
||||
return $this->getFromDefaultCurrency();
|
||||
break;
|
||||
case 5:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 6:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
default:
|
||||
@@ -1052,8 +1128,9 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
$keys[1] => $this->getCurrencyId(),
|
||||
$keys[2] => $this->getPrice(),
|
||||
$keys[3] => $this->getPromoPrice(),
|
||||
$keys[4] => $this->getCreatedAt(),
|
||||
$keys[5] => $this->getUpdatedAt(),
|
||||
$keys[4] => $this->getFromDefaultCurrency(),
|
||||
$keys[5] => $this->getCreatedAt(),
|
||||
$keys[6] => $this->getUpdatedAt(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach ($virtualColumns as $key => $virtualColumn) {
|
||||
@@ -1114,9 +1191,12 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
$this->setPromoPrice($value);
|
||||
break;
|
||||
case 4:
|
||||
$this->setCreatedAt($value);
|
||||
$this->setFromDefaultCurrency($value);
|
||||
break;
|
||||
case 5:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 6:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -1147,8 +1227,9 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
if (array_key_exists($keys[1], $arr)) $this->setCurrencyId($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setPrice($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setPromoPrice($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setFromDefaultCurrency($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1164,6 +1245,7 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(ProductPriceTableMap::CURRENCY_ID)) $criteria->add(ProductPriceTableMap::CURRENCY_ID, $this->currency_id);
|
||||
if ($this->isColumnModified(ProductPriceTableMap::PRICE)) $criteria->add(ProductPriceTableMap::PRICE, $this->price);
|
||||
if ($this->isColumnModified(ProductPriceTableMap::PROMO_PRICE)) $criteria->add(ProductPriceTableMap::PROMO_PRICE, $this->promo_price);
|
||||
if ($this->isColumnModified(ProductPriceTableMap::FROM_DEFAULT_CURRENCY)) $criteria->add(ProductPriceTableMap::FROM_DEFAULT_CURRENCY, $this->from_default_currency);
|
||||
if ($this->isColumnModified(ProductPriceTableMap::CREATED_AT)) $criteria->add(ProductPriceTableMap::CREATED_AT, $this->created_at);
|
||||
if ($this->isColumnModified(ProductPriceTableMap::UPDATED_AT)) $criteria->add(ProductPriceTableMap::UPDATED_AT, $this->updated_at);
|
||||
|
||||
@@ -1240,6 +1322,7 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
$copyObj->setCurrencyId($this->getCurrencyId());
|
||||
$copyObj->setPrice($this->getPrice());
|
||||
$copyObj->setPromoPrice($this->getPromoPrice());
|
||||
$copyObj->setFromDefaultCurrency($this->getFromDefaultCurrency());
|
||||
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||
$copyObj->setUpdatedAt($this->getUpdatedAt());
|
||||
if ($makeNew) {
|
||||
@@ -1380,10 +1463,12 @@ abstract class ProductPrice implements ActiveRecordInterface
|
||||
$this->currency_id = null;
|
||||
$this->price = null;
|
||||
$this->promo_price = null;
|
||||
$this->from_default_currency = null;
|
||||
$this->created_at = null;
|
||||
$this->updated_at = null;
|
||||
$this->alreadyInSave = false;
|
||||
$this->clearAllReferences();
|
||||
$this->applyDefaultValues();
|
||||
$this->resetModified();
|
||||
$this->setNew(true);
|
||||
$this->setDeleted(false);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user