# By Manuel Raynaud (18) and others
# Via Manuel Raynaud (5) and others
* 'master' of https://github.com/thelia/thelia: (45 commits)
  Implemented "Remember Me" feature on admin. Started template management
  Added Templates events
  First version of installation wizard
  tax engine retriever
  allow address removal from front
  Insert pagination inside tfoot
  allow update customer address in front tempalte
  allow to create a new address
  allow to make an address as default on update action
  Finished attributes management
  Fixed action column alignment
  Fixed duplication parameter check regexp
  absoluteUrl prevetn duplicate parameters in generated URL
  fix test suite
  fix current url bug + fix empty loop pagination exception
  add accessDenied method
  add helper checkXmlHttpRequest
  don't delete address if this is address is a default one
  AttributesAv management
  update cart model
  ...
This commit is contained in:
gmorel
2013-09-16 10:04:03 +02:00
209 changed files with 23734 additions and 4721 deletions

View File

@@ -22,10 +22,14 @@
/*************************************************************************************/
namespace Thelia\Action;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Propel;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\AddressCreateOrUpdateEvent;
use Thelia\Core\Event\AddressEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Address as AddressModel;
use Thelia\Model\Map\AddressTableMap;
/**
* Class Address
@@ -49,31 +53,51 @@ class Address extends BaseAction implements EventSubscriberInterface
$this->createOrUpdate($addressModel, $event);
}
public function delete(AddressEvent $event)
{
$address = $event->getAddress();
$address->delete();
}
protected function createOrUpdate(AddressModel $addressModel, AddressCreateOrUpdateEvent $event)
{
$addressModel->setDispatcher($this->getDispatcher());
$con = Propel::getWriteConnection(AddressTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
if ($addressModel->isNew()) {
$addressModel->setLabel($event->getLabel());
}
if ($addressModel->isNew()) {
$addressModel->setLabel($event->getLabel());
$addressModel
->setTitleId($event->getTitle())
->setFirstname($event->getFirstname())
->setLastname($event->getLastname())
->setAddress1($event->getAddress1())
->setAddress2($event->getAddress2())
->setAddress3($event->getAddress3())
->setZipcode($event->getZipcode())
->setCity($event->getCity())
->setCountryId($event->getCountry())
->setCellphone($event->getCellphone())
->setPhone($event->getPhone())
->setCompany($event->getCompany())
->save()
;
if($event->getIsDefault()) {
$addressModel->makeItDefault();
}
$event->setAddress($addressModel);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
$addressModel
->setTitleId($event->getTitle())
->setFirstname($event->getFirstname())
->setLastname($event->getLastname())
->setAddress1($event->getAddress1())
->setAddress2($event->getAddress2())
->setAddress3($event->getAddress3())
->setZipcode($event->getZipcode())
->setCity($event->getCity())
->setCountryId($event->getCountry())
->setCellphone($event->getCellphone())
->setPhone($event->getPhone())
->setCompany($event->getCompany())
->save()
;
$event->setAddress($addressModel);
}
/**
@@ -100,7 +124,8 @@ class Address extends BaseAction implements EventSubscriberInterface
{
return array(
TheliaEvents::ADDRESS_CREATE => array("create", 128),
TheliaEvents::ADDRESS_UPDATE => array("update", 128)
TheliaEvents::ADDRESS_UPDATE => array("update", 128),
TheliaEvents::ADDRESS_DELETE => array("delete", 128)
);
}
}

View File

@@ -0,0 +1,175 @@
<?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\AttributeQuery;
use Thelia\Model\Attribute as AttributeModel;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\AttributeUpdateEvent;
use Thelia\Core\Event\AttributeCreateEvent;
use Thelia\Core\Event\AttributeDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Model\AttributeAv;
use Thelia\Model\AttributeAvQuery;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\CategoryEvent;
use Thelia\Core\Event\AttributeEvent;
use Thelia\Model\AttributeTemplate;
use Thelia\Model\AttributeTemplateQuery;
class Attribute extends BaseAction implements EventSubscriberInterface
{
/**
* Create a new attribute entry
*
* @param AttributeCreateEvent $event
*/
public function create(AttributeCreateEvent $event)
{
$attribute = new AttributeModel();
$attribute
->setDispatcher($this->getDispatcher())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->save()
;
$event->setAttribute($attribute);
// Add atribute to all product templates if required
if ($event->getAddToAllTemplates() != 0) {
// TODO: add to all product template
}
}
/**
* Change a product attribute
*
* @param AttributeUpdateEvent $event
*/
public function update(AttributeUpdateEvent $event)
{
$search = AttributeQuery::create();
if (null !== $attribute = AttributeQuery::create()->findPk($event->getAttributeId())) {
$attribute
->setDispatcher($this->getDispatcher())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
->setChapo($event->getChapo())
->setPostscriptum($event->getPostscriptum())
->save();
$event->setAttribute($attribute);
}
}
/**
* Delete a product attribute entry
*
* @param AttributeDeleteEvent $event
*/
public function delete(AttributeDeleteEvent $event)
{
if (null !== ($attribute = AttributeQuery::create()->findPk($event->getAttributeId()))) {
$attribute
->setDispatcher($this->getDispatcher())
->delete()
;
$event->setAttribute($attribute);
}
}
/**
* Changes position, selecting absolute ou relative change.
*
* @param CategoryChangePositionEvent $event
*/
public function updatePosition(UpdatePositionEvent $event)
{
if (null !== $attribute = AttributeQuery::create()->findPk($event->getObjectId())) {
$attribute->setDispatcher($this->getDispatcher());
$mode = $event->getMode();
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
return $attribute->changeAbsolutePosition($event->getPosition());
else if ($mode == UpdatePositionEvent::POSITION_UP)
return $attribute->movePositionUp();
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
return $attribute->movePositionDown();
}
}
public function addToAllTemplates(AttributeEvent $event)
{
$templates = AttributeTemplateQuery::create()->find();
foreach($templates as $template) {
$pat = new AttributeTemplate();
$pat->setTemplate($template->getId())
->setAttributeId($event->getAttribute()->getId())
->save();
}
}
public function removeFromAllTemplates(AttributeEvent $event)
{
// Delete this attribute from all product templates
AttributeTemplateQuery::create()->filterByAttributeId($event->getAttribute()->getId())->delete();
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::ATTRIBUTE_CREATE => array("create", 128),
TheliaEvents::ATTRIBUTE_UPDATE => array("update", 128),
TheliaEvents::ATTRIBUTE_DELETE => array("delete", 128),
TheliaEvents::ATTRIBUTE_UPDATE_POSITION => array("updatePosition", 128),
TheliaEvents::ATTRIBUTE_REMOVE_FROM_ALL_TEMPLATES => array("removeFromAllTemplates", 128),
TheliaEvents::ATTRIBUTE_ADD_TO_ALL_TEMPLATES => array("addToAllTemplates", 128),
);
}
}

View File

@@ -0,0 +1,143 @@
<?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\AttributeAvQuery;
use Thelia\Model\AttributeAv as AttributeAvModel;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\AttributeAvUpdateEvent;
use Thelia\Core\Event\AttributeAvCreateEvent;
use Thelia\Core\Event\AttributeAvDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Event\UpdatePositionEvent;
class AttributeAv extends BaseAction implements EventSubscriberInterface
{
/**
* Create a new attribute entry
*
* @param AttributeAvCreateEvent $event
*/
public function create(AttributeAvCreateEvent $event)
{
$attribute = new AttributeAvModel();
$attribute
->setDispatcher($this->getDispatcher())
->setAttributeId($event->getAttributeId())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->save()
;
$event->setAttributeAv($attribute);
}
/**
* Change a product attribute
*
* @param AttributeAvUpdateEvent $event
*/
public function update(AttributeAvUpdateEvent $event)
{
$search = AttributeAvQuery::create();
if (null !== $attribute = AttributeAvQuery::create()->findPk($event->getAttributeAvId())) {
$attribute
->setDispatcher($this->getDispatcher())
->setLocale($event->getLocale())
->setTitle($event->getTitle())
->setDescription($event->getDescription())
->setChapo($event->getChapo())
->setPostscriptum($event->getPostscriptum())
->save();
$event->setAttributeAv($attribute);
}
}
/**
* Delete a product attribute entry
*
* @param AttributeAvDeleteEvent $event
*/
public function delete(AttributeAvDeleteEvent $event)
{
if (null !== ($attribute = AttributeAvQuery::create()->findPk($event->getAttributeAvId()))) {
$attribute
->setDispatcher($this->getDispatcher())
->delete()
;
$event->setAttributeAv($attribute);
}
}
/**
* Changes position, selecting absolute ou relative change.
*
* @param CategoryChangePositionEvent $event
*/
public function updatePosition(UpdatePositionEvent $event)
{
if (null !== $attribute = AttributeAvQuery::create()->findPk($event->getObjectId())) {
$attribute->setDispatcher($this->getDispatcher());
$mode = $event->getMode();
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
return $attribute->changeAbsolutePosition($event->getPosition());
else if ($mode == UpdatePositionEvent::POSITION_UP)
return $attribute->movePositionUp();
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
return $attribute->movePositionDown();
}
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::ATTRIBUTE_AV_CREATE => array("create", 128),
TheliaEvents::ATTRIBUTE_AV_UPDATE => array("update", 128),
TheliaEvents::ATTRIBUTE_AV_DELETE => array("delete", 128),
TheliaEvents::ATTRIBUTE_AV_UPDATE_POSITION => array("updatePosition", 128),
);
}
}

View File

@@ -34,7 +34,7 @@ use Thelia\Core\Event\CurrencyUpdateEvent;
use Thelia\Core\Event\CurrencyCreateEvent;
use Thelia\Core\Event\CurrencyDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Event\CurrencyUpdatePositionEvent;
use Thelia\Core\Event\UpdatePositionEvent;
class Currency extends BaseAction implements EventSubscriberInterface
{
@@ -164,19 +164,20 @@ class Currency extends BaseAction implements EventSubscriberInterface
*
* @param CategoryChangePositionEvent $event
*/
public function updatePosition(CurrencyUpdatePositionEvent $event)
public function updatePosition(UpdatePositionEvent $event)
{
if (null !== $currency = CurrencyQuery::create()->findOneById($event->getObjectId())) {
if (null !== $currency = CurrencyQuery::create()->findPk($event->getObjectId())) {
$currency->setDispatcher($this->getDispatcher());
$mode = $event->getMode();
echo "loaded $mode !";
if ($mode == CurrencyUpdatePositionEvent::POSITION_ABSOLUTE)
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
return $currency->changeAbsolutePosition($event->getPosition());
else if ($mode == CurrencyUpdatePositionEvent::POSITION_UP)
else if ($mode == UpdatePositionEvent::POSITION_UP)
return $currency->movePositionUp();
else if ($mode == CurrencyUpdatePositionEvent::POSITION_DOWN)
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
return $currency->movePositionDown();
}
}

View File

@@ -26,6 +26,7 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\CustomerEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Customer as CustomerModel;
use Thelia\Core\Event\CustomerLoginEvent;
@@ -59,6 +60,13 @@ class Customer extends BaseAction implements EventSubscriberInterface
}
public function delete(CustomerEvent $event)
{
$customer = $event->getCustomer();
$customer->delete();
}
private function createOrUpdateCustomer(CustomerModel $customer, CustomerCreateOrUpdateEvent $event)
{
$customer->setDispatcher($this->getDispatcher());
@@ -80,7 +88,8 @@ class Customer extends BaseAction implements EventSubscriberInterface
$event->getLang(),
$event->getReseller(),
$event->getSponsor(),
$event->getDiscount()
$event->getDiscount(),
$event->getCompany()
);
$event->setCustomer($customer);
@@ -143,6 +152,7 @@ class Customer extends BaseAction implements EventSubscriberInterface
TheliaEvents::CUSTOMER_UPDATEACCOUNT => array("modify", 128),
TheliaEvents::CUSTOMER_LOGOUT => array("logout", 128),
TheliaEvents::CUSTOMER_LOGIN => array("login" , 128),
TheliaEvents::CUSTOMER_DELETEACCOUNT => array("delete", 128),
);
}
}

View File

@@ -32,29 +32,38 @@ use Thelia\Model\ConfigQuery;
/**
*
* Class PageNotFound
* Class HttpException
* @package Thelia\Action
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class PageNotFound extends BaseAction implements EventSubscriberInterface
class HttpException extends BaseAction implements EventSubscriberInterface
{
public function display404(GetResponseForExceptionEvent $event)
public function checkHttpException(GetResponseForExceptionEvent $event)
{
if ($event->getException() instanceof NotFoundHttpException) {
$parser = $this->container->get("thelia.parser");
// Define the template thant shoud be used
$parser->setTemplate(ConfigQuery::getActiveTemplate());
//$event->getRequest()->attributes->set('_view', ConfigQuery::getPageNotFoundView());
$response = new Response($parser->render(ConfigQuery::getPageNotFoundView()), 404);
$event->setResponse($response);
$this->display404($event);
}
}
protected function display404(GetResponseForExceptionEvent $event)
{
$parser = $this->container->get("thelia.parser");
// Define the template thant shoud be used
$parser->setTemplate(ConfigQuery::getActiveTemplate());
//$event->getRequest()->attributes->set('_view', ConfigQuery::getPageNotFoundView());
$response = new Response($parser->render(ConfigQuery::getPageNotFoundView()), 404);
$event->setResponse($response);
}
protected function display403(GetResponseForExceptionEvent $event)
{
$event->setResponse(new Response("You don't have access to this resources", 403));
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
@@ -78,7 +87,7 @@ class PageNotFound extends BaseAction implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
KernelEvents::EXCEPTION => array("display404", 128),
KernelEvents::EXCEPTION => array("checkHttpException", 128),
);
}
}

View File

@@ -1,157 +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\Action;
use Thelia\Core\Event\BaseChangePositionEvent;
trait PositionManagementTrait
{
const POSITION_UP
/**
* Changes object position, selecting absolute ou relative change.
*
* @param BaseChangePositionEvent $event
*/
public function changePosition(BaseChangePositionEvent $event)
{
if ($event->getMode() == BaseChangePositionEvent::POSITION_ABSOLUTE)
return $this->changeAbsolutePosition($event);
else
return $this->exchangePosition($event);
}
/**
* Move up or down a object
*
* @param BaseChangePositionEvent $event
*/
protected function exchangePosition(BaseChangePositionEvent $event)
{
$object = CategoryQuery::create()->findPk($event->getCategoryId());
if ($object !== null) {
// The current position of the object
$my_position = $object->getPosition();
// Find object to exchange position with
$search = CategoryQuery::create()
->filterByParent($object->getParent());
// Up or down ?
if ($event->getMode() == BaseChangePositionEvent::POSITION_UP) {
// Find the object immediately before me
$search->filterByPosition(array('max' => $my_position-1))->orderByPosition(Criteria::DESC);
} elseif ($event->getMode() == BaseChangePositionEvent::POSITION_DOWN) {
// Find the object immediately after me
$search->filterByPosition(array('min' => $my_position+1))->orderByPosition(Criteria::ASC);
} else
return;
$result = $search->findOne();
// If we found the proper object, exchange their positions
if ($result) {
$cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME);
$cnx->beginTransaction();
try {
$object
->setDispatcher($this->getDispatcher())
->setPosition($result->getPosition())
->save()
;
$result->setPosition($my_position)->save();
$cnx->commit();
} catch (Exception $e) {
$cnx->rollback();
}
}
}
}
/**
* Changes object position
*
* @param BaseChangePositionEvent $event
*/
protected function changeAbsolutePosition(BaseChangePositionEvent $event)
{
$object = CategoryQuery::create()->findPk($event->getCategoryId());
if ($object !== null) {
// The required position
$new_position = $event->getPosition();
// The current position
$current_position = $object->getPosition();
if ($new_position != null && $new_position > 0 && $new_position != $current_position) {
// Find categories to offset
$search = CategoryQuery::create()->filterByParent($object->getParent());
if ($new_position > $current_position) {
// The new position is after the current position -> we will offset + 1 all categories located between us and the new position
$search->filterByPosition(array('min' => 1+$current_position, 'max' => $new_position));
$delta = -1;
} else {
// The new position is brefore the current position -> we will offset - 1 all categories located between us and the new position
$search->filterByPosition(array('min' => $new_position, 'max' => $current_position - 1));
$delta = 1;
}
$results = $search->find();
$cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME);
$cnx->beginTransaction();
try {
foreach ($results as $result) {
$result->setPosition($result->getPosition() + $delta)->save($cnx);
}
$object
->setDispatcher($this->getDispatcher())
->setPosition($new_position)
->save($cnx)
;
$cnx->commit();
} catch (Exception $e) {
$cnx->rollback();
}
}
}
}
}

View File

@@ -0,0 +1,127 @@
<?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\TemplateQuery;
use Thelia\Model\Template as TemplateModel;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\TemplateUpdateEvent;
use Thelia\Core\Event\TemplateCreateEvent;
use Thelia\Core\Event\TemplateDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Model\TemplateAv;
use Thelia\Model\TemplateAvQuery;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\CategoryEvent;
use Thelia\Core\Event\TemplateEvent;
use Thelia\Model\TemplateTemplate;
use Thelia\Model\TemplateTemplateQuery;
use Thelia\Model\ProductQuery;
class Template extends BaseAction implements EventSubscriberInterface
{
/**
* Create a new template entry
*
* @param TemplateCreateEvent $event
*/
public function create(TemplateCreateEvent $event)
{
$template = new TemplateModel();
$template
->setDispatcher($this->getDispatcher())
->setLocale($event->getLocale())
->setName($event->getTemplateName())
->save()
;
$event->setTemplate($template);
}
/**
* Change a product template
*
* @param TemplateUpdateEvent $event
*/
public function update(TemplateUpdateEvent $event)
{
$search = TemplateQuery::create();
if (null !== $template = TemplateQuery::create()->findPk($event->getTemplateId())) {
$template
->setDispatcher($this->getDispatcher())
->setLocale($event->getLocale())
->setName($event->getTemplateName())
->save();
$event->setTemplate($template);
}
}
/**
* Delete a product template entry
*
* @param TemplateDeleteEvent $event
*/
public function delete(TemplateDeleteEvent $event)
{
if (null !== ($template = TemplateQuery::create()->findPk($event->getTemplateId()))) {
// Check if template is used by a product
$product_count = ProductQuery::create()->findByTemplateId($template->getId())->count();
if ($product_count <= 0) {
$template
->setDispatcher($this->getDispatcher())
->delete()
;
}
$event->setTemplate($template);
$event->setProductCount($product_count);
}
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::TEMPLATE_CREATE => array("create", 128),
TheliaEvents::TEMPLATE_UPDATE => array("update", 128),
TheliaEvents::TEMPLATE_DELETE => array("delete", 128),
);
}
}

View File

@@ -57,7 +57,22 @@
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.pageNotFound" class="Thelia\Action\PageNotFound">
<service id="thelia.action.template" class="Thelia\Action\Template">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.attribute" class="Thelia\Action\Attribute">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.attributeav" class="Thelia\Action\AttributeAv">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.httpException" class="Thelia\Action\HttpException">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>

View File

@@ -36,6 +36,7 @@
<loop class="Thelia\Core\Template\Loop\Coupon" name="coupon"/>
<loop class="Thelia\Core\Template\Loop\Message" name="message"/>
<loop class="Thelia\Core\Template\Loop\Delivery" name="delivery"/>
<loop class="Thelia\Core\Template\Loop\Template" name="template"/> <!-- This is product templates ;-) -->
</loops>
<forms>
@@ -67,6 +68,15 @@
<form name="thelia.admin.currency.modification" class="Thelia\Form\CurrencyModificationForm"/>
<form name="thelia.admin.coupon.creation" class="Thelia\Form\CouponCreationForm"/>
<form name="thelia.admin.attribute.creation" class="Thelia\Form\AttributeCreationForm"/>
<form name="thelia.admin.attribute.modification" class="Thelia\Form\AttributeModificationForm"/>
<form name="thelia.admin.attributeav.creation" class="Thelia\Form\AttributeAvCreationForm"/>
<form name="thelia.admin.template.creation" class="Thelia\Form\TemplateCreationForm"/>
<form name="thelia.admin.template.modification" class="Thelia\Form\TemplateModificationForm"/>
</forms>

View File

@@ -37,18 +37,32 @@
<default key="_controller">Thelia\Controller\Admin\CustomerController::indexAction</default>
</route>
<route id="admin.customer.update.view" path="/admin/customer/update/{customer_id}">
<route id="admin.customer.update.view" path="/admin/customer/update/{customer_id}" methods="get">
<default key="_controller">Thelia\Controller\Admin\CustomerController::viewAction</default>
<requirement key="customer_id">\d+</requirement>
</route>
<route id="admin.customer.update.process" path="/admin/customer/update/{customer_id}" methods="post">
<default key="_controller">Thelia\Controller\Admin\CustomerController::updateAction</default>
<requirement key="customer_id">\d+</requirement>
</route>
<route id="admin.customer.delete" path="/admin/customer/delete">
<default key="_controller">Thelia\Controller\Admin\CustomerController::deleteAction</default>
</route>
<!-- end Customer rule management -->
<!-- Order rule management -->
<route id="admin.order" path="/admin/order">
<default key="_controller">Thelia\Controller\Admin\OrderController::indexAction</default>
</route>
</route>
<route id="admin.order.update.view" path="/admin/order/update/{order_id}">
<default key="_controller">Thelia\Controller\Admin\OrderController::viewAction</default>
<requirement key="order_id">\d+</requirement>
</route>
<!-- end Customer rule management -->
@@ -63,11 +77,11 @@
</route>
<route id="admin.categories.update" path="/admin/categories/update">
<default key="_controller">Thelia\Controller\Admin\CategoryController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\CategoryController::updateAction</default>
</route>
<route id="admin.categories.save" path="/admin/categories/save">
<default key="_controller">Thelia\Controller\Admin\CategoryController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\CategoryController::processUpdateAction</default>
</route>
<route id="admin.categories.set-default" path="/admin/categories/toggle-online">
@@ -87,12 +101,8 @@
</route>
<!-- Route to the Coupon controller (process Coupon browsing) -->
<route id="admin.coupon.list" path="/admin/coupon">
<default key="_controller">Thelia\Controller\Admin\CouponController::browseAction</default>
</route>
@@ -113,10 +123,6 @@
</route>
<!-- Routes to the Config (system variables) controller -->
<route id="admin.configuration.variables.default" path="/admin/configuration/variables">
@@ -132,11 +138,11 @@
</route>
<route id="admin.configuration.variables.update" path="/admin/configuration/variables/update">
<default key="_controller">Thelia\Controller\Admin\ConfigController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\ConfigController::updateAction</default>
</route>
<route id="admin.configuration.variables.save" path="/admin/configuration/variables/save">
<default key="_controller">Thelia\Controller\Admin\ConfigController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\ConfigController::processUpdateAction</default>
</route>
<route id="admin.configuration.variables.delete" path="/admin/configuration/variables/delete">
@@ -154,11 +160,11 @@
</route>
<route id="admin.configuration.messages.update" path="/admin/configuration/messages/update">
<default key="_controller">Thelia\Controller\Admin\MessageController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\MessageController::updateAction</default>
</route>
<route id="admin.configuration.messages.save" path="/admin/configuration/messages/save">
<default key="_controller">Thelia\Controller\Admin\MessageController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\MessageController::processUpdateAction</default>
</route>
<route id="admin.configuration.messages.delete" path="/admin/configuration/messages/delete">
@@ -176,11 +182,11 @@
</route>
<route id="admin.configuration.currencies.update" path="/admin/configuration/currencies/update">
<default key="_controller">Thelia\Controller\Admin\CurrencyController::changeAction</default>
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updateAction</default>
</route>
<route id="admin.configuration.currencies.save" path="/admin/configuration/currencies/save">
<default key="_controller">Thelia\Controller\Admin\CurrencyController::saveChangeAction</default>
<default key="_controller">Thelia\Controller\Admin\CurrencyController::processUpdateAction</default>
</route>
<route id="admin.configuration.currencies.set-default" path="/admin/configuration/currencies/set-default">
@@ -203,16 +209,85 @@
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updatePositionAction</default>
</route>
<!-- attribute and feature routes management -->
<route id="admin.configuration.product-attribute.default" path="/admin/configuration/product-attributes">
<!-- Product templates management -->
<route id="admin.configuration.templates.default" path="/admin/configuration/templates">
<default key="_controller">Thelia\Controller\Admin\TemplateController::defaultAction</default>
</route>
<route id="admin.configuration.templates.create" path="/admin/configuration/templates/create">
<default key="_controller">Thelia\Controller\Admin\TemplateController::createAction</default>
</route>
<route id="admin.configuration.templates.update" path="/admin/configuration/templates/update">
<default key="_controller">Thelia\Controller\Admin\TemplateController::updateAction</default>
</route>
<route id="admin.configuration.templates.save" path="/admin/configuration/templates/save">
<default key="_controller">Thelia\Controller\Admin\TemplateController::processUpdateAction</default>
</route>
<route id="admin.configuration.templates.delete" path="/admin/configuration/templates/delete">
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteAction</default>
</route>
<!-- attribute and attributes value management -->
<route id="admin.configuration.attributes.default" path="/admin/configuration/attributes">
<default key="_controller">Thelia\Controller\Admin\AttributeController::defaultAction</default>
</route>
<route id="admin.configuration.product-attribute.edit" path="/admin/configuration/product-attributes/update">
<route id="admin.configuration.attributes.create" path="/admin/configuration/attributes/create">
<default key="_controller">Thelia\Controller\Admin\AttributeController::createAction</default>
</route>
<route id="admin.configuration.attributes.update" path="/admin/configuration/attributes/update">
<default key="_controller">Thelia\Controller\Admin\AttributeController::updateAction</default>
</route>
<route id="admin.configuration.attributes.save" path="/admin/configuration/attributes/save">
<default key="_controller">Thelia\Controller\Admin\AttributeController::processUpdateAction</default>
</route>
<route id="admin.configuration.attributes.delete" path="/admin/configuration/attributes/delete">
<default key="_controller">Thelia\Controller\Admin\AttributeController::deleteAction</default>
</route>
<route id="admin.configuration.attributes.update-position" path="/admin/configuration/attributes/update-position">
<default key="_controller">Thelia\Controller\Admin\AttributeController::updatePositionAction</default>
</route>
<route id="admin.configuration.attributes.rem-from-all" path="/admin/configuration/attributes/remove-from-all-templates">
<default key="_controller">Thelia\Controller\Admin\AttributeController::removeFromAllTemplates</default>
</route>
<route id="admin.configuration.attributes.add-to-all" path="/admin/configuration/attributes/add-to-all-templates">
<default key="_controller">Thelia\Controller\Admin\AttributeController::addToAllTemplates</default>
</route>
<route id="admin.configuration.attributes-av.create" path="/admin/configuration/attributes-av/create">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::createAction</default>
</route>
<route id="admin.configuration.attributes-av.update" path="/admin/configuration/attributes-av/update">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::updateAction</default>
</route>
<route id="admin.configuration.attributes-av.save" path="/admin/configuration/attributes-av/save">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::processUpdateAction</default>
</route>
<route id="admin.configuration.attributes-av.delete" path="/admin/configuration/attributes-av/delete">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::deleteAction</default>
</route>
<route id="admin.configuration.attributes-av.update-position" path="/admin/configuration/attributes-av/update-position">
<default key="_controller">Thelia\Controller\Admin\AttributeAvController::updatePositionAction</default>
</route>
<!-- end attribute and feature routes management -->
<!-- The default route, to display a template -->

View File

