35 const NAME =
'agent_founifiedreport';
37 function __construct()
39 parent::__construct(self::NAME, array(
40 self::TITLE => _(
"Unified Report generation"),
42 self::REQUIRES_LOGIN => TRUE
50 protected function handle(Request $request)
52 $groupId = Auth::getGroupId();
53 $uploadId = intval($request->get(
'upload'));
55 $upload = $this->getUpload($uploadId, $groupId);
56 }
catch(Exception $e) {
57 return $this->flushContent($e->getMessage());
60 list($jobId, $jobQueueId, $error) = $this->
scheduleAgent($groupId, $upload);
62 if ($jobQueueId < 0) {
63 return $this->flushContent(_(
'Cannot schedule').
": $error");
66 $vars = array(
'jqPk' => $jobQueueId,
67 'downloadLink' =>
Traceback_uri().
"?mod=download&report=".$jobId,
68 'reportType' =>
"Unified");
69 $text = sprintf(_(
"Generating new report for '%s'"), $upload->getFilename());
70 $vars[
'content'] =
"<h2>".$text.
"</h2>";
71 $content = $this->renderer->loadTemplate(
"report.html.twig")->render($vars);
72 $message =
'<h3 id="jobResult"></h3>';
73 $request->duplicate(array(
'injectedMessage'=>$message,
'injectedFoot'=>$content,
'mod'=>
'showjobs'))->overrideGlobals();
75 $showJobsPlugin->OutputOpen();
76 return $showJobsPlugin->getResponse();
86 protected function getUpload($uploadId, $groupId)
89 throw new Exception(_(
"parameter error"));
92 $uploadDao = $this->
getObject(
'dao.upload');
93 if (!$uploadDao->isAccessible($uploadId, $groupId)) {
94 throw new Exception(_(
"permission denied"));
97 $upload = $uploadDao->getUpload($uploadId);
98 if ($upload === null) {
99 throw new Exception(_(
'cannot find uploadId'));
110 $text = _(
"Generate Report");
111 menu_insert(
"Browse-Pfile::Export Unified Report", 0, self::NAME, $text);
123 $reportGenAgent =
plugin_find(
'agent_unifiedreport');
124 $userId = Auth::getUserId();
125 $uploadId = $upload->getId();
126 $jobId = JobAddJob($userId, $groupId, $upload->getFilename(), $uploadId);
128 $jobQueueId = $reportGenAgent->AgentAdd($jobId, $uploadId, $error, array(),
tracebackTotalUri());
129 return array($jobId, $jobQueueId, $error);
Traceback_uri()
Get the URI without query to this location.
tracebackTotalUri()
Get the total url without query.
scheduleAgent($groupId, $upload)
const NAME
Plugin mod name.
Unified report generator UI plugin.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
#define PERM_WRITE
Read-Write permission.