4 * @file classes/submission/form/comment/ProofreadCommentForm.inc.php
6 * Copyright (c) 2003-2008 John Willinsky
7 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
9 * @class ProofreadCommentForm
10 * @ingroup submission_form
12 * @brief ProofreadComment form.
15 // $Id: ProofreadCommentForm.inc.php,v 1.4 2009/06/09 23:37:14 tylerl Exp $
18 import("submission.form.comment.CommentForm");
20 class ProofreadCommentForm
extends CommentForm
{
24 * @param $monograph object
26 function ProofreadCommentForm($monograph, $roleId) {
27 parent
::CommentForm($monograph, COMMENT_TYPE_PROOFREAD
, $roleId, $monograph->getMonographId());
34 $templateMgr =& TemplateManager
::getManager();
35 $templateMgr->assign('pageTitle', 'submission.comments.corrections');
36 $templateMgr->assign('commentAction', 'postProofreadComment');
37 $templateMgr->assign('commentType', 'proofread');
38 $templateMgr->assign('hiddenFormParams',
40 'monographId' => $this->monograph
->getMonographId()
48 * Assign form data to user-submitted data.
50 function readInputData() {
51 parent
::readInputData();
65 $roleDao =& DAORegistry
::getDAO('RoleDAO');
66 $userDao =& DAORegistry
::getDAO('UserDAO');
67 $press =& Request
::getPress();
69 // Create list of recipients:
70 $recipients = array();
72 // Proofread comments are to be sent to the editors, layout editor, proofreader, and author,
73 // excluding whomever posted the comment.
76 $editAssignmentDao =& DAORegistry
::getDAO('EditAssignmentDAO');
77 $editAssignments =& $editAssignmentDao->getByIdsByMonographId($this->monograph
->getMonographId());
78 $editorAddresses = array();
79 while (!$editAssignments->eof()) {
80 $editAssignment =& $editAssignments->next();
81 if ($editAssignment->getCanEdit()) $editorAddresses[$editAssignment->getEditorEmail()] = $editAssignment->getEditorFullName();
82 unset($editAssignment);
85 // If no editors are currently assigned to this monograph,
86 // send the email to all editors for the press
87 if (empty($editorAddresses)) {
88 $editors =& $roleDao->getUsersByRoleId(ROLE_ID_EDITOR
, $press->getPressId());
89 while (!$editors->eof()) {
90 $editor =& $editors->next();
91 $editorAddresses[$editor->getEmail()] = $editor->getFullName();
96 $layoutAssignmentDao =& DAORegistry
::getDAO('LayoutAssignmentDAO');
97 $layoutAssignment =& $layoutAssignmentDao->getLayoutAssignmentByMonographId($this->monograph
->getMonographId());
98 if ($layoutAssignment != null && $layoutAssignment->getEditorId() > 0) {
99 $layoutEditor =& $userDao->getUser($layoutAssignment->getEditorId());
101 $layoutEditor = null;
105 $proofAssignmentDao =& DAORegistry
::getDAO('ProofAssignmentDAO');
106 $proofAssignment =& $proofAssignmentDao->getProofAssignmentByMonographId($this->monograph
->getMonographId());
107 if ($proofAssignment != null && $proofAssignment->getProofreaderId() > 0) {
108 $proofreader =& $userDao->getUser($proofAssignment->getProofreaderId());
114 $author =& $userDao->getUser($this->monograph
->getUserId());
116 // Choose who receives this email
117 if ($this->roleId
== ROLE_ID_EDITOR ||
$this->roleId
== ROLE_ID_ACQUISITIONS_EDITOR
) {
118 // Then add layout editor, proofreader and author
119 if ($layoutEditor != null) {
120 $recipients = array_merge($recipients, array($layoutEditor->getEmail() => $layoutEditor->getFullName()));
123 if ($proofreader != null) {
124 $recipients = array_merge($recipients, array($proofreader->getEmail() => $proofreader->getFullName()));
127 if (isset($author)) $recipients = array_merge($recipients, array($author->getEmail() => $author->getFullName()));
129 } else if ($this->roleId
== ROLE_ID_LAYOUT_EDITOR
) {
130 // Then add editors, proofreader and author
131 $recipients = array_merge($recipients, $editorAddresses);
133 if ($proofreader != null) {
134 $recipients = array_merge($recipients, array($proofreader->getEmail() => $proofreader->getFullName()));
137 if (isset($author)) $recipients = array_merge($recipients, array($author->getEmail() => $author->getFullName()));
139 } else if ($this->roleId
== ROLE_ID_PROOFREADER
) {
140 // Then add editors, layout editor, and author
141 $recipients = array_merge($recipients, $editorAddresses);
143 if ($layoutEditor != null) {
144 $recipients = array_merge($recipients, array($layoutEditor->getEmail() => $layoutEditor->getFullName()));
147 if (isset($author)) $recipients = array_merge($recipients, array($author->getEmail() => $author->getFullName()));
150 // Then add editors, layout editor, and proofreader
151 $recipients = array_merge($recipients, $editorAddresses);
153 if ($layoutEditor != null) {
154 $recipients = array_merge($recipients, array($layoutEditor->getEmail() => $layoutEditor->getFullName()));
157 if ($proofreader != null) {
158 $recipients = array_merge($recipients, array($proofreader->getEmail() => $proofreader->getFullName()));
162 parent
::email($recipients);