30 const NAME =
"change-license-bulk";
38 function __construct()
40 parent::__construct(self::NAME, array(
41 self::TITLE => _(
"Private: schedule a bulk scan from post"),
46 $this->licenseDao = $this->
getObject(
'dao.license');
47 $this->uploadDao = $this->
getObject(
'dao.upload');
54 protected function handle(Request $request)
56 $uploadTreeId = intval($request->get(
'uploadTreeId'));
57 if ($uploadTreeId <= 0) {
58 return new JsonResponse(array(
"error" =>
'bad request'), JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
62 $jobQueueId = $this->getJobQueueId($uploadTreeId, $request);
63 }
catch (Exception $ex) {
64 $errorMsg = $ex->getMessage();
65 return new JsonResponse(array(
"error" => $errorMsg), JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
69 return new JsonResponse(array(
"jqid" => $jobQueueId));
78 private function getJobQueueId($uploadTreeId, Request $request)
80 $uploadEntry = $this->uploadDao->getUploadEntry($uploadTreeId);
81 $uploadId = intval($uploadEntry[
'upload_fk']);
82 $userId = Auth::getUserId();
83 $groupId = Auth::getGroupId();
85 if ($uploadId <= 0 || !$this->uploadDao->isAccessible($uploadId, $groupId)) {
86 throw new Exception(
'permission denied');
89 $bulkScope = $request->get(
'bulkScope');
92 $uploadTreeTable = $this->uploadDao->getUploadtreeTableName($uploadId);
93 $topBounds = $this->uploadDao->getParentItemBounds($uploadId, $uploadTreeTable);
94 $uploadTreeId = $topBounds->getItemId();
98 if (!
Isdir($uploadEntry[
'ufile_mode']) &&
101 $uploadTreeId = $uploadEntry[
'parent'] ?: $uploadTreeId;
106 throw new InvalidArgumentException(
'bad scope request');
109 $refText = $request->get(
'refText');
110 $actions = $request->get(
'bulkAction');
112 $licenseRemovals = array();
113 foreach ($actions as $licenseAction) {
114 $licenseRemovals[$licenseAction[
'licenseId']] = array(($licenseAction[
'action']==
'Remove'), $licenseAction[
'comment'], $licenseAction[
'reportinfo'], $licenseAction[
'acknowledgement']);
116 $bulkId = $this->licenseDao->insertBulkLicense($userId, $groupId, $uploadTreeId, $licenseRemovals, $refText);
119 throw new Exception(
'cannot insert bulk reference');
121 $upload = $this->uploadDao->getUpload($uploadId);
122 $uploadName = $upload->getFilename();
123 $job_pk = JobAddJob($userId, $groupId, $uploadName, $uploadId);
126 $dependecies = array(array(
'name' =>
'agent_monk_bulk',
'args' => $bulkId));
127 $conflictStrategyId = intval($request->get(
'forceDecision'));
129 $jqId =
$deciderPlugin->AgentAdd($job_pk, $uploadId, $errorMsg, $dependecies, $conflictStrategyId);
131 if (!empty($errorMsg)) {
132 throw new Exception(str_replace(
'<br>',
"\n", $errorMsg));
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
ReportCachePurgeAll()
Purge all records from the report cache.
fo_dbManager * dbManager
fo_dbManager object
#define PERM_WRITE
Read-Write permission.