diff options
author | Dzial Techniczny WMW Projekt s.c <techniczna@wmwprojekt.pl> | 2019-12-10 11:34:53 +0100 |
---|---|---|
committer | Dzial Techniczny WMW Projekt s.c <techniczna@wmwprojekt.pl> | 2019-12-10 11:34:53 +0100 |
commit | b8fa0246803dab40cf57d40b45984c53046f2d55 (patch) | |
tree | dc92b167c7542137c385614a1d558e57669a4339 /plugins/Group_assign/Action/EmailGroup.php | |
parent | 2a43146236fd8fb16f84398d85720ad84aa0a0b1 (diff) |
Plugins directory and local modifications
Diffstat (limited to 'plugins/Group_assign/Action/EmailGroup.php')
-rw-r--r-- | plugins/Group_assign/Action/EmailGroup.php | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/plugins/Group_assign/Action/EmailGroup.php b/plugins/Group_assign/Action/EmailGroup.php new file mode 100644 index 00000000..6d12bc73 --- /dev/null +++ b/plugins/Group_assign/Action/EmailGroup.php @@ -0,0 +1,80 @@ +<?php + +namespace Kanboard\Plugin\Group_assign\Action; + +use Kanboard\Model\TaskModel; +use Kanboard\Action\Base; + +class EmailGroup extends Base +{ + + public function getDescription() + { + return t('Send a task by email to assigned group members'); + } + + + public function getCompatibleEvents() + { + return array( + TaskModel::EVENT_MOVE_COLUMN, + TaskModel::EVENT_CLOSE, + TaskModel::EVENT_CREATE, + ); + } + + + public function getActionRequiredParameters() + { + return array( + 'column_id' => t('Column'), + 'subject' => t('Email subject'), + ); + } + + + public function getEventRequiredParameters() + { + return array( + 'task_id', + 'task' => array( + 'project_id', + 'column_id', + 'owner_id', + 'owner_gp', + ), + ); + } + + + public function doAction(array $data) + { + $groupmembers = $this->groupMemberModel->getMembers($data['task']['owner_gp']); + + if (! empty($groupmembers)) { + foreach ($groupmembers as $members) { + $user = $this->userModel->getById($members['id']); + if (! empty($user['email'])) { + $this->emailClient->send( + $user['email'], + $user['name'] ?: $user['username'], + $this->getParam('subject'), + $this->template->render('notification/task_create', array( + 'task' => $data['task'], + )) + ); + } + } + return true; + } + + return false; + } + + + + public function hasRequiredCondition(array $data) + { + return $data['task']['column_id'] == $this->getParam('column_id'); + } +} |