Open Journal Systems  3.3.0
PKPReviewRoundTabHandler.inc.php
1 <?php
2 
16 // Import the base Handler.
17 import('classes.handler.Handler');
18 import('lib.pkp.classes.core.JSONMessage');
19 
21 
22  //
23  // Extended methods from Handler
24  //
28  function authorize($request, &$args, $roleAssignments) {
29  // We need a review round id in request.
30  import('lib.pkp.classes.security.authorization.internal.ReviewRoundRequiredPolicy');
31  $this->addPolicy(new ReviewRoundRequiredPolicy($request, $args));
32 
33  return parent::authorize($request, $args, $roleAssignments);
34  }
35 
42  function externalReviewRound($args, $request) {
43  return $this->_reviewRound($args, $request);
44  }
45 
46 
50  function setupTemplate($request) {
51  AppLocale::requireComponents(LOCALE_COMPONENT_APP_EDITOR);
52  parent::setupTemplate($request);
53  }
54 
55 
56  //
57  // Protected helper methods.
58  //
65  protected function _reviewRound($args, $request) {
66  $this->setupTemplate($request);
67 
68  // Retrieve the authorized submission, stage id and review round.
69  $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
70  $stageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
71  $reviewRound = $this->getAuthorizedContextObject(ASSOC_TYPE_REVIEW_ROUND);
72 
73  // Is this round the most recent round?
74  $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /* @var $reviewRoundDao ReviewRoundDAO */
75  $lastReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $stageId);
76 
77  // Add the round information to the template.
78  $templateMgr = TemplateManager::getManager($request);
79  $templateMgr->assign('stageId', $stageId);
80  $templateMgr->assign('reviewRoundId', $reviewRound->getId());
81  $templateMgr->assign('isLastReviewRound', $reviewRound->getId() == $lastReviewRound->getId());
82  $templateMgr->assign('submission', $submission);
83 
84  // Assign editor decision actions to the template, only if
85  // user is accessing the last review round for this stage.
86  $notificationRequestOptions = array(
87  NOTIFICATION_LEVEL_NORMAL => array(
88  NOTIFICATION_TYPE_REVIEW_ROUND_STATUS => array(ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId())),
89  NOTIFICATION_LEVEL_TRIVIAL => array(),
90  );
91  $templateMgr->assign('reviewRoundNotificationRequestOptions', $notificationRequestOptions);
92 
93  // If a user is also assigned as an author to this submission, they
94  // shouldn't see any editorial actions
95  $userAccessibleStages = $this->getAuthorizedContextObject(ASSOC_TYPE_ACCESSIBLE_WORKFLOW_STAGES);
96  foreach ($userAccessibleStages as $accessibleStageId => $roles) {
97  if (in_array(ROLE_ID_AUTHOR, $roles)) {
98  $templateMgr->assign('isAssignedAsAuthor', true);
99  break;
100  }
101  }
102 
103  return $templateMgr->fetchJson('workflow/reviewRound.tpl');
104  }
105 }
106 
107 
PKPReviewRoundTabHandler
Definition: PKPReviewRoundTabHandler.inc.php:20
AppLocale\requireComponents
static requireComponents()
Definition: env1/MockAppLocale.inc.php:56
PKPReviewRoundTabHandler\externalReviewRound
externalReviewRound($args, $request)
Definition: PKPReviewRoundTabHandler.inc.php:42
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57
PKPReviewRoundTabHandler\_reviewRound
_reviewRound($args, $request)
Definition: PKPReviewRoundTabHandler.inc.php:65
PKPReviewRoundTabHandler\authorize
authorize($request, &$args, $roleAssignments)
Definition: PKPReviewRoundTabHandler.inc.php:28
ReviewRoundRequiredPolicy
Policy that ensures that the request contains a valid review round.
Definition: ReviewRoundRequiredPolicy.inc.php:17
PKPReviewRoundTabHandler\setupTemplate
setupTemplate($request)
Definition: PKPReviewRoundTabHandler.inc.php:50
PKPTemplateManager\getManager
static & getManager($request=null)
Definition: PKPTemplateManager.inc.php:1239
PKPHandler\getAuthorizedContextObject
& getAuthorizedContextObject($assocType)
Definition: PKPHandler.inc.php:174
PKPHandler\addPolicy
addPolicy($authorizationPolicy, $addToTop=false)
Definition: PKPHandler.inc.php:157
Handler
Base request handler application class.
Definition: Handler.inc.php:18