_noteId = $noteId; } // // Overridden public methods from FilesGridDataProvider // /** * @copydoc GridDataProvider::getAuthorizationPolicy() */ public function getAuthorizationPolicy($request, $args, $roleAssignments) { $this->setUploaderRoles($roleAssignments); return new QueryAccessPolicy($request, $args, $roleAssignments, $this->getStageId()); } /** * @copydoc FilesGridDataProvider::getSelectAction() */ public function getSelectAction($request) { $query = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_QUERY); return new SelectFilesLinkAction( $request, $this->getRequestArgs(), __('editor.submission.selectFiles') ); } /** * @copydoc GridDataProvider::loadData() */ public function loadData($filter = []) { // Retrieve all submission files for the given file query. $submission = $this->getSubmission(); $query = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_QUERY); $noteDao = DAORegistry::getDAO('NoteDAO'); /** @var NoteDAO $noteDao */ $note = $noteDao->getById($this->_noteId); if ($note->getAssocType() != Application::ASSOC_TYPE_QUERY || $note->getAssocId() != $query->getId()) { throw new Exception('Invalid note ID specified!'); } $submissionFiles = Repo::submissionFile() ->getCollector() ->filterByAssoc( Application::ASSOC_TYPE_NOTE, [$this->_noteId] )->filterBySubmissionIds([$submission->getId()]) ->filterByFileStages([(int) $this->getFileStage()]) ->getMany() ->toArray(); return $this->prepareSubmissionFileData($submissionFiles, $this->_viewableOnly, $filter); } /** * @copydoc GridDataProvider::getRequestArgs() */ public function getRequestArgs() { $query = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_QUERY); $representation = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_REPRESENTATION); return array_merge( parent::getRequestArgs(), [ 'assocType' => Application::ASSOC_TYPE_NOTE, 'assocId' => $this->_noteId, 'queryId' => $query->getId(), 'noteId' => $this->_noteId, 'representationId' => $representation ? $representation->getId() : null, ] ); } /** * @copydoc FilesGridDataProvider::getAddFileAction() */ public function getAddFileAction($request) { $submission = $this->getSubmission(); $query = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_QUERY); return new AddFileLinkAction( $request, $submission->getId(), $this->getStageId(), $this->getUploaderRoles(), $this->getFileStage(), Application::ASSOC_TYPE_NOTE, $this->_noteId, null, null, false, $query->getId() ); } }