Merge branch 'master' into rewrite
Conflicts: core/lib/Thelia/Core/Template/Loop/Attribute.php core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php core/lib/Thelia/Core/Template/Loop/AttributeCombination.php core/lib/Thelia/Core/Template/Loop/Category.php core/lib/Thelia/Core/Template/Loop/Content.php core/lib/Thelia/Core/Template/Loop/Country.php core/lib/Thelia/Core/Template/Loop/Currency.php core/lib/Thelia/Core/Template/Loop/Feature.php core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php core/lib/Thelia/Core/Template/Loop/FeatureValue.php core/lib/Thelia/Core/Template/Loop/Folder.php core/lib/Thelia/Core/Template/Loop/Image.php core/lib/Thelia/Core/Template/Loop/Product.php core/lib/Thelia/Core/Template/Loop/Title.php core/lib/Thelia/Model/Tools/ModelCriteriaTools.php
This commit is contained in:
@@ -35,27 +35,8 @@ use Thelia\Form\BaseForm;
|
||||
*/
|
||||
abstract class ActionEvent extends Event
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
protected $errorForm = null;
|
||||
|
||||
protected $parameters = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param string $action
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->parameters[$name] = $value;
|
||||
@@ -69,30 +50,4 @@ abstract class ActionEvent extends Event
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
public function setErrorForm(BaseForm $form)
|
||||
{
|
||||
$this->errorForm = $form;
|
||||
|
||||
if ($form != null) $this->stopPropagation();
|
||||
}
|
||||
|
||||
public function getErrorForm()
|
||||
{
|
||||
return $this->errorForm;
|
||||
}
|
||||
|
||||
public function hasErrorForm()
|
||||
{
|
||||
return $this->errorForm != null ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\CartItem;
|
||||
|
||||
class CartItemEvent extends InternalEvent
|
||||
class CartItemEvent extends ActionEvent
|
||||
{
|
||||
protected $cartItem;
|
||||
|
||||
|
||||
68
core/lib/Thelia/Core/Context.php → core/lib/Thelia/Core/Event/CategoryChangePositionEvent.php
Executable file → Normal file
68
core/lib/Thelia/Core/Context.php → core/lib/Thelia/Core/Event/CategoryChangePositionEvent.php
Executable file → Normal file
@@ -21,34 +21,64 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core;
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Category;
|
||||
|
||||
class Context
|
||||
class CategoryChangePositionEvent extends ActionEvent
|
||||
{
|
||||
const CONTEXT_FRONT_OFFICE = 'front';
|
||||
const CONTEXT_BACK_OFFICE = 'admin';
|
||||
const POSITION_UP = 1;
|
||||
const POSITION_DOWN = 2;
|
||||
const POSITION_ABSOLUTE = 3;
|
||||
|
||||
protected $defineContext = array(
|
||||
self::CONTEXT_BACK_OFFICE,
|
||||
self::CONTEXT_FRONT_OFFICE
|
||||
);
|
||||
protected $id;
|
||||
protected $mode;
|
||||
protected $position;
|
||||
protected $category;
|
||||
|
||||
protected $currentContext = self::CONTEXT_FRONT_OFFICE;
|
||||
|
||||
public function isValidContext($context)
|
||||
public function __construct($id, $mode, $position = null)
|
||||
{
|
||||
return in_array($context, $this->defineContext);
|
||||
$this->id = $id;
|
||||
$this->mode = $mode;
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
public function setContext($context)
|
||||
public function getId()
|
||||
{
|
||||
if ($this->isValidContext($context)) {
|
||||
$this->currentContext = $context;
|
||||
}
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getContext()
|
||||
public function setId($id)
|
||||
{
|
||||
return $this->currentContext;
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
||||
public function getMode()
|
||||
{
|
||||
return $this->mode;
|
||||
}
|
||||
|
||||
public function setMode($mode)
|
||||
{
|
||||
$this->mode = $mode;
|
||||
}
|
||||
|
||||
public function getPosition()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function setPosition($position)
|
||||
{
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
public function setCategory($category)
|
||||
{
|
||||
$this->category = $category;
|
||||
}
|
||||
}
|
||||
64
core/lib/Thelia/Core/Event/Internal/InternalEvent.php → core/lib/Thelia/Core/Event/CategoryCreateEvent.php
Executable file → Normal file
64
core/lib/Thelia/Core/Event/Internal/InternalEvent.php → core/lib/Thelia/Core/Event/CategoryCreateEvent.php
Executable file → Normal file
@@ -21,16 +21,62 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Internal;
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Thelia\Model\Category;
|
||||
|
||||
/**
|
||||
* Base class used for internal event like creating new Customer, adding item to cart, etc
|
||||
*
|
||||
* Class InternalEvent
|
||||
* @package Thelia\Core\Event
|
||||
*/
|
||||
abstract class InternalEvent extends Event
|
||||
class CategoryCreateEvent extends ActionEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $parent;
|
||||
protected $locale;
|
||||
protected $created_category;
|
||||
|
||||
public function __construct($title, $parent, $locale)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->parent = $parent;
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
public function getCreatedCategory()
|
||||
{
|
||||
return $this->created_category;
|
||||
}
|
||||
|
||||
public function setCreatedCategory(Category $created_category)
|
||||
{
|
||||
$this->created_category = $created_category;
|
||||
var_dump($this->created_category);
|
||||
}
|
||||
}
|
||||
33
core/lib/Thelia/Core/Event/Internal/CartEvent.php → core/lib/Thelia/Core/Event/CategoryDeleteEvent.php
Executable file → Normal file
33
core/lib/Thelia/Core/Event/Internal/CartEvent.php → core/lib/Thelia/Core/Event/CategoryDeleteEvent.php
Executable file → Normal file
@@ -21,17 +21,36 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Internal;
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Category;
|
||||
|
||||
use Thelia\Model\Cart;
|
||||
|
||||
class CartEvent extends InternalEvent
|
||||
class CategoryDeleteEvent extends ActionEvent
|
||||
{
|
||||
public $cart;
|
||||
protected $id;
|
||||
protected $deleted_category;
|
||||
|
||||
public function __construct(Cart $cart)
|
||||
public function __construct($id)
|
||||
{
|
||||
$this->cart = $cart;
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getDeletedCategory()
|
||||
{
|
||||
return $this->deleted_category;
|
||||
}
|
||||
|
||||
public function setDeletedCategory(Category $deleted_category)
|
||||
{
|
||||
$this->deleted_category = $deleted_category;
|
||||
}
|
||||
}
|
||||
30
core/lib/Thelia/Core/Event/CategoryEvent.php → core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php
Executable file → Normal file
30
core/lib/Thelia/Core/Event/CategoryEvent.php → core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php
Executable file → Normal file
@@ -22,15 +22,35 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Category;
|
||||
|
||||
class CategoryEvent extends InternalEvent
|
||||
class CategoryToggleVisibilityEvent extends ActionEvent
|
||||
{
|
||||
public $category;
|
||||
protected $id;
|
||||
protected $category;
|
||||
|
||||
public function __construct(Category $category)
|
||||
public function __construct($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
public function setCategory(Category $category)
|
||||
{
|
||||
$this->category = $category;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,12 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Internal;
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Customer;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class CustomerEvent extends InternalEvent
|
||||
class CustomerEvent extends ActionEvent
|
||||
{
|
||||
public $customer;
|
||||
|
||||
@@ -94,11 +94,29 @@ final class TheliaEvents
|
||||
*/
|
||||
const AFTER_CHANGECUSTOMER = "action.after_changecustomer";
|
||||
|
||||
|
||||
/**
|
||||
* Sent once the category creation form has been successfully validated, and before category insertion in the database.
|
||||
*/
|
||||
const BEFORE_CREATECATEGORY = "action.before_createcategory";
|
||||
|
||||
/**
|
||||
* Create, change or delete a category
|
||||
*/
|
||||
const CATEGORY_CREATE = "action.createCategory";
|
||||
const CATEGORY_MODIFY = "action.modifyCategory";
|
||||
const CATEGORY_DELETE = "action.deleteCategory";
|
||||
|
||||
/**
|
||||
* Toggle category visibility
|
||||
*/
|
||||
const CATEGORY_TOGGLE_VISIBILITY = "action.toggleCategoryVisibility";
|
||||
|
||||
/**
|
||||
* Change category position
|
||||
*/
|
||||
const CATEGORY_CHANGE_POSITION = "action.changeCategoryPosition";
|
||||
|
||||
/**
|
||||
* Sent just after a successful insert of a new category in the database.
|
||||
*/
|
||||
@@ -113,6 +131,11 @@ final class TheliaEvents
|
||||
*/
|
||||
const AFTER_DELETECATEGORY = "action.after_deletecategory";
|
||||
|
||||
/**
|
||||
* Sent just before a successful change of a category in the database.
|
||||
*/
|
||||
const BEFORE_CHANGECATEGORY = "action.before_changecategory";
|
||||
|
||||
/**
|
||||
* Sent just after a successful change of a category in the database.
|
||||
*/
|
||||
@@ -154,5 +177,4 @@ final class TheliaEvents
|
||||
* Sent on cimage cache clear request
|
||||
*/
|
||||
const IMAGE_CLEAR_CACHE = "action.clearImageCache";
|
||||
|
||||
}
|
||||
|
||||
@@ -33,36 +33,11 @@ use Thelia\Core\HttpFoundation\Request;
|
||||
*/
|
||||
class SecurityContext
|
||||
{
|
||||
const CONTEXT_FRONT_OFFICE = 'front';
|
||||
const CONTEXT_BACK_OFFICE = 'admin';
|
||||
|
||||
private $request;
|
||||
private $context;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
|
||||
$this->context = null;
|
||||
}
|
||||
|
||||
public function setContext($context)
|
||||
{
|
||||
if ($context !== self::CONTEXT_FRONT_OFFICE && $context !== self::CONTEXT_BACK_OFFICE) {
|
||||
throw new \InvalidArgumentException(sprintf("Invalid or empty context identifier '%s'", $context));
|
||||
}
|
||||
|
||||
$this->context = $context;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContext($exception_if_context_undefined = false)
|
||||
{
|
||||
if (null === $this->context && $exception_if_context_undefined === true)
|
||||
throw new \LogicException("No context defined. Please use setContext() first.");
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
private function getSession()
|
||||
@@ -76,28 +51,47 @@ class SecurityContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the currently authenticated user in the current context, or null if none is defined
|
||||
* Gets the currently authenticated user in the admin, or null if none is defined
|
||||
*
|
||||
* @return UserInterface|null A UserInterface instance or null if no user is available
|
||||
*/
|
||||
public function getUser()
|
||||
public function getAdminUser()
|
||||
{
|
||||
$context = $this->getContext(true);
|
||||
|
||||
if ($context === self::CONTEXT_FRONT_OFFICE)
|
||||
$user = $this->getSession()->getCustomerUser();
|
||||
else if ($context == self::CONTEXT_BACK_OFFICE)
|
||||
$user = $this->getSession()->getAdminUser();
|
||||
else
|
||||
$user = null;
|
||||
|
||||
return $user;
|
||||
return $this->getSession()->getAdminUser();
|
||||
}
|
||||
|
||||
final public function isAuthenticated()
|
||||
/**
|
||||
* Gets the currently authenticated customer, or null if none is defined
|
||||
*
|
||||
* @return UserInterface|null A UserInterface instance or null if no user is available
|
||||
*/
|
||||
public function getCustomerUser()
|
||||
{
|
||||
if (null !== $this->getUser()) {
|
||||
return true;
|
||||
return $this->getSession()->getCustomerUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user has at least one of the required roles
|
||||
*
|
||||
* @param UserInterface $user the user
|
||||
* @param array $roles the roles
|
||||
* @return boolean true if the user has the required role, false otherwise
|
||||
*/
|
||||
final public function hasRequiredRole($user, array $roles) {
|
||||
|
||||
if ($user != null) {
|
||||
// Check if user's roles matches required roles
|
||||
$userRoles = $user->getRoles();
|
||||
|
||||
$roleFound = false;
|
||||
|
||||
foreach ($userRoles as $role) {
|
||||
if (in_array($role, $roles)) {
|
||||
$roleFound = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -110,85 +104,88 @@ class SecurityContext
|
||||
*/
|
||||
final public function isGranted(array $roles, array $permissions)
|
||||
{
|
||||
if ($this->isAuthenticated() === true) {
|
||||
// Find a user which matches the required roles.
|
||||
$user = $this->getCustomerUser();
|
||||
|
||||
$user = $this->getUser();
|
||||
if (! $this->hasRequiredRole($user, $roles)) {
|
||||
$user = $this->getAdminUser();
|
||||
|
||||
// Check if user's roles matches required roles
|
||||
$userRoles = $user->getRoles();
|
||||
if (! $this->hasRequiredRole($user, $roles)) {
|
||||
$user = null;
|
||||
}
|
||||
}
|
||||
|
||||
$roleFound = false;
|
||||
if ($user != null) {
|
||||
|
||||
foreach ($userRoles as $role) {
|
||||
if (in_array($role, $roles)) {
|
||||
$roleFound = true;
|
||||
|
||||
break;
|
||||
}
|
||||
if (empty($permissions)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($roleFound) {
|
||||
// Get permissions from profile
|
||||
// $userPermissions = $user->getPermissions(); FIXME
|
||||
|
||||
if (empty($permissions)) {
|
||||
return true;
|
||||
}
|
||||
// TODO: Finalize permissions system !;
|
||||
|
||||
// Get permissions from profile
|
||||
// $userPermissions = $user->getPermissions(); FIXME
|
||||
$userPermissions = array('*'); // FIXME !
|
||||
|
||||
// TODO: Finalize permissions system !;
|
||||
$permissionsFound = true;
|
||||
|
||||
$userPermissions = array('*'); // FIXME !
|
||||
// User have all permissions ?
|
||||
if (in_array('*', $userPermissions))
|
||||
return true;
|
||||
|
||||
$permissionsFound = true;
|
||||
// Check that user's permissions matches required permissions
|
||||
foreach ($permissions as $permission) {
|
||||
if (! in_array($permission, $userPermissions)) {
|
||||
$permissionsFound = false;
|
||||
|
||||
// User have all permissions ?
|
||||
if (in_array('*', $userPermissions))
|
||||
return true;
|
||||
|
||||
// Check that user's permissions matches required permissions
|
||||
foreach ($permissions as $permission) {
|
||||
if (! in_array($permission, $userPermissions)) {
|
||||
$permissionsFound = false;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $permissionsFound;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $permissionsFound;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the authenticated user.
|
||||
* Sets the authenticated admin user.
|
||||
*
|
||||
* @param UserInterface $user A UserInterface, or null if no further user should be stored
|
||||
*/
|
||||
public function setUser(UserInterface $user)
|
||||
public function setAdminUser(UserInterface $user)
|
||||
{
|
||||
$context = $this->getContext(true);
|
||||
|
||||
$user->eraseCredentials();
|
||||
|
||||
if ($context === self::CONTEXT_FRONT_OFFICE)
|
||||
$this->getSession()->setCustomerUser($user);
|
||||
else if ($context == self::CONTEXT_BACK_OFFICE)
|
||||
$this->getSession()->setAdminUser($user);
|
||||
$this->getSession()->setAdminUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the user from the security context
|
||||
* Sets the authenticated customer user.
|
||||
*
|
||||
* @param UserInterface $user A UserInterface, or null if no further user should be stored
|
||||
*/
|
||||
public function clear()
|
||||
public function setCustomerUser(UserInterface $user)
|
||||
{
|
||||
$context = $this->getContext(true);
|
||||
$user->eraseCredentials();
|
||||
|
||||
if ($context === self::CONTEXT_FRONT_OFFICE)
|
||||
$this->getSession()->clearCustomerUser();
|
||||
else if ($context == self::CONTEXT_BACK_OFFICE)
|
||||
$this->getSession()->clearAdminUser();
|
||||
$this->getSession()->setCustomerUser($user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the customer from the security context
|
||||
*/
|
||||
public function clearCustomerUser()
|
||||
{
|
||||
$this->getSession()->clearCustomerUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the admin from the security context
|
||||
*/
|
||||
public function clearAdminUser()
|
||||
{
|
||||
$this->getSession()->clearAdminUser();
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -234,6 +235,31 @@ abstract class BaseLoop
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup ModelCriteria for proper i18n processing
|
||||
*
|
||||
* @param ModelCriteria $search the Propel Criteria to configure
|
||||
* @param array $columns the i18n columns
|
||||
* @param string $foreignTable the specified table (default to criteria table)
|
||||
* @param string $foreignKey the foreign key in this table (default to criteria table)
|
||||
*
|
||||
* @return mixed the locale
|
||||
*/
|
||||
protected function configureI18nProcessing(ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID', $forceReturn = false) {
|
||||
|
||||
/* manage translations */
|
||||
return ModelCriteriaTools::getI18n(
|
||||
$this->getBackend_context(),
|
||||
$this->getLang(),
|
||||
$search,
|
||||
$this->request->getSession()->getLocale(),
|
||||
$columns,
|
||||
$foreignTable,
|
||||
$foreignKey,
|
||||
$forceReturn
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* this function have to be implement in your own loop class.
|
||||
|
||||
@@ -34,7 +34,6 @@ use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Base\LangQuery;
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\Base\CategoryQuery;
|
||||
use Thelia\Model\Base\ProductCategoryQuery;
|
||||
@@ -92,7 +91,7 @@ class Attribute extends BaseLoop
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\Base\AttributeAvQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
@@ -79,12 +77,8 @@ class AttributeAvailability extends BaseLoop
|
||||
{
|
||||
$search = AttributeAvQuery::create();
|
||||
|
||||
$backendContext = $this->getBackend_context();
|
||||
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\Base\AttributeCombinationQuery;
|
||||
use Thelia\Model\Map\AttributeAvTableMap;
|
||||
use Thelia\Model\Map\AttributeTableMap;
|
||||
@@ -59,6 +57,7 @@ class AttributeCombination extends BaseLoop
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('product_sale_elements', null, true),
|
||||
Argument::createIntTypeArgument('lang'),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
@@ -79,20 +78,16 @@ class AttributeCombination extends BaseLoop
|
||||
$search = AttributeCombinationQuery::create();
|
||||
|
||||
/* manage attribute translations */
|
||||
ModelCriteriaTools::getFrontEndI18n(
|
||||
$this->configureI18nProcessing(
|
||||
$search,
|
||||
ConfigQuery::getDefaultLangWhenNoTranslationAvailable(),
|
||||
$this->request->getSession()->getLocale(),
|
||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||
AttributeTableMap::TABLE_NAME,
|
||||
'ATTRIBUTE_ID'
|
||||
);
|
||||
|
||||
/* manage attributeAv translations */
|
||||
ModelCriteriaTools::getFrontEndI18n(
|
||||
$this->configureI18nProcessing(
|
||||
$search,
|
||||
ConfigQuery::getDefaultLangWhenNoTranslationAvailable(),
|
||||
$this->request->getSession()->getLocale(),
|
||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||
AttributeAvTableMap::TABLE_NAME,
|
||||
'ATTRIBUTE_AV_ID'
|
||||
|
||||
@@ -68,15 +68,12 @@ class Auth extends BaseLoop
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$context = $this->getContext();
|
||||
$roles = $this->_explode($this->getRoles());
|
||||
$permissions = $this->_explode($this->getPermissions());
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
try {
|
||||
$this->securityContext->setContext($context);
|
||||
|
||||
if (true === $this->securityContext->isGranted($roles, $permissions == null ? array() : $permissions)) {
|
||||
|
||||
// Create an empty row: loop is no longer empty :)
|
||||
|
||||
@@ -32,8 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
@@ -98,12 +96,8 @@ class Category extends BaseLoop
|
||||
{
|
||||
$search = CategoryQuery::create();
|
||||
|
||||
$backendContext = $this->getBackend_context();
|
||||
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
$locale = ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -169,7 +163,6 @@ class Category extends BaseLoop
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach ($categories as $category) {
|
||||
|
||||
/*
|
||||
* no cause pagination lost :
|
||||
* if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue;
|
||||
|
||||
@@ -65,7 +65,8 @@ class CategoryPath extends BaseLoop
|
||||
Argument::createIntTypeArgument('category', null, true),
|
||||
Argument::createIntTypeArgument('depth'),
|
||||
Argument::createIntTypeArgument('level'),
|
||||
Argument::createBooleanOrBothTypeArgument('visible', true, false)
|
||||
Argument::createBooleanOrBothTypeArgument('visible', true, false),
|
||||
Argument::createIntTypeArgument('lang')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,6 +81,9 @@ class CategoryPath extends BaseLoop
|
||||
$visible = $this->getVisible();
|
||||
|
||||
$search = CategoryQuery::create();
|
||||
|
||||
$this->configureI18nProcessing($search, array('TITLE'));
|
||||
|
||||
$search->filterById($id);
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
|
||||
@@ -95,7 +99,7 @@ class CategoryPath extends BaseLoop
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow
|
||||
->set("TITLE",$category->getTitle())
|
||||
->set("TITLE",$category->getVirtualColumn('i18n_TITLE'))
|
||||
->set("URL", $category->getUrl())
|
||||
->set("ID", $category->getId())
|
||||
;
|
||||
@@ -114,8 +118,11 @@ class CategoryPath extends BaseLoop
|
||||
$ids[] = $parent;
|
||||
|
||||
$search = CategoryQuery::create();
|
||||
|
||||
$this->configureI18nProcessing($search, array('TITLE'));
|
||||
|
||||
$search->filterById($parent);
|
||||
if ($visible == true) $search->filterByVisible($visible);
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
}
|
||||
}
|
||||
} while ($category != null && $parent > 0);
|
||||
|
||||
@@ -31,8 +31,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\Map\ContentTableMap;
|
||||
use Thelia\Model\ContentFolderQuery;
|
||||
@@ -88,12 +86,8 @@ class Content extends BaseLoop
|
||||
{
|
||||
$search = ContentQuery::create();
|
||||
|
||||
$backendContext = $this->getBackend_context();
|
||||
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
$locale = ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
@@ -70,12 +68,8 @@ class Country extends BaseLoop
|
||||
{
|
||||
$search = CountryQuery::create();
|
||||
|
||||
$backendContext = $this->getBackend_context();
|
||||
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
@@ -69,12 +67,8 @@ class Currency extends BaseLoop
|
||||
{
|
||||
$search = CurrencyQuery::create();
|
||||
|
||||
$backendContext = $this->getBackend_context();
|
||||
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale(), array('NAME'));
|
||||
$this->configureI18nProcessing($search, array('NAME'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\Base\CategoryQuery;
|
||||
use Thelia\Model\Base\ProductCategoryQuery;
|
||||
use Thelia\Model\Base\FeatureQuery;
|
||||
@@ -84,12 +82,8 @@ class Feature extends BaseLoop
|
||||
{
|
||||
$search = FeatureQuery::create();
|
||||
|
||||
$backendContext = $this->getBackend_context();
|
||||
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\Base\FeatureAvQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
@@ -77,12 +75,8 @@ class FeatureAvailability extends BaseLoop
|
||||
{
|
||||
$search = FeatureAvQuery::create();
|
||||
|
||||
$backendContext = $this->getBackend_context();
|
||||
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\Base\FeatureProductQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Map\FeatureAvTableMap;
|
||||
@@ -70,7 +68,8 @@ class FeatureValue extends BaseLoop
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual_reverse'))
|
||||
),
|
||||
'manual'
|
||||
)
|
||||
),
|
||||
Argument::createIntTypeArgument('lang')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -84,10 +83,8 @@ class FeatureValue extends BaseLoop
|
||||
$search = FeatureProductQuery::create();
|
||||
|
||||
/* manage featureAv translations */
|
||||
ModelCriteriaTools::getFrontEndI18n(
|
||||
$this->configureI18nProcessing(
|
||||
$search,
|
||||
ConfigQuery::getDefaultLangWhenNoTranslationAvailable(),
|
||||
$this->request->getSession()->getLocale(),
|
||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||
FeatureAvTableMap::TABLE_NAME,
|
||||
'FEATURE_AV_ID',
|
||||
|
||||
@@ -32,8 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
@@ -80,12 +78,8 @@ class Folder extends BaseLoop
|
||||
{
|
||||
$search = FolderQuery::create();
|
||||
|
||||
$backendContext = $this->getBackend_context();
|
||||
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
$locale = ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
|
||||
@@ -207,16 +207,8 @@ class Image extends BaseLoop
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* \Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
|
||||
*
|
||||
* @todo : verify here if we want results for row without translations.
|
||||
*/
|
||||
|
||||
$search->joinWithI18n(
|
||||
$this->request->getSession()->getLocale(),
|
||||
(ConfigQuery::getDefaultLangWhenNoTranslationAvailable()) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
||||
);
|
||||
/* manage translations */
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$results = $this->search($search, $pagination);
|
||||
|
||||
@@ -295,6 +287,7 @@ class Image extends BaseLoop
|
||||
),
|
||||
'manual'
|
||||
),
|
||||
Argument::createIntTypeArgument('lang'),
|
||||
|
||||
Argument::createIntTypeArgument('width'),
|
||||
Argument::createIntTypeArgument('height'),
|
||||
|
||||
@@ -33,8 +33,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\Map\FeatureProductTableMap;
|
||||
use Thelia\Model\Map\ProductPriceTableMap;
|
||||
@@ -138,12 +136,8 @@ class Product extends BaseLoop
|
||||
{
|
||||
$search = ProductQuery::create();
|
||||
|
||||
$backendContext = $this->getBackend_context();
|
||||
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
$locale = ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$attributeNonStrictMatch = $this->getAttribute_non_strict_match();
|
||||
$isPSELeftJoinList = array();
|
||||
|
||||
@@ -31,8 +31,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
use Thelia\Model\CustomerTitleQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
@@ -67,12 +65,8 @@ class Title extends BaseLoop
|
||||
{
|
||||
$search = CustomerTitleQuery::create();
|
||||
|
||||
$backendContext = $this->getBackend_context();
|
||||
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale(), array('SHORT', 'LONG'));
|
||||
$this->configureI18nProcessing($search, array('SHORT', 'LONG'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
*/
|
||||
public function adminDataAccess($params, &$smarty)
|
||||
{
|
||||
return $this->userDataAccess("Admin User", SecurityContext::CONTEXT_BACK_OFFICE, $params);
|
||||
return $this->userDataAccess("Admin User", $this->securityContext->getAdminUser(), $params);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,7 +64,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
*/
|
||||
public function customerDataAccess($params, &$smarty)
|
||||
{
|
||||
return $this->userDataAccess("Customer User", SecurityContext::CONTEXT_FRONT_OFFICE, $params);
|
||||
return $this->userDataAccess("Customer User", $this->securityContext->getCustomerUser(), $params);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,12 +75,11 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
* @return string the value of the requested attribute
|
||||
* @throws InvalidArgumentException if the object does not have the requested attribute.
|
||||
*/
|
||||
protected function userDataAccess($objectLabel, $context, $params)
|
||||
protected function userDataAccess($objectLabel, $user, $params)
|
||||
{
|
||||
$attribute = $this->getNormalizedParam($params, array('attribute', 'attrib', 'attr'));
|
||||
|
||||
if (! empty($attribute)) {
|
||||
$user = $this->securityContext->setContext($context)->getUser();
|
||||
|
||||
if (null != $user) {
|
||||
$getter = sprintf("get%s", ucfirst($attribute));
|
||||
|
||||
@@ -46,11 +46,6 @@ class Security extends AbstractSmartyPlugin
|
||||
*/
|
||||
public function checkAuthFunction($params, &$smarty)
|
||||
{
|
||||
// Context: 'front' or 'admin'
|
||||
$context = $this->getNormalizedParam($params, 'context');
|
||||
|
||||
$this->securityContext->setContext($context);
|
||||
|
||||
$roles = $this->_explode($this->getParam($params, 'roles'));
|
||||
$permissions = $this->_explode($this->getParam($params, 'permissions'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user