10 define(
"TITLE_SHOWJOBS", _(
"Show Jobs"));
29 $this->Name =
"showjobs";
30 $this->Title = TITLE_SHOWJOBS;
32 $this->Dependency = array(
"browse");
36 $this->showJobsDao = $container->get(
'dao.show_jobs');
37 $this->uploadDao = $container->get(
'dao.upload');
38 $this->jobDao = $container->get(
'dao.job');
40 parent::__construct();
45 menu_insert(
"Main::Jobs::My Recent Jobs", $this->MenuOrder - 1, $this->Name,
48 if (array_key_exists(Auth::USER_LEVEL, $_SESSION) &&
54 menu_insert(
"Main::Jobs::All Recent Jobs", $this->MenuOrder - 2,
55 $URIpart .
'1', $this->MenuTarget);
67 $row = $this->showJobsDao->getDataForASingleJob($job_pk);
69 if (empty($row[
"job_upload_fk"])) {
73 if (empty($row[
'jq_pk'])) {
74 return _(
"Job history record is no longer available");
78 $uploadFileName = htmlspecialchars($this->uploadDao->getUpload($row[
'job_upload_fk'])->getFilename());
79 if (empty($uploadFileName)) {
81 $jobName = $this->showJobsDao->getJobName($row[
"job_upload_fk"]);
82 $uploadFileName =
"Deleted " . $jobName;
88 $uploadtree_pk = $this->uploadDao->getUploadParent($row[
'job_upload_fk']);
89 }
catch (Exception $e) {
90 echo $e->getMessage(),
"\n";
94 return "<a title='Click to browse this upload' href='" .
Traceback_uri() .
"?mod=browse&upload=" . $row[
'job_upload_fk'] .
"&item=" . $uploadtree_pk .
"'>" . $uploadFileName .
"</a>";
101 if (empty($uploadPk)) {
103 } elseif ($uploadPk > 0) {
104 if (! $this->uploadDao->isEditable($uploadPk, Auth::getGroupId())) {
105 $this->vars[
'message'] = _(
"Permission Denied");
109 $this->vars[
'uploadId']= $uploadPk;
114 if ($_SESSION[Auth::USER_LEVEL] >=
PLUGIN_DB_WRITE && !empty($action)) {
118 if (!($uploadPk === -1 &&
120 $this->jobDao->hasActionPermissionsOnJob($jq_pk, Auth::getUserId(), Auth::getGroupId()))) &&
121 !$this->uploadDao->isEditable($uploadPk, Auth::getGroupId())) {
122 $this->vars[
'message'] = _(
"Permission Denied to perform action");
124 $thisURL =
Traceback_uri() .
"?mod=" . $this->Name .
"&upload=$uploadPk";
130 $command =
"pause $jq_pk";
133 $this->vars[
'errorInfo'] = _(
"Unable to pause job.") .
" " . $response_from_scheduler . $error_info;
135 echo
"<script type=\"text/javascript\"> window.location.replace(\"$thisURL\"); </script>";
142 $command =
"restart $jq_pk";
145 $this->vars[
'errorInfo'] = _(
"Unable to restart job.") .
" " . $response_from_scheduler . $error_info;
147 echo
"<script type=\"text/javascript\"> window.location.replace(\"$thisURL\"); </script>";
154 $Msg =
"\"" . _(
"Killed by") .
" " . $_SESSION[Auth::USER_NAME] .
"\"";
155 $command =
"kill $jq_pk $Msg";
158 $this->vars[
'errorInfo'] = _(
"Unable to cancel job.") . $response_from_scheduler . $error_info;
160 echo
"<script type=\"text/javascript\"> window.location.replace(\"$thisURL\"); </script>";
167 $this->vars[
'jobId'] = $job;
171 if (! $allusersval) {
174 $this->vars[
'allusersval'] = $allusersval;
178 $this->vars[
'page'] = $page;
194 return $SysConf[
'SYSCONFIG'][
'ShowJobsAutoRefresh'];
197 public function getTemplateName()
201 return "ui-showjobs.html.twig";
203 return "ui-job-show.html.twig";
209 $NewPlugin->Initialize();
This is the Plugin class. All plugins should:
Contains the constants and helpers for authentication of user.
Output()
This function is called when user output is requested. This function is responsible for content....
RegisterMenus()
While menus can be added to any time at or after the PostInitialize phase, this is the standard locat...
getUploadNameForGeekyScan($job_pk)
Returns uploadname as link for geeky scan.
__construct()
base constructor. Most plugins will just use this
getTimeToRefresh()
getTimeToRefresh() get the refresh time from DB. @Returns time in seconds to refresh the jobs.
Traceback_uri()
Get the URI without query to this location.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
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.
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.