From 6c772de184505ae339a970631c8e98f3e3b6e5f0 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 27 Jun 2015 15:14:04 -0400 Subject: Remove column default_project_id for users because it's useless now --- app/Api/User.php | 9 +++------ app/Controller/Board.php | 31 ------------------------------- app/Controller/User.php | 1 - app/Model/User.php | 2 -- app/Model/UserSession.php | 34 ---------------------------------- app/Schema/Mysql.php | 7 ++++++- app/Schema/Postgres.php | 7 ++++++- app/Schema/Sqlite.php | 3 +-- app/Template/user/edit.php | 3 --- app/Template/user/index.php | 1 - app/Template/user/new.php | 3 --- app/Template/user/show.php | 1 - docs/api-json-rpc.markdown | 5 ----- tests/units/UserSessionTest.php | 13 ------------- 14 files changed, 16 insertions(+), 104 deletions(-) diff --git a/app/Api/User.php b/app/Api/User.php index 166ef2c1..0f0f4e59 100644 --- a/app/Api/User.php +++ b/app/Api/User.php @@ -27,7 +27,7 @@ class User extends Base return $this->user->remove($user_id); } - public function createUser($username, $password, $name = '', $email = '', $is_admin = 0, $default_project_id = 0) + public function createUser($username, $password, $name = '', $email = '', $is_admin = 0) { $values = array( 'username' => $username, @@ -36,7 +36,6 @@ class User extends Base 'name' => $name, 'email' => $email, 'is_admin' => $is_admin, - 'default_project_id' => $default_project_id, ); list($valid,) = $this->user->validateCreation($values); @@ -44,7 +43,7 @@ class User extends Base return $valid ? $this->user->create($values) : false; } - public function createLdapUser($username = '', $email = '', $is_admin = 0, $default_project_id = 0) + public function createLdapUser($username = '', $email = '', $is_admin = 0) { $ldap = new Ldap($this->container); $user = $ldap->lookup($username, $email); @@ -59,13 +58,12 @@ class User extends Base 'email' => $user['email'], 'is_ldap_user' => 1, 'is_admin' => $is_admin, - 'default_project_id' => $default_project_id, ); return $this->user->create($values); } - public function updateUser($id, $username = null, $name = null, $email = null, $is_admin = null, $default_project_id = null) + public function updateUser($id, $username = null, $name = null, $email = null, $is_admin = null) { $values = array( 'id' => $id, @@ -73,7 +71,6 @@ class User extends Base 'name' => $name, 'email' => $email, 'is_admin' => $is_admin, - 'default_project_id' => $default_project_id, ); foreach ($values as $key => $value) { diff --git a/app/Controller/Board.php b/app/Controller/Board.php index 2b633d82..433d3af1 100644 --- a/app/Controller/Board.php +++ b/app/Controller/Board.php @@ -44,35 +44,6 @@ class Board extends Base ))); } - /** - * Redirect the user to the default project - * - * @access public - */ - public function index() - { - $last_seen_project_id = $this->userSession->getLastSeenProjectId(); - $favorite_project_id = $this->userSession->getFavoriteProjectId(); - $project_id = $last_seen_project_id ?: $favorite_project_id; - - if (! $project_id) { - $projects = $this->projectPermission->getAllowedProjects($this->userSession->getId()); - - if (empty($projects)) { - - if ($this->userSession->isAdmin()) { - $this->redirectNoProject(); - } - - $this->forbidden(); - } - - $project_id = key($projects); - } - - $this->show($project_id); - } - /** * Show a board for a given project * @@ -87,8 +58,6 @@ class Board extends Base $board_selector = $projects; unset($board_selector[$project['id']]); - $this->userSession->storeLastSeenProjectId($project['id']); - list($categories_listing, $categories_description) = $this->category->getBoardCategories($project['id']); $this->response->html($this->template->layout('board/index', array( diff --git a/app/Controller/User.php b/app/Controller/User.php index 4cea06b1..1a7810b0 100644 --- a/app/Controller/User.php +++ b/app/Controller/User.php @@ -360,7 +360,6 @@ class User extends Base $this->response->html($this->layout('user/edit', array( 'values' => $values, 'errors' => $errors, - 'projects' => $this->projectPermission->filterProjects($this->project->getList(), $user['id']), 'user' => $user, 'timezones' => $this->config->getTimezones(true), 'languages' => $this->config->getLanguages(true), diff --git a/app/Model/User.php b/app/Model/User.php index 63b49367..4c32942c 100644 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -57,7 +57,6 @@ class User extends Base 'name', 'email', 'is_admin', - 'default_project_id', 'is_ldap_user', 'notifications_enabled', 'google_id', @@ -377,7 +376,6 @@ class User extends Base new Validators\MaxLength('username', t('The maximum length is %d characters', 50), 50), new Validators\Unique('username', t('The username must be unique'), $this->db->getConnection(), self::TABLE, 'id'), new Validators\Email('email', t('Email address invalid')), - new Validators\Integer('default_project_id', t('This value must be an integer')), new Validators\Integer('is_admin', t('This value must be an integer')), ); } diff --git a/app/Model/UserSession.php b/app/Model/UserSession.php index 6703a1bc..f1f2ffee 100644 --- a/app/Model/UserSession.php +++ b/app/Model/UserSession.php @@ -33,7 +33,6 @@ class UserSession extends Base } $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']; $user['twofactor_activated'] = (bool) $user['twofactor_activated']; @@ -95,37 +94,4 @@ class UserSession extends Base { return ! empty($this->session['user']); } - - /** - * Get the last seen project from the session - * - * @access public - * @return integer - */ - public function getLastSeenProjectId() - { - return empty($this->session['last_show_project_id']) ? 0 : $this->session['last_show_project_id']; - } - - /** - * Get the default project from the session - * - * @access public - * @return integer - */ - public function getFavoriteProjectId() - { - return isset($this->session['user']['default_project_id']) ? $this->session['user']['default_project_id'] : 0; - } - - /** - * Set the last seen project from the session - * - * @access public - * @param integer $project_id Project id - */ - public function storeLastSeenProjectId($project_id) - { - $this->session['last_show_project_id'] = (int) $project_id; - } } diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index dd6af5a2..0c932104 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -6,7 +6,12 @@ use PDO; use Core\Security; use Model\Link; -const VERSION = 76; +const VERSION = 77; + +function version_77($pdo) +{ + $pdo->exec('ALTER TABLE users DROP COLUMN `default_project_id`'); +} function version_76($pdo) { diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index ac6ebf6f..a3309068 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -6,7 +6,12 @@ use PDO; use Core\Security; use Model\Link; -const VERSION = 56; +const VERSION = 57; + +function version_57($pdo) +{ + $pdo->exec('ALTER TABLE users DROP COLUMN "default_project_id"'); +} function version_56($pdo) { diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index feda8ec2..c3bbbac9 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -903,8 +903,7 @@ function version_1($pdo) id INTEGER PRIMARY KEY, username TEXT NOT NULL, password TEXT, - is_admin INTEGER DEFAULT 0, - default_project_id INTEGER DEFAULT 0 + is_admin INTEGER DEFAULT 0 ) "); diff --git a/app/Template/user/edit.php b/app/Template/user/edit.php index e29dcfca..2462308f 100644 --- a/app/Template/user/edit.php +++ b/app/Template/user/edit.php @@ -17,9 +17,6 @@ form->label(t('Email'), 'email') ?> form->email('email', $values, $errors) ?>
- form->label(t('Default project'), 'default_project_id') ?> - form->select('default_project_id', $projects, $values, $errors) ?>
- form->label(t('Timezone'), 'timezone') ?> form->select('timezone', $timezones, $values, $errors) ?>
diff --git a/app/Template/user/index.php b/app/Template/user/index.php index 6b4396b2..08184698 100644 --- a/app/Template/user/index.php +++ b/app/Template/user/index.php @@ -18,7 +18,6 @@ order(t('Email'), 'email') ?> order(t('Administrator'), 'is_admin') ?> order(t('Two factor authentication'), 'twofactor_activated') ?> - order(t('Default project'), 'default_project_id') ?> order(t('Notifications'), 'notifications_enabled') ?> order(t('Account type'), 'is_ldap_user') ?> diff --git a/app/Template/user/new.php b/app/Template/user/new.php index ba7a3881..5c55b0bb 100644 --- a/app/Template/user/new.php +++ b/app/Template/user/new.php @@ -24,9 +24,6 @@ form->label(t('Confirmation'), 'confirmation') ?> form->password('confirmation', $values, $errors, array('required')) ?>
- form->label(t('Default project'), 'default_project_id') ?> - form->select('default_project_id', $projects, $values, $errors) ?>
- form->label(t('Timezone'), 'timezone') ?> form->select('timezone', $timezones, $values, $errors) ?>
diff --git a/app/Template/user/show.php b/app/Template/user/show.php index a9de6d85..acb02f71 100644 --- a/app/Template/user/show.php +++ b/app/Template/user/show.php @@ -20,7 +20,6 @@