diff options
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/ProjectPermissionModel.php | 24 | ||||
-rw-r--r-- | app/Model/UserMentionModel.php | 62 |
2 files changed, 20 insertions, 66 deletions
diff --git a/app/Model/ProjectPermissionModel.php b/app/Model/ProjectPermissionModel.php index 25b6a382..dabd406c 100644 --- a/app/Model/ProjectPermissionModel.php +++ b/app/Model/ProjectPermissionModel.php @@ -62,17 +62,33 @@ class ProjectPermissionModel extends Base ->withFilter(new ProjectUserRoleProjectFilter($project_id)) ->withFilter(new ProjectUserRoleUsernameFilter($input)) ->getQuery() - ->findAllByColumn('username'); + ->columns( + UserModel::TABLE.'.id', + UserModel::TABLE.'.username', + UserModel::TABLE.'.name', + UserModel::TABLE.'.email', + UserModel::TABLE.'.avatar_path' + ) + ->findAll(); $groupMembers = $this->projectGroupRoleQuery ->withFilter(new ProjectGroupRoleProjectFilter($project_id)) ->withFilter(new ProjectGroupRoleUsernameFilter($input)) ->getQuery() - ->findAllByColumn('username'); + ->columns( + UserModel::TABLE.'.id', + UserModel::TABLE.'.username', + UserModel::TABLE.'.name', + UserModel::TABLE.'.email', + UserModel::TABLE.'.avatar_path' + ) + ->findAll(); - $members = array_unique(array_merge($userMembers, $groupMembers)); + $userMembers = array_column_index_unique($userMembers, 'username'); + $groupMembers = array_column_index_unique($groupMembers, 'username'); + $members = array_merge($userMembers, $groupMembers); - sort($members); + ksort($members); return $members; } diff --git a/app/Model/UserMentionModel.php b/app/Model/UserMentionModel.php deleted file mode 100644 index cdb9949e..00000000 --- a/app/Model/UserMentionModel.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -namespace Kanboard\Model; - -use Kanboard\Core\Base; -use Kanboard\Event\GenericEvent; - -/** - * User Mention - * - * @package Kanboard\Model - * @author Frederic Guillot - */ -class UserMentionModel extends Base -{ - /** - * Get list of mentioned users - * - * @access public - * @param string $content - * @return array - */ - public function getMentionedUsers($content) - { - $users = array(); - - if (preg_match_all('/@([^\s]+)/', $content, $matches)) { - $users = $this->db->table(UserModel::TABLE) - ->columns('id', 'username', 'name', 'email', 'language') - ->eq('notifications_enabled', 1) - ->neq('id', $this->userSession->getId()) - ->in('username', array_unique($matches[1])) - ->findAll(); - } - - return $users; - } - - /** - * Fire events for user mentions - * - * @access public - * @param string $content - * @param string $eventName - * @param GenericEvent $event - */ - public function fireEvents($content, $eventName, GenericEvent $event) - { - if (empty($event['project_id'])) { - $event['project_id'] = $this->taskFinderModel->getProjectId($event['task_id']); - } - - $users = $this->getMentionedUsers($content); - - foreach ($users as $user) { - if ($this->projectPermissionModel->isMember($event['project_id'], $user['id'])) { - $event['mention'] = $user; - $this->dispatcher->dispatch($eventName, $event); - } - } - } -} |