Allow users to override the timezone and the language
This commit is contained in:
@@ -33,7 +33,7 @@ class Database extends Base
|
|||||||
$user = $this->db->table(User::TABLE)->eq('username', $username)->eq('is_ldap_user', 0)->findOne();
|
$user = $this->db->table(User::TABLE)->eq('username', $username)->eq('is_ldap_user', 0)->findOne();
|
||||||
|
|
||||||
if ($user && password_verify($password, $user['password'])) {
|
if ($user && password_verify($password, $user['password'])) {
|
||||||
$this->user->updateSession($user);
|
$this->userSession->refresh($user);
|
||||||
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
|
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class GitHub extends Base
|
|||||||
$user = $this->user->getByGitHubId($github_id);
|
$user = $this->user->getByGitHubId($github_id);
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$this->user->updateSession($user);
|
$this->userSession->refresh($user);
|
||||||
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
|
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class Google extends Base
|
|||||||
$user = $this->user->getByGoogleId($google_id);
|
$user = $this->user->getByGoogleId($google_id);
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$this->user->updateSession($user);
|
$this->userSession->refresh($user);
|
||||||
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
|
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class Ldap extends Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We open the session
|
// We open the session
|
||||||
$this->user->updateSession($user);
|
$this->userSession->refresh($user);
|
||||||
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
|
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class RememberMe extends Base
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Create the session
|
// Create the session
|
||||||
$this->user->updateSession($this->user->getById($record['user_id']));
|
$this->userSession->refresh($this->user->getById($record['user_id']));
|
||||||
|
|
||||||
$this->container['dispatcher']->dispatch(
|
$this->container['dispatcher']->dispatch(
|
||||||
'auth.success',
|
'auth.success',
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class ReverseProxy extends Base
|
|||||||
$user = $this->user->getByUsername($login);
|
$user = $this->user->getByUsername($login);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->user->updateSession($user);
|
$this->userSession->refresh($user);
|
||||||
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
|
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use Symfony\Component\Console\Command\Command;
|
|||||||
* @property \Model\ProjectPermission $projectPermission
|
* @property \Model\ProjectPermission $projectPermission
|
||||||
* @property \Model\ProjectAnalytic $projectAnalytic
|
* @property \Model\ProjectAnalytic $projectAnalytic
|
||||||
* @property \Model\ProjectDailySummary $projectDailySummary
|
* @property \Model\ProjectDailySummary $projectDailySummary
|
||||||
|
* @property \Model\SubtaskExport $subtaskExport
|
||||||
* @property \Model\Task $task
|
* @property \Model\Task $task
|
||||||
* @property \Model\TaskExport $taskExport
|
* @property \Model\TaskExport $taskExport
|
||||||
* @property \Model\TaskFinder $taskFinder
|
* @property \Model\TaskFinder $taskFinder
|
||||||
|
|||||||
@@ -151,6 +151,8 @@ class User extends Base
|
|||||||
public function create(array $values = array(), array $errors = array())
|
public function create(array $values = array(), array $errors = array())
|
||||||
{
|
{
|
||||||
$this->response->html($this->template->layout('user/new', array(
|
$this->response->html($this->template->layout('user/new', array(
|
||||||
|
'timezones' => $this->config->getTimezones(true),
|
||||||
|
'languages' => $this->config->getLanguages(true),
|
||||||
'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
|
'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
|
||||||
'projects' => $this->project->getList(),
|
'projects' => $this->project->getList(),
|
||||||
'errors' => $errors,
|
'errors' => $errors,
|
||||||
@@ -194,6 +196,8 @@ class User extends Base
|
|||||||
$this->response->html($this->layout('user/show', array(
|
$this->response->html($this->layout('user/show', array(
|
||||||
'projects' => $this->projectPermission->getAllowedProjects($user['id']),
|
'projects' => $this->projectPermission->getAllowedProjects($user['id']),
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
|
'timezones' => $this->config->getTimezones(true),
|
||||||
|
'languages' => $this->config->getLanguages(true),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,6 +362,8 @@ class User extends Base
|
|||||||
'errors' => $errors,
|
'errors' => $errors,
|
||||||
'projects' => $this->projectPermission->filterProjects($this->project->getList(), $user['id']),
|
'projects' => $this->projectPermission->filterProjects($this->project->getList(), $user['id']),
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
|
'timezones' => $this->config->getTimezones(true),
|
||||||
|
'languages' => $this->config->getLanguages(true),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -181,5 +181,8 @@ class Translator
|
|||||||
if (file_exists($filename)) {
|
if (file_exists($filename)) {
|
||||||
self::$locales = require $filename;
|
self::$locales = require $filename;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
self::$locales = array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
// 'Subtasks exportation for "%s"' => '',
|
// 'Subtasks exportation for "%s"' => '',
|
||||||
// 'Task Title' => '',
|
// 'Task Title' => '',
|
||||||
// 'Untitled' => '',
|
// 'Untitled' => '',
|
||||||
|
// 'Application default' => '',
|
||||||
|
// 'Language:' => '',
|
||||||
|
// 'Timezone:' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
// 'Subtasks exportation for "%s"' => '',
|
// 'Subtasks exportation for "%s"' => '',
|
||||||
// 'Task Title' => '',
|
// 'Task Title' => '',
|
||||||
// 'Untitled' => '',
|
// 'Untitled' => '',
|
||||||
|
// 'Application default' => '',
|
||||||
|
// 'Language:' => '',
|
||||||
|
// 'Timezone:' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -453,7 +453,7 @@ return array(
|
|||||||
'Notifications:' => 'Notificaciones:',
|
'Notifications:' => 'Notificaciones:',
|
||||||
// 'Notifications' => '',
|
// 'Notifications' => '',
|
||||||
'Group:' => 'Grupo:',
|
'Group:' => 'Grupo:',
|
||||||
'Regular user' => 'Usuario regular:',
|
'Regular user' => 'Usuario regular',
|
||||||
'Account type:' => 'Tipo de Cuenta:',
|
'Account type:' => 'Tipo de Cuenta:',
|
||||||
'Edit profile' => 'Editar perfil',
|
'Edit profile' => 'Editar perfil',
|
||||||
'Change password' => 'Cambiar contraseña',
|
'Change password' => 'Cambiar contraseña',
|
||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
// 'Subtasks exportation for "%s"' => '',
|
// 'Subtasks exportation for "%s"' => '',
|
||||||
// 'Task Title' => '',
|
// 'Task Title' => '',
|
||||||
// 'Untitled' => '',
|
// 'Untitled' => '',
|
||||||
|
// 'Application default' => '',
|
||||||
|
// 'Language:' => '',
|
||||||
|
// 'Timezone:' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
// 'Subtasks exportation for "%s"' => '',
|
// 'Subtasks exportation for "%s"' => '',
|
||||||
// 'Task Title' => '',
|
// 'Task Title' => '',
|
||||||
// 'Untitled' => '',
|
// 'Untitled' => '',
|
||||||
|
// 'Application default' => '',
|
||||||
|
// 'Language:' => '',
|
||||||
|
// 'Timezone:' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
'Subtasks exportation for "%s"' => 'Exportation des sous-tâches pour le projet « %s »',
|
'Subtasks exportation for "%s"' => 'Exportation des sous-tâches pour le projet « %s »',
|
||||||
'Task Title' => 'Titre de la tâche',
|
'Task Title' => 'Titre de la tâche',
|
||||||
'Untitled' => 'Sans nom',
|
'Untitled' => 'Sans nom',
|
||||||
|
'Application default' => 'Valeur par défaut de l\'application',
|
||||||
|
'Language:' => 'Langue :',
|
||||||
|
'Timezone:' => 'Fuseau horaire :',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
// 'Subtasks exportation for "%s"' => '',
|
// 'Subtasks exportation for "%s"' => '',
|
||||||
// 'Task Title' => '',
|
// 'Task Title' => '',
|
||||||
// 'Untitled' => '',
|
// 'Untitled' => '',
|
||||||
|
// 'Application default' => '',
|
||||||
|
// 'Language:' => '',
|
||||||
|
// 'Timezone:' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
// 'Subtasks exportation for "%s"' => '',
|
// 'Subtasks exportation for "%s"' => '',
|
||||||
// 'Task Title' => '',
|
// 'Task Title' => '',
|
||||||
// 'Untitled' => '',
|
// 'Untitled' => '',
|
||||||
|
// 'Application default' => '',
|
||||||
|
// 'Language:' => '',
|
||||||
|
// 'Timezone:' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
// 'Subtasks exportation for "%s"' => '',
|
// 'Subtasks exportation for "%s"' => '',
|
||||||
// 'Task Title' => '',
|
// 'Task Title' => '',
|
||||||
// 'Untitled' => '',
|
// 'Untitled' => '',
|
||||||
|
// 'Application default' => '',
|
||||||
|
// 'Language:' => '',
|
||||||
|
// 'Timezone:' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
// 'Subtasks exportation for "%s"' => '',
|
// 'Subtasks exportation for "%s"' => '',
|
||||||
// 'Task Title' => '',
|
// 'Task Title' => '',
|
||||||
// 'Untitled' => '',
|
// 'Untitled' => '',
|
||||||
|
// 'Application default' => '',
|
||||||
|
// 'Language:' => '',
|
||||||
|
// 'Timezone:' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
// 'Subtasks exportation for "%s"' => '',
|
// 'Subtasks exportation for "%s"' => '',
|
||||||
// 'Task Title' => '',
|
// 'Task Title' => '',
|
||||||
// 'Untitled' => '',
|
// 'Untitled' => '',
|
||||||
|
// 'Application default' => '',
|
||||||
|
// 'Language:' => '',
|
||||||
|
// 'Timezone:' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
// 'Subtasks exportation for "%s"' => '',
|
// 'Subtasks exportation for "%s"' => '',
|
||||||
// 'Task Title' => '',
|
// 'Task Title' => '',
|
||||||
// 'Untitled' => '',
|
// 'Untitled' => '',
|
||||||
|
// 'Application default' => '',
|
||||||
|
// 'Language:' => '',
|
||||||
|
// 'Timezone:' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
// 'Subtasks exportation for "%s"' => '',
|
// 'Subtasks exportation for "%s"' => '',
|
||||||
// 'Task Title' => '',
|
// 'Task Title' => '',
|
||||||
// 'Untitled' => '',
|
// 'Untitled' => '',
|
||||||
|
// 'Application default' => '',
|
||||||
|
// 'Language:' => '',
|
||||||
|
// 'Timezone:' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
// 'Subtasks exportation for "%s"' => '',
|
// 'Subtasks exportation for "%s"' => '',
|
||||||
// 'Task Title' => '',
|
// 'Task Title' => '',
|
||||||
// 'Untitled' => '',
|
// 'Untitled' => '',
|
||||||
|
// 'Application default' => '',
|
||||||
|
// 'Language:' => '',
|
||||||
|
// 'Timezone:' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -644,4 +644,7 @@ return array(
|
|||||||
// 'Subtasks exportation for "%s"' => '',
|
// 'Subtasks exportation for "%s"' => '',
|
||||||
// 'Task Title' => '',
|
// 'Task Title' => '',
|
||||||
// 'Untitled' => '',
|
// 'Untitled' => '',
|
||||||
|
// 'Application default' => '',
|
||||||
|
// 'Language:' => '',
|
||||||
|
// 'Timezone:' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -25,24 +25,32 @@ class Config extends Base
|
|||||||
* Get available timezones
|
* Get available timezones
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
* @param boolean $prepend Prepend a default value
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getTimezones()
|
public function getTimezones($prepend = false)
|
||||||
{
|
{
|
||||||
$timezones = timezone_identifiers_list();
|
$timezones = timezone_identifiers_list();
|
||||||
return array_combine(array_values($timezones), $timezones);
|
$listing = array_combine(array_values($timezones), $timezones);
|
||||||
|
|
||||||
|
if ($prepend) {
|
||||||
|
return array('' => t('Application default')) + $listing;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $listing;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get available languages
|
* Get available languages
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
* @param boolean $prepend Prepend a default value
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getLanguages()
|
public function getLanguages($prepend = false)
|
||||||
{
|
{
|
||||||
// Sorted by value
|
// Sorted by value
|
||||||
return array(
|
$languages = array(
|
||||||
'da_DK' => 'Dansk',
|
'da_DK' => 'Dansk',
|
||||||
'de_DE' => 'Deutsch',
|
'de_DE' => 'Deutsch',
|
||||||
'en_US' => 'English',
|
'en_US' => 'English',
|
||||||
@@ -59,6 +67,12 @@ class Config extends Base
|
|||||||
'ja_JP' => '日本語',
|
'ja_JP' => '日本語',
|
||||||
'th_TH' => 'ไทย',
|
'th_TH' => 'ไทย',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($prepend) {
|
||||||
|
return array('' => t('Application default')) + $languages;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,10 +152,11 @@ class Config extends Base
|
|||||||
*/
|
*/
|
||||||
public function setupTranslations()
|
public function setupTranslations()
|
||||||
{
|
{
|
||||||
$language = $this->get('application_language', 'en_US');
|
if ($this->userSession->isLogged() && ! empty($this->session['user']['language'])) {
|
||||||
|
Translator::load($this->session['user']['language']);
|
||||||
if ($language !== 'en_US') {
|
}
|
||||||
Translator::load($language);
|
else {
|
||||||
|
Translator::load($this->get('application_language', 'en_US'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,8 +167,13 @@ class Config extends Base
|
|||||||
*/
|
*/
|
||||||
public function setupTimezone()
|
public function setupTimezone()
|
||||||
{
|
{
|
||||||
|
if ($this->userSession->isLogged() && ! empty($this->session['user']['timezone'])) {
|
||||||
|
date_default_timezone_set($this->session['user']['timezone']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
date_default_timezone_set($this->get('application_timezone', 'UTC'));
|
date_default_timezone_set($this->get('application_timezone', 'UTC'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optimize the Sqlite database
|
* Optimize the Sqlite database
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ class User extends Base
|
|||||||
|
|
||||||
// If the user is connected refresh his session
|
// If the user is connected refresh his session
|
||||||
if (Session::isOpen() && $this->userSession->getId() == $values['id']) {
|
if (Session::isOpen() && $this->userSession->getId() == $values['id']) {
|
||||||
$this->updateSession();
|
$this->userSession->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -294,30 +294,6 @@ class User extends Base
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update user session information
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param array $user User data
|
|
||||||
*/
|
|
||||||
public function updateSession(array $user = array())
|
|
||||||
{
|
|
||||||
if (empty($user)) {
|
|
||||||
$user = $this->getById($this->userSession->getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($user['password'])) {
|
|
||||||
unset($user['password']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$user['id'] = (int) $user['id'];
|
|
||||||
$user['default_project_id'] = (int) $user['default_project_id'];
|
|
||||||
$user['is_admin'] = (bool) $user['is_admin'];
|
|
||||||
$user['is_ldap_user'] = (bool) $user['is_ldap_user'];
|
|
||||||
|
|
||||||
$this->session['user'] = $user;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common validation rules
|
* Common validation rules
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Model;
|
namespace Model;
|
||||||
|
|
||||||
|
use Core\Translator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User Session
|
* User Session
|
||||||
*
|
*
|
||||||
@@ -10,6 +12,30 @@ namespace Model;
|
|||||||
*/
|
*/
|
||||||
class UserSession extends Base
|
class UserSession extends Base
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Update user session information
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param array $user User data
|
||||||
|
*/
|
||||||
|
public function refresh(array $user = array())
|
||||||
|
{
|
||||||
|
if (empty($user)) {
|
||||||
|
$user = $this->user->getById($this->userSession->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($user['password'])) {
|
||||||
|
unset($user['password']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user['id'] = (int) $user['id'];
|
||||||
|
$user['default_project_id'] = (int) $user['default_project_id'];
|
||||||
|
$user['is_admin'] = (bool) $user['is_admin'];
|
||||||
|
$user['is_ldap_user'] = (bool) $user['is_ldap_user'];
|
||||||
|
|
||||||
|
$this->session['user'] = $user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the logged user is admin
|
* Return true if the logged user is admin
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ namespace Schema;
|
|||||||
use PDO;
|
use PDO;
|
||||||
use Core\Security;
|
use Core\Security;
|
||||||
|
|
||||||
const VERSION = 40;
|
const VERSION = 41;
|
||||||
|
|
||||||
|
function version_41($pdo)
|
||||||
|
{
|
||||||
|
$pdo->exec('ALTER TABLE users ADD COLUMN timezone VARCHAR(50)');
|
||||||
|
$pdo->exec('ALTER TABLE users ADD COLUMN language CHAR(5)');
|
||||||
|
}
|
||||||
|
|
||||||
function version_40($pdo)
|
function version_40($pdo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ namespace Schema;
|
|||||||
use PDO;
|
use PDO;
|
||||||
use Core\Security;
|
use Core\Security;
|
||||||
|
|
||||||
const VERSION = 21;
|
const VERSION = 22;
|
||||||
|
|
||||||
|
function version_22($pdo)
|
||||||
|
{
|
||||||
|
$pdo->exec('ALTER TABLE users ADD COLUMN timezone VARCHAR(50)');
|
||||||
|
$pdo->exec('ALTER TABLE users ADD COLUMN language CHAR(5)');
|
||||||
|
}
|
||||||
|
|
||||||
function version_21($pdo)
|
function version_21($pdo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ namespace Schema;
|
|||||||
use Core\Security;
|
use Core\Security;
|
||||||
use PDO;
|
use PDO;
|
||||||
|
|
||||||
const VERSION = 39;
|
const VERSION = 40;
|
||||||
|
|
||||||
|
function version_40($pdo)
|
||||||
|
{
|
||||||
|
$pdo->exec('ALTER TABLE users ADD COLUMN timezone TEXT');
|
||||||
|
$pdo->exec('ALTER TABLE users ADD COLUMN language TEXT');
|
||||||
|
}
|
||||||
|
|
||||||
function version_39($pdo)
|
function version_39($pdo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,12 @@
|
|||||||
<?= $this->formLabel(t('Default project'), 'default_project_id') ?>
|
<?= $this->formLabel(t('Default project'), 'default_project_id') ?>
|
||||||
<?= $this->formSelect('default_project_id', $projects, $values, $errors) ?><br/>
|
<?= $this->formSelect('default_project_id', $projects, $values, $errors) ?><br/>
|
||||||
|
|
||||||
|
<?= $this->formLabel(t('Timezone'), 'timezone') ?>
|
||||||
|
<?= $this->formSelect('timezone', $timezones, $values, $errors) ?><br/>
|
||||||
|
|
||||||
|
<?= $this->formLabel(t('Language'), 'language') ?>
|
||||||
|
<?= $this->formSelect('language', $languages, $values, $errors) ?><br/>
|
||||||
|
|
||||||
<?php if ($this->userSession->isAdmin()): ?>
|
<?php if ($this->userSession->isAdmin()): ?>
|
||||||
<?= $this->formCheckbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?><br/>
|
<?= $this->formCheckbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?><br/>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|||||||
@@ -27,6 +27,12 @@
|
|||||||
<?= $this->formLabel(t('Default project'), 'default_project_id') ?>
|
<?= $this->formLabel(t('Default project'), 'default_project_id') ?>
|
||||||
<?= $this->formSelect('default_project_id', $projects, $values, $errors) ?><br/>
|
<?= $this->formSelect('default_project_id', $projects, $values, $errors) ?><br/>
|
||||||
|
|
||||||
|
<?= $this->formLabel(t('Timezone'), 'timezone') ?>
|
||||||
|
<?= $this->formSelect('timezone', $timezones, $values, $errors) ?><br/>
|
||||||
|
|
||||||
|
<?= $this->formLabel(t('Language'), 'language') ?>
|
||||||
|
<?= $this->formSelect('language', $languages, $values, $errors) ?><br/>
|
||||||
|
|
||||||
<?= $this->formCheckbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?>
|
<?= $this->formCheckbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
|
|||||||
@@ -3,9 +3,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<ul class="listing">
|
<ul class="listing">
|
||||||
<li><?= t('Username:') ?> <strong><?= $this->e($user['username']) ?></strong></li>
|
<li><?= t('Username:') ?> <strong><?= $this->e($user['username']) ?></strong></li>
|
||||||
<li><?= t('Name:') ?> <strong><?= $this->e($user['name']) ?></strong></li>
|
<li><?= t('Name:') ?> <strong><?= $this->e($user['name']) ?: t('None') ?></strong></li>
|
||||||
<li><?= t('Email:') ?> <strong><?= $this->e($user['email']) ?></strong></li>
|
<li><?= t('Email:') ?> <strong><?= $this->e($user['email']) ?: t('None') ?></strong></li>
|
||||||
<li><?= t('Default project:') ?> <strong><?= (isset($user['default_project_id']) && isset($projects[$user['default_project_id']])) ? $this->e($projects[$user['default_project_id']]) : t('None'); ?></strong></li>
|
<li><?= t('Default project:') ?> <strong><?= (isset($user['default_project_id']) && isset($projects[$user['default_project_id']])) ? $this->e($projects[$user['default_project_id']]) : t('None') ?></strong></li>
|
||||||
|
<li><?= t('Timezone:') ?> <strong><?= $this->inList($user['timezone'], $timezones) ?></strong></li>
|
||||||
|
<li><?= t('Language:') ?> <strong><?= $this->inList($user['language'], $languages) ?></strong></li>
|
||||||
<li><?= t('Notifications:') ?> <strong><?= $user['notifications_enabled'] == 1 ? t('Enabled') : t('Disabled') ?></strong></li>
|
<li><?= t('Notifications:') ?> <strong><?= $user['notifications_enabled'] == 1 ? t('Enabled') : t('Disabled') ?></strong></li>
|
||||||
<li><?= t('Group:') ?> <strong><?= $user['is_admin'] ? t('Administrator') : t('Regular user') ?></strong></li>
|
<li><?= t('Group:') ?> <strong><?= $user['is_admin'] ? t('Administrator') : t('Regular user') ?></strong></li>
|
||||||
<li><?= t('Account type:') ?> <strong><?= $user['is_ldap_user'] ? t('Remote') : t('Local') ?></strong></li>
|
<li><?= t('Account type:') ?> <strong><?= $user['is_ldap_user'] ? t('Remote') : t('Local') ?></strong></li>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use Model\TaskPermission;
|
|||||||
use Model\Project;
|
use Model\Project;
|
||||||
use Model\Category;
|
use Model\Category;
|
||||||
use Model\User;
|
use Model\User;
|
||||||
|
use Model\UserSession;
|
||||||
|
|
||||||
class TaskPermissionTest extends Base
|
class TaskPermissionTest extends Base
|
||||||
{
|
{
|
||||||
@@ -19,6 +20,7 @@ class TaskPermissionTest extends Base
|
|||||||
$tp = new TaskPermission($this->container);
|
$tp = new TaskPermission($this->container);
|
||||||
$p = new Project($this->container);
|
$p = new Project($this->container);
|
||||||
$u = new User($this->container);
|
$u = new User($this->container);
|
||||||
|
$us = new UserSession($this->container);
|
||||||
|
|
||||||
$this->assertNotFalse($u->create(array('username' => 'toto', 'password' => '123456')));
|
$this->assertNotFalse($u->create(array('username' => 'toto', 'password' => '123456')));
|
||||||
$this->assertNotFalse($u->create(array('username' => 'toto2', 'password' => '123456')));
|
$this->assertNotFalse($u->create(array('username' => 'toto2', 'password' => '123456')));
|
||||||
@@ -31,7 +33,7 @@ class TaskPermissionTest extends Base
|
|||||||
// User #1 can remove everything
|
// User #1 can remove everything
|
||||||
$user = $u->getbyId(1);
|
$user = $u->getbyId(1);
|
||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$us->refresh($user);
|
||||||
|
|
||||||
$task = $tf->getbyId(1);
|
$task = $tf->getbyId(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
@@ -40,7 +42,7 @@ class TaskPermissionTest extends Base
|
|||||||
// User #2 can't remove the task #1
|
// User #2 can't remove the task #1
|
||||||
$user = $u->getbyId(2);
|
$user = $u->getbyId(2);
|
||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$us->refresh($user);
|
||||||
|
|
||||||
$task = $tf->getbyId(1);
|
$task = $tf->getbyId(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
@@ -49,7 +51,7 @@ class TaskPermissionTest extends Base
|
|||||||
// User #1 can remove everything
|
// User #1 can remove everything
|
||||||
$user = $u->getbyId(1);
|
$user = $u->getbyId(1);
|
||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$us->refresh($user);
|
||||||
|
|
||||||
$task = $tf->getbyId(2);
|
$task = $tf->getbyId(2);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
@@ -58,7 +60,7 @@ class TaskPermissionTest extends Base
|
|||||||
// User #2 can remove his own task
|
// User #2 can remove his own task
|
||||||
$user = $u->getbyId(2);
|
$user = $u->getbyId(2);
|
||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$us->refresh($user);
|
||||||
|
|
||||||
$task = $tf->getbyId(2);
|
$task = $tf->getbyId(2);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
@@ -67,7 +69,7 @@ class TaskPermissionTest extends Base
|
|||||||
// User #1 can remove everything
|
// User #1 can remove everything
|
||||||
$user = $u->getbyId(1);
|
$user = $u->getbyId(1);
|
||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$us->refresh($user);
|
||||||
|
|
||||||
$task = $tf->getbyId(3);
|
$task = $tf->getbyId(3);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
@@ -76,7 +78,7 @@ class TaskPermissionTest extends Base
|
|||||||
// User #2 can't remove the task #3
|
// User #2 can't remove the task #3
|
||||||
$user = $u->getbyId(2);
|
$user = $u->getbyId(2);
|
||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$us->refresh($user);
|
||||||
|
|
||||||
$task = $tf->getbyId(3);
|
$task = $tf->getbyId(3);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
@@ -85,7 +87,7 @@ class TaskPermissionTest extends Base
|
|||||||
// User #1 can remove everything
|
// User #1 can remove everything
|
||||||
$user = $u->getbyId(1);
|
$user = $u->getbyId(1);
|
||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$us->refresh($user);
|
||||||
|
|
||||||
$task = $tf->getbyId(4);
|
$task = $tf->getbyId(4);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
@@ -94,7 +96,7 @@ class TaskPermissionTest extends Base
|
|||||||
// User #2 can't remove the task #4
|
// User #2 can't remove the task #4
|
||||||
$user = $u->getbyId(2);
|
$user = $u->getbyId(2);
|
||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$us->refresh($user);
|
||||||
|
|
||||||
$task = $tf->getbyId(4);
|
$task = $tf->getbyId(4);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
|
|||||||
Reference in New Issue
Block a user