diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2020-05-08 15:49:32 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2020-05-19 18:29:46 +0200 |
commit | 3085f3ca2c18387c867cac571aea463ca4dd27bd (patch) | |
tree | 0825f288dba099d8b1f5a5c193e28cab1a2eb809 /admin/WebConsole/includes/restfunctions.php | |
parent | b0ef87a38399820b38aaac62723cd70160c555e2 (diff) |
#942 schedule commands (web)
Diffstat (limited to 'admin/WebConsole/includes/restfunctions.php')
-rw-r--r-- | admin/WebConsole/includes/restfunctions.php | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php index 66af9d9f..6abe56e0 100644 --- a/admin/WebConsole/includes/restfunctions.php +++ b/admin/WebConsole/includes/restfunctions.php @@ -65,7 +65,7 @@ define('OG_REST_PARAM_DIFF_NAME', 'diff_name'); define('OG_REST_PARAM_METHOD', 'method'); define('OG_REST_PARAM_ECHO', 'echo'); define('OG_REST_PARAM_TASK', 'task'); -define('OG_REST_PARAM_TIME_PARAMS', 'time_params'); +define('OG_REST_PARAM_WHEN', 'when'); define('OG_REST_PARAM_YEARS', 'years'); define('OG_REST_PARAM_MONTHS', 'months'); define('OG_REST_PARAM_WEEKS', 'weeks'); @@ -75,6 +75,11 @@ define('OG_REST_PARAM_HOURS', 'hours'); define('OG_REST_PARAM_AM_PM', 'am_pm'); define('OG_REST_PARAM_MINUTES', 'minutes'); +define('TYPE_COMMAND', 1); +define('TYPE_TASK', 3); +define('OG_SCHEDULE_COMMAND', 'command'); +define('OG_SCHEDULE_TASK', 'task'); + $conf_file = parse_ini_file(__DIR__ . '/../../etc/ogAdmServer.cfg'); define('OG_REST_API_TOKEN', 'Authorization: ' . $conf_file['APITOKEN']); @@ -573,13 +578,24 @@ function run_task($task_id) { return common_request(OG_REST_CMD_RUN_TASK, POST, $data); } -function create_schedule($task_id, $name, $years, $months, $weeks, $week_days, - $days, $hours, $am_pm, $minutes) { +function create_schedule($task_id, $type, $name, $years, $months, $weeks, + $week_days, $days, $hours, $am_pm, $minutes) { + $type_string; + + switch ($type) { + case TYPE_COMMAND: + $type_string = OG_SCHEDULE_COMMAND; + 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, - OG_REST_PARAM_TIME_PARAMS => array ( + OG_REST_PARAM_WHEN => array ( OG_REST_PARAM_YEARS => intval($years), OG_REST_PARAM_MONTHS => intval($months), OG_REST_PARAM_WEEKS => intval($weeks), @@ -610,7 +626,7 @@ function update_schedule($schedule_id, $task_id, $name, $years, $months, $days, OG_REST_PARAM_ID => $schedule_id, OG_REST_PARAM_TASK => $task_id, OG_REST_PARAM_NAME => $name, - OG_REST_PARAM_TIME_PARAMS => array ( + OG_REST_PARAM_WHEN => array ( OG_REST_PARAM_YEARS => intval($years), OG_REST_PARAM_MONTHS => intval($months), OG_REST_PARAM_DAYS => intval($days), |