| <?php |
|
|
| namespace Kanboard\Action; |
|
|
| use Kanboard\Model\TaskModel; |
|
|
| |
| |
| |
| |
| |
| |
| class TaskEmailNoActivity extends Base |
| { |
| |
| |
| |
| |
| |
| |
| public function getDescription() |
| { |
| return t('Send email when there is no activity on a task'); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getCompatibleEvents() |
| { |
| return array( |
| TaskModel::EVENT_DAILY_CRONJOB, |
| ); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getActionRequiredParameters() |
| { |
| return array( |
| 'user_id' => t('User that will receive the email'), |
| 'subject' => t('Email subject'), |
| 'duration' => t('Duration in days'), |
| ); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getEventRequiredParameters() |
| { |
| return array('tasks'); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public function hasRequiredCondition(array $data) |
| { |
| return count($data['tasks']) > 0; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public function doAction(array $data) |
| { |
| $results = array(); |
| $max = $this->getParam('duration') * 86400; |
| $user = $this->userModel->getById($this->getParam('user_id')); |
|
|
| if (! empty($user['email'])) { |
| foreach ($data['tasks'] as $task) { |
| $duration = time() - $task['date_modification']; |
|
|
| if ($duration > $max) { |
| $results[] = $this->sendEmail($task['id'], $user); |
| } |
| } |
| } |
|
|
| return in_array(true, $results, true); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| private function sendEmail($task_id, array $user) |
| { |
| $task = $this->taskFinderModel->getDetails($task_id); |
|
|
| $this->emailClient->send( |
| $user['email'], |
| $user['name'] ?: $user['username'], |
| $this->getParam('subject'), |
| $this->template->render('notification/task_create', array('task' => $task)) |
| ); |
|
|
| return true; |
| } |
| } |
|
|