00001 <?php
00002
00015 import('lib.pkp.classes.controllers.listbuilder.ListbuilderHandler');
00016
00017 class ChapterAuthorListbuilderHandler extends ListbuilderHandler {
00019 var $_chapterId;
00020
00024 function ChapterAuthorListbuilderHandler() {
00025 parent::ListbuilderHandler();
00026 $this->addRoleAssignment(
00027 array(ROLE_ID_AUTHOR, ROLE_ID_SERIES_EDITOR, ROLE_ID_PRESS_MANAGER),
00028 array('fetch', 'fetchRow', 'fetchOptions', 'save')
00029 );
00030 }
00031
00032
00033
00034
00039 function getMonograph() {
00040 return $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00041 }
00042
00047 function setChapterId($chapterId) {
00048 $this->_chapterId = $chapterId;
00049 }
00050
00055 function getChapterId() {
00056 return $this->_chapterId;
00057 }
00058
00059
00060
00061
00068 function authorize(&$request, $args, $roleAssignments) {
00069 import('classes.security.authorization.OmpSubmissionAccessPolicy');
00070 $this->addPolicy(new OmpSubmissionAccessPolicy($request, $args, $roleAssignments));
00071 return parent::authorize($request, $args, $roleAssignments);
00072 }
00073
00074
00075
00076
00077
00078 function initialize(&$request) {
00079 parent::initialize($request);
00080
00081
00082 AppLocale::requireComponents(LOCALE_COMPONENT_OMP_SUBMISSION, LOCALE_COMPONENT_PKP_SUBMISSION);
00083
00084
00085 $this->setTitle('submission.submit.addAuthor');
00086 $this->setSourceType(LISTBUILDER_SOURCE_TYPE_SELECT);
00087 $this->setSaveType(LISTBUILDER_SAVE_TYPE_EXTERNAL);
00088 $this->setSaveFieldName('authors');
00089
00090
00091 $chapterDao =& DAORegistry::getDAO('ChapterDAO');
00092 $monograph =& $this->getMonograph();
00093 $chapter =& $chapterDao->getChapter(
00094 $request->getUserVar('chapterId'),
00095 $monograph->getId()
00096 );
00097 if ($chapter) {
00098
00099 $this->setChapterId($chapter->getId());
00100 } else {
00101
00102 $this->setChapterId(null);
00103 }
00104
00105
00106 $nameColumn = new ListbuilderGridColumn($this, 'name', 'common.name');
00107
00108 import('controllers.listbuilder.users.UserListbuilderGridCellProvider');
00109 $nameColumn->setCellProvider(new UserListbuilderGridCellProvider());
00110 $this->addColumn($nameColumn);
00111 }
00112
00116 function initFeatures($request, $args) {
00117 import('lib.pkp.classes.controllers.grid.feature.OrderListbuilderItemsFeature');
00118 return array(new OrderListbuilderItemsFeature());
00119 }
00120
00124 function getRequestArgs() {
00125 $monograph =& $this->getMonograph();
00126 return array(
00127 'monographId' => $monograph->getId(),
00128 'chapterId' => $this->getChapterId()
00129 );
00130 }
00131
00137 function getRowDataElement(&$request, $rowId) {
00138
00139 if ( !empty($rowId) ) {
00140 return parent::getRowDataElement($request, $rowId);
00141 }
00142 $id = 0;
00143
00144 $authorId = $this->getNewRowId($request);
00145 if (isset($authorId['name'])) {
00146 $id = (int) $authorId['name'];
00147 }
00148
00149 $authorDao =& DAORegistry::getDAO('AuthorDAO');
00150 $monograph =& $this->getMonograph();
00151 $author =& $authorDao->getAuthor($id, $monograph->getId());
00152 return $author;
00153 }
00154
00158 function getOptions() {
00159
00160 $items = array(
00161 array()
00162 );
00163
00164 $monograph =& $this->getMonograph();
00165 $authors =& $monograph->getAuthors();
00166
00167 foreach ($authors as $author) {
00168 $items[0][$author->getId()] = $author->getFullName();
00169 }
00170 unset($authors);
00171
00172 return $items;
00173 }
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 function loadData(&$request, $filter) {
00184 $monograph =& $this->getMonograph();
00185
00186
00187 if (!$this->getChapterId()) return array();
00188
00189
00190 $chapterAuthorDao =& DAORegistry::getDAO('ChapterAuthorDAO');
00191 $chapterAuthors =& $chapterAuthorDao->getAuthors($monograph->getId(), $this->getChapterId());
00192
00193 return $chapterAuthors;
00194 }
00195 }
00196
00197 ?>