task_save

Triggered when a new task or an edited existing task is saved.

Teamwork

Input (passed by reference)

$params['type'] string Task action type from the list: 'add', 'edit'.
$params['task'] array Task properties as an array with the following keys:
$params['task']['id'] int Task ID.
$params['task']['name'] string Task name.
$params['task']['create_contact_id'] int ID of the user who has added the task.
$params['task']['create_datetime'] datetime Task creation date and time.
$params['task']['update_datetime'] datetime Date and time of the most recent task update.
$params['task']['assigned_contact_id'] int|null Assigned user ID.
$params['task']['project_id'] int ID of the project to which the task belongs.
$params['task']['milestone_id'] int|null ID of the milestone to which the task belongs.
$params['task']['number'] int Task number within its project.
$params['task']['status_id'] int Task status ID.
$params['task']['priority'] int Priority value.
$params['task']['assign_log_id'] int ID of the latest task assignment log entry.
$params['task']['hidden_timestamp'] int|null Timestamp of the date and time until which the task was marked as hidden.
$params['task']['due_date'] date Deadline date.
$params['task']['comment_log_id'] date ID of the latest task comment adding log entry.
$params['task']['uuid'] string Global task identifier.
$params['task']['public_hash'] string|null Hash string used in the task’s public link URL.
$params['prev_task'] array Task properties before the saving as an array with the same keys as described for the 'task' array.
… your plugin code …

Output

Teamwork

Plugin code example

PHP

public function taskSave($params)
{
    if ($params['type'] == 'edit' && $params['task']['name'] != $params['prev_task']['name']) {
        waLog::log(
            sprintf_wp(
                'Task “%s” (#%d) renamed to “%s”.',
                $params['prev_task']['name'],
                $params['task']['id'],
                $params['task']['name']
            ),
            sprintf('tasks/plugins/%s/task_save.log', $this->id)
        );
    }
}