/** * @brief Returns uploadname as link for geeky scan * @param $job_pk * @return uploadname **/ function getUploadNameForGeekyScan($job_pk) { $row = $this->showJobsDao->getDataForASingleJob($job_pk); if (empty($row["job_upload_fk"])) { return ''; } if (empty($row['jq_pk'])) { return _("Job history record is no longer available"); } /* get the upload filename */ $uploadFileName = htmlspecialchars($this->uploadDao->getUpload($row['job_upload_fk'])->getFilename()); if (empty($uploadFileName)) { /* upload has been deleted so try to get the job name from the original upload job record */ $jobName = $this->showJobsDao->getJobName($row["job_upload_fk"]); $uploadFileName = "Deleted " . $jobName; } $uploadtree_pk = -1; /* Find the uploadtree_pk for this upload so that it can be used in the browse link */ try { $uploadtree_pk = $this->uploadDao->getUploadParent($row['job_upload_fk']); } catch (Exception $e) { echo $e->getMessage(), "\n"; } /* upload file name link to browse */ $uploadNameLink = "<a title='Click to browse this upload' href='" . Traceback_uri() . "?mod=browse&upload=" . $row['job_upload_fk'] . "&item=" . $uploadtree_pk . "'>" . $uploadFileName . "</a>"; return $uploadNameLink; }
/** * @brief Returns geeky scan details about the jobqueue item * @param $job_pk * @return Return job and jobqueue record data in an html table. **/ protected function getGeekyScanDetailsForJob($job_pk) { $i = 0; $fields = array('jq_pk' => 'jq_pk', 'job_pk' => 'jq_job_fk', 'Job Name' => 'job_name', 'Agent Name' => 'jq_type', 'Priority' => 'job_priority', 'Args' => 'jq_args', 'jq_runonpfile' => 'jq_runonpfile', 'Queued' => 'job_queued', 'Started' => 'jq_starttime', 'Ended' => 'jq_endtime', 'Elapsed HH:MM:SS' => 'elapsed', 'Status' => 'jq_end_bits', 'Items processed' => 'jq_itemsprocessed', 'Submitter' => 'job_user_fk', 'Upload' => 'job_upload_fk', 'Log' => 'jq_log'); $uri = Traceback_uri() . "?mod=showjobs&upload="; $row = $this->showJobsDao->getDataForASingleJob($job_pk); $table = array(); foreach ($fields as $labelKey => $field) { $value = ""; $label = $labelKey; switch ($field) { case 'jq_itemsprocessed': $value = number_format($row[$field]); break; case 'jq_end_bits': $value = $this->jobqueueStatus($row); break; case 'jq_pk': if (!empty($row['job_upload_fk'])) { $value = "<a href='{$uri}" . $row['job_upload_fk'] . "'>" . htmlentities($row[$field]) . "</a>" . " (" . _("Click to view jobs for this upload") . ")"; } else { $uri2 = Traceback_uri() . "?mod=showjobs"; $back = "(" . _("Click to return to Show Jobs") . ")"; $value = "<a href='{$uri2}'>{$row[$field]} {$back}</a>"; } break; case 'job_upload_fk': if (!empty($row[$field])) { $browse = Traceback_uri() . "?mod=browse&upload=" . htmlentities($row[$field]); $value = "<a href='{$browse}'>" . htmlentities($row[$field]) . "</a>" . " (" . _("Click to browse upload") . ")"; } break; case 'jq_log': if (empty($row[$field]) || !file_exists($row[$field])) { break; } if (filesize($row[$field]) > self::MAX_LOG_OUTPUT) { $value = "<pre>" . file_get_contents($row[$field], false, null, -1, self::MAX_LOG_OUTPUT) . "</pre>" . '<a href="' . Traceback_uri() . '?mod=download&log=' . $row['jq_pk'] . '">...</a>'; } else { $value = "<pre>" . file_get_contents($row[$field]) . "</pre>"; } break; case 'job_user_fk': if (!empty($row[$field])) { $value = $this->userDao->getUserName($row[$field]); } break; case 'jq_args': $jq_args_temp = $row[$field]; $jq_args_show = $jq_args_temp; if (!empty($jq_args_temp)) { $pos = strpos($jq_args_temp, ' SVN '); if ($pos) { $jq_args_show = substr($jq_args_temp, 0, $pos + 4); } $pos = strpos($jq_args_temp, ' CVS '); if ($pos) { $jq_args_show = substr($jq_args_temp, 0, $pos + 4); } $pos = strpos($jq_args_temp, ' Git '); if ($pos) { $jq_args_show = substr($jq_args_temp, 0, $pos + 4); } $value = $jq_args_show; } break; default: if (array_key_exists($field, $row)) { $value = htmlentities($row[$field]); } break; } $table[] = array('DT_RowId' => $i++, '0' => $label, '1' => $value); } $tableData = array_values($table); return new JsonResponse(array('sEcho' => intval($_GET['sEcho']), 'aaData' => $tableData, 'iTotalRecords' => count($tableData), 'iTotalDisplayRecords' => count($tableData))); }