summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-08-16 17:53:07 -0700
committerFrédéric Guillot <fred@kanboard.net>2014-08-16 17:53:07 -0700
commit658123a2328867a87da59ca660a7044d99eea22c (patch)
treee9d278eeba1699b13823dc7b115dce56635d0823 /app/Model
parentdb3c006be80d6690892b11608619f9683824e21b (diff)
The fullname is displayed instead of the username if not empty
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/Comment.php6
-rw-r--r--app/Model/Project.php15
-rw-r--r--app/Model/SubTask.php2
-rw-r--r--app/Model/Task.php7
-rw-r--r--app/Model/User.php12
5 files changed, 34 insertions, 8 deletions
diff --git a/app/Model/Comment.php b/app/Model/Comment.php
index b849fc23..43c275bc 100644
--- a/app/Model/Comment.php
+++ b/app/Model/Comment.php
@@ -45,7 +45,8 @@ class Comment extends Base
self::TABLE.'.task_id',
self::TABLE.'.user_id',
self::TABLE.'.comment',
- User::TABLE.'.username'
+ User::TABLE.'.username',
+ User::TABLE.'.name'
)
->join(User::TABLE, 'id', 'user_id')
->orderBy(self::TABLE.'.date', 'ASC')
@@ -70,7 +71,8 @@ class Comment extends Base
self::TABLE.'.user_id',
self::TABLE.'.date',
self::TABLE.'.comment',
- User::TABLE.'.username'
+ User::TABLE.'.username',
+ User::TABLE.'.name'
)
->join(User::TABLE, 'id', 'user_id')
->eq(self::TABLE.'.id', $comment_id)
diff --git a/app/Model/Project.php b/app/Model/Project.php
index 9f53fdda..9ee54cbd 100644
--- a/app/Model/Project.php
+++ b/app/Model/Project.php
@@ -80,12 +80,23 @@ class Project extends Base
*/
public function getAllowedUsers($project_id)
{
- return $this->db
+ $users = $this->db
->table(self::TABLE_USERS)
->join(User::TABLE, 'id', 'user_id')
->eq('project_id', $project_id)
->asc('username')
- ->listing('user_id', 'username');
+ ->columns(User::TABLE.'.id', User::TABLE.'.username', User::TABLE.'.name')
+ ->findAll();
+
+ $result = array();
+
+ foreach ($users as $user) {
+ $result[$user['id']] = $user['name'] ?: $user['username'];
+ }
+
+ asort($result);
+
+ return $result;
}
/**
diff --git a/app/Model/SubTask.php b/app/Model/SubTask.php
index c7bab44b..9f2941c5 100644
--- a/app/Model/SubTask.php
+++ b/app/Model/SubTask.php
@@ -80,7 +80,7 @@ class SubTask extends Base
$status = $this->getStatusList();
$subtasks = $this->db->table(self::TABLE)
->eq('task_id', $task_id)
- ->columns(self::TABLE.'.*', User::TABLE.'.username')
+ ->columns(self::TABLE.'.*', User::TABLE.'.username', User::TABLE.'.name')
->join(User::TABLE, 'id', 'user_id')
->findAll();
diff --git a/app/Model/Task.php b/app/Model/Task.php
index 6647f041..0753c57d 100644
--- a/app/Model/Task.php
+++ b/app/Model/Task.php
@@ -125,7 +125,9 @@ class Task extends Base
projects.name AS project_name,
columns.title AS column_title,
users.username AS assignee_username,
- creators.username AS creator_username
+ users.name AS assignee_name,
+ creators.username AS creator_username,
+ creators.name AS creator_name
FROM tasks
LEFT JOIN users ON users.id = tasks.owner_id
LEFT JOIN users AS creators ON creators.id = tasks.creator_id
@@ -209,7 +211,8 @@ class Task extends Base
'tasks.is_active',
'tasks.score',
'tasks.category_id',
- 'users.username'
+ 'users.username AS assignee_username',
+ 'users.name AS assignee_name'
)
->join(User::TABLE, 'id', 'owner_id');
diff --git a/app/Model/User.php b/app/Model/User.php
index 5f6b8a3a..19ec0494 100644
--- a/app/Model/User.php
+++ b/app/Model/User.php
@@ -98,7 +98,17 @@ class User extends Base
*/
public function getList()
{
- return $this->db->table(self::TABLE)->asc('username')->listing('id', 'username');
+ $users = $this->db->table(self::TABLE)->columns('id', 'username', 'name')->findAll();
+
+ $result = array();
+
+ foreach ($users as $user) {
+ $result[$user['id']] = $user['name'] ?: $user['username'];
+ }
+
+ asort($result);
+
+ return $result;
}
/**