diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Controller/TaskMailController.php | 1 | ||||
-rw-r--r-- | app/Model/ProjectGroupRoleModel.php | 8 | ||||
-rw-r--r-- | app/Model/ProjectPermissionModel.php | 18 | ||||
-rw-r--r-- | app/Model/ProjectUserRoleModel.php | 8 | ||||
-rw-r--r-- | app/Template/task_mail/create.php | 15 |
5 files changed, 47 insertions, 3 deletions
diff --git a/app/Controller/TaskMailController.php b/app/Controller/TaskMailController.php index e4906bcd..64b81f8f 100644 --- a/app/Controller/TaskMailController.php +++ b/app/Controller/TaskMailController.php @@ -20,6 +20,7 @@ class TaskMailController extends BaseController 'errors' => $errors, 'task' => $task, 'project' => $project, + 'members' => $this->projectPermissionModel->getMembersWithEmail($project['id']), ))); } diff --git a/app/Model/ProjectGroupRoleModel.php b/app/Model/ProjectGroupRoleModel.php index 2729d5a6..2b1973f5 100644 --- a/app/Model/ProjectGroupRoleModel.php +++ b/app/Model/ProjectGroupRoleModel.php @@ -85,7 +85,13 @@ class ProjectGroupRoleModel extends Base public function getUsers($project_id) { return $this->db->table(self::TABLE) - ->columns(UserModel::TABLE.'.id', UserModel::TABLE.'.username', UserModel::TABLE.'.name', self::TABLE.'.role') + ->columns( + UserModel::TABLE.'.id', + UserModel::TABLE.'.username', + UserModel::TABLE.'.name', + UserModel::TABLE.'.email', + self::TABLE.'.role' + ) ->join(GroupMemberModel::TABLE, 'group_id', 'group_id', self::TABLE) ->join(UserModel::TABLE, 'id', 'user_id', GroupMemberModel::TABLE) ->eq(self::TABLE.'.project_id', $project_id) diff --git a/app/Model/ProjectPermissionModel.php b/app/Model/ProjectPermissionModel.php index dabd406c..752913d7 100644 --- a/app/Model/ProjectPermissionModel.php +++ b/app/Model/ProjectPermissionModel.php @@ -93,6 +93,24 @@ class ProjectPermissionModel extends Base return $members; } + public function getMembers($project_id) + { + $userMembers = $this->projectUserRoleModel->getUsers($project_id); + $groupMembers = $this->projectGroupRoleModel->getUsers($project_id); + + $userMembers = array_column_index_unique($userMembers, 'username'); + $groupMembers = array_column_index_unique($groupMembers, 'username'); + return array_merge($userMembers, $groupMembers); + } + + public function getMembersWithEmail($project_id) + { + $members = $this->getMembers($project_id); + return array_filter($members, function (array $user) { + return ! empty($user['email']); + }); + } + /** * Return true if everybody is allowed for the project * diff --git a/app/Model/ProjectUserRoleModel.php b/app/Model/ProjectUserRoleModel.php index 76094431..a95cf5d9 100644 --- a/app/Model/ProjectUserRoleModel.php +++ b/app/Model/ProjectUserRoleModel.php @@ -98,7 +98,13 @@ class ProjectUserRoleModel extends Base public function getUsers($project_id) { return $this->db->table(self::TABLE) - ->columns(UserModel::TABLE.'.id', UserModel::TABLE.'.username', UserModel::TABLE.'.name', self::TABLE.'.role') + ->columns( + UserModel::TABLE.'.id', + UserModel::TABLE.'.username', + UserModel::TABLE.'.name', + UserModel::TABLE.'.email', + self::TABLE.'.role' + ) ->join(UserModel::TABLE, 'id', 'user_id') ->eq('project_id', $project_id) ->asc(UserModel::TABLE.'.username') diff --git a/app/Template/task_mail/create.php b/app/Template/task_mail/create.php index b3c84e5d..4df81a6b 100644 --- a/app/Template/task_mail/create.php +++ b/app/Template/task_mail/create.php @@ -1,12 +1,25 @@ <div class="page-header"> <h2><?= $this->text->e($task['title']) ?> > <?= t('Send by email') ?></h2> </div> -<form method="post" action="<?= $this->url->href('TaskMailController', 'send', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off"> +<form method="post" action="<?= $this->url->href('TaskMailController', 'send', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off" class="js-task-mail-form"> <?= $this->form->csrf() ?> <?= $this->form->label(t('Email'), 'email') ?> <?= $this->form->email('email', $values, $errors, array('autofocus', 'required', 'tabindex="1"')) ?> + <?php if (! empty($members)): ?> + <div class="dropdown"> + <a href="#" class="dropdown-menu dropdown-menu-link-icon"><i class="fa fa-address-card-o"></i><i class="fa fa-caret-down"></i></a> + <ul> + <?php foreach ($members as $member): ?> + <li data-email="<?= $this->text->e($member['email']) ?>" class="js-autocomplete-email"> + <?= $this->text->e($this->user->getFullname($member)) ?> + </li> + <?php endforeach ?> + </ul> + </div> + <?php endif ?> + <?= $this->form->label(t('Subject'), 'subject') ?> <?= $this->form->text('subject', $values, $errors, array('required', 'tabindex="2"')) ?> |