16 import(
'lib.pkp.classes.form.Form');
19 import(
'lib.pkp.classes.submission.reviewRound.ReviewRound');
37 function __construct($submission, $stageId, $reviewRound) {
38 parent::__construct(
'controllers/modals/editorDecision/form/recommendationForm.tpl');
39 $this->_submission = $submission;
40 $this->_stageId = $stageId;
41 $this->_reviewRound = $reviewRound;
87 $editorsStageAssignments = $stageAssignmentDao->getEditorsAssignedToStage($submission->getId(), $this->getStageId());
90 foreach ($editorsStageAssignments as $editorsStageAssignment) {
91 if (!$editorsStageAssignment->getRecommendOnly()) {
92 $editorFullName = $userDao->getUserFullName($editorsStageAssignment->getUserId());
93 $editorsStr .= ($i == 0) ? $editorFullName :
', ' . $editorFullName;
98 import(
'lib.pkp.classes.mail.SubmissionMailTemplate');
101 $router = $request->getRouter();
102 $dispatcher = $router->getDispatcher();
103 $user = $request->getUser();
104 $submissionUrl = $dispatcher->url($request, ROUTE_PAGE,
null,
'workflow',
'index', array($submission->getId(), $this->getStageId()));
105 $emailParams = array(
106 'editors' => $editorsStr,
107 'submissionUrl' => $submissionUrl,
109 $email->assignParams($emailParams);
110 $email->replaceParams();
114 $editorRecommendations = $editDecisionDao->getEditorDecisions($submission->getId(), $this->getStageId(),
null, $user->getId());
119 'submissionId' => $submission->getId(),
120 'stageId' => $this->getStageId(),
121 'reviewRoundId' => $this->getReviewRound()->getId(),
122 'editorRecommendations' => $editorRecommendations,
123 'recommendationOptions' => $recommendationOptions,
124 'editors' => $editorsStr,
125 'personalMessage' => $email->getBody(),
127 foreach($data as $key => $value) {
130 return parent::initData();
136 function fetch($request, $template =
null, $display =
false) {
138 $templateMgr->assign(array(
139 'allowedVariables' => [
140 'recommendation' => __(
'editor.submission.recommendation'),
143 return parent::fetch($request, $template, $display);
150 $this->
readUserVars(array(
'recommendation',
'personalMessage',
'skipEmail',
'skipDiscussion'));
151 parent::readInputData();
157 function execute(...$functionParams) {
158 parent::execute(...$functionParams);
164 $recommendation = $this->
getData(
'recommendation');
167 import(
'lib.pkp.classes.submission.action.EditorAction');
171 $actionLabels = array($recommendation => $recommendationOptions[$recommendation]);
172 $editorAction->recordDecision($request, $submission, $recommendation, $actionLabels, $reviewRound, $this->
getStageId(),
true);
174 if (!$this->
getData(
'skipEmail') || !$this->
getData(
'skipDiscussion')) {
175 $router = $request->getRouter();
176 $user = $request->getUser();
179 import(
'lib.pkp.classes.mail.SubmissionMailTemplate');
181 $email->setBody($this->
getData(
'personalMessage'));
185 $editorsStageAssignments = $stageAssignmentDao->getEditorsAssignedToStage($submission->getId(), $this->getStageId());
186 foreach ($editorsStageAssignments as $editorsStageAssignment) {
187 if (!$editorsStageAssignment->getRecommendOnly()) {
188 $editor = $userDao->getById($editorsStageAssignment->getUserId());
189 $editorFullName = $editor->getFullName();
190 $email->addRecipient($editor->getEmail(), $editorFullName);
195 $email->setEventType(SUBMISSION_EMAIL_EDITOR_RECOMMEND_NOTIFY);
197 $dispatcher = $router->getDispatcher();
198 $submissionUrl = $dispatcher->url($request, ROUTE_PAGE,
null,
'workflow',
'index', array($submission->getId(), $this->getStageId()));
199 $email->assignParams(array(
200 'editors' => $this->
getData(
'editors'),
201 'editorialContactSignature' => $user->getContactSignature(),
202 'submissionUrl' => $submissionUrl,
203 'recommendation' => __($recommendationOptions[$recommendation]),
205 if (!$this->
getData(
'skipEmail')) {
206 if (!$email->send($request)) {
207 import(
'classes.notification.NotificationManager');
209 $notificationMgr->createTrivialNotification($request->getUser()->getId(), NOTIFICATION_TYPE_ERROR, array(
'contents' => __(
'email.compose.error')));
213 if (!$this->
getData(
'skipDiscussion')) {
216 $query = $queryDao->newDataObject();
217 $query->setAssocType(ASSOC_TYPE_SUBMISSION);
218 $query->setAssocId($submission->getId());
220 $query->setSequence(REALLY_BIG_NUMBER);
221 $queryDao->insertObject($query);
222 $queryDao->resequence(ASSOC_TYPE_SUBMISSION, $submission->getId());
227 $discussionParticipantsIds = array();
228 $editorsStageAssignments = $stageAssignmentDao->getEditorsAssignedToStage($submission->getId(), $this->getStageId());
229 foreach ($editorsStageAssignments as $editorsStageAssignment) {
230 if (!$editorsStageAssignment->getRecommendOnly()) {
231 if (!in_array($editorsStageAssignment->getUserId(), $discussionParticipantsIds)) {
232 $discussionParticipantsIds[] = $editorsStageAssignment->getUserId();
233 $queryDao->insertParticipant($query->getId(), $editorsStageAssignment->getUserId());
239 $note = $noteDao->newDataObject();
240 $note->setAssocType(ASSOC_TYPE_QUERY);
241 $note->setAssocId($query->getId());
242 $email->replaceParams();
243 $note->setContents($email->getBody());
244 $note->setTitle(__(
'editor.submission.recommendation'));
247 $note->setUserId( $user->getId());
248 $noteDao->insertObject($note);
252 foreach ($discussionParticipantsIds as $discussionParticipantsId) {
253 $notificationMgr->createNotification(
255 $discussionParticipantsId,
256 NOTIFICATION_TYPE_NEW_QUERY,
257 $request->getContext()->getId(),
260 NOTIFICATION_LEVEL_TASK