Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
SubmissionSubmitStep3Form.inc.php
1 <?php
2 
16 import('lib.pkp.classes.submission.form.PKPSubmissionSubmitStep3Form');
17 import('classes.submission.SubmissionMetadataFormImplementation');
18 
23  function SubmissionSubmitStep3Form($context, $submission) {
24  parent::PKPSubmissionSubmitStep3Form(
25  $context,
28  );
29  }
30 
34  function readInputData() {
35  parent::readInputData();
36 
37  // Include category information.
38  $this->readUserVars(array('categories'));
39 
40  // Load the series. This is used in the step 3 form to
41  // determine whether or not to display indexing options.
42  $seriesDao = DAORegistry::getDAO('SeriesDAO');
43  $this->_data['series'] = $seriesDao->getById($this->submission->getSeriesId(), $this->submission->getContextId());
44  }
45 
49  function fetch($request) {
50  $templateMgr = TemplateManager::getManager($request);
51 
52  $templateMgr->assign('isEditedVolume', $this->submission->getWorkType() == WORK_TYPE_EDITED_VOLUME);
53 
54  // If categories are configured, present the LB.
55  $categoryDao = DAORegistry::getDAO('CategoryDAO');
56  $templateMgr->assign('categoriesExist', $categoryDao->getCountByPressId($this->context->getId()) > 0);
57 
58  return parent::fetch($request);
59  }
60 
67  function execute($args, $request) {
68  parent::execute($args, $request);
69 
70  // handle category assignment.
71  ListbuilderHandler::unpack($request, $this->getData('categories'));
72 
73  $submissionDao = Application::getSubmissionDAO();
74  $submission = $submissionDao->getById($this->submissionId);
75 
76  // Send author notification email
77  import('classes.mail.MonographMailTemplate');
78  $mail = new MonographMailTemplate($submission, 'SUBMISSION_ACK');
79  $authorMail = new MonographMailTemplate($submission, 'SUBMISSION_ACK_NOT_USER');
80 
81  $context = $request->getContext();
82  $router = $request->getRouter();
83  if ($mail->isEnabled()) {
84  // submission ack emails should be from the contact.
85  $mail->setReplyTo($this->context->getSetting('contactEmail'), $this->context->getSetting('contactName'));
86  $authorMail->setReplyTo($this->context->getSetting('contactEmail'), $this->context->getSetting('contactName'));
87 
88  $user = $submission->getUser();
89  $primaryAuthor = $submission->getPrimaryAuthor();
90  if (!isset($primaryAuthor)) {
91  $authors = $submission->getAuthors();
92  $primaryAuthor = $authors[0];
93  }
94  $mail->addRecipient($user->getEmail(), $user->getFullName());
95 
96  if ($user->getEmail() != $primaryAuthor->getEmail()) {
97  $authorMail->addRecipient($primaryAuthor->getEmail(), $primaryAuthor->getFullName());
98  }
99  if ($context->getSetting('copySubmissionAckPrimaryContact')) {
100  $authorMail->addBcc(
101  $context->getSetting('contactEmail'),
102  $context->getSetting('contactName')
103  );
104  }
105  if ($copyAddress = $context->getSetting('copySubmissionAckAddress')) {
106  $authorMail->addBcc($copyAddress);
107  }
108 
109  $assignedAuthors = $submission->getAuthors();
110 
111  foreach ($assignedAuthors as $author) {
112  $authorEmail = $author->getEmail();
113  // only add the author email if they have not already been added as the primary author
114  // or user creating the submission.
115  if ($authorEmail != $primaryAuthor->getEmail() && $authorEmail != $user->getEmail()) {
116  $authorMail->addRecipient($author->getEmail(), $author->getFullName());
117  }
118  }
119  $mail->bccAssignedSeriesEditors($submission->getId(), WORKFLOW_STAGE_ID_SUBMISSION);
120 
121  $mail->assignParams(array(
122  'authorName' => $user->getFullName(),
123  'authorUsername' => $user->getUsername(),
124  'editorialContactSignature' => $context->getSetting('contactName') . "\n" . $context->getLocalizedName(),
125  'submissionUrl' => $router->url($request, null, 'authorDashboard', 'submission', $submission->getId()),
126  ));
127 
128  $authorMail->assignParams(array(
129  'submitterName' => $user->getFullName(),
130  'editorialContactSignature' => $context->getSetting('contactName') . "\n" . $context->getLocalizedName(),
131  ));
132 
133  $mail->send($request);
134 
135  $recipients = $authorMail->getRecipients();
136  if (!empty($recipients)) {
137  $authorMail->send($request);
138  }
139  }
140 
141  // Log submission.
142  import('lib.pkp.classes.log.SubmissionLog');
143  import('classes.log.SubmissionEventLogEntry'); // constants
144  SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_SUBMISSION_SUBMIT, 'submission.event.submissionSubmitted');
145 
146  return $this->submissionId;
147  }
148 
153  function insertEntry($request, $newRowId) {
154 
155  $application = PKPApplication::getApplication();
156  $request = $application->getRequest();
157 
158  $categoryId = $newRowId['name'];
159  $categoryDao = DAORegistry::getDAO('CategoryDAO');
160  $submissionDao = DAORegistry::getDAO('MonographDAO');
161  $context = $request->getContext();
163 
164  $category = $categoryDao->getById($categoryId, $context->getId());
165  if (!$category) return true;
166 
167  // Associate the category with the submission
168  $submissionDao->addCategory(
169  $submission->getId(),
170  $categoryId
171  );
172  }
173 
178  function deleteEntry($request, $rowId) {
179  if ($rowId) {
180  $categoryDao = DAORegistry::getDAO('CategoryDAO');
181  $submissionDao = DAORegistry::getDAO('MonographDAO');
182  $category = $categoryDao->getById($rowId);
183  if (!is_a($category, 'Category')) {
184  assert(false);
185  return false;
186  }
188  $submissionDao->removeCategory($submission->getId(), $rowId);
189  }
190 
191  return true;
192  }
193 
198  function updateEntry($request, $rowId, $newRowId) {
199 
200  $this->deleteEntry($request, $rowId);
201  $this->insertEntry($request, $newRowId);
202  }
203 }
204 
205 ?>
static & getDAO($name, $dbconn=null)
Subclass of MailTemplate for sending emails related to submissions.
readUserVars($vars)
Definition: Form.inc.php:364
Form for Step 3 of author submission.
getData($key)
Definition: Form.inc.php:210
static getSubmissionDAO()
SubmissionSubmitStep3Form($context, $submission)
This can be used by other forms that want to implement submission metadata data and form operations...
static logEvent($request, $submission, $eventType, $messageKey, $params=array())
Form for Step 3 of author submission: submission metadata.
unpack($request, $data, $deletionCallback=null, $insertionCallback=null, $updateCallback=null)
updateEntry($request, $rowId, $newRowId)