Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
ReviewerReviewStep3Form.inc.php
1 <?php
2 
16 import('lib.pkp.classes.submission.reviewer.form.ReviewerReviewForm');
17 
24  function ReviewerReviewStep3Form($request, $reviewerSubmission, $reviewAssignment) {
25  parent::ReviewerReviewForm($request, $reviewerSubmission, $reviewAssignment, 3);
26 
27  // Validation checks for this form
28  // FIXME #5123: Include when review form infrastructure is in place
29  //$reviewFormElementDao = DAORegistry::getDAO('ReviewFormElementDAO');
30  //$requiredReviewFormElementIds = $reviewFormElementDao->getRequiredReviewFormElementIds($this->reviewAssignment->getReviewFormId());
31  //$this->addCheck(new FormValidatorCustom($this, 'reviewFormResponses', 'required', 'reviewer.submission.reviewFormResponse.form.responseRequired', create_function('$reviewFormResponses, $requiredReviewFormElementIds', 'foreach ($requiredReviewFormElementIds as $requiredReviewFormElementId) { if (!isset($reviewFormResponses[$requiredReviewFormElementId]) || $reviewFormResponses[$requiredReviewFormElementId] == \'\') return false; } return true;'), array($requiredReviewFormElementIds)));
32 
33  $this->addCheck(new FormValidatorPost($this));
34  }
35 
36 
37  function initData() {
38  $reviewAssignment = $this->getReviewAssignment();
39  // Retrieve reviewer comment.
40  $submissionCommentDao = DAORegistry::getDAO('SubmissionCommentDAO');
41  $submissionComments = $submissionCommentDao->getReviewerCommentsByReviewerId($reviewAssignment->getReviewerId(), $reviewAssignment->getSubmissionId(), $reviewAssignment->getId());
42  $this->setData('reviewerComment', $submissionComments->next());
43  }
44 
45  //
46  // Implement protected template methods from Form
47  //
51  function readInputData() {
52  // FIXME #5123: Include when review form infrastructure is in place
53  $this->readUserVars(
54  array(/*'reviewFormResponses', */ 'comments', 'recommendation')
55  );
56  }
57 
61  function fetch($request) {
62  $templateMgr = TemplateManager::getManager($request);
63 
64  $reviewAssignment = $this->getReviewAssignment();
65  $reviewRoundId = $reviewAssignment->getReviewRoundId();
66 
67  // Assign the objects and data to the template.
68  $context = $this->request->getContext();
69  $templateMgr->assign('reviewAssignment', $reviewAssignment);
70  $templateMgr->assign('reviewRoundId', $reviewRoundId);
71 
72  // Include the review recommendation options on the form.
73  $templateMgr->assign_by_ref('reviewerRecommendationOptions', ReviewAssignment::getReviewerRecommendationOptions());
74 
75  /* FIXME #5123: Include when review form infrastructure is in place
76  if($reviewAssignment->getReviewFormId()) {
77 
78  // Get the review form components
79  $reviewFormElementDao = DAORegistry::getDAO('ReviewFormElementDAO');
80  $reviewFormElements =& $reviewFormElementDao->getReviewFormElements($reviewAssignment->getReviewFormId());
81  $reviewFormResponseDao = DAORegistry::getDAO('ReviewFormResponseDAO');
82  $reviewFormResponses =& $reviewFormResponseDao->getReviewReviewFormResponseValues($reviewAssignment->getReviewId());
83  $reviewFormDao = DAORegistry::getDAO('ReviewFormDAO');
84  $reviewformid = $reviewAssignment->getReviewFormId();
85  $reviewForm =& $reviewFormDao->getReviewForm($reviewAssignment->getReviewFormId(), ASSOC_TYPE_..., $context->getId());
86 
87  $templateMgr->assign_by_ref('reviewForm', $reviewForm);
88  $templateMgr->assign('reviewFormElements', $reviewFormElements);
89  $templateMgr->assign('reviewFormResponses', $reviewFormResponses);
90  $templateMgr->assign('isLocked', isset($reviewAssignment) && $reviewAssignment->getDateCompleted() != null);
91  }*/
92 
93  //
94  // Assign the link actions
95  //
96  if ($context->getLocalizedSetting('reviewGuidelines')) {
97  import('lib.pkp.controllers.confirmationModal.linkAction.ViewReviewGuidelinesLinkAction');
98  $viewReviewGuidelinesAction = new ViewReviewGuidelinesLinkAction($request, $reviewAssignment->getStageId());
99  $templateMgr->assign('viewGuidelinesAction', $viewReviewGuidelinesAction);
100  }
101  return parent::fetch($request);
102  }
103 
108  function execute($request) {
109  $reviewAssignment =& $this->getReviewAssignment();
110  $notificationMgr = new NotificationManager();
111  if($reviewAssignment->getReviewFormId()) {
112  /* FIXME #5123: Include when review form infrastructure is in place
113  $reviewFormResponseDao = DAORegistry::getDAO('ReviewFormResponseDAO');
114  $reviewFormResponses = $this->getData('reviewFormResponses');
115  if (is_array($reviewFormResponses)) foreach ($reviewFormResponses as $reviewFormElementId => $reviewFormResponseValue) {
116  $reviewFormResponse =& $reviewFormResponseDao->getReviewFormResponse($reviewAssignment->getReviewId(), $reviewFormElementId);
117  if (!isset($reviewFormResponse)) {
118  $reviewFormResponse = new ReviewFormResponse();
119  }
120  $reviewFormElementDao = DAORegistry::getDAO('ReviewFormElementDAO');
121  $reviewFormElement = $reviewFormElementDao->getReviewFormElement($reviewFormElementId);
122  $elementType = $reviewFormElement->getElementType();
123  switch ($elementType) {
124  case REVIEW_FORM_ELEMENT_TYPE_SMALL_TEXT_FIELD:
125  case REVIEW_FORM_ELEMENT_TYPE_TEXT_FIELD:
126  case REVIEW_FORM_ELEMENT_TYPE_TEXTAREA:
127  $reviewFormResponse->setResponseType('string');
128  $reviewFormResponse->setValue($reviewFormResponseValue);
129  break;
130  case REVIEW_FORM_ELEMENT_TYPE_RADIO_BUTTONS:
131  case REVIEW_FORM_ELEMENT_TYPE_DROP_DOWN_BOX:
132  $reviewFormResponse->setResponseType('int');
133  $reviewFormResponse->setValue($reviewFormResponseValue);
134  break;
135  case REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES:
136  $reviewFormResponse->setResponseType('object');
137  $reviewFormResponse->setValue($reviewFormResponseValue);
138  break;
139  }
140  if ($reviewFormResponse->getReviewFormElementId() != null && $reviewFormResponse->getReviewId() != null) {
141  $reviewFormResponseDao->updateObject($reviewFormResponse);
142  } else {
143  $reviewFormResponse->setReviewFormElementId($reviewFormElementId);
144  $reviewFormResponse->setReviewId($reviewAssignment->getReviewId());
145  $reviewFormResponseDao->insertObject($reviewFormResponse);
146  }
147  } */
148  } else {
149  // Create a comment with the review.
150  $submissionCommentDao = DAORegistry::getDAO('SubmissionCommentDAO');
151  $comment = $submissionCommentDao->newDataObject();
152  $comment->setCommentType(COMMENT_TYPE_PEER_REVIEW);
153  $comment->setRoleId(ROLE_ID_REVIEWER);
154  $comment->setAssocId($reviewAssignment->getId());
155  $comment->setSubmissionId($reviewAssignment->getSubmissionId());
156  $comment->setAuthorId($reviewAssignment->getReviewerId());
157  $comment->setComments($this->getData('comments'));
158  $comment->setCommentTitle('');
159  $comment->setViewable(true);
160  $comment->setDatePosted(Core::getCurrentDate());
161 
162  // Persist the comment.
163  $submissionCommentDao->insertObject($comment);
164 
165  $submissionDao = Application::getSubmissionDAO();
166  $submission = $submissionDao->getById($reviewAssignment->getSubmissionId());
167 
168  $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
169  $stageAssignments = $stageAssignmentDao->getBySubmissionAndStageId($submission->getId(), $submission->getStageId());
170 
171  while ($stageAssignment = $stageAssignments->next()) {
172  $notificationMgr->createNotification(
173  $request, $stageAssignment->getUserId(), NOTIFICATION_TYPE_REVIEWER_COMMENT,
174  $submission->getContextId(), ASSOC_TYPE_REVIEW_ASSIGNMENT, $reviewAssignment->getId()
175  );
176  }
177  }
178 
179  // Set review to next step.
181 
182  // Mark the review assignment as completed.
183  $reviewAssignment->setDateCompleted(Core::getCurrentDate());
184  $reviewAssignment->stampModified();
185 
186  // assign the recommendation to the review assignment, if there was one.
187  $reviewAssignment->setRecommendation((int) $this->getData('recommendation'));
188 
189  // Persist the updated review assignment.
190  $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); /* @var $reviewAssignmentDao ReviewAssignmentDAO */
191  $reviewAssignmentDao->updateObject($reviewAssignment);
192 
193  // Update the review round status.
194  $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /* @var $reviewRoundDao ReviewRoundDAO */
195  $reviewRound = $reviewRoundDao->getById($reviewAssignment->getReviewRoundId());
196  $reviewAssignments = $reviewAssignmentDao->getByReviewRoundId($reviewRound->getId(), true);
197  $reviewRoundDao->updateStatus($reviewRound, $reviewAssignments);
198 
199  // Update "all reviews in" notification.
200  $notificationMgr->updateNotification(
201  $request,
202  array(NOTIFICATION_TYPE_ALL_REVIEWS_IN),
203  null,
204  ASSOC_TYPE_REVIEW_ROUND,
205  $reviewRound->getId()
206  );
207 
208  // Remove the task
209  $notificationDao = DAORegistry::getDAO('NotificationDAO');
210  $notificationDao->deleteByAssoc(
211  ASSOC_TYPE_REVIEW_ASSIGNMENT,
212  $reviewAssignment->getId(),
213  $reviewAssignment->getReviewerId(),
214  NOTIFICATION_TYPE_REVIEW_ASSIGNMENT
215  );
216  }
217 }
218 
219 ?>
static & getDAO($name, $dbconn=null)
addCheck($formValidator)
Definition: Form.inc.php:396
setData($key, $value)
Definition: Form.inc.php:219
Form validation check to make sure the form is POSTed.
readUserVars($vars)
Definition: Form.inc.php:364
getData($key)
Definition: Form.inc.php:210
static getSubmissionDAO()
ReviewerReviewStep3Form($request, $reviewerSubmission, $reviewAssignment)
Form for Step 3 of a review.
Base class for reviewer forms.
updateReviewStepAndSaveSubmission(&$reviewerSubmission)
An action to open the review guidelines confirmation modal.
static getCurrentDate($ts=null)
Definition: Core.inc.php:95