00001 <?php
00002
00015
00016 import('classes.handler.Handler');
00017
00018 class AuthorDashboardHandler extends Handler {
00019
00023 function AuthorDashboardHandler() {
00024 parent::Handler();
00025 $this->addRoleAssignment($this->_getAssignmentRoles(), array('submission', 'readMonographEmail'));
00026 }
00027
00028
00029
00030
00031
00035 function authorize(&$request, $args, $roleAssignments) {
00036 import('classes.security.authorization.OmpAuthorDashboardAccessPolicy');
00037 $this->addPolicy(new OmpAuthorDashboardAccessPolicy($request, $args, $roleAssignments), true);
00038
00039 return parent::authorize($request, $args, $roleAssignments);
00040 }
00041
00042
00043
00044
00045
00051 function submission($args, &$request) {
00052
00053 $this->setupTemplate($request);
00054 $templateMgr =& TemplateManager::getManager();
00055 $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00056 $templateMgr->assign_by_ref('monograph', $monograph);
00057
00058
00059 import('controllers.modals.submissionMetadata.linkAction.AuthorViewMetadataLinkAction');
00060 $viewMetadataAction = new AuthorViewMetadataLinkAction($request, $monograph->getId());
00061 $templateMgr->assign('viewMetadataAction', $viewMetadataAction);
00062
00063
00064 import('classes.monograph.MonographFile');
00065
00066
00067 $fileStage = null;
00068 $currentStage = $monograph->getStageId();
00069 switch ($currentStage) {
00070 case WORKFLOW_STAGE_ID_SUBMISSION:
00071 $fileStage = MONOGRAPH_FILE_SUBMISSION;
00072 break;
00073 case WORKFLOW_STAGE_ID_INTERNAL_REVIEW:
00074 case WORKFLOW_STAGE_ID_EXTERNAL_REVIEW:
00075 $fileStage = MONOGRAPH_FILE_REVIEW_REVISION;
00076 break;
00077
00078 case WORKFLOW_STAGE_ID_EDITING:
00079 $fileStage = MONOGRAPH_FILE_FINAL;
00080 break;
00081 }
00082
00083 $reviewRoundDao =& DAORegistry::getDAO('ReviewRoundDAO');
00084 $internalReviewRounds =& $reviewRoundDao->getByMonographId($monograph->getId(), WORKFLOW_STAGE_ID_INTERNAL_REVIEW);
00085 $externalReviewRounds =& $reviewRoundDao->getByMonographId($monograph->getId(), WORKFLOW_STAGE_ID_EXTERNAL_REVIEW);
00086 $lastInternalReviewRound =& $reviewRoundDao->getLastReviewRoundByMonographId($monograph->getId(), WORKFLOW_STAGE_ID_INTERNAL_REVIEW);
00087 $lastExternalReviewRound =& $reviewRoundDao->getLastReviewRoundByMonographId($monograph->getId(), WORKFLOW_STAGE_ID_EXTERNAL_REVIEW);
00088 $lastInternalReviewRoundNumber = 0;
00089 $lastExternalReviewRoundNumber = 0;
00090 if ($lastInternalReviewRound) {
00091 $lastInternalReviewRoundNumber = $lastInternalReviewRound->getRound();
00092 }
00093 if ($lastExternalReviewRound) {
00094 $lastExternalReviewRoundNumber = $lastExternalReviewRound->getRound();
00095 }
00096 $lastReviewRoundNumber = array('internalReview' => $lastInternalReviewRoundNumber,
00097 'externalReview' => $lastExternalReviewRoundNumber);
00098 $templateMgr->assign_by_ref('internalReviewRounds', $internalReviewRounds);
00099 $templateMgr->assign_by_ref('externalReviewRounds', $externalReviewRounds);
00100 $templateMgr->assign('lastReviewRoundNumber', $lastReviewRoundNumber);
00101
00102
00103 $lastReviewRound =& $reviewRoundDao->getLastReviewRoundByMonographId($monograph->getId(), $currentStage);
00104
00105
00106 if ($fileStage && is_a($lastReviewRound, 'ReviewRound')) {
00107 import('controllers.api.file.linkAction.AddFileLinkAction');
00108 $uploadFileAction = new AddFileLinkAction(
00109 $request, $monograph->getId(), $currentStage,
00110 array(ROLE_ID_AUTHOR), $fileStage, null, null, $lastReviewRound->getId());
00111 $templateMgr->assign('uploadFileAction', $uploadFileAction);
00112 }
00113
00114
00115
00116
00117 $monographEmailLogDao =& DAORegistry::getDAO('MonographEmailLogDAO');
00118 $user =& $request->getUser();
00119
00120 if ($monograph->getStageId() >= WORKFLOW_STAGE_ID_EDITING) {
00121 $copyeditingEmails =& $monographEmailLogDao->getByEventType($monograph->getId(), MONOGRAPH_EMAIL_COPYEDIT_NOTIFY_AUTHOR, $user->getId());
00122 $templateMgr->assign_by_ref('copyeditingEmails', $copyeditingEmails);
00123 }
00124
00125
00126 if ($monograph->getStageId() == WORKFLOW_STAGE_ID_PRODUCTION) {
00127 $productionEmails =& $monographEmailLogDao->getByEventType($monograph->getId(), MONOGRAPH_EMAIL_PROOFREAD_NOTIFY_AUTHOR, $user->getId());
00128 $templateMgr->assign_by_ref('productionEmails', $productionEmails);
00129 }
00130
00131
00132 $monographAssocTypeAndIdArray = array(ASSOC_TYPE_MONOGRAPH, $monograph->getId());
00133 $notificationRequestOptions = array(
00134 NOTIFICATION_LEVEL_TASK => array(
00135 NOTIFICATION_TYPE_SIGNOFF_COPYEDIT => $monographAssocTypeAndIdArray,
00136 NOTIFICATION_TYPE_SIGNOFF_PROOF => $monographAssocTypeAndIdArray,
00137 NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS => $monographAssocTypeAndIdArray,
00138 NOTIFICATION_TYPE_PENDING_INTERNAL_REVISIONS => $monographAssocTypeAndIdArray),
00139 NOTIFICATION_LEVEL_NORMAL => array(
00140 NOTIFICATION_TYPE_EDITOR_DECISION_INTERNAL_REVIEW => $monographAssocTypeAndIdArray,
00141 NOTIFICATION_TYPE_EDITOR_DECISION_ACCEPT => $monographAssocTypeAndIdArray,
00142 NOTIFICATION_TYPE_EDITOR_DECISION_EXTERNAL_REVIEW => $monographAssocTypeAndIdArray,
00143 NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS => $monographAssocTypeAndIdArray,
00144 NOTIFICATION_TYPE_EDITOR_DECISION_RESUBMIT => $monographAssocTypeAndIdArray,
00145 NOTIFICATION_TYPE_EDITOR_DECISION_DECLINE => $monographAssocTypeAndIdArray,
00146 NOTIFICATION_TYPE_EDITOR_DECISION_SEND_TO_PRODUCTION => $monographAssocTypeAndIdArray),
00147 NOTIFICATION_LEVEL_TRIVIAL => array()
00148 );
00149 $templateMgr->assign('authorDashboardNotificationRequestOptions', $notificationRequestOptions);
00150
00151 $templateMgr->display('authorDashboard/authorDashboard.tpl');
00152 }
00153
00154
00161 function readMonographEmail($args, &$request) {
00162 $monographEmailLogDao =& DAORegistry::getDAO('MonographEmailLogDAO');
00163 $user =& $request->getUser();
00164 $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00165 $monographEmailId = $request->getUserVar('monographEmailId');
00166
00167 $monographEmailFactory =& $monographEmailLogDao->getByEventType($monograph->getId(), MONOGRAPH_EMAIL_EDITOR_NOTIFY_AUTHOR, $user->getId());
00168 while ($email =& $monographEmailFactory->next()) {
00169 if ($email->getId() == $monographEmailId) {
00170 $templateMgr =& TemplateManager::getManager();
00171 $templateMgr->assign_by_ref('monographEmail', $email);
00172 return $templateMgr->fetchJson('authorDashboard/monographEmail.tpl');
00173 }
00174 }
00175 }
00176
00177
00178
00179
00180
00184 function setupTemplate($request) {
00185 parent::setupTemplate();
00186 AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION, LOCALE_COMPONENT_OMP_SUBMISSION, LOCALE_COMPONENT_OMP_EDITOR, LOCALE_COMPONENT_PKP_GRID);
00187 }
00188
00193 function _getAssignmentRoles() {
00194 return array(ROLE_ID_AUTHOR);
00195 }
00196 }
00197
00198 ?>