26 define(
"TITLE_CHANGELICPROCPOST", _(
"Private: Change license file post"));
35 function __construct()
37 $this->Name =
"change-license-processPost";
38 $this->Title = TITLE_CHANGELICPROCPOST;
40 $this->OutputType =
'JSON';
41 $this->OutputToStdout = 1;
45 parent::__construct();
48 $this->clearingDao = $container->get(
'dao.clearing');
49 $this->uploadDao = $container->get(
'dao.upload');
64 $sql =
"SELECT bucketpool_fk from bucket_ars where upload_fk = $uploadId;";
65 $result = pg_query($PG_CONN, $sql);
67 $bucketpool_array = pg_fetch_all_columns($result, 0);
68 pg_free_result($result);
69 $buckets_dir = $SysConf[
'DIRECTORIES'][
'MODDIR'];
71 foreach ($bucketpool_array as $bucketpool) {
72 $command =
"$buckets_dir/buckets/agent/buckets -r -t $uploadTreeId -p $bucketpool";
82 if ($this->
State != PLUGIN_STATE_READY) {
85 $itemId = @$_POST[
'uploadTreeId'];
87 return $this->errorJson(
"bad item id");
90 $userId = Auth::getUserId();
91 $groupId = Auth::getGroupId();
92 $decisionMark = @$_POST[
'decisionMark'];
93 if (! empty($decisionMark) && ($decisionMark ==
"irrelevant" || $decisionMark ==
"doNotUse") ) {
94 if (! is_array($itemId)) {
95 $responseMsg = $this->doMarkDecisionTypes($itemId, $groupId, $userId, $decisionMark);
97 foreach ($itemId as $uploadTreeId) {
98 $responseMsg = $this->doMarkDecisionTypes($uploadTreeId, $groupId,
99 $userId, $decisionMark);
100 if (! empty($responseMsg)) {
105 if (!empty($responseMsg)) {
108 return new JsonResponse(array(
'result'=>
'success'));
111 if (!empty($decisionMark) && ($decisionMark ==
"deleteIrrelevant" || $decisionMark ==
"deleteDoNotUse")) {
112 $itemTableName = $this->uploadDao->getUploadtreeTableName($itemId);
114 $itemTreeBounds = $this->uploadDao->getItemTreeBounds($itemId, $itemTableName);
115 $errMsg = $this->clearingDao->deleteDecisionTypeFromDirectory($itemTreeBounds, $groupId, $userId, $decisionMark);
116 if (empty($errMsg)) {
117 return new JsonResponse(array(
'result'=>
'success'));
119 return $this->errorJson($errMsg,$errMsg);
122 return $this->doEdit($userId,$groupId,$itemId);
125 function doMarkDecisionTypes($itemId, $groupId, $userId, $decisionMark)
127 $itemTableName = $this->uploadDao->getUploadtreeTableName($itemId);
129 $itemTreeBounds = $this->uploadDao->getItemTreeBounds($itemId,$itemTableName);
130 $errMsg = $this->clearingDao->markDirectoryAsDecisionType($itemTreeBounds, $groupId, $userId, $decisionMark);
134 function doEdit($userId,$groupId,$itemId)
137 $removed = $_POST[
'removed'] ===
't' || $_POST[
'removed'] ===
'true';
139 $itemTreeBounds = $this->uploadDao->getItemTreeBounds($itemId);
140 $uploadId = $itemTreeBounds->getUploadId();
141 $upload = $this->uploadDao->getUpload($uploadId);
142 $uploadName = $upload->getFilename();
144 $jobId = JobAddJob($userId, $groupId, $uploadName, $uploadId);
146 if (isset($licenses)) {
147 if (! is_array($licenses)) {
148 return $this->errorJson(
"bad license array");
150 foreach ($licenses as $licenseId) {
151 if (intval($licenseId) <= 0) {
152 return $this->errorJson(
"bad license");
155 $this->clearingDao->insertClearingEvent($itemId, $userId, $groupId, $licenseId, $removed,
156 ClearingEventTypes::USER, $reportInfo =
'', $comment =
'', $acknowledgement =
'', $jobId);
163 $conflictStrategyId = null;
165 $jq_pk =
$deciderPlugin->AgentAdd($jobId, $uploadId, $errorMsg, array(), $conflictStrategyId);
176 if (empty($errorMsg) && ($jq_pk>0)) {
177 return new JsonResponse(array(
"jqid" => $jq_pk));
179 return $this->errorJson($errorMsg, 500);
183 private function errorJson($msg, $code = 404)
185 return new JsonResponse(array(
"error" => $msg), $code);
190 $NewPlugin->Initialize();
ChangeBuckets()
change bucket accordingly when change license of one file
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.
ReportCachePurgeAll()
Purge all records from the report cache.
#define PLUGIN_DB_WRITE
Plugin requires write permission on DB.
This is the Plugin class. All plugins should:
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Output()
This function is called when user output is requested. This function is responsible for content...