@@ -10,15 +10,31 @@
</route>
<!-- Customer routes -->
<route id="customer.create.view" path="/register">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">register</default>
</route>
<route id="customer.login.view" path="/login">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">login</default>
</route>
<route id="customer.logout.process" path="/logout">
<default key="_controller">Thelia\Controller\Front\CustomerController::logoutAction</default>
</route>
<route id="customer.account.view" path="/customer/account">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">account</default>
</route>
<route id="customer.create.process" path="/customer/create" methods="post">
<default key="_controller">Thelia\Controller\Front\CustomerController::createAction</default>
<default key="_view">register</default>
</route>
<route id="customer.create.view" path="/register">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">register</default>
</route>
<route id="customer.update.process" path="/customer/update" methods="post">
<default key="_controller">Thelia\Controller\Front\CustomerController::updateAction</default>
@@ -29,14 +45,6 @@
<default key="_view">login</default>
</route>
<route id="customer.login.view" path="/login">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">login</default>
</route>
<route id="customer.logout.process" path="/logout">
<default key="_controller">Thelia\Controller\Front\CustomerController::logoutAction</default>
</route>
<route id="customer.password.retrieve.view" path="/password" methods="get">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
@@ -51,19 +59,37 @@
<!-- end customer routes -->
<!-- customer address routes -->
<route id="address.create" path="/address/create" >
<route id="address.create.view" path="/address/create" methods="get">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">address</default>
</route>
<route id="address.create" path="/address/create" methods="post" >
<default key="_controller">Thelia\Controller\Front\AddressController::createAction</default>
<default key="_view">address</default>
</route>
<route id="address.edit" path="/address/edit/{address_id}">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">address_edit</default>
<route id="address.edit" path="/address/update/{address_id}" methods="get">
<default key="_controller">Thelia\Controller\Front\AddressController::updateViewAction</default>
<default key="_view">address-update</default>
</route>
<route id="address.update" path="/address/update" >
<default key="_controller">Thelia\Controller\Front\AddressController::updateAction</default>
<route id="address.update" path="/address/update/{address_id}" methods="post" >
<default key="_controller">Thelia\Controller\Front\AddressController::processUpdateAction</default>
<default key="_view">address-update</default>
</route>
<route id="address.delete" path="/address/delete/{address_id}">
<default key="_controller">Thelia\Controller\Front\AddressController::deleteAction</default>
<default key="_view">account</default>
</route>
<route id="address.generateModal" path="/address/modal/{address_id}" methods="get">
<default key="_controller">Thelia\Controller\Front\AddressController::generateModalAction</default>
<default key="_view">modal-address</default>
<requirement key="address_id">\d+</requirement>
</route>
<!-- end customer address routes -->
<!-- cart routes -->
@@ -86,6 +112,8 @@
<default key="_view">cart</default>
</route>
<!-- end cart routes -->
<!-- order management process -->
<route id="order.delivery.add" path="/delivery/choose/{delivery_id}">
<default key="_controller">Thelia\Controller\Front\DeliveryController::select</default>

View File

@@ -4,12 +4,28 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="home" path="/install" >
<route id="install.step1" path="/install" >
<default key="_controller">Thelia\Controller\Install\InstallController::index</default>
</route>
<route id="home" path="/install/step/2" >
<route id="install.step2" path="/install/step/2" >
<default key="_controller">Thelia\Controller\Install\InstallController::checkPermission</default>
</route>
<route id="install.step3" path="/install/step/3" >
<default key="_controller">Thelia\Controller\Install\InstallController::databaseConnection</default>
</route>
<route id="install.step4" path="/install/step/4" >
<default key="_controller">Thelia\Controller\Install\InstallController::databaseSelection</default>
</route>
<route id="install.step5" path="/install/step/5" >
<default key="_controller">Thelia\Controller\Install\InstallController::generalInformation</default>
</route>
<route id="install.step6" path="/install/thanks" >
<default key="_controller">Thelia\Controller\Install\InstallController::thanks</default>
</route>
</routes>

View File

@@ -0,0 +1,508 @@
<?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\Exception\FormValidationException;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\ToggleVisibilityEvent;
/**
* An abstract CRUD controller for Thelia ADMIN, to manage basic CRUD operations on a givent object.
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
abstract class AbstractCrudController extends BaseAdminController
{
protected $objectName;
// List ordering
protected $defaultListOrder;
protected $orderRequestParameterName;
// Permissions
protected $viewPermissionIdentifier;
protected $createPermissionIdentifier;
protected $updatePermissionIdentifier;
protected $deletePermissionIdentifier;
// Events
protected $createEventIdentifier;
protected $updateEventIdentifier;
protected $deleteEventIdentifier;
protected $visibilityToggleEventIdentifier;
protected $changePositionEventIdentifier;
/**
* @param string $objectName the lower case object name. Example. "message"
*
* @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual
*
* @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view"
* @param string $createPermissionIdentifier the 'create' permission identifier. Example: "admin.configuration.message.create"
* @param string $updatePermissionIdentifier the 'update' permission identifier. Example: "admin.configuration.message.update"
* @param string $deletePermissionIdentifier the 'delete' permission identifier. Example: "admin.configuration.message.delete"
*
* @param string $createEventIdentifier the dispatched create TheliaEvent identifier. Example: TheliaEvents::MESSAGE_CREATE
* @param string $updateEventIdentifier the dispatched update TheliaEvent identifier. Example: TheliaEvents::MESSAGE_UPDATE
* @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE
*
* @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY
* @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION
*/
public function __construct(
$objectName,
$defaultListOrder = null,
$orderRequestParameterName = null,
$viewPermissionIdentifier,
$createPermissionIdentifier,
$updatePermissionIdentifier,
$deletePermissionIdentifier,
$createEventIdentifier,
$updateEventIdentifier,
$deleteEventIdentifier,
$visibilityToggleEventIdentifier = null,
$changePositionEventIdentifier = null
) {
$this->objectName = $objectName;
$this->defaultListOrder = $defaultListOrder;
$this->orderRequestParameterName = $orderRequestParameterName;
$this->viewPermissionIdentifier = $viewPermissionIdentifier;
$this->createPermissionIdentifier = $createPermissionIdentifier;
$this->updatePermissionIdentifier = $updatePermissionIdentifier;
$this->deletePermissionIdentifier = $deletePermissionIdentifier;
$this->createEventIdentifier = $createEventIdentifier;
$this->updateEventIdentifier = $updateEventIdentifier;
$this->deleteEventIdentifier = $deleteEventIdentifier;
$this->visibilityToggleEventIdentifier = $visibilityToggleEventIdentifier;
$this->changePositionEventIdentifier = $changePositionEventIdentifier;
}
/**
* Return the creation form for this object
*/
protected abstract function getCreationForm();
/**
* Return the update form for this object
*/
protected abstract function getUpdateForm();
/**
* Hydrate the update form for this object, before passing it to the update template
*
* @param unknown $object
*/
protected abstract function hydrateObjectForm($object);
/**
* Creates the creation event with the provided form data
*
* @param unknown $formData
*/
protected abstract function getCreationEvent($formData);
/**
* Creates the update event with the provided form data
*
* @param unknown $formData
*/
protected abstract function getUpdateEvent($formData);
/**
* Creates the delete event with the provided form data
*/
protected abstract function getDeleteEvent();
/**
* Return true if the event contains the object, e.g. the action has updated the object in the event.
*
* @param unknown $event
*/
protected abstract function eventContainsObject($event);
/**
* Get the created object from an event.
*
* @param unknown $createEvent
*/
protected abstract function getObjectFromEvent($event);
/**
* Load an existing object from the database
*/
protected abstract function getExistingObject();
/**
* Returns the object label form the object event (name, title, etc.)
*
* @param unknown $object
*/
protected abstract function getObjectLabel($object);
/**
* Returns the object ID from the object
*
* @param unknown $object
*/
protected abstract function getObjectId($object);
/**
* Render the main list template
*
* @param unknown $currentOrder, if any, null otherwise.
*/
protected abstract function renderListTemplate($currentOrder);
/**
* Render the edition template
*/
protected abstract function renderEditionTemplate();
/**
* Redirect to the edition template
*/
protected abstract function redirectToEditionTemplate();
/**
* Redirect to the list template
*/
protected abstract function redirectToListTemplate();
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
throw new \LogicException ("Position Update is not supported for this object");
}
protected function createToggleVisibilityEvent()
{
throw new \LogicException ("Toggle Visibility is not supported for this object");
}
/**
* Put in this method post object creation processing if required.
*
* @param unknown $createEvent the create event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalCreateAction($createEvent)
{
return null;
}
/**
* Put in this method post object update processing if required.
*
* @param unknown $updateEvent the update event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalUpdateAction($updateeEvent)
{
return null;
}
/**
* Put in this method post object delete processing if required.
*
* @param unknown $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalDeleteAction($deleteEvent)
{
return null;
}
/**
* Return the current list order identifier, updating it in the same time.
*/
protected function getCurrentListOrder($update_session = true)
{
return $this->getListOrderFromSession(
$this->objectName,
$this->orderRequestParameterName,
$this->defaultListOrder
);
}
/**
* Render the object list, ensuring the sort order is set.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
protected function renderList()
{
return $this->renderListTemplate($this->getCurrentListOrder());
}
/**
* The default action is displaying the list.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function defaultAction()
{
if (null !== $response = $this->checkAuth($this->viewPermissionIdentifier)) return $response;
return $this->renderList();
}
/**
* Create a new object
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function createAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->createPermissionIdentifier)) return $response;
$error_msg = false;
// Create the Creation Form
$creationForm = $this->getCreationForm($this->getRequest());
try {
// Validate the form, create the event and dispatch it.
$form = $this->validateForm($creationForm, "POST");
$data = $form->getData();
$createEvent = $this->getCreationEvent($data);
$this->dispatch($this->createEventIdentifier, $createEvent);
if (! $this->eventContainsObject($createEvent))
throw new \LogicException(
$this->getTranslator()->trans("No %obj was created.", array('%obj', $this->objectName)));
if (null !== $createdObject = $this->getObjectFromEvent($createEvent)) {
// Log object creation
$this->adminLogAppend(sprintf("%s %s (ID %s) created", ucfirst($this->objectName), $this->getObjectLabel($createdObject), $this->getObjectId($createdObject)));
}
$this->performAdditionalCreateAction($createEvent);
// Substitute _ID_ in the URL with the ID of the created object
$successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl());
// Redirect to the success URL
$this->redirect($successUrl);
}
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' => $this->objectName)), $error_msg, $creationForm, $ex);
// At this point, the form has error, and should be redisplayed.
return $this->renderList();
}
/**
* Load a object for modification, and display the edit template.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function updateAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
// Load the object
$object = $this->getExistingObject();
if ($object != null) {
// Hydrate the form abd pass it to the parser
$changeForm = $this->hydrateObjectForm($object);
// Pass it to the parser
$this->getParserContext()->addForm($changeForm);
}
// Render the edition template.
return $this->renderEditionTemplate();
}
/**
* 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()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$error_msg = false;
// Create the form from the request
$changeForm = $this->getUpdateForm($this->getRequest());
try {
// Check the form against constraints violations
$form = $this->validateForm($changeForm, "POST");
// Get the form field values
$data = $form->getData();
$changeEvent = $this->getUpdateEvent($data);
$this->dispatch($this->updateEventIdentifier, $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)));
}
$this->performAdditionalUpdateAction($changeEvent);
// 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("%obj modification", array('%obj' => $this->objectName)), $error_msg, $changeForm, $ex);
// At this point, the form has errors, and should be redisplayed.
return $this->renderEditionTemplate();
}
/**
* Update object position (only for objects whichsupport that)
*/
public function updatePositionAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
try {
$mode = $this->getRequest()->get('mode', null);
if ($mode == 'up')
$mode = UpdatePositionEvent::POSITION_UP;
else if ($mode == 'down')
$mode = UpdatePositionEvent::POSITION_DOWN;
else
$mode = UpdatePositionEvent::POSITION_ABSOLUTE;
$position = $this->getRequest()->get('position', null);
$event = $this->createUpdatePositionEvent($mode, $position);
$this->dispatch($this->changePositionEventIdentifier, $event);
}
catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
$this->redirectToListTemplate();
}
/**
* Online status toggle (only for object which support it)
*/
public function setToggleVisibilityAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
$changeEvent = $this->createToggleVisibilityEvent($this->getRequest());
// Create and dispatch the change event
$changeEvent->setIsDefault(true);
try {
$this->dispatch($this->visibilityToggleEventIdentifier, $changeEvent);
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
$this->redirectToRoute('admin.categories.default');
}
/**
* Delete an object
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function deleteAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth($this->deletePermissionIdentifier)) return $response;
// Get the currency id, and dispatch the delet request
$deleteEvent = $this->getDeleteEvent();
$this->dispatch($this->deleteEventIdentifier, $deleteEvent);
if (null !== $deletedObject = $this->getObjectFromEvent($deleteEvent)) {
$this->adminLogAppend(
sprintf("%s %s (ID %s) deleted", ucfirst($this->objectName), $this->getObjectLabel($deletedObject), $this->getObjectId($deletedObject)));
}
$response = $this->performAdditionalDeleteAction($deleteEvent);
if ($response == null)
$this->redirectToListTemplate();
else
return $response;
}
}

View File

@@ -23,6 +23,10 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Security\Authentication\AdminTokenAuthenticator;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Security\Exception\TokenAuthenticationException;
class AdminController extends BaseAdminController
{
public function indexAction()

View File

@@ -0,0 +1,196 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AttributeAvDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\AttributeAvUpdateEvent;
use Thelia\Core\Event\AttributeAvCreateEvent;
use Thelia\Model\AttributeAvQuery;
use Thelia\Form\AttributeAvModificationForm;
use Thelia\Form\AttributeAvCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
/**
* Manages attributes-av sent by mail
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
class AttributeAvController extends AbstractCrudController
{
public function __construct()
{
parent::__construct(
'attributeav',
'manual',
'order',
'admin.configuration.attributes-av.view',
'admin.configuration.attributes-av.create',
'admin.configuration.attributes-av.update',
'admin.configuration.attributes-av.delete',
TheliaEvents::ATTRIBUTE_AV_CREATE,
TheliaEvents::ATTRIBUTE_AV_UPDATE,
TheliaEvents::ATTRIBUTE_AV_DELETE,
null, // No visibility toggle
TheliaEvents::ATTRIBUTE_AV_UPDATE_POSITION
);
}
protected function getCreationForm()
{
return new AttributeAvCreationForm($this->getRequest());
}
protected function getUpdateForm()
{
return new AttributeAvModificationForm($this->getRequest());
}
protected function getCreationEvent($formData)
{
$createEvent = new AttributeAvCreateEvent();
$createEvent
->setAttributeId($formData['attribute_id'])
->setTitle($formData['title'])
->setLocale($formData["locale"])
;
return $createEvent;
}
protected function getUpdateEvent($formData)
{
$changeEvent = new AttributeAvUpdateEvent($formData['id']);
// Create and dispatch the change event
$changeEvent
->setLocale($formData["locale"])
->setTitle($formData['title'])
->setChapo($formData['chapo'])
->setDescription($formData['description'])
->setPostscriptum($formData['postscriptum'])
;
return $changeEvent;
}
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
return new UpdatePositionEvent(
$this->getRequest()->get('attributeav_id', null),
$positionChangeMode,
$positionValue
);
}
protected function getDeleteEvent()
{
return new AttributeAvDeleteEvent($this->getRequest()->get('attributeav_id'));
}
protected function eventContainsObject($event)
{
return $event->hasAttributeAv();
}
protected function hydrateObjectForm($object)
{
$data = array(
'id' => $object->getId(),
'locale' => $object->getLocale(),
'title' => $object->getTitle(),
'chapo' => $object->getChapo(),
'description' => $object->getDescription(),
'postscriptum' => $object->getPostscriptum()
);
// Setup the object form
return new AttributeAvModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event)
{
return $event->hasAttributeAv() ? $event->getAttributeAv() : null;
}
protected function getExistingObject()
{
return AttributeAvQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('attributeav_id'));
}
protected function getObjectLabel($object)
{
return $object->getTitle();
}
protected function getObjectId($object)
{
return $object->getId();
}
protected function getViewArguments()
{
return array(
'attribute_id' => $this->getRequest()->get('attribute_id'),
'order' => $this->getCurrentListOrder()
);
}
protected function renderListTemplate($currentOrder)
{
// We always return to the attribute edition form
return $this->render(
'attribute-edit',
$this->getViewArguments()
);
}
protected function renderEditionTemplate()
{
// We always return to the attribute edition form
return $this->render('attribute-edit', $this->getViewArguments());
}
protected function redirectToEditionTemplate()
{
// We always return to the attribute edition form
$this->redirectToRoute(
"admin.configuration.attributes.update",
$this->getViewArguments()
);
}
protected function redirectToListTemplate()
{
$this->redirectToRoute(
"admin.configuration.attributes.update",
$this->getViewArguments()
);
}
}

View File

@@ -23,27 +23,267 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\AttributeDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\AttributeUpdateEvent;
use Thelia\Core\Event\AttributeCreateEvent;
use Thelia\Model\AttributeQuery;
use Thelia\Form\AttributeModificationForm;
use Thelia\Form\AttributeCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Model\AttributeAv;
use Thelia\Model\AttributeAvQuery;
use Thelia\Core\Event\AttributeAvUpdateEvent;
use Thelia\Core\Event\AttributeEvent;
/**
* Manages messages sent by mail
* Manages attributes sent by mail
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
class AttributeController extends BaseAdminController
class AttributeController extends AbstractCrudController
{
/**
* The default action is displaying the attributes list.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function defaultAction()
public function __construct()
{
if (null !== $response = $this->checkAuth("admin.configuration.attributes.view")) return $response;
return $this->render('product-attributes');
parent::__construct(
'attribute',
'manual',
'order',
'admin.configuration.attributes.view',
'admin.configuration.attributes.create',
'admin.configuration.attributes.update',
'admin.configuration.attributes.delete',
TheliaEvents::ATTRIBUTE_CREATE,
TheliaEvents::ATTRIBUTE_UPDATE,
TheliaEvents::ATTRIBUTE_DELETE,
null, // No visibility toggle
TheliaEvents::ATTRIBUTE_UPDATE_POSITION
);
}
public function updateAction()
protected function getCreationForm()
{
if (null !== $response = $this->checkAuth("admin.configuration.attributes.update")) return $response;
return $this->render('product-attributes-edit');
return new AttributeCreationForm($this->getRequest());
}
}
protected function getUpdateForm()
{
return new AttributeModificationForm($this->getRequest());
}
protected function getCreationEvent($formData)
{
$createEvent = new AttributeCreateEvent();
$createEvent
->setTitle($formData['title'])
->setLocale($formData["locale"])
->setAddToAllTemplates($formData['add_to_all'])
;
return $createEvent;
}
protected function getUpdateEvent($formData)
{
$changeEvent = new AttributeUpdateEvent($formData['id']);
// Create and dispatch the change event
$changeEvent
->setLocale($formData["locale"])
->setTitle($formData['title'])
->setChapo($formData['chapo'])
->setDescription($formData['description'])
->setPostscriptum($formData['postscriptum'])
;
return $changeEvent;
}
/**
* Process the attributes values (fix it in future version to integrate it in the attribute form as a collection)
*
* @see \Thelia\Controller\Admin\AbstractCrudController::performAdditionalUpdateAction()
*/
protected function performAdditionalUpdateAction($updateEvent)
{
$attr_values = $this->getRequest()->get('attribute_values', null);
if ($attr_values !== null) {
foreach($attr_values as $id => $value) {
$event = new AttributeAvUpdateEvent($id);
$event->setTitle($value);
$event->setLocale($this->getCurrentEditionLocale());
$this->dispatch(TheliaEvents::ATTRIBUTE_AV_UPDATE, $event);
}
}
return null;
}
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
return new UpdatePositionEvent(
$this->getRequest()->get('attribute_id', null),
$positionChangeMode,
$positionValue
);
}
protected function getDeleteEvent()
{
return new AttributeDeleteEvent($this->getRequest()->get('attribute_id'));
}
protected function eventContainsObject($event)
{
return $event->hasAttribute();
}
protected function hydrateObjectForm($object)
{
$data = array(
'id' => $object->getId(),
'locale' => $object->getLocale(),
'title' => $object->getTitle(),
'chapo' => $object->getChapo(),
'description' => $object->getDescription(),
'postscriptum' => $object->getPostscriptum()
);
// Setup attributes values
/*
* FIXME : doesn't work. "We get a This form should not contain extra fields." error
$attr_av_list = AttributeAvQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->filterByAttributeId($object->getId())
->find();
$attr_array = array();
foreach($attr_av_list as $attr_av) {
$attr_array[$attr_av->getId()] = $attr_av->getTitle();
}
$data['attribute_values'] = $attr_array;
*/
// Setup the object form
return new AttributeModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event)
{
return $event->hasAttribute() ? $event->getAttribute() : null;
}
protected function getExistingObject()
{
return AttributeQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('attribute_id'));
}
protected function getObjectLabel($object)
{
return $object->getTitle();
}
protected function getObjectId($object)
{
return $object->getId();
}
protected function renderListTemplate($currentOrder)
{
return $this->render('attributes', array('order' => $currentOrder));
}
protected function renderEditionTemplate()
{
return $this->render(
'attribute-edit',
array(
'attribute_id' => $this->getRequest()->get('attribute_id'),
'attributeav_order' => $this->getAttributeAvListOrder()
)
);
}
protected function redirectToEditionTemplate()
{
$this->redirectToRoute(
"admin.configuration.attributes.update",
array(
'attribute_id' => $this->getRequest()->get('attribute_id'),
'attributeav_order' => $this->getAttributeAvListOrder()
)
);
}
protected function redirectToListTemplate()
{
$this->redirectToRoute('admin.configuration.attributes.default');
}
/**
* Get the Attribute value list order.
*
* @return string the current list order
*/
protected function getAttributeAvListOrder()
{
return $this->getListOrderFromSession(
'attributeav',
'attributeav_order',
'manual'
);
}
/**
* Add or Remove from all product templates
*/
protected function addRemoveFromAllTemplates($eventType)
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.attributes.update")) return $response;
try {
if (null !== $object = $this->getExistingObject()) {
$event = new AttributeEvent($object);
$this->dispatch($eventType, $event);
}
}
catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
$this->redirectToListTemplate();
}
/**
* Remove from all product templates
*/
public function removeFromAllTemplates()
{
return $this->addRemoveFromAllTemplates(TheliaEvents::ATTRIBUTE_REMOVE_FROM_ALL_TEMPLATES);
}
/**
* Add to all product templates
*/
public function addToAllTemplates()
{
return $this->addRemoveFromAllTemplates(TheliaEvents::ATTRIBUTE_ADD_TO_ALL_TEMPLATES);
}
}

View File

@@ -40,6 +40,8 @@ use Thelia\Form\BaseForm;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Log\Tlog;
use Symfony\Component\Routing\Router;
use Thelia\Model\Admin;
use Thelia\Core\Security\Token\CookieTokenProvider;
class BaseAdminController extends BaseController
{
@@ -97,7 +99,7 @@ class BaseAdminController extends BaseController
protected function errorPage($message)
{
if ($message instanceof \Exception) {
$message = sprintf($this->getTranslator()->trans("Sorry, an error occured: %msg"), array('msg' => $message->getMessage()));
$message = $this->getTranslator()->trans("Sorry, an error occured: %msg", array('%msg' => $message->getMessage()));
}
return $this->render('general_error', array(
@@ -273,6 +275,75 @@ class BaseAdminController extends BaseController
return $this->getCurrentEditionLang()->getLocale();
}
/**
* Return the current list order identifier for a given object name,
* updating in using the current request.
*
* @param unknown $objectName the object name (e.g. 'attribute', 'message')
* @param unknown $requestParameterName the name of the request parameter that defines the list order
* @param unknown $defaultListOrder the default order to use, if none is defined
* @param string $updateSession if true, the session will be updated with the current order.
*
* @return String the current liste order.
*/
protected function getListOrderFromSession($objectName, $requestParameterName, $defaultListOrder, $updateSession = true) {
$order = $defaultListOrder;
$orderSessionIdentifier = sprintf("admin.%s.currentListOrder", $objectName);
// Find the current order
$order = $this->getRequest()->get(
$requestParameterName,
$this->getSession()->get($orderSessionIdentifier, $defaultListOrder)
);
if ($updateSession) $this->getSession()->set($orderSessionIdentifier, $order);
return $order;
}
/**
* Create the remember me cookie for the given user.
*/
protected function createAdminRememberMeCookie(Admin $user)
{
$ctp = new CookieTokenProvider();
$cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn');
$cookieExpiration = ConfigQuery::read('admin_remember_me_cookie_expiration', 2592000 /* 1 month */);
$ctp->createCookie($user, $cookieName, $cookieExpiration);
}
/**
* Get the rememberme key from the cookie.
*
* @return string hte key found, or null if no key was found.
*/
protected function getRememberMeKeyFromCookie()
{
// Check if we can authenticate the user with a cookie-based token
$cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn');
$ctp = new CookieTokenProvider();
return $ctp->getKeyFromCookie($this->getRequest(), $cookieName);
}
/** Clear the remember me cookie.
*
*/
protected function clearRememberMeCookie() {
$ctp = new CookieTokenProvider();
$cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn');
$ctp->clearCookie($cookieName);
}
/**
* Render the given template, and returns the result as an Http Response.
*
@@ -314,7 +385,7 @@ class BaseAdminController extends BaseController
'edit_language_id' => $edition_language->getId(),
'edit_language_locale' => $edition_language->getLocale(),
'current_url' => htmlspecialchars($this->getRequest()->getUri())
'current_url' => $this->getRequest()->getUri()
));
// Update the current edition language in session

View File

@@ -25,228 +25,145 @@ namespace Thelia\Controller\Admin;
use Thelia\Core\Event\ConfigDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Tools\URL;
use Thelia\Core\Event\ConfigUpdateEvent;
use Thelia\Core\Event\ConfigCreateEvent;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\ConfigQuery;
use Thelia\Form\ConfigModificationForm;
use Thelia\Form\ConfigCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
/**
* Manages Thelmia system variables, aka Config objects.
* Manages variables sent by mail
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
class ConfigController extends BaseAdminController
class ConfigController extends AbstractCrudController
{
/**
* Render the currencies list, ensuring the sort order is set.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
protected function renderList()
{
// Find the current order
$order = $this->getRequest()->get(
'order',
$this->getSession()->get('admin.variables_order', 'name')
public function __construct() {
parent::__construct(
'variable',
'name',
'order',
'admin.configuration.variables.view',
'admin.configuration.variables.create',
'admin.configuration.variables.update',
'admin.configuration.variables.delete',
TheliaEvents::CONFIG_CREATE,
TheliaEvents::CONFIG_UPDATE,
TheliaEvents::CONFIG_DELETE,
null, // No visibility toggle
null // no position change
);
}
protected function getCreationForm() {
return new ConfigCreationForm($this->getRequest());
}
protected function getUpdateForm() {
return new ConfigModificationForm($this->getRequest());
}
protected function getCreationEvent($data) {
$createEvent = new ConfigCreateEvent();
$createEvent
->setEventName($data['name'])
->setValue($data['value'])
->setLocale($data["locale"])
->setTitle($data['title'])
->setHidden($data['hidden'])
->setSecured($data['secured'])
;
return $createEvent;
}
protected function getUpdateEvent($data) {
$changeEvent = new ConfigUpdateEvent($data['id']);
// Create and dispatch the change event
$changeEvent
->setEventName($data['name'])
->setValue($data['value'])
->setHidden($data['hidden'])
->setSecured($data['secured'])
->setLocale($data["locale"])
->setTitle($data['title'])
->setChapo($data['chapo'])
->setDescription($data['description'])
->setPostscriptum($data['postscriptum'])
;
return $changeEvent;
}
protected function getDeleteEvent() {
return new ConfigDeleteEvent($this->getRequest()->get('variable_id'));
}
protected function eventContainsObject($event) {
return $event->hasConfig();
}
protected function hydrateObjectForm($object) {
// Prepare the data that will hydrate the form
$data = array(
'id' => $object->getId(),
'name' => $object->getName(),
'value' => $object->getValue(),
'hidden' => $object->getHidden(),
'secured' => $object->getSecured(),
'locale' => $object->getLocale(),
'title' => $object->getTitle(),
'chapo' => $object->getChapo(),
'description' => $object->getDescription(),
'postscriptum' => $object->getPostscriptum()
);
// Store the current sort order in session
$this->getSession()->set('admin.variables_order', $order);
return $this->render('variables', array('order' => $order));
// Setup the object form
return new ConfigModificationForm($this->getRequest(), "form", $data);
}
/**
* The default action is displaying the variables list.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function defaultAction()
{
if (null !== $response = $this->checkAuth("admin.configuration.variables.view")) return $response;
return $this->renderList();
protected function getObjectFromEvent($event) {
return $event->hasConfig() ? $event->getConfig() : null;
}
/**
* Create a new config object
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function createAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.variables.create")) return $response;
$message = false;
// Create the Creation Form
$creationForm = new ConfigCreationForm($this->getRequest());
try {
// Validate the form, create the ConfigCreation event and dispatch it.
$form = $this->validateForm($creationForm, "POST");
$data = $form->getData();
$createEvent = new ConfigCreateEvent();
$createEvent
->setEventName($data['name'])
->setValue($data['value'])
->setLocale($data["locale"])
->setTitle($data['title'])
->setHidden($data['hidden'])
->setSecured($data['secured'])
;
$this->dispatch(TheliaEvents::CONFIG_CREATE, $createEvent);
if (! $createEvent->hasConfig()) throw new \LogicException($this->getTranslator()->trans("No variable was created."));
$createdObject = $createEvent->getConfig();
// Log config creation
$this->adminLogAppend(sprintf("Variable %s (ID %s) created", $createdObject->getName(), $createdObject->getId()));
// Substitute _ID_ in the URL with the ID of the created object
$successUrl = str_replace('_ID_', $createdObject->getId(), $creationForm->getSuccessUrl());
// Redirect to the success URL
$this->redirect($successUrl);
} catch (FormValidationException $ex) {
// Form cannot be validated
$message = $this->createStandardFormValidationErrorMessage($ex);
} catch (\Exception $ex) {
// Any other error
$message = $ex->getMessage();
}
$this->setupFormErrorContext("variable creation", $message, $creationForm, $ex);
// At this point, the form has error, and should be redisplayed.
return $this->renderList();
protected function getExistingObject() {
return ConfigQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('variable_id'));
}
/**
* Load a config object for modification, and display the edit template.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function changeAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.variables.update")) return $response;
protected function getObjectLabel($object) {
return $object->getName();
}
// Load the config object
$config = ConfigQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('variable_id'));
protected function getObjectId($object) {
return $object->getId();
}
if ($config != null) {
protected function renderListTemplate($currentOrder) {
return $this->render('variables', array('order' => $currentOrder));
}
// Prepare the data that will hydrate the form
$data = array(
'id' => $config->getId(),
'name' => $config->getName(),
'value' => $config->getValue(),
'hidden' => $config->getHidden(),
'secured' => $config->getSecured(),
'locale' => $config->getLocale(),
'title' => $config->getTitle(),
'chapo' => $config->getChapo(),
'description' => $config->getDescription(),
'postscriptum' => $config->getPostscriptum()
);
// Setup the object form
$changeForm = new ConfigModificationForm($this->getRequest(), "form", $data);
// Pass it to the parser
$this->getParserContext()->addForm($changeForm);
}
// Render the edition template.
protected function renderEditionTemplate() {
return $this->render('variable-edit', array('variable_id' => $this->getRequest()->get('variable_id')));
}
/**
* Save changes on a modified config object, and either go back to the variable list, or stay on the edition page.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function saveChangeAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.variables.update")) return $response;
protected function redirectToEditionTemplate() {
$this->redirectToRoute(
"admin.configuration.variables.update",
array('variable_id' => $this->getRequest()->get('variable_id'))
);
}
$message = false;
// Create the form from the request
$changeForm = new ConfigModificationForm($this->getRequest());
// Get the variable ID
$variable_id = $this->getRequest()->get('variable_id');
try {
// Check the form against constraints violations
$form = $this->validateForm($changeForm, "POST");
// Get the form field values
$data = $form->getData();
$changeEvent = new ConfigUpdateEvent($data['id']);
// Create and dispatch the change event
$changeEvent
->setEventName($data['name'])
->setValue($data['value'])
->setHidden($data['hidden'])
->setSecured($data['secured'])
->setLocale($data["locale"])
->setTitle($data['title'])
->setChapo($data['chapo'])
->setDescription($data['description'])
->setPostscriptum($data['postscriptum'])
;
$this->dispatch(TheliaEvents::CONFIG_UPDATE, $changeEvent);
if (! $changeEvent->hasConfig()) throw new \LogicException($this->getTranslator()->trans("No variable was updated."));
// Log config modification
$changedObject = $changeEvent->getConfig();
$this->adminLogAppend(sprintf("Variable %s (ID %s) modified", $changedObject->getName(), $changedObject->getId()));
// 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->redirectToRoute(
"admin.configuration.variables.update",
array('variable_id' => $variable_id)
);
}
// Redirect to the success URL
$this->redirect($changeForm->getSuccessUrl());
} catch (FormValidationException $ex) {
// Form cannot be validated
$message = $this->createStandardFormValidationErrorMessage($ex);
} catch (\Exception $ex) {
// Any other error
$message = $ex->getMessage();
}
$this->setupFormErrorContext("variable edition", $message, $changeForm, $ex);
// At this point, the form has errors, and should be redisplayed.
return $this->render('variable-edit', array('variable_id' => $variable_id));
protected function redirectToListTemplate() {
$this->redirectToRoute('admin.configuration.variables.default');
}
/**
@@ -271,25 +188,4 @@ class ConfigController extends BaseAdminController
$this->redirectToRoute('admin.configuration.variables.default');
}
/**
* Delete a config object
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function deleteAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.variables.delete")) return $response;
// Get the config id, and dispatch the delet request
$event = new ConfigDeleteEvent($this->getRequest()->get('variable_id'));
$this->dispatch(TheliaEvents::CONFIG_DELETE, $event);
if ($event->hasConfig())
$this->adminLogAppend(sprintf("Variable %s (ID %s) modified", $event->getConfig()->getName(), $event->getConfig()->getId()));
$this->redirectToRoute('admin.configuration.variables.default');
}
}
}

View File

@@ -25,219 +25,163 @@ namespace Thelia\Controller\Admin;
use Thelia\Core\Event\CurrencyDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Tools\URL;
use Thelia\Core\Event\CurrencyUpdateEvent;
use Thelia\Core\Event\CurrencyCreateEvent;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\CurrencyQuery;
use Thelia\Form\CurrencyModificationForm;
use Thelia\Form\CurrencyCreationForm;
use Thelia\Core\Event\CurrencyUpdatePositionEvent;
use Thelia\Core\Event\UpdatePositionEvent;
/**
* Manages currencies sent by mail
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
class CurrencyController extends BaseAdminController
class CurrencyController extends AbstractCrudController
{
/**
* Render the currencies list, ensuring the sort order is set.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
protected function renderList()
{
// Find the current order
$order = $this->getRequest()->get(
'order',
$this->getSession()->get('admin.currency_order', 'manual')
public function __construct() {
parent::__construct(
'currency',
'manual',
'order',
'admin.configuration.currencies.view',
'admin.configuration.currencies.create',
'admin.configuration.currencies.update',
'admin.configuration.currencies.delete',
TheliaEvents::CURRENCY_CREATE,
TheliaEvents::CURRENCY_UPDATE,
TheliaEvents::CURRENCY_DELETE,
null, // No visibility toggle
TheliaEvents::CURRENCY_UPDATE_POSITION
);
}
protected function getCreationForm() {
return new CurrencyCreationForm($this->getRequest());
}
protected function getUpdateForm() {
return new CurrencyModificationForm($this->getRequest());
}
protected function getCreationEvent($formData) {
$createEvent = new CurrencyCreateEvent();
$createEvent
->setCurrencyName($formData['name'])
->setLocale($formData["locale"])
->setSymbol($formData['symbol'])
->setCode($formData['code'])
->setRate($formData['rate'])
;
return $createEvent;
}
protected function getUpdateEvent($formData) {
$changeEvent = new CurrencyUpdateEvent($formData['id']);
// Create and dispatch the change event
$changeEvent
->setCurrencyName($formData['name'])
->setLocale($formData["locale"])
->setSymbol($formData['symbol'])
->setCode($formData['code'])
->setRate($formData['rate'])
;
return $changeEvent;
}
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) {
return new UpdatePositionEvent(
$this->getRequest()->get('currency_id', null),
$positionChangeMode,
$positionValue
);
}
protected function getDeleteEvent() {
return new CurrencyDeleteEvent($this->getRequest()->get('currency_id'));
}
protected function eventContainsObject($event) {
return $event->hasCurrency();
}
protected function hydrateObjectForm($object) {
// Prepare the data that will hydrate the form
$data = array(
'id' => $object->getId(),
'name' => $object->getName(),
'locale' => $object->getLocale(),
'code' => $object->getCode(),
'symbol' => $object->getSymbol(),
'rate' => $object->getRate()
);
// Store the current sort order in session
$this->getSession()->set('admin.currency_order', $order);
return $this->render('currencies', array('order' => $order));
// Setup the object form
return new CurrencyModificationForm($this->getRequest(), "form", $data);
}
/**
* The default action is displaying the currencies list.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function defaultAction()
{
if (null !== $response = $this->checkAuth("admin.configuration.currencies.view")) return $response;
return $this->renderList();
protected function getObjectFromEvent($event) {
return $event->hasCurrency() ? $event->getCurrency() : null;
}
/**
* Create a new currency object
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function createAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.create")) return $response;
$error_msg = false;
// Create the Creation Form
$creationForm = new CurrencyCreationForm($this->getRequest());
try {
// Validate the form, create the CurrencyCreation event and dispatch it.
$form = $this->validateForm($creationForm, "POST");
$data = $form->getData();
$createEvent = new CurrencyCreateEvent();
$createEvent
->setCurrencyName($data['name'])
->setLocale($data["locale"])
->setSymbol($data['symbol'])
->setCode($data['code'])
->setRate($data['rate'])
;
$this->dispatch(TheliaEvents::CURRENCY_CREATE, $createEvent);
if (! $createEvent->hasCurrency()) throw new \LogicException($this->getTranslator()->trans("No currency was created."));
$createdObject = $createEvent->getCurrency();
// Log currency creation
$this->adminLogAppend(sprintf("Currency %s (ID %s) created", $createdObject->getName(), $createdObject->getId()));
// Substitute _ID_ in the URL with the ID of the created object
$successUrl = str_replace('_ID_', $createdObject->getId(), $creationForm->getSuccessUrl());
// Redirect to the success URL
$this->redirect($successUrl);
} catch (FormValidationException $ex) {
// Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
} catch (\Exception $ex) {
// Any other error
$error_msg = $ex->getMessage();
}
$this->setupFormErrorContext("currency creation", $error_msg, $creationForm, $ex);
// At this point, the form has error, and should be redisplayed.
return $this->renderList();
protected function getExistingObject() {
return CurrencyQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('currency_id'));
}
/**
* Load a currency object for modification, and display the edit template.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function changeAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response;
protected function getObjectLabel($object) {
return $object->getName();
}
// Load the currency object
$currency = CurrencyQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('currency_id'));
protected function getObjectId($object) {
return $object->getId();
}
if ($currency != null) {
protected function renderListTemplate($currentOrder) {
return $this->render('currencies', array('order' => $currentOrder));
}
// Prepare the data that will hydrate the form
$data = array(
'id' => $currency->getId(),
'name' => $currency->getName(),
'locale' => $currency->getLocale(),
'code' => $currency->getCode(),
'symbol' => $currency->getSymbol(),
'rate' => $currency->getRate()
);
// Setup the object form
$changeForm = new CurrencyModificationForm($this->getRequest(), "form", $data);
// Pass it to the parser
$this->getParserContext()->addForm($changeForm);
}
// Render the edition template.
protected function renderEditionTemplate() {
return $this->render('currency-edit', array('currency_id' => $this->getRequest()->get('currency_id')));
}
protected function redirectToEditionTemplate() {
$this->redirectToRoute(
"admin.configuration.currencies.update",
array('currency_id' => $this->getRequest()->get('currency_id'))
);
}
protected function redirectToListTemplate() {
$this->redirectToRoute('admin.configuration.currencies.default');
}
/**
* Save changes on a modified currency object, and either go back to the currency list, or stay on the edition page.
*
* @return Symfony\Component\HttpFoundation\Response the response
* Update currencies rates
*/
public function saveChangeAction()
public function updateRatesAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response;
$error_msg = false;
// Create the form from the request
$changeForm = new CurrencyModificationForm($this->getRequest());
// Get the currency ID
$currency_id = $this->getRequest()->get('currency_id');
try {
// Check the form against constraints violations
$form = $this->validateForm($changeForm, "POST");
// Get the form field values
$data = $form->getData();
$changeEvent = new CurrencyUpdateEvent($data['id']);
// Create and dispatch the change event
$changeEvent
->setCurrencyName($data['name'])
->setLocale($data["locale"])
->setSymbol($data['symbol'])
->setCode($data['code'])
->setRate($data['rate'])
;
$this->dispatch(TheliaEvents::CURRENCY_UPDATE, $changeEvent);
if (! $changeEvent->hasCurrency()) throw new \LogicException($this->getTranslator()->trans("No currency was updated."));
// Log currency modification
$changedObject = $changeEvent->getCurrency();
$this->adminLogAppend(sprintf("Currency %s (ID %s) modified", $changedObject->getName(), $changedObject->getId()));
// 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->redirectToRoute(
"admin.configuration.currencies.update",
array('currency_id' => $currency_id)
);
}
// Redirect to the success URL
$this->redirect($changeForm->getSuccessUrl());
} catch (FormValidationException $ex) {
// Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
$this->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES);
} catch (\Exception $ex) {
// Any other error
$error_msg = $ex->getMessage();
// Any error
return $this->errorPage($ex);
}
$this->setupFormErrorContext("currency modification", $error_msg, $changeForm, $ex);
// At this point, the form has errors, and should be redisplayed.
return $this->render('currency-edit', array('currency_id' => $currency_id));
$this->redirectToListTemplate();
}
/**
@@ -260,80 +204,7 @@ class CurrencyController extends BaseAdminController
return $this->errorPage($ex);
}
$this->redirectToRoute('admin.configuration.currencies.default');
$this->redirectToListTemplate();
}
/**
* Update currencies rates
*/
public function updateRatesAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response;
try {
$this->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES);
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
$this->redirectToRoute('admin.configuration.currencies.default');
}
/**
* Update currencyposition
*/
public function updatePositionAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response;
try {
$mode = $this->getRequest()->get('mode', null);
if ($mode == 'up')
$mode = CurrencyUpdatePositionEvent::POSITION_UP;
else if ($mode == 'down')
$mode = CurrencyUpdatePositionEvent::POSITION_DOWN;
else
$mode = CurrencyUpdatePositionEvent::POSITION_ABSOLUTE;
$position = $this->getRequest()->get('position', null);
$event = new CurrencyUpdatePositionEvent(
$this->getRequest()->get('currency_id', null),
$mode,
$this->getRequest()->get('position', null)
);
$this->dispatch(TheliaEvents::CURRENCY_UPDATE_POSITION, $event);
} catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
$this->redirectToRoute('admin.configuration.currencies.default');
}
/**
* Delete a currency object
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function deleteAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.delete")) return $response;
// Get the currency id, and dispatch the delet request
$event = new CurrencyDeleteEvent($this->getRequest()->get('currency_id'));
$this->dispatch(TheliaEvents::CURRENCY_DELETE, $event);
if ($event->hasCurrency())
$this->adminLogAppend(sprintf("Currency %s (ID %s) modified", $event->getCurrency()->getName(), $event->getCurrency()->getId()));
$this->redirectToRoute('admin.configuration.currencies.default');
}
}

View File

@@ -22,6 +22,15 @@
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Propel\Runtime\Exception\PropelException;
use Symfony\Component\Form\Form;
use Thelia\Core\Event\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\CustomerEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\CustomerModification;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\CustomerQuery;
use Thelia\Core\Translation\Translator;
/**
* Class CustomerController
@@ -32,15 +41,141 @@ class CustomerController extends BaseAdminController
{
public function indexAction()
{
if (null !== $response = $this->checkAuth("admin.customers.view")) return $response;
if (null !== $response = $this->checkAuth("admin.customer.view")) return $response;
return $this->render("customers", array("display_customer" => 20));
}
public function viewAction($customer_id)
{
if (null !== $response = $this->checkAuth("admin.customer.view")) return $response;
return $this->render("customer-edit", array(
"customer_id" => $customer_id
));
}
/**
* update customer action
*
* @param $customer_id
* @return mixed|\Symfony\Component\HttpFoundation\Response
*/
public function updateAction($customer_id)
{
if (null !== $response = $this->checkAuth("admin.customer.update")) return $response;
$message = false;
$customerModification = new CustomerModification($this->getRequest());
try {
$customer = CustomerQuery::create()->findPk($customer_id);
if(null === $customer) {
throw new \InvalidArgumentException(sprintf("%d customer id does not exists", $customer_id));
}
$form = $this->validateForm($customerModification);
$event = $this->createEventInstance($form->getData());
$event->setCustomer($customer);
$this->dispatch(TheliaEvents::CUSTOMER_UPDATEACCOUNT, $event);
$customerUpdated = $event->getCustomer();
$this->adminLogAppend(sprintf("Customer with Ref %s (ID %d) modified", $customerUpdated->getRef() , $customerUpdated->getId()));
if($this->getRequest()->get("save_mode") == "close") {
$this->redirectToRoute("admin.customers");
} else {
$this->redirectSuccess($customerModification);
}
} catch (FormValidationException $e) {
$message = sprintf("Please check your input: %s", $e->getMessage());
} catch (PropelException $e) {
$message = $e->getMessage();
} catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage()." ".$e->getFile());
}
if ($message !== false) {
\Thelia\Log\Tlog::getInstance()->error(sprintf("Error during customer login process : %s.", $message));
$customerModification->setErrorMessage($message);
$this->getParserContext()
->addForm($customerModification)
->setGeneralError($message)
;
}
return $this->render("customer-edit", array(
"customer_id" => $customer_id
));
}
public function deleteAction()
{
if (null !== $response = $this->checkAuth("admin.customer.delete")) return $response;
$message = null;
try {
$customer_id = $this->getRequest()->get("customer_id");
$customer = CustomerQuery::create()->findPk($customer_id);
if(null === $customer) {
throw new \InvalidArgumentException(Translator::getInstance("The customer you want to delete does not exists"));
}
$event = new CustomerEvent($customer);
$this->dispatch(TheliaEvents::CUSTOMER_DELETEACCOUNT, $event);
} catch(\Exception $e) {
$message = $e->getMessage();
}
$params = array(
"customer_page" => $this->getRequest()->get("customer_page", 1)
);
if ($message) {
$params["delete_error_message"] = $message;
}
$this->redirectToRoute("admin.customers", $params);
}
/**
* @param $data
* @return CustomerCreateOrUpdateEvent
*/
private function createEventInstance($data)
{
$customerCreateEvent = new CustomerCreateOrUpdateEvent(
$data["title"],
$data["firstname"],
$data["lastname"],
$data["address1"],
$data["address2"],
$data["address3"],
$data["phone"],
$data["cellphone"],
$data["zipcode"],
$data["city"],
$data["country"],
isset($data["email"])?$data["email"]:null,
isset($data["password"]) ? $data["password"]:null,
$this->getRequest()->getSession()->getLang()->getId(),
isset($data["reseller"])?$data["reseller"]:null,
isset($data["sponsor"])?$data["sponsor"]:null,
isset($data["discount"])?$data["discount"]:null,
isset($data["company"])?$data["company"]:null
);
return $customerCreateEvent;
}
}

View File

