14 use Symfony\Component\HttpFoundation\JsonResponse;
16 define(
"TITLE_CHANGELICPROCPOST", _(
"Private: Change license file post"));
25 private $decisionSearch = array(
26 DecisionTypes::IRRELEVANT =>
"noLicenseKnown",
27 DecisionTypes::NON_FUNCTIONAL =>
"nonFunctional",
28 DecisionTypes::TO_BE_DISCUSSED =>
"toBeDiscussed",
29 DecisionTypes::IRRELEVANT =>
"irrelevant",
30 DecisionTypes::DO_NOT_USE =>
"doNotUse",
31 DecisionTypes::IDENTIFIED =>
"identified"
36 $this->Name =
"change-license-processPost";
37 $this->Title = TITLE_CHANGELICPROCPOST;
39 $this->OutputType =
'JSON';
40 $this->OutputToStdout = 1;
44 parent::__construct();
47 $this->clearingDao = $container->get(
'dao.clearing');
48 $this->uploadDao = $container->get(
'dao.upload');
63 $sql =
"SELECT bucketpool_fk from bucket_ars where upload_fk = $uploadId;";
66 $bucketpool_array = pg_fetch_all_columns($result, 0);
67 pg_free_result($result);
68 $buckets_dir = $SysConf[
'DIRECTORIES'][
'MODDIR'];
70 foreach ($bucketpool_array as $bucketpool) {
71 $command =
"$buckets_dir/buckets/agent/buckets -r -t ".escapeshellarg($uploadTreeId).
" -p $bucketpool";
82 if ($this->
State != PLUGIN_STATE_READY) {
85 $itemId = @$_POST[
'uploadTreeId'];
87 return $this->errorJson(
"Bad item id");
89 $itemArray = explode(
',', $itemId);
90 $userId = Auth::getUserId();
91 $groupId = Auth::getGroupId();
92 $isRemoval = strtolower(@$_POST[
'isRemoval']);
93 $isRemoval = $isRemoval ==
't' || $isRemoval ==
'true';
94 $decisionMark = @$_POST[
'decisionMark'];
95 $decisionMarkExists = array_search($decisionMark, $this->decisionSearch,
true);
97 if ( (!empty($decisionMark)) && $decisionMarkExists !==
false ) {
98 foreach ($itemArray as $uploadTreeId) {
99 $responseMsg = $this->doMarkDecisionTypes($uploadTreeId, $groupId,
100 $userId, $decisionMark, $isRemoval);
101 if (! empty($responseMsg)) {
105 return new JsonResponse(array(
'result'=>
'success'));
107 return $this->doEdit($userId, $groupId, $itemArray);
110 function doMarkDecisionTypes($itemId, $groupId, $userId, $decisionMark, $isRemoval)
112 $itemTableName = $this->uploadDao->getUploadtreeTableName($itemId);
114 $itemTreeBounds = $this->uploadDao->getItemTreeBounds($itemId, $itemTableName);
116 $errMsg = $this->clearingDao->deleteDecisionTypeFromDirectory($itemTreeBounds, $groupId, $userId, $decisionMark);
118 $errMsg = $this->clearingDao->markDirectoryAsDecisionType($itemTreeBounds, $groupId, $userId, $decisionMark);
123 function doEdit($userId, $groupId, $itemArray)
126 $removed = strtolower(@$_POST[
'removed']);
127 $removed = $removed ==
't' || $removed ==
'true';
129 $itemTreeBounds = $this->uploadDao->getItemTreeBounds($itemArray[0]);
130 $uploadId = $itemTreeBounds->getUploadId();
131 $upload = $this->uploadDao->getUpload($uploadId);
132 $uploadName = $upload->getFilename();
134 $jobId = JobAddJob($userId, $groupId, $uploadName, $uploadId);
135 foreach ($itemArray as $itemId) {
136 if (isset($licenses)) {
137 if (! is_array($licenses)) {
138 return $this->errorJson(
"bad license array");
140 foreach ($licenses as $licenseId) {
141 if (intval($licenseId) <= 0) {
142 return $this->errorJson(
"bad license");
145 $this->clearingDao->insertClearingEvent($itemId, $userId, $groupId,
146 $licenseId, $removed, ClearingEventTypes::USER, $reportInfo =
'',
147 $comment =
'', $acknowledgement =
'', $jobId);
155 $conflictStrategyId =
null;
157 $jq_pk =
$deciderPlugin->AgentAdd($jobId, $uploadId, $errorMsg, array(), $conflictStrategyId);
168 if (empty($errorMsg) && ($jq_pk>0)) {
169 return new JsonResponse(array(
"jqid" => $jq_pk));
171 return $this->errorJson($errorMsg, 500);
175 private function errorJson($msg, $code = 404)
177 return new JsonResponse(array(
"error" => $msg), $code);
182 $NewPlugin->Initialize();
This is the Plugin class. All plugins should:
Contains the constants and helpers for authentication of user.
__construct()
base constructor. Most plugins will just use this
Output()
Display the loaded menu and plugins.
ChangeBuckets()
change bucket accordingly when change license of one file
ReportCachePurgeAll()
Purge all records from the report cache.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
#define PLUGIN_DB_WRITE
Plugin requires write permission on DB.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN