From f867d2bf6e0b9e5bd5442ba3c7ef6e78029a1693 Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Sat, 12 Dec 2015 13:52:56 +0100 Subject: [PATCH] baculum: Get job show result by job name or jobid --- gui/baculum/protected/Pages/API/JobShow.php | 17 +++++++++++++---- gui/baculum/protected/application.xml | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gui/baculum/protected/Pages/API/JobShow.php b/gui/baculum/protected/Pages/API/JobShow.php index fddd516c95..b378386f8b 100644 --- a/gui/baculum/protected/Pages/API/JobShow.php +++ b/gui/baculum/protected/Pages/API/JobShow.php @@ -22,10 +22,19 @@ class JobShow extends BaculumAPI { public function get() { - $jobid = intval($this->Request['id']); - $job = $this->getModule('job')->getJobById($jobid); - if(!is_null($job)) { - $jobShow = $this->getModule('bconsole')->bconsoleCommand($this->director, array('show', 'job="' . $job->name . '"'), $this->user); + $jobname = null; + + if (isset($this->Request['id'])) { + $jobid = intval($this->Request['id']); + $job = $this->getModule('job')->getJobById($jobid); + $jobname = property_exists($job, 'name') ? $job->name : null; + } elseif (isset($this->Request['name'])) { + $allowedJobs = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.jobs'), $this->user)->output; + $jobname = in_array($this->Request['name'], $allowedJobs) ? $this->Request['name'] : null; + } + + if(!is_null($jobname)) { + $jobShow = $this->getModule('bconsole')->bconsoleCommand($this->director, array('show', 'job="' . $jobname . '"'), $this->user); $this->output = $jobShow->output; $this->error = (integer)$jobShow->exitcode; } else { diff --git a/gui/baculum/protected/application.xml b/gui/baculum/protected/application.xml index 99e3f67717..ad0e839f0d 100644 --- a/gui/baculum/protected/application.xml +++ b/gui/baculum/protected/application.xml @@ -65,6 +65,7 @@ + -- 2.39.5