@@ -24,11 +24,8 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\MessageDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Tools\URL;
use Thelia\Core\Event\MessageUpdateEvent;
use Thelia\Core\Event\TheliaEvents;use Thelia\Core\Event\MessageUpdateEvent;
use Thelia\Core\Event\MessageCreateEvent;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\MessageQuery;
use Thelia\Form\MessageModificationForm;
use Thelia\Form\MessageCreationForm;
@@ -38,217 +35,140 @@ use Thelia\Form\MessageCreationForm;
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
class MessageController extends BaseAdminController
class MessageController extends AbstractCrudController
{
/**
* Render the messages list
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
protected function renderList()
public function __construct()
{
parent::__construct(
'message',
null, // no sort order change
null, // no sort order change
'admin.configuration.messages.view',
'admin.configuration.messages.create',
'admin.configuration.messages.update',
'admin.configuration.messages.delete',
TheliaEvents::MESSAGE_CREATE,
TheliaEvents::MESSAGE_UPDATE,
TheliaEvents::MESSAGE_DELETE,
null, // No visibility toggle
null // No position update
);
}
protected function getCreationForm()
{
return new MessageCreationForm($this->getRequest());
}
protected function getUpdateForm()
{
return new MessageModificationForm($this->getRequest());
}
protected function getCreationEvent($formData)
{
$createEvent = new MessageCreateEvent();
$createEvent
->setMessageName($formData['name'])
->setLocale($formData["locale"])
->setTitle($formData['title'])
->setSecured($formData['secured'])
;
return $createEvent;
}
protected function getUpdateEvent($formData)
{
$changeEvent = new MessageUpdateEvent($formData['id']);
// Create and dispatch the change event
$changeEvent
->setMessageName($formData['name'])
->setSecured($formData['secured'])
->setLocale($formData["locale"])
->setTitle($formData['title'])
->setSubject($formData['subject'])
->setHtmlMessage($formData['html_message'])
->setTextMessage($formData['text_message'])
;
return $changeEvent;
}
protected function getDeleteEvent()
{
return new MessageDeleteEvent($this->getRequest()->get('message_id'));
}
protected function eventContainsObject($event)
{
return $event->hasMessage();
}
protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form
$data = array(
'id' => $object->getId(),
'name' => $object->getName(),
'secured' => $object->getSecured(),
'locale' => $object->getLocale(),
'title' => $object->getTitle(),
'subject' => $object->getSubject(),
'html_message' => $object->getHtmlMessage(),
'text_message' => $object->getTextMessage()
);
// Setup the object form
return new MessageModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event)
{
return $event->hasMessage() ? $event->getMessage() : null;
}
protected function getExistingObject()
{
return MessageQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('message_id'));
}
protected function getObjectLabel($object)
{
return $object->getName();
}
protected function getObjectId($object)
{
return $object->getId();
}
protected function renderListTemplate($currentOrder)
{
return $this->render('messages');
}
/**
* The default action is displaying the messages list.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function defaultAction()
protected function renderEditionTemplate()
{
if (null !== $response = $this->checkAuth("admin.configuration.messages.view")) return $response;
return $this->renderList();
}
/**
* Create a new message object
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function createAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.messages.create")) return $response;
$message = false;
// Create the creation Form
$creationForm = new MessageCreationForm($this->getRequest());
try {
// Validate the form, create the MessageCreation event and dispatch it.
$form = $this->validateForm($creationForm, "POST");
$data = $form->getData();
$createEvent = new MessageCreateEvent();
$createEvent
->setMessageName($data['name'])
->setLocale($data["locale"])
->setTitle($data['title'])
->setSecured($data['secured'])
;
$this->dispatch(TheliaEvents::MESSAGE_CREATE, $createEvent);
if (! $createEvent->hasMessage()) throw new \LogicException($this->getTranslator()->trans("No message was created."));
$createdObject = $createEvent->getMessage();
$this->adminLogAppend(sprintf("Message %s (ID %s) created", $createdObject->getName(), $createdObject->getId()));
// Substitute _ID_ in the URL with the ID of the created object
$successUrl = str_replace('_ID_', $createdObject->getId(), $creationForm->getSuccessUrl());
// Redirect to the success URL
$this->redirect($successUrl);
} catch (FormValidationException $ex) {
// Form cannot be validated
$message = $this->createStandardFormValidationErrorMessage($ex);
} catch (\Exception $ex) {
// Any other error
$message = $ex->getMessage();
}
$this->setupFormErrorContext("message modification", $message, $creationForm, $ex);
// At this point, the form has error, and should be redisplayed.
return $this->render('messages');
}
/**
* Load a message object for modification, and display the edit template.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function changeAction()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.messages.update")) return $response;
// Load the message object
$message = MessageQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('message_id'));
if ($message != null) {
// Prepare the data that will hydrate the form
$data = array(
'id' => $message->getId(),
'name' => $message->getName(),
'secured' => $message->getSecured(),
'locale' => $message->getLocale(),
'title' => $message->getTitle(),
'subject' => $message->getSubject(),
'html_message' => $message->getHtmlMessage(),
'text_message' => $message->getTextMessage()
);
// Setup the object form
$changeForm = new MessageModificationForm($this->getRequest(), "form", $data);
// Pass it to the parser
$this->getParserContext()->addForm($changeForm);
}
// Render the edition template.
return $this->render('message-edit', array('message_id' => $this->getRequest()->get('message_id')));
}
/**
* Save changes on a modified message object, and either go back to the message list, or stay on the edition page.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function saveChangeAction()
protected function redirectToEditionTemplate()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.messages.update")) return $response;
$message = false;
// Create the form from the request
$changeForm = new MessageModificationForm($this->getRequest());
// Get the message ID
$message_id = $this->getRequest()->get('message_id');
try {
// Check the form against constraints violations
$form = $this->validateForm($changeForm, "POST");
// Get the form field values
$data = $form->getData();
$changeEvent = new MessageUpdateEvent($data['id']);
// Create and dispatch the change event
$changeEvent
->setMessageName($data['name'])
->setSecured($data['secured'])
->setLocale($data["locale"])
->setTitle($data['title'])
->setSubject($data['subject'])
->setHtmlMessage($data['html_message'])
->setTextMessage($data['text_message'])
;
$this->dispatch(TheliaEvents::MESSAGE_UPDATE, $changeEvent);
if (! $changeEvent->hasMessage()) throw new \LogicException($this->getTranslator()->trans("No message was updated."));
$changedObject = $changeEvent->getMessage();
$this->adminLogAppend(sprintf("Variable %s (ID %s) modified", $changedObject->getName(), $changedObject->getId()));
// 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->redirectToRoute(
"admin.configuration.messages.update",
array('message_id' => $message_id)
);
}
// Redirect to the success URL
$this->redirect($changeForm->getSuccessUrl());
} catch (FormValidationException $ex) {
// Form cannot be validated
$message = $this->createStandardFormValidationErrorMessage($ex);
} catch (\Exception $ex) {
// Any other error
$message = $ex->getMessage();
}
$this->setupFormErrorContext("message modification", $message, $changeForm, $ex);
// At this point, the form has errors, and should be redisplayed.
return $this->render('message-edit', array('message_id' => $message_id));
$this->redirectToRoute(
"admin.configuration.messages.update",
array('message_id' => $this->getRequest()->get('message_id'))
);
}
/**
* Delete a message object
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function deleteAction()
protected function redirectToListTemplate()
{
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.messages.delete")) return $response;
// Get the message id, and dispatch the delet request
$event = new MessageDeleteEvent($this->getRequest()->get('message_id'));
$this->dispatch(TheliaEvents::MESSAGE_DELETE, $event);
if ($event->hasMessage())
$this->adminLogAppend(sprintf("Message %s (ID %s) modified", $event->getMessage()->getName(), $event->getMessage()->getId()));
$this->redirectToRoute('admin.configuration.messages.default');
}
}

View File

@@ -36,4 +36,12 @@ class OrderController extends BaseAdminController
return $this->render("orders", array("display_order" => 20));
}
public function viewAction($order_id)
{
return $this->render("order-edit", array(
"order_id" => $order_id
));
}
}

View File

@@ -30,11 +30,44 @@ use Thelia\Core\Security\Exception\AuthenticationException;
use Thelia\Tools\URL;
use Thelia\Tools\Redirect;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Security\Authentication\AdminTokenAuthenticator;
use Thelia\Core\Security\UserProvider\TokenProvider;
use Symfony\Component\HttpFoundation\Cookie;
use Thelia\Core\Security\UserProvider\CookieTokenProvider;
use Thelia\Core\Security\Exception\TokenAuthenticationException;
class SessionController extends BaseAdminController
{
public function showLoginAction()
{
// Check if we can authenticate the user with a cookie-based token
if (null !== $key = $this->getRememberMeKeyFromCookie()) {
// Create the authenticator
$authenticator = new AdminTokenAuthenticator($key);
try {
// If have found a user, store it in the security context
$user = $authenticator->getAuthentifiedUser();
$this->getSecurityContext()->setAdminUser($user);
$this->adminLogAppend("Successful token authentication");
// Update the cookie
$cookie = $this->createAdminRememberMeCookie($user);
// Render the home page
return $this->render("home");
}
catch (TokenAuthenticationException $ex) {
$this->adminLogAppend("Token based authentication failed.");
// Clear the cookie
$this->clearRememberMeCookie();
}
}
return $this->render("login");
}
@@ -44,6 +77,9 @@ class SessionController extends BaseAdminController
$this->getSecurityContext()->clearAdminUser();
// Clear the remember me cookie, if any
$this->clearRememberMeCookie();
// Go back to login page.
$this->redirectToRoute('admin.login');
}
@@ -68,10 +104,19 @@ class SessionController extends BaseAdminController
// Log authentication success
AdminLog::append("Authentication successful", $request, $user);
/**
* FIXME: we have tou find a way to send cookie
*/
if (intval($adminLoginForm->getForm()->get('remember_me')->getData()) > 0) {
// If a remember me field if present and set in the form, create
// the cookie thant store "remember me" information
$this->createAdminRememberMeCookie($user);
}
$this->dispatch(TheliaEvents::ADMIN_LOGIN);
// Redirect to the success URL
return Redirect::exec($adminLoginForm->getSuccessUrl());
// Redirect to the success URL, passing the cookie if one exists.
$this->redirect($adminLoginForm->getSuccessUrl());
} catch (FormValidationException $ex) {

View File

@@ -0,0 +1,196 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\TemplateDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\TemplateUpdateEvent;
use Thelia\Core\Event\TemplateCreateEvent;
use Thelia\Model\TemplateQuery;
use Thelia\Form\TemplateModificationForm;
use Thelia\Form\TemplateCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Model\TemplateAv;
use Thelia\Model\TemplateAvQuery;
use Thelia\Core\Event\TemplateAvUpdateEvent;
use Thelia\Core\Event\TemplateEvent;
/**
* Manages templates sent by mail
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
class TemplateController extends AbstractCrudController
{
public function __construct()
{
parent::__construct(
'template',
null,
null,
'admin.configuration.templates.view',
'admin.configuration.templates.create',
'admin.configuration.templates.update',
'admin.configuration.templates.delete',
TheliaEvents::TEMPLATE_CREATE,
TheliaEvents::TEMPLATE_UPDATE,
TheliaEvents::TEMPLATE_DELETE,
null, // No visibility toggle
null // No position update
);
}
protected function getCreationForm()
{
return new TemplateCreationForm($this->getRequest());
}
protected function getUpdateForm()
{
return new TemplateModificationForm($this->getRequest());
}
protected function getCreationEvent($formData)
{
$createEvent = new TemplateCreateEvent();
$createEvent
->setTemplateName($formData['name'])
->setLocale($formData["locale"])
;
return $createEvent;
}
protected function getUpdateEvent($formData)
{
$changeEvent = new TemplateUpdateEvent($formData['id']);
// Create and dispatch the change event
$changeEvent
->setLocale($formData["locale"])
->setTemplateName($formData['name'])
;
// Add feature and attributes list
return $changeEvent;
}
protected function getDeleteEvent()
{
return new TemplateDeleteEvent($this->getRequest()->get('template_id'));
}
protected function eventContainsObject($event)
{
return $event->hasTemplate();
}
protected function hydrateObjectForm($object)
{
$data = array(
'id' => $object->getId(),
'locale' => $object->getLocale(),
'name' => $object->getName()
);
// Setup the object form
return new TemplateModificationForm($this->getRequest(), "form", $data);
}
protected function getObjectFromEvent($event)
{
return $event->hasTemplate() ? $event->getTemplate() : null;
}
protected function getExistingObject()
{
return TemplateQuery::create()
->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('template_id'));
}
protected function getObjectLabel($object)
{
return $object->getName();
}
protected function getObjectId($object)
{
return $object->getId();
}
protected function renderListTemplate($currentOrder)
{
return $this->render('templates', array('order' => $currentOrder));
}
protected function renderEditionTemplate()
{
return $this->render(
'template-edit',
array(
'template_id' => $this->getRequest()->get('template_id'),
)
);
}
protected function redirectToEditionTemplate()
{
$this->redirectToRoute(
"admin.configuration.templates.update",
array(
'template_id' => $this->getRequest()->get('template_id'),
)
);
}
protected function redirectToListTemplate()
{
$this->redirectToRoute('admin.configuration.templates.default');
}
// Process delete failure, which may occurs if template is in use.
protected function performAdditionalDeleteAction($deleteEvent)
{
if ($deleteEvent->getProductCount() > 0) {
$this->getParserContext()->setGeneralError(
$this->getTranslator()->trans(
"This template is in use in some of your products, and cannot be deleted. Delete it from all your products and try again."
)
);
return $this->renderList();
}
// Normal delete processing
return null;
}
}

View File

@@ -25,6 +25,7 @@ namespace Thelia\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Exception\InvalidParameterException;
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
@@ -197,9 +198,9 @@ class BaseController extends ContainerAware
*
* @param string $url
*/
public function redirect($url, $status = 302)
public function redirect($url, $status = 302, $cookies = array())
{
Redirect::exec($url, $status);
Redirect::exec($url, $status, $cookies);
}
/**
@@ -263,4 +264,21 @@ class BaseController extends ContainerAware
{
return $this->container->getParameter('kernel.debug');
}
protected function accessDenied()
{
throw new AccessDeniedHttpException();
}
/**
* check if the current http request is a XmlHttpRequest.
*
* If not, send a
*/
protected function checkXmlHttpRequest()
{
if(false === $this->getRequest()->isXmlHttpRequest() && false === $this->isDebug()) {
$this->accessDenied();
}
}
}

View File

@@ -23,11 +23,12 @@
namespace Thelia\Controller\Front;
use Thelia\Core\Event\AddressCreateOrUpdateEvent;
use Thelia\Core\Event\AddressEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\AddressCreateForm;
use Thelia\Form\AddressUpdateForm;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\Base\AddressQuery;
use Thelia\Model\AddressQuery;
use Thelia\Model\Customer;
use Thelia\Tools\URL;
@@ -39,6 +40,20 @@ use Thelia\Tools\URL;
class AddressController extends BaseFrontController
{
/**
* Controller for generate modal containing update form
* Check if request is a XmlHttpRequest and address owner is the current customer
* @param $address_id
*/
public function generateModalAction($address_id)
{
$this->checkAuth();
$this->checkXmlHttpRequest();
}
/**
* Create controller.
* Check if customer is logged in
@@ -47,9 +62,7 @@ class AddressController extends BaseFrontController
*/
public function createAction()
{
if ($this->getSecurityContext()->hasCustomerUser() === false) {
$this->redirect(URL::getInstance()->getIndexPage());
}
$this->checkAuth();
$addressCreate = new AddressCreateForm($this->getRequest());
@@ -81,20 +94,28 @@ class AddressController extends BaseFrontController
}
}
public function updateAction()
public function updateViewAction($address_id)
{
$this->checkAuth();
$customer = $this->getSecurityContext()->getCustomerUser();
$address = AddressQuery::create()->findPk($address_id);
if(!$address || $customer->getId() != $address->getCustomerId()) {
$this->redirectToRoute("home");
}
$this->getParserContext()->set("address_id", $address_id);
}
public function processUpdateAction($address_id)
{
$this->checkAuth();
$request = $this->getRequest();
if ($this->getSecurityContext()->hasCustomerUser() === false) {
$this->redirectToRoute("home");
}
if (null === $address_id = $request->get("address_id")) {
$this->redirectToRoute("home");
}
$addressUpdate = new AddressUpdateForm($request);
try {
$customer = $this->getSecurityContext()->getCustomerUser();
@@ -121,7 +142,7 @@ class AddressController extends BaseFrontController
} catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
}
$this->getParserContext()->set("address_id", $address_id);
if ($message !== false) {
\Thelia\Log\Tlog::getInstance()->error(sprintf("Error during address creation process : %s", $message));
@@ -134,6 +155,22 @@ class AddressController extends BaseFrontController
}
}
public function deleteAction($address_id)
{
$this->checkAuth();
$customer = $this->getSecurityContext()->getCustomerUser();
$address = AddressQuery::create()->findPk($address_id);
if(!$address || $customer->getId() != $address->getCustomerId()) {
$this->redirectToRoute("home");
}
$this->dispatch(TheliaEvents::ADDRESS_DELETE, new AddressEvent($address));
$this->redirectToRoute("customer.account.view");
}
protected function createAddressEvent($form)
{
return new AddressCreateOrUpdateEvent(
@@ -149,7 +186,8 @@ class AddressController extends BaseFrontController
$form->get("country")->getData(),
$form->get("cellphone")->getData(),
$form->get("phone")->getData(),
$form->get("company")->getData()
$form->get("company")->getData(),
$form->get("is_default")->getData()
);
}
}

View File

@@ -50,4 +50,11 @@ class BaseFrontController extends BaseController
{
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId, array(), $referenceType), $urlParameters));
}
public function checkAuth()
{
if($this->getSecurityContext()->hasCustomerUser() === false) {
$this->redirectToRoute("customer.login.view");
}
}
}

View File

@@ -278,7 +278,8 @@ class CustomerController extends BaseFrontController
$this->getRequest()->getSession()->getLang()->getId(),
isset($data["reseller"])?$data["reseller"]:null,
isset($data["sponsor"])?$data["sponsor"]:null,
isset($data["discount"])?$data["discount"]:null
isset($data["discount"])?$data["discount"]:null,
isset($data["company"])?$data["company"]:null
);
return $customerCreateEvent;

View File

@@ -39,7 +39,7 @@ class BaseInstallController extends BaseController
{
$parser = $this->container->get("thelia.parser");
// Define the template thant shoud be used
// Define the template that shoud be used
$parser->setTemplate("install");
return $parser;

View File

@@ -33,18 +33,61 @@ class InstallController extends BaseInstallController
{
public function index()
{
$this->verifyStep(1);
//$this->verifyStep(1);
$this->getSession()->set("step", 1);
$this->render("index.html");
return $this->render("index.html");
}
public function checkPermission()
{
$this->verifyStep(2);
//$this->verifyStep(2);
$permission = new CheckPermission();
//$permission = new CheckPermission();
$this->getSession()->set("step", 2);
return $this->render("step-2.html");
}
public function databaseConnection()
{
//$this->verifyStep(2);
//$permission = new CheckPermission();
$this->getSession()->set("step", 3);
return $this->render("step-3.html");
}
public function databaseSelection()
{
//$this->verifyStep(2);
//$permission = new CheckPermission();
$this->getSession()->set("step", 4);
return $this->render("step-4.html");
}
public function generalInformation()
{
//$this->verifyStep(2);
//$permission = new CheckPermission();
$this->getSession()->set("step", 5);
return $this->render("step-5.html");
}
public function thanks()
{
//$this->verifyStep(2);
//$permission = new CheckPermission();
$this->getSession()->set("step", 6);
return $this->render("thanks.html");
}
protected function verifyStep($step)

View File

@@ -108,7 +108,12 @@ class AddressCreateOrUpdateEvent extends ActionEvent
*/
protected $address;
public function __construct($label, $title, $firstname, $lastname, $address1, $address2, $address3, $zipcode, $city, $country, $cellphone, $phone, $company)
/**
* @var int
*/
protected $isDefault;
public function __construct($label, $title, $firstname, $lastname, $address1, $address2, $address3, $zipcode, $city, $country, $cellphone, $phone, $company, $isDefault = 0)
{
$this->address1 = $address1;
$this->address2 = $address2;
@@ -123,6 +128,7 @@ class AddressCreateOrUpdateEvent extends ActionEvent
$this->phone = $phone;
$this->title = $title;
$this->zipcode = $zipcode;
$this->isDefault = $isDefault;
}
/**
@@ -229,6 +235,16 @@ class AddressCreateOrUpdateEvent extends ActionEvent
return $this->zipcode;
}
/**
* @return int
*/
public function getIsDefault()
{
return $this->isDefault;
}
/**
* @param \Thelia\Model\Customer $customer
*/

View File

@@ -0,0 +1,68 @@
<?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;
class AttributeAvCreateEvent extends AttributeAvEvent
{
protected $title;
protected $locale;
protected $attribute_id;
public function getLocale()
{
return $this->locale;
}
public function setLocale($locale)
{
$this->locale = $locale;
return $this;
}
public function getTitle()
{
return $this->title;
}
public function setTitle($title)
{
$this->title = $title;
return $this;
}
public function getAttributeId()
{
return $this->attribute_id;
}
public function setAttributeId($attribute_id)
{
$this->attribute_id = $attribute_id;
return $this;
}
}

View 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\Core\Event;
class AttributeAvDeleteEvent extends AttributeAvEvent
{
protected $attributeAv_id;
public function __construct($attributeAv_id)
{
$this->setAttributeAvId($attributeAv_id);
}
public function getAttributeAvId()
{
return $this->attributeAv_id;
}
public function setAttributeAvId($attributeAv_id)
{
$this->attributeAv_id = $attributeAv_id;
return $this;
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
use Thelia\Model\AttributeAv;
class AttributeAvEvent extends ActionEvent
{
protected $attributeAv = null;
public function __construct(AttributeAv $attributeAv = null)
{
$this->attributeAv = $attributeAv;
}
public function hasAttributeAv()
{
return ! is_null($this->attributeAv);
}
public function getAttributeAv()
{
return $this->attributeAv;
}
public function setAttributeAv($attributeAv)
{
$this->attributeAv = $attributeAv;
return $this;
}
}

View File

@@ -0,0 +1,86 @@
<?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;
class AttributeAvUpdateEvent extends AttributeAvCreateEvent
{
protected $attributeAv_id;
protected $description;
protected $chapo;
protected $postscriptum;
public function __construct($attributeAv_id)
{
$this->setAttributeAvId($attributeAv_id);
}
public function getAttributeAvId()
{
return $this->attributeAv_id;
}
public function setAttributeAvId($attributeAv_id)
{
$this->attributeAv_id = $attributeAv_id;
return $this;
}
public function getDescription()
{
return $this->description;
}
public function setDescription($description)
{
$this->description = $description;
return $this;
}
public function getChapo()
{
return $this->chapo;
}
public function setChapo($chapo)
{
$this->chapo = $chapo;
return $this;
}
public function getPostscriptum()
{
return $this->postscriptum;
}
public function setPostscriptum($postscriptum)
{
$this->postscriptum = $postscriptum;
return $this;
}
}

View File

@@ -0,0 +1,68 @@
<?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;
class AttributeCreateEvent extends AttributeEvent
{
protected $title;
protected $locale;
protected $add_to_all_templates;
public function getLocale()
{
return $this->locale;
}
public function setLocale($locale)
{
$this->locale = $locale;
return $this;
}
public function getTitle()
{
return $this->title;
}
public function setTitle($title)
{
$this->title = $title;
return $this;
}
public function getAddToAllTemplates()
{
return $this->add_to_all_templates;
}
public function setAddToAllTemplates($add_to_all_templates)
{
$this->add_to_all_templates = $add_to_all_templates;
return $this;
}
}

View 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\Core\Event;
class AttributeDeleteEvent extends AttributeEvent
{
protected $attribute_id;
public function __construct($attribute_id)
{
$this->setAttributeId($attribute_id);
}
public function getAttributeId()
{
return $this->attribute_id;
}
public function setAttributeId($attribute_id)
{
$this->attribute_id = $attribute_id;
return $this;
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
use Thelia\Model\Attribute;
class AttributeEvent extends ActionEvent
{
protected $attribute = null;
public function __construct(Attribute $attribute = null)
{
$this->attribute = $attribute;
}
public function hasAttribute()
{
return ! is_null($this->attribute);
}
public function getAttribute()
{
return $this->attribute;
}
public function setAttribute($attribute)
{
$this->attribute = $attribute;
return $this;
}
}

View File

@@ -0,0 +1,86 @@
<?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;
class AttributeUpdateEvent extends AttributeCreateEvent
{
protected $attribute_id;
protected $description;
protected $chapo;
protected $postscriptum;
public function __construct($attribute_id)
{
$this->setAttributeId($attribute_id);
}
public function getAttributeId()
{
return $this->attribute_id;
}
public function setAttributeId($attribute_id)
{
$this->attribute_id = $attribute_id;
return $this;
}
public function getDescription()
{
return $this->description;
}
public function setDescription($description)
{
$this->description = $description;
return $this;
}
public function getChapo()
{
return $this->chapo;
}
public function setChapo($chapo)
{
$this->chapo = $chapo;
return $this;
}
public function getPostscriptum()
{
return $this->postscriptum;
}
public function setPostscriptum($postscriptum)
{
$this->postscriptum = $postscriptum;
return $this;
}
}

View File

@@ -1,17 +1,35 @@
<?php
/**
* Created by JetBrains PhpStorm.
* User: manu
* Date: 16/08/13
* Time: 10:24
* To change this template use File | Settings | File Templates.
*/
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
use Symfony\Component\EventDispatcher\Event;
use Thelia\Model\Customer;
/**
* Class CustomerCreateOrUpdateEvent
* @package Thelia\Core\Event
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CustomerCreateOrUpdateEvent extends ActionEvent
{
//base parameters for creating new customer
@@ -32,6 +50,7 @@ class CustomerCreateOrUpdateEvent extends ActionEvent
protected $reseller;
protected $sponsor;
protected $discount;
protected $company;
/**
* @var \Thelia\Model\Customer
@@ -39,7 +58,7 @@ class CustomerCreateOrUpdateEvent extends ActionEvent
protected $customer;
/**
* @param int $title the title customer id
* @param int $title the title customer id
* @param string $firstname
* @param string $lastname
* @param string $address1
@@ -49,15 +68,16 @@ class CustomerCreateOrUpdateEvent extends ActionEvent
* @param string $cellphone
* @param string $zipcode
* @param string $city
* @param int $country the country id
* @param int $country the country id
* @param string $email
* @param string $password plain password, don't put hash password, it will hashes again
* @param $lang
* @param int $reseller if customer is a reseller
* @param int $sponsor customer's id sponsor
* @param int $reseller if customer is a reseller
* @param int $sponsor customer's id sponsor
* @param float $discount
* @param string $company
*/
public function __construct($title, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $country, $email, $password, $lang, $reseller, $sponsor, $discount)
public function __construct($title, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $country, $email, $password, $lang, $reseller, $sponsor, $discount, $company)
{
$this->address1 = $address1;
$this->address2 = $address2;
@@ -72,9 +92,18 @@ class CustomerCreateOrUpdateEvent extends ActionEvent
$this->cellphone = $cellphone;
$this->title = $title;
$this->zipcode = $zipcode;
$this->city = $city;
$this->reseller = $reseller;
$this->sponsor = $sponsor;
$this->discount = $discount;
$this->company = $company;
}
/**
* @return mixed
*/
public function getCompany()
{
return $this->company;
}
/**

View File

@@ -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;
class TemplateCreateEvent extends TemplateEvent
{
protected $template_name;
protected $locale;
public function getLocale()
{
return $this->locale;
}
public function setLocale($locale)
{
$this->locale = $locale;
return $this;
}
public function getTemplateName()
{
return $this->template_name;
}
public function setTemplateName($template_name)
{
$this->template_name = $template_name;
return $this;
}
}

View File

@@ -0,0 +1,59 @@
<?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;
class TemplateDeleteEvent extends TemplateEvent
{
protected $template_id;
protected $product_count;
public function __construct($template_id)
{
$this->setTemplateId($template_id);
}
public function getTemplateId()
{
return $this->template_id;
}
public function setTemplateId($template_id)
{
$this->template_id = $template_id;
return $this;
}
public function getProductCount()
{
return $this->product_count;
}
public function setProductCount($product_count)
{
$this->product_count = $product_count;
return $this;
}
}

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
use Thelia\Model\Template;
class TemplateEvent extends ActionEvent
{
protected $template = null;
public function __construct(Template $template = null)
{
$this->template = $template;
}
public function hasTemplate()
{
return ! is_null($this->template);
}
public function getTemplate()
{
return $this->template;
}
public function setTemplate($template)
{
$this->template = $template;
return $this;
}
}

View File

@@ -0,0 +1,71 @@
<?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;
class TemplateUpdateEvent extends TemplateCreateEvent
{
protected $template_id;
protected $feature_list;
protected $attribute_list;
public function __construct($template_id)
{
$this->setTemplateId($template_id);
}
public function getTemplateId()
{
return $this->template_id;
}
public function setTemplateId($template_id)
{
$this->template_id = $template_id;
return $this;
}
public function getFeatureList()
{
return $this->feature_list;
}
public function setFeatureList($feature_list)
{
$this->feature_list = $feature_list;
return $this;
}
public function getAttributeList()
{
return $this->attribute_list;
}
public function setAttributeList($attribute_list)
{
$this->attribute_list = $attribute_list;
return $this;
}
}

View File

@@ -71,6 +71,11 @@ final class TheliaEvents
*/
const CUSTOMER_UPDATEACCOUNT = "action.updateCustomer";
/**
* sent on customer removal
*/
const CUSTOMER_DELETEACCOUNT = "action.deleteCustomer";
/**
* sent when a customer need a new password
*/
@@ -103,6 +108,16 @@ final class TheliaEvents
*/
const AFTER_UPDATECUSTOMER = "action.after_updateCustomer";
/**
* sent just before customer removal
*/
const BEFORE_DELETECUSTOMER = "action.before_updateCustomer";
/**
* sent just after customer removal
*/
const AFTER_DELETECUSTOMER = "action.after_deleteCustomer";
// -- ADDRESS MANAGEMENT ---------------------------------------------------------
/**
* sent for address creation
@@ -114,6 +129,11 @@ final class TheliaEvents
*/
const ADDRESS_UPDATE = "action.updateAddress";
/**
* sent on address removal
*/
const ADDRESS_DELETE = "action.deleteAddress";
const BEFORE_CREATEADDRESS = "action.before_createAddress";
const AFTER_CREATEADDRESS = "action.after_createAddress";
@@ -347,5 +367,53 @@ final class TheliaEvents
const BEFORE_DELETECURRENCY = "action.before_deleteCurrency";
const AFTER_DELETECURRENCY = "action.after_deleteCurrency";
// -- Product templates management -----------------------------------------
const TEMPLATE_CREATE = "action.createTemplate";
const TEMPLATE_UPDATE = "action.updateTemplate";
const TEMPLATE_DELETE = "action.deleteTemplate";
const BEFORE_CREATETEMPLATE = "action.before_createTemplate";
const AFTER_CREATETEMPLATE = "action.after_createTemplate";
const BEFORE_UPDATETEMPLATE = "action.before_updateTemplate";
const AFTER_UPDATETEMPLATE = "action.after_updateTemplate";
const BEFORE_DELETETEMPLATE = "action.before_deleteTemplate";
const AFTER_DELETETEMPLATE = "action.after_deleteTemplate";
// -- Attributes management ---------------------------------------------
const ATTRIBUTE_CREATE = "action.createAttribute";
const ATTRIBUTE_UPDATE = "action.updateAttribute";
const ATTRIBUTE_DELETE = "action.deleteAttribute";
const ATTRIBUTE_UPDATE_POSITION = "action.updateAttributePosition";
const ATTRIBUTE_REMOVE_FROM_ALL_TEMPLATES = "action.addAttributeToAllTemplate";
const ATTRIBUTE_ADD_TO_ALL_TEMPLATES = "action.removeAttributeFromAllTemplate";
const BEFORE_CREATEATTRIBUTE = "action.before_createAttribute";
const AFTER_CREATEATTRIBUTE = "action.after_createAttribute";
const BEFORE_UPDATEATTRIBUTE = "action.before_updateAttribute";
const AFTER_UPDATEATTRIBUTE = "action.after_updateAttribute";
const BEFORE_DELETEATTRIBUTE = "action.before_deleteAttribute";
const AFTER_DELETEATTRIBUTE = "action.after_deleteAttribute";
// -- Attributes values management ----------------------------------------
const ATTRIBUTE_AV_CREATE = "action.createAttributeAv";
const ATTRIBUTE_AV_UPDATE = "action.updateAttributeAv";
const ATTRIBUTE_AV_DELETE = "action.deleteAttributeAv";
const ATTRIBUTE_AV_UPDATE_POSITION = "action.updateAttributeAvPosition";
const BEFORE_CREATEATTRIBUTE_AV = "action.before_createAttributeAv";
const AFTER_CREATEATTRIBUTE_AV = "action.after_createAttributeAv";
const BEFORE_UPDATEATTRIBUTE_AV = "action.before_updateAttributeAv";
const AFTER_UPDATEATTRIBUTE_AV = "action.after_updateAttributeAv";
const BEFORE_DELETEATTRIBUTE_AV = "action.before_deleteAttributeAv";
const AFTER_DELETEATTRIBUTE_AV = "action.after_deleteAttributeAv";
}

View File

@@ -23,7 +23,7 @@
namespace Thelia\Core\Event;
class BaseToggleVisibilityEvent extends ActionEvent
class ToggleVisibilityEvent extends ActionEvent
{
protected $object_id;

View File

@@ -23,7 +23,7 @@
namespace Thelia\Core\Event;
class BaseUpdatePositionEvent extends ActionEvent
class UpdatePositionEvent extends ActionEvent
{
const POSITION_UP = 1;
const POSITION_DOWN = 2;

View 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\Core\HttpKernel\Exceptions;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException as BaseNotFountHttpException;
/**
* Class NotFountHttpException
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class NotFountHttpException extends BaseNotFountHttpException {
protected $adminContext = false;
public function __construct($message = null, \Exception $previous = null, $code = 0, $adminContext = false)
{
$this->adminContext = $adminContext;
parent::__construct($message, $previous, $code);
}
public function isAdminContext()
{
return $this->adminContext === true;
}
}

View File

@@ -4,7 +4,7 @@
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
@@ -21,8 +21,17 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Security\Authentication;
class CurrencyUpdatePositionEvent extends BaseUpdatePositionEvent
use Thelia\Core\Security\UserProvider\AdminTokenUserProvider;
class AdminTokenAuthenticator extends TokenAuthenticator
{
public function __construct($key)
{
parent::__construct(
$key,
new AdminTokenUserProvider()
);
}
}

View File

@@ -0,0 +1,37 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Security\Authentication;
use Thelia\Core\Security\UserProvider\CustomerTokenUserProvider;
class CustomerTokenAuthenticator extends TokenAuthenticator
{
public function __construct($key)
{
parent::__construct(
$key,
new CustomerTokenUserProvider()
);
}
}

View File

@@ -0,0 +1,57 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Security\Authentication;
use Thelia\Core\Security\Authentication\AuthenticatorInterface;
use Thelia\Core\Security\UserProvider\UserProviderInterface;
use Thelia\Core\Security\UserProvider\TokenUserProvider;
use Thelia\Core\Security\Exception\TokenAuthenticationException;
class TokenAuthenticator implements AuthenticatorInterface
{
protected $key;
protected $userProvider;
public function __construct($key, TokenUserProvider $userProvider)
{
$this->key = $key;
$this->userProvider = $userProvider;
}
/**
* @see \Thelia\Core\Security\Authentication\AuthenticatorInterface::getAuthentifiedUser()
*/
public function getAuthentifiedUser()
{
$keyData = $this->userProvider->decodeKey($this->key);
$user = $this->userProvider->getUser($keyData);
if ($user === null) throw new TokenAuthenticationException("No user matches the provided token");
return $user;
}
}

View File

@@ -4,7 +4,7 @@
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
@@ -21,8 +21,8 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Security\Exception;
class CategoryUpdatePositionEvent extends BaseUpdatePositionEvent
class TokenAuthenticationException extends \Exception
{
}

View File

@@ -0,0 +1,55 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Security\Token;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\Security\User\UserInterface;
class CookieTokenProvider
{
public function getKeyFromCookie(Request $request, $cookieName)
{
if ($request->cookies->has($cookieName)) {
// Create the authenticator
return $request->cookies->get($cookieName);
}
return null;
}
public function createCookie(UserInterface $user, $cookieName, $cookieExpires)
{
$tokenProvider = new TokenProvider();
$key = $tokenProvider->encodeKey($user);
setcookie($cookieName, $key, time() + $cookieExpires, '/');
}
public function clearCookie($cookieName)
{
setcookie($cookieName, '', time() - 3600, '/');
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Thelia\Core\Security\Token;
use Thelia\Core\Security\User\UserInterface;
class TokenProvider
{
public function encodeKey(UserInterface $user) {
// Always set a new token in the user environment
$user->setToken(uniqid());
return base64_encode(serialize(
array($user->getUsername(), $user->getToken(), $user->getSerial())));
}
public function decodeKey($key) {
$data = unserialize(base64_decode($key));
return array(
'username' => $data[0],
'token' => $data[1],
'serial' => $data[2]
);
}
}

View File

@@ -48,4 +48,24 @@ interface UserInterface
* @return void
*/
public function eraseCredentials();
}
/**
* return the user token (used by remember me authnetication system)
*/
public function getToken();
/**
* Set a token in the user data (used by remember me authnetication system)
*/
public function setToken($token);
/**
* return the user serial (used by remember me authnetication system)
*/
public function getSerial();
/**
* Set a serial number int the user data (used by remember me authnetication system)
*/
public function setSerial($serial);
}

View File

@@ -0,0 +1,39 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Security\UserProvider;
use Thelia\Model\Admin;
use Thelia\Model\AdminQuery;
class AdminTokenUserProvider extends TokenUserProvider
{
public function getUser($dataArray) {
return AdminQuery::create()
->filterByLogin($dataArray['username'])
->filterByRememberMeSerial($dataArray['serial'])
->filterByRememberMeToken($dataArray['token'])
->findOne();
}
}

View File

@@ -1,4 +1,26 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Security\UserProvider;
use Thelia\Model\Admin;

View File

@@ -0,0 +1,39 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Security\UserProvider;
use Thelia\Action\Customer;
use Thelia\Model\CustomerQuery;
class CustomerTokenUserProvider extends TokenUserProvider
{
public function getUser($dataArray) {
return CustomerQuery::create()
->filterByEmail($dataArray['username'])
->filterByRememberMeSerial($dataArray['serial'])
->filterByRememberMeToken($dataArray['token'])
->findOne();
}
}

View File

@@ -1,4 +1,26 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Security\UserProvider;
use Thelia\Action\Customer;
@@ -13,4 +35,4 @@ class CustomerUserProvider implements UserProviderInterface
return $customer;
}
}
}

View File

@@ -4,7 +4,7 @@
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
@@ -21,8 +21,12 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
namespace Thelia\Core\Security\UserProvider;
class CategoryToggleVisibilityEvent extends BaseToggleVisibilityEvent
use Thelia\Core\Security\User\UserInterface;
use Thelia\Core\Security\Token\TokenProvider;
abstract class TokenUserProvider extends TokenProvider implements UserProviderInterface
{
public abstract function getUser($key);
}

View File

@@ -1,4 +1,25 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Security\UserProvider;

View File

@@ -129,6 +129,7 @@ abstract class BaseLoop
$loopType = isset($nameValuePairs['type']) ? $nameValuePairs['type'] : "undefined";
$loopName = isset($nameValuePairs['name']) ? $nameValuePairs['name'] : "undefined";
$this->args->rewind();
while (($argument = $this->args->current()) !== false) {
$this->args->next();

View File

@@ -63,7 +63,7 @@ class Address extends BaseLoop
),
'current'
),
Argument::createBooleanTypeArgument('default', false),
Argument::createBooleanTypeArgument('default'),
Argument::createIntListTypeArgument('exclude')
);
}
@@ -100,6 +100,8 @@ class Address extends BaseLoop
if ($default === true) {
$search->filterByIsDefault(1, Criteria::EQUAL);
} else if($default === false) {
$search->filterByIsDefault(0, Criteria::EQUAL);
}
$exclude = $this->getExclude();

