Add more events and notifications for tasks
This commit is contained in:
@@ -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'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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']) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user