Merge branch 'master' into template

Conflicts:
	core/lib/Thelia/Core/Event/TheliaEvents.php
This commit is contained in:
Manuel Raynaud
2013-09-16 10:19:40 +02:00
148 changed files with 18129 additions and 3349 deletions

View File

@@ -22,6 +22,8 @@
/**********************************************************************************/
namespace Thelia\Core\Event\Coupon;
use Thelia\Core\Event\ActionEvent;
use Thelia\Coupon\CouponRuleCollection;
use Thelia\Model\Coupon;
/**
@@ -29,75 +31,112 @@ use Thelia\Model\Coupon;
* Date: 8/29/13
* Time: 3:45 PM
*
* Occurring when a Coupon is disabled
* Occurring when a Coupon is consumed
*
* @package Coupon
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
*/
class CouponDisableEvent extends ActionEvent
class CouponConsumeEvent extends ActionEvent
{
/** @var int Coupon id */
protected $couponId;
/** @var string Coupon code */
protected $code = null;
/** @var Coupon Coupon being disabled */
protected $disabledCoupon;
/** @var float Total discount given by this coupon */
protected $discount = 0;
/** @var bool If Coupon is valid or if Customer meets coupon conditions */
protected $isValid = null;
/**
* Constructor
*
* @param int $id Coupon Id
* @param string $code Coupon code
* @param float $discount Total discount given by this coupon
* @param bool $isValid If Coupon is valid or
* if Customer meets coupon conditions
*/
public function __construct($id)
function __construct($code, $discount = null, $isValid = null)
{
$this->id = $id;
$this->code = $code;
$this->discount = $discount;
$this->isValid = $isValid;
}
/**
* Get Coupon id
* Set Coupon code
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set Coupon id
*
* @param int $id Coupon id
* @param string $code Coupon code
*
* @return $this
*/
public function setId($id)
public function setCode($code)
{
$this->id = $id;
$this->code = $code;
return $this;
}
/**
* Get Coupon being disabled
* Get Coupon code
*
* @return Coupon
* @return string
*/
public function getDisabledCoupon()
public function getCode()
{
return $this->disabledCoupon;
return $this->code;
}
/**
* Set Coupon to be disabled
* Set total discount given by this coupon
*
* @param Coupon $disabledCoupon Coupon to disable
* @param float $discount Total discount given by this coupon
*
* @return $this
*/
public function setDisabledCoupon(Coupon $disabledCoupon)
public function setDiscount($discount)
{
$this->disabledCoupon = $disabledCoupon;
$this->discount = $discount;
return $this;
}
/**
* Get total discount given by this coupon
*
* @return float
*/
public function getDiscount()
{
return $this->discount;
}
/**
* Set if Coupon is valid or if Customer meets coupon conditions
*
* @param boolean $isValid if Coupon is valid or
* if Customer meets coupon conditions
*
* @return $this
*/
public function setIsValid($isValid)
{
$this->isValid = $isValid;
return $this;
}
/**
* Get if Coupon is valid or if Customer meets coupon conditions
*
* @return boolean
*/
public function getIsValid()
{
return $this->isValid;
}
}

View File

@@ -1,103 +0,0 @@
<?php
/**********************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/**********************************************************************************/
namespace Thelia\Core\Event\Coupon;
use Thelia\Model\Coupon;
/**
* Created by JetBrains PhpStorm.
* Date: 8/29/13
* Time: 3:45 PM
*
* Occurring when a Coupon is enabled
*
* @package Coupon
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
*/
class CouponEnableEvent extends ActionEvent
{
/** @var int Coupon id */
protected $couponId;
/** @var Coupon Coupon being enabled */
protected $enabledCoupon;
/**
* Constructor
*
* @param int $id Coupon Id
*/
public function __construct($id)
{
$this->id = $id;
}
/**
* Get Coupon id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set Coupon id
*
* @param int $id Coupon id
*
* @return $this
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Get Coupon being enabled
*
* @return Coupon
*/
public function getEnabledCoupon()
{
return $this->enabledCoupon;
}
/**
* Set Coupon to be enabled
*
* @param Coupon $enabledCoupon Coupon to enabled
*
* @return $this
*/
public function setEnabledCoupon(Coupon $enabledCoupon)
{
$this->enabledCoupon = $enabledCoupon;
return $this;
}
}

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

@@ -258,36 +258,6 @@ final class TheliaEvents
*/
const AFTER_UPDATE_COUPON = "action.after_update_coupon";
/**
* Sent when disabling a Coupon
*/
const COUPON_DISABLE = "action.disable_coupon";
/**
* Sent just before a successful disable of a new Coupon in the database.
*/
const BEFORE_DISABLE_COUPON = "action.before_disable_coupon";
/**
* Sent just after a successful disable of a new Coupon in the database.
*/
const AFTER_DISABLE_COUPON = "action.after_disable_coupon";
/**
* Sent when enabling a Coupon
*/
const COUPON_ENABLE = "action.enable_coupon";
/**
* Sent just before a successful enable of a new Coupon in the database.
*/
const BEFORE_ENABLE_COUPON = "action.before_enable_coupon";
/**
* Sent just after a successful enable of a new Coupon in the database.
*/
const AFTER_ENABLE_COUPON = "action.after_enable_coupon";
/**
* Sent when attempting to use a Coupon
*/
@@ -368,6 +338,20 @@ final class TheliaEvents
const AFTER_DELETECURRENCY = "action.after_deleteCurrency";
const CHANGE_DEFAULT_CURRENCY = 'action.changeDefaultCurrency';
// -- 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 ---------------------------------------------

View File