View File

@@ -38,6 +38,9 @@ use Thelia\Model\Map\ProductCategoryTableMap;
use Thelia\Type\TypeCollection;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
use Thelia\Model\ProductQuery;
use Thelia\Model\TemplateQuery;
use Thelia\Model\AttributeTemplateQuery;
/**
*
@@ -60,13 +63,12 @@ class Attribute extends BaseI18nLoop
return new ArgumentCollection(
Argument::createIntListTypeArgument('id'),
Argument::createIntListTypeArgument('product'),
Argument::createIntListTypeArgument('category'),
Argument::createBooleanOrBothTypeArgument('visible', 1),
Argument::createIntListTypeArgument('template'),
Argument::createIntListTypeArgument('exclude'),
new Argument(
'order',
new TypeCollection(
new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse'))
new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse', 'manual', 'manual_reverse'))
),
'manual'
)
@@ -101,26 +103,23 @@ class Attribute extends BaseI18nLoop
$search->filterById($exclude, Criteria::NOT_IN);
}
$visible = $this->getVisible();
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
$product = $this->getProduct();
$category = $this->getCategory();
$template = $this->getTemplate();
if (null !== $product) {
$productCategories = ProductCategoryQuery::create()->select(array(ProductCategoryTableMap::CATEGORY_ID))->filterByProductId($product, Criteria::IN)->find()->getData();
// Find the template assigned to the product.
$productObj = ProductQuery::create()->findPk($product);
if (null === $category) {
$category = $productCategories;
} else {
$category = array_merge($category, $productCategories);
}
}
// Ignore if the product cannot be found.
if ($productObj !== null)
$template = $productObj->getTemplate();
}
if (null !== $category) {
$search->filterByCategory(
CategoryQuery::create()->filterById($category)->find(),
// If we have to filter by template, find all attributes assigned to this template, and filter by found IDs
if (null !== $template) {
$search->filterById(
AttributeTemplateQuery::create()->filterByTemplateId($template)->select('id')->find(),
Criteria::IN
);
}
@@ -129,6 +128,12 @@ class Attribute extends BaseI18nLoop
foreach ($orders as $order) {
switch ($order) {
case "id":
$search->orderById(Criteria::ASC);
break;
case "id_reverse":
$search->orderById(Criteria::DESC);
break;
case "alpha":
$search->addAscendingOrderByColumn('i18n_TITLE');
break;

View File

@@ -59,7 +59,7 @@ class AttributeAvailability extends BaseI18nLoop
new Argument(
'order',
new TypeCollection(
new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse'))
new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse', 'manual', 'manual_reverse'))
),
'manual'
)
@@ -100,6 +100,12 @@ class AttributeAvailability extends BaseI18nLoop
foreach ($orders as $order) {
switch ($order) {
case 'id':
$search->orderById(Criteria::ASC);
break;
case 'id_reverse':
$search->orderById(Criteria::DESC);
break;
case "alpha":
$search->addAscendingOrderByColumn('i18n_TITLE');
break;

View File

@@ -79,7 +79,7 @@ class Category extends BaseI18nLoop
new Argument(
'order',
new TypeCollection(
new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'visible', 'visible_reverse', 'random'))
new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'visible', 'visible_reverse', 'random'))
),
'manual'
),
@@ -132,6 +132,12 @@ class Category extends BaseI18nLoop
foreach ($orders as $order) {
switch ($order) {
case "id":
$search->orderById(Criteria::ASC);
break;
case "id_reverse":
$search->orderById(Criteria::DESC);
break;
case "alpha":
$search->addAscendingOrderByColumn('i18n_TITLE');
break;

View File

@@ -0,0 +1,114 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\Base\CategoryQuery;
use Thelia\Model\Base\ProductCategoryQuery;
use Thelia\Model\Base\TemplateQuery;
use Thelia\Model\Map\ProductCategoryTableMap;
use Thelia\Type\TypeCollection;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/**
*
* Template loop
*
*
* Class Template
* @package Thelia\Core\Template\Loop
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class Template extends BaseI18nLoop
{
public $timestampable = true;
/**
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id'),
Argument::createIntListTypeArgument('exclude')
);
}
/**
* @param $pagination
*
* @return \Thelia\Core\Template\Element\LoopResult
*/
public function exec(&$pagination)
{
$search = TemplateQuery::create();
$backendContext = $this->getBackend_context();
$lang = $this->getLang();
/* manage translations */
$locale = $this->configureI18nProcessing($search, $columns = array('NAME'));
$id = $this->getId();
if (null !== $id) {
$search->filterById($id, Criteria::IN);
}
$exclude = $this->getExclude();
if (null !== $exclude) {
$search->filterById($exclude, Criteria::NOT_IN);
}
/* perform search */
$templates = $this->search($search, $pagination);
$loopResult = new LoopResult($templates);
foreach ($templates as $template) {
$loopResultRow = new LoopResultRow($loopResult, $template, $this->versionable, $this->timestampable, $this->countable);
$loopResultRow
->set("ID", $template->getId())
->set("IS_TRANSLATED" , $template->getVirtualColumn('IS_TRANSLATED'))
->set("LOCALE" , $locale)
->set("NAME" , $template->getVirtualColumn('i18n_NAME'))
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -106,6 +106,9 @@ class AdminUtilities extends AbstractSmartyPlugin
// The column label
$label = $this->getParam($params, 'label');
// The request parameter
$request_parameter_name = $this->getParam($params, 'request_parameter_name', 'order');
if ($current_order == $order) {
$icon = 'up';
$order_change = $reverse_order;
@@ -121,7 +124,7 @@ class AdminUtilities extends AbstractSmartyPlugin
else
$output = '';
return sprintf('%s<a href="%s">%s</a>', $output, URL::getInstance()->absoluteUrl($path, array('order' => $order_change)), $label);
return sprintf('%s<a href="%s">%s</a>', $output, URL::getInstance()->absoluteUrl($path, array($request_parameter_name => $order_change)), $label);
}
/**

View File

@@ -112,40 +112,68 @@ class Form extends AbstractSmartyPlugin
}
}
protected function assignFieldValues($template, $fieldName, $fieldValue, $fieldVars)
{
$template->assign("name", $fieldName);
$template->assign("value", $fieldValue);
// If Checkbox input type
if ($fieldVars['checked'] !== null) {
$this->renderFormFieldCheckBox($template, $formFieldView['checked']);
}
$template->assign("label", $fieldVars["label"]);
$template->assign("label_attr", $fieldVars["label_attr"]);
$errors = $fieldVars["errors"];
$template->assign("error", empty($errors) ? false : true);
if (! empty($errors)) {
$this->assignFieldErrorVars($template, $errors);
}
$attr = array();
foreach ($fieldVars["attr"] as $key => $value) {
$attr[] = sprintf('%s="%s"', $key, $value);
}
$template->assign("attr", implode(" ", $attr));
}
public function renderFormField($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
if ($repeat) {
if ($repeat) {
$formFieldView = $this->getFormFieldView($params);
$template->assign("options", $formFieldView->vars);
$template->assign("name", $formFieldView->vars["full_name"]);
$template->assign("value", $formFieldView->vars["value"]);
$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)) {
// If Checkbox input type
if ($formFieldView->vars['checked'] !== null) {
$this->renderFormFieldCheckBox($template, $formFieldView);
}
$key = $this->getParam($params, 'value_key');
$template->assign("label", $formFieldView->vars["label"]);
$template->assign("label_attr", $formFieldView->vars["label_attr"]);
if ($key != null) {
$errors = $formFieldView->vars["errors"];
if (isset($value[$key])) {
$template->assign("error", empty($errors) ? false : true);
$name = sprintf("%s[%s]", $formFieldView->vars["full_name"], $key);
$val = $value[$key];
if (! empty($errors)) {
$this->assignFieldErrorVars($template, $errors);
}
$attr = array();
foreach ($formFieldView->vars["attr"] as $key => $value) {
$attr[] = sprintf('%s="%s"', $key, $value);
}
$template->assign("attr", implode(" ", $attr));
$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);
$formFieldView->setRendered();
} else {
@@ -275,12 +303,12 @@ class Form extends AbstractSmartyPlugin
* @param \Smarty_Internal_Template $template
* @param $formFieldView
*/
public function renderFormFieldCheckBox(\Smarty_Internal_Template $template, $formFieldView)
public function renderFormFieldCheckBox(\Smarty_Internal_Template $template, $isChecked)
{
$template->assign("value", 0);
if ($formFieldView->vars['checked']) {
if ($isChecked) {
$template->assign("value", 1);
}
$template->assign("value", $formFieldView->vars['checked']);
$template->assign("value", $isChecked);
}
}

View File

@@ -67,12 +67,12 @@ class TheliaLoop extends AbstractSmartyPlugin
*
* @return \PropelModelPager
*/
public static function getPagination($loopId)
public static function getPagination($loopName)
{
if (!empty(self::$pagination[$loopId])) {
return self::$pagination[$loopId];
if (array_key_exists($loopName, self::$pagination)) {
return self::$pagination[$loopName];
} else {
return null;
throw new \InvalidArgumentException("Loop $loopName is not defined");
}
}
@@ -242,16 +242,10 @@ class TheliaLoop extends AbstractSmartyPlugin
if (null == $loopName)
throw new \InvalidArgumentException("Missing 'rel' parameter in page loop");
// Find loop results in the current template vars
/* $loopResults = $template->getTemplateVars($loopName);
if (empty($loopResults)) {
throw new \InvalidArgumentException("Loop $loopName is not defined.");
}*/
// Find pagination
$pagination = self::getPagination($loopName);
if ($pagination === null) {
throw new \InvalidArgumentException("Loop $loopName is not defined");
if ($pagination === null) { // loop gas no result
return '';
}
if ($pagination->getNbResults() == 0) {

View File

@@ -54,6 +54,7 @@ class UrlGenerator extends AbstractSmartyPlugin
$url = URL::getInstance()->absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target')));
if ($target != null) $url .= '#'.$target;
return $url;
}

View File

@@ -212,7 +212,7 @@ class TheliaHttpKernel extends HttpKernel
if (Model\ConfigQuery::read("session_config.default")) {
$storage->setSaveHandler(new Session\Storage\Handler\NativeFileSessionHandler(Model\ConfigQuery::read("session_config.save_path", THELIA_ROOT . '/local/session/')));
} else {
$handlerString = Model\ConfigQuery::read("session_config.handlers");
$handlerString = Model\ConfigQuery::read("session_config.handlers", 'Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler');
$handler = new $handlerString;

View File

@@ -60,7 +60,7 @@ class AddressCreateForm extends BaseForm
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Address label *"),
"label" => Translator::getInstance()->trans("Address label"),
"label_attr" => array(
"for" => "label_create"
),
@@ -154,11 +154,17 @@ class AddressCreateForm extends BaseForm
)
))
->add("company", "text", array(
"label" => Translator::getInstance()->trans("Compagny"),
"label" => Translator::getInstance()->trans("Company"),
"label_attr" => array(
"for" => "company_create"
)
))
->add("is_default", "integer", array(
"label" => Translator::getInstance()->trans("Make this address has my primary address"),
"label_attr" => array(
"for" => "default_address"
)
))
;
}

View File

@@ -0,0 +1,62 @@
<?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 Thelia\Model\CurrencyQuery;
use Symfony\Component\Validator\ExecutionContextInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
class AttributeAvCreationForm extends BaseForm
{
protected function buildForm()
{
$this->formBuilder
->add("title" , "text" , array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Title *"),
"label_attr" => array(
"for" => "title"
))
)
->add("locale" , "text" , array(
"constraints" => array(
new NotBlank()
))
)
->add("attribute_id", "hidden", array(
"constraints" => array(
new NotBlank()
))
)
;
}
public function getName()
{
return "thelia_attributeav_creation";
}
}

View File

@@ -0,0 +1,66 @@
<?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 Thelia\Model\CurrencyQuery;
use Symfony\Component\Validator\ExecutionContextInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
class AttributeCreationForm extends BaseForm
{
protected function buildForm()
{
$this->formBuilder
->add("title" , "text" , array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Title *"),
"label_attr" => array(
"for" => "title"
))
)
->add("locale" , "text" , array(
"constraints" => array(
new NotBlank()
))
)
->add("add_to_all" , "checkbox" , array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Add to all product templates"),
"label_attr" => array(
"for" => "add_to_all"
))
)
;
}
public function getName()
{
return "thelia_attribute_creation";
}
}

View File

@@ -0,0 +1,62 @@
<?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 Thelia\Model\CurrencyQuery;
use Symfony\Component\Validator\ExecutionContextInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
use Symfony\Component\Validator\Constraints\GreaterThan;
class AttributeModificationForm extends AttributeCreationForm
{
use StandardDescriptionFieldsTrait;
protected function buildForm()
{
$this->formBuilder
->add("id", "hidden", array(
"constraints" => array(
new GreaterThan(
array('value' => 0)
)
)
))
/* FIXME: doesn't work
->add('attribute_values', 'collection', array(
'type' => 'text',
'options' => array('required' => false)
))
*/
;
// Add standard description fields
$this->addStandardDescFields();
}
public function getName()
{
return "thelia_attribute_modification";
}
}

View File

@@ -58,6 +58,12 @@ class CustomerModification extends BaseForm
$this->formBuilder
->add('update_logged_in_user', 'integer') // In a front office context, update the in-memory logged-in user data
->add("company", "text", array(
"label" => Translator::getInstance()->trans("Company"),
"label_attr" => array(
"for" => "company"
)
))
->add("firstname", "text", array(
"constraints" => array(
new Constraints\NotBlank()

View File

@@ -0,0 +1,57 @@
<?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 Thelia\Model\CurrencyQuery;
use Symfony\Component\Validator\ExecutionContextInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
class TemplateCreationForm extends BaseForm
{
protected function buildForm()
{
$this->formBuilder
->add("name" , "text" , array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Template Name *"),
"label_attr" => array(
"for" => "name"
))
)
->add("locale" , "text" , array(
"constraints" => array(
new NotBlank()
))
)
;
}
public function getName()
{
return "thelia_template_creation";
}
}

View 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\Form;
use Symfony\Component\Validator\Constraints;
use Thelia\Model\CurrencyQuery;
use Symfony\Component\Validator\ExecutionContextInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
use Symfony\Component\Validator\Constraints\GreaterThan;
class TemplateModificationForm extends TemplateCreationForm
{
use StandardDescriptionFieldsTrait;
protected function buildForm()
{
parent::buildForm();
$this->formBuilder
->add("id", "hidden", array(
"constraints" => array(
new GreaterThan(
array('value' => 0)
)
)
))
/*
->add('attributes', 'collection', array(
'type' => 'text',
'options' => array('required' => false)
))
*/
/* FIXME: doesn't work
->add('features', 'collection', array(
'type' => 'text',
'options' => array('required' => false)
))
*/
;
}
public function getName()
{
return "thelia_template_modification";
}
}

View File

@@ -34,9 +34,10 @@ abstract class BaseInstall
*/
public function __construct($verifyInstall = true)
{
/* TODO : activate this part
if (file_exists(THELIA_ROOT . '/local/config/database.yml') && $verifyInstall) {
throw new AlreadyInstallException("Thelia is already installed");
}
}*/
$this->exec();

View File

@@ -7,10 +7,24 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Thelia\Core\Event\AddressEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Base\Address as BaseAddress;
use Thelia\Model\AddressQuery;
class Address extends BaseAddress {
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
/**
* put the the current address as default one
*/
public function makeItDefault()
{
AddressQuery::create()->filterByCustomerId($this->getCustomerId())
->update(array('IsDefault' => '0'));
$this->setIsDefault(1);
$this->save();
}
/**
* Code to be run before inserting to database
* @param ConnectionInterface $con
@@ -58,6 +72,10 @@ class Address extends BaseAddress {
*/
public function preDelete(ConnectionInterface $con = null)
{
if($this->getIsDefault()) {
return false;
}
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEADDRESS, new AddressEvent($this));
return true;
}

View File

@@ -6,6 +6,7 @@ use Thelia\Core\Security\User\UserInterface;
use Thelia\Core\Security\Role\Role;
use Thelia\Model\Base\Admin as BaseAdmin;
use Propel\Runtime\Connection\ConnectionInterface;
/**
* Skeleton subclass for representing a row from the 'admin' table.
@@ -20,6 +21,16 @@ use Thelia\Model\Base\Admin as BaseAdmin;
*/
class Admin extends BaseAdmin implements UserInterface
{
/**
* {@inheritDoc}
*/
public function preInsert(ConnectionInterface $con = null)
{
// Set the serial number (for auto-login)
$this->setRememberMeSerial(uniqid());
return true;
}
public function setPassword($password)
{
@@ -65,4 +76,32 @@ class Admin extends BaseAdmin implements UserInterface
public function getRoles() {
return array(new Role('ADMIN'));
}
/**
* {@inheritDoc}
*/
public function getToken() {
return $this->getRememberMeToken();
}
/**
* {@inheritDoc}
*/
public function setToken($token) {
$this->setRememberMeToken($token)->save();
}
/**
* {@inheritDoc}
*/
public function getSerial() {
return $this->getRememberMeSerial();
}
/**
* {@inheritDoc}
*/
public function setSerial($serial) {
$this->setRememberMeSerial($serial)->save();
}
}

View File

@@ -3,7 +3,69 @@
namespace Thelia\Model;
use Thelia\Model\Base\Attribute as BaseAttribute;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\AttributeEvent;
class Attribute extends BaseAttribute {
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
use \Thelia\Model\Tools\PositionManagementTrait;
/**
* {@inheritDoc}
*/
public function preInsert(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEATTRIBUTE, new AttributeEvent($this));
// Set the current position for the new object
$this->setPosition($this->getNextPosition());
return true;
}
/**
* {@inheritDoc}
*/
public function postInsert(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_CREATEATTRIBUTE, new AttributeEvent($this));
}
/**
* {@inheritDoc}
*/
public function preUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEATTRIBUTE, new AttributeEvent($this));
return true;
}
/**
* {@inheritDoc}
*/
public function postUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_UPDATEATTRIBUTE, new AttributeEvent($this));
}
/**
* {@inheritDoc}
*/
public function preDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEATTRIBUTE, new AttributeEvent($this));
return true;
}
/**
* {@inheritDoc}
*/
public function postDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_DELETEATTRIBUTE, new AttributeEvent($this));
}
}

View File

