Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
PKPAuthorDashboardHandler.inc.php
1 <?php
2 
16 // Import base class
17 import('classes.handler.Handler');
18 
20 
25  parent::Handler();
26  $this->addRoleAssignment($this->_getAssignmentRoles(), array('submission', 'readSubmissionEmail'));
27  }
28 
29 
30  //
31  // Public handler operations
32  //
38  function submission($args, $request) {
39  // Pass the authorized submission on to the template.
40  $this->setupTemplate($request);
41  $templateMgr = TemplateManager::getManager($request);
42  $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
43  $templateMgr->assign('submission', $submission);
44 
45  // "View metadata" action.
46  import('lib.pkp.controllers.modals.submissionMetadata.linkAction.AuthorViewMetadataLinkAction');
47  $viewMetadataAction = new AuthorViewMetadataLinkAction($request, $submission->getId());
48  $templateMgr->assign('viewMetadataAction', $viewMetadataAction);
49 
50  // Import submission file to define file stages.
51  import('lib.pkp.classes.submission.SubmissionFile');
52 
53  // Workflow-stage specific "upload file" action.
54  $currentStage = $submission->getStageId();
55  $fileStage = $this->_fileStageFromWorkflowStage($currentStage);
56 
57  $templateMgr->assign('lastReviewRoundNumber', $this->_getLastReviewRoundNumbers($submission));
58 
59  $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
60  $externalReviewRounds = $reviewRoundDao->getBySubmissionId($submission->getId(), WORKFLOW_STAGE_ID_EXTERNAL_REVIEW);
61  $templateMgr->assign('externalReviewRounds', $externalReviewRounds);
62 
63  // Get the last review round.
64  $lastReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $currentStage);
65 
66  // Create and assign add file link action.
67  if ($fileStage && is_a($lastReviewRound, 'ReviewRound')) {
68  import('lib.pkp.controllers.api.file.linkAction.AddFileLinkAction');
69  $uploadFileAction = new AddFileLinkAction(
70  $request, $submission->getId(), $currentStage,
71  array(ROLE_ID_AUTHOR), null, $fileStage, null, null, $lastReviewRound->getId());
72  $templateMgr->assign('uploadFileAction', $uploadFileAction);
73  }
74 
75 
76  // If the submission is in or past the editorial stage,
77  // assign the editor's copyediting emails to the template
78  $submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
79  $user = $request->getUser();
80 
81  if ($submission->getStageId() >= WORKFLOW_STAGE_ID_EDITING) {
82  $copyeditingEmails = $submissionEmailLogDao->getByEventType($submission->getId(), SUBMISSION_EMAIL_COPYEDIT_NOTIFY_AUTHOR, $user->getId());
83  $templateMgr->assign('copyeditingEmails', $copyeditingEmails);
84  }
85 
86  // Same for production stage.
87  if ($submission->getStageId() == WORKFLOW_STAGE_ID_PRODUCTION) {
88  $productionEmails = $submissionEmailLogDao->getByEventType($submission->getId(), SUBMISSION_EMAIL_PROOFREAD_NOTIFY_AUTHOR, $user->getId());
89  $templateMgr->assign('productionEmails', $productionEmails);
90  }
91 
92  // Define the notification options.
93  $templateMgr->assign(
94  'authorDashboardNotificationRequestOptions',
95  $this->_getNotificationRequestOptions($submission)
96  );
97 
98  $templateMgr->display('authorDashboard/authorDashboard.tpl');
99  }
100 
101 
108  function readSubmissionEmail($args, $request) {
109  $submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
110  $user = $request->getUser();
111  $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
112  $submissionEmailId = $request->getUserVar('submissionEmailId');
113 
114  $submissionEmailFactory = $submissionEmailLogDao->getByEventType($submission->getId(), SUBMISSION_EMAIL_EDITOR_NOTIFY_AUTHOR, $user->getId());
115  while ($email = $submissionEmailFactory->next()) { // validate the email id for this user.
116  if ($email->getId() == $submissionEmailId) {
117  $templateMgr = TemplateManager::getManager($request);
118  $templateMgr->assign('submissionEmail', $email);
119  return $templateMgr->fetchJson('authorDashboard/submissionEmail.tpl');
120  }
121  }
122  }
123 
124 
125  //
126  // Protected helper methods
127  //
131  function setupTemplate($request) {
132  parent::setupTemplate($request);
134  LOCALE_COMPONENT_PKP_SUBMISSION,
135  LOCALE_COMPONENT_APP_SUBMISSION,
136  LOCALE_COMPONENT_APP_EDITOR,
137  LOCALE_COMPONENT_PKP_GRID
138  );
139  }
140 
145  protected function _getAssignmentRoles() {
146  return array(ROLE_ID_AUTHOR);
147  }
148 
155  protected function _fileStageFromWorkflowStage($currentStage) {
156  switch ($currentStage) {
157  case WORKFLOW_STAGE_ID_SUBMISSION:
158  return SUBMISSION_FILE_SUBMISSION;
159  case WORKFLOW_STAGE_ID_EXTERNAL_REVIEW:
160  return SUBMISSION_FILE_REVIEW_REVISION;
161  case WORKFLOW_STAGE_ID_EDITING:
162  return SUBMISSION_FILE_FINAL;
163  default:
164  return null;
165  }
166  }
167 
173  protected function _getLastReviewRoundNumbers($submission) {
174  $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
175  $lastExternalReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), WORKFLOW_STAGE_ID_EXTERNAL_REVIEW);
176  if ($lastExternalReviewRound) {
177  $lastExternalReviewRoundNumber = $lastExternalReviewRound->getRound();
178  } else {
179  $lastExternalReviewRoundNumber = 0;
180  }
181  return array(
182  'externalReview' => $lastExternalReviewRoundNumber
183  );
184  }
185 
191  protected function _getNotificationRequestOptions($submission) {
192  $submissionAssocTypeAndIdArray = array(ASSOC_TYPE_SUBMISSION, $submission->getId());
193  return array(
194  NOTIFICATION_LEVEL_TASK => array(
195  NOTIFICATION_TYPE_SIGNOFF_COPYEDIT => $submissionAssocTypeAndIdArray,
196  NOTIFICATION_TYPE_SIGNOFF_PROOF => $submissionAssocTypeAndIdArray,
197  NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS => $submissionAssocTypeAndIdArray),
198  NOTIFICATION_LEVEL_NORMAL => array(
199  NOTIFICATION_TYPE_EDITOR_DECISION_ACCEPT => $submissionAssocTypeAndIdArray,
200  NOTIFICATION_TYPE_EDITOR_DECISION_EXTERNAL_REVIEW => $submissionAssocTypeAndIdArray,
201  NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS => $submissionAssocTypeAndIdArray,
202  NOTIFICATION_TYPE_EDITOR_DECISION_RESUBMIT => $submissionAssocTypeAndIdArray,
203  NOTIFICATION_TYPE_EDITOR_DECISION_DECLINE => $submissionAssocTypeAndIdArray,
204  NOTIFICATION_TYPE_EDITOR_DECISION_SEND_TO_PRODUCTION => $submissionAssocTypeAndIdArray),
205  NOTIFICATION_LEVEL_TRIVIAL => array()
206  );
207  }
208 }
209 
210 ?>
static & getDAO($name, $dbconn=null)
An action to open the submission meta-data modal.
static requireComponents()
Handle requests for the author dashboard.
addRoleAssignment($roleIds, $operations)
Base request handler application class.
Definition: Handler.inc.php:20
An action to add a submission file.
& getAuthorizedContextObject($assocType)