00001 <?php
00002
00015 import('lib.pkp.classes.controllers.listbuilder.ListbuilderHandler');
00016
00017 class FilesListbuilderHandler extends ListbuilderHandler {
00018
00020 var $_fileStage;
00021
00025 function FilesListbuilderHandler($fileStage) {
00026 parent::ListbuilderHandler();
00027
00028 $this->_fileStage = $fileStage;
00029
00030 $this->addRoleAssignment(
00031 array(ROLE_ID_SERIES_EDITOR, ROLE_ID_PRESS_MANAGER, ROLE_ID_PRESS_ASSISTANT),
00032 array('fetch', 'fetchRow', 'fetchOptions')
00033 );
00034 }
00035
00040 function getFileStage() {
00041 return $this->_fileStage;
00042 }
00043
00044
00045
00046
00047
00051 function authorize(&$request, &$args, $roleAssignments, $stageId) {
00052 import('classes.security.authorization.OmpWorkflowStageAccessPolicy');
00053 $this->addPolicy(new OmpWorkflowStageAccessPolicy($request, $args, $roleAssignments, 'monographId', $stageId), true);
00054 return parent::authorize($request, $args, $roleAssignments);
00055 }
00056
00061 function initialize(&$request) {
00062 parent::initialize($request);
00063
00064
00065 $this->setSourceType(LISTBUILDER_SOURCE_TYPE_SELECT);
00066 $this->setSaveType(LISTBUILDER_SAVE_TYPE_EXTERNAL);
00067 $this->setSaveFieldName('files');
00068
00069
00070 $itemColumn = new ListbuilderGridColumn($this, 'name', 'common.name');
00071 import('controllers.listbuilder.files.FileListbuilderGridCellProvider');
00072 $itemColumn->setCellProvider(new FileListbuilderGridCellProvider());
00073 $this->addColumn($itemColumn);
00074 }
00075
00076
00077
00078
00079
00080
00086 function getOptions($monographFiles) {
00087 $itemList = array();
00088 foreach ($monographFiles as $monographFile) {
00089 $itemList[$monographFile->getFileId()] = $monographFile->getFileLabel();
00090 }
00091 return array($itemList);
00092 }
00093
00094
00095
00096
00097
00101 function getRequestArgs() {
00102 $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00103 $args = parent::getRequestArgs();
00104 $args['monographId'] = $monograph->getId();
00105 return $args;
00106 }
00107
00111 function setupTemplate() {
00112 parent::setupTemplate();
00113
00114 AppLocale::requireComponents(LOCALE_COMPONENT_OMP_EDITOR, LOCALE_COMPONENT_PKP_SUBMISSION);
00115 }
00116
00122 function getRowDataElement(&$request, $rowId) {
00123
00124 if ( !empty($rowId) ) {
00125 return parent::getRowDataElement($request, $rowId);
00126 }
00127
00128
00129 $newRowId = $this->getNewRowId($request);
00130 $fileId = (int) $newRowId['name'];
00131 $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00132 $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
00133 import('classes.monograph.MonographFile');
00134 $monographFiles =& $submissionFileDao->getLatestRevisions($monograph->getId(), $this->getFileStage());
00135 foreach ($monographFiles as $monographFile) {
00136 if ($monographFile->getFileId() == $fileId) {
00137 return $monographFile;
00138 }
00139 }
00140 return null;
00141 }
00142 }
00143
00144 ?>