From df02d76e56b7e4a60dca6b9ec15592eb40b45714 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 19 May 2020 08:06:42 +0200 Subject: [PATCH] add removal of task --- op/op.SchedulerTaskMgr.php | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/op/op.SchedulerTaskMgr.php b/op/op.SchedulerTaskMgr.php index 6e67f4e54..8b327b468 100644 --- a/op/op.SchedulerTaskMgr.php +++ b/op/op.SchedulerTaskMgr.php @@ -66,7 +66,7 @@ if ($action == "addtask") { /* {{{ */ add_log_line(".php&action=addtask&name=".$name); } /* }}} */ -// modify transmittal ---------------------------------------------------- +// modify task ---------------------------------------------------- else if ($action == "edittask") { /* {{{ */ /* Check if the form data comes for a trusted request */ @@ -104,5 +104,40 @@ else if ($action == "edittask") { /* {{{ */ add_log_line(".php&action=edittask&taskid=".$taskid); } /* }}} */ +// delete task ------------------------------------------------------------- +else if ($action == "removetask") { /* {{{ */ + header('Content-Type: application/json'); + + /* Check if the form data comes from a trusted request */ + if(!checkFormKey('removetask')) { + echo json_encode(array('success'=>false, 'message'=>getMLText("invalid_request_token"))); + exit; + } + + if (!isset($_POST["taskid"]) || !is_numeric($_POST["taskid"]) || intval($_POST["taskid"])<1) { + echo json_encode(array('success'=>false, 'message'=>getMLText("invalid_task"))); + exit; + } + + $taskid=$_POST["taskid"]; + $task = $scheduler->getTask($taskid); + + if (!is_object($task)) { + echo json_encode(array('success'=>false, 'message'=>getMLText("invalid_task"))); + exit; + } + + if (!$task->remove()) { + echo json_encode(array('success'=>false, 'message'=>getMLText("error_occured"))); + exit; + } + + add_log_line("?taskid=".$_POST["taskid"]."&action=removetask"); + + echo json_encode(array('success'=>true, 'message'=>getMLText("task_removed"))); + exit; +} /* }}} */ + + header("Location:../out/out.SchedulerTaskMgr.php");