21 define(
"TITLE_SHOWJOBS", _(
"Show Jobs"));
38 function __construct()
40 $this->Name =
"showjobs";
41 $this->Title = TITLE_SHOWJOBS;
43 $this->Dependency = array(
"browse");
47 $this->showJobsDao = $container->get(
'dao.show_jobs');
48 $this->uploadDao = $container->get(
'dao.upload');
49 $this->jobDao = $container->get(
'dao.job');
51 parent::__construct();
54 function RegisterMenus()
56 menu_insert(
"Main::Jobs::My Recent Jobs", $this->MenuOrder - 1, $this->Name,
64 menu_insert(
"Main::Jobs::All Recent Jobs", $this->MenuOrder - 2,
65 $URIpart .
'1', $this->MenuTarget);
71 $text = _(
"Show uploads from all users");
72 $URI = $URIpart .
"1";
74 $text = _(
"Show only your own uploads");
75 $URI = $URIpart .
"0";
90 $row = $this->showJobsDao->getDataForASingleJob($job_pk);
92 if (empty($row[
"job_upload_fk"])) {
96 if (empty($row[
'jq_pk'])) {
97 return _(
"Job history record is no longer available");
101 $uploadFileName = htmlspecialchars($this->uploadDao->getUpload($row[
'job_upload_fk'])->getFilename());
102 if (empty($uploadFileName)) {
104 $jobName = $this->showJobsDao->getJobName($row[
"job_upload_fk"]);
105 $uploadFileName =
"Deleted " . $jobName;
111 $uploadtree_pk = $this->uploadDao->getUploadParent($row[
'job_upload_fk']);
112 }
catch (Exception $e) {
113 echo $e->getMessage(),
"\n";
117 $uploadNameLink =
"<a title='Click to browse this upload' href='" .
Traceback_uri() .
"?mod=browse&upload=" . $row[
'job_upload_fk'] .
"&item=" . $uploadtree_pk .
"'>" . $uploadFileName .
"</a>";
118 return $uploadNameLink;
121 public function Output()
125 if (empty($uploadPk)) {
127 } elseif ($uploadPk > 0) {
128 if (! $this->uploadDao->isEditable($uploadPk, Auth::getGroupId())) {
129 $this->vars[
'message'] = _(
"Permission Denied");
133 $this->vars[
'uploadId']= $uploadPk;
138 if ($_SESSION[Auth::USER_LEVEL] >=
PLUGIN_DB_WRITE && !empty($action)) {
142 if (!($uploadPk === -1 &&
144 $this->jobDao->hasActionPermissionsOnJob($jq_pk, Auth::getUserId(), Auth::getGroupId()))) &&
145 !$this->uploadDao->isEditable($uploadPk, Auth::getGroupId())) {
146 $this->vars[
'message'] = _(
"Permission Denied to perform action");
148 $thisURL =
Traceback_uri() .
"?mod=" . $this->Name .
"&upload=$uploadPk";
154 $command =
"pause $jq_pk";
157 $this->vars[
'errorInfo'] = _(
"Unable to pause job.") .
" " . $response_from_scheduler . $error_info;
159 echo
"<script type=\"text/javascript\"> window.location.replace(\"$thisURL\"); </script>";
166 $command =
"restart $jq_pk";
169 $this->vars[
'errorInfo'] = _(
"Unable to restart job.") .
" " . $response_from_scheduler . $error_info;
171 echo
"<script type=\"text/javascript\"> window.location.replace(\"$thisURL\"); </script>";
178 $Msg =
"\"" . _(
"Killed by") .
" " . $_SESSION[Auth::USER_NAME] .
"\"";
179 $command =
"kill $jq_pk $Msg";
182 $this->vars[
'errorInfo'] = _(
"Unable to cancel job.") . $response_from_scheduler . $error_info;
184 echo
"<script type=\"text/javascript\"> window.location.replace(\"$thisURL\"); </script>";
191 $this->vars[
'jobId'] = $job;
195 if (! $allusersval) {
198 $this->vars[
'allusersval'] = $allusersval;
202 $this->vars[
'page'] = $page;
218 return $SysConf[
'SYSCONFIG'][
'ShowJobsAutoRefresh'];
221 public function getTemplateName()
225 return "ui-showjobs.html.twig";
227 return "ui-job-show.html.twig";
233 $NewPlugin->Initialize();
Traceback_uri()
Get the URI without query to this location.
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
getTimeToRefresh()
getTimeToRefresh() get the refresh time from DB. time in seconds to refresh the jobs.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
getUploadNameForGeekyScan($job_pk)
Returns uploadname as link for geeky scan.
fo_communicate_with_scheduler($input, &$output, &$error_msg)
Communicate with scheduler, send commands to the scheduler, then get the output.
#define PLUGIN_DB_WRITE
Plugin requires write permission on DB.
This is the Plugin class. All plugins should:
Traceback_parm_keep($List)
Create a new URI, keeping only these items.