summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--app/Templates/board_task.php4
-rw-r--r--app/Templates/comment_show.php2
-rw-r--r--app/Templates/notification_comment_creation.php2
-rw-r--r--app/Templates/subtask_show.php2
-rw-r--r--app/Templates/task_show.php4
-rw-r--r--app/Templates/task_table.php4
-rw-r--r--app/Templates/user_remove.php2
-rw-r--r--app/helpers.php2
-rw-r--r--tests/functionals/ApiTest.php6
14 files changed, 48 insertions, 22 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;
}
/**
diff --git a/app/Templates/board_task.php b/app/Templates/board_task.php
index 61f7f5bf..0bc96579 100644
--- a/app/Templates/board_task.php
+++ b/app/Templates/board_task.php
@@ -4,7 +4,7 @@
<span class="task-board-user">
<?php if (! empty($task['owner_id'])): ?>
- <?= t('Assigned to %s', $task['username']) ?>
+ <?= t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) ?>
<?php else: ?>
<span class="task-board-nobody"><?= t('Nobody assigned') ?></span>
<?php endif ?>
@@ -24,7 +24,7 @@
<span class="task-board-user">
<?php if (! empty($task['owner_id'])): ?>
- <a class="assignee-popover" href="?controller=board&amp;action=assign&amp;task_id=<?= $task['id'] ?>" title="<?= t('Change assignee') ?>"><?= t('Assigned to %s', $task['username']) ?></a>
+ <a class="assignee-popover" href="?controller=board&amp;action=assign&amp;task_id=<?= $task['id'] ?>" title="<?= t('Change assignee') ?>"><?= t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) ?></a>
<?php else: ?>
<a class="assignee-popover" href="?controller=board&amp;action=assign&amp;task_id=<?= $task['id'] ?>" title="<?= t('Change assignee') ?>" class="task-board-nobody"><?= t('Nobody assigned') ?></a>
<?php endif ?>
diff --git a/app/Templates/comment_show.php b/app/Templates/comment_show.php
index d9d40d7e..08d77b29 100644
--- a/app/Templates/comment_show.php
+++ b/app/Templates/comment_show.php
@@ -1,7 +1,7 @@
<div class="comment <?= isset($preview) ? 'comment-preview' : '' ?>" id="comment-<?= $comment['id'] ?>">
<p class="comment-title">
- <span class="comment-username"><?= Helper\escape($comment['username']) ?></span> @ <span class="comment-date"><?= dt('%B %e, %Y at %k:%M %p', $comment['date']) ?></span>
+ <span class="comment-username"><?= Helper\escape($comment['name'] ?: $comment['username']) ?></span> @ <span class="comment-date"><?= dt('%B %e, %Y at %k:%M %p', $comment['date']) ?></span>
</p>
<div class="comment-inner">
diff --git a/app/Templates/notification_comment_creation.php b/app/Templates/notification_comment_creation.php
index ff286790..79d34f90 100644
--- a/app/Templates/notification_comment_creation.php
+++ b/app/Templates/notification_comment_creation.php
@@ -1,6 +1,6 @@
<h2><?= Helper\escape($task['title']) ?> (#<?= $task['id'] ?>)</h2>
-<h3><?= t('New comment posted by %s', $comment['username']) ?></h3>
+<h3><?= t('New comment posted by %s', $comment['name'] ?: $comment['username']) ?></h3>
<?= Helper\parse($comment['comment']) ?>
diff --git a/app/Templates/subtask_show.php b/app/Templates/subtask_show.php
index b9385c7e..968473af 100644
--- a/app/Templates/subtask_show.php
+++ b/app/Templates/subtask_show.php
@@ -24,7 +24,7 @@ $total_remaining = 0;
<td><?= Helper\escape($subtask['status_name']) ?></td>
<td>
<?php if (! empty($subtask['username'])): ?>
- <?= Helper\escape($subtask['username']) ?>
+ <?= Helper\escape($subtask['name'] ?: $subtask['username']) ?>
<?php endif ?>
</td>
<td>
diff --git a/app/Templates/task_show.php b/app/Templates/task_show.php
index a353d4d0..329fde80 100644
--- a/app/Templates/task_show.php
+++ b/app/Templates/task_show.php
@@ -24,13 +24,13 @@
<?php endif ?>
<?php if ($task['creator_username']): ?>
<li>
- <?= t('Created by %s', $task['creator_username']) ?>
+ <?= t('Created by %s', $task['creator_name'] ?: $task['creator_username']) ?>
</li>
<?php endif ?>
<li>
<strong>
<?php if ($task['assignee_username']): ?>
- <?= t('Assigned to %s', $task['assignee_username']) ?>
+ <?= t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) ?>
<?php else: ?>
<?= t('There is nobody assigned') ?>
<?php endif ?>
diff --git a/app/Templates/task_table.php b/app/Templates/task_table.php
index ad513452..d10d3f42 100644
--- a/app/Templates/task_table.php
+++ b/app/Templates/task_table.php
@@ -25,8 +25,8 @@
<a href="?controller=task&amp;action=show&amp;task_id=<?= $task['id'] ?>" title="<?= t('View this task') ?>"><?= Helper\escape($task['title']) ?></a>
</td>
<td>
- <?php if ($task['username']): ?>
- <?= Helper\escape($task['username']) ?>
+ <?php if ($task['assignee_username']): ?>
+ <?= Helper\escape($task['assignee_name'] ?: $task['assignee_username']) ?>
<?php else: ?>
<?= t('Unassigned') ?>
<?php endif ?>
diff --git a/app/Templates/user_remove.php b/app/Templates/user_remove.php
index 61d4163b..45774d27 100644
--- a/app/Templates/user_remove.php
+++ b/app/Templates/user_remove.php
@@ -4,7 +4,7 @@
</div>
<div class="confirm">
- <p class="alert alert-info"><?= t('Do you really want to remove this user: "%s"?', $user['username']) ?></p>
+ <p class="alert alert-info"><?= t('Do you really want to remove this user: "%s"?', $user['name'] ?: $user['username']) ?></p>
<div class="form-actions">
<a href="?controller=user&amp;action=remove&amp;user_id=<?= $user['id'].Helper\param_csrf() ?>" class="btn btn-red"><?= t('Yes') ?></a>
diff --git a/app/helpers.php b/app/helpers.php
index ec13c5ab..9a2b4cbf 100644
--- a/app/helpers.php
+++ b/app/helpers.php
@@ -37,7 +37,7 @@ function is_admin()
function get_username()
{
- return $_SESSION['user']['username'];
+ return $_SESSION['user']['name'] ?: $_SESSION['user']['username'];
}
function parse($text)
diff --git a/tests/functionals/ApiTest.php b/tests/functionals/ApiTest.php
index 8396be4f..6e23fd52 100644
--- a/tests/functionals/ApiTest.php
+++ b/tests/functionals/ApiTest.php
@@ -247,7 +247,7 @@ class Api extends PHPUnit_Framework_TestCase
{
$users = $this->client->getAllowedUsers(1);
$this->assertNotFalse($users);
- $this->assertEquals(array(1 => 'admin', 2 => 'titi'), $users);
+ $this->assertEquals(array(1 => 'admin', 2 => 'Titi'), $users);
}
public function testAllowedUser()
@@ -256,7 +256,7 @@ class Api extends PHPUnit_Framework_TestCase
$users = $this->client->getAllowedUsers(1);
$this->assertNotFalse($users);
- $this->assertEquals(array(2 => 'titi'), $users);
+ $this->assertEquals(array(2 => 'Titi'), $users);
}
public function testRevokeUser()
@@ -265,7 +265,7 @@ class Api extends PHPUnit_Framework_TestCase
$users = $this->client->getAllowedUsers(1);
$this->assertNotFalse($users);
- $this->assertEquals(array(1 => 'admin', 2 => 'titi'), $users);
+ $this->assertEquals(array(1 => 'admin', 2 => 'Titi'), $users);
}
public function testCreateComment()