Remove column default_project_id for users because it's useless now
This commit is contained in:
parent
e6e286be83
commit
6c772de184
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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')),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
");
|
||||
|
||||
|
|
|
|||
|
|
@ -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/>
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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/>
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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**
|
||||
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue