00001 <?php
00002
00016 import('classes.submission.form.SubmissionSubmitForm');
00017 import('classes.submission.SubmissionMetadataFormImplementation');
00018
00019 class SubmissionSubmitStep3Form extends SubmissionSubmitForm {
00020
00022 var $_metadataFormImplem;
00023
00027 function SubmissionSubmitStep3Form($press, $monograph) {
00028 parent::SubmissionSubmitForm($press, $monograph, 3);
00029
00030 $this->_metadataFormImplem = new SubmissionMetadataFormImplementation($this);
00031
00032 $this->_metadataFormImplem->addChecks($monograph);
00033 }
00034
00038 function initData() {
00039
00040 $this->_metadataFormImplem->initData($this->monograph);
00041
00042 return parent::initData();
00043 }
00044
00048 function readInputData() {
00049
00050 $this->_metadataFormImplem->readInputData();
00051
00052
00053 $this->readUserVars(array('categories'));
00054
00055
00056
00057 $seriesDao =& DAORegistry::getDAO('SeriesDAO');
00058 $this->_data['series'] =& $seriesDao->getById($this->monograph->getSeriesId(), $this->monograph->getPressId());
00059 }
00060
00064 function display($request) {
00065 $templateMgr =& TemplateManager::getManager();
00066
00067 $templateMgr->assign('isEditedVolume', $this->monograph->getWorkType() == WORK_TYPE_EDITED_VOLUME);
00068
00069
00070 $categoryDao =& DAORegistry::getDAO('CategoryDAO');
00071 $templateMgr->assign('categoriesExist', $categoryDao->getCountByPressId($this->press->getId()) > 0);
00072
00073 return parent::display($request);
00074 }
00075
00080 function getLocaleFieldNames() {
00081 $this->_metadataFormImplem->getLocaleFieldNames();
00082 }
00083
00090 function execute($args, &$request) {
00091
00092
00093 $this->_metadataFormImplem->execute($this->monograph, $request);
00094
00095
00096 ListbuilderHandler::unpack($request, $this->getData('categories'));
00097
00098
00099 $monographDao =& DAORegistry::getDAO('MonographDAO');
00100 $monograph =& $monographDao->getById($this->monographId);
00101
00102
00103 if ($monograph->getSubmissionProgress() <= $this->step) {
00104 $monograph->setDateSubmitted(Core::getCurrentDate());
00105 $monograph->stampStatusModified();
00106 $monograph->setSubmissionProgress(0);
00107 }
00108
00109
00110 $monographDao->updateMonograph($monograph);
00111
00112
00113 import('classes.submission.seriesEditor.SeriesEditorAction');
00114 $seriesEditorAction = new SeriesEditorAction();
00115 $seriesEditorAction->assignDefaultStageParticipants($monograph, WORKFLOW_STAGE_ID_SUBMISSION, $request);
00116
00117
00118
00119
00120
00121 $roleDao =& DAORegistry::getDAO('RoleDAO');
00122
00123
00124 $pressManagers = $roleDao->getUsersByRoleId(ROLE_ID_PRESS_MANAGER, $monograph->getPressId());
00125
00126 $pressManagersArray = $pressManagers->toAssociativeArray();
00127
00128 $allUserIds = array_keys($pressManagersArray);
00129
00130 $notificationManager = new NotificationManager();
00131 foreach ($allUserIds as $userId) {
00132 $notificationManager->createNotification(
00133 $request, $userId, NOTIFICATION_TYPE_MONOGRAPH_SUBMITTED,
00134 $monograph->getPressId(), ASSOC_TYPE_MONOGRAPH, $monograph->getId()
00135 );
00136
00137
00138 $notificationManager->createNotification(
00139 $request,
00140 $userId,
00141 NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_REQUIRED,
00142 $monograph->getPressId(),
00143 ASSOC_TYPE_MONOGRAPH,
00144 $monograph->getId(),
00145 NOTIFICATION_LEVEL_TASK
00146 );
00147 }
00148
00149
00150 import('classes.mail.MonographMailTemplate');
00151 $mail = new MonographMailTemplate($monograph, 'SUBMISSION_ACK');
00152 $authorMail = new MonographMailTemplate($monograph, 'SUBMISSION_ACK_NOT_USER');
00153
00154 $press =& $request->getPress();
00155
00156 $router =& $request->getRouter();
00157 if ($mail->isEnabled()) {
00158
00159 $mail->setFrom($this->press->getSetting('contactEmail'), $this->press->getSetting('contactName'));
00160 $authorMail->setFrom($this->press->getSetting('contactEmail'), $this->press->getSetting('contactName'));
00161
00162 $user = $monograph->getUser();
00163 $primaryAuthor = $monograph->getPrimaryAuthor();
00164 if (!isset($primaryAuthor)) {
00165 $authors =& $monograph->getAuthors();
00166 $primaryAuthor = $authors[0];
00167 }
00168 $mail->addRecipient($user->getEmail(), $user->getFullName());
00169
00170 if ($user->getEmail() != $primaryAuthor->getEmail()) {
00171 $authorMail->addRecipient($primaryAuthor->getEmail(), $primaryAuthor->getFullName());
00172 }
00173
00174 $assignedAuthors = $monograph->getAuthors();
00175
00176 foreach ($assignedAuthors as $author) {
00177 $authorEmail = $author->getEmail();
00178
00179
00180 if ($authorEmail != $primaryAuthor->getEmail() && $authorEmail != $user->getEmail()) {
00181 $authorMail->addRecipient($author->getEmail(), $author->getFullName());
00182 }
00183 }
00184 $mail->bccAssignedSeriesEditors($monograph->getId(), WORKFLOW_STAGE_ID_SUBMISSION);
00185
00186 $mail->assignParams(array(
00187 'authorName' => $user->getFullName(),
00188 'authorUsername' => $user->getUsername(),
00189 'editorialContactSignature' => $press->getSetting('contactName') . "\n" . $press->getLocalizedName(),
00190 'submissionUrl' => $router->url($request, null, 'authorDashboard', 'submission', $monograph->getId()),
00191 ));
00192
00193 $authorMail->assignParams(array(
00194 'submitterName' => $user->getFullName(),
00195 'editorialContactSignature' => $press->getSetting('contactName') . "\n" . $press->getLocalizedName(),
00196 ));
00197
00198 $mail->send($request);
00199
00200 $recipients = $authorMail->getRecipients();
00201 if (!empty($recipients)) {
00202 $authorMail->send($request);
00203 }
00204 }
00205
00206
00207 $notificationManager->updateApproveSubmissionNotificationTypes($request, $monograph);
00208
00209
00210 import('classes.log.MonographLog');
00211 MonographLog::logEvent($request, $monograph, MONOGRAPH_LOG_MONOGRAPH_SUBMIT, 'submission.event.monographSubmitted');
00212
00213 return $this->monographId;
00214 }
00215
00220 function insertEntry(&$request, $newRowId) {
00221
00222 $application =& PKPApplication::getApplication();
00223 $request =& $application->getRequest();
00224
00225 $categoryId = $newRowId['name'];
00226 $categoryDao =& DAORegistry::getDAO('CategoryDAO');
00227 $monographDao =& DAORegistry::getDAO('MonographDAO');
00228 $press =& $request->getPress();
00229 $monograph =& $this->monograph;
00230
00231 $category =& $categoryDao->getById($categoryId, $press->getId());
00232 if (!$category) return true;
00233
00234
00235 $monographDao->addCategory(
00236 $monograph->getId(),
00237 $categoryId
00238 );
00239 }
00240
00245 function deleteEntry(&$request, $rowId) {
00246 if ($rowId) {
00247 $categoryDao =& DAORegistry::getDAO('CategoryDAO');
00248 $monographDao =& DAORegistry::getDAO('MonographDAO');
00249 $category =& $categoryDao->getById($rowId);
00250 if (!is_a($category, 'Category')) {
00251 assert(false);
00252 return false;
00253 }
00254 $monograph =& $this->monograph;
00255 $monographDao->removeCategory($monograph->getId(), $rowId);
00256 }
00257
00258 return true;
00259 }
00260
00265 function updateEntry($request, $rowId, $newRowId) {
00266
00267 $this->deleteEntry($request, $rowId);
00268 $this->insertEntry($request, $newRowId);
00269 }
00270 }
00271
00272 ?>