diff --git a/core/lib/Thelia/Action/Administrator.php b/core/lib/Thelia/Action/Administrator.php
index 15940082a..5c34e2c59 100644
--- a/core/lib/Thelia/Action/Administrator.php
+++ b/core/lib/Thelia/Action/Administrator.php
@@ -46,6 +46,7 @@ class Administrator extends BaseAction implements EventSubscriberInterface
->setLogin($event->getLogin())
->setPassword($event->getPassword())
->setProfileId($event->getProfile())
+ ->setLocale($event->getLocale())
;
$administrator->save();
@@ -66,6 +67,7 @@ class Administrator extends BaseAction implements EventSubscriberInterface
->setLastname($event->getLastname())
->setLogin($event->getLogin())
->setProfileId($event->getProfile())
+ ->setLocale($event->getLocale())
;
if ('' !== $event->getPassword()) {
diff --git a/core/lib/Thelia/Command/CreateAdminUser.php b/core/lib/Thelia/Command/CreateAdminUser.php
index 7e9b59ba0..bbc4f9ad0 100644
--- a/core/lib/Thelia/Command/CreateAdminUser.php
+++ b/core/lib/Thelia/Command/CreateAdminUser.php
@@ -62,6 +62,13 @@ class CreateAdminUser extends ContainerAwareCommand
'User last name',
null
)
+ ->addOption(
+ "locale",
+ null,
+ InputOption::VALUE_OPTIONAL,
+ 'Preferred locale (default: en_US)',
+ null
+ )
->addOption(
'password',
null,
@@ -122,6 +129,7 @@ class CreateAdminUser extends ContainerAwareCommand
$admin->setLogin($input->getOption("login_name") ?: $this->enterData($dialog, $output, "Admin login name : ", "Please enter a login name."));
$admin->setFirstname($input->getOption("first_name") ?: $this->enterData($dialog, $output, "User first name : ", "Please enter user first name."));
$admin->setLastname($input->getOption("last_name") ?: $this->enterData($dialog, $output, "User last name : ", "Please enter user last name."));
+ $admin->setLocale($input->getOption("locale") ?: 'en_US');
do {
$password = $input->getOption("password") ?: $this->enterData($dialog, $output, "Password : ", "Please enter a password.", true);
diff --git a/core/lib/Thelia/Controller/Admin/AdministratorController.php b/core/lib/Thelia/Controller/Admin/AdministratorController.php
index 273728206..eabc62c13 100644
--- a/core/lib/Thelia/Controller/Admin/AdministratorController.php
+++ b/core/lib/Thelia/Controller/Admin/AdministratorController.php
@@ -66,6 +66,7 @@ class AdministratorController extends AbstractCrudController
$event->setLastname($formData['lastname']);
$event->setPassword($formData['password']);
$event->setProfile($formData['profile'] ? : null);
+ $event->setLocale($formData['locale']);
return $event;
}
@@ -80,6 +81,7 @@ class AdministratorController extends AbstractCrudController
$event->setLastname($formData['lastname']);
$event->setPassword($formData['password']);
$event->setProfile($formData['profile'] ? : null);
+ $event->setLocale($formData['locale']);
return $event;
}
@@ -108,6 +110,7 @@ class AdministratorController extends AbstractCrudController
'lastname' => $object->getLastname(),
'login' => $object->getLogin(),
'profile' => $object->getProfileId(),
+ 'locale' => $object->getLocale()
);
// Setup the object form
diff --git a/core/lib/Thelia/Controller/Admin/SessionController.php b/core/lib/Thelia/Controller/Admin/SessionController.php
index 2aedfe90a..78394fa19 100644
--- a/core/lib/Thelia/Controller/Admin/SessionController.php
+++ b/core/lib/Thelia/Controller/Admin/SessionController.php
@@ -26,8 +26,11 @@ namespace Thelia\Controller\Admin;
use Thelia\Form\AdminLogin;
use Thelia\Core\Security\Authentication\AdminUsernamePasswordFormAuthenticator;
use Thelia\Form\Exception\FormValidationException;
+use Thelia\Model\Admin;
use Thelia\Model\AdminLog;
use Thelia\Core\Security\Exception\AuthenticationException;
+use Thelia\Model\Lang;
+use Thelia\Model\LangQuery;
use Thelia\Tools\URL;
use Thelia\Tools\Redirect;
use Thelia\Core\Event\TheliaEvents;
@@ -56,8 +59,11 @@ class SessionController extends BaseAdminController
// Update the cookie
$this->createAdminRememberMeCookie($user);
+ $this->applyUserLocale($user);
+
// Render the home page
return $this->render("home");
+
} catch (TokenAuthenticationException $ex) {
$this->adminLogAppend("admin", "LOGIN", "Token based authentication failed.");
@@ -69,6 +75,18 @@ class SessionController extends BaseAdminController
return $this->render("login");
}
+ protected function applyUserLocale(Admin $user) {
+
+ // Set the current language according to Admin locale preference
+ $locale = $user->getLocale();
+
+ if (null === $lang = LangQuery::create()->findOneByLocale($locale)) {
+ $lang = Lang::getDefaultLanguage();
+ }
+
+ $this->getSession()->setLang($lang);
+ }
+
public function checkLogoutAction()
{
$this->dispatch(TheliaEvents::ADMIN_LOGOUT);
@@ -102,6 +120,8 @@ class SessionController extends BaseAdminController
// Log authentication success
AdminLog::append("admin", "LOGIN", "Authentication successful", $request, $user, false);
+ $this->applyUserLocale($user);
+
/**
* FIXME: we have tou find a way to send cookie
*/
diff --git a/core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.php b/core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.php
index 070e57f87..48ff97be8 100644
--- a/core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.php
+++ b/core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.php
@@ -35,6 +35,7 @@ class AdministratorEvent extends ActionEvent
protected $login = null;
protected $password = null;
protected $profile = null;
+ protected $locale = null;
public function __construct(Admin $administrator = null)
{
@@ -117,4 +118,15 @@ class AdministratorEvent extends ActionEvent
{
return $this->profile;
}
-}
+
+ public function setLocale($locale)
+ {
+ $this->locale = $locale;
+ return $this;
+ }
+
+ public function getLocale()
+ {
+ return $this->locale;
+ }
+}
\ No newline at end of file
diff --git a/core/lib/Thelia/Core/Template/Loop/Admin.php b/core/lib/Thelia/Core/Template/Loop/Admin.php
index d9c49ef80..b5ac7d8b8 100644
--- a/core/lib/Thelia/Core/Template/Loop/Admin.php
+++ b/core/lib/Thelia/Core/Template/Loop/Admin.php
@@ -89,6 +89,7 @@ class Admin extends BaseLoop implements PropelSearchLoopInterface
->set("FIRSTNAME",$admin->getFirstname())
->set("LASTNAME",$admin->getLastname())
->set("LOGIN",$admin->getLogin())
+ ->set("LOCALE",$admin->getLocale())
;
$loopResult->addRow($loopResultRow);
diff --git a/core/lib/Thelia/Form/AdministratorCreationForm.php b/core/lib/Thelia/Form/AdministratorCreationForm.php
index f0a479dd2..f2a7e2452 100644
--- a/core/lib/Thelia/Form/AdministratorCreationForm.php
+++ b/core/lib/Thelia/Form/AdministratorCreationForm.php
@@ -27,6 +27,7 @@ use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Model\AdminQuery;
+use Thelia\Model\LangQuery;
use Thelia\Model\ProfileQuery;
class AdministratorCreationForm extends BaseForm
@@ -100,9 +101,35 @@ class AdministratorCreationForm extends BaseForm
),
)
)
+ ->add(
+ 'locale',
+ "choice",
+ array(
+ "choices" => $this->getLocaleList(),
+ "constraints" => array(
+ new Constraints\NotBlank(),
+ ),
+ "label" => Translator::getInstance()->trans('Preferred locale'),
+ "label_attr" => array(
+ "for" => "locale"
+ ),
+ )
+ )
;
}
+ protected function getLocaleList() {
+ $locales = array();
+
+ $list = LangQuery::create()->find();
+
+ foreach($list as $item) {
+ $locales[$item->getLocale()] = $item->getLocale();
+ }
+
+ return $locales;
+ }
+
public function verifyPasswordField($value, ExecutionContextInterface $context)
{
$data = $context->getRoot()->getData();
diff --git a/core/lib/Thelia/Model/Admin.php b/core/lib/Thelia/Model/Admin.php
index 7c88ee8d2..df8e5ebf5 100644
--- a/core/lib/Thelia/Model/Admin.php
+++ b/core/lib/Thelia/Model/Admin.php
@@ -31,7 +31,7 @@ class Admin extends BaseAdmin implements UserInterface
{
$profileId = $this->getProfileId();
- if( null === $profileId ) {
+ if( null === $profileId || 0 === $profileId ) {
return AdminResources::SUPERADMINISTRATOR;
}
diff --git a/core/lib/Thelia/Model/Base/Admin.php b/core/lib/Thelia/Model/Base/Admin.php
index 22b3492b4..433d47a54 100644
--- a/core/lib/Thelia/Model/Base/Admin.php
+++ b/core/lib/Thelia/Model/Base/Admin.php
@@ -92,6 +92,12 @@ abstract class Admin implements ActiveRecordInterface
*/
protected $password;
+ /**
+ * The value for the locale field.
+ * @var string
+ */
+ protected $locale;
+
/**
* The value for the algo field.
* @var string
@@ -465,6 +471,17 @@ abstract class Admin implements ActiveRecordInterface
return $this->password;
}
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
/**
* Get the [algo] column value.
*
@@ -679,6 +696,27 @@ abstract class Admin implements ActiveRecordInterface
return $this;
} // setPassword()
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Admin The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[AdminTableMap::LOCALE] = true;
+ }
+
+
+ return $this;
+ } // setLocale()
+
/**
* Set the value of [algo] column.
*
@@ -860,25 +898,28 @@ abstract class Admin implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AdminTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)];
$this->password = (null !== $col) ? (string) $col : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : AdminTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)];
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : AdminTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : AdminTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)];
$this->algo = (null !== $col) ? (string) $col : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : AdminTableMap::translateFieldName('Salt', TableMap::TYPE_PHPNAME, $indexType)];
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : AdminTableMap::translateFieldName('Salt', TableMap::TYPE_PHPNAME, $indexType)];
$this->salt = (null !== $col) ? (string) $col : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : AdminTableMap::translateFieldName('RememberMeToken', TableMap::TYPE_PHPNAME, $indexType)];
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : AdminTableMap::translateFieldName('RememberMeToken', TableMap::TYPE_PHPNAME, $indexType)];
$this->remember_me_token = (null !== $col) ? (string) $col : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : AdminTableMap::translateFieldName('RememberMeSerial', TableMap::TYPE_PHPNAME, $indexType)];
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : AdminTableMap::translateFieldName('RememberMeSerial', TableMap::TYPE_PHPNAME, $indexType)];
$this->remember_me_serial = (null !== $col) ? (string) $col : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : AdminTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : AdminTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : AdminTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : AdminTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -891,7 +932,7 @@ abstract class Admin implements ActiveRecordInterface
$this->ensureConsistency();
}
- return $startcol + 12; // 12 = AdminTableMap::NUM_HYDRATE_COLUMNS.
+ return $startcol + 13; // 13 = AdminTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\Admin object", 0, $e);
@@ -1145,6 +1186,9 @@ abstract class Admin implements ActiveRecordInterface
if ($this->isColumnModified(AdminTableMap::PASSWORD)) {
$modifiedColumns[':p' . $index++] = '`PASSWORD`';
}
+ if ($this->isColumnModified(AdminTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = '`LOCALE`';
+ }
if ($this->isColumnModified(AdminTableMap::ALGO)) {
$modifiedColumns[':p' . $index++] = '`ALGO`';
}
@@ -1192,6 +1236,9 @@ abstract class Admin implements ActiveRecordInterface
case '`PASSWORD`':
$stmt->bindValue($identifier, $this->password, PDO::PARAM_STR);
break;
+ case '`LOCALE`':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
case '`ALGO`':
$stmt->bindValue($identifier, $this->algo, PDO::PARAM_STR);
break;
@@ -1291,21 +1338,24 @@ abstract class Admin implements ActiveRecordInterface
return $this->getPassword();
break;
case 6:
- return $this->getAlgo();
+ return $this->getLocale();
break;
case 7:
- return $this->getSalt();
+ return $this->getAlgo();
break;
case 8:
- return $this->getRememberMeToken();
+ return $this->getSalt();
break;
case 9:
- return $this->getRememberMeSerial();
+ return $this->getRememberMeToken();
break;
case 10:
- return $this->getCreatedAt();
+ return $this->getRememberMeSerial();
break;
case 11:
+ return $this->getCreatedAt();
+ break;
+ case 12:
return $this->getUpdatedAt();
break;
default:
@@ -1343,12 +1393,13 @@ abstract class Admin implements ActiveRecordInterface
$keys[3] => $this->getLastname(),
$keys[4] => $this->getLogin(),
$keys[5] => $this->getPassword(),
- $keys[6] => $this->getAlgo(),
- $keys[7] => $this->getSalt(),
- $keys[8] => $this->getRememberMeToken(),
- $keys[9] => $this->getRememberMeSerial(),
- $keys[10] => $this->getCreatedAt(),
- $keys[11] => $this->getUpdatedAt(),
+ $keys[6] => $this->getLocale(),
+ $keys[7] => $this->getAlgo(),
+ $keys[8] => $this->getSalt(),
+ $keys[9] => $this->getRememberMeToken(),
+ $keys[10] => $this->getRememberMeSerial(),
+ $keys[11] => $this->getCreatedAt(),
+ $keys[12] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
@@ -1412,21 +1463,24 @@ abstract class Admin implements ActiveRecordInterface
$this->setPassword($value);
break;
case 6:
- $this->setAlgo($value);
+ $this->setLocale($value);
break;
case 7:
- $this->setSalt($value);
+ $this->setAlgo($value);
break;
case 8:
- $this->setRememberMeToken($value);
+ $this->setSalt($value);
break;
case 9:
- $this->setRememberMeSerial($value);
+ $this->setRememberMeToken($value);
break;
case 10:
- $this->setCreatedAt($value);
+ $this->setRememberMeSerial($value);
break;
case 11:
+ $this->setCreatedAt($value);
+ break;
+ case 12:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1459,12 +1513,13 @@ abstract class Admin implements ActiveRecordInterface
if (array_key_exists($keys[3], $arr)) $this->setLastname($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setLogin($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setPassword($arr[$keys[5]]);
- if (array_key_exists($keys[6], $arr)) $this->setAlgo($arr[$keys[6]]);
- if (array_key_exists($keys[7], $arr)) $this->setSalt($arr[$keys[7]]);
- if (array_key_exists($keys[8], $arr)) $this->setRememberMeToken($arr[$keys[8]]);
- if (array_key_exists($keys[9], $arr)) $this->setRememberMeSerial($arr[$keys[9]]);
- if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]);
- if (array_key_exists($keys[11], $arr)) $this->setUpdatedAt($arr[$keys[11]]);
+ if (array_key_exists($keys[6], $arr)) $this->setLocale($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setAlgo($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setSalt($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setRememberMeToken($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setRememberMeSerial($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setCreatedAt($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setUpdatedAt($arr[$keys[12]]);
}
/**
@@ -1482,6 +1537,7 @@ abstract class Admin implements ActiveRecordInterface
if ($this->isColumnModified(AdminTableMap::LASTNAME)) $criteria->add(AdminTableMap::LASTNAME, $this->lastname);
if ($this->isColumnModified(AdminTableMap::LOGIN)) $criteria->add(AdminTableMap::LOGIN, $this->login);
if ($this->isColumnModified(AdminTableMap::PASSWORD)) $criteria->add(AdminTableMap::PASSWORD, $this->password);
+ if ($this->isColumnModified(AdminTableMap::LOCALE)) $criteria->add(AdminTableMap::LOCALE, $this->locale);
if ($this->isColumnModified(AdminTableMap::ALGO)) $criteria->add(AdminTableMap::ALGO, $this->algo);
if ($this->isColumnModified(AdminTableMap::SALT)) $criteria->add(AdminTableMap::SALT, $this->salt);
if ($this->isColumnModified(AdminTableMap::REMEMBER_ME_TOKEN)) $criteria->add(AdminTableMap::REMEMBER_ME_TOKEN, $this->remember_me_token);
@@ -1556,6 +1612,7 @@ abstract class Admin implements ActiveRecordInterface
$copyObj->setLastname($this->getLastname());
$copyObj->setLogin($this->getLogin());
$copyObj->setPassword($this->getPassword());
+ $copyObj->setLocale($this->getLocale());
$copyObj->setAlgo($this->getAlgo());
$copyObj->setSalt($this->getSalt());
$copyObj->setRememberMeToken($this->getRememberMeToken());
@@ -1652,6 +1709,7 @@ abstract class Admin implements ActiveRecordInterface
$this->lastname = null;
$this->login = null;
$this->password = null;
+ $this->locale = null;
$this->algo = null;
$this->salt = null;
$this->remember_me_token = null;
diff --git a/core/lib/Thelia/Model/Base/AdminQuery.php b/core/lib/Thelia/Model/Base/AdminQuery.php
index 0ec88d23e..3b4bb9eb5 100644
--- a/core/lib/Thelia/Model/Base/AdminQuery.php
+++ b/core/lib/Thelia/Model/Base/AdminQuery.php
@@ -27,6 +27,7 @@ use Thelia\Model\Map\AdminTableMap;
* @method ChildAdminQuery orderByLastname($order = Criteria::ASC) Order by the lastname column
* @method ChildAdminQuery orderByLogin($order = Criteria::ASC) Order by the login column
* @method ChildAdminQuery orderByPassword($order = Criteria::ASC) Order by the password column
+ * @method ChildAdminQuery orderByLocale($order = Criteria::ASC) Order by the locale column
* @method ChildAdminQuery orderByAlgo($order = Criteria::ASC) Order by the algo column
* @method ChildAdminQuery orderBySalt($order = Criteria::ASC) Order by the salt column
* @method ChildAdminQuery orderByRememberMeToken($order = Criteria::ASC) Order by the remember_me_token column
@@ -40,6 +41,7 @@ use Thelia\Model\Map\AdminTableMap;
* @method ChildAdminQuery groupByLastname() Group by the lastname column
* @method ChildAdminQuery groupByLogin() Group by the login column
* @method ChildAdminQuery groupByPassword() Group by the password column
+ * @method ChildAdminQuery groupByLocale() Group by the locale column
* @method ChildAdminQuery groupByAlgo() Group by the algo column
* @method ChildAdminQuery groupBySalt() Group by the salt column
* @method ChildAdminQuery groupByRememberMeToken() Group by the remember_me_token column
@@ -64,6 +66,7 @@ use Thelia\Model\Map\AdminTableMap;
* @method ChildAdmin findOneByLastname(string $lastname) Return the first ChildAdmin filtered by the lastname column
* @method ChildAdmin findOneByLogin(string $login) Return the first ChildAdmin filtered by the login column
* @method ChildAdmin findOneByPassword(string $password) Return the first ChildAdmin filtered by the password column
+ * @method ChildAdmin findOneByLocale(string $locale) Return the first ChildAdmin filtered by the locale column
* @method ChildAdmin findOneByAlgo(string $algo) Return the first ChildAdmin filtered by the algo column
* @method ChildAdmin findOneBySalt(string $salt) Return the first ChildAdmin filtered by the salt column
* @method ChildAdmin findOneByRememberMeToken(string $remember_me_token) Return the first ChildAdmin filtered by the remember_me_token column
@@ -77,6 +80,7 @@ use Thelia\Model\Map\AdminTableMap;
* @method array findByLastname(string $lastname) Return ChildAdmin objects filtered by the lastname column
* @method array findByLogin(string $login) Return ChildAdmin objects filtered by the login column
* @method array findByPassword(string $password) Return ChildAdmin objects filtered by the password column
+ * @method array findByLocale(string $locale) Return ChildAdmin objects filtered by the locale column
* @method array findByAlgo(string $algo) Return ChildAdmin objects filtered by the algo column
* @method array findBySalt(string $salt) Return ChildAdmin objects filtered by the salt column
* @method array findByRememberMeToken(string $remember_me_token) Return ChildAdmin objects filtered by the remember_me_token column
@@ -171,7 +175,7 @@ abstract class AdminQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT `ID`, `PROFILE_ID`, `FIRSTNAME`, `LASTNAME`, `LOGIN`, `PASSWORD`, `ALGO`, `SALT`, `REMEMBER_ME_TOKEN`, `REMEMBER_ME_SERIAL`, `CREATED_AT`, `UPDATED_AT` FROM `admin` WHERE `ID` = :p0';
+ $sql = 'SELECT `ID`, `PROFILE_ID`, `FIRSTNAME`, `LASTNAME`, `LOGIN`, `PASSWORD`, `LOCALE`, `ALGO`, `SALT`, `REMEMBER_ME_TOKEN`, `REMEMBER_ME_SERIAL`, `CREATED_AT`, `UPDATED_AT` FROM `admin` WHERE `ID` = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -460,6 +464,35 @@ abstract class AdminQuery extends ModelCriteria
return $this->addUsingAlias(AdminTableMap::PASSWORD, $password, $comparison);
}
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminTableMap::LOCALE, $locale, $comparison);
+ }
+
/**
* Filter the query on the algo column
*
diff --git a/core/lib/Thelia/Model/Map/AdminTableMap.php b/core/lib/Thelia/Model/Map/AdminTableMap.php
index 2ba6714d1..2010f9a9c 100644
--- a/core/lib/Thelia/Model/Map/AdminTableMap.php
+++ b/core/lib/Thelia/Model/Map/AdminTableMap.php
@@ -58,7 +58,7 @@ class AdminTableMap extends TableMap
/**
* The total number of columns
*/
- const NUM_COLUMNS = 12;
+ const NUM_COLUMNS = 13;
/**
* The number of lazy-loaded columns
@@ -68,7 +68,7 @@ class AdminTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
- const NUM_HYDRATE_COLUMNS = 12;
+ const NUM_HYDRATE_COLUMNS = 13;
/**
* the column name for the ID field
@@ -100,6 +100,11 @@ class AdminTableMap extends TableMap
*/
const PASSWORD = 'admin.PASSWORD';
+ /**
+ * the column name for the LOCALE field
+ */
+ const LOCALE = 'admin.LOCALE';
+
/**
* the column name for the ALGO field
*/
@@ -142,12 +147,12 @@ class AdminTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'ProfileId', 'Firstname', 'Lastname', 'Login', 'Password', 'Algo', 'Salt', 'RememberMeToken', 'RememberMeSerial', 'CreatedAt', 'UpdatedAt', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'profileId', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'rememberMeToken', 'rememberMeSerial', 'createdAt', 'updatedAt', ),
- self::TYPE_COLNAME => array(AdminTableMap::ID, AdminTableMap::PROFILE_ID, AdminTableMap::FIRSTNAME, AdminTableMap::LASTNAME, AdminTableMap::LOGIN, AdminTableMap::PASSWORD, AdminTableMap::ALGO, AdminTableMap::SALT, AdminTableMap::REMEMBER_ME_TOKEN, AdminTableMap::REMEMBER_ME_SERIAL, AdminTableMap::CREATED_AT, AdminTableMap::UPDATED_AT, ),
- self::TYPE_RAW_COLNAME => array('ID', 'PROFILE_ID', 'FIRSTNAME', 'LASTNAME', 'LOGIN', 'PASSWORD', 'ALGO', 'SALT', 'REMEMBER_ME_TOKEN', 'REMEMBER_ME_SERIAL', 'CREATED_AT', 'UPDATED_AT', ),
- self::TYPE_FIELDNAME => array('id', 'profile_id', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'remember_me_token', 'remember_me_serial', 'created_at', 'updated_at', ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
+ self::TYPE_PHPNAME => array('Id', 'ProfileId', 'Firstname', 'Lastname', 'Login', 'Password', 'Locale', 'Algo', 'Salt', 'RememberMeToken', 'RememberMeSerial', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'profileId', 'firstname', 'lastname', 'login', 'password', 'locale', 'algo', 'salt', 'rememberMeToken', 'rememberMeSerial', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(AdminTableMap::ID, AdminTableMap::PROFILE_ID, AdminTableMap::FIRSTNAME, AdminTableMap::LASTNAME, AdminTableMap::LOGIN, AdminTableMap::PASSWORD, AdminTableMap::LOCALE, AdminTableMap::ALGO, AdminTableMap::SALT, AdminTableMap::REMEMBER_ME_TOKEN, AdminTableMap::REMEMBER_ME_SERIAL, AdminTableMap::CREATED_AT, AdminTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'PROFILE_ID', 'FIRSTNAME', 'LASTNAME', 'LOGIN', 'PASSWORD', 'LOCALE', 'ALGO', 'SALT', 'REMEMBER_ME_TOKEN', 'REMEMBER_ME_SERIAL', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'profile_id', 'firstname', 'lastname', 'login', 'password', 'locale', 'algo', 'salt', 'remember_me_token', 'remember_me_serial', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, )
);
/**
@@ -157,12 +162,12 @@ class AdminTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'ProfileId' => 1, 'Firstname' => 2, 'Lastname' => 3, 'Login' => 4, 'Password' => 5, 'Algo' => 6, 'Salt' => 7, 'RememberMeToken' => 8, 'RememberMeSerial' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'profileId' => 1, 'firstname' => 2, 'lastname' => 3, 'login' => 4, 'password' => 5, 'algo' => 6, 'salt' => 7, 'rememberMeToken' => 8, 'rememberMeSerial' => 9, 'createdAt' => 10, 'updatedAt' => 11, ),
- self::TYPE_COLNAME => array(AdminTableMap::ID => 0, AdminTableMap::PROFILE_ID => 1, AdminTableMap::FIRSTNAME => 2, AdminTableMap::LASTNAME => 3, AdminTableMap::LOGIN => 4, AdminTableMap::PASSWORD => 5, AdminTableMap::ALGO => 6, AdminTableMap::SALT => 7, AdminTableMap::REMEMBER_ME_TOKEN => 8, AdminTableMap::REMEMBER_ME_SERIAL => 9, AdminTableMap::CREATED_AT => 10, AdminTableMap::UPDATED_AT => 11, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'PROFILE_ID' => 1, 'FIRSTNAME' => 2, 'LASTNAME' => 3, 'LOGIN' => 4, 'PASSWORD' => 5, 'ALGO' => 6, 'SALT' => 7, 'REMEMBER_ME_TOKEN' => 8, 'REMEMBER_ME_SERIAL' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'profile_id' => 1, 'firstname' => 2, 'lastname' => 3, 'login' => 4, 'password' => 5, 'algo' => 6, 'salt' => 7, 'remember_me_token' => 8, 'remember_me_serial' => 9, 'created_at' => 10, 'updated_at' => 11, ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
+ self::TYPE_PHPNAME => array('Id' => 0, 'ProfileId' => 1, 'Firstname' => 2, 'Lastname' => 3, 'Login' => 4, 'Password' => 5, 'Locale' => 6, 'Algo' => 7, 'Salt' => 8, 'RememberMeToken' => 9, 'RememberMeSerial' => 10, 'CreatedAt' => 11, 'UpdatedAt' => 12, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'profileId' => 1, 'firstname' => 2, 'lastname' => 3, 'login' => 4, 'password' => 5, 'locale' => 6, 'algo' => 7, 'salt' => 8, 'rememberMeToken' => 9, 'rememberMeSerial' => 10, 'createdAt' => 11, 'updatedAt' => 12, ),
+ self::TYPE_COLNAME => array(AdminTableMap::ID => 0, AdminTableMap::PROFILE_ID => 1, AdminTableMap::FIRSTNAME => 2, AdminTableMap::LASTNAME => 3, AdminTableMap::LOGIN => 4, AdminTableMap::PASSWORD => 5, AdminTableMap::LOCALE => 6, AdminTableMap::ALGO => 7, AdminTableMap::SALT => 8, AdminTableMap::REMEMBER_ME_TOKEN => 9, AdminTableMap::REMEMBER_ME_SERIAL => 10, AdminTableMap::CREATED_AT => 11, AdminTableMap::UPDATED_AT => 12, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'PROFILE_ID' => 1, 'FIRSTNAME' => 2, 'LASTNAME' => 3, 'LOGIN' => 4, 'PASSWORD' => 5, 'LOCALE' => 6, 'ALGO' => 7, 'SALT' => 8, 'REMEMBER_ME_TOKEN' => 9, 'REMEMBER_ME_SERIAL' => 10, 'CREATED_AT' => 11, 'UPDATED_AT' => 12, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'profile_id' => 1, 'firstname' => 2, 'lastname' => 3, 'login' => 4, 'password' => 5, 'locale' => 6, 'algo' => 7, 'salt' => 8, 'remember_me_token' => 9, 'remember_me_serial' => 10, 'created_at' => 11, 'updated_at' => 12, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, )
);
/**
@@ -187,6 +192,7 @@ class AdminTableMap extends TableMap
$this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 100, null);
$this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 100, null);
$this->addColumn('PASSWORD', 'Password', 'VARCHAR', true, 128, null);
+ $this->addColumn('LOCALE', 'Locale', 'VARCHAR', true, 45, null);
$this->addColumn('ALGO', 'Algo', 'VARCHAR', false, 128, null);
$this->addColumn('SALT', 'Salt', 'VARCHAR', false, 128, null);
$this->addColumn('REMEMBER_ME_TOKEN', 'RememberMeToken', 'VARCHAR', false, 255, null);
@@ -360,6 +366,7 @@ class AdminTableMap extends TableMap
$criteria->addSelectColumn(AdminTableMap::LASTNAME);
$criteria->addSelectColumn(AdminTableMap::LOGIN);
$criteria->addSelectColumn(AdminTableMap::PASSWORD);
+ $criteria->addSelectColumn(AdminTableMap::LOCALE);
$criteria->addSelectColumn(AdminTableMap::ALGO);
$criteria->addSelectColumn(AdminTableMap::SALT);
$criteria->addSelectColumn(AdminTableMap::REMEMBER_ME_TOKEN);
@@ -373,6 +380,7 @@ class AdminTableMap extends TableMap
$criteria->addSelectColumn($alias . '.LASTNAME');
$criteria->addSelectColumn($alias . '.LOGIN');
$criteria->addSelectColumn($alias . '.PASSWORD');
+ $criteria->addSelectColumn($alias . '.LOCALE');
$criteria->addSelectColumn($alias . '.ALGO');
$criteria->addSelectColumn($alias . '.SALT');
$criteria->addSelectColumn($alias . '.REMEMBER_ME_TOKEN');
diff --git a/install/thelia.sql b/install/thelia.sql
index d7cc7b3c8..d5b84f368 100644
--- a/install/thelia.sql
+++ b/install/thelia.sql
@@ -978,6 +978,7 @@ CREATE TABLE `admin`
`lastname` VARCHAR(100) NOT NULL,
`login` VARCHAR(100) NOT NULL,
`password` VARCHAR(128) NOT NULL,
+ `locale` VARCHAR(45) NOT NULL,
`algo` VARCHAR(128),
`salt` VARCHAR(128),
`remember_me_token` VARCHAR(255),
@@ -1085,7 +1086,7 @@ CREATE TABLE `coupon`
`id` INTEGER NOT NULL AUTO_INCREMENT,
`code` VARCHAR(45) NOT NULL,
`type` VARCHAR(255) NOT NULL,
- `serialized_effects` TEXT NOT NULL,
+ `serialized_effects` LONGTEXT NOT NULL,
`is_enabled` TINYINT(1) NOT NULL,
`expiration_date` DATETIME NOT NULL,
`max_usage` INTEGER NOT NULL,
@@ -2394,7 +2395,7 @@ CREATE TABLE `coupon_version`
`id` INTEGER NOT NULL,
`code` VARCHAR(45) NOT NULL,
`type` VARCHAR(255) NOT NULL,
- `serialized_effects` TEXT NOT NULL,
+ `serialized_effects` LONGTEXT NOT NULL,
`is_enabled` TINYINT(1) NOT NULL,
`expiration_date` DATETIME NOT NULL,
`max_usage` INTEGER NOT NULL,
diff --git a/reset_install.bat b/reset_install.bat
index dc6d667e2..7caf00fe4 100644
--- a/reset_install.bat
+++ b/reset_install.bat
@@ -43,7 +43,7 @@ if exist local\config\database.yml (
echo [INFO] Activating Delivery Module(s)
php Thelia module:activate Colissimo
- echo "[INFO] Activating Payment Module(s)"
+ echo [INFO] Activating Payment Module(s)
php Thelia module:activate Cheque
echo [SUCCESS] Reset done
diff --git a/templates/backOffice/default/administrators.html b/templates/backOffice/default/administrators.html
index 73fd9724d..9bec35ee3 100644
--- a/templates/backOffice/default/administrators.html
+++ b/templates/backOffice/default/administrators.html
@@ -39,6 +39,7 @@