From 61e5ebd8ebd70eeb1eeed4a1ed75fbd1f4a586eb Mon Sep 17 00:00:00 2001 From: ramon Date: Mon, 30 Apr 2018 08:58:05 +0000 Subject: #839: Correción en API REST para RemotePC: permitir sesión ilimitada si parámetro {{{deadLine=0}}}. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://opengnsys.es/svn/branches/version1.1@5763 a21b9725-9963-47de-94b9-378ad31fedc9 --- admin/WebConsole/rest/remotepc.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'admin/WebConsole/rest/remotepc.php') diff --git a/admin/WebConsole/rest/remotepc.php b/admin/WebConsole/rest/remotepc.php index 98166391..39224636 100644 --- a/admin/WebConsole/rest/remotepc.php +++ b/admin/WebConsole/rest/remotepc.php @@ -340,7 +340,7 @@ EOD; /* * @brief Store session time (in sec). * @note Route: /ous/:ouid/labs/:labid/clients/:clntid/session, Method: POST - * @param int deadLine maximum time session (in seconds) + * @param int deadLine maximum session time, in seconds (0 for unlimited) * @warning Parameters will be stored in a new "remotepc" table. */ $app->post('/ous/:ouid/labs/:labid/clients/:clntid/session', 'validateApiKey', @@ -365,7 +365,7 @@ $app->post('/ous/:ouid/labs/:labid/clients/:clntid/session', 'validateApiKey', if (filter_var($deadLine, FILTER_VALIDATE_INT) === false) { throw new Exception("Deadline must be integer"); } - if ($deadLine <= 0) { + if ($deadLine < 0) { throw new Exception("Resource unavailable"); } } catch (Exception $e) { @@ -420,11 +420,12 @@ EOD; } # Add power off command at deadline time. $cmd->texto .= " ($clntid, NOW() + INTERVAL $deadLine SECOND, 'poweroff');"; - if ($cmd->Ejecutar()) { + if ($deadLine == 0 or $cmd->Ejecutar()) { // Confirm operation. + $cmd->texto = ""; $response = ""; jsonResponse(200, $response); - } else { + } else { // Error message. $response["message"] = "Database error"; jsonResponse(400, $response); @@ -434,7 +435,7 @@ EOD; $response["message"] = "Client is not reserved"; jsonResponse(400, $response); } - } else { + } else { // Error message. $response["message"] = "Client does not exist"; jsonResponse(404, $response); -- cgit v1.2.3-18-g5258