summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-06-27 15:14:04 -0400
committerFrederic Guillot <fred@kanboard.net>2015-06-27 15:14:04 -0400
commit6c772de184505ae339a970631c8e98f3e3b6e5f0 (patch)
tree47aaafd9ef996041c7857db72ad1d274d7b44c42
parente6e286be8315345bed575712b338629e4ba76bcb (diff)
Remove column default_project_id for users because it's useless now
-rw-r--r--app/Api/User.php9
-rw-r--r--app/Controller/Board.php31
-rw-r--r--app/Controller/User.php1
-rw-r--r--app/Model/User.php2
-rw-r--r--app/Model/UserSession.php34
-rw-r--r--app/Schema/Mysql.php7
-rw-r--r--app/Schema/Postgres.php7
-rw-r--r--app/Schema/Sqlite.php3
-rw-r--r--app/Template/user/edit.php3
-rw-r--r--app/Template/user/index.php1
-rw-r--r--app/Template/user/new.php3
-rw-r--r--app/Template/user/show.php1
-rw-r--r--docs/api-json-rpc.markdown5
-rw-r--r--tests/units/UserSessionTest.php13
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
@@ -45,35 +45,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
*
* @access public
@@ -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 @@
<?= $this->form->label(t('Email'), 'email') ?>
<?= $this->form->email('email', $values, $errors) ?><br/>
- <?= $this->form->label(t('Default project'), 'default_project_id') ?>
- <?= $this->form->select('default_project_id', $projects, $values, $errors) ?><br/>
-
<?= $this->form->label(t('Timezone'), 'timezone') ?>
<?= $this->form->select('timezone', $timezones, $values, $errors) ?><br/>
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 @@
<th><?= $paginator->order(t('Email'), 'email') ?></th>
<th><?= $paginator->order(t('Administrator'), 'is_admin') ?></th>
<th><?= $paginator->order(t('Two factor authentication'), 'twofactor_activated') ?></th>
- <th><?= $paginator->order(t('Default project'), 'default_project_id') ?></th>
<th><?= $paginator->order(t('Notifications'), 'notifications_enabled') ?></th>
<th><?= t('External accounts') ?></th>
<th><?= $paginator->order(t('Account type'), 'is_ldap_user') ?></th>
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 @@
<?= $this->form->label(t('Confirmation'), 'confirmation') ?>
<?= $this->form->password('confirmation', $values, $errors, array('required')) ?><br/>
- <?= $this->form->label(t('Default project'), 'default_project_id') ?>
- <?= $this->form->select('default_project_id', $projects, $values, $errors) ?><br/>
-
<?= $this->form->label(t('Timezone'), 'timezone') ?>
<?= $this->form->select('timezone', $timezones, $values, $errors) ?><br/>
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 @@
<h2><?= t('Preferences') ?></h2>
</div>
<ul class="listing">
- <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->text->in($user['timezone'], $timezones) ?></strong></li>
<li><?= t('Language:') ?> <strong><?= $this->text->in($user['language'], $languages) ?></strong></li>
<li><?= t('Notifications:') ?> <strong><?= $user['notifications_enabled'] == 1 ? t('Enabled') : t('Disabled') ?></strong></li>
diff --git a/docs/api-json-rpc.markdown b/docs/api-json-rpc.markdown
index 0d192db3..e54c3a13 100644
--- a/docs/api-json-rpc.markdown
+++ b/docs/api-json-rpc.markdown
@@ -2367,7 +2367,6 @@ Response example:
- **name** (string, optional)
- **email** (string, optional)
- **is_admin** Set the value 1 for admins or 0 for regular users (integer, optional)
- - **default_project_id** (integer, optional)
- Result on success: **user_id**
- Result on failure: **false**
@@ -2402,7 +2401,6 @@ Response example:
- **username** (string, optional if email is set)
- **email** (string, optional if username is set)
- **is_admin** Set the value 1 for admins or 0 for regular users (integer, optional)
- - **default_project_id** (integer, optional)
- Result on success: **user_id**
- Result on failure: **false**
@@ -2464,7 +2462,6 @@ Response example:
"username": "biloute",
"password": "$2y$10$dRs6pPoBu935RpmsrhmbjevJH5MgZ7Kr9QrnVINwwyZ3.MOwqg.0m",
"is_admin": "0",
- "default_project_id": "0",
"is_ldap_user": "0",
"name": "",
"email": "",
@@ -2506,7 +2503,6 @@ Response example:
"name": "",
"email": "",
"is_admin": "0",
- "default_project_id": "0",
"is_ldap_user": "0",
"notifications_enabled": "0",
"google_id": null,
@@ -2526,7 +2522,6 @@ Response example:
- **name** (string, optional)
- **email** (string, optional)
- **is_admin** (integer, optional)
- - **default_project_id** (integer, optional)
- Result on success: **true**
- Result on failure: **false**
diff --git a/tests/units/UserSessionTest.php b/tests/units/UserSessionTest.php
index 45f1bfde..6a831183 100644
--- a/tests/units/UserSessionTest.php
+++ b/tests/units/UserSessionTest.php
@@ -29,17 +29,4 @@ class UserSessionTest extends Base
$s['user'] = array('is_admin' => true);
$this->assertTrue($us->isAdmin());
}
-
- public function testLastSeenProject()
- {
- $us = new UserSession($this->container);
-
- $this->assertEquals(0, $us->getLastSeenProjectId());
-
- $us->storeLastSeenProjectId(33);
- $this->assertEquals(33, $us->getLastSeenProjectId());
-
- $us->storeLastSeenProjectId(66);
- $this->assertEquals(66, $us->getLastSeenProjectId());
- }
}