summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/includes
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2021-03-11 10:19:45 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-03-11 12:47:32 +0100
commitafbfe2ad7df10b3d90555dee1089030b6bfd25b5 (patch)
tree413aac79110e9505f808025d6be1aa3615d86bc3 /admin/WebConsole/includes
parent3a2feab4fc7e37f00cd2f24c822bf35a7a1305f9 (diff)
#1032 Use create_schedule_now for immediate logged commands
Avoid stale commands from being executed when given a time schedule that include past dates, ie. when they are manually scheduled. Use create_schedule_now for immediate execution commands (no manual schedule) that the user want to be logged (by automatic scheduling to the right moment they are processed). Fixes #1032 (https://opengnsys.es/trac/ticket/1032#comment:2)
Diffstat (limited to 'admin/WebConsole/includes')
-rw-r--r--admin/WebConsole/includes/restfunctions.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php
index b0ae084e..e7b1e1e6 100644
--- a/admin/WebConsole/includes/restfunctions.php
+++ b/admin/WebConsole/includes/restfunctions.php
@@ -619,6 +619,30 @@ function create_schedule($task_id, $type, $name, $years, $months, $weeks,
return common_request(OG_REST_CMD_CREATE_SCHEDULE, POST, $data);
}
+function create_schedule_now($task_id, $type, $name) {
+ $type_string;
+
+ switch ($type) {
+ case TYPE_COMMAND:
+ $type_string = OG_SCHEDULE_COMMAND;
+ break;
+ case TYPE_PROCEDURE:
+ $type_string = OG_SCHEDULE_PROCEDURE;
+ break;
+ case TYPE_TASK:
+ default:
+ $type_string = OG_SCHEDULE_TASK;
+ }
+
+ $data = array (
+ OG_REST_PARAM_TASK => $task_id,
+ OG_REST_PARAM_TYPE => $type_string,
+ OG_REST_PARAM_NAME => $name,
+ );
+
+ return common_request(OG_REST_CMD_CREATE_SCHEDULE, POST, $data);
+}
+
function delete_schedule($schedule_id) {
$data = array (