00001 <?php
00002
00015 import('lib.pkp.classes.controllers.grid.GridRow');
00016
00017 class AuthorGridRow extends GridRow {
00019 var $_monograph;
00020
00022 var $_reaadOnly;
00023
00027 function AuthorGridRow(&$monograph, $readOnly = false) {
00028 $this->_monograph =& $monograph;
00029 $this->_readOnly = $readOnly;
00030 parent::GridRow();
00031 }
00032
00033
00034
00035
00040 function initialize(&$request) {
00041
00042 parent::initialize($request);
00043
00044
00045 $monograph =& $this->getMonograph();
00046
00047
00048 $rowId = $this->getId();
00049 if (!empty($rowId) && is_numeric($rowId)) {
00050
00051 $router =& $request->getRouter();
00052 $actionArgs = array(
00053 'monographId' => $monograph->getId(),
00054 'authorId' => $rowId
00055 );
00056
00057
00058 import('lib.pkp.classes.linkAction.request.AjaxModal');
00059 $this->addAction(
00060 new LinkAction(
00061 'editAuthor',
00062 new AjaxModal(
00063 $router->url($request, null, null, 'editAuthor', null, $actionArgs),
00064 __('grid.action.editContributor'),
00065 'modal_edit'
00066 ),
00067 __('grid.action.edit'),
00068 'edit'
00069 )
00070 );
00071
00072 import('lib.pkp.classes.linkAction.request.RemoteActionConfirmationModal');
00073 $this->addAction(
00074 new LinkAction(
00075 'deleteAuthor',
00076 new RemoteActionConfirmationModal(
00077 __('common.confirmDelete'),
00078 __('common.delete'),
00079 $router->url($request, null, null, 'deleteAuthor', null, $actionArgs),
00080 'modal_delete'
00081 ),
00082 __('grid.action.delete'),
00083 'delete'
00084 )
00085 );
00086
00087 $user =& $request->getUser();
00088 $stageAssignmentDao =& DAORegistry::getDAO('StageAssignmentDAO');
00089 $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
00090
00091 $allowedToCreateUser = false;
00092
00093 $stageAssignments =& $stageAssignmentDao->getBySubmissionAndStageId($monograph->getId(), $monograph->getStageId(), null, $user->getId());
00094 while ($stageAssignment =& $stageAssignments->next()) {
00095 $userGroup =& $userGroupDao->getById($stageAssignment->getUserGroupId());
00096 if (in_array($userGroup->getRoleId(), array(ROLE_ID_PRESS_MANAGER, ROLE_ID_SERIES_EDITOR, ROLE_ID_PRESS_ASSISTANT))) {
00097 $allowedToCreateUser = true;
00098 break;
00099 }
00100 }
00101
00102 if ($allowedToCreateUser) {
00103
00104 $authorDao =& DAORegistry::getDAO('AuthorDAO');
00105 $userDao =& DAORegistry::getDAO('UserDAO');
00106 $author =& $authorDao->getAuthor($rowId);
00107
00108 if ($author && !$userDao->userExistsByEmail($author->getEmail())) {
00109 $this->addAction(
00110 new LinkAction(
00111 'addUser',
00112 new AjaxModal(
00113 $router->url($request, null, null, 'addUser', null, $actionArgs),
00114 __('grid.user.add'),
00115 'modal_add_user',
00116 true
00117 ),
00118 __('grid.user.add'),
00119 'add_user')
00120 );
00121 }
00122 }
00123 }
00124 }
00125
00130 function &getMonograph() {
00131 return $this->_monograph;
00132 }
00133
00138 function isReadOnly() {
00139 return $this->_readOnly;
00140 }
00141 }
00142
00143 ?>