/** * Select a proofreader for submission */ function selectProofreader($userId, $article, $request) { $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $proofSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $article->getId()); if (!HookRegistry::call('ProofreaderAction::selectProofreader', array(&$userId, &$article))) { $proofSignoff->setUserId($userId); $signoffDao->updateObject($proofSignoff); // Add log entry $user =& Request::getUser(); $userDao =& DAORegistry::getDAO('UserDAO'); $proofreader =& $userDao->getUser($userId); if (!isset($proofreader)) { return; } import('classes.article.log.ArticleLog'); import('classes.article.log.ArticleEventLogEntry'); ArticleLog::logEvent($request, $article, ARTICLE_LOG_PROOFREAD_ASSIGN, 'log.proofread.assign', array('assignerName' => $user->getFullName(), 'proofreaderName' => $proofreader->getFullName())); } }
/** * Select a proofreader for submission */ function selectProofreader($userId, $article) { $proofAssignmentDao =& DAORegistry::getDAO('ProofAssignmentDAO'); $proofAssignment =& $proofAssignmentDao->getProofAssignmentByArticleId($article->getArticleId()); if (!HookRegistry::call('ProofreaderAction::selectProofreader', array(&$userId, &$article, &$proofAssignment))) { $proofAssignment->setProofreaderId($userId); $proofAssignmentDao->updateProofAssignment($proofAssignment); // Add log entry $user =& Request::getUser(); $userDao =& DAORegistry::getDAO('UserDAO'); $proofreader =& $userDao->getUser($userId); if (!isset($proofreader)) { return; } import('article.log.ArticleLog'); import('article.log.ArticleEventLogEntry'); ArticleLog::logEvent($article->getArticleId(), ARTICLE_LOG_PROOFREAD_ASSIGN, ARTICLE_LOG_TYPE_PROOFREAD, $user->getUserId(), 'log.proofread.assign', array('assignerName' => $user->getFullName(), 'proofreaderName' => $proofreader->getFullName(), 'articleId' => $article->getArticleId())); } }
/** * Set that the copyedit is underway. */ function copyeditUnderway(&$copyeditorSubmission) { if (!HookRegistry::call('CopyeditorAction::copyeditUnderway', array(&$copyeditorSubmission))) { $copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO'); $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $initialSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $copyeditorSubmission->getId()); $finalSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $copyeditorSubmission->getId()); if ($initialSignoff->getDateNotified() != null && $initialSignoff->getDateUnderway() == null) { $initialSignoff->setDateUnderway(Core::getCurrentDate()); $signoffDao->updateObject($initialSignoff); $update = true; } elseif ($finalSignoff->getDateNotified() != null && $finalSignoff->getDateUnderway() == null) { $finalSignoff->setDateUnderway(Core::getCurrentDate()); $signoffDao->updateObject($finalSignoff); $update = true; } if (isset($update)) { // Add log entry $user =& Request::getUser(); import('classes.article.log.ArticleLog'); import('classes.article.log.ArticleEventLogEntry'); ArticleLog::logEvent($copyeditorSubmission->getArticleId(), ARTICLE_LOG_COPYEDIT_INITIATE, ARTICLE_LOG_TYPE_COPYEDIT, $user->getId(), 'log.copyedit.initiate', array('copyeditorName' => $user->getFullName(), 'articleId' => $copyeditorSubmission->getArticleId())); } } }
/** * Save metadata. * @param $article object * @param $request PKPRequest */ function saveMetadata($article, &$request) { $router =& $request->getRouter(); if (!HookRegistry::call('Action::saveMetadata', array(&$article))) { import('classes.submission.form.MetadataForm'); $journal =& $request->getJournal(); $metadataForm = new MetadataForm($article, $journal); $metadataForm->readInputData(); // Check for any special cases before trying to save if ($request->getUserVar('addAuthor')) { // Add an author $editData = true; $authors = $metadataForm->getData('authors'); array_push($authors, array()); $metadataForm->setData('authors', $authors); } else { if (($delAuthor = $request->getUserVar('delAuthor')) && count($delAuthor) == 1) { // Delete an author $editData = true; list($delAuthor) = array_keys($delAuthor); $delAuthor = (int) $delAuthor; $authors = $metadataForm->getData('authors'); if (isset($authors[$delAuthor]['authorId']) && !empty($authors[$delAuthor]['authorId'])) { $deletedAuthors = explode(':', $metadataForm->getData('deletedAuthors')); array_push($deletedAuthors, $authors[$delAuthor]['authorId']); $metadataForm->setData('deletedAuthors', join(':', $deletedAuthors)); } array_splice($authors, $delAuthor, 1); $metadataForm->setData('authors', $authors); if ($metadataForm->getData('primaryContact') == $delAuthor) { $metadataForm->setData('primaryContact', 0); } } else { if ($request->getUserVar('moveAuthor')) { // Move an author up/down $editData = true; $moveAuthorDir = $request->getUserVar('moveAuthorDir'); $moveAuthorDir = $moveAuthorDir == 'u' ? 'u' : 'd'; $moveAuthorIndex = (int) $request->getUserVar('moveAuthorIndex'); $authors = $metadataForm->getData('authors'); if (!($moveAuthorDir == 'u' && $moveAuthorIndex <= 0 || $moveAuthorDir == 'd' && $moveAuthorIndex >= count($authors) - 1)) { $tmpAuthor = $authors[$moveAuthorIndex]; $primaryContact = $metadataForm->getData('primaryContact'); if ($moveAuthorDir == 'u') { $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex - 1]; $authors[$moveAuthorIndex - 1] = $tmpAuthor; if ($primaryContact == $moveAuthorIndex) { $metadataForm->setData('primaryContact', $moveAuthorIndex - 1); } else { if ($primaryContact == $moveAuthorIndex - 1) { $metadataForm->setData('primaryContact', $moveAuthorIndex); } } } else { $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex + 1]; $authors[$moveAuthorIndex + 1] = $tmpAuthor; if ($primaryContact == $moveAuthorIndex) { $metadataForm->setData('primaryContact', $moveAuthorIndex + 1); } else { if ($primaryContact == $moveAuthorIndex + 1) { $metadataForm->setData('primaryContact', $moveAuthorIndex); } } } } $metadataForm->setData('authors', $authors); } } } if (isset($editData)) { $metadataForm->display(); return false; } else { if (!$metadataForm->validate()) { return $metadataForm->display(); } $metadataForm->execute($request); // Send a notification to associated users import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationUsers = $article->getAssociatedUserIds(); foreach ($notificationUsers as $userRole) { $notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_METADATA_MODIFIED, $article->getJournalId(), ASSOC_TYPE_ARTICLE, $article->getId()); } // Add log entry $user =& $request->getUser(); import('classes.article.log.ArticleLog'); ArticleLog::logEvent($request, $article, ARTICLE_LOG_METADATA_UPDATE, 'log.editor.metadataModified', array('editorName' => $user->getFullName())); return true; } } }
/** * Author completes editor / author review. * @param $authorSubmission object * @param $send boolean * @param $request object */ function completeAuthorCopyedit($authorSubmission, $send, $request) { $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $journal =& $request->getJournal(); $authorSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $authorSubmission->getId()); if ($authorSignoff->getDateCompleted() != null) { return true; } $user =& $request->getUser(); import('classes.mail.ArticleMailTemplate'); $email = new ArticleMailTemplate($authorSubmission, 'COPYEDIT_AUTHOR_COMPLETE'); $editAssignments = $authorSubmission->getEditAssignments(); $copyeditor = $authorSubmission->getUserBySignoffType('SIGNOFF_COPYEDITING_INITIAL'); if (!$email->isEnabled() || $send && !$email->hasErrors()) { HookRegistry::call('AuthorAction::completeAuthorCopyedit', array(&$authorSubmission, &$email)); if ($email->isEnabled()) { $email->send($request); } $authorSignoff->setDateCompleted(Core::getCurrentDate()); $finalSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $authorSubmission->getId()); if ($copyeditor) { $finalSignoff->setUserId($copyeditor->getId()); } $finalSignoff->setDateNotified(Core::getCurrentDate()); $signoffDao->updateObject($authorSignoff); $signoffDao->updateObject($finalSignoff); // Add log entry import('classes.article.log.ArticleLog'); ArticleLog::logEvent($request, $authorSubmission, ARTICLE_LOG_COPYEDIT_REVISION, 'log.copyedit.authorFile'); return true; } else { if (!$request->getUserVar('continued')) { if (isset($copyeditor)) { $email->addRecipient($copyeditor->getEmail(), $copyeditor->getFullName()); $assignedSectionEditors = $email->ccAssignedEditingSectionEditors($authorSubmission->getId()); $assignedEditors = $email->ccAssignedEditors($authorSubmission->getId()); if (empty($assignedSectionEditors) && empty($assignedEditors)) { $email->addCc($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $editorName = $journal->getSetting('contactName'); } else { $editor = array_shift($assignedSectionEditors); if (!$editor) { $editor = array_shift($assignedEditors); } $editorName = $editor->getEditorFullName(); } } else { $assignedSectionEditors = $email->toAssignedEditingSectionEditors($authorSubmission->getId()); $assignedEditors = $email->ccAssignedEditors($authorSubmission->getId()); if (empty($assignedSectionEditors) && empty($assignedEditors)) { $email->addRecipient($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $editorName = $journal->getSetting('contactName'); } else { $editor = array_shift($assignedSectionEditors); if (!$editor) { $editor = array_shift($assignedEditors); } $editorName = $editor->getEditorFullName(); } } $paramArray = array('editorialContactName' => isset($copyeditor) ? $copyeditor->getFullName() : $editorName, 'authorName' => $user->getFullName()); $email->assignParams($paramArray); } $email->displayEditForm($request->url(null, 'author', 'completeAuthorCopyedit', 'send'), array('articleId' => $authorSubmission->getId())); return false; } }
/** * Payments */ function waiveSubmissionFee($args, $request) { $articleId = (int) array_shift($args); $markAsPaid = $request->getUserVar('markAsPaid'); $this->validate($articleId, SECTION_EDITOR_ACCESS_EDIT); $submission =& $this->submission; import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $user =& $request->getUser(); $journal =& $request->getJournal(); $queuedPayment =& $paymentManager->createQueuedPayment($journal->getId(), PAYMENT_TYPE_SUBMISSION, $markAsPaid ? $submission->getUserId() : $user->getId(), $articleId, $markAsPaid ? $journal->getSetting('submissionFee') : 0, $markAsPaid ? $journal->getSetting('currency') : ''); // Since this is a waiver, fulfill the payment immediately $paymentManager->fulfillQueuedPayment($queuedPayment, $markAsPaid ? 'ManualPayment' : 'Waiver'); import('classes.article.log.ArticleLog'); import('classes.article.log.ArticleEventLogEntry'); Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON)); if ($markAsPaid) { $message = 'log.editor.fee.paid'; } else { $message = 'log.editor.fee.waived'; } ArticleLog::logEvent($submission->getArticleId(), ARTICLE_LOG_SECTION_DECISION, ARTICLE_LOG_TYPE_EDITOR, $user->getId(), $message, array('editorName' => $user->getFullName(), 'proposalId' => $submission->getProposalId())); $request->redirect(null, null, 'submissionReview', $articleId); }
/** * Set that the copyedit is underway. */ function copyeditUnderway(&$copyeditorSubmission) { if (!HookRegistry::call('CopyeditorAction::copyeditUnderway', array(&$copyeditorSubmission))) { $copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO'); if ($copyeditorSubmission->getDateNotified() != null && $copyeditorSubmission->getDateUnderway() == null) { $copyeditorSubmission->setDateUnderway(Core::getCurrentDate()); $update = true; } elseif ($copyeditorSubmission->getDateFinalNotified() != null && $copyeditorSubmission->getDateFinalUnderway() == null) { $copyeditorSubmission->setDateFinalUnderway(Core::getCurrentDate()); $update = true; } if (isset($update)) { $copyeditorSubmissionDao->updateCopyeditorSubmission($copyeditorSubmission); // Add log entry $user =& Request::getUser(); import('article.log.ArticleLog'); import('article.log.ArticleEventLogEntry'); ArticleLog::logEvent($copyeditorSubmission->getArticleId(), ARTICLE_LOG_COPYEDIT_INITIATE, ARTICLE_LOG_TYPE_COPYEDIT, $user->getUserId(), 'log.copyedit.initiate', array('copyeditorName' => $user->getFullName(), 'articleId' => $copyeditorSubmission->getArticleId())); } } }
/** * Display a summary of the status of an author's submission. */ function submission($args) { $journal =& Request::getJournal(); $user =& Request::getUser(); $articleId = isset($args[0]) ? (int) $args[0] : 0; $this->validate($articleId); $submission =& $this->submission; $this->setupTemplate(true, $articleId); $articleDao =& DAORegistry::getDAO('ArticleDAO'); if (Request::getUserVar("archive")) { $article = $articleDao->getArticle($articleId); $article->setStatus(STATUS_ARCHIVED); $article->stampStatusModified(); $articleDao->updateArticle($article); // Add log import('classes.article.log.ArticleLog'); import('classes.article.log.ArticleEventLogEntry'); ArticleLog::logEvent($articleId, ARTICLE_LOG_EDITOR_ARCHIVE, ARTICLE_LOG_TYPE_EDITOR, $articleId, 'log.editor.archived', array('articleId' => $articleId)); } $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO'); $journalSettings = $journalSettingsDao->getJournalSettings($journal->getId()); // Setting the round. $round = isset($args[1]) ? $args[1] : $submission->getCurrentRound(); $templateMgr =& TemplateManager::getManager(); $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($submission->getArticleId()); if ($publishedArticle) { $issueDao =& DAORegistry::getDAO('IssueDAO'); $issue =& $issueDao->getIssueById($publishedArticle->getIssueId()); $templateMgr->assign_by_ref('issue', $issue); } $sectionDao =& DAORegistry::getDAO('SectionDAO'); $section =& $sectionDao->getSection($submission->getSectionId()); $templateMgr->assign_by_ref('section', $section); $templateMgr->assign_by_ref('journalSettings', $journalSettings); $templateMgr->assign_by_ref('submission', $submission); $templateMgr->assign_by_ref('publishedArticle', $publishedArticle); $templateMgr->assign_by_ref('reviewAssignments', $submission->getReviewAssignments($round)); $templateMgr->assign('round', $round); $templateMgr->assign_by_ref('submissionFile', $submission->getSubmissionFile()); $templateMgr->assign_by_ref('revisedFile', $submission->getRevisedFile()); $templateMgr->assign_by_ref('suppFiles', $submission->getSuppFiles()); $authorSubmisionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $authorSubmission = $authorSubmisionDao->getAuthorSubmission($articleId); if ($authorSubmission->getSubmissionStatus() == STATUS_QUEUED_EDITING) { $templateMgr->assign_by_ref('proofView', $proofView = 1); } //%CBP% Pass repository URL also //TODO: Update to get different file versions also (include ED) $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO'); $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $CBPPlatformDao =& DAORegistry::getDAO('CBPPlatformDAO'); $submission->getAuthorFileRevisions($submission->getCurrentRound()); if ($submission->getRevisedFile()) { $submissionFile = $submission->getRevisedFile(); } else { $submissionFile = $submission->getSubmissionFile(); } $editorDecisions = $submission->getDecisions($submission->getCurrentRound()); $lastDecision = count($editorDecisions) >= 1 ? $editorDecisions[count($editorDecisions) - 1] : null; if ($submissionFile) { $fileId = $submissionFile->getFileId(); $object = $CBPPlatformDao->getFedoraObjectInformation($fileId); $objectPid = $object['fedora_namespace'] . ":" . $object['fedora_pid']; $templateMgr->assign_by_ref('repositoryObjectPid', $objectPid); $objectDsid = $object['fedora_dsid']; $templateMgr->assign_by_ref('repositoryObjectDsid', $objectDsid); } $templateMgr->assign('lastEditorDecision', $lastDecision['decision']); import('classes.submission.sectionEditor.SectionEditorSubmission'); $templateMgr->assign_by_ref('editorDecisionOptions', SectionEditorSubmission::getEditorDecisionOptions()); // Set up required Payment Related Information import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); if ($paymentManager->submissionEnabled() || $paymentManager->fastTrackEnabled() || $paymentManager->publicationEnabled()) { $templateMgr->assign('authorFees', true); $completedPaymentDAO =& DAORegistry::getDAO('OJSCompletedPaymentDAO'); if ($paymentManager->submissionEnabled()) { $templateMgr->assign_by_ref('submissionPayment', $completedPaymentDAO->getSubmissionCompletedPayment($journal->getId(), $articleId)); } if ($paymentManager->fastTrackEnabled()) { $templateMgr->assign_by_ref('fastTrackPayment', $completedPaymentDAO->getFastTrackCompletedPayment($journal->getId(), $articleId)); } if ($paymentManager->publicationEnabled()) { $templateMgr->assign_by_ref('publicationPayment', $completedPaymentDAO->getPublicationCompletedPayment($journal->getId(), $articleId)); } } $templateMgr->assign('helpTopicId', 'editorial.authorsRole'); $initialCopyeditSignoff = $submission->getSignoff('SIGNOFF_COPYEDITING_INITIAL'); $templateMgr->assign('canEditMetadata', !$initialCopyeditSignoff->getDateCompleted() && $submission->getStatus() != STATUS_PUBLISHED); $templateMgr->display('author/submission.tpl'); }
/** * Rush a new submission into the end of the editing queue. * @param $article object */ function expediteSubmission($article) { $user =& Request::getUser(); import('submission.editor.EditorAction'); import('submission.sectionEditor.SectionEditorAction'); import('submission.proofreader.ProofreaderAction'); $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO'); $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($article->getArticleId()); $submissionFile = $sectionEditorSubmission->getSubmissionFile(); // Add a long entry before doing anything. import('article.log.ArticleLog'); import('article.log.ArticleEventLogEntry'); ArticleLog::logEvent($article->getArticleId(), ARTICLE_LOG_EDITOR_EXPEDITE, ARTICLE_LOG_TYPE_EDITOR, $user->getUserId(), 'log.editor.submissionExpedited', array('editorName' => $user->getFullName(), 'articleId' => $article->getArticleId())); // 1. Ensure that an editor is assigned. $editAssignments =& $sectionEditorSubmission->getEditAssignments(); if (empty($editAssignments)) { // No editors are currently assigned; assign self. EditorAction::assignEditor($article->getArticleId(), $user->getUserId(), true); } // 2. Accept the submission and send to copyediting. $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($article->getArticleId()); if (!$sectionEditorSubmission->getCopyeditFile()) { SectionEditorAction::recordDecision($sectionEditorSubmission, SUBMISSION_EDITOR_DECISION_ACCEPT); $reviewFile = $sectionEditorSubmission->getReviewFile(); SectionEditorAction::setCopyeditFile($sectionEditorSubmission, $reviewFile->getFileId(), $reviewFile->getRevision()); } // 3. Add a galley. $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($article->getArticleId()); $galleys =& $sectionEditorSubmission->getGalleys(); if (empty($galleys)) { // No galley present -- use copyediting file. import('file.ArticleFileManager'); $copyeditFile =& $sectionEditorSubmission->getCopyeditFile(); $fileType = $copyeditFile->getFileType(); $articleFileManager =& new ArticleFileManager($article->getArticleId()); $fileId = $articleFileManager->copyPublicFile($copyeditFile->getFilePath(), $fileType); if (strstr($fileType, 'html')) { $galley =& new ArticleHTMLGalley(); } else { $galley =& new ArticleGalley(); } $galley->setArticleId($article->getArticleId()); $galley->setFileId($fileId); $galley->setLocale(Locale::getLocale()); if ($galley->isHTMLGalley()) { $galley->setLabel('HTML'); } else { if (strstr($fileType, 'pdf')) { $galley->setLabel('PDF'); } else { if (strstr($fileType, 'postscript')) { $galley->setLabel('Postscript'); } else { if (strstr($fileType, 'xml')) { $galley->setLabel('XML'); } else { $galley->setLabel(Locale::translate('common.untitled')); } } } } $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO'); $galleyDao->insertGalley($galley); } $sectionEditorSubmission->setStatus(STATUS_QUEUED); $sectionEditorSubmissionDao->updateSectionEditorSubmission($sectionEditorSubmission); }
/** * Marks layout assignment as completed. * @param $submission object * @param $send boolean */ function completeLayoutEditing($submission, $send = false) { $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $journal =& Request::getJournal(); $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $submission->getArticleId()); if ($layoutSignoff->getDateCompleted() != null) { return true; } import('classes.mail.ArticleMailTemplate'); $email = new ArticleMailTemplate($submission, 'LAYOUT_COMPLETE'); $editAssignments =& $submission->getEditAssignments(); if (empty($editAssignments)) { return; } if (!$email->isEnabled() || $send && !$email->hasErrors()) { HookRegistry::call('LayoutEditorAction::completeLayoutEditing', array(&$submission, &$editAssignments, &$email)); if ($email->isEnabled()) { $email->setAssoc(ARTICLE_EMAIL_LAYOUT_NOTIFY_COMPLETE, ARTICLE_EMAIL_TYPE_LAYOUT, $layoutSignoff->getId()); $email->send(); } $layoutSignoff->setDateCompleted(Core::getCurrentDate()); $signoffDao->updateObject($layoutSignoff); // Add log entry $user =& Request::getUser(); import('classes.article.log.ArticleLog'); import('classes.article.log.ArticleEventLogEntry'); ArticleLog::logEvent($submission->getArticleId(), ARTICLE_LOG_LAYOUT_COMPLETE, ARTICLE_LOG_TYPE_LAYOUT, $user->getId(), 'log.layout.layoutEditComplete', array('editorName' => $user->getFullName(), 'articleId' => $submission->getArticleId())); return true; } else { $user =& Request::getUser(); if (!Request::getUserVar('continued')) { $assignedSectionEditors = $email->toAssignedEditingSectionEditors($submission->getArticleId()); $assignedEditors = $email->ccAssignedEditors($submission->getArticleId()); if (empty($assignedSectionEditors) && empty($assignedEditors)) { $email->addRecipient($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $editorialContactName = $journal->getSetting('contactName'); } else { $editorialContact = array_shift($assignedSectionEditors); if (!$editorialContact) { $editorialContact = array_shift($assignedEditors); } $editorialContactName = $editorialContact->getEditorFullName(); } $paramArray = array('editorialContactName' => $editorialContactName, 'layoutEditorName' => $user->getFullName()); $email->assignParams($paramArray); } $email->displayEditForm(Request::url(null, 'layoutEditor', 'completeAssignment', 'send'), array('articleId' => $submission->getArticleId())); return false; } }
/** * Save metadata. * @param $article object * @param $request PKPRequest */ function saveMetadata($article, &$request) { $router =& $request->getRouter(); if (!HookRegistry::call('Action::saveMetadata', array(&$article))) { import('classes.submission.form.MetadataForm'); $journal =& $request->getJournal(); $metadataForm = new MetadataForm($article, $journal); $metadataForm->readInputData(); // Check for any special cases before trying to save if ($request->getUserVar('addAuthor')) { // Add an author $editData = true; $authors = $metadataForm->getData('authors'); array_push($authors, array()); $metadataForm->setData('authors', $authors); } else { if (($delAuthor = $request->getUserVar('delAuthor')) && count($delAuthor) == 1) { // Delete an author $editData = true; list($delAuthor) = array_keys($delAuthor); $delAuthor = (int) $delAuthor; $authors = $metadataForm->getData('authors'); if (isset($authors[$delAuthor]['authorId']) && !empty($authors[$delAuthor]['authorId'])) { $deletedAuthors = explode(':', $metadataForm->getData('deletedAuthors')); array_push($deletedAuthors, $authors[$delAuthor]['authorId']); $metadataForm->setData('deletedAuthors', join(':', $deletedAuthors)); } array_splice($authors, $delAuthor, 1); $metadataForm->setData('authors', $authors); if ($metadataForm->getData('primaryContact') == $delAuthor) { $metadataForm->setData('primaryContact', 0); } } else { if ($request->getUserVar('moveAuthor')) { // Move an author up/down $editData = true; $moveAuthorDir = $request->getUserVar('moveAuthorDir'); $moveAuthorDir = $moveAuthorDir == 'u' ? 'u' : 'd'; $moveAuthorIndex = (int) $request->getUserVar('moveAuthorIndex'); $authors = $metadataForm->getData('authors'); if (!($moveAuthorDir == 'u' && $moveAuthorIndex <= 0 || $moveAuthorDir == 'd' && $moveAuthorIndex >= count($authors) - 1)) { $tmpAuthor = $authors[$moveAuthorIndex]; $primaryContact = $metadataForm->getData('primaryContact'); if ($moveAuthorDir == 'u') { $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex - 1]; $authors[$moveAuthorIndex - 1] = $tmpAuthor; if ($primaryContact == $moveAuthorIndex) { $metadataForm->setData('primaryContact', $moveAuthorIndex - 1); } else { if ($primaryContact == $moveAuthorIndex - 1) { $metadataForm->setData('primaryContact', $moveAuthorIndex); } } } else { $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex + 1]; $authors[$moveAuthorIndex + 1] = $tmpAuthor; if ($primaryContact == $moveAuthorIndex) { $metadataForm->setData('primaryContact', $moveAuthorIndex + 1); } else { if ($primaryContact == $moveAuthorIndex + 1) { $metadataForm->setData('primaryContact', $moveAuthorIndex); } } } } $metadataForm->setData('authors', $authors); } } } if (isset($editData)) { $metadataForm->display(); return false; } else { if (!$metadataForm->validate()) { return $metadataForm->display(); } $metadataForm->execute($request); // Send a notification to associated users import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationUsers = $article->getAssociatedUserIds(); foreach ($notificationUsers as $userRole) { $url = $router->url($request, null, $userRole['role'], 'submission', $article->getId(), null, 'metadata'); $notificationManager->createNotification($userRole['id'], 'notification.type.metadataModified', $article->getProposalId(), $url, 1, NOTIFICATION_TYPE_METADATA_MODIFIED); } //Added by AIM, Jan 20, 2012 $notificationUsers = array(); $roleDao =& DAORegistry::getDAO('RoleDAO'); $editors = $roleDao->getUsersByRoleId(ROLE_ID_EDITOR); while (!$editors->eof()) { $editor =& $editors->next(); $notificationUsers[] = array('id' => $editor->getId(), 'role' => $roleDao->getRolePath(ROLE_ID_EDITOR)); unset($editor); } //print_r($notificationUsers); die(); foreach ($notificationUsers as $userRole) { $url = $router->url($request, null, $userRole['role'], 'submission', $article->getId(), null, 'metadata'); $notificationManager->createNotification($userRole['id'], 'notification.type.metadataModified', $article->getProposalId(), $url, 1, NOTIFICATION_TYPE_METADATA_MODIFIED); } // Add log entry $user =& $request->getUser(); import('classes.article.log.ArticleLog'); import('classes.article.log.ArticleEventLogEntry'); ArticleLog::logEvent($article->getId(), ARTICLE_LOG_METADATA_UPDATE, ARTICLE_LOG_TYPE_DEFAULT, 0, 'log.editor.metadataModified', array('editorName' => $user->getFullName())); return true; } } }
/** * Upload the annotated version of an article. * @param $reviewId int * @param $reviewerSubmission object * @param $request object */ function uploadReviewerVersion($reviewId, $reviewerSubmission, $request) { import('classes.file.ArticleFileManager'); $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewAssignment =& $reviewAssignmentDao->getById($reviewId); $articleFileManager = new ArticleFileManager($reviewAssignment->getSubmissionId()); // Only upload the file if the reviewer has yet to submit a recommendation // and if review forms are not used if (($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation() === '') && !$reviewAssignment->getCancelled()) { $fileName = 'upload'; if ($articleFileManager->uploadedFileExists($fileName)) { HookRegistry::call('ReviewerAction::uploadReviewFile', array(&$reviewAssignment)); if ($reviewAssignment->getReviewerFileId() != null) { $fileId = $articleFileManager->uploadReviewFile($fileName, $reviewAssignment->getReviewerFileId()); } else { $fileId = $articleFileManager->uploadReviewFile($fileName); } } } if (isset($fileId) && $fileId != 0) { $reviewAssignment->setReviewerFileId($fileId); $reviewAssignment->stampModified(); $reviewAssignmentDao->updateReviewAssignment($reviewAssignment); $userDao =& DAORegistry::getDAO('UserDAO'); $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId()); // Add log import('classes.article.log.ArticleLog'); ArticleLog::logEvent($request, $reviewerSubmission, ARTICLE_LOG_REVIEW_FILE, 'log.review.reviewerFile', array('reviewId' => $reviewAssignment->getId())); } }
/** * Assign a layout editor to a submission. * @param $submission object * @param $editorId int user ID of the new layout editor */ function assignLayoutEditor($submission, $editorId) { if (HookRegistry::call('SectionEditorAction::assignLayoutEditor', array(&$submission, &$editorId))) { return; } $layoutAssignment =& $submission->getLayoutAssignment(); import('article.log.ArticleLog'); import('article.log.ArticleEventLogEntry'); if ($layoutAssignment->getEditorId()) { ArticleLog::logEvent($submission->getArticleId(), ARTICLE_LOG_LAYOUT_UNASSIGN, ARTICLE_LOG_TYPE_LAYOUT, $layoutAssignment->getLayoutId(), 'log.layout.layoutEditorUnassigned', array('editorName' => $layoutAssignment->getEditorFullName(), 'articleId' => $submission->getArticleId())); } $layoutAssignment->setEditorId($editorId); $layoutAssignment->setDateNotified(null); $layoutAssignment->setDateUnderway(null); $layoutAssignment->setDateCompleted(null); $layoutAssignment->setDateAcknowledged(null); $layoutDao =& DAORegistry::getDAO('LayoutAssignmentDAO'); $layoutDao->updateLayoutAssignment($layoutAssignment); $layoutAssignment =& $layoutDao->getLayoutAssignmentById($layoutAssignment->getLayoutId()); ArticleLog::logEvent($submission->getArticleId(), ARTICLE_LOG_LAYOUT_ASSIGN, ARTICLE_LOG_TYPE_LAYOUT, $layoutAssignment->getLayoutId(), 'log.layout.layoutEditorAssigned', array('editorName' => $layoutAssignment->getEditorFullName(), 'articleId' => $submission->getArticleId())); }
/** * Save changes to article. */ function execute() { $articleDao =& DAORegistry::getDAO('ArticleDAO'); $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $sectionDao =& DAORegistry::getDAO('SectionDAO'); $ercReviewersDao =& DAORegistry::getDAO('ErcReviewersDAO'); $institutionDao =& DAORegistry::getDAO('InstitutionDAO'); $journal = Request::getJournal(); $user = Request::getUser(); // Update article $article =& $this->article; if ($article->getDateSubmitted() == null) { $year = substr(Core::getCurrentDate(), 0, 4); $countyear = $articleDao->getSubmissionsForYearCount($year) + 1; $pSponsor = $article->getArticlePrimarySponsor(); $institution = $institutionDao->getInstitutionById($pSponsor->getInstitutionId()); $article->setProposalId($year . '-' . $countyear . '-' . $institution->getInstitutionAcronym()); } if ($this->getData('commentsToEditor') != '') { $article->setCommentsToEditor($this->getData('commentsToEditor')); } $article->setDateSubmitted(Core::getCurrentDate()); $article->setSubmissionProgress(0); $article->stampStatusModified(); $articleDao->updateArticle($article); // Designate this as the review version by default. $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $authorSubmission =& $authorSubmissionDao->getAuthorSubmission($article->getId()); AuthorAction::designateReviewVersion($authorSubmission, true); unset($authorSubmission); $copyeditInitialSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $article->getId()); $copyeditAuthorSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $article->getId()); $copyeditFinalSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $article->getId()); $copyeditInitialSignoff->setUserId(0); $copyeditAuthorSignoff->setUserId($user->getId()); $copyeditFinalSignoff->setUserId(0); $signoffDao->updateObject($copyeditInitialSignoff); $signoffDao->updateObject($copyeditAuthorSignoff); $signoffDao->updateObject($copyeditFinalSignoff); $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $article->getId()); $layoutSignoff->setUserId(0); $signoffDao->updateObject($layoutSignoff); $proofAuthorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_AUTHOR', ASSOC_TYPE_ARTICLE, $article->getId()); $proofProofreaderSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $article->getId()); $proofLayoutEditorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $article->getId()); $proofAuthorSignoff->setUserId($user->getId()); $proofProofreaderSignoff->setUserId(0); $proofLayoutEditorSignoff->setUserId(0); $signoffDao->updateObject($proofAuthorSignoff); $signoffDao->updateObject($proofProofreaderSignoff); $signoffDao->updateObject($proofLayoutEditorSignoff); $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO'); $sectionEditors =& $sectionEditorsDao->getEditorsBySectionId($journal->getId(), $article->getSectionId()); $user =& Request::getUser(); // Update search index import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::indexArticleMetadata($article); ArticleSearchIndex::indexArticleFiles($article); // Send author notification email import('classes.mail.ArticleMailTemplate'); $mail = new ArticleMailTemplate($article, null, 'SUBMISSION_ACK', null, null, null, false); foreach ($sectionEditors as $sectionEditor) { // If one of the secretary is the chair of the committee, send from the chair, if not, take the last secretary in the array $from = $mail->getFrom(); if ($ercReviewersDao->isErcReviewer($journal->getId(), $sectionEditor->getId(), REVIEWER_CHAIR)) { $mail->setFrom($sectionEditor->getEmail(), $sectionEditor->getFullName()); } elseif ($from['email'] == $user->getEmail()) { $mail->setFrom($sectionEditor->getEmail(), $sectionEditor->getFullName()); } $mail->addBcc($sectionEditor->getEmail(), $sectionEditor->getFullName()); unset($sectionEditor); } if ($mail->isEnabled()) { $mail->addRecipient($user->getEmail(), $user->getFullName()); if ($journal->getSetting('copySubmissionAckSpecified')) { $copyAddress = $journal->getSetting('copySubmissionAckAddress'); if (!empty($copyAddress)) { $mail->addBcc($copyAddress); } } $section = $sectionDao->getSection($article->getSectionId()); $mail->assignParams(array('authorName' => $user->getFullName(), 'authorUsername' => $user->getUsername(), 'address' => $sectionDao->getSettingValue($article->getSectionId(), 'address'), 'bankAccount' => $sectionDao->getSettingValue($article->getSectionId(), 'bankAccount'), 'proposalId' => $article->getProposalId(), 'submissionUrl' => Request::url(null, 'author', 'submission', $article->getId()))); $mail->send(); } // Send a regular notification to section editors $lastDecision = $article->getLastSectionDecision(); switch ($lastDecision->getReviewType()) { case REVIEW_TYPE_INITIAL: if ($lastDecision->getRound() == 1) { $message = 'notification.type.articleSubmitted.initialReview'; } else { $message = 'notification.type.articleReSubmitted.initialReview'; } break; case REVIEW_TYPE_PR: if ($lastDecision->getRound() == 1) { $message = 'notification.type.articleSubmitted.continuingReview'; } else { $message = 'notification.type.articleReSubmitted.continuingReview'; } break; case REVIEW_TYPE_AMENDMENT: if ($lastDecision->getRound() == 1) { $message = 'notification.type.articleSubmitted.PAAmendmentReview'; } else { $message = 'notification.type.articleReSubmitted.PAAmendmentReview'; } break; case REVIEW_TYPE_SAE: if ($lastDecision->getRound() == 1) { $message = 'notification.type.articleSubmitted.SAE'; } else { $message = 'notification.type.articleReSubmitted.SAE'; } break; case REVIEW_TYPE_FR: if ($lastDecision->getRound() == 1) { $message = 'notification.type.articleSubmitted.EOS'; } else { $message = 'notification.type.articleReSubmitted.EOS'; } break; } import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $url = Request::url($journal->getPath(), 'sectionEditor', 'submission', array($article->getId(), 'submissionReview')); foreach ($sectionEditors as $sectionEditor) { $notificationManager->createNotification($sectionEditor->getId(), $message, $article->getProposalId(), $url, 1, NOTIFICATION_TYPE_ARTICLE_SUBMITTED); } import('classes.article.log.ArticleLog'); import('classes.article.log.ArticleEventLogEntry'); if ($lastDecision->getRound() == 1) { $message = 'log.author.submitted'; } else { $message = 'log.author.resubmitted'; } ArticleLog::logEvent($this->articleId, ARTICLE_LOG_ARTICLE_SUBMIT, ARTICLE_LOG_TYPE_AUTHOR, $user->getId(), $message, array('submissionId' => $article->getProposalId(), 'authorName' => $user->getFullName(), 'reviewType' => Locale::translate($lastDecision->getReviewTypeKey()))); return $this->articleId; }
/** * Author completes editor / author review. * @param $authorSubmission object */ function completeAuthorCopyedit($authorSubmission, $send = false) { $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $journal =& Request::getJournal(); if ($authorSubmission->getCopyeditorDateAuthorCompleted() != null) { return true; } $user =& Request::getUser(); import('mail.ArticleMailTemplate'); $email =& new ArticleMailTemplate($authorSubmission, 'COPYEDIT_AUTHOR_COMPLETE'); $editAssignments = $authorSubmission->getEditAssignments(); $copyeditor =& $authorSubmission->getCopyeditor(); if (!$email->isEnabled() || $send && !$email->hasErrors()) { HookRegistry::call('AuthorAction::completeAuthorCopyedit', array(&$authorSubmission, &$email)); if ($email->isEnabled()) { $email->setAssoc(ARTICLE_EMAIL_COPYEDIT_NOTIFY_AUTHOR_COMPLETE, ARTICLE_EMAIL_TYPE_COPYEDIT, $authorSubmission->getArticleId()); $email->send(); } $authorSubmission->setCopyeditorDateAuthorCompleted(Core::getCurrentDate()); $authorSubmission->setCopyeditorDateFinalNotified(Core::getCurrentDate()); $authorSubmissionDao->updateAuthorSubmission($authorSubmission); // Add log entry import('article.log.ArticleLog'); import('article.log.ArticleEventLogEntry'); ArticleLog::logEvent($authorSubmission->getArticleId(), ARTICLE_LOG_COPYEDIT_REVISION, ARTICLE_LOG_TYPE_AUTHOR, $user->getUserId(), 'log.copyedit.authorFile'); return true; } else { if (!Request::getUserVar('continued')) { if (isset($copyeditor)) { $email->addRecipient($copyeditor->getEmail(), $copyeditor->getFullName()); $assignedSectionEditors = $email->ccAssignedEditingSectionEditors($authorSubmission->getArticleId()); $assignedEditors = $email->ccAssignedEditors($authorSubmission->getArticleId()); if (empty($assignedSectionEditors) && empty($assignedEditors)) { $email->addCc($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $editorName = $journal->getSetting('contactName'); } else { $editor = array_shift($assignedSectionEditors); if (!$editor) { $editor = array_shift($assignedEditors); } $editorName = $editor->getEditorFullName(); } } else { $assignedSectionEditors = $email->toAssignedEditingSectionEditors($authorSubmission->getArticleId()); $assignedEditors = $email->ccAssignedEditors($authorSubmission->getArticleId()); if (empty($assignedSectionEditors) && empty($assignedEditors)) { $email->addRecipient($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $editorName = $journal->getSetting('contactName'); } else { $editor = array_shift($assignedSectionEditors); if (!$editor) { $editor = array_shift($assignedEditors); } $editorName = $editor->getEditorFullName(); } } $paramArray = array('editorialContactName' => isset($copyeditor) ? $copyeditor->getFullName() : $editorName, 'authorName' => $user->getFullName()); $email->assignParams($paramArray); } $email->displayEditForm(Request::url(null, 'author', 'completeAuthorCopyedit', 'send'), array('articleId' => $authorSubmission->getArticleId())); return false; } }
/** * Save changes to article. */ function execute() { $articleDao =& DAORegistry::getDAO('ArticleDAO'); $journal = Request::getJournal(); // Update article $article =& $this->article; if ($this->getData('commentsToEditor') != '') { $article->setCommentsToEditor($this->getData('commentsToEditor')); } $article->setDateSubmitted(Core::getCurrentDate()); $article->setSubmissionProgress(0); $article->stampStatusModified(); $articleDao->updateArticle($article); // Designate this as the review version by default. $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $authorSubmission =& $authorSubmissionDao->getAuthorSubmission($article->getArticleId()); AuthorAction::designateReviewVersion($authorSubmission, true); unset($authorSubmission); // Create additional submission mangement records $copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO'); $copyeditorSubmission =& new CopyeditorSubmission(); $copyeditorSubmission->setArticleId($article->getArticleId()); $copyeditorSubmission->setCopyeditorId(0); $copyeditorSubmissionDao->insertCopyeditorSubmission($copyeditorSubmission); $layoutDao =& DAORegistry::getDAO('LayoutAssignmentDAO'); $layoutAssignment =& new LayoutAssignment(); $layoutAssignment->setArticleId($article->getArticleId()); $layoutAssignment->setEditorId(0); $layoutDao->insertLayoutAssignment($layoutAssignment); $proofAssignmentDao =& DAORegistry::getDAO('ProofAssignmentDAO'); $proofAssignment =& new ProofAssignment(); $proofAssignment->setArticleId($article->getArticleId()); $proofAssignment->setProofreaderId(0); $proofAssignmentDao->insertProofAssignment($proofAssignment); $sectionEditors = $this->assignEditors($article); $user =& Request::getUser(); // Update search index import('search.ArticleSearchIndex'); ArticleSearchIndex::indexArticleMetadata($article); ArticleSearchIndex::indexArticleFiles($article); // Send author notification email import('mail.ArticleMailTemplate'); $mail =& new ArticleMailTemplate($article, 'SUBMISSION_ACK'); $mail->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); if ($mail->isEnabled()) { $mail->addRecipient($user->getEmail(), $user->getFullName()); // If necessary, BCC the acknowledgement to someone. if ($journal->getSetting('copySubmissionAckPrimaryContact')) { $mail->addBcc($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); } if ($journal->getSetting('copySubmissionAckSpecified')) { $copyAddress = $journal->getSetting('copySubmissionAckAddress'); if (!empty($copyAddress)) { $mail->addBcc($copyAddress); } } // Also BCC automatically assigned section editors foreach ($sectionEditors as $sectionEditorEntry) { $sectionEditor =& $sectionEditorEntry['user']; $mail->addBcc($sectionEditor->getEmail(), $sectionEditor->getFullName()); unset($sectionEditor); } $mail->assignParams(array('authorName' => $user->getFullName(), 'authorUsername' => $user->getUsername(), 'editorialContactSignature' => $journal->getSetting('contactName') . "\n" . $journal->getJournalTitle(), 'submissionUrl' => Request::url(null, 'author', 'submission', $article->getArticleId()))); $mail->send(); } import('article.log.ArticleLog'); import('article.log.ArticleEventLogEntry'); ArticleLog::logEvent($this->articleId, ARTICLE_LOG_ARTICLE_SUBMIT, ARTICLE_LOG_TYPE_AUTHOR, $user->getUserId(), 'log.author.submitted', array('submissionId' => $article->getArticleId(), 'authorName' => $user->getFullName())); return $this->articleId; }
/** * Upload the copyedited version of an article. * @param $copyeditorSubmission object * @param $copyeditStage string * @param $request object */ function uploadCopyeditVersion($copyeditorSubmission, $copyeditStage, $request) { import('classes.file.ArticleFileManager'); $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO'); $copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO'); $signoffDao =& DAORegistry::getDAO('SignoffDAO'); if ($copyeditStage == 'initial') { $signoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $copyeditorSubmission->getId()); } else { if ($copyeditStage == 'final') { $signoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $copyeditorSubmission->getId()); } } // Only allow an upload if they're in the initial or final copyediting // stages. if ($copyeditStage == 'initial' && ($signoff->getDateNotified() == null || $signoff->getDateCompleted() != null)) { return; } else { if ($copyeditStage == 'final' && ($signoff->getDateNotified() == null || $signoff->getDateCompleted() != null)) { return; } else { if ($copyeditStage != 'initial' && $copyeditStage != 'final') { return; } } } $articleFileManager = new ArticleFileManager($copyeditorSubmission->getId()); $user =& $request->getUser(); $fileName = 'upload'; if ($articleFileManager->uploadedFileExists($fileName)) { HookRegistry::call('CopyeditorAction::uploadCopyeditVersion', array(&$copyeditorSubmission)); if ($signoff->getFileId() != null) { $fileId = $articleFileManager->uploadCopyeditFile($fileName, $copyeditorSubmission->getFileBySignoffType('SIGNOFF_COPYEDITING_INITIAL', true)); } else { $fileId = $articleFileManager->uploadCopyeditFile($fileName); } } if (isset($fileId) && $fileId != 0) { $signoff->setFileId($fileId); $signoff->setFileRevision($articleFileDao->getRevisionNumber($fileId)); $signoffDao->updateObject($signoff); // Add log import('classes.article.log.ArticleLog'); ArticleLog::logEvent($request, $copyeditorSubmission, ARTICLE_LOG_COPYEDITOR_FILE, 'log.copyedit.copyeditorFile', array('copyeditorName' => $user->getFullName(), 'fileId' => $fileId)); } }
/** * Save metadata. * @param $article object */ function saveMetadata($article) { if (!HookRegistry::call('Action::saveMetadata', array(&$article))) { import("submission.form.MetadataForm"); $metadataForm =& new MetadataForm($article); $metadataForm->readInputData(); if (!$metadataForm->validate()) { return $metadataForm->display(); } // Check for any special cases before trying to save if (Request::getUserVar('addAuthor')) { // Add an author $editData = true; $authors = $metadataForm->getData('authors'); array_push($authors, array()); $metadataForm->setData('authors', $authors); } else { if (($delAuthor = Request::getUserVar('delAuthor')) && count($delAuthor) == 1) { // Delete an author $editData = true; list($delAuthor) = array_keys($delAuthor); $delAuthor = (int) $delAuthor; $authors = $metadataForm->getData('authors'); if (isset($authors[$delAuthor]['authorId']) && !empty($authors[$delAuthor]['authorId'])) { $deletedAuthors = explode(':', $metadataForm->getData('deletedAuthors')); array_push($deletedAuthors, $authors[$delAuthor]['authorId']); $metadataForm->setData('deletedAuthors', join(':', $deletedAuthors)); } array_splice($authors, $delAuthor, 1); $metadataForm->setData('authors', $authors); if ($metadataForm->getData('primaryContact') == $delAuthor) { $metadataForm->setData('primaryContact', 0); } } else { if (Request::getUserVar('moveAuthor')) { // Move an author up/down $editData = true; $moveAuthorDir = Request::getUserVar('moveAuthorDir'); $moveAuthorDir = $moveAuthorDir == 'u' ? 'u' : 'd'; $moveAuthorIndex = (int) Request::getUserVar('moveAuthorIndex'); $authors = $metadataForm->getData('authors'); if (!($moveAuthorDir == 'u' && $moveAuthorIndex <= 0 || $moveAuthorDir == 'd' && $moveAuthorIndex >= count($authors) - 1)) { $tmpAuthor = $authors[$moveAuthorIndex]; $primaryContact = $metadataForm->getData('primaryContact'); if ($moveAuthorDir == 'u') { $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex - 1]; $authors[$moveAuthorIndex - 1] = $tmpAuthor; if ($primaryContact == $moveAuthorIndex) { $metadataForm->setData('primaryContact', $moveAuthorIndex - 1); } else { if ($primaryContact == $moveAuthorIndex - 1) { $metadataForm->setData('primaryContact', $moveAuthorIndex); } } } else { $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex + 1]; $authors[$moveAuthorIndex + 1] = $tmpAuthor; if ($primaryContact == $moveAuthorIndex) { $metadataForm->setData('primaryContact', $moveAuthorIndex + 1); } else { if ($primaryContact == $moveAuthorIndex + 1) { $metadataForm->setData('primaryContact', $moveAuthorIndex); } } } } $metadataForm->setData('authors', $authors); } } } if (isset($editData)) { $metadataForm->display(); return false; } else { $metadataForm->execute(); // Add log entry $user =& Request::getUser(); import('article.log.ArticleLog'); import('article.log.ArticleEventLogEntry'); ArticleLog::logEvent($article->getArticleId(), ARTICLE_LOG_METADATA_UPDATE, ARTICLE_LOG_TYPE_DEFAULT, 0, 'log.editor.metadataModified', array('editorName' => $user->getFullName())); return true; } } }
function handleArticleNode(&$journal, &$articleNode, &$issue, &$section, &$article, &$publishedArticle, &$errors, &$user, $isCommandLine, &$dependentItems) { $errors = array(); $journalSupportedLocales = array_keys($journal->getSupportedLocaleNames()); // => journal locales must be set up before $journalPrimaryLocale = $journal->getPrimaryLocale(); $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $articleDao =& DAORegistry::getDAO('ArticleDAO'); $article = new Article(); $article->setLocale($journalPrimaryLocale); // FIXME in bug #5543 $article->setJournalId($journal->getId()); $article->setUserId($user->getId()); $article->setSectionId($section->getId()); $article->setStatus(STATUS_PUBLISHED); $article->setSubmissionProgress(0); $article->setDateSubmitted(Core::getCurrentDate()); $article->stampStatusModified(); $titleExists = false; for ($index = 0; $node = $articleNode->getChildByName('title', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleTitleLocaleUnsupported', array('articleTitle' => $node->getValue(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setTitle($node->getValue(), $locale); $titleExists = true; } if (!$titleExists || $article->getTitle($journalPrimaryLocale) == "") { $errors[] = array('plugins.importexport.native.import.error.articleTitleMissing', array('issueTitle' => $issue->getIssueIdentification(), 'sectionTitle' => $section->getLocalizedTitle())); return false; } for ($index = 0; $node = $articleNode->getChildByName('abstract', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleAbstractLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setAbstract($node->getValue(), $locale); } if ($indexingNode = $articleNode->getChildByName('indexing')) { for ($index = 0; $node = $indexingNode->getChildByName('discipline', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleDisciplineLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setDiscipline($node->getValue(), $locale); } for ($index = 0; $node = $indexingNode->getChildByName('type', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleTypeLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setType($node->getValue(), $locale); } for ($index = 0; $node = $indexingNode->getChildByName('subject', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleSubjectLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setSubject($node->getValue(), $locale); } for ($index = 0; $node = $indexingNode->getChildByName('subject_class', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleSubjectClassLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setSubjectClass($node->getValue(), $locale); } if ($coverageNode = $indexingNode->getChildByName('coverage')) { for ($index = 0; $node = $coverageNode->getChildByName('geographical', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleCoverageGeoLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setCoverageGeo($node->getValue(), $locale); } for ($index = 0; $node = $coverageNode->getChildByName('chronological', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleCoverageChronLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setCoverageChron($node->getValue(), $locale); } for ($index = 0; $node = $coverageNode->getChildByName('sample', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleCoverageSampleLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setCoverageSample($node->getValue(), $locale); } } } for ($index = 0; $node = $articleNode->getChildByName('sponsor', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleSponsorLocaleUnsupported', array('articleTitle' => $article->getLocalizedTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setSponsor($node->getValue(), $locale); } if ($node = $articleNode->getChildByName('pages')) { $article->setPages($node->getValue()); } if ($language = $articleNode->getAttribute('language')) { $article->setLanguage($language); } /* --- Handle authors --- */ $hasErrors = false; for ($index = 0; $node = $articleNode->getChildByName('author', $index); $index++) { if (!NativeImportDom::handleAuthorNode($journal, $node, $issue, $section, $article, $authorErrors)) { $errors = array_merge($errors, $authorErrors); $hasErrors = true; } } if ($hasErrors) { return false; } /* --- Handle covers --- */ for ($index = 0; $node = $articleNode->getChildByName('cover', $index); $index++) { if (!NativeImportDom::handleArticleCoverNode($journal, $node, $article, $coverErrors, $isCommandLine)) { $errors = array_merge($errors, $coverErrors); $hasErrors = true; } } for ($index = 0; $node = $articleNode->getChildByName('id', $index); $index++) { switch ($node->getAttribute('type')) { case 'doi': $article->setStoredDOI($node->getValue()); break; } } $articleDao->insertArticle($article); $dependentItems[] = array('article', $article); // Create submission mangement records $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $initialCopyeditSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $article->getId()); $initialCopyeditSignoff->setUserId(0); $signoffDao->updateObject($initialCopyeditSignoff); $authorCopyeditSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $article->getId()); $authorCopyeditSignoff->setUserId(0); $signoffDao->updateObject($authorCopyeditSignoff); $finalCopyeditSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $article->getId()); $finalCopyeditSignoff->setUserId(0); $signoffDao->updateObject($finalCopyeditSignoff); $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $article->getId()); $layoutSignoff->setUserId(0); $signoffDao->updateObject($layoutSignoff); $authorProofSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_AUTHOR', ASSOC_TYPE_ARTICLE, $article->getId()); $authorProofSignoff->setUserId(0); $signoffDao->updateObject($authorProofSignoff); $proofreaderProofSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $article->getId()); $proofreaderProofSignoff->setUserId(0); $signoffDao->updateObject($proofreaderProofSignoff); $layoutProofSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $article->getId()); $layoutProofSignoff->setUserId(0); $signoffDao->updateObject($layoutProofSignoff); // Log the import in the article event log. import('classes.article.log.ArticleLog'); import('classes.article.log.ArticleEventLogEntry'); ArticleLog::logEvent($article->getId(), ARTICLE_LOG_ARTICLE_IMPORT, ARTICLE_LOG_TYPE_DEFAULT, 0, 'log.imported', array('userName' => $user->getFullName(), 'articleId' => $article->getId())); // Insert published article entry. $publishedArticle = new PublishedArticle(); $publishedArticle->setArticleId($article->getId()); $publishedArticle->setIssueId($issue->getId()); if ($node = $articleNode->getChildByName('date_published')) { $publishedDate = strtotime($node->getValue()); if ($publishedDate === -1) { $errors[] = array('plugins.importexport.native.import.error.invalidDate', array('value' => $node->getValue())); return false; } else { $publishedArticle->setDatePublished($publishedDate); } } $node = $articleNode->getChildByName('open_access'); $publishedArticle->setAccessStatus($node ? ARTICLE_ACCESS_OPEN : ARTICLE_ACCESS_ISSUE_DEFAULT); $publishedArticle->setSeq(REALLY_BIG_NUMBER); $publishedArticle->setViews(0); $publishedArticle->setPublicArticleId($articleNode->getAttribute('public_id')); $publishedArticle->setPubId($publishedArticleDao->insertPublishedArticle($publishedArticle)); $publishedArticleDao->resequencePublishedArticles($section->getId(), $issue->getId()); /* --- Galleys (html or otherwise handled simultaneously) --- */ import('classes.file.ArticleFileManager'); $articleFileManager = new ArticleFileManager($article->getId()); /* --- Handle galleys --- */ $hasErrors = false; $galleyCount = 0; for ($index = 0; $index < count($articleNode->children); $index++) { $node = $articleNode->children[$index]; if ($node->getName() == 'htmlgalley') { $isHtml = true; } elseif ($node->getName() == 'galley') { $isHtml = false; } else { continue; } if (!NativeImportDom::handleGalleyNode($journal, $node, $issue, $section, $article, $galleyErrors, $isCommandLine, $isHtml, $galleyCount, $articleFileManager)) { $errors = array_merge($errors, $galleyErrors); $hasErrors = true; } $galleyCount++; unset($node); } if ($hasErrors) { return false; } /* --- Handle supplemental files --- */ $hasErrors = false; for ($index = 0; $node = $articleNode->getChildByName('supplemental_file', $index); $index++) { if (!NativeImportDom::handleSuppFileNode($journal, $node, $issue, $section, $article, $suppFileErrors, $isCommandLine, $articleFileManager)) { $errors = array_merge($errors, $suppFileErrors); $hasErrors = true; } } if ($hasErrors) { return false; } // Index the inserted article. import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::indexArticleMetadata($article); ArticleSearchIndex::indexArticleFiles($article); return true; }
/** * Assign a layout editor to a submission. * @param $submission object * @param $editorId int user ID of the new layout editor */ function assignLayoutEditor($submission, $editorId) { $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); if (HookRegistry::call('SectionEditorAction::assignLayoutEditor', array(&$submission, &$editorId))) { return; } import('classes.article.log.ArticleLog'); import('classes.article.log.ArticleEventLogEntry'); $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $submission->getArticleId()); $layoutProofSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $submission->getArticleId()); if ($layoutSignoff->getUserId()) { $layoutEditor =& $userDao->getUser($layoutSignoff->getUserId()); ArticleLog::logEvent($submission->getArticleId(), ARTICLE_LOG_LAYOUT_UNASSIGN, ARTICLE_LOG_TYPE_LAYOUT, $layoutSignoff->getId(), 'log.layout.layoutEditorUnassigned', array('editorName' => $layoutEditor->getFullName(), 'articleId' => $submission->getArticleId())); } $layoutSignoff->setUserId($editorId); $layoutSignoff->setDateNotified(null); $layoutSignoff->setDateUnderway(null); $layoutSignoff->setDateCompleted(null); $layoutSignoff->setDateAcknowledged(null); $layoutProofSignoff->setUserId($editorId); $layoutProofSignoff->setDateNotified(null); $layoutProofSignoff->setDateUnderway(null); $layoutProofSignoff->setDateCompleted(null); $layoutProofSignoff->setDateAcknowledged(null); $signoffDao->updateObject($layoutSignoff); $signoffDao->updateObject($layoutProofSignoff); $layoutEditor =& $userDao->getUser($layoutSignoff->getUserId()); ArticleLog::logEvent($submission->getArticleId(), ARTICLE_LOG_LAYOUT_ASSIGN, ARTICLE_LOG_TYPE_LAYOUT, $layoutSignoff->getId(), 'log.layout.layoutEditorAssigned', array('editorName' => $layoutEditor->getFullName(), 'articleId' => $submission->getArticleId())); }
/** * Upload a review on behalf of its reviewer. * @param $reviewId int */ function uploadReviewForReviewer($reviewId, $article, $request) { $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $user =& $request->getUser(); $reviewAssignment =& $reviewAssignmentDao->getById($reviewId); $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId(), true); if (HookRegistry::call('SectionEditorAction::uploadReviewForReviewer', array(&$reviewAssignment, &$reviewer))) { return; } // Upload the review file. import('classes.file.ArticleFileManager'); $articleFileManager = new ArticleFileManager($reviewAssignment->getSubmissionId()); // Only upload the file if the reviewer has yet to submit a recommendation if (($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation() === '') && !$reviewAssignment->getCancelled()) { $fileName = 'upload'; if ($articleFileManager->uploadedFileExists($fileName)) { if ($reviewAssignment->getReviewerFileId() != null) { $fileId = $articleFileManager->uploadReviewFile($fileName, $reviewAssignment->getReviewerFileId()); } else { $fileId = $articleFileManager->uploadReviewFile($fileName); } } } if (isset($fileId) && $fileId != 0) { // Only confirm the review for the reviewer if // he has not previously done so. if ($reviewAssignment->getDateConfirmed() == null) { $reviewAssignment->setDeclined(0); $reviewAssignment->setDateConfirmed(Core::getCurrentDate()); } $reviewAssignment->setReviewerFileId($fileId); $reviewAssignment->stampModified(); $reviewAssignmentDao->updateReviewAssignment($reviewAssignment); // Add log import('classes.article.log.ArticleLog'); ArticleLog::logEvent($request, $article, ARTICLE_LOG_REVIEW_FILE_BY_PROXY, 'log.review.reviewFileByProxy', array('reviewerName' => $reviewer->getFullName(), 'round' => $reviewAssignment->getRound(), 'userName' => $user->getFullName(), 'reviewId' => $reviewAssignment->getId())); } }
/** * Rush a new submission into the end of the editing queue. * @param $article object */ function expediteSubmission($article, $request) { $user =& $request->getUser(); import('classes.submission.editor.EditorAction'); import('classes.submission.sectionEditor.SectionEditorAction'); import('classes.submission.proofreader.ProofreaderAction'); $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO'); $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($article->getId()); $submissionFile = $sectionEditorSubmission->getSubmissionFile(); // Add a log entry before doing anything. import('classes.article.log.ArticleLog'); import('classes.article.log.ArticleEventLogEntry'); ArticleLog::logEvent($request, $article, ARTICLE_LOG_EDITOR_EXPEDITE, 'log.editor.submissionExpedited', array('editorName' => $user->getFullName())); // 1. Ensure that an editor is assigned. $editAssignments =& $sectionEditorSubmission->getEditAssignments(); if (empty($editAssignments)) { // No editors are currently assigned; assign self. EditorAction::assignEditor($article->getId(), $user->getId(), true, false, $request); } // 2. Accept the submission and send to copyediting. $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($article->getId()); if (!$sectionEditorSubmission->getFileBySignoffType('SIGNOFF_COPYEDITING_INITIAL', true)) { SectionEditorAction::recordDecision($sectionEditorSubmission, SUBMISSION_EDITOR_DECISION_ACCEPT, $request); $reviewFile = $sectionEditorSubmission->getReviewFile(); SectionEditorAction::setCopyeditFile($sectionEditorSubmission, $reviewFile->getFileId(), $reviewFile->getRevision(), $request); } // 3. Add a galley. $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($article->getId()); $galleys =& $sectionEditorSubmission->getGalleys(); if (empty($galleys)) { // No galley present -- use copyediting file. import('classes.file.ArticleFileManager'); $copyeditFile =& $sectionEditorSubmission->getFileBySignoffType('SIGNOFF_COPYEDITING_INITIAL'); $fileType = $copyeditFile->getFileType(); $articleFileManager = new ArticleFileManager($article->getId()); $fileId = $articleFileManager->copyPublicFile($copyeditFile->getFilePath(), $fileType); if (strstr($fileType, 'html')) { $galley = new ArticleHTMLGalley(); } else { $galley = new ArticleGalley(); } $galley->setArticleId($article->getId()); $galley->setFileId($fileId); $galley->setLocale(AppLocale::getLocale()); if ($galley->isHTMLGalley()) { $galley->setLabel('HTML'); } else { if (strstr($fileType, 'pdf')) { $galley->setLabel('PDF'); } else { if (strstr($fileType, 'postscript')) { $galley->setLabel('Postscript'); } else { if (strstr($fileType, 'xml')) { $galley->setLabel('XML'); } else { $galley->setLabel(__('common.untitled')); } } } } $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO'); $galleyDao->insertGalley($galley); // Update file search index import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::updateFileIndex($article->getId(), ARTICLE_SEARCH_GALLEY_FILE, $fileId); } $sectionEditorSubmission->setStatus(STATUS_QUEUED); $sectionEditorSubmissionDao->updateSectionEditorSubmission($sectionEditorSubmission); }
/** * Save changes to article. */ function execute() { $articleDao =& DAORegistry::getDAO('ArticleDAO'); $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $journal = Request::getJournal(); $user = Request::getUser(); // Update article $article =& $this->article; if ($this->getData('commentsToEditor') != '') { $article->setCommentsToEditor($this->getData('commentsToEditor')); } $article->setDateSubmitted(Core::getCurrentDate()); $article->setSubmissionProgress(0); $article->stampStatusModified(); $articleDao->updateArticle($article); // Designate this as the review version by default. $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $authorSubmission =& $authorSubmissionDao->getAuthorSubmission($article->getId()); AuthorAction::designateReviewVersion($authorSubmission, true); unset($authorSubmission); $copyeditInitialSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $article->getId()); $copyeditAuthorSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $article->getId()); $copyeditFinalSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $article->getId()); $copyeditInitialSignoff->setUserId(0); $copyeditAuthorSignoff->setUserId($user->getId()); $copyeditFinalSignoff->setUserId(0); $signoffDao->updateObject($copyeditInitialSignoff); $signoffDao->updateObject($copyeditAuthorSignoff); $signoffDao->updateObject($copyeditFinalSignoff); $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $article->getId()); $layoutSignoff->setUserId(0); $signoffDao->updateObject($layoutSignoff); $proofAuthorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_AUTHOR', ASSOC_TYPE_ARTICLE, $article->getId()); $proofProofreaderSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $article->getId()); $proofLayoutEditorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $article->getId()); $proofAuthorSignoff->setUserId($user->getId()); $proofProofreaderSignoff->setUserId(0); $proofLayoutEditorSignoff->setUserId(0); $signoffDao->updateObject($proofAuthorSignoff); $signoffDao->updateObject($proofProofreaderSignoff); $signoffDao->updateObject($proofLayoutEditorSignoff); $sectionEditors = $this->assignEditors($article); $user =& Request::getUser(); // Update search index import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::indexArticleMetadata($article); ArticleSearchIndex::indexArticleFiles($article); // Send author notification email import('classes.mail.ArticleMailTemplate'); $mail = new ArticleMailTemplate($article, 'SUBMISSION_ACK', null, null, null, false); $mail->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); if ($mail->isEnabled()) { $mail->addRecipient($user->getEmail(), $user->getFullName()); // If necessary, BCC the acknowledgement to someone. if ($journal->getSetting('copySubmissionAckPrimaryContact')) { $mail->addBcc($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); } if ($journal->getSetting('copySubmissionAckSpecified')) { $copyAddress = $journal->getSetting('copySubmissionAckAddress'); if (!empty($copyAddress)) { $mail->addBcc($copyAddress); } } // Also BCC automatically assigned section editors foreach ($sectionEditors as $sectionEditorEntry) { $sectionEditor =& $sectionEditorEntry['user']; $mail->addBcc($sectionEditor->getEmail(), $sectionEditor->getFullName()); unset($sectionEditor); } $mail->assignParams(array('authorName' => $user->getFullName(), 'authorUsername' => $user->getUsername(), 'editorialContactSignature' => $journal->getSetting('contactName') . "\n" . $journal->getLocalizedTitle(), 'submissionUrl' => Request::url(null, 'author', 'submission', $article->getId()))); $mail->send(); } import('classes.article.log.ArticleLog'); import('classes.article.log.ArticleEventLogEntry'); ArticleLog::logEvent($this->articleId, ARTICLE_LOG_ARTICLE_SUBMIT, ARTICLE_LOG_TYPE_AUTHOR, $user->getId(), 'log.author.submitted', array('submissionId' => $article->getId(), 'authorName' => $user->getFullName())); return $this->articleId; }
function handleArticleNode(&$journal, &$articleNode, &$issue, &$section, &$article, &$publishedArticle, &$errors, &$user, $isCommandLine, &$dependentItems) { $errors = array(); $journalSupportedLocales = array_keys($journal->getSupportedLocaleNames()); // => journal locales must be set up before $journalPrimaryLocale = $journal->getPrimaryLocale(); $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $articleDao =& DAORegistry::getDAO('ArticleDAO'); $article = new Article(); $article->setJournalId($journal->getJournalId()); $article->setUserId($user->getUserId()); $article->setSectionId($section->getSectionId()); $article->setStatus(STATUS_PUBLISHED); $article->setSubmissionProgress(0); $article->setDateSubmitted(Core::getCurrentDate()); $article->stampStatusModified(); $titleExists = false; for ($index = 0; $node = $articleNode->getChildByName('title', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleTitleLocaleUnsupported', array('articleTitle' => $node->getValue(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setTitle($node->getValue(), $locale); $titleExists = true; } if (!$titleExists || $article->getTitle($journalPrimaryLocale) == "") { $errors[] = array('plugins.importexport.native.import.error.articleTitleMissing', array('issueTitle' => $issue->getIssueIdentification(), 'sectionTitle' => $section->getSectionTitle())); return false; } for ($index = 0; $node = $articleNode->getChildByName('abstract', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleAbstractLocaleUnsupported', array('articleTitle' => $article->getArticleTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setAbstract($node->getValue(), $locale); } if ($indexingNode = $articleNode->getChildByName('indexing')) { for ($index = 0; $node = $indexingNode->getChildByName('discipline', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleDisciplineLocaleUnsupported', array('articleTitle' => $article->getArticleTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setDiscipline($node->getValue(), $locale); } for ($index = 0; $node = $indexingNode->getChildByName('type', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleTypeLocaleUnsupported', array('articleTitle' => $article->getArticleTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setType($node->getValue(), $locale); } for ($index = 0; $node = $indexingNode->getChildByName('subject', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleSubjectLocaleUnsupported', array('articleTitle' => $article->getArticleTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setSubject($node->getValue(), $locale); } for ($index = 0; $node = $indexingNode->getChildByName('subject_class', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleSubjectClassLocaleUnsupported', array('articleTitle' => $article->getArticleTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setSubjectClass($node->getValue(), $locale); } if ($coverageNode = $indexingNode->getChildByName('coverage')) { for ($index = 0; $node = $coverageNode->getChildByName('geographical', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleCoverageGeoLocaleUnsupported', array('articleTitle' => $article->getArticleTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setCoverageGeo($node->getValue(), $locale); } for ($index = 0; $node = $coverageNode->getChildByName('chronological', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleCoverageChronLocaleUnsupported', array('articleTitle' => $article->getArticleTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setCoverageChron($node->getValue(), $locale); } for ($index = 0; $node = $coverageNode->getChildByName('sample', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleCoverageSampleLocaleUnsupported', array('articleTitle' => $article->getArticleTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setCoverageSample($node->getValue(), $locale); } } } for ($index = 0; $node = $articleNode->getChildByName('sponsor', $index); $index++) { $locale = $node->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.articleSponsorLocaleUnsupported', array('articleTitle' => $article->getArticleTitle(), 'issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setSponsor($node->getValue(), $locale); } if ($node = $articleNode->getChildByName('pages')) { $article->setPages($node->getValue()); } if ($language = $articleNode->getAttribute('language')) { $article->setLanguage($language); } /* --- Handle authors --- */ $hasErrors = false; for ($index = 0; $node = $articleNode->getChildByName('author', $index); $index++) { if (!NativeImportDom::handleAuthorNode($journal, $node, $issue, $section, $article, $authorErrors)) { $errors = array_merge($errors, $authorErrors); $hasErrors = true; } } if ($hasErrors) { return false; } $articleDao->insertArticle($article); $dependentItems[] = array('article', $article); // Create submission mangement records $copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO'); $copyeditorSubmission =& new CopyeditorSubmission(); $copyeditorSubmission->setArticleId($article->getArticleId()); $copyeditorSubmission->setCopyeditorId(0); $copyeditorSubmissionDao->insertCopyeditorSubmission($copyeditorSubmission); $layoutDao =& DAORegistry::getDAO('LayoutAssignmentDAO'); $layoutAssignment =& new LayoutAssignment(); $layoutAssignment->setArticleId($article->getArticleId()); $layoutAssignment->setEditorId(0); $layoutAssignment->setDateAcknowledged(Core::getCurrentDate()); // Make sure that imported articles go directly into the Archive. FIXME? $layoutDao->insertLayoutAssignment($layoutAssignment); $proofAssignmentDao =& DAORegistry::getDAO('ProofAssignmentDAO'); $proofAssignment =& new ProofAssignment(); $proofAssignment->setArticleId($article->getArticleId()); $proofAssignment->setProofreaderId(0); $proofAssignmentDao->insertProofAssignment($proofAssignment); // Log the import in the article event log. import('article.log.ArticleLog'); import('article.log.ArticleEventLogEntry'); ArticleLog::logEvent($article->getArticleId(), ARTICLE_LOG_ARTICLE_IMPORT, ARTICLE_LOG_TYPE_DEFAULT, 0, 'log.imported', array('userName' => $user->getFullName(), 'articleId' => $article->getArticleId())); // Insert published article entry. $publishedArticle =& new PublishedArticle(); $publishedArticle->setArticleId($article->getArticleId()); $publishedArticle->setIssueId($issue->getIssueId()); if ($node = $articleNode->getChildByName('date_published')) { $publishedDate = strtotime($node->getValue()); if ($publishedDate === -1) { $errors[] = array('plugins.importexport.native.import.error.invalidDate', array('value' => $node->getValue())); return false; } else { $publishedArticle->setDatePublished($publishedDate); } } $node = $articleNode->getChildByName('open_access'); $publishedArticle->setAccessStatus($node ? 1 : 0); $publishedArticle->setSeq(REALLY_BIG_NUMBER); $publishedArticle->setViews(0); $publishedArticle->setPublicArticleId($articleNode->getAttribute('public_id')); $publishedArticle->setPubId($publishedArticleDao->insertPublishedArticle($publishedArticle)); $publishedArticleDao->resequencePublishedArticles($section->getSectionId(), $issue->getIssueId()); /* --- Galleys (html or otherwise handled simultaneously) --- */ import('file.ArticleFileManager'); $articleFileManager =& new ArticleFileManager($article->getArticleId()); /* --- Handle galleys --- */ $hasErrors = false; $galleyCount = 0; for ($index = 0; $index < count($articleNode->children); $index++) { $node =& $articleNode->children[$index]; if ($node->getName() == 'htmlgalley') { $isHtml = true; } elseif ($node->getName() == 'galley') { $isHtml = false; } else { continue; } if (!NativeImportDom::handleGalleyNode($journal, $node, $issue, $section, $article, $galleyErrors, $isCommandLine, $isHtml, $galleyCount, $articleFileManager)) { $errors = array_merge($errors, $galleyErrors); $hasErrors = true; } $galleyCount++; } if ($hasErrors) { return false; } /* --- Handle supplemental files --- */ $hasErrors = false; for ($index = 0; $node = $articleNode->getChildByName('supplemental_file', $index); $index++) { if (!NativeImportDom::handleSuppFileNode($journal, $node, $issue, $section, $article, $suppFileErrors, $isCommandLine, $articleFileManager)) { $errors = array_merge($errors, $suppFileErrors); $hasErrors = true; } } if ($hasErrors) { return false; } // Index the inserted article. import('search.ArticleSearchIndex'); ArticleSearchIndex::indexArticleMetadata($article); ArticleSearchIndex::indexArticleFiles($article); return true; }