31 use Symfony\Component\HttpFoundation\RedirectResponse;
32 use Symfony\Component\HttpFoundation\Response;
34 define(
"TITLE_CLEARINGVIEW", _(
"Change concluded License "));
49 private $highlightDao;
51 private $highlightProcessor;
53 private $highlightRenderer;
55 private $clearingDecisionEventProcessor;
57 private $clearingDecisionFilter;
59 private $invalidParm =
false;
61 private $decisionTypes;
65 $this->Name =
"view-license";
66 $this->Title = TITLE_CLEARINGVIEW;
68 $this->Dependency = array(
"view");
71 parent::__construct();
74 $this->licenseDao = $container->get(
'dao.license');
75 $this->uploadDao = $container->get(
'dao.upload');
76 $this->clearingDao = $container->get(
'dao.clearing');
77 $this->agentsDao = $container->get(
'dao.agent');
78 $this->logger = $container->get(
"logger");
79 $this->highlightDao = $container->get(
"dao.highlight");
80 $this->highlightRenderer = $container->get(
"view.highlight_renderer");
81 $this->highlightProcessor = $container->get(
"view.highlight_processor");
83 $this->decisionTypes = $container->get(
'decision.types');
85 $this->clearingDecisionEventProcessor = $container->get(
86 'businessrules.clearing_decision_processor');
87 $this->clearingDecisionFilter = $container->get(
88 'businessrules.clearing_decision_filter');
103 $unmaskAgents = $selectedAgentId;
104 if (empty($selectedAgentId)) {
105 $scanJobProxy =
new ScanJobProxy($this->agentsDao,$uploadId);
106 $scanJobProxy->createAgentStatus(array_keys(AgentRef::AGENT_LIST));
107 $unmaskAgents = $scanJobProxy->getLatestSuccessfulAgentIds();
109 $highlightEntries = $this->highlightDao->getHighlightEntries($itemTreeBounds,
110 $licenseId, $unmaskAgents, $highlightId, $clearingId);
111 $groupId = Auth::getGroupId();
112 if (($selectedAgentId > 0) || ($clearingId > 0)) {
113 $this->highlightProcessor->addReferenceTexts($highlightEntries, $groupId);
115 $this->highlightProcessor->flattenHighlights($highlightEntries, array(
"K",
"K "));
117 return $highlightEntries;
120 public function execute()
123 if ($openOutput instanceof RedirectResponse) {
124 $response = $openOutput;
134 if ($this->
State != PLUGIN_STATE_READY) {
138 if (empty($uploadId)) {
143 if (empty($uploadTreeId)) {
144 $parent = $this->uploadDao->getUploadParent($uploadId);
145 if (!isset($parent)) {
146 $this->invalidParm =
true;
150 $item = $this->uploadDao->getNextItem($uploadId, $parent);
151 if ($item === UploadDao::NOT_FOUND) {
152 $this->invalidParm =
true;
155 $uploadTreeId = $item->getId();
156 return new RedirectResponse(
Traceback_uri() .
'?mod=' . $this->Name
160 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
161 $uploadEntry = $this->uploadDao->getUploadEntry($uploadTreeId, $uploadTreeTableName);
162 if (
Isdir($uploadEntry[
'ufile_mode']) ||
Iscontainer($uploadEntry[
'ufile_mode'])) {
163 $parent = $this->uploadDao->getUploadParent($uploadId);
164 if (!isset($parent)) {
165 $this->invalidParm =
true;
169 $item = $this->uploadDao->getNextItem($uploadId, $parent);
170 if ($item === UploadDao::NOT_FOUND) {
171 $this->invalidParm =
true;
174 $uploadTreeId = $item->getId();
175 return new RedirectResponse(
Traceback_uri() .
'?mod=' . $this->Name
179 return parent::OutputOpen();
188 if ($this->invalidParm) {
189 $this->vars[
'content'] =
'This upload contains no files!<br><a href="'
190 .
Traceback_uri() .
'?mod=browse">Go back to browse view</a>';
191 return $this->
render(
"include/base.html.twig");
195 if (empty($uploadId)) {
196 return new Response(
"", Response::HTTP_BAD_REQUEST);
199 if (empty($uploadTreeId)) {
200 return new Response(
"", Response::HTTP_BAD_REQUEST);
203 $userId = Auth::getUserId();
204 $groupId = Auth::getGroupId();
208 if (!empty($lastItem)) {
209 $currentUploadtreeId = $lastItem;
210 if ($lastItem == $uploadTreeId) {
211 $currentUploadtreeId = $uploadTreeId;
213 $this->
updateLastItem($userId, $groupId, $lastItem, $currentUploadtreeId);
216 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
217 $itemTreeBounds = $this->uploadDao->getItemTreeBounds($uploadTreeId, $uploadTreeTableName);
219 $this->vars[
'micromenu'] =
Dir2Browse(
'license', $uploadTreeId, NULL,
220 $showBox = 0,
"View", -1,
'',
'', $uploadTreeTableName);
224 $view = &$Plugins[plugin_find_id(
"view")];
231 if ($clearingId !==
null) {
233 }
else if ($highlightId !==
null) {
238 $this->vars[
'baseuri'] = $baseUri;
239 $this->vars[
'uri'] = $baseUri .
"?mod=" . $this->Name .
Traceback_parm_keep(array(
'upload',
'folder'));
240 $this->vars[
'bulkHistoryHighlightUri'] = $this->vars[
'uri'];
241 $this->vars[
'optionName'] =
"skipFile";
242 $this->vars[
'formName'] =
"uiClearingForm";
243 $this->vars[
'ajaxAction'] =
"setNextPrev";
245 $selectedAgentId, $highlightId, $clearingId, $uploadId);
247 $isSingleFile = !$itemTreeBounds->containsFiles();
248 $hasWritePermission = $this->uploadDao->isEditable($uploadId, $groupId);
250 $clearingDecisions =
null;
251 if ($isSingleFile || $hasWritePermission) {
252 $clearingDecisions = $this->clearingDao->getFileClearings($itemTreeBounds, $groupId,
false);
255 if ($isSingleFile && $hasWritePermission) {
256 $this->vars[
'bulkUri'] =
Traceback_uri() .
"?mod=popup-license";
257 $licenseArray = $this->licenseDao->getLicenseArray($groupId);
258 list($addedResults, $removedResults) = $this->clearingDecisionEventProcessor->getCurrentClearings($itemTreeBounds, $groupId, LicenseMap::CONCLUSION);
259 if (count($addedResults)+count($removedResults)>0) {
260 array_unshift($licenseArray, array(
'id'=>0,
'fullname'=>
'',
'shortname'=>
'------'));
263 foreach ($removedResults as $result) {
264 array_unshift($licenseArray, array(
'id'=>$result->getLicenseId() ,
'fullname'=>$result->getLicenseFullName() ,
'shortname'=>$result->getLicenseShortName()));
267 foreach ($addedResults as $result) {
268 array_unshift($licenseArray, array(
'id'=>$result->getLicenseId() ,
'fullname'=>$result->getLicenseFullName() ,
'shortname'=>$result->getLicenseShortName()));
270 $this->vars[
'licenseArray'] = $licenseArray;
271 } elseif ($isSingleFile) {
272 $this->vars[
'auditDenied'] =
true;
275 $selectedClearingType =
false;
276 $selectedClearingScope =
false;
277 if (!empty($clearingDecisions)) {
278 $selectedClearingType = $clearingDecisions[0]->getType();
279 $selectedClearingScope = $clearingDecisions[0]->getScope();
281 $bulkHistory = $this->clearingDao->getBulkHistory($itemTreeBounds, $groupId);
284 list($pageMenu, $textView) = $view->getView(NULL, $ModBack, 0,
"", $highlights,
false,
true);
286 $this->vars[
'uploadId'] = $uploadId;
287 $this->vars[
'itemId'] = $uploadTreeId;
288 $this->vars[
'pageMenu'] = $pageMenu;
289 $this->vars[
'textView'] = $textView;
290 $this->vars[
'legendData'] = $this->highlightRenderer->getLegendData($selectedAgentId || $clearingId);
291 $this->vars[
'clearingTypes'] = $this->decisionTypes->getMap();
292 $this->vars[
'selectedClearingType'] = $selectedClearingType;
293 $this->vars[
'selectedClearingScope'] = $selectedClearingScope;
294 $this->vars[
'tmpClearingType'] = $this->clearingDao->isDecisionCheck($uploadTreeId, $groupId, DecisionTypes::WIP);
295 $this->vars[
'bulkHistory'] = $bulkHistory;
298 array(UploadTreeProxy::OPT_SKIP_THESE =>
"noLicense",
299 UploadTreeProxy::OPT_GROUP_ID => $groupId),
300 $uploadTreeTableName,
301 'no_license_uploadtree' . $uploadId);
302 $filesOfInterest = $noLicenseUploadTreeView->count();
305 array(UploadTreeProxy::OPT_SKIP_THESE =>
"alreadyCleared",
306 UploadTreeProxy::OPT_GROUP_ID => $groupId),
307 $uploadTreeTableName,
308 'already_cleared_uploadtree' . $uploadId);
309 $filesToBeCleared = $nonClearedUploadTreeView->count();
311 $filesAlreadyCleared = $filesOfInterest - $filesToBeCleared;
312 $this->vars[
'message'] = _(
"Cleared").
": $filesAlreadyCleared/$filesOfInterest";
313 if ($filesOfInterest == 0) {
316 $percentage = ($filesAlreadyCleared / $filesOfInterest) * 100;
317 $percentage = ($percentage > 11) ? $percentage : 11;
319 $this->vars[
'progressBar'] =
"width:".$percentage.
"%";
321 return $this->
render(
"ui-clearing-view.html.twig");
329 $menuText=
"Licenses";
332 $tooltipText = _(
"Set the concluded licenses for this upload");
333 $this->microMenu->insert(array(MicroMenu::VIEW, MicroMenu::VIEW_META), $menuText, $menuPosition, $this->Name, $uri, $tooltipText );
336 menu_insert(
"Browse-Pfile::$menuText", 0, $this->Name, $tooltipText);
348 public function updateLastItem($userId, $groupId, $lastItem, $currentUploadtreeId)
352 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($lastItem);
353 $itemBounds = $this->uploadDao->getItemTreeBounds($lastItem, $uploadTreeTableName);
355 $isDecisionWip = $this->clearingDao->isDecisionCheck($currentUploadtreeId, $groupId, DecisionTypes::WIP);
356 $hasChangedClearingType = $this->clearingDao->isDecisionCheck($currentUploadtreeId, $groupId,
'');
357 if ($isDecisionWip) {
358 $this->clearingDecisionEventProcessor->makeDecisionFromLastEvents($itemBounds, $userId, $groupId, $type, $global);
359 }
else if (empty($hasChangedClearingType[
'scope'])
360 || ($hasChangedClearingType[
'decision_type'] != $type)
362 $this->clearingDecisionEventProcessor->makeDecisionFromLastEvents($itemBounds, $userId, $groupId, $type, $global);
367 $this->clearingDecisionEventProcessor->makeDecisionFromLastEvents($itemBounds, $userId, $groupId, $type, $global);
getSelectedHighlighting(ItemTreeBounds $itemTreeBounds, $licenseId, $selectedAgentId, $highlightId, $clearingId, $uploadId)
RegisterMenus()
While menus can be added to any time at or after the PostInitialize phase, this is the standard locat...
OutputOpen()
This function is called when user output is requested. This function is responsible for assigning hea...
updateLastItem($userId, $groupId, $lastItem, $currentUploadtreeId)
__construct()
base constructor. Most plugins will just use this
This is the Plugin class. All plugins should:
Output()
This function is called when user output is requested. This function is responsible for content....
render($templateName, $vars=null)
Contains the constants and helpers for authentication of user.
Various utility functions to filter ClearingDecision.
Utility functions to process ClearingDecision.
Wrapper class for license map.
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.
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.
#define PLUGIN_DB_WRITE
Plugin requires write permission on DB.