diff options
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/Action.php | 1 | ||||
-rw-r--r-- | app/Model/Notification.php | 13 | ||||
-rw-r--r-- | app/Model/Task.php | 27 | ||||
-rw-r--r-- | app/Model/TaskHistory.php | 2 |
4 files changed, 32 insertions, 11 deletions
diff --git a/app/Model/Action.php b/app/Model/Action.php index ad995991..a318c5b0 100644 --- a/app/Model/Action.php +++ b/app/Model/Action.php @@ -64,6 +64,7 @@ class Action extends Base Task::EVENT_OPEN => t('Open a closed task'), Task::EVENT_CLOSE => t('Closing a task'), Task::EVENT_CREATE_UPDATE => t('Task creation or modification'), + Task::EVENT_ASSIGNEE_CHANGE => t('Task assignee change'), ); } diff --git a/app/Model/Notification.php b/app/Model/Notification.php index 0cb17076..89439f37 100644 --- a/app/Model/Notification.php +++ b/app/Model/Notification.php @@ -79,6 +79,9 @@ class Notification extends Base $this->event->attach(Task::EVENT_UPDATE, new TaskNotificationListener($this, 'notification_task_update')); $this->event->attach(Task::EVENT_CLOSE, new TaskNotificationListener($this, 'notification_task_close')); $this->event->attach(Task::EVENT_OPEN, new TaskNotificationListener($this, 'notification_task_open')); + $this->event->attach(Task::EVENT_MOVE_COLUMN, new TaskNotificationListener($this, 'notification_task_move_column')); + $this->event->attach(Task::EVENT_MOVE_POSITION, new TaskNotificationListener($this, 'notification_task_move_position')); + $this->event->attach(Task::EVENT_ASSIGNEE_CHANGE, new TaskNotificationListener($this, 'notification_task_assignee_change')); } /** @@ -97,7 +100,6 @@ class Notification extends Base $message = Swift_Message::newInstance() ->setSubject($this->getMailSubject($template, $data)) ->setFrom(array(MAIL_FROM => 'Kanboard')) - //->setTo(array($user['email'] => $user['name'])) ->setBody($this->getMailContent($template, $data), 'text/html'); foreach ($users as $user) { @@ -143,6 +145,15 @@ class Notification extends Base case 'notification_task_open': $subject = e('[%s][Task opened] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); break; + case 'notification_task_move_column': + $subject = e('[%s][Column Change] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + break; + case 'notification_task_move_position': + $subject = e('[%s][Position Change] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + break; + case 'notification_task_assignee_change': + $subject = e('[%s][Assignee Change] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + break; case 'notification_task_due': $subject = e('[%s][Due tasks]', $data['project']); break; diff --git a/app/Model/Task.php b/app/Model/Task.php index fcee67f7..ddeb8a2b 100644 --- a/app/Model/Task.php +++ b/app/Model/Task.php @@ -35,13 +35,14 @@ class Task extends Base * * @var string */ - const EVENT_MOVE_COLUMN = 'task.move.column'; - const EVENT_MOVE_POSITION = 'task.move.position'; - const EVENT_UPDATE = 'task.update'; - const EVENT_CREATE = 'task.create'; - const EVENT_CLOSE = 'task.close'; - const EVENT_OPEN = 'task.open'; - const EVENT_CREATE_UPDATE = 'task.create_update'; + const EVENT_MOVE_COLUMN = 'task.move.column'; + const EVENT_MOVE_POSITION = 'task.move.position'; + const EVENT_UPDATE = 'task.update'; + const EVENT_CREATE = 'task.create'; + const EVENT_CLOSE = 'task.close'; + const EVENT_OPEN = 'task.open'; + const EVENT_CREATE_UPDATE = 'task.create_update'; + const EVENT_ASSIGNEE_CHANGE = 'task.assignee_change'; /** * Get available colors @@ -437,9 +438,10 @@ class Task extends Base * * @access public * @param array $values Form values + * @param boolean $trigger_Events Trigger events * @return boolean */ - public function update(array $values) + public function update(array $values, $trigger_events = true) { // Fetch original task $original_task = $this->getById($values['id']); @@ -454,7 +456,9 @@ class Task extends Base $updated_task['date_modification'] = time(); unset($updated_task['id']); - if ($this->db->table(self::TABLE)->eq('id', $values['id'])->update($updated_task)) { + $result = $this->db->table(self::TABLE)->eq('id', $values['id'])->update($updated_task); + + if ($result && $trigger_events) { $this->triggerUpdateEvents($original_task, $updated_task); } @@ -472,7 +476,10 @@ class Task extends Base { $events = array(); - if (isset($updated_task['column_id']) && $original_task['column_id'] != $updated_task['column_id']) { + if (isset($updated_task['owner_id']) && $original_task['owner_id'] != $updated_task['owner_id']) { + $events[] = self::EVENT_ASSIGNEE_CHANGE; + } + else if (isset($updated_task['column_id']) && $original_task['column_id'] != $updated_task['column_id']) { $events[] = self::EVENT_MOVE_COLUMN; } else if (isset($updated_task['position']) && $original_task['position'] != $updated_task['position']) { diff --git a/app/Model/TaskHistory.php b/app/Model/TaskHistory.php index c81e3eb4..0615cba0 100644 --- a/app/Model/TaskHistory.php +++ b/app/Model/TaskHistory.php @@ -122,6 +122,7 @@ class TaskHistory extends BaseHistory public function getTitle(array $event) { $titles = array( + Task::EVENT_ASSIGNEE_CHANGE => t('%s change the assignee of the task #%d', $event['author'], $event['task_id']), Task::EVENT_UPDATE => t('%s updated the task #%d', $event['author'], $event['task_id']), Task::EVENT_CREATE => t('%s created the task #%d', $event['author'], $event['task_id']), Task::EVENT_CLOSE => t('%s closed the task #%d', $event['author'], $event['task_id']), @@ -141,6 +142,7 @@ class TaskHistory extends BaseHistory public function attachEvents() { $events = array( + Task::EVENT_ASSIGNEE_CHANGE, Task::EVENT_UPDATE, Task::EVENT_CREATE, Task::EVENT_CLOSE, |