"2.0", "method" => "getTagsByProject", "id" => get_id(), "params" => [KB_PROJECT] ]; } function remove_tag($tag_id) { return [ "jsonrpc" => "2.0", "method" => "removeTag", "id" => get_id(), "params" => [$tag_id] ]; } function create_tag($title, $color) { return [ "jsonrpc" => "2.0", "method" => "createTag", "id" => get_id(), "params" => [ "project_id" => KB_PROJECT, "tag" => $title, "color_id" => $color ] ]; } function create_task($title, $tag, $color, $date_due) { return [ "jsonrpc" => "2.0", "method" => "createTask", "id" => get_id(), "params" => [ "title" => $title, "project_id" => KB_PROJECT, "color_id" => $color, "column_id" => KB_TASK_COLUMN, "owner_id" => KB_USER, "creator_id" => KB_USER, "date_due" => $date_due, "category_id" => KB_TASK_CATEGORY, "swimlane_id" => KB_TASK_SWIMLANE, "priority" => 1, "tags" => [$tag] ] ]; } function move_task_position($task_id, $position) { return [ "jsonrpc" => "2.0", "method" => "moveTaskPosition", "id" => get_id(), "params" => [ "project_id" => KB_PROJECT, "task_id" => $task_id, "column_id" => KB_TASK_COLUMN, "position" => $position, "swimlane_id" => KB_TASK_SWIMLANE ] ]; } function create_subtask($task_id, $title) { return [ "jsonrpc" => "2.0", "method" => "createSubtask", "id" => get_id(), "params" => [ "task_id" => $task_id, "title" => $title, "user_id" => KB_USER, "status" => 0 ] ]; } function send_request($payload) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, KANBOARD_URL); curl_setopt($curl, CURLOPT_USERPWD, KANBOARD_USER.":".KANBOARD_TOKEN); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($payload)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FAILONERROR, true); $response = curl_exec($curl); curl_close($curl); return $response; } $now = new DateTime('now', new DateTimeZone('Europe/Berlin')); $id = time(); // --- tags --- \\ // define tag $tag_color = "blue"; // old tag to be removed $old_tag_date = new DateTime('now', new DateTimeZone('Europe/Berlin')); date_sub($old_tag_date, DateInterval::createFromDateString('4 week')); $old_tag = $old_tag_date->format('Y-W'); // new tag to be created $new_tag_date = new DateTime('now', new DateTimeZone('Europe/Berlin')); date_add($new_tag_date, DateInterval::createFromDateString('4 week')); $new_tag = $new_tag_date->format('Y-W'); // get existing tags $tags = json_decode(send_request(get_tags()))->result; // remove old tag, create new tag $new_tag_exists = FALSE; foreach ($tags as $tag) { if ($tag->name == $old_tag) { send_request(remove_tag($tag->id)); } if ($tag->name == $new_tag) { $new_tag_exists = TRUE; } } if ($new_tag_exists == FALSE) { send_request(create_tag($new_tag, $tag_color)); } // --- tasks --- \\ // define task and subtasks $task_title = "My Daily Task ".$now->format('d.m.Y'); $task_tag = $now->format('Y-W'); $task_color = "green"; $task_datedue = $now->format('Y-m-d')." 12:30"; $task_subtasks = array("First Subtask", "Second Subtask"); // create task $response = send_request(create_task($task_title, $task_tag, $task_color, $task_datedue)); $created_task_id = json_decode($response)->result; // move task to top & create subtasks if (is_int($created_task_id)) { send_request(move_task_position($created_task_id, 1)); foreach ($task_subtasks as $subtask_title) { send_request(create_subtask($created_task_id, $subtask_title)); } } ?>