diff options
Diffstat (limited to 'modules-available/rebootcontrol/pages')
-rw-r--r-- | modules-available/rebootcontrol/pages/exec.inc.php | 57 | ||||
-rw-r--r-- | modules-available/rebootcontrol/pages/task.inc.php | 4 |
2 files changed, 59 insertions, 2 deletions
diff --git a/modules-available/rebootcontrol/pages/exec.inc.php b/modules-available/rebootcontrol/pages/exec.inc.php new file mode 100644 index 00000000..58053072 --- /dev/null +++ b/modules-available/rebootcontrol/pages/exec.inc.php @@ -0,0 +1,57 @@ +<?php + +class SubPage +{ + + public static function doPreprocess() + { + $action = Request::post('action', false, 'string'); + if ($action === 'exec') { + self::execExec(); + } + } + + private static function execExec() + { + $id = Request::post('id', Request::REQUIRED, 'int'); + $machines = Session::get('exec-' . $id); + if (!is_array($machines)) { + Message::addError('unknown-exec-job', $id); + return; + } + $script = Request::post('script', Request::REQUIRED, 'string'); + $task = RebootControl::runScript($machines, $script); + if (Taskmanager::isTask($task)) { + Util::redirect("?do=rebootcontrol&show=task&what=task&taskid=" . $task["id"]); + } + } + + /* + * Render + */ + + public static function doRender() + { + $what = Request::get('what', 'list', 'string'); + if ($what === 'prepare') { + self::showPrepare(); + } + } + + private static function showPrepare() + { + $id = Request::get('id', Request::REQUIRED, 'int'); + $machines = Session::get('exec-' . $id); + if (!is_array($machines)) { + Message::addError('unknown-exec-job', $id); + return; + } + Render::addTemplate('exec-enter-command', ['clients' => $machines, 'id' => $id]); + } + + public static function doAjax() + { + + } + +}
\ No newline at end of file diff --git a/modules-available/rebootcontrol/pages/task.inc.php b/modules-available/rebootcontrol/pages/task.inc.php index e52eb981..691fd9e2 100644 --- a/modules-available/rebootcontrol/pages/task.inc.php +++ b/modules-available/rebootcontrol/pages/task.inc.php @@ -82,9 +82,9 @@ class SubPage // Output if ($type === RebootControl::TASK_REBOOTCTL) { - $job['clients'] = RebootQueries::getMachinesByUuid(ArrayUtil::flattenByKey($job['clients'], 'machineuuid')); + $job['clients'] = RebootUtils::getMachinesByUuid(ArrayUtil::flattenByKey($job['clients'], 'machineuuid')); } elseif ($type === RebootControl::TASK_EXEC) { - $details = RebootQueries::getMachinesByUuid(ArrayUtil::flattenByKey($job['clients'], 'machineuuid'), true); + $details = RebootUtils::getMachinesByUuid(ArrayUtil::flattenByKey($job['clients'], 'machineuuid'), true); foreach ($job['clients'] as &$client) { if (isset($client['machineuuid']) && isset($details[$client['machineuuid']])) { $client += $details[$client['machineuuid']]; |