diff options
Diffstat (limited to 'app/User')
-rw-r--r-- | app/User/DatabaseBackendUserProvider.php | 43 | ||||
-rw-r--r-- | app/User/DatabaseUserProvider.php | 8 |
2 files changed, 47 insertions, 4 deletions
diff --git a/app/User/DatabaseBackendUserProvider.php b/app/User/DatabaseBackendUserProvider.php new file mode 100644 index 00000000..835d90be --- /dev/null +++ b/app/User/DatabaseBackendUserProvider.php @@ -0,0 +1,43 @@ +<?php + +namespace Kanboard\User; + +use Kanboard\Core\Base; +use Kanboard\Core\User\UserBackendProviderInterface; +use Kanboard\Filter\UserNameFilter; +use Kanboard\Model\UserModel; + +/** + * Database Backend User Provider + * + * @package Kanboard\User + * @author Frederic Guillot + */ +class DatabaseBackendUserProvider extends Base implements UserBackendProviderInterface +{ + /** + * Find a group from a search query + * + * @access public + * @param string $input + * @return DatabaseUserProvider[] + */ + public function find($input) + { + $result = array(); + + $users = $this->userQuery->withFilter(new UserNameFilter($input)) + ->getQuery() + ->columns(UserModel::TABLE.'.id', UserModel::TABLE.'.username', UserModel::TABLE.'.name') + ->eq(UserModel::TABLE.'.is_active', 1) + ->asc(UserModel::TABLE.'.name') + ->asc(UserModel::TABLE.'.username') + ->findAll(); + + foreach ($users as $user) { + $result[] = new DatabaseUserProvider($user); + } + + return $result; + } +} diff --git a/app/User/DatabaseUserProvider.php b/app/User/DatabaseUserProvider.php index fc626610..3b26aedb 100644 --- a/app/User/DatabaseUserProvider.php +++ b/app/User/DatabaseUserProvider.php @@ -83,7 +83,7 @@ class DatabaseUserProvider implements UserProviderInterface */ public function getRole() { - return ''; + return empty($this->user['role']) ? '' : $this->user['role']; } /** @@ -94,7 +94,7 @@ class DatabaseUserProvider implements UserProviderInterface */ public function getUsername() { - return ''; + return empty($this->user['username']) ? '' : $this->user['username']; } /** @@ -105,7 +105,7 @@ class DatabaseUserProvider implements UserProviderInterface */ public function getName() { - return ''; + return empty($this->user['name']) ? '' : $this->user['name']; } /** @@ -116,7 +116,7 @@ class DatabaseUserProvider implements UserProviderInterface */ public function getEmail() { - return ''; + return empty($this->user['email']) ? '' : $this->user['email']; } /** |