45 define(
"TITLE_CLEARINGVIEW", _(
"Change concluded License "));
60 private $highlightDao;
62 private $highlightProcessor;
64 private $highlightRenderer;
66 private $clearingDecisionEventProcessor;
68 private $clearingDecisionFilter;
70 private $invalidParm =
false;
72 private $decisionTypes;
74 function __construct()
76 $this->Name =
"view-license";
77 $this->Title = TITLE_CLEARINGVIEW;
79 $this->Dependency = array(
"view");
82 parent::__construct();
85 $this->licenseDao = $container->get(
'dao.license');
86 $this->uploadDao = $container->get(
'dao.upload');
87 $this->clearingDao = $container->get(
'dao.clearing');
88 $this->agentsDao = $container->get(
'dao.agent');
89 $this->logger = $container->get(
"logger");
90 $this->highlightDao = $container->get(
"dao.highlight");
91 $this->highlightRenderer = $container->get(
"view.highlight_renderer");
92 $this->highlightProcessor = $container->get(
"view.highlight_processor");
94 $this->decisionTypes = $container->get(
'decision.types');
96 $this->clearingDecisionEventProcessor = $container->get(
97 'businessrules.clearing_decision_processor');
98 $this->clearingDecisionFilter = $container->get(
99 'businessrules.clearing_decision_filter');
114 $unmaskAgents = $selectedAgentId;
115 if (empty($selectedAgentId)) {
116 $scanJobProxy =
new ScanJobProxy($this->agentsDao,$uploadId);
117 $scanJobProxy->createAgentStatus(array_keys(AgentRef::AGENT_LIST));
118 $unmaskAgents = $scanJobProxy->getLatestSuccessfulAgentIds();
120 $highlightEntries = $this->highlightDao->getHighlightEntries($itemTreeBounds,
121 $licenseId, $unmaskAgents, $highlightId, $clearingId);
122 $groupId = Auth::getGroupId();
123 if (($selectedAgentId > 0) || ($clearingId > 0)) {
124 $this->highlightProcessor->addReferenceTexts($highlightEntries, $groupId);
126 $this->highlightProcessor->flattenHighlights($highlightEntries, array(
"K",
"K "));
128 return $highlightEntries;
131 public function execute()
133 $openOutput = $this->OutputOpen();
134 if ($openOutput instanceof RedirectResponse) {
135 $response = $openOutput;
143 function OutputOpen()
145 if ($this->
State != PLUGIN_STATE_READY) {
149 if (empty($uploadId)) {
154 if (empty($uploadTreeId)) {
155 $parent = $this->uploadDao->getUploadParent($uploadId);
156 if (!isset($parent)) {
157 $this->invalidParm =
true;
161 $item = $this->uploadDao->getNextItem($uploadId, $parent);
162 if ($item === UploadDao::NOT_FOUND) {
163 $this->invalidParm =
true;
166 $uploadTreeId = $item->getId();
167 return new RedirectResponse(
Traceback_uri() .
'?mod=' . $this->Name
171 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
172 $uploadEntry = $this->uploadDao->getUploadEntry($uploadTreeId, $uploadTreeTableName);
173 if (
Isdir($uploadEntry[
'ufile_mode']) ||
Iscontainer($uploadEntry[
'ufile_mode'])) {
174 $parent = $this->uploadDao->getUploadParent($uploadId);
175 if (!isset($parent)) {
176 $this->invalidParm =
true;
180 $item = $this->uploadDao->getNextItem($uploadId, $parent);
181 if ($item === UploadDao::NOT_FOUND) {
182 $this->invalidParm =
true;
185 $uploadTreeId = $item->getId();
186 return new RedirectResponse(
Traceback_uri() .
'?mod=' . $this->Name
190 return parent::OutputOpen();
199 if ($this->invalidParm) {
200 $this->vars[
'content'] =
'This upload contains no files!<br><a href="' 201 .
Traceback_uri() .
'?mod=browse">Go back to browse view</a>';
202 return $this->
render(
"include/base.html.twig");
206 if (empty($uploadId)) {
207 return new Response(
"", Response::HTTP_BAD_REQUEST);
210 if (empty($uploadTreeId)) {
211 return new Response(
"", Response::HTTP_BAD_REQUEST);
214 $userId = Auth::getUserId();
215 $groupId = Auth::getGroupId();
219 if (!empty($lastItem)) {
223 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
224 $itemTreeBounds = $this->uploadDao->getItemTreeBounds($uploadTreeId, $uploadTreeTableName);
226 $this->vars[
'micromenu'] =
Dir2Browse(
'license', $uploadTreeId, NULL,
227 $showBox = 0,
"View", -1,
'',
'', $uploadTreeTableName);
231 $view = &$Plugins[plugin_find_id(
"view")];
238 if ($clearingId !== null) {
240 }
else if ($highlightId !== null) {
245 $this->vars[
'baseuri'] = $baseUri;
246 $this->vars[
'uri'] = $baseUri .
"?mod=" . $this->Name .
Traceback_parm_keep(array(
'upload',
'folder'));
247 $this->vars[
'bulkHistoryHighlightUri'] = $this->vars[
'uri'];
248 $this->vars[
'optionName'] =
"skipFile";
249 $this->vars[
'formName'] =
"uiClearingForm";
250 $this->vars[
'ajaxAction'] =
"setNextPrev";
252 $selectedAgentId, $highlightId, $clearingId, $uploadId);
254 $isSingleFile = !$itemTreeBounds->containsFiles();
255 $hasWritePermission = $this->uploadDao->isEditable($uploadId, $groupId);
257 $clearingDecisions = null;
258 if ($isSingleFile || $hasWritePermission) {
259 $clearingDecisions = $this->clearingDao->getFileClearings($itemTreeBounds, $groupId,
false);
262 if ($isSingleFile && $hasWritePermission) {
263 $this->vars[
'bulkUri'] =
Traceback_uri() .
"?mod=popup-license";
264 $licenseArray = $this->licenseDao->getLicenseArray($groupId);
265 list($addedResults, $removedResults) = $this->clearingDecisionEventProcessor->getCurrentClearings($itemTreeBounds, $groupId, LicenseMap::CONCLUSION);
266 if (count($addedResults)+count($removedResults)>0) {
267 array_unshift($licenseArray, array(
'id'=>0,
'fullname'=>
'',
'shortname'=>
'------'));
270 foreach ($removedResults as $result) {
271 array_unshift($licenseArray, array(
'id'=>$result->getLicenseId() ,
'fullname'=>$result->getLicenseFullName() ,
'shortname'=>$result->getLicenseShortName()));
274 foreach ($addedResults as $result) {
275 array_unshift($licenseArray, array(
'id'=>$result->getLicenseId() ,
'fullname'=>$result->getLicenseFullName() ,
'shortname'=>$result->getLicenseShortName()));
277 $this->vars[
'licenseArray'] = $licenseArray;
278 } elseif ($isSingleFile) {
279 $this->vars[
'auditDenied'] =
true;
282 $selectedClearingType =
false;
283 $selectedClearingScope =
false;
284 if (!empty($clearingDecisions)) {
285 $selectedClearingType = $clearingDecisions[0]->getType();
286 $selectedClearingScope = $clearingDecisions[0]->getScope();
288 $bulkHistory = $this->clearingDao->getBulkHistory($itemTreeBounds, $groupId);
291 list($pageMenu, $textView) = $view->getView(NULL, $ModBack, 0,
"", $highlights,
false,
true);
293 $this->vars[
'uploadId'] = $uploadId;
294 $this->vars[
'itemId'] = $uploadTreeId;
295 $this->vars[
'pageMenu'] = $pageMenu;
296 $this->vars[
'textView'] = $textView;
297 $this->vars[
'legendData'] = $this->highlightRenderer->getLegendData($selectedAgentId || $clearingId);
298 $this->vars[
'clearingTypes'] = $this->decisionTypes->getMap();
299 $this->vars[
'selectedClearingType'] = $selectedClearingType;
300 $this->vars[
'selectedClearingScope'] = $selectedClearingScope;
301 $this->vars[
'tmpClearingType'] = $this->clearingDao->isDecisionWip($uploadTreeId, $groupId);
302 $this->vars[
'bulkHistory'] = $bulkHistory;
304 $filesOfInterest = $this->clearingDao->getTotalDecisionCount($uploadId,
306 $filesCleared = $this->clearingDao->getClearingDecisionsCount($uploadId,
309 $this->vars[
'message'] = _(
"Cleared").
": $filesCleared/$filesOfInterest";
311 return $this->
render(
"ui-clearing-view.html.twig");
317 function RegisterMenus()
319 $menuText=
"Licenses";
322 $tooltipText = _(
"Set the concluded licenses for this upload");
323 $this->microMenu->insert(array(MicroMenu::VIEW, MicroMenu::VIEW_META), $menuText, $menuPosition, $this->Name, $uri, $tooltipText );
326 menu_insert(
"Browse-Pfile::$menuText", 0, $this->Name, $tooltipText);
341 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($lastItem);
342 $itemBounds = $this->uploadDao->getItemTreeBounds($lastItem, $uploadTreeTableName);
343 $this->clearingDecisionEventProcessor->makeDecisionFromLastEvents($itemBounds, $userId, $groupId, $type, $global);
Dir2Browse($Mod, $UploadtreePk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText='', $PostText='', $uploadtree_tablename="uploadtree")
Get an html linked string of a file browse path.
Traceback_uri()
Get the URI without query to this location.
getSelectedHighlighting(ItemTreeBounds $itemTreeBounds, $licenseId, $selectedAgentId, $highlightId, $clearingId, $uploadId)
updateLastItem($userId, $groupId, $lastItem)
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
#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.
Output()
This function is called when user output is requested. This function is responsible for content...
render($templateName, $vars=null)