blob: 32a836087ab9dc7dc902b5311a7aae76af87889e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
<?php
namespace Kanboard\Formatter;
use Kanboard\Model\UserModel;
use Kanboard\Core\Filter\FormatterInterface;
/**
* Auto-complete formatter for user filter
*
* @package formatter
* @author Frederic Guillot
*/
class UserAutoCompleteFormatter extends BaseFormatter implements FormatterInterface
{
/**
* Format the tasks for the ajax auto-completion
*
* @access public
* @return array
*/
public function format()
{
$users = $this->query->columns(UserModel::TABLE.'.id', UserModel::TABLE.'.username', UserModel::TABLE.'.name')->findAll();
foreach ($users as &$user) {
$user['value'] = $user['username'].' (#'.$user['id'].')';
if (empty($user['name'])) {
$user['label'] = $user['username'];
} else {
$user['label'] = $user['name'].' ('.$user['username'].')';
}
}
return $users;
}
}
|