Merge branch 'master' of https://github.com/thelia/thelia into coupon
# By franck (6) and others # Via franck (3) and others * 'master' of https://github.com/thelia/thelia: 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
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
54
core/lib/Thelia/Core/Event/TemplateCreateEvent.php
Normal file
54
core/lib/Thelia/Core/Event/TemplateCreateEvent.php
Normal 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;
|
||||
}
|
||||
}
|
||||
59
core/lib/Thelia/Core/Event/TemplateDeleteEvent.php
Normal file
59
core/lib/Thelia/Core/Event/TemplateDeleteEvent.php
Normal 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;
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Core/Event/TemplateEvent.php
Normal file
52
core/lib/Thelia/Core/Event/TemplateEvent.php
Normal 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;
|
||||
}
|
||||
}
|
||||
71
core/lib/Thelia/Core/Event/TemplateUpdateEvent.php
Normal file
71
core/lib/Thelia/Core/Event/TemplateUpdateEvent.php
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -129,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";
|
||||
|
||||
@@ -332,6 +337,21 @@ 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";
|
||||
@@ -339,6 +359,9 @@ final class TheliaEvents
|
||||
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";
|
||||
|
||||
|
||||
@@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
}
|
||||
55
core/lib/Thelia/Core/Security/Token/CookieTokenProvider.php
Normal file
55
core/lib/Thelia/Core/Security/Token/CookieTokenProvider.php
Normal 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, '/');
|
||||
}
|
||||
}
|
||||
27
core/lib/Thelia/Core/Security/Token/TokenProvider.php
Normal file
27
core/lib/Thelia/Core/Security/Token/TokenProvider.php
Normal 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]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
114
core/lib/Thelia/Core/Template/Loop/Template.php
Normal file
114
core/lib/Thelia/Core/Template/Loop/Template.php
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user