@@ -55,4 +55,15 @@ class Request extends BaseRequest
return $uri . $additionalQs;
}
/**
* Gets the Session.
*
* @return \Thelia\Core\HttpFoundation\Session\Session The session
* @api
*/
public function getSession()
{
return parent::getSession();
}
}

View File

@@ -222,4 +222,29 @@ class Session extends BaseSession
{
return $this->get("thelia.delivery_id");
}
/**
* Set consumed coupons by the Customer
*
* @param array $couponsCode An array of Coupon code
*
* @return $this
*/
public function setConsumedCoupons(array $couponsCode)
{
$this->set('thelia.consumed_coupons', $couponsCode);
return $this;
}
/**
* Get Customer consumed coupons
*
* @return array $couponsCode An array of Coupon code
*/
public function getConsumedCoupons()
{
return $this->get('thelia.consumed_coupons');
}
}

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\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

@@ -0,0 +1,28 @@
<?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\Exception;
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

@@ -0,0 +1,32 @@
<?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\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

@@ -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,8 +63,7 @@ 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',
@@ -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
);
}

View File

@@ -24,6 +24,7 @@
namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Util\PropelModelPager;
use Thelia\Constraint\ConstraintFactory;
use Thelia\Constraint\Rule\CouponRuleInterface;
use Thelia\Core\HttpFoundation\Request;
@@ -34,9 +35,11 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Coupon\Type\CouponInterface;
use Thelia\Model\CouponQuery;
use Thelia\Model\Coupon as MCoupon;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/**
* Created by JetBrains PhpStorm.
@@ -52,17 +55,22 @@ use Thelia\Type;
class Coupon extends BaseI18nLoop
{
/**
* Define all args used in your loop
*
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id')
Argument::createIntListTypeArgument('id'),
Argument::createBooleanOrBothTypeArgument('is_enabled', 1)
);
}
/**
* @param $pagination
* Execute Loop
*
* @param PropelModelPager $pagination
*
* @return \Thelia\Core\Template\Element\LoopResult
*/
@@ -74,11 +82,16 @@ class Coupon extends BaseI18nLoop
$locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION', 'SHORT_DESCRIPTION'));
$id = $this->getId();
$isEnabled = $this->getIsEnabled();
if (null !== $id) {
$search->filterById($id, Criteria::IN);
}
if ($isEnabled != BooleanOrBothType::ANY) {
$search->filterByIsEnabled($isEnabled ? 1 : 0);
}
// Perform search
$coupons = $this->search($search, $pagination);
@@ -98,9 +111,30 @@ class Coupon extends BaseI18nLoop
$coupon->getSerializedRules()
);
/** @var CouponInterface $couponManager */
$couponManager = $this->container->get($coupon->getType());
$couponManager->set(
$this->container->get('thelia.adapter'),
$coupon->getCode(),
$coupon->getTitle(),
$coupon->getShortDescription(),
$coupon->getDescription(),
$coupon->getAmount(),
$coupon->getIsCumulative(),
$coupon->getIsRemovingPostage(),
$coupon->getIsAvailableOnSpecialOffers(),
$coupon->getIsEnabled(),
$coupon->getMaxUsage(),
$coupon->getExpirationDate()
);
$now = time();
$datediff = $coupon->getExpirationDate()->getTimestamp() - $now;
$daysLeftBeforeExpiration = floor($datediff/(60*60*24));
$cleanedRules = array();
/** @var CouponRuleInterface $rule */
foreach ($rules->getRules() as $key => $rule) {
foreach ($rules->getRules() as $rule) {
$cleanedRules[] = $rule->getToolTip();
}
$loopResultRow->set("ID", $coupon->getId())
@@ -114,9 +148,13 @@ class Coupon extends BaseI18nLoop
->set("USAGE_LEFT", $coupon->getMaxUsage())
->set("IS_CUMULATIVE", $coupon->getIsCumulative())
->set("IS_REMOVING_POSTAGE", $coupon->getIsRemovingPostage())
->set("IS_AVAILABLE_ON_SPECIAL_OFFERS", $coupon->getIsAvailableOnSpecialOffers())
->set("IS_ENABLED", $coupon->getIsEnabled())
->set("AMOUNT", $coupon->getAmount())
->set("APPLICATION_CONDITIONS", $cleanedRules);
->set("APPLICATION_CONDITIONS", $cleanedRules)
->set("TOOLTIP", $couponManager->getToolTip())
->set("DAY_LEFT_BEFORE_EXPIRATION", $daysLeftBeforeExpiration)
->set("SERVICE_ID", $couponManager->getServiceId());
$loopResult->addRow($loopResultRow);
}

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

@@ -145,7 +145,7 @@ class Form extends AbstractSmartyPlugin
public function renderFormField($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
if ($repeat) {
if ($repeat) {
$formFieldView = $this->getFormFieldView($params);
@@ -153,25 +153,25 @@ class Form extends AbstractSmartyPlugin
$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)) {
// We have a collection
if (is_array($value)) {
$key = $this->getParam($params, 'value_key');
$key = $this->getParam($params, 'value_key');
if ($key != null) {
if ($key != null) {
if (isset($value[$key])) {
if (isset($value[$key])) {
$name = sprintf("%s[%s]", $formFieldView->vars["full_name"], $key);
$val = $value[$key];
$name = sprintf("%s[%s]", $formFieldView->vars["full_name"], $key);
$val = $value[$key];
$this->assignFieldValues($template, $name, $val, $formFieldView->vars);
}
}
}
else {
$this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVars["value"], $formFieldView->vars);
}
$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);

View File

@@ -217,7 +217,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;