14 namespace Fossology\UnifiedReport\UI;
19 use Symfony\Component\HttpFoundation\Request;
27 const NAME =
'agent_founifiedreport';
29 function __construct()
31 parent::__construct(self::NAME, array(
32 self::TITLE => _(
"Unified Report generation"),
34 self::REQUIRES_LOGIN => TRUE
42 protected function handle(Request $request)
45 $uploadId = intval($request->get(
'upload'));
47 $upload = $this->getUpload($uploadId, $groupId);
48 }
catch(Exception $e) {
49 return $this->flushContent($e->getMessage());
54 if ($jobQueueId < 0) {
55 return $this->flushContent(_(
'Cannot schedule').
": $error");
58 $vars = array(
'jqPk' => $jobQueueId,
59 'downloadLink' =>
Traceback_uri().
"?mod=download&report=".$jobId,
60 'reportType' =>
"Unified");
61 $text = sprintf(_(
"Generating new report for '%s'"), $upload->getFilename());
62 $vars[
'content'] =
"<h2>".$text.
"</h2>";
63 $content = $this->renderer->load(
"report.html.twig")->render($vars);
64 $message =
'<h3 id="jobResult"></h3>';
65 $request->duplicate(array(
'injectedMessage'=>$message,
'injectedFoot'=>$content,
'mod'=>
'showjobs'))->overrideGlobals();
67 $showJobsPlugin->OutputOpen();
68 return $showJobsPlugin->getResponse();
78 protected function getUpload($uploadId, $groupId)
81 throw new Exception(_(
"parameter error"));
84 $uploadDao = $this->
getObject(
'dao.upload');
85 if (!$uploadDao->isAccessible($uploadId, $groupId)) {
86 throw new Exception(_(
"permission denied"));
89 $upload = $uploadDao->getUpload($uploadId);
90 if ($upload ===
null) {
91 throw new Exception(_(
'cannot find uploadId'));
102 $text = _(
"Generate Report");
103 menu_insert(
"Browse-Pfile::Export Unified Report", 0, self::NAME, $text);
115 $reportGenAgent =
plugin_find(
'agent_unifiedreport');
117 $uploadId = $upload->getId();
118 $jobId = JobAddJob($userId, $groupId, $upload->getFilename(), $uploadId);
121 $url = preg_replace(
"/api\/.*/i",
"", $url);
122 $jobQueueId = $reportGenAgent->AgentAdd($jobId, $uploadId, $error, array(), $url);
123 return array($jobId, $jobQueueId, $error);
127 register_plugin(
new FoUnifiedReportGenerator());
Contains the constants and helpers for authentication of user.
static getUserId()
Get the current user's id.
static getGroupId()
Get the current user's group id.
Unified report generator UI plugin.
const NAME
Plugin mod name.
scheduleAgent($groupId, $upload)
Traceback_uri()
Get the URI without query to this location.
tracebackTotalUri()
Get the total url without query.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
list_t type structure used to keep various lists. (e.g. there are multiple lists).