@@ -3,7 +3,78 @@
namespace Thelia\Model;
use Thelia\Model\Base\AttributeAv as BaseAttributeAv;
use Thelia\Core\Event\AttributeAvEvent;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Core\Event\TheliaEvents;
use Propel\Runtime\ActiveQuery\Criteria;
class AttributeAv extends BaseAttributeAv {
}
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
use \Thelia\Model\Tools\PositionManagementTrait;
/**
* when dealing with position, be sure to work insite the current attribute.
*/
protected function addCriteriaToPositionQuery($query) {
$query->filterByAttributeId($this->getAttributeId());
}
/**
* {@inheritDoc}
*/
public function preInsert(ConnectionInterface $con = null)
{
// Set the current position for the new object
$this->setPosition($this->getNextPosition());
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEATTRIBUTE_AV, new AttributeAvEvent($this));
return true;
}
/**
* {@inheritDoc}
*/
public function postInsert(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_CREATEATTRIBUTE_AV, new AttributeAvEvent($this));
}
/**
* {@inheritDoc}
*/
public function preUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEATTRIBUTE_AV, new AttributeAvEvent($this));
return true;
}
/**
* {@inheritDoc}
*/
public function postUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_UPDATEATTRIBUTE_AV, new AttributeAvEvent($this));
}
/**
* {@inheritDoc}
*/
public function preDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEATTRIBUTE_AV, new AttributeAvEvent($this));
return true;
}
/**
* {@inheritDoc}
*/
public function postDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_DELETEATTRIBUTE_AV, new AttributeAvEvent($this));
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\AttributeTemplate as BaseAttributeTemplate;
class AttributeTemplate extends BaseAttributeTemplate
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\AttributeTemplateQuery as BaseAttributeTemplateQuery;
/**
* Skeleton subclass for performing query and update operations on the 'attribute_template' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class AttributeTemplateQuery extends BaseAttributeTemplateQuery
{
} // AttributeTemplateQuery

View File

@@ -101,6 +101,18 @@ abstract class Admin implements ActiveRecordInterface
*/
protected $salt;
/**
* The value for the remember_me_token field.
* @var string
*/
protected $remember_me_token;
/**
* The value for the remember_me_serial field.
* @var string
*/
protected $remember_me_serial;
/**
* The value for the created_at field.
* @var string
@@ -475,6 +487,28 @@ abstract class Admin implements ActiveRecordInterface
return $this->salt;
}
/**
* Get the [remember_me_token] column value.
*
* @return string
*/
public function getRememberMeToken()
{
return $this->remember_me_token;
}
/**
* Get the [remember_me_serial] column value.
*
* @return string
*/
public function getRememberMeSerial()
{
return $this->remember_me_serial;
}
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -662,6 +696,48 @@ abstract class Admin implements ActiveRecordInterface
return $this;
} // setSalt()
/**
* Set the value of [remember_me_token] column.
*
* @param string $v new value
* @return \Thelia\Model\Admin The current object (for fluent API support)
*/
public function setRememberMeToken($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->remember_me_token !== $v) {
$this->remember_me_token = $v;
$this->modifiedColumns[] = AdminTableMap::REMEMBER_ME_TOKEN;
}
return $this;
} // setRememberMeToken()
/**
* Set the value of [remember_me_serial] column.
*
* @param string $v new value
* @return \Thelia\Model\Admin The current object (for fluent API support)
*/
public function setRememberMeSerial($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->remember_me_serial !== $v) {
$this->remember_me_serial = $v;
$this->modifiedColumns[] = AdminTableMap::REMEMBER_ME_SERIAL;
}
return $this;
} // setRememberMeSerial()
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -762,13 +838,19 @@ abstract class Admin implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : AdminTableMap::translateFieldName('Salt', TableMap::TYPE_PHPNAME, $indexType)];
$this->salt = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : AdminTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : AdminTableMap::translateFieldName('RememberMeToken', TableMap::TYPE_PHPNAME, $indexType)];
$this->remember_me_token = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : AdminTableMap::translateFieldName('RememberMeSerial', TableMap::TYPE_PHPNAME, $indexType)];
$this->remember_me_serial = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : AdminTableMap::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 ? 8 + $startcol : AdminTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : AdminTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -781,7 +863,7 @@ abstract class Admin implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 9; // 9 = AdminTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 11; // 11 = AdminTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\Admin object", 0, $e);
@@ -1069,6 +1151,12 @@ abstract class Admin implements ActiveRecordInterface
if ($this->isColumnModified(AdminTableMap::SALT)) {
$modifiedColumns[':p' . $index++] = 'SALT';
}
if ($this->isColumnModified(AdminTableMap::REMEMBER_ME_TOKEN)) {
$modifiedColumns[':p' . $index++] = 'REMEMBER_ME_TOKEN';
}
if ($this->isColumnModified(AdminTableMap::REMEMBER_ME_SERIAL)) {
$modifiedColumns[':p' . $index++] = 'REMEMBER_ME_SERIAL';
}
if ($this->isColumnModified(AdminTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
}
@@ -1107,6 +1195,12 @@ abstract class Admin implements ActiveRecordInterface
case 'SALT':
$stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR);
break;
case 'REMEMBER_ME_TOKEN':
$stmt->bindValue($identifier, $this->remember_me_token, PDO::PARAM_STR);
break;
case 'REMEMBER_ME_SERIAL':
$stmt->bindValue($identifier, $this->remember_me_serial, 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;
@@ -1197,9 +1291,15 @@ abstract class Admin implements ActiveRecordInterface
return $this->getSalt();
break;
case 7:
return $this->getCreatedAt();
return $this->getRememberMeToken();
break;
case 8:
return $this->getRememberMeSerial();
break;
case 9:
return $this->getCreatedAt();
break;
case 10:
return $this->getUpdatedAt();
break;
default:
@@ -1238,8 +1338,10 @@ abstract class Admin implements ActiveRecordInterface
$keys[4] => $this->getPassword(),
$keys[5] => $this->getAlgo(),
$keys[6] => $this->getSalt(),
$keys[7] => $this->getCreatedAt(),
$keys[8] => $this->getUpdatedAt(),
$keys[7] => $this->getRememberMeToken(),
$keys[8] => $this->getRememberMeSerial(),
$keys[9] => $this->getCreatedAt(),
$keys[10] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -1307,9 +1409,15 @@ abstract class Admin implements ActiveRecordInterface
$this->setSalt($value);
break;
case 7:
$this->setCreatedAt($value);
$this->setRememberMeToken($value);
break;
case 8:
$this->setRememberMeSerial($value);
break;
case 9:
$this->setCreatedAt($value);
break;
case 10:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1343,8 +1451,10 @@ abstract class Admin implements ActiveRecordInterface
if (array_key_exists($keys[4], $arr)) $this->setPassword($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setAlgo($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setSalt($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]]);
if (array_key_exists($keys[7], $arr)) $this->setRememberMeToken($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setRememberMeSerial($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setUpdatedAt($arr[$keys[10]]);
}
/**
@@ -1363,6 +1473,8 @@ abstract class Admin implements ActiveRecordInterface
if ($this->isColumnModified(AdminTableMap::PASSWORD)) $criteria->add(AdminTableMap::PASSWORD, $this->password);
if ($this->isColumnModified(AdminTableMap::ALGO)) $criteria->add(AdminTableMap::ALGO, $this->algo);
if ($this->isColumnModified(AdminTableMap::SALT)) $criteria->add(AdminTableMap::SALT, $this->salt);
if ($this->isColumnModified(AdminTableMap::REMEMBER_ME_TOKEN)) $criteria->add(AdminTableMap::REMEMBER_ME_TOKEN, $this->remember_me_token);
if ($this->isColumnModified(AdminTableMap::REMEMBER_ME_SERIAL)) $criteria->add(AdminTableMap::REMEMBER_ME_SERIAL, $this->remember_me_serial);
if ($this->isColumnModified(AdminTableMap::CREATED_AT)) $criteria->add(AdminTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(AdminTableMap::UPDATED_AT)) $criteria->add(AdminTableMap::UPDATED_AT, $this->updated_at);
@@ -1434,6 +1546,8 @@ abstract class Admin implements ActiveRecordInterface
$copyObj->setPassword($this->getPassword());
$copyObj->setAlgo($this->getAlgo());
$copyObj->setSalt($this->getSalt());
$copyObj->setRememberMeToken($this->getRememberMeToken());
$copyObj->setRememberMeSerial($this->getRememberMeSerial());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
@@ -1935,6 +2049,8 @@ abstract class Admin implements ActiveRecordInterface
$this->password = null;
$this->algo = null;
$this->salt = null;
$this->remember_me_token = null;
$this->remember_me_serial = null;
$this->created_at = null;
$this->updated_at = null;
$this->alreadyInSave = false;

View File

@@ -28,6 +28,8 @@ use Thelia\Model\Map\AdminTableMap;
* @method ChildAdminQuery orderByPassword($order = Criteria::ASC) Order by the password column
* @method ChildAdminQuery orderByAlgo($order = Criteria::ASC) Order by the algo column
* @method ChildAdminQuery orderBySalt($order = Criteria::ASC) Order by the salt column
* @method ChildAdminQuery orderByRememberMeToken($order = Criteria::ASC) Order by the remember_me_token column
* @method ChildAdminQuery orderByRememberMeSerial($order = Criteria::ASC) Order by the remember_me_serial column
* @method ChildAdminQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildAdminQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
@@ -38,6 +40,8 @@ use Thelia\Model\Map\AdminTableMap;
* @method ChildAdminQuery groupByPassword() Group by the password column
* @method ChildAdminQuery groupByAlgo() Group by the algo column
* @method ChildAdminQuery groupBySalt() Group by the salt column
* @method ChildAdminQuery groupByRememberMeToken() Group by the remember_me_token column
* @method ChildAdminQuery groupByRememberMeSerial() Group by the remember_me_serial column
* @method ChildAdminQuery groupByCreatedAt() Group by the created_at column
* @method ChildAdminQuery groupByUpdatedAt() Group by the updated_at column
*
@@ -59,6 +63,8 @@ use Thelia\Model\Map\AdminTableMap;
* @method ChildAdmin findOneByPassword(string $password) Return the first ChildAdmin filtered by the password column
* @method ChildAdmin findOneByAlgo(string $algo) Return the first ChildAdmin filtered by the algo column
* @method ChildAdmin findOneBySalt(string $salt) Return the first ChildAdmin filtered by the salt column
* @method ChildAdmin findOneByRememberMeToken(string $remember_me_token) Return the first ChildAdmin filtered by the remember_me_token column
* @method ChildAdmin findOneByRememberMeSerial(string $remember_me_serial) Return the first ChildAdmin filtered by the remember_me_serial column
* @method ChildAdmin findOneByCreatedAt(string $created_at) Return the first ChildAdmin filtered by the created_at column
* @method ChildAdmin findOneByUpdatedAt(string $updated_at) Return the first ChildAdmin filtered by the updated_at column
*
@@ -69,6 +75,8 @@ use Thelia\Model\Map\AdminTableMap;
* @method array findByPassword(string $password) Return ChildAdmin objects filtered by the password column
* @method array findByAlgo(string $algo) Return ChildAdmin objects filtered by the algo column
* @method array findBySalt(string $salt) Return ChildAdmin objects filtered by the salt column
* @method array findByRememberMeToken(string $remember_me_token) Return ChildAdmin objects filtered by the remember_me_token column
* @method array findByRememberMeSerial(string $remember_me_serial) Return ChildAdmin objects filtered by the remember_me_serial column
* @method array findByCreatedAt(string $created_at) Return ChildAdmin objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildAdmin objects filtered by the updated_at column
*
@@ -159,7 +167,7 @@ abstract class AdminQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, FIRSTNAME, LASTNAME, LOGIN, PASSWORD, ALGO, SALT, CREATED_AT, UPDATED_AT FROM admin WHERE ID = :p0';
$sql = 'SELECT ID, FIRSTNAME, LASTNAME, LOGIN, PASSWORD, ALGO, SALT, REMEMBER_ME_TOKEN, REMEMBER_ME_SERIAL, CREATED_AT, UPDATED_AT FROM admin WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -463,6 +471,64 @@ abstract class AdminQuery extends ModelCriteria
return $this->addUsingAlias(AdminTableMap::SALT, $salt, $comparison);
}
/**
* Filter the query on the remember_me_token column
*
* Example usage:
* <code>
* $query->filterByRememberMeToken('fooValue'); // WHERE remember_me_token = 'fooValue'
* $query->filterByRememberMeToken('%fooValue%'); // WHERE remember_me_token LIKE '%fooValue%'
* </code>
*
* @param string $rememberMeToken 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 ChildAdminQuery The current query, for fluid interface
*/
public function filterByRememberMeToken($rememberMeToken = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($rememberMeToken)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $rememberMeToken)) {
$rememberMeToken = str_replace('*', '%', $rememberMeToken);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(AdminTableMap::REMEMBER_ME_TOKEN, $rememberMeToken, $comparison);
}
/**
* Filter the query on the remember_me_serial column
*
* Example usage:
* <code>
* $query->filterByRememberMeSerial('fooValue'); // WHERE remember_me_serial = 'fooValue'
* $query->filterByRememberMeSerial('%fooValue%'); // WHERE remember_me_serial LIKE '%fooValue%'
* </code>
*
* @param string $rememberMeSerial 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 ChildAdminQuery The current query, for fluid interface
*/
public function filterByRememberMeSerial($rememberMeSerial = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($rememberMeSerial)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $rememberMeSerial)) {
$rememberMeSerial = str_replace('*', '%', $rememberMeSerial);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(AdminTableMap::REMEMBER_ME_SERIAL, $rememberMeSerial, $comparison);
}
/**
* Filter the query on the created_at column
*

View File

@@ -20,15 +20,15 @@ use Propel\Runtime\Util\PropelDateTime;
use Thelia\Model\Attribute as ChildAttribute;
use Thelia\Model\AttributeAv as ChildAttributeAv;
use Thelia\Model\AttributeAvQuery as ChildAttributeAvQuery;
use Thelia\Model\AttributeCategory as ChildAttributeCategory;
use Thelia\Model\AttributeCategoryQuery as ChildAttributeCategoryQuery;
use Thelia\Model\AttributeCombination as ChildAttributeCombination;
use Thelia\Model\AttributeCombinationQuery as ChildAttributeCombinationQuery;
use Thelia\Model\AttributeI18n as ChildAttributeI18n;
use Thelia\Model\AttributeI18nQuery as ChildAttributeI18nQuery;
use Thelia\Model\AttributeQuery as ChildAttributeQuery;
use Thelia\Model\Category as ChildCategory;
use Thelia\Model\CategoryQuery as ChildCategoryQuery;
use Thelia\Model\AttributeTemplate as ChildAttributeTemplate;
use Thelia\Model\AttributeTemplateQuery as ChildAttributeTemplateQuery;
use Thelia\Model\Template as ChildTemplate;
use Thelia\Model\TemplateQuery as ChildTemplateQuery;
use Thelia\Model\Map\AttributeTableMap;
abstract class Attribute implements ActiveRecordInterface
@@ -102,10 +102,10 @@ abstract class Attribute implements ActiveRecordInterface
protected $collAttributeCombinationsPartial;
/**
* @var ObjectCollection|ChildAttributeCategory[] Collection to store aggregation of ChildAttributeCategory objects.
* @var ObjectCollection|ChildAttributeTemplate[] Collection to store aggregation of ChildAttributeTemplate objects.
*/
protected $collAttributeCategories;
protected $collAttributeCategoriesPartial;
protected $collAttributeTemplates;
protected $collAttributeTemplatesPartial;
/**
* @var ObjectCollection|ChildAttributeI18n[] Collection to store aggregation of ChildAttributeI18n objects.
@@ -114,9 +114,9 @@ abstract class Attribute implements ActiveRecordInterface
protected $collAttributeI18nsPartial;
/**
* @var ChildCategory[] Collection to store aggregation of ChildCategory objects.
* @var ChildTemplate[] Collection to store aggregation of ChildTemplate objects.
*/
protected $collCategories;
protected $collTemplates;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -144,7 +144,7 @@ abstract class Attribute implements ActiveRecordInterface
* An array of objects scheduled for deletion.
* @var ObjectCollection
*/
protected $categoriesScheduledForDeletion = null;
protected $templatesScheduledForDeletion = null;
/**
* An array of objects scheduled for deletion.
@@ -162,7 +162,7 @@ abstract class Attribute implements ActiveRecordInterface
* An array of objects scheduled for deletion.
* @var ObjectCollection
*/
protected $attributeCategoriesScheduledForDeletion = null;
protected $attributeTemplatesScheduledForDeletion = null;
/**
* An array of objects scheduled for deletion.
@@ -697,11 +697,11 @@ abstract class Attribute implements ActiveRecordInterface
$this->collAttributeCombinations = null;
$this->collAttributeCategories = null;
$this->collAttributeTemplates = null;
$this->collAttributeI18ns = null;
$this->collCategories = null;
$this->collTemplates = null;
} // if (deep)
}
@@ -835,29 +835,29 @@ abstract class Attribute implements ActiveRecordInterface
$this->resetModified();
}
if ($this->categoriesScheduledForDeletion !== null) {
if (!$this->categoriesScheduledForDeletion->isEmpty()) {
if ($this->templatesScheduledForDeletion !== null) {
if (!$this->templatesScheduledForDeletion->isEmpty()) {
$pks = array();
$pk = $this->getPrimaryKey();
foreach ($this->categoriesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
$pks[] = array($remotePk, $pk);
foreach ($this->templatesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
$pks[] = array($pk, $remotePk);
}
AttributeCategoryQuery::create()
AttributeTemplateQuery::create()
->filterByPrimaryKeys($pks)
->delete($con);
$this->categoriesScheduledForDeletion = null;
$this->templatesScheduledForDeletion = null;
}
foreach ($this->getCategories() as $category) {
if ($category->isModified()) {
$category->save($con);
foreach ($this->getTemplates() as $template) {
if ($template->isModified()) {
$template->save($con);
}
}
} elseif ($this->collCategories) {
foreach ($this->collCategories as $category) {
if ($category->isModified()) {
$category->save($con);
} elseif ($this->collTemplates) {
foreach ($this->collTemplates as $template) {
if ($template->isModified()) {
$template->save($con);
}
}
}
@@ -896,17 +896,17 @@ abstract class Attribute implements ActiveRecordInterface
}
}
if ($this->attributeCategoriesScheduledForDeletion !== null) {
if (!$this->attributeCategoriesScheduledForDeletion->isEmpty()) {
\Thelia\Model\AttributeCategoryQuery::create()
->filterByPrimaryKeys($this->attributeCategoriesScheduledForDeletion->getPrimaryKeys(false))
if ($this->attributeTemplatesScheduledForDeletion !== null) {
if (!$this->attributeTemplatesScheduledForDeletion->isEmpty()) {
\Thelia\Model\AttributeTemplateQuery::create()
->filterByPrimaryKeys($this->attributeTemplatesScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
$this->attributeCategoriesScheduledForDeletion = null;
$this->attributeTemplatesScheduledForDeletion = null;
}
}
if ($this->collAttributeCategories !== null) {
foreach ($this->collAttributeCategories as $referrerFK) {
if ($this->collAttributeTemplates !== null) {
foreach ($this->collAttributeTemplates as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
@@ -1112,8 +1112,8 @@ abstract class Attribute implements ActiveRecordInterface
if (null !== $this->collAttributeCombinations) {
$result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
if (null !== $this->collAttributeCategories) {
$result['AttributeCategories'] = $this->collAttributeCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
if (null !== $this->collAttributeTemplates) {
$result['AttributeTemplates'] = $this->collAttributeTemplates->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
if (null !== $this->collAttributeI18ns) {
$result['AttributeI18ns'] = $this->collAttributeI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
@@ -1291,9 +1291,9 @@ abstract class Attribute implements ActiveRecordInterface
}
}
foreach ($this->getAttributeCategories() as $relObj) {
foreach ($this->getAttributeTemplates() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addAttributeCategory($relObj->copy($deepCopy));
$copyObj->addAttributeTemplate($relObj->copy($deepCopy));
}
}
@@ -1350,8 +1350,8 @@ abstract class Attribute implements ActiveRecordInterface
if ('AttributeCombination' == $relationName) {
return $this->initAttributeCombinations();
}
if ('AttributeCategory' == $relationName) {
return $this->initAttributeCategories();
if ('AttributeTemplate' == $relationName) {
return $this->initAttributeTemplates();
}
if ('AttributeI18n' == $relationName) {
return $this->initAttributeI18ns();
@@ -1848,31 +1848,31 @@ abstract class Attribute implements ActiveRecordInterface
}
/**
* Clears out the collAttributeCategories collection
* Clears out the collAttributeTemplates collection
*
* This does not modify the database; however, it will remove any associated objects, causing
* them to be refetched by subsequent calls to accessor method.
*
* @return void
* @see addAttributeCategories()
* @see addAttributeTemplates()
*/
public function clearAttributeCategories()
public function clearAttributeTemplates()
{
$this->collAttributeCategories = null; // important to set this to NULL since that means it is uninitialized
$this->collAttributeTemplates = null; // important to set this to NULL since that means it is uninitialized
}
/**
* Reset is the collAttributeCategories collection loaded partially.
* Reset is the collAttributeTemplates collection loaded partially.
*/
public function resetPartialAttributeCategories($v = true)
public function resetPartialAttributeTemplates($v = true)
{
$this->collAttributeCategoriesPartial = $v;
$this->collAttributeTemplatesPartial = $v;
}
/**
* Initializes the collAttributeCategories collection.
* Initializes the collAttributeTemplates collection.
*
* By default this just sets the collAttributeCategories collection to an empty array (like clearcollAttributeCategories());
* By default this just sets the collAttributeTemplates collection to an empty array (like clearcollAttributeTemplates());
* however, you may wish to override this method in your stub class to provide setting appropriate
* to your application -- for example, setting the initial array to the values stored in database.
*
@@ -1881,17 +1881,17 @@ abstract class Attribute implements ActiveRecordInterface
*
* @return void
*/
public function initAttributeCategories($overrideExisting = true)
public function initAttributeTemplates($overrideExisting = true)
{
if (null !== $this->collAttributeCategories && !$overrideExisting) {
if (null !== $this->collAttributeTemplates && !$overrideExisting) {
return;
}
$this->collAttributeCategories = new ObjectCollection();
$this->collAttributeCategories->setModel('\Thelia\Model\AttributeCategory');
$this->collAttributeTemplates = new ObjectCollection();
$this->collAttributeTemplates->setModel('\Thelia\Model\AttributeTemplate');
}
/**
* Gets an array of ChildAttributeCategory objects which contain a foreign key that references this object.
* Gets an array of ChildAttributeTemplate objects which contain a foreign key that references this object.
*
* If the $criteria is not null, it is used to always fetch the results from the database.
* Otherwise the results are fetched from the database the first time, then cached.
@@ -1901,109 +1901,109 @@ abstract class Attribute implements ActiveRecordInterface
*
* @param Criteria $criteria optional Criteria object to narrow the query
* @param ConnectionInterface $con optional connection object
* @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects
* @return Collection|ChildAttributeTemplate[] List of ChildAttributeTemplate objects
* @throws PropelException
*/
public function getAttributeCategories($criteria = null, ConnectionInterface $con = null)
public function getAttributeTemplates($criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collAttributeCategoriesPartial && !$this->isNew();
if (null === $this->collAttributeCategories || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAttributeCategories) {
$partial = $this->collAttributeTemplatesPartial && !$this->isNew();
if (null === $this->collAttributeTemplates || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAttributeTemplates) {
// return empty collection
$this->initAttributeCategories();
$this->initAttributeTemplates();
} else {
$collAttributeCategories = ChildAttributeCategoryQuery::create(null, $criteria)
$collAttributeTemplates = ChildAttributeTemplateQuery::create(null, $criteria)
->filterByAttribute($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collAttributeCategoriesPartial && count($collAttributeCategories)) {
$this->initAttributeCategories(false);
if (false !== $this->collAttributeTemplatesPartial && count($collAttributeTemplates)) {
$this->initAttributeTemplates(false);
foreach ($collAttributeCategories as $obj) {
if (false == $this->collAttributeCategories->contains($obj)) {
$this->collAttributeCategories->append($obj);
foreach ($collAttributeTemplates as $obj) {
if (false == $this->collAttributeTemplates->contains($obj)) {
$this->collAttributeTemplates->append($obj);
}
}
$this->collAttributeCategoriesPartial = true;
$this->collAttributeTemplatesPartial = true;
}
$collAttributeCategories->getInternalIterator()->rewind();
$collAttributeTemplates->getInternalIterator()->rewind();
return $collAttributeCategories;
return $collAttributeTemplates;
}
if ($partial && $this->collAttributeCategories) {
foreach ($this->collAttributeCategories as $obj) {
if ($partial && $this->collAttributeTemplates) {
foreach ($this->collAttributeTemplates as $obj) {
if ($obj->isNew()) {
$collAttributeCategories[] = $obj;
$collAttributeTemplates[] = $obj;
}
}
}
$this->collAttributeCategories = $collAttributeCategories;
$this->collAttributeCategoriesPartial = false;
$this->collAttributeTemplates = $collAttributeTemplates;
$this->collAttributeTemplatesPartial = false;
}
}
return $this->collAttributeCategories;
return $this->collAttributeTemplates;
}
/**
* Sets a collection of AttributeCategory objects related by a one-to-many relationship
* Sets a collection of AttributeTemplate objects related by a one-to-many relationship
* to the current object.
* It will also schedule objects for deletion based on a diff between old objects (aka persisted)
* and new objects from the given Propel collection.
*
* @param Collection $attributeCategories A Propel collection.
* @param Collection $attributeTemplates A Propel collection.
* @param ConnectionInterface $con Optional connection object
* @return ChildAttribute The current object (for fluent API support)
*/
public function setAttributeCategories(Collection $attributeCategories, ConnectionInterface $con = null)
public function setAttributeTemplates(Collection $attributeTemplates, ConnectionInterface $con = null)
{
$attributeCategoriesToDelete = $this->getAttributeCategories(new Criteria(), $con)->diff($attributeCategories);
$attributeTemplatesToDelete = $this->getAttributeTemplates(new Criteria(), $con)->diff($attributeTemplates);
$this->attributeCategoriesScheduledForDeletion = $attributeCategoriesToDelete;
$this->attributeTemplatesScheduledForDeletion = $attributeTemplatesToDelete;
foreach ($attributeCategoriesToDelete as $attributeCategoryRemoved) {
$attributeCategoryRemoved->setAttribute(null);
foreach ($attributeTemplatesToDelete as $attributeTemplateRemoved) {
$attributeTemplateRemoved->setAttribute(null);
}
$this->collAttributeCategories = null;
foreach ($attributeCategories as $attributeCategory) {
$this->addAttributeCategory($attributeCategory);
$this->collAttributeTemplates = null;
foreach ($attributeTemplates as $attributeTemplate) {
$this->addAttributeTemplate($attributeTemplate);
}
$this->collAttributeCategories = $attributeCategories;
$this->collAttributeCategoriesPartial = false;
$this->collAttributeTemplates = $attributeTemplates;
$this->collAttributeTemplatesPartial = false;
return $this;
}
/**
* Returns the number of related AttributeCategory objects.
* Returns the number of related AttributeTemplate objects.
*
* @param Criteria $criteria
* @param boolean $distinct
* @param ConnectionInterface $con
* @return int Count of related AttributeCategory objects.
* @return int Count of related AttributeTemplate objects.
* @throws PropelException
*/
public function countAttributeCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
public function countAttributeTemplates(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collAttributeCategoriesPartial && !$this->isNew();
if (null === $this->collAttributeCategories || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAttributeCategories) {
$partial = $this->collAttributeTemplatesPartial && !$this->isNew();
if (null === $this->collAttributeTemplates || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAttributeTemplates) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getAttributeCategories());
return count($this->getAttributeTemplates());
}
$query = ChildAttributeCategoryQuery::create(null, $criteria);
$query = ChildAttributeTemplateQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
@@ -2013,53 +2013,53 @@ abstract class Attribute implements ActiveRecordInterface
->count($con);
}
return count($this->collAttributeCategories);
return count($this->collAttributeTemplates);
}
/**
* Method called to associate a ChildAttributeCategory object to this object
* through the ChildAttributeCategory foreign key attribute.
* Method called to associate a ChildAttributeTemplate object to this object
* through the ChildAttributeTemplate foreign key attribute.
*
* @param ChildAttributeCategory $l ChildAttributeCategory
* @param ChildAttributeTemplate $l ChildAttributeTemplate
* @return \Thelia\Model\Attribute The current object (for fluent API support)
*/
public function addAttributeCategory(ChildAttributeCategory $l)
public function addAttributeTemplate(ChildAttributeTemplate $l)
{
if ($this->collAttributeCategories === null) {
$this->initAttributeCategories();
$this->collAttributeCategoriesPartial = true;
if ($this->collAttributeTemplates === null) {
$this->initAttributeTemplates();
$this->collAttributeTemplatesPartial = true;
}
if (!in_array($l, $this->collAttributeCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddAttributeCategory($l);
if (!in_array($l, $this->collAttributeTemplates->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddAttributeTemplate($l);
}
return $this;
}
/**
* @param AttributeCategory $attributeCategory The attributeCategory object to add.
* @param AttributeTemplate $attributeTemplate The attributeTemplate object to add.
*/
protected function doAddAttributeCategory($attributeCategory)
protected function doAddAttributeTemplate($attributeTemplate)
{
$this->collAttributeCategories[]= $attributeCategory;
$attributeCategory->setAttribute($this);
$this->collAttributeTemplates[]= $attributeTemplate;
$attributeTemplate->setAttribute($this);
}
/**
* @param AttributeCategory $attributeCategory The attributeCategory object to remove.
* @param AttributeTemplate $attributeTemplate The attributeTemplate object to remove.
* @return ChildAttribute The current object (for fluent API support)
*/
public function removeAttributeCategory($attributeCategory)
public function removeAttributeTemplate($attributeTemplate)
{
if ($this->getAttributeCategories()->contains($attributeCategory)) {
$this->collAttributeCategories->remove($this->collAttributeCategories->search($attributeCategory));
if (null === $this->attributeCategoriesScheduledForDeletion) {
$this->attributeCategoriesScheduledForDeletion = clone $this->collAttributeCategories;
$this->attributeCategoriesScheduledForDeletion->clear();
if ($this->getAttributeTemplates()->contains($attributeTemplate)) {
$this->collAttributeTemplates->remove($this->collAttributeTemplates->search($attributeTemplate));
if (null === $this->attributeTemplatesScheduledForDeletion) {
$this->attributeTemplatesScheduledForDeletion = clone $this->collAttributeTemplates;
$this->attributeTemplatesScheduledForDeletion->clear();
}
$this->attributeCategoriesScheduledForDeletion[]= clone $attributeCategory;
$attributeCategory->setAttribute(null);
$this->attributeTemplatesScheduledForDeletion[]= clone $attributeTemplate;
$attributeTemplate->setAttribute(null);
}
return $this;
@@ -2071,7 +2071,7 @@ abstract class Attribute implements ActiveRecordInterface
* an identical criteria, it returns the collection.
* Otherwise if this Attribute is new, it will return
* an empty collection; or if this Attribute has previously
* been saved, it will retrieve related AttributeCategories from storage.
* been saved, it will retrieve related AttributeTemplates from storage.
*
* This method is protected by default in order to keep the public
* api reasonable. You can provide public methods for those you
@@ -2080,14 +2080,14 @@ abstract class Attribute implements ActiveRecordInterface
* @param Criteria $criteria optional Criteria object to narrow the query
* @param ConnectionInterface $con optional connection object
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
* @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects
* @return Collection|ChildAttributeTemplate[] List of ChildAttributeTemplate objects
*/
public function getAttributeCategoriesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
public function getAttributeTemplatesJoinTemplate($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildAttributeCategoryQuery::create(null, $criteria);
$query->joinWith('Category', $joinBehavior);
$query = ChildAttributeTemplateQuery::create(null, $criteria);
$query->joinWith('Template', $joinBehavior);
return $this->getAttributeCategories($query, $con);
return $this->getAttributeTemplates($query, $con);
}
/**
@@ -2316,38 +2316,38 @@ abstract class Attribute implements ActiveRecordInterface
}
/**
* Clears out the collCategories collection
* Clears out the collTemplates collection
*
* This does not modify the database; however, it will remove any associated objects, causing
* them to be refetched by subsequent calls to accessor method.
*
* @return void
* @see addCategories()
* @see addTemplates()
*/
public function clearCategories()
public function clearTemplates()
{
$this->collCategories = null; // important to set this to NULL since that means it is uninitialized
$this->collCategoriesPartial = null;
$this->collTemplates = null; // important to set this to NULL since that means it is uninitialized
$this->collTemplatesPartial = null;
}
/**
* Initializes the collCategories collection.
* Initializes the collTemplates collection.
*
* By default this just sets the collCategories collection to an empty collection (like clearCategories());
* By default this just sets the collTemplates collection to an empty collection (like clearTemplates());
* however, you may wish to override this method in your stub class to provide setting appropriate
* to your application -- for example, setting the initial array to the values stored in database.
*
* @return void
*/
public function initCategories()
public function initTemplates()
{
$this->collCategories = new ObjectCollection();
$this->collCategories->setModel('\Thelia\Model\Category');
$this->collTemplates = new ObjectCollection();
$this->collTemplates->setModel('\Thelia\Model\Template');
}
/**
* Gets a collection of ChildCategory objects related by a many-to-many relationship
* to the current object by way of the attribute_category cross-reference table.
* Gets a collection of ChildTemplate objects related by a many-to-many relationship
* to the current object by way of the attribute_template cross-reference table.
*
* If the $criteria is not null, it is used to always fetch the results from the database.
* Otherwise the results are fetched from the database the first time, then cached.
@@ -2358,73 +2358,73 @@ abstract class Attribute implements ActiveRecordInterface
* @param Criteria $criteria Optional query object to filter the query
* @param ConnectionInterface $con Optional connection object
*
* @return ObjectCollection|ChildCategory[] List of ChildCategory objects
* @return ObjectCollection|ChildTemplate[] List of ChildTemplate objects
*/
public function getCategories($criteria = null, ConnectionInterface $con = null)
public function getTemplates($criteria = null, ConnectionInterface $con = null)
{
if (null === $this->collCategories || null !== $criteria) {
if ($this->isNew() && null === $this->collCategories) {
if (null === $this->collTemplates || null !== $criteria) {
if ($this->isNew() && null === $this->collTemplates) {
// return empty collection
$this->initCategories();
$this->initTemplates();
} else {
$collCategories = ChildCategoryQuery::create(null, $criteria)
$collTemplates = ChildTemplateQuery::create(null, $criteria)
->filterByAttribute($this)
->find($con);
if (null !== $criteria) {
return $collCategories;
return $collTemplates;
}
$this->collCategories = $collCategories;
$this->collTemplates = $collTemplates;
}
}
return $this->collCategories;
return $this->collTemplates;
}
/**
* Sets a collection of Category objects related by a many-to-many relationship
* to the current object by way of the attribute_category cross-reference table.
* Sets a collection of Template objects related by a many-to-many relationship
* to the current object by way of the attribute_template cross-reference table.
* It will also schedule objects for deletion based on a diff between old objects (aka persisted)
* and new objects from the given Propel collection.
*
* @param Collection $categories A Propel collection.
* @param Collection $templates A Propel collection.
* @param ConnectionInterface $con Optional connection object
* @return ChildAttribute The current object (for fluent API support)
*/
public function setCategories(Collection $categories, ConnectionInterface $con = null)
public function setTemplates(Collection $templates, ConnectionInterface $con = null)
{
$this->clearCategories();
$currentCategories = $this->getCategories();
$this->clearTemplates();
$currentTemplates = $this->getTemplates();
$this->categoriesScheduledForDeletion = $currentCategories->diff($categories);
$this->templatesScheduledForDeletion = $currentTemplates->diff($templates);
foreach ($categories as $category) {
if (!$currentCategories->contains($category)) {
$this->doAddCategory($category);
foreach ($templates as $template) {
if (!$currentTemplates->contains($template)) {
$this->doAddTemplate($template);
}
}
$this->collCategories = $categories;
$this->collTemplates = $templates;
return $this;
}
/**
* Gets the number of ChildCategory objects related by a many-to-many relationship
* to the current object by way of the attribute_category cross-reference table.
* Gets the number of ChildTemplate objects related by a many-to-many relationship
* to the current object by way of the attribute_template cross-reference table.
*
* @param Criteria $criteria Optional query object to filter the query
* @param boolean $distinct Set to true to force count distinct
* @param ConnectionInterface $con Optional connection object
*
* @return int the number of related ChildCategory objects
* @return int the number of related ChildTemplate objects
*/
public function countCategories($criteria = null, $distinct = false, ConnectionInterface $con = null)
public function countTemplates($criteria = null, $distinct = false, ConnectionInterface $con = null)
{
if (null === $this->collCategories || null !== $criteria) {
if ($this->isNew() && null === $this->collCategories) {
if (null === $this->collTemplates || null !== $criteria) {
if ($this->isNew() && null === $this->collTemplates) {
return 0;
} else {
$query = ChildCategoryQuery::create(null, $criteria);
$query = ChildTemplateQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
@@ -2434,65 +2434,65 @@ abstract class Attribute implements ActiveRecordInterface
->count($con);
}
} else {
return count($this->collCategories);
return count($this->collTemplates);
}
}
/**
* Associate a ChildCategory object to this object
* through the attribute_category cross reference table.
* Associate a ChildTemplate object to this object
* through the attribute_template cross reference table.
*
* @param ChildCategory $category The ChildAttributeCategory object to relate
* @param ChildTemplate $template The ChildAttributeTemplate object to relate
* @return ChildAttribute The current object (for fluent API support)
*/
public function addCategory(ChildCategory $category)
public function addTemplate(ChildTemplate $template)
{
if ($this->collCategories === null) {
$this->initCategories();
if ($this->collTemplates === null) {
$this->initTemplates();
}
if (!$this->collCategories->contains($category)) { // only add it if the **same** object is not already associated
$this->doAddCategory($category);
$this->collCategories[] = $category;
if (!$this->collTemplates->contains($template)) { // only add it if the **same** object is not already associated
$this->doAddTemplate($template);
$this->collTemplates[] = $template;
}
return $this;
}
/**
* @param Category $category The category object to add.
* @param Template $template The template object to add.
*/
protected function doAddCategory($category)
protected function doAddTemplate($template)
{
$attributeCategory = new ChildAttributeCategory();
$attributeCategory->setCategory($category);
$this->addAttributeCategory($attributeCategory);
$attributeTemplate = new ChildAttributeTemplate();
$attributeTemplate->setTemplate($template);
$this->addAttributeTemplate($attributeTemplate);
// set the back reference to this object directly as using provided method either results
// in endless loop or in multiple relations
if (!$category->getAttributes()->contains($this)) {
$foreignCollection = $category->getAttributes();
if (!$template->getAttributes()->contains($this)) {
$foreignCollection = $template->getAttributes();
$foreignCollection[] = $this;
}
}
/**
* Remove a ChildCategory object to this object
* through the attribute_category cross reference table.
* Remove a ChildTemplate object to this object
* through the attribute_template cross reference table.
*
* @param ChildCategory $category The ChildAttributeCategory object to relate
* @param ChildTemplate $template The ChildAttributeTemplate object to relate
* @return ChildAttribute The current object (for fluent API support)
*/
public function removeCategory(ChildCategory $category)
public function removeTemplate(ChildTemplate $template)
{
if ($this->getCategories()->contains($category)) {
$this->collCategories->remove($this->collCategories->search($category));
if ($this->getTemplates()->contains($template)) {
$this->collTemplates->remove($this->collTemplates->search($template));
if (null === $this->categoriesScheduledForDeletion) {
$this->categoriesScheduledForDeletion = clone $this->collCategories;
$this->categoriesScheduledForDeletion->clear();
if (null === $this->templatesScheduledForDeletion) {
$this->templatesScheduledForDeletion = clone $this->collTemplates;
$this->templatesScheduledForDeletion->clear();
}
$this->categoriesScheduledForDeletion[] = $category;
$this->templatesScheduledForDeletion[] = $template;
}
return $this;
@@ -2536,8 +2536,8 @@ abstract class Attribute implements ActiveRecordInterface
$o->clearAllReferences($deep);
}
}
if ($this->collAttributeCategories) {
foreach ($this->collAttributeCategories as $o) {
if ($this->collAttributeTemplates) {
foreach ($this->collAttributeTemplates as $o) {
$o->clearAllReferences($deep);
}
}
@@ -2546,8 +2546,8 @@ abstract class Attribute implements ActiveRecordInterface
$o->clearAllReferences($deep);
}
}
if ($this->collCategories) {
foreach ($this->collCategories as $o) {
if ($this->collTemplates) {
foreach ($this->collTemplates as $o) {
$o->clearAllReferences($deep);
}
}
@@ -2565,18 +2565,18 @@ abstract class Attribute implements ActiveRecordInterface
$this->collAttributeCombinations->clearIterator();
}
$this->collAttributeCombinations = null;
if ($this->collAttributeCategories instanceof Collection) {
$this->collAttributeCategories->clearIterator();
if ($this->collAttributeTemplates instanceof Collection) {
$this->collAttributeTemplates->clearIterator();
}
$this->collAttributeCategories = null;
$this->collAttributeTemplates = null;
if ($this->collAttributeI18ns instanceof Collection) {
$this->collAttributeI18ns->clearIterator();
}
$this->collAttributeI18ns = null;
if ($this->collCategories instanceof Collection) {
$this->collCategories->clearIterator();
if ($this->collTemplates instanceof Collection) {
$this->collTemplates->clearIterator();
}
$this->collCategories = null;
$this->collTemplates = null;
}
/**

View File

@@ -44,9 +44,9 @@ use Thelia\Model\Map\AttributeTableMap;
* @method ChildAttributeQuery rightJoinAttributeCombination($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCombination relation
* @method ChildAttributeQuery innerJoinAttributeCombination($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCombination relation
*
* @method ChildAttributeQuery leftJoinAttributeCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeCategory relation
* @method ChildAttributeQuery rightJoinAttributeCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCategory relation
* @method ChildAttributeQuery innerJoinAttributeCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCategory relation
* @method ChildAttributeQuery leftJoinAttributeTemplate($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeTemplate relation
* @method ChildAttributeQuery rightJoinAttributeTemplate($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeTemplate relation
* @method ChildAttributeQuery innerJoinAttributeTemplate($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeTemplate relation
*
* @method ChildAttributeQuery leftJoinAttributeI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeI18n relation
* @method ChildAttributeQuery rightJoinAttributeI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeI18n relation
@@ -556,40 +556,40 @@ abstract class AttributeQuery extends ModelCriteria
}
/**
* Filter the query by a related \Thelia\Model\AttributeCategory object
* Filter the query by a related \Thelia\Model\AttributeTemplate object
*
* @param \Thelia\Model\AttributeCategory|ObjectCollection $attributeCategory the related object to use as filter
* @param \Thelia\Model\AttributeTemplate|ObjectCollection $attributeTemplate the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildAttributeQuery The current query, for fluid interface
*/
public function filterByAttributeCategory($attributeCategory, $comparison = null)
public function filterByAttributeTemplate($attributeTemplate, $comparison = null)
{
if ($attributeCategory instanceof \Thelia\Model\AttributeCategory) {
if ($attributeTemplate instanceof \Thelia\Model\AttributeTemplate) {
return $this
->addUsingAlias(AttributeTableMap::ID, $attributeCategory->getAttributeId(), $comparison);
} elseif ($attributeCategory instanceof ObjectCollection) {
->addUsingAlias(AttributeTableMap::ID, $attributeTemplate->getAttributeId(), $comparison);
} elseif ($attributeTemplate instanceof ObjectCollection) {
return $this
->useAttributeCategoryQuery()
->filterByPrimaryKeys($attributeCategory->getPrimaryKeys())
->useAttributeTemplateQuery()
->filterByPrimaryKeys($attributeTemplate->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByAttributeCategory() only accepts arguments of type \Thelia\Model\AttributeCategory or Collection');
throw new PropelException('filterByAttributeTemplate() only accepts arguments of type \Thelia\Model\AttributeTemplate or Collection');
}
}
/**
* Adds a JOIN clause to the query using the AttributeCategory relation
* Adds a JOIN clause to the query using the AttributeTemplate relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildAttributeQuery The current query, for fluid interface
*/
public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
public function joinAttributeTemplate($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('AttributeCategory');
$relationMap = $tableMap->getRelation('AttributeTemplate');
// create a ModelJoin object for this join
$join = new ModelJoin();
@@ -604,14 +604,14 @@ abstract class AttributeQuery extends ModelCriteria
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'AttributeCategory');
$this->addJoinObject($join, 'AttributeTemplate');
}
return $this;
}
/**
* Use the AttributeCategory relation AttributeCategory object
* Use the AttributeTemplate relation AttributeTemplate object
*
* @see useQuery()
*
@@ -619,13 +619,13 @@ abstract class AttributeQuery extends ModelCriteria
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query
* @return \Thelia\Model\AttributeTemplateQuery A secondary query class using the current class as primary query
*/
public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
public function useAttributeTemplateQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinAttributeCategory($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery');
->joinAttributeTemplate($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'AttributeTemplate', '\Thelia\Model\AttributeTemplateQuery');
}
/**
@@ -702,19 +702,19 @@ abstract class AttributeQuery extends ModelCriteria
}
/**
* Filter the query by a related Category object
* using the attribute_category table as cross reference
* Filter the query by a related Template object
* using the attribute_template table as cross reference
*
* @param Category $category the related object to use as filter
* @param Template $template the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildAttributeQuery The current query, for fluid interface
*/
public function filterByCategory($category, $comparison = Criteria::EQUAL)
public function filterByTemplate($template, $comparison = Criteria::EQUAL)
{
return $this
->useAttributeCategoryQuery()
->filterByCategory($category, $comparison)
->useAttributeTemplateQuery()
->filterByTemplate($template, $comparison)
->endUse();
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,759 @@
<?php
namespace Thelia\Model\Base;
use \Exception;
use \PDO;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\AttributeTemplate as ChildAttributeTemplate;
use Thelia\Model\AttributeTemplateQuery as ChildAttributeTemplateQuery;
use Thelia\Model\Map\AttributeTemplateTableMap;
/**
* Base class that represents a query for the 'attribute_template' table.
*
*
*
* @method ChildAttributeTemplateQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildAttributeTemplateQuery orderByAttributeId($order = Criteria::ASC) Order by the attribute_id column
* @method ChildAttributeTemplateQuery orderByTemplateId($order = Criteria::ASC) Order by the template_id column
* @method ChildAttributeTemplateQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildAttributeTemplateQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildAttributeTemplateQuery groupById() Group by the id column
* @method ChildAttributeTemplateQuery groupByAttributeId() Group by the attribute_id column
* @method ChildAttributeTemplateQuery groupByTemplateId() Group by the template_id column
* @method ChildAttributeTemplateQuery groupByCreatedAt() Group by the created_at column
* @method ChildAttributeTemplateQuery groupByUpdatedAt() Group by the updated_at column
*
* @method ChildAttributeTemplateQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildAttributeTemplateQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildAttributeTemplateQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildAttributeTemplateQuery leftJoinAttribute($relationAlias = null) Adds a LEFT JOIN clause to the query using the Attribute relation
* @method ChildAttributeTemplateQuery rightJoinAttribute($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Attribute relation
* @method ChildAttributeTemplateQuery innerJoinAttribute($relationAlias = null) Adds a INNER JOIN clause to the query using the Attribute relation
*
* @method ChildAttributeTemplateQuery leftJoinTemplate($relationAlias = null) Adds a LEFT JOIN clause to the query using the Template relation
* @method ChildAttributeTemplateQuery rightJoinTemplate($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Template relation
* @method ChildAttributeTemplateQuery innerJoinTemplate($relationAlias = null) Adds a INNER JOIN clause to the query using the Template relation
*
* @method ChildAttributeTemplate findOne(ConnectionInterface $con = null) Return the first ChildAttributeTemplate matching the query
* @method ChildAttributeTemplate findOneOrCreate(ConnectionInterface $con = null) Return the first ChildAttributeTemplate matching the query, or a new ChildAttributeTemplate object populated from the query conditions when no match is found
*
* @method ChildAttributeTemplate findOneById(int $id) Return the first ChildAttributeTemplate filtered by the id column
* @method ChildAttributeTemplate findOneByAttributeId(int $attribute_id) Return the first ChildAttributeTemplate filtered by the attribute_id column
* @method ChildAttributeTemplate findOneByTemplateId(int $template_id) Return the first ChildAttributeTemplate filtered by the template_id column
* @method ChildAttributeTemplate findOneByCreatedAt(string $created_at) Return the first ChildAttributeTemplate filtered by the created_at column
* @method ChildAttributeTemplate findOneByUpdatedAt(string $updated_at) Return the first ChildAttributeTemplate filtered by the updated_at column
*
* @method array findById(int $id) Return ChildAttributeTemplate objects filtered by the id column
* @method array findByAttributeId(int $attribute_id) Return ChildAttributeTemplate objects filtered by the attribute_id column
* @method array findByTemplateId(int $template_id) Return ChildAttributeTemplate objects filtered by the template_id column
* @method array findByCreatedAt(string $created_at) Return ChildAttributeTemplate objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildAttributeTemplate objects filtered by the updated_at column
*
*/
abstract class AttributeTemplateQuery extends ModelCriteria
{
/**
* Initializes internal state of \Thelia\Model\Base\AttributeTemplateQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\AttributeTemplate', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildAttributeTemplateQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildAttributeTemplateQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \Thelia\Model\AttributeTemplateQuery) {
return $criteria;
}
$query = new \Thelia\Model\AttributeTemplateQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(12, $con);
* </code>
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildAttributeTemplate|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = AttributeTemplateTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(AttributeTemplateTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildAttributeTemplate A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, ATTRIBUTE_ID, TEMPLATE_ID, CREATED_AT, UPDATED_AT FROM attribute_template WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildAttributeTemplate();
$obj->hydrate($row);
AttributeTemplateTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildAttributeTemplate|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(AttributeTemplateTableMap::ID, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(AttributeTemplateTableMap::ID, $keys, Criteria::IN);
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(AttributeTemplateTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(AttributeTemplateTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(AttributeTemplateTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the attribute_id column
*
* Example usage:
* <code>
* $query->filterByAttributeId(1234); // WHERE attribute_id = 1234
* $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34)
* $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
* </code>
*
* @see filterByAttribute()
*
* @param mixed $attributeId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function filterByAttributeId($attributeId = null, $comparison = null)
{
if (is_array($attributeId)) {
$useMinMax = false;
if (isset($attributeId['min'])) {
$this->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($attributeId['max'])) {
$this->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_ID, $attributeId, $comparison);
}
/**
* Filter the query on the template_id column
*
* Example usage:
* <code>
* $query->filterByTemplateId(1234); // WHERE template_id = 1234
* $query->filterByTemplateId(array(12, 34)); // WHERE template_id IN (12, 34)
* $query->filterByTemplateId(array('min' => 12)); // WHERE template_id > 12
* </code>
*
* @see filterByTemplate()
*
* @param mixed $templateId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function filterByTemplateId($templateId = null, $comparison = null)
{
if (is_array($templateId)) {
$useMinMax = false;
if (isset($templateId['min'])) {
$this->addUsingAlias(AttributeTemplateTableMap::TEMPLATE_ID, $templateId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($templateId['max'])) {
$this->addUsingAlias(AttributeTemplateTableMap::TEMPLATE_ID, $templateId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(AttributeTemplateTableMap::TEMPLATE_ID, $templateId, $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 ChildAttributeTemplateQuery 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(AttributeTemplateTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($createdAt['max'])) {
$this->addUsingAlias(AttributeTemplateTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(AttributeTemplateTableMap::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 ChildAttributeTemplateQuery 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(AttributeTemplateTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($updatedAt['max'])) {
$this->addUsingAlias(AttributeTemplateTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(AttributeTemplateTableMap::UPDATED_AT, $updatedAt, $comparison);
}
/**
* Filter the query by a related \Thelia\Model\Attribute object
*
* @param \Thelia\Model\Attribute|ObjectCollection $attribute The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function filterByAttribute($attribute, $comparison = null)
{
if ($attribute instanceof \Thelia\Model\Attribute) {
return $this
->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison);
} elseif ($attribute instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection');
}
}
/**
* Adds a JOIN clause to the query using the Attribute relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Attribute');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'Attribute');
}
return $this;
}
/**
* Use the Attribute relation Attribute object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\AttributeQuery A secondary query class using the current class as primary query
*/
public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinAttribute($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery');
}
/**
* Filter the query by a related \Thelia\Model\Template object
*
* @param \Thelia\Model\Template|ObjectCollection $template The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function filterByTemplate($template, $comparison = null)
{
if ($template instanceof \Thelia\Model\Template) {
return $this
->addUsingAlias(AttributeTemplateTableMap::TEMPLATE_ID, $template->getId(), $comparison);
} elseif ($template instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(AttributeTemplateTableMap::TEMPLATE_ID, $template->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByTemplate() only accepts arguments of type \Thelia\Model\Template or Collection');
}
}
/**
* Adds a JOIN clause to the query using the Template relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function joinTemplate($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Template');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'Template');
}
return $this;
}
/**
* Use the Template relation Template object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\TemplateQuery A secondary query class using the current class as primary query
*/
public function useTemplateQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinTemplate($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Template', '\Thelia\Model\TemplateQuery');
}
/**
* Exclude object from result
*
* @param ChildAttributeTemplate $attributeTemplate Object to remove from the list of results
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function prune($attributeTemplate = null)
{
if ($attributeTemplate) {
$this->addUsingAlias(AttributeTemplateTableMap::ID, $attributeTemplate->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
/**
* Deletes all rows from the attribute_template table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(AttributeTemplateTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
AttributeTemplateTableMap::clearInstancePool();
AttributeTemplateTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildAttributeTemplate or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildAttributeTemplate object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(AttributeTemplateTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(AttributeTemplateTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
AttributeTemplateTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
AttributeTemplateTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
// timestampable behavior
/**
* Filter by the latest updated
*
* @param int $nbDays Maximum age of the latest update in days
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function recentlyUpdated($nbDays = 7)
{
return $this->addUsingAlias(AttributeTemplateTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Filter by the latest created
*
* @param int $nbDays Maximum age of in days
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function recentlyCreated($nbDays = 7)
{
return $this->addUsingAlias(AttributeTemplateTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Order by update date desc
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function lastUpdatedFirst()
{
return $this->addDescendingOrderByColumn(AttributeTemplateTableMap::UPDATED_AT);
}
/**
* Order by update date asc
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function firstUpdatedFirst()
{
return $this->addAscendingOrderByColumn(AttributeTemplateTableMap::UPDATED_AT);
}
/**
* Order by create date desc
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function lastCreatedFirst()
{
return $this->addDescendingOrderByColumn(AttributeTemplateTableMap::CREATED_AT);
}
/**
* Order by create date asc
*
* @return ChildAttributeTemplateQuery The current query, for fluid interface
*/
public function firstCreatedFirst()
{
return $this->addAscendingOrderByColumn(AttributeTemplateTableMap::CREATED_AT);
}
} // AttributeTemplateQuery

View File

@@ -99,6 +99,13 @@ abstract class Cart implements ActiveRecordInterface
*/
protected $currency_id;
/**
* The value for the discount field.
* Note: this column has a database default value of: 0
* @var double
*/
protected $discount;
/**
* The value for the created_at field.
* @var string
@@ -151,11 +158,24 @@ abstract class Cart implements ActiveRecordInterface
*/
protected $cartItemsScheduledForDeletion = 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->discount = 0;
}
/**
* Initializes internal state of Thelia\Model\Base\Cart object.
* @see applyDefaults()
*/
public function __construct()
{
$this->applyDefaultValues();
}
/**
@@ -471,6 +491,17 @@ abstract class Cart implements ActiveRecordInterface
return $this->currency_id;
}
/**
* Get the [discount] column value.
*
* @return double
*/
public function getDiscount()
{
return $this->discount;
}
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -653,6 +684,27 @@ abstract class Cart implements ActiveRecordInterface
return $this;
} // setCurrencyId()
/**
* Set the value of [discount] column.
*
* @param double $v new value
* @return \Thelia\Model\Cart The current object (for fluent API support)
*/
public function setDiscount($v)
{
if ($v !== null) {
$v = (double) $v;
}
if ($this->discount !== $v) {
$this->discount = $v;
$this->modifiedColumns[] = CartTableMap::DISCOUNT;
}
return $this;
} // setDiscount()
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -705,6 +757,10 @@ abstract class Cart implements ActiveRecordInterface
*/
public function hasOnlyDefaultValues()
{
if ($this->discount !== 0) {
return false;
}
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@@ -750,13 +806,16 @@ abstract class Cart implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CartTableMap::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)];
$this->currency_id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CartTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CartTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)];
$this->discount = (null !== $col) ? (double) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CartTableMap::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 : CartTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CartTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -769,7 +828,7 @@ abstract class Cart implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 8; // 8 = CartTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 9; // 9 = CartTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\Cart object", 0, $e);
@@ -1075,6 +1134,9 @@ abstract class Cart implements ActiveRecordInterface
if ($this->isColumnModified(CartTableMap::CURRENCY_ID)) {
$modifiedColumns[':p' . $index++] = 'CURRENCY_ID';
}
if ($this->isColumnModified(CartTableMap::DISCOUNT)) {
$modifiedColumns[':p' . $index++] = 'DISCOUNT';
}
if ($this->isColumnModified(CartTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
}
@@ -1110,6 +1172,9 @@ abstract class Cart implements ActiveRecordInterface
case 'CURRENCY_ID':
$stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT);
break;
case 'DISCOUNT':
$stmt->bindValue($identifier, $this->discount, 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;
@@ -1197,9 +1262,12 @@ abstract class Cart implements ActiveRecordInterface
return $this->getCurrencyId();
break;
case 6:
return $this->getCreatedAt();
return $this->getDiscount();
break;
case 7:
return $this->getCreatedAt();
break;
case 8:
return $this->getUpdatedAt();
break;
default:
@@ -1237,8 +1305,9 @@ abstract class Cart implements ActiveRecordInterface
$keys[3] => $this->getAddressDeliveryId(),
$keys[4] => $this->getAddressInvoiceId(),
$keys[5] => $this->getCurrencyId(),
$keys[6] => $this->getCreatedAt(),
$keys[7] => $this->getUpdatedAt(),
$keys[6] => $this->getDiscount(),
$keys[7] => $this->getCreatedAt(),
$keys[8] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -1315,9 +1384,12 @@ abstract class Cart implements ActiveRecordInterface
$this->setCurrencyId($value);
break;
case 6:
$this->setCreatedAt($value);
$this->setDiscount($value);
break;
case 7:
$this->setCreatedAt($value);
break;
case 8:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1350,8 +1422,9 @@ abstract class Cart implements ActiveRecordInterface
if (array_key_exists($keys[3], $arr)) $this->setAddressDeliveryId($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setAddressInvoiceId($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setCurrencyId($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->setDiscount($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]]);
}
/**
@@ -1369,6 +1442,7 @@ abstract class Cart implements ActiveRecordInterface
if ($this->isColumnModified(CartTableMap::ADDRESS_DELIVERY_ID)) $criteria->add(CartTableMap::ADDRESS_DELIVERY_ID, $this->address_delivery_id);
if ($this->isColumnModified(CartTableMap::ADDRESS_INVOICE_ID)) $criteria->add(CartTableMap::ADDRESS_INVOICE_ID, $this->address_invoice_id);
if ($this->isColumnModified(CartTableMap::CURRENCY_ID)) $criteria->add(CartTableMap::CURRENCY_ID, $this->currency_id);
if ($this->isColumnModified(CartTableMap::DISCOUNT)) $criteria->add(CartTableMap::DISCOUNT, $this->discount);
if ($this->isColumnModified(CartTableMap::CREATED_AT)) $criteria->add(CartTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(CartTableMap::UPDATED_AT)) $criteria->add(CartTableMap::UPDATED_AT, $this->updated_at);
@@ -1439,6 +1513,7 @@ abstract class Cart implements ActiveRecordInterface
$copyObj->setAddressDeliveryId($this->getAddressDeliveryId());
$copyObj->setAddressInvoiceId($this->getAddressInvoiceId());
$copyObj->setCurrencyId($this->getCurrencyId());
$copyObj->setDiscount($this->getDiscount());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
@@ -1982,10 +2057,12 @@ abstract class Cart implements ActiveRecordInterface
$this->address_delivery_id = null;
$this->address_invoice_id = null;
$this->currency_id = null;
$this->discount = null;
$this->created_at = null;
$this->updated_at = null;
$this->alreadyInSave = false;
$this->clearAllReferences();
$this->applyDefaultValues();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);

View File

@@ -109,6 +109,13 @@ abstract class CartItem implements ActiveRecordInterface
*/
protected $price_end_of_life;
/**
* The value for the discount field.
* Note: this column has a database default value of: 0
* @var double
*/
protected $discount;
/**
* The value for the created_at field.
* @var string
@@ -153,6 +160,7 @@ abstract class CartItem implements ActiveRecordInterface
public function applyDefaultValues()
{
$this->quantity = 1;
$this->discount = 0;
}
/**
@@ -508,6 +516,17 @@ abstract class CartItem implements ActiveRecordInterface
}
}
/**
* Get the [discount] column value.
*
* @return double
*/
public function getDiscount()
{
return $this->discount;
}
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -728,6 +747,27 @@ abstract class CartItem implements ActiveRecordInterface
return $this;
} // setPriceEndOfLife()
/**
* Set the value of [discount] column.
*
* @param double $v new value
* @return \Thelia\Model\CartItem The current object (for fluent API support)
*/
public function setDiscount($v)
{
if ($v !== null) {
$v = (double) $v;
}
if ($this->discount !== $v) {
$this->discount = $v;
$this->modifiedColumns[] = CartItemTableMap::DISCOUNT;
}
return $this;
} // setDiscount()
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -784,6 +824,10 @@ abstract class CartItem implements ActiveRecordInterface
return false;
}
if ($this->discount !== 0) {
return false;
}
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@@ -838,13 +882,16 @@ abstract class CartItem implements ActiveRecordInterface
}
$this->price_end_of_life = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CartItemTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CartItemTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)];
$this->discount = (null !== $col) ? (double) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CartItemTableMap::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 ? 9 + $startcol : CartItemTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CartItemTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -857,7 +904,7 @@ abstract class CartItem implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 10; // 10 = CartItemTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 11; // 11 = CartItemTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\CartItem object", 0, $e);
@@ -1139,6 +1186,9 @@ abstract class CartItem implements ActiveRecordInterface
if ($this->isColumnModified(CartItemTableMap::PRICE_END_OF_LIFE)) {
$modifiedColumns[':p' . $index++] = 'PRICE_END_OF_LIFE';
}
if ($this->isColumnModified(CartItemTableMap::DISCOUNT)) {
$modifiedColumns[':p' . $index++] = 'DISCOUNT';
}
if ($this->isColumnModified(CartItemTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
}
@@ -1180,6 +1230,9 @@ abstract class CartItem implements ActiveRecordInterface
case 'PRICE_END_OF_LIFE':
$stmt->bindValue($identifier, $this->price_end_of_life ? $this->price_end_of_life->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'DISCOUNT':
$stmt->bindValue($identifier, $this->discount, 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;
@@ -1273,9 +1326,12 @@ abstract class CartItem implements ActiveRecordInterface
return $this->getPriceEndOfLife();
break;
case 8:
return $this->getCreatedAt();
return $this->getDiscount();
break;
case 9:
return $this->getCreatedAt();
break;
case 10:
return $this->getUpdatedAt();
break;
default:
@@ -1315,8 +1371,9 @@ abstract class CartItem implements ActiveRecordInterface
$keys[5] => $this->getPrice(),
$keys[6] => $this->getPromoPrice(),
$keys[7] => $this->getPriceEndOfLife(),
$keys[8] => $this->getCreatedAt(),
$keys[9] => $this->getUpdatedAt(),
$keys[8] => $this->getDiscount(),
$keys[9] => $this->getCreatedAt(),
$keys[10] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -1393,9 +1450,12 @@ abstract class CartItem implements ActiveRecordInterface
$this->setPriceEndOfLife($value);
break;
case 8:
$this->setCreatedAt($value);
$this->setDiscount($value);
break;
case 9:
$this->setCreatedAt($value);
break;
case 10:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1430,8 +1490,9 @@ abstract class CartItem implements ActiveRecordInterface
if (array_key_exists($keys[5], $arr)) $this->setPrice($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setPromoPrice($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setPriceEndOfLife($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]);
if (array_key_exists($keys[8], $arr)) $this->setDiscount($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setUpdatedAt($arr[$keys[10]]);
}
/**
@@ -1451,6 +1512,7 @@ abstract class CartItem implements ActiveRecordInterface
if ($this->isColumnModified(CartItemTableMap::PRICE)) $criteria->add(CartItemTableMap::PRICE, $this->price);
if ($this->isColumnModified(CartItemTableMap::PROMO_PRICE)) $criteria->add(CartItemTableMap::PROMO_PRICE, $this->promo_price);
if ($this->isColumnModified(CartItemTableMap::PRICE_END_OF_LIFE)) $criteria->add(CartItemTableMap::PRICE_END_OF_LIFE, $this->price_end_of_life);
if ($this->isColumnModified(CartItemTableMap::DISCOUNT)) $criteria->add(CartItemTableMap::DISCOUNT, $this->discount);
if ($this->isColumnModified(CartItemTableMap::CREATED_AT)) $criteria->add(CartItemTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(CartItemTableMap::UPDATED_AT)) $criteria->add(CartItemTableMap::UPDATED_AT, $this->updated_at);
@@ -1523,6 +1585,7 @@ abstract class CartItem implements ActiveRecordInterface
$copyObj->setPrice($this->getPrice());
$copyObj->setPromoPrice($this->getPromoPrice());
$copyObj->setPriceEndOfLife($this->getPriceEndOfLife());
$copyObj->setDiscount($this->getDiscount());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
if ($makeNew) {
@@ -1719,6 +1782,7 @@ abstract class CartItem implements ActiveRecordInterface
$this->price = null;
$this->promo_price = null;
$this->price_end_of_life = null;
$this->discount = null;
$this->created_at = null;
$this->updated_at = null;
$this->alreadyInSave = false;

View File

@@ -29,6 +29,7 @@ use Thelia\Model\Map\CartItemTableMap;
* @method ChildCartItemQuery orderByPrice($order = Criteria::ASC) Order by the price column
* @method ChildCartItemQuery orderByPromoPrice($order = Criteria::ASC) Order by the promo_price column
* @method ChildCartItemQuery orderByPriceEndOfLife($order = Criteria::ASC) Order by the price_end_of_life column
* @method ChildCartItemQuery orderByDiscount($order = Criteria::ASC) Order by the discount column
* @method ChildCartItemQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildCartItemQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
@@ -40,6 +41,7 @@ use Thelia\Model\Map\CartItemTableMap;
* @method ChildCartItemQuery groupByPrice() Group by the price column
* @method ChildCartItemQuery groupByPromoPrice() Group by the promo_price column
* @method ChildCartItemQuery groupByPriceEndOfLife() Group by the price_end_of_life column
* @method ChildCartItemQuery groupByDiscount() Group by the discount column
* @method ChildCartItemQuery groupByCreatedAt() Group by the created_at column
* @method ChildCartItemQuery groupByUpdatedAt() Group by the updated_at column
*
@@ -70,6 +72,7 @@ use Thelia\Model\Map\CartItemTableMap;
* @method ChildCartItem findOneByPrice(double $price) Return the first ChildCartItem filtered by the price column
* @method ChildCartItem findOneByPromoPrice(double $promo_price) Return the first ChildCartItem filtered by the promo_price column
* @method ChildCartItem findOneByPriceEndOfLife(string $price_end_of_life) Return the first ChildCartItem filtered by the price_end_of_life column
* @method ChildCartItem findOneByDiscount(double $discount) Return the first ChildCartItem filtered by the discount column
* @method ChildCartItem findOneByCreatedAt(string $created_at) Return the first ChildCartItem filtered by the created_at column
* @method ChildCartItem findOneByUpdatedAt(string $updated_at) Return the first ChildCartItem filtered by the updated_at column
*
@@ -81,6 +84,7 @@ use Thelia\Model\Map\CartItemTableMap;
* @method array findByPrice(double $price) Return ChildCartItem objects filtered by the price column
* @method array findByPromoPrice(double $promo_price) Return ChildCartItem objects filtered by the promo_price column
* @method array findByPriceEndOfLife(string $price_end_of_life) Return ChildCartItem objects filtered by the price_end_of_life column
* @method array findByDiscount(double $discount) Return ChildCartItem objects filtered by the discount column
* @method array findByCreatedAt(string $created_at) Return ChildCartItem objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildCartItem objects filtered by the updated_at column
*
@@ -171,7 +175,7 @@ abstract class CartItemQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, PRICE, PROMO_PRICE, PRICE_END_OF_LIFE, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0';
$sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, PRICE, PROMO_PRICE, PRICE_END_OF_LIFE, DISCOUNT, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -596,6 +600,47 @@ abstract class CartItemQuery extends ModelCriteria
return $this->addUsingAlias(CartItemTableMap::PRICE_END_OF_LIFE, $priceEndOfLife, $comparison);
}
/**
* Filter the query on the discount column
*
* Example usage:
* <code>
* $query->filterByDiscount(1234); // WHERE discount = 1234
* $query->filterByDiscount(array(12, 34)); // WHERE discount IN (12, 34)
* $query->filterByDiscount(array('min' => 12)); // WHERE discount > 12
* </code>
*
* @param mixed $discount The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCartItemQuery The current query, for fluid interface
*/
public function filterByDiscount($discount = null, $comparison = null)
{
if (is_array($discount)) {
$useMinMax = false;
if (isset($discount['min'])) {
$this->addUsingAlias(CartItemTableMap::DISCOUNT, $discount['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($discount['max'])) {
$this->addUsingAlias(CartItemTableMap::DISCOUNT, $discount['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CartItemTableMap::DISCOUNT, $discount, $comparison);
}
/**
* Filter the query on the created_at column
*

View File

@@ -27,6 +27,7 @@ use Thelia\Model\Map\CartTableMap;
* @method ChildCartQuery orderByAddressDeliveryId($order = Criteria::ASC) Order by the address_delivery_id column
* @method ChildCartQuery orderByAddressInvoiceId($order = Criteria::ASC) Order by the address_invoice_id column
* @method ChildCartQuery orderByCurrencyId($order = Criteria::ASC) Order by the currency_id column
* @method ChildCartQuery orderByDiscount($order = Criteria::ASC) Order by the discount column
* @method ChildCartQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildCartQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
@@ -36,6 +37,7 @@ use Thelia\Model\Map\CartTableMap;
* @method ChildCartQuery groupByAddressDeliveryId() Group by the address_delivery_id column
* @method ChildCartQuery groupByAddressInvoiceId() Group by the address_invoice_id column
* @method ChildCartQuery groupByCurrencyId() Group by the currency_id column
* @method ChildCartQuery groupByDiscount() Group by the discount column
* @method ChildCartQuery groupByCreatedAt() Group by the created_at column
* @method ChildCartQuery groupByUpdatedAt() Group by the updated_at column
*
@@ -72,6 +74,7 @@ use Thelia\Model\Map\CartTableMap;
* @method ChildCart findOneByAddressDeliveryId(int $address_delivery_id) Return the first ChildCart filtered by the address_delivery_id column
* @method ChildCart findOneByAddressInvoiceId(int $address_invoice_id) Return the first ChildCart filtered by the address_invoice_id column
* @method ChildCart findOneByCurrencyId(int $currency_id) Return the first ChildCart filtered by the currency_id column
* @method ChildCart findOneByDiscount(double $discount) Return the first ChildCart filtered by the discount column
* @method ChildCart findOneByCreatedAt(string $created_at) Return the first ChildCart filtered by the created_at column
* @method ChildCart findOneByUpdatedAt(string $updated_at) Return the first ChildCart filtered by the updated_at column
*
@@ -81,6 +84,7 @@ use Thelia\Model\Map\CartTableMap;
* @method array findByAddressDeliveryId(int $address_delivery_id) Return ChildCart objects filtered by the address_delivery_id column
* @method array findByAddressInvoiceId(int $address_invoice_id) Return ChildCart objects filtered by the address_invoice_id column
* @method array findByCurrencyId(int $currency_id) Return ChildCart objects filtered by the currency_id column
* @method array findByDiscount(double $discount) Return ChildCart objects filtered by the discount column
* @method array findByCreatedAt(string $created_at) Return ChildCart objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildCart objects filtered by the updated_at column
*
@@ -171,7 +175,7 @@ abstract class CartQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, TOKEN, CUSTOMER_ID, ADDRESS_DELIVERY_ID, ADDRESS_INVOICE_ID, CURRENCY_ID, CREATED_AT, UPDATED_AT FROM cart WHERE ID = :p0';
$sql = 'SELECT ID, TOKEN, CUSTOMER_ID, ADDRESS_DELIVERY_ID, ADDRESS_INVOICE_ID, CURRENCY_ID, DISCOUNT, CREATED_AT, UPDATED_AT FROM cart WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -502,6 +506,47 @@ abstract class CartQuery extends ModelCriteria
return $this->addUsingAlias(CartTableMap::CURRENCY_ID, $currencyId, $comparison);
}
/**
* Filter the query on the discount column
*
* Example usage:
* <code>
* $query->filterByDiscount(1234); // WHERE discount = 1234
* $query->filterByDiscount(array(12, 34)); // WHERE discount IN (12, 34)
* $query->filterByDiscount(array('min' => 12)); // WHERE discount > 12
* </code>
*
* @param mixed $discount The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCartQuery The current query, for fluid interface
*/
public function filterByDiscount($discount = null, $comparison = null)
{
if (is_array($discount)) {
$useMinMax = false;
if (isset($discount['min'])) {
$this->addUsingAlias(CartTableMap::DISCOUNT, $discount['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($discount['max'])) {
$this->addUsingAlias(CartTableMap::DISCOUNT, $discount['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CartTableMap::DISCOUNT, $discount, $comparison);
}
/**
* Filter the query on the created_at column
*

File diff suppressed because it is too large Load Diff

View File

@@ -50,14 +50,6 @@ use Thelia\Model\Map\CategoryTableMap;
* @method ChildCategoryQuery rightJoinProductCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductCategory relation
* @method ChildCategoryQuery innerJoinProductCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductCategory relation
*
* @method ChildCategoryQuery leftJoinFeatureCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureCategory relation
* @method ChildCategoryQuery rightJoinFeatureCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureCategory relation
* @method ChildCategoryQuery innerJoinFeatureCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureCategory relation
*
* @method ChildCategoryQuery leftJoinAttributeCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeCategory relation
* @method ChildCategoryQuery rightJoinAttributeCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCategory relation
* @method ChildCategoryQuery innerJoinAttributeCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCategory relation
*
* @method ChildCategoryQuery leftJoinCategoryImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryImage relation
* @method ChildCategoryQuery rightJoinCategoryImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryImage relation
* @method ChildCategoryQuery innerJoinCategoryImage($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryImage relation
@@ -720,152 +712,6 @@ abstract class CategoryQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'ProductCategory', '\Thelia\Model\ProductCategoryQuery');
}
/**
* Filter the query by a related \Thelia\Model\FeatureCategory object
*
* @param \Thelia\Model\FeatureCategory|ObjectCollection $featureCategory the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCategoryQuery The current query, for fluid interface
*/
public function filterByFeatureCategory($featureCategory, $comparison = null)
{
if ($featureCategory instanceof \Thelia\Model\FeatureCategory) {
return $this
->addUsingAlias(CategoryTableMap::ID, $featureCategory->getCategoryId(), $comparison);
} elseif ($featureCategory instanceof ObjectCollection) {
return $this
->useFeatureCategoryQuery()
->filterByPrimaryKeys($featureCategory->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByFeatureCategory() only accepts arguments of type \Thelia\Model\FeatureCategory or Collection');
}
}
/**
* Adds a JOIN clause to the query using the FeatureCategory relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCategoryQuery The current query, for fluid interface
*/
public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('FeatureCategory');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'FeatureCategory');
}
return $this;
}
/**
* Use the FeatureCategory relation FeatureCategory object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\FeatureCategoryQuery A secondary query class using the current class as primary query
*/
public function useFeatureCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinFeatureCategory($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'FeatureCategory', '\Thelia\Model\FeatureCategoryQuery');
}
/**
* Filter the query by a related \Thelia\Model\AttributeCategory object
*
* @param \Thelia\Model\AttributeCategory|ObjectCollection $attributeCategory the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCategoryQuery The current query, for fluid interface
*/
public function filterByAttributeCategory($attributeCategory, $comparison = null)
{
if ($attributeCategory instanceof \Thelia\Model\AttributeCategory) {
return $this
->addUsingAlias(CategoryTableMap::ID, $attributeCategory->getCategoryId(), $comparison);
} elseif ($attributeCategory instanceof ObjectCollection) {
return $this
->useAttributeCategoryQuery()
->filterByPrimaryKeys($attributeCategory->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByAttributeCategory() only accepts arguments of type \Thelia\Model\AttributeCategory or Collection');
}
}
/**
* Adds a JOIN clause to the query using the AttributeCategory relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCategoryQuery The current query, for fluid interface
*/
public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('AttributeCategory');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'AttributeCategory');
}
return $this;
}
/**
* Use the AttributeCategory relation AttributeCategory object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query
*/
public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinAttributeCategory($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery');
}
/**
* Filter the query by a related \Thelia\Model\CategoryImage object
*
@@ -1248,40 +1094,6 @@ abstract class CategoryQuery extends ModelCriteria
->endUse();
}
/**
* Filter the query by a related Feature object
* using the feature_category table as cross reference
*
* @param Feature $feature the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCategoryQuery The current query, for fluid interface
*/
public function filterByFeature($feature, $comparison = Criteria::EQUAL)
{
return $this
->useFeatureCategoryQuery()
->filterByFeature($feature, $comparison)
->endUse();
}
/**
* Filter the query by a related Attribute object
* using the attribute_category table as cross reference
*
* @param Attribute $attribute the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCategoryQuery The current query, for fluid interface
*/
public function filterByAttribute($attribute, $comparison = Criteria::EQUAL)
{
return $this
->useAttributeCategoryQuery()
->filterByAttribute($attribute, $comparison)
->endUse();
}
/**
* Exclude object from result
*

View File

@@ -135,6 +135,18 @@ abstract class Customer implements ActiveRecordInterface
*/
protected $discount;
/**
* The value for the remember_me_token field.
* @var string
*/
protected $remember_me_token;
/**
* The value for the remember_me_serial field.
* @var string
*/
protected $remember_me_serial;
/**
* The value for the created_at field.
* @var string
@@ -582,6 +594,28 @@ abstract class Customer implements ActiveRecordInterface
return $this->discount;
}
/**
* Get the [remember_me_token] column value.
*
* @return string
*/
public function getRememberMeToken()
{
return $this->remember_me_token;
}
/**
* Get the [remember_me_serial] column value.
*
* @return string
*/
public function getRememberMeSerial()
{
return $this->remember_me_serial;
}
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -878,6 +912,48 @@ abstract class Customer implements ActiveRecordInterface
return $this;
} // setDiscount()
/**
* Set the value of [remember_me_token] column.
*
* @param string $v new value
* @return \Thelia\Model\Customer The current object (for fluent API support)
*/
public function setRememberMeToken($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->remember_me_token !== $v) {
$this->remember_me_token = $v;
$this->modifiedColumns[] = CustomerTableMap::REMEMBER_ME_TOKEN;
}
return $this;
} // setRememberMeToken()
/**
* Set the value of [remember_me_serial] column.
*
* @param string $v new value
* @return \Thelia\Model\Customer The current object (for fluent API support)
*/
public function setRememberMeSerial($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->remember_me_serial !== $v) {
$this->remember_me_serial = $v;
$this->modifiedColumns[] = CustomerTableMap::REMEMBER_ME_SERIAL;
}
return $this;
} // setRememberMeSerial()
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -993,13 +1069,19 @@ abstract class Customer implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CustomerTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)];
$this->discount = (null !== $col) ? (double) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CustomerTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CustomerTableMap::translateFieldName('RememberMeToken', TableMap::TYPE_PHPNAME, $indexType)];
$this->remember_me_token = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CustomerTableMap::translateFieldName('RememberMeSerial', TableMap::TYPE_PHPNAME, $indexType)];
$this->remember_me_serial = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CustomerTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -1012,7 +1094,7 @@ abstract class Customer implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 14; // 14 = CustomerTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 16; // 16 = CustomerTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\Customer object", 0, $e);
@@ -1342,6 +1424,12 @@ abstract class Customer implements ActiveRecordInterface
if ($this->isColumnModified(CustomerTableMap::DISCOUNT)) {
$modifiedColumns[':p' . $index++] = 'DISCOUNT';
}
if ($this->isColumnModified(CustomerTableMap::REMEMBER_ME_TOKEN)) {
$modifiedColumns[':p' . $index++] = 'REMEMBER_ME_TOKEN';
}
if ($this->isColumnModified(CustomerTableMap::REMEMBER_ME_SERIAL)) {
$modifiedColumns[':p' . $index++] = 'REMEMBER_ME_SERIAL';
}
if ($this->isColumnModified(CustomerTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
}
@@ -1395,6 +1483,12 @@ abstract class Customer implements ActiveRecordInterface
case 'DISCOUNT':
$stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR);
break;
case 'REMEMBER_ME_TOKEN':
$stmt->bindValue($identifier, $this->remember_me_token, PDO::PARAM_STR);
break;
case 'REMEMBER_ME_SERIAL':
$stmt->bindValue($identifier, $this->remember_me_serial, 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;
@@ -1500,9 +1594,15 @@ abstract class Customer implements ActiveRecordInterface
return $this->getDiscount();
break;
case 12:
return $this->getCreatedAt();
return $this->getRememberMeToken();
break;
case 13:
return $this->getRememberMeSerial();
break;
case 14:
return $this->getCreatedAt();
break;
case 15:
return $this->getUpdatedAt();
break;
default:
@@ -1546,8 +1646,10 @@ abstract class Customer implements ActiveRecordInterface
$keys[9] => $this->getLang(),
$keys[10] => $this->getSponsor(),
$keys[11] => $this->getDiscount(),
$keys[12] => $this->getCreatedAt(),
$keys[13] => $this->getUpdatedAt(),
$keys[12] => $this->getRememberMeToken(),
$keys[13] => $this->getRememberMeSerial(),
$keys[14] => $this->getCreatedAt(),
$keys[15] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -1639,9 +1741,15 @@ abstract class Customer implements ActiveRecordInterface
$this->setDiscount($value);
break;
case 12:
$this->setCreatedAt($value);
$this->setRememberMeToken($value);
break;
case 13:
$this->setRememberMeSerial($value);
break;
case 14:
$this->setCreatedAt($value);
break;
case 15:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1680,8 +1788,10 @@ abstract class Customer implements ActiveRecordInterface
if (array_key_exists($keys[9], $arr)) $this->setLang($arr[$keys[9]]);
if (array_key_exists($keys[10], $arr)) $this->setSponsor($arr[$keys[10]]);
if (array_key_exists($keys[11], $arr)) $this->setDiscount($arr[$keys[11]]);
if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]);
if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]);
if (array_key_exists($keys[12], $arr)) $this->setRememberMeToken($arr[$keys[12]]);
if (array_key_exists($keys[13], $arr)) $this->setRememberMeSerial($arr[$keys[13]]);
if (array_key_exists($keys[14], $arr)) $this->setCreatedAt($arr[$keys[14]]);
if (array_key_exists($keys[15], $arr)) $this->setUpdatedAt($arr[$keys[15]]);
}
/**
@@ -1705,6 +1815,8 @@ abstract class Customer implements ActiveRecordInterface
if ($this->isColumnModified(CustomerTableMap::LANG)) $criteria->add(CustomerTableMap::LANG, $this->lang);
if ($this->isColumnModified(CustomerTableMap::SPONSOR)) $criteria->add(CustomerTableMap::SPONSOR, $this->sponsor);
if ($this->isColumnModified(CustomerTableMap::DISCOUNT)) $criteria->add(CustomerTableMap::DISCOUNT, $this->discount);
if ($this->isColumnModified(CustomerTableMap::REMEMBER_ME_TOKEN)) $criteria->add(CustomerTableMap::REMEMBER_ME_TOKEN, $this->remember_me_token);
if ($this->isColumnModified(CustomerTableMap::REMEMBER_ME_SERIAL)) $criteria->add(CustomerTableMap::REMEMBER_ME_SERIAL, $this->remember_me_serial);
if ($this->isColumnModified(CustomerTableMap::CREATED_AT)) $criteria->add(CustomerTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(CustomerTableMap::UPDATED_AT)) $criteria->add(CustomerTableMap::UPDATED_AT, $this->updated_at);
@@ -1781,6 +1893,8 @@ abstract class Customer implements ActiveRecordInterface
$copyObj->setLang($this->getLang());
$copyObj->setSponsor($this->getSponsor());
$copyObj->setDiscount($this->getDiscount());
$copyObj->setRememberMeToken($this->getRememberMeToken());
$copyObj->setRememberMeSerial($this->getRememberMeSerial());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
@@ -2806,6 +2920,8 @@ abstract class Customer implements ActiveRecordInterface
$this->lang = null;
$this->sponsor = null;
$this->discount = null;
$this->remember_me_token = null;
$this->remember_me_serial = null;
$this->created_at = null;
$this->updated_at = null;
$this->alreadyInSave = false;

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