setCanAdd($capabilities & self::FILE_GRID_ADD); $this->setCanDownloadAll($capabilities & self::FILE_GRID_DOWNLOAD_ALL); $this->setCanDelete($capabilities & self::FILE_GRID_DELETE); $this->setCanViewNotes($capabilities & self::FILE_GRID_VIEW_NOTES); $this->setCanManage($capabilities & self::FILE_GRID_MANAGE); $this->setCanEdit($capabilities & self::FILE_GRID_EDIT); } // // Getters and Setters // /** * Does this grid allow the addition of files or revisions? * * @return bool */ public function canAdd() { return $this->_canAdd; } /** * Set whether or not the grid allows the addition of files or revisions. * * @param bool $canAdd */ public function setCanAdd($canAdd) { $this->_canAdd = (bool) $canAdd; } /** * Does this grid allow viewing of notes? * * @return bool */ public function canViewNotes() { return $this->_canViewNotes; } /** * Set whether this grid allows viewing of notes or not. */ public function setCanViewNotes($canViewNotes) { $this->_canViewNotes = $canViewNotes; } /** * Can the user download all files as an archive? * * @return bool */ public function canDownloadAll() { return $this->_canDownloadAll && FileArchive::isFunctional(); } /** * Set whether user can download all files as an archive or not. */ public function setCanDownloadAll($canDownloadAll) { $this->_canDownloadAll = $canDownloadAll; } /** * Can the user delete files from this grid? * * @return bool */ public function canDelete() { return $this->_canDelete; } /** * Set whether or not the user can delete files from this grid. * * @param bool $canDelete */ public function setCanDelete($canDelete) { $this->_canDelete = (bool) $canDelete; } /** * Whether the grid allows file management (select existing files to add to grid) * * @return bool */ public function canManage() { return $this->_canManage; } /** * Set whether the grid allows file management (select existing files to add to grid) */ public function setCanManage($canManage) { $this->_canManage = $canManage; } /** * Whether the grid allows file metadata editing * * @return bool */ public function canEdit() { return $this->_canEdit; } /** * Set whether the grid allows file metadata editing */ public function setCanEdit($canEdit) { $this->_canEdit = $canEdit; } /** * Get the download all link action. * * @param PKPRequest $request * @param array $files The files to be downloaded. * @param array $linkParams The link action request * parameters. * * @return ?LinkAction */ public function getDownloadAllAction($request, $files, $linkParams) { if (sizeof($files) > 0) { return new DownloadAllLinkAction($request, $linkParams); } else { return null; } } } if (!PKP_STRICT_MODE) { class_alias('\PKP\controllers\grid\files\FilesGridCapabilities', '\FilesGridCapabilities'); foreach ([ 'FILE_GRID_ADD', 'FILE_GRID_DOWNLOAD_ALL', 'FILE_GRID_DELETE', 'FILE_GRID_VIEW_NOTES', 'FILE_GRID_MANAGE', 'FILE_GRID_EDIT', ] as $constantName) { define($constantName, constant('\FilesGridCapabilities::' . $constantName)); } }