/** * Rebuild the search index. * @return boolean */ function rebuildSearchIndex() { import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->rebuildIndex(); return true; }
/** * indexes the files associated with a submission. * @param $submission Submission * @param $submissionFile SubmissionFile */ function indexSubmissionFiles($submission, $submissionFile) { // update the submission's search index if this submission is published. if ($submission->getDatePublished()) { import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::articleFilesChanged($submission); } }
/** * @copydoc PKPManageFileApiHandler::removeFileIndex() */ function removeFileIndex($submission, $submissionFile) { // update the submission's search index if this was a proof file if ($submissionFile->getFileStage() == SUBMISSION_FILE_PROOF) { import('lib.pkp.classes.search.SubmissionSearch'); import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::deleteTextIndex($submission->getId(), SUBMISSION_SEARCH_GALLEY_FILE, $submissionFile->getFileId()); } }
/** * Rebuild the search index for all articles in all journals. */ function execute() { // If we have an argument that this must be a journal path. $journal = null; if (count($this->argv)) { $journalPath = array_shift($this->argv); $journalDao =& DAORegistry::getDAO('JournalDAO'); $journal =& $journalDao->getJournalByPath($journalPath); if (!$journal) { die(__('search.cli.rebuildIndex.unknownJournal', array('journalPath' => $journalPath)) . "\n"); } } // Register a router hook so that we can construct // useful URLs to journal content. HookRegistry::register('Request::getBaseUrl', array(&$this, 'callbackBaseUrl')); // Let the search implementation re-build the index. $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->rebuildIndex(true, $journal); }
/** * Delete a submission. * @param $args array * @param $request PKPRequest */ function deleteSubmission($args, $request) { $articleId = (int) array_shift($args); $this->validate($request, $articleId); $authorSubmission =& $this->submission; $this->setupTemplate($request, true); // If the submission is incomplete, allow the author to delete it. if ($authorSubmission->getSubmissionProgress() != 0) { import('classes.file.ArticleFileManager'); $articleFileManager = new ArticleFileManager($articleId); $articleFileManager->deleteArticleTree(); $articleDao =& DAORegistry::getDAO('ArticleDAO'); $articleDao->deleteArticleById($articleId); import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->articleDeleted($articleId); $articleSearchIndex->articleChangesFinished(); } $request->redirect(null, null, 'index'); }
/** * Save changes to submission. * @param $request PKPRequest */ function execute($request) { parent::execute($request); $submission = $this->getSubmission(); $submissionDao = Application::getSubmissionDAO(); $submission->setSectionId($this->getData('sectionId')); $submissionDao->updateObject($submission); if ($submission->getDatePublished()) { import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::articleMetadataChanged($submission); } }
/** * @see Filter::process() * @param $document DOMDocument|string * @return array Array of imported documents */ function &process(&$document) { $importedObjects =& parent::process($document); // Index imported content import('classes.search.ArticleSearchIndex'); foreach ($importedObjects as $submission) { assert(is_a($submission, 'Submission')); ArticleSearchIndex::articleMetadataChanged($submission); ArticleSearchIndex::submissionFilesChanged($submission); } ArticleSearchIndex::articleChangesFinished(); return $importedObjects; }
/** * Rebuild the search index for all articles in all journals. */ function execute() { // Check whether we have (optional) switches. $switches = array(); while (count($this->argv) && substr($this->argv[0], 0, 1) == '-') { $switches[] = array_shift($this->argv); } // If we have another argument that this must be a journal path. $journal = null; if (count($this->argv)) { $journalPath = array_shift($this->argv); $journalDao = DAORegistry::getDAO('JournalDAO'); $journal = $journalDao->getByPath($journalPath); if (!$journal) { die(__('search.cli.rebuildIndex.unknownJournal', array('journalPath' => $journalPath)) . "\n"); } } // Register a router hook so that we can construct // useful URLs to journal content. HookRegistry::register('Request::getBaseUrl', array($this, 'callbackBaseUrl')); // Let the search implementation re-build the index. $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->rebuildIndex(true, $journal, $switches); }
/** * Save the metadata. */ function execute($request) { parent::execute($request); $submission = $this->getSubmission(); $submissionDao = Application::getSubmissionDAO(); $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticle = $publishedArticleDao->getPublishedArticleByArticleId($submission->getId(), null, false); $isExistingEntry = $publishedArticle ? true : false; if ($isExistingEntry) { // Update the search index for this published article. import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::articleMetadataChanged($submission); } $submissionDao->updateObject($submission); }
/** * Save changes to article. * @param $request PKPRequest * @return int the article ID */ function execute(&$request) { $articleDao =& DAORegistry::getDAO('ArticleDAO'); $authorDao =& DAORegistry::getDAO('AuthorDAO'); $sectionDao =& DAORegistry::getDAO('SectionDAO'); $citationDao =& DAORegistry::getDAO('CitationDAO'); /* @var $citationDao CitationDAO */ $article =& $this->article; // Retrieve the previous citation list for comparison. $previousRawCitationList = $article->getCitations(); // Update article $article->setTitle($this->getData('title'), null); // Localized $section =& $sectionDao->getSection($article->getSectionId()); $article->setAbstract($this->getData('abstract'), null); // Localized import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); if ($publicFileManager->uploadedFileExists(COVER_PAGE_IMAGE_NAME)) { $journal = Request::getJournal(); $originalFileName = $publicFileManager->getUploadedFileName(COVER_PAGE_IMAGE_NAME); $type = $publicFileManager->getUploadedFileType(COVER_PAGE_IMAGE_NAME); $newFileName = 'cover_article_' . $this->article->getId() . '_' . $this->getFormLocale() . $publicFileManager->getImageExtension($type); $publicFileManager->uploadJournalFile($journal->getId(), COVER_PAGE_IMAGE_NAME, $newFileName); $article->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale()); $article->setFileName($newFileName, $this->getFormLocale()); // Store the image dimensions. list($width, $height) = getimagesize($publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $newFileName); $article->setWidth($width, $this->getFormLocale()); $article->setHeight($height, $this->getFormLocale()); } $article->setCoverPageAltText($this->getData('coverPageAltText'), null); // Localized $showCoverPage = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('showCoverPage')); foreach (array_keys($this->getData('coverPageAltText')) as $locale) { if (!array_key_exists($locale, $showCoverPage)) { $showCoverPage[$locale] = 0; } } $article->setShowCoverPage($showCoverPage, null); // Localized $hideCoverPageToc = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageToc')); foreach (array_keys($this->getData('coverPageAltText')) as $locale) { if (!array_key_exists($locale, $hideCoverPageToc)) { $hideCoverPageToc[$locale] = 0; } } $article->setHideCoverPageToc($hideCoverPageToc, null); // Localized $hideCoverPageAbstract = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageAbstract')); foreach (array_keys($this->getData('coverPageAltText')) as $locale) { if (!array_key_exists($locale, $hideCoverPageAbstract)) { $hideCoverPageAbstract[$locale] = 0; } } $article->setHideCoverPageAbstract($hideCoverPageAbstract, null); // Localized $article->setDiscipline($this->getData('discipline'), null); // Localized $article->setSubjectClass($this->getData('subjectClass'), null); // Localized $article->setSubject($this->getData('subject'), null); // Localized $article->setCoverageGeo($this->getData('coverageGeo'), null); // Localized $article->setCoverageChron($this->getData('coverageChron'), null); // Localized $article->setCoverageSample($this->getData('coverageSample'), null); // Localized $article->setType($this->getData('type'), null); // Localized $article->setLanguage($this->getData('language')); // Localized $article->setSponsor($this->getData('sponsor'), null); // Localized $article->setCitations($this->getData('citations')); if ($this->isEditor) { $article->setHideAuthor($this->getData('hideAuthor') ? $this->getData('hideAuthor') : 0); } // consider the additional field names from the public identifer plugins import('classes.plugins.PubIdPluginHelper'); $pubIdPluginHelper = new PubIdPluginHelper(); $pubIdPluginHelper->execute($this, $article); // Update authors $authors = $this->getData('authors'); for ($i = 0, $count = count($authors); $i < $count; $i++) { if ($authors[$i]['authorId'] > 0) { // Update an existing author $author =& $authorDao->getAuthor($authors[$i]['authorId'], $article->getId()); $isExistingAuthor = true; } else { // Create a new author if (checkPhpVersion('5.0.0')) { // *5488* PHP4 Requires explicit instantiation-by-reference $author = new Author(); } else { $author =& new Author(); } $isExistingAuthor = false; } if ($author != null) { $author->setSubmissionId($article->getId()); $author->setFirstName($authors[$i]['firstName']); $author->setMiddleName($authors[$i]['middleName']); $author->setLastName($authors[$i]['lastName']); $author->setAffiliation($authors[$i]['affiliation'], null); // Localized $author->setCountry($authors[$i]['country']); $author->setEmail($authors[$i]['email']); $author->setData('orcid', $authors[$i]['orcid']); $author->setUrl($authors[$i]['url']); if (array_key_exists('competingInterests', $authors[$i])) { $author->setCompetingInterests($authors[$i]['competingInterests'], null); // Localized } $author->setBiography($authors[$i]['biography'], null); // Localized $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0); $author->setSequence($authors[$i]['seq']); HookRegistry::call('Submission::Form::MetadataForm::Execute', array(&$author, &$authors[$i])); if ($isExistingAuthor) { $authorDao->updateAuthor($author); } else { $authorDao->insertAuthor($author); } unset($author); } } // Remove deleted authors $deletedAuthors = preg_split('/:/', $this->getData('deletedAuthors'), -1, PREG_SPLIT_NO_EMPTY); for ($i = 0, $count = count($deletedAuthors); $i < $count; $i++) { $authorDao->deleteAuthorById($deletedAuthors[$i], $article->getId()); } if ($this->isEditor) { $article->setCopyrightHolder($this->getData('copyrightHolder'), null); $article->setCopyrightYear($this->getData('copyrightYear')); $article->setLicenseURL($this->getData('licenseURL')); } parent::execute(); // Save the article $articleDao->updateArticle($article); // Update search index import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->articleMetadataChanged($article); $articleSearchIndex->articleChangesFinished(); // Update references list if it changed. $rawCitationList = $article->getCitations(); if ($previousRawCitationList != $rawCitationList) { $citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $article->getId(), $rawCitationList); } return $article->getId(); }
/** * Save changes to the supplementary file. * @return int the supplementary file ID */ function execute($fileName = null) { import("file.ArticleFileManager"); $articleFileManager =& new ArticleFileManager($this->article->getArticleId()); $suppFileDao =& DAORegistry::getDAO('SuppFileDAO'); $fileName = isset($fileName) ? $fileName : 'uploadSuppFile'; if (isset($this->suppFile)) { $suppFile =& $this->suppFile; // Upload file, if file selected. if ($articleFileManager->uploadedFileExists($fileName)) { $articleFileManager->uploadSuppFile($fileName, $suppFile->getFileId()); import('search.ArticleSearchIndex'); ArticleSearchIndex::updateFileIndex($this->article->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $suppFile->getFileId()); } // Index metadata ArticleSearchIndex::indexSuppFileMetadata($suppFile); // Update existing supplementary file $this->setSuppFileData($suppFile); $suppFileDao->updateSuppFile($suppFile); } else { // Upload file, if file selected. if ($articleFileManager->uploadedFileExists($fileName)) { $fileId = $articleFileManager->uploadSuppFile($fileName); import('search.ArticleSearchIndex'); ArticleSearchIndex::updateFileIndex($this->article->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId); } else { $fileId = 0; } // Insert new supplementary file $suppFile =& new SuppFile(); $suppFile->setArticleId($this->article->getArticleId()); $suppFile->setFileId($fileId); $this->setSuppFileData($suppFile); $suppFileDao->insertSuppFile($suppFile); $this->suppFileId = $suppFile->getSuppFileId(); } return $this->suppFileId; }
/** * Publish issue * @param $args array * @param $request Request */ function publishIssue($args, $request) { $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE); $issueId = $issue->getId(); $journal = $request->getJournal(); $journalId = $journal->getId(); $articleSearchIndex = null; if (!$issue->getPublished()) { $confirmationText = __('editor.issues.confirmPublish'); import('controllers.grid.pubIds.form.AssignPublicIdentifiersForm'); $formTemplate = $this->getAssignPublicIdentifiersFormTemplate(); $assignPublicIdentifiersForm = new AssignPublicIdentifiersForm($formTemplate, $issue, true, $confirmationText); if (!$request->getUserVar('confirmed')) { // Display assign pub ids modal $assignPublicIdentifiersForm->initData($args, $request); return new JSONMessage(true, $assignPublicIdentifiersForm->fetch($request)); } // Asign pub ids $assignPublicIdentifiersForm->readInputData(); $assignPublicIdentifiersForm->execute($request); // Set the status of any attendant queued articles to STATUS_PUBLISHED. $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $articleDao = DAORegistry::getDAO('ArticleDAO'); $publishedArticles = $publishedArticleDao->getPublishedArticles($issueId); foreach ($publishedArticles as $publishedArticle) { $article = $articleDao->getById($publishedArticle->getId()); if ($article && $article->getStatus() == STATUS_QUEUED) { $article->setStatus(STATUS_PUBLISHED); $article->stampStatusModified(); $articleDao->updateObject($article); if (!$articleSearchIndex) { import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); } $articleSearchIndex->articleMetadataChanged($publishedArticle); } // delete article tombstone $tombstoneDao = DAORegistry::getDAO('DataObjectTombstoneDAO'); $tombstoneDao->deleteByDataObjectId($article->getId()); } } $issue->setCurrent(1); $issue->setPublished(1); $issue->setDatePublished(Core::getCurrentDate()); // If subscriptions with delayed open access are enabled then // update open access date according to open access delay policy if ($journal->getSetting('publishingMode') == PUBLISHING_MODE_SUBSCRIPTION && $journal->getSetting('enableDelayedOpenAccess')) { $delayDuration = $journal->getSetting('delayedOpenAccessDuration'); $delayYears = (int) floor($delayDuration / 12); $delayMonths = (int) fmod($delayDuration, 12); $curYear = date('Y'); $curMonth = date('n'); $curDay = date('j'); $delayOpenAccessYear = $curYear + $delayYears + (int) floor(($curMonth + $delayMonths) / 12); $delayOpenAccessMonth = (int) fmod($curMonth + $delayMonths, 12); $issue->setAccessStatus(ISSUE_ACCESS_SUBSCRIPTION); $issue->setOpenAccessDate(date('Y-m-d H:i:s', mktime(0, 0, 0, $delayOpenAccessMonth, $curDay, $delayOpenAccessYear))); } $issueDao = DAORegistry::getDAO('IssueDAO'); $issueDao->updateCurrent($journalId, $issue); if ($articleSearchIndex) { $articleSearchIndex->articleChangesFinished(); } // Send a notification to associated users import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationUsers = array(); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $allUsers = $userGroupDao->getUsersByContextId($journalId); while ($user = $allUsers->next()) { $notificationUsers[] = array('id' => $user->getId()); } foreach ($notificationUsers as $userRole) { $notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_PUBLISHED_ISSUE, $journalId); } $notificationManager->sendToMailingList($request, $notificationManager->createNotification($request, UNSUBSCRIBED_USER_NOTIFICATION, NOTIFICATION_TYPE_PUBLISHED_ISSUE, $journalId)); return DAO::getDataChangedEvent(); }
/** * 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; }
/** * Save the metadata and store the catalog data for this published * monograph. */ function execute($request) { parent::execute($request); $submission = $this->getSubmission(); $context = $request->getContext(); $waivePublicationFee = $request->getUserVar('waivePublicationFee') ? true : false; if ($waivePublicationFee) { $markAsPaid = $request->getUserVar('markAsPaid'); import('classes.payment.ojs.OJSPaymentManager'); $paymentManager = new OJSPaymentManager($request); $user = $request->getUser(); // Get a list of author user IDs $authorUserIds = array(); $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); $submitterAssignments = $stageAssignmentDao->getBySubmissionAndRoleId($submission->getId(), ROLE_ID_AUTHOR); $submitterAssignment = $submitterAssignments->next(); assert($submitterAssignment); // At least one author should be assigned $queuedPayment =& $paymentManager->createQueuedPayment($context->getId(), PAYMENT_TYPE_PUBLICATION, $markAsPaid ? $submitterAssignment->getUserId() : $user->getId(), $submission->getId(), $markAsPaid ? $context->getSetting('publicationFee') : 0, $markAsPaid ? $context->getSetting('currency') : ''); $paymentManager->queuePayment($queuedPayment); // Since this is a waiver, fulfill the payment immediately $paymentManager->fulfillQueuedPayment($request, $queuedPayment, $markAsPaid ? 'ManualPayment' : 'Waiver'); } else { // Get the issue for publication. $issueDao = DAORegistry::getDAO('IssueDAO'); $issueId = $this->getData('issueId'); $issue = $issueDao->getById($issueId, $context->getId()); $sectionDao = DAORegistry::getDAO('SectionDAO'); $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticle = $publishedArticleDao->getPublishedArticleByArticleId($submission->getId(), null, false); /* @var $publishedArticle PublishedArticle */ if ($publishedArticle) { if (!$issue || !$issue->getPublished()) { $fromIssue = $issueDao->getById($publishedArticle->getIssueId(), $context->getId()); if ($fromIssue->getPublished()) { // Insert article tombstone import('classes.article.ArticleTombstoneManager'); $articleTombstoneManager = new ArticleTombstoneManager(); $articleTombstoneManager->insertArticleTombstone($submission, $context); } } } import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); // define the access status for the article if none is set. $accessStatus = $this->getData('accessStatus') != '' ? $this->getData('accessStatus') : ARTICLE_ACCESS_ISSUE_DEFAULT; $articleDao = DAORegistry::getDAO('ArticleDAO'); if (!is_null($this->getData('pages'))) { $submission->setPages($this->getData('pages')); } if ($issue) { // Schedule against an issue. if ($publishedArticle) { $publishedArticle->setIssueId($issueId); $publishedArticle->setSequence(REALLY_BIG_NUMBER); $publishedArticle->setDatePublished($this->getData('datePublished')); $publishedArticle->setAccessStatus($accessStatus); $publishedArticleDao->updatePublishedArticle($publishedArticle); // Re-index the published article metadata. $articleSearchIndex->articleMetadataChanged($publishedArticle); } else { $publishedArticle = $publishedArticleDao->newDataObject(); $publishedArticle->setId($submission->getId()); $publishedArticle->setIssueId($issueId); $publishedArticle->setDatePublished(Core::getCurrentDate()); $publishedArticle->setSequence(REALLY_BIG_NUMBER); $publishedArticle->setAccessStatus($accessStatus); $publishedArticleDao->insertObject($publishedArticle); // If we're using custom section ordering, and if this is the first // article published in a section, make sure we enter a custom ordering // for it. (Default at the end of the list.) if ($sectionDao->customSectionOrderingExists($issueId)) { if ($sectionDao->getCustomSectionOrder($issueId, $submission->getSectionId()) === null) { $sectionDao->insertCustomSectionOrder($issueId, $submission->getSectionId(), REALLY_BIG_NUMBER); $sectionDao->resequenceCustomSectionOrders($issueId); } } // Index the published article metadata and files for the first time. $articleSearchIndex->articleMetadataChanged($publishedArticle); $articleSearchIndex->submissionFilesChanged($publishedArticle); } } else { if ($publishedArticle) { // This was published elsewhere; make sure we don't // mess up sequencing information. $issueId = $publishedArticle->getIssueId(); $publishedArticleDao->deletePublishedArticleByArticleId($submission->getId()); // Delete the article from the search index. $articleSearchIndex->submissionFileDeleted($submission->getId()); } } if ($this->getData('attachPermissions')) { $submission->setCopyrightYear($this->getData('copyrightYear')); $submission->setCopyrightHolder($this->getData('copyrightHolder'), null); // Localized $submission->setLicenseURL($this->getData('licenseURL')); } else { $submission->setCopyrightYear(null); $submission->setCopyrightHolder(null, null); $submission->setLicenseURL(null); } // Resequence the articles. $publishedArticleDao->resequencePublishedArticles($submission->getSectionId(), $issueId); $submission->stampStatusModified(); if ($issue && $issue->getPublished()) { $submission->setStatus(STATUS_PUBLISHED); // delete article tombstone $tombstoneDao = DAORegistry::getDAO('DataObjectTombstoneDAO'); $tombstoneDao->deleteByDataObjectId($submission->getId()); } else { $submission->setStatus(STATUS_QUEUED); } $articleDao->updateObject($submission); $articleSearchIndex->articleChangesFinished(); } }
/** * Changes the section. * @param $submission object * @param $sectionId int */ function updateSection($submission, $sectionId) { if (HookRegistry::call('SectionEditorAction::updateSection', array(&$submission, &$sectionId))) { return; } $submissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO'); $submission->setSectionId($sectionId); // FIXME validate this ID? $submissionDao->updateSectionEditorSubmission($submission); // Reindex the submission (may be required to update section-specific ranking). $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->articleMetadataChanged($submission); $articleSearchIndex->articleChangesFinished(); }
/** * Rebuild the search index for all articles in all journals. */ function execute() { ArticleSearchIndex::rebuildIndex(true); }
/** * Save settings. */ function execute() { $articleDao = DAORegistry::getDAO('ArticleDAO'); $signoffDao = DAORegistry::getDAO('SignoffDAO'); $sectionEditorSubmissionDao = DAORegistry::getDAO('SectionEditorSubmissionDAO'); $application = PKPApplication::getApplication(); $request = $this->request; $user = $request->getUser(); $router = $request->getRouter(); $journal = $router->getContext($request); $article = $articleDao->newDataObject(); $article->setLocale($journal->getPrimaryLocale()); // FIXME in bug #5543 $article->setUserId($user->getId()); $article->setJournalId($journal->getId()); $article->setSectionId($this->getData('sectionId')); $article->setLanguage($this->getData('language')); $article->setTitle($this->getData('title'), null); // Localized $article->setAbstract($this->getData('abstract'), null); // Localized $article->setDiscipline($this->getData('discipline'), null); // Localized $article->setSubjectClass($this->getData('subjectClass'), null); // Localized $article->setSubject($this->getData('subject'), null); // Localized $article->setCoverageGeo($this->getData('coverageGeo'), null); // Localized $article->setCoverageChron($this->getData('coverageChron'), null); // Localized $article->setCoverageSample($this->getData('coverageSample'), null); // Localized $article->setType($this->getData('type'), null); // Localized $article->setSponsor($this->getData('sponsor'), null); // Localized $article->setCitations($this->getData('citations')); $article->setPages($this->getData('pages')); // Set some default values so the ArticleDAO doesn't complain when adding this article $article->setDateSubmitted(Core::getCurrentDate()); $article->setStatus(STATUS_PUBLISHED); $article->setSubmissionProgress(0); $article->stampStatusModified(); $article->setCurrentRound(1); $article->setFastTracked(1); $article->setHideAuthor(0); $article->setCommentsStatus(0); // Insert the article to get it's ID $articleDao->insertObject($article); $articleId = $article->getId(); // Add authors $authors = $this->getData('authors'); for ($i = 0, $count = count($authors); $i < $count; $i++) { if ($authors[$i]['authorId'] > 0) { // Update an existing author $author =& $authorDao->getAuthor($authors[$i]['authorId'], $articleId); $isExistingAuthor = true; } else { // Create a new author $author = new Author(); $isExistingAuthor = false; } if ($author != null) { $author->setSubmissionId($articleId); $author->setFirstName($authors[$i]['firstName']); $author->setMiddleName($authors[$i]['middleName']); $author->setLastName($authors[$i]['lastName']); if (array_key_exists('affiliation', $authors[$i])) { $author->setAffiliation($authors[$i]['affiliation'], null); } $author->setCountry($authors[$i]['country']); $author->setEmail($authors[$i]['email']); $author->setUrl($authors[$i]['url']); if (array_key_exists('competingInterests', $authors[$i])) { $author->setCompetingInterests($authors[$i]['competingInterests'], null); } $author->setBiography($authors[$i]['biography'], null); $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0); $author->setSequence($authors[$i]['seq']); if ($isExistingAuthor == false) { $authorDao = DAORegistry::getDAO('AuthorDAO'); /* @var $authorDao AuthorDAO */ $authorDao->insertObject($author); } } } // Add the submission files as galleys import('lib.pkp.classes.file.TemporaryFileManager'); import('classes.file.ArticleFileManager'); $tempFileIds = $this->getData('tempFileId'); $temporaryFileManager = new TemporaryFileManager(); $articleFileManager = new ArticleFileManager($articleId); $designatedPrimary = false; foreach (array_keys($tempFileIds) as $locale) { $temporaryFile = $temporaryFileManager->getFile($tempFileIds[$locale], $user->getId()); $fileId = null; if ($temporaryFile) { $fileId = $articleFileManager->temporaryFileToArticleFile($temporaryFile, SUBMISSION_FILE_SUBMISSION); $fileType = $temporaryFile->getFileType(); if (strstr($fileType, 'html')) { import('classes.article.ArticleHTMLGalley'); $galley = new ArticleHTMLGalley(); } else { import('classes.article.ArticleGalley'); $galley = new ArticleGalley(); } $galley->setArticleId($articleId); $galley->setFileId($fileId); $galley->setLocale($locale); 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); if (!$designatedPrimary) { $article->setSubmissionFileId($fileId); if ($locale == $journal->getPrimaryLocale()) { // Used to make sure that *some* file // is designated Review Version, but // preferrably the primary locale. $designatedPrimary = true; } } } // Update file search index import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); if (isset($galley)) { $articleSearchIndex->articleFileChanged($galley->getArticleId(), SUBMISSION_SEARCH_GALLEY_FILE, $galley->getFileId()); } $articleSearchIndex->articleChangesFinished(); } // Designate this as the review version by default. $authorSubmissionDao = DAORegistry::getDAO('AuthorSubmissionDAO'); $authorSubmission =& $authorSubmissionDao->getAuthorSubmission($articleId); import('classes.submission.author.AuthorAction'); AuthorAction::designateReviewVersion($authorSubmission, true); // Accept the submission $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($articleId); $articleFileManager = new ArticleFileManager($articleId); import('classes.submission.sectionEditor.SectionEditorAction'); assert(false); // FIXME: $decisionLabels missing from call below. SectionEditorAction::recordDecision($this->request, $sectionEditorSubmission, SUBMISSION_EDITOR_DECISION_ACCEPT); import('classes.author.form.submit.AuthorSubmitForm'); AuthorSubmitForm::assignEditors($article); $articleDao->updateObject($article); // Add to end of editing queue import('classes.submission.editor.EditorAction'); if (isset($galley)) { EditorAction::expediteSubmission($article, $this->request); } if ($this->getData('destination') == "issue") { // Add to an existing issue $issueId = $this->getData('issueId'); $this->scheduleForPublication($articleId, $issueId); } // Import the references list. $citationDao = DAORegistry::getDAO('CitationDAO'); $rawCitationList = $article->getCitations(); $citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $articleId, $rawCitationList); // Index article. import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->articleMetadataChanged($article); $articleSearchIndex->articleChangesFinished(); }
/** * Rebuild the article search index. * Note: Rebuilds index for _all_ journals (non-optimal, but shouldn't be a problem) * Based on code from tools/rebuildSearchIndex.php */ function rebuildSearchIndex() { if ($this->hasOption('verbose')) { printf("Rebuilding search index\n"); } ArticleSearchIndex::rebuildIndex(); }
/** * Rebuild the search index. * @return boolean */ function rebuildSearchIndex() { import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::rebuildIndex(); return true; }
/** * @covers ArticleSearchIndex */ public function testIndexSubmissionFilesViaPluginHook() { // Diverting to the search plugin hook. HookRegistry::register('ArticleSearchIndex::submissionFilesChanged', array($this, 'callbackIndexSubmissionFiles')); // The file DAOs should not be called. $this->registerFileDAOs(false); // Simulate indexing via hook. $article = new Article(); $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->submissionFilesChanged($article); // Test whether the hook was called. $calledHooks = HookRegistry::getCalledHooks(); $lastHook = array_pop($calledHooks); self::assertEquals('ArticleSearchIndex::submissionFilesChanged', $lastHook[0]); // Remove the test hook. HookRegistry::clear('ArticleSearchIndex::submissionFilesChanged'); }
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; }
/** * Save settings. */ function execute() { $articleDao =& DAORegistry::getDAO('ArticleDAO'); $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO'); $application =& PKPApplication::getApplication(); $request =& $application->getRequest(); $user =& $request->getUser(); $router =& $request->getRouter(); $journal =& $router->getContext($request); $article = new Article(); $article->setLocale($journal->getPrimaryLocale()); // FIXME in bug #5543 $article->setUserId($user->getId()); $article->setJournalId($journal->getId()); $article->setSectionId($this->getData('sectionId')); $article->setLanguage(String::substr($journal->getPrimaryLocale(), 0, 2)); $article->setTitle($this->getData('title'), null); // Localized $article->setAbstract($this->getData('abstract'), null); // Localized $article->setDiscipline($this->getData('discipline'), null); // Localized $article->setSubjectClass($this->getData('subjectClass'), null); // Localized $article->setSubject($this->getData('subject'), null); // Localized $article->setCoverageGeo($this->getData('coverageGeo'), null); // Localized $article->setCoverageChron($this->getData('coverageChron'), null); // Localized $article->setCoverageSample($this->getData('coverageSample'), null); // Localized $article->setType($this->getData('type'), null); // Localized $article->setSponsor($this->getData('sponsor'), null); // Localized $article->setCitations($this->getData('citations')); $article->setPages($this->getData('pages')); // Set some default values so the ArticleDAO doesn't complain when adding this article $article->setDateSubmitted(Core::getCurrentDate()); $article->setStatus(STATUS_PUBLISHED); $article->setSubmissionProgress(0); $article->stampStatusModified(); $article->setCurrentRound(1); $article->setFastTracked(1); $article->setHideAuthor(0); $article->setCommentsStatus(0); // Insert the article to get it's ID $articleDao->insertArticle($article); $articleId = $article->getId(); // Add authors $authors = $this->getData('authors'); for ($i = 0, $count = count($authors); $i < $count; $i++) { if ($authors[$i]['authorId'] > 0) { // Update an existing author $author =& $article->getAuthor($authors[$i]['authorId']); $isExistingAuthor = true; } else { // Create a new author $author = new Author(); $isExistingAuthor = false; } if ($author != null) { $author->setSubmissionId($articleId); $author->setFirstName($authors[$i]['firstName']); $author->setMiddleName($authors[$i]['middleName']); $author->setLastName($authors[$i]['lastName']); if (array_key_exists('affiliation', $authors[$i])) { $author->setAffiliation($authors[$i]['affiliation'], null); } $author->setCountry($authors[$i]['country']); $author->setEmail($authors[$i]['email']); $author->setUrl($authors[$i]['url']); if (array_key_exists('competingInterests', $authors[$i])) { $author->setCompetingInterests($authors[$i]['competingInterests'], null); } $author->setBiography($authors[$i]['biography'], null); $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0); $author->setSequence($authors[$i]['seq']); if ($isExistingAuthor == false) { $article->addAuthor($author); } } } // Add the submission files as galleys import('classes.file.TemporaryFileManager'); import('classes.file.ArticleFileManager'); $tempFileIds = $this->getData('tempFileId'); $temporaryFileManager = new TemporaryFileManager(); $articleFileManager = new ArticleFileManager($articleId); foreach (array_keys($tempFileIds) as $locale) { $temporaryFile = $temporaryFileManager->getFile($tempFileIds[$locale], $user->getId()); $fileId = null; if ($temporaryFile) { $fileId = $articleFileManager->temporaryFileToArticleFile($temporaryFile, ARTICLE_FILE_SUBMISSION); $fileType = $temporaryFile->getFileType(); if (strstr($fileType, 'html')) { import('classes.article.ArticleHTMLGalley'); $galley = new ArticleHTMLGalley(); } else { import('classes.article.ArticleGalley'); $galley = new ArticleGalley(); } $galley->setArticleId($articleId); $galley->setFileId($fileId); $galley->setLocale($locale); 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); } if ($locale == $journal->getPrimaryLocale()) { $article->setSubmissionFileId($fileId); $article->SetReviewFileId($fileId); } // Update file search index import('classes.search.ArticleSearchIndex'); if (isset($galley)) { ArticleSearchIndex::updateFileIndex($galley->getArticleId(), ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId()); } } // Designate this as the review version by default. $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $authorSubmission =& $authorSubmissionDao->getAuthorSubmission($articleId); import('classes.submission.author.AuthorAction'); AuthorAction::designateReviewVersion($authorSubmission, true); // Accept the submission $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($articleId); $articleFileManager = new ArticleFileManager($articleId); $sectionEditorSubmission->setReviewFile($articleFileManager->getFile($article->getSubmissionFileId())); import('classes.submission.sectionEditor.SectionEditorAction'); SectionEditorAction::recordDecision($sectionEditorSubmission, SUBMISSION_EDITOR_DECISION_ACCEPT); // Create signoff infrastructure $copyeditInitialSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $articleId); $copyeditAuthorSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId); $copyeditFinalSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $articleId); $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, $articleId); $layoutSignoff->setUserId(0); $signoffDao->updateObject($layoutSignoff); $proofAuthorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId); $proofProofreaderSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId); $proofLayoutEditorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId); $proofAuthorSignoff->setUserId($user->getId()); $proofProofreaderSignoff->setUserId(0); $proofLayoutEditorSignoff->setUserId(0); $signoffDao->updateObject($proofAuthorSignoff); $signoffDao->updateObject($proofProofreaderSignoff); $signoffDao->updateObject($proofLayoutEditorSignoff); import('classes.author.form.submit.AuthorSubmitForm'); AuthorSubmitForm::assignEditors($article); $articleDao->updateArticle($article); // Add to end of editing queue import('classes.submission.editor.EditorAction'); if (isset($galley)) { EditorAction::expediteSubmission($article); } if ($this->getData('destination') == "issue") { // Add to an existing issue $issueId = $this->getData('issueId'); $this->scheduleForPublication($articleId, $issueId); } // Index article. import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::indexArticleMetadata($article); // Import the references list. $citationDao =& DAORegistry::getDAO('CitationDAO'); $rawCitationList = $article->getCitations(); $citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $articleId, $rawCitationList); }
/** * Publish issue * @param $args array * @param $request Request */ function publishIssue($args, $request) { $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE); $issueId = $issue->getId(); $journal = $request->getJournal(); $journalId = $journal->getId(); $articleSearchIndex = null; if (!$issue->getPublished()) { // Set the status of any attendant queued articles to STATUS_PUBLISHED. $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $articleDao = DAORegistry::getDAO('ArticleDAO'); $publishedArticles = $publishedArticleDao->getPublishedArticles($issueId); foreach ($publishedArticles as $publishedArticle) { $article = $articleDao->getById($publishedArticle->getId()); if ($article && $article->getStatus() == STATUS_QUEUED) { $article->setStatus(STATUS_PUBLISHED); $article->stampStatusModified(); $articleDao->updateObject($article); if (!$articleSearchIndex) { import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); } $articleSearchIndex->articleMetadataChanged($publishedArticle); } // delete article tombstone $tombstoneDao = DAORegistry::getDAO('DataObjectTombstoneDAO'); $tombstoneDao->deleteByDataObjectId($article->getId()); } } $issue->setCurrent(1); $issue->setPublished(1); $issue->setDatePublished(Core::getCurrentDate()); // If subscriptions with delayed open access are enabled then // update open access date according to open access delay policy if ($journal->getSetting('publishingMode') == PUBLISHING_MODE_SUBSCRIPTION && $journal->getSetting('enableDelayedOpenAccess')) { $delayDuration = $journal->getSetting('delayedOpenAccessDuration'); $delayYears = (int) floor($delayDuration / 12); $delayMonths = (int) fmod($delayDuration, 12); $curYear = date('Y'); $curMonth = date('n'); $curDay = date('j'); $delayOpenAccessYear = $curYear + $delayYears + (int) floor(($curMonth + $delayMonths) / 12); $delayOpenAccessMonth = (int) fmod($curMonth + $delayMonths, 12); $issue->setAccessStatus(ISSUE_ACCESS_SUBSCRIPTION); $issue->setOpenAccessDate(date('Y-m-d H:i:s', mktime(0, 0, 0, $delayOpenAccessMonth, $curDay, $delayOpenAccessYear))); } $issueDao = DAORegistry::getDAO('IssueDAO'); $issueDao->updateCurrent($journalId, $issue); if ($articleSearchIndex) { $articleSearchIndex->articleChangesFinished(); } // Send a notification to associated users import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationUsers = array(); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $allUsers = $userGroupDao->getUsersByContextId($journalId); while ($user = $allUsers->next()) { $notificationUsers[] = array('id' => $user->getId()); } foreach ($notificationUsers as $userRole) { $notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_PUBLISHED_ISSUE, $journalId); } $notificationManager->sendToMailingList($request, $notificationManager->createNotification($request, UNSUBSCRIBED_USER_NOTIFICATION, NOTIFICATION_TYPE_PUBLISHED_ISSUE, $journalId)); $dispatcher = $request->getDispatcher(); // FIXME: Find a better way to reload the containing tabs. // Without this, issues don't move between tabs properly. return $request->redirectUrlJson($dispatcher->url($request, ROUTE_PAGE, null, 'manageIssues')); }
/** * Approve a galley submission file. * @param $args array * @param $request PKPRequest */ function saveApproveProof($args, $request) { $submissionFile = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION_FILE); $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION); // Make sure we only alter files associated with a galley. if ($submissionFile->getAssocType() !== ASSOC_TYPE_GALLEY) { fatalError('The requested file is not associated with any galley.'); } if ($submissionFile->getViewable()) { // No longer expose the file to readers. $submissionFile->setViewable(false); } else { // Expose the file to readers (e.g. via e-commerce). $submissionFile->setViewable(true); // Log the approve proof event. import('lib.pkp.classes.log.SubmissionLog'); import('classes.log.SubmissionEventLogEntry'); // constants $user = $request->getUser(); $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO'); $galley = $articleGalleyDao->getByBestGalleyId($submissionFile->getAssocId(), $submission->getId()); SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_PROOFS_APPROVED, 'submission.event.proofsApproved', array('formatName' => $galley->getLabel(), 'name' => $user->getFullName(), 'username' => $user->getUsername())); } $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); $submissionFileDao->updateObject($submissionFile); // update the submission's file index import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::submissionFilesChanged($submission); return DAO::getDataChangedEvent($submissionFile->getId()); }
/** * Save changes to article. * @return int the article ID */ function execute() { $articleDao =& DAORegistry::getDAO('ArticleDAO'); $authorDao =& DAORegistry::getDAO('AuthorDAO'); $sectionDao =& DAORegistry::getDAO('SectionDAO'); // Update article $article =& $this->article; $article->setTitle($this->getData('title'), null); // Localized $section =& $sectionDao->getSection($article->getSectionId()); if (!$section->getAbstractsDisabled()) { $article->setAbstract($this->getData('abstract'), null); // Localized } import('file.PublicFileManager'); $publicFileManager =& new PublicFileManager(); if ($publicFileManager->uploadedFileExists('coverPage')) { $journal = Request::getJournal(); $originalFileName = $publicFileManager->getUploadedFileName('coverPage'); $newFileName = 'cover_article_' . $this->getData('articleId') . '_' . $this->getFormLocale() . '.' . $publicFileManager->getExtension($originalFileName); $publicFileManager->uploadJournalFile($journal->getJournalId(), 'coverPage', $newFileName); $article->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale()); $article->setFileName($newFileName, $this->getFormLocale()); // Store the image dimensions. list($width, $height) = getimagesize($publicFileManager->getJournalFilesPath($journal->getJournalId()) . '/' . $newFileName); $article->setWidth($width, $this->getFormLocale()); $article->setHeight($height, $this->getFormLocale()); } $article->setCoverPageAltText($this->getData('coverPageAltText'), null); // Localized $showCoverPage = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('showCoverPage')); foreach (array_keys($this->getData('coverPageAltText')) as $locale) { if (!array_key_exists($locale, $showCoverPage)) { $showCoverPage[$locale] = 0; } } $article->setShowCoverPage($showCoverPage, null); // Localized $article->setDiscipline($this->getData('discipline'), null); // Localized $article->setSubjectClass($this->getData('subjectClass'), null); // Localized $article->setSubject($this->getData('subject'), null); // Localized $article->setCoverageGeo($this->getData('coverageGeo'), null); // Localized $article->setCoverageChron($this->getData('coverageChron'), null); // Localized $article->setCoverageSample($this->getData('coverageSample'), null); // Localized $article->setType($this->getData('type'), null); // Localized $article->setLanguage($this->getData('language')); // Localized $article->setSponsor($this->getData('sponsor'), null); // Localized $article->setHideAuthor($this->getData('hideAuthor') ? $this->getData('hideAuthor') : 0); // Update authors $authors = $this->getData('authors'); for ($i = 0, $count = count($authors); $i < $count; $i++) { if ($authors[$i]['authorId'] > 0) { // Update an existing author $author =& $article->getAuthor($authors[$i]['authorId']); $isExistingAuthor = true; } else { // Create a new author $author =& new Author(); $isExistingAuthor = false; } if ($author != null) { $author->setFirstName($authors[$i]['firstName'], null); // Opatan Inc. : Localized author firstName $author->setMiddleName($authors[$i]['middleName'], null); // Opatan Inc. : Localized author middleName $author->setLastName($authors[$i]['lastName'], null); // Opatan Inc. : Localized author lastName $author->setAffiliation($authors[$i]['affiliation'], null); // Opatan Inc. : Localized author affiliation $author->setCountry($authors[$i]['country']); $author->setEmail($authors[$i]['email']); $author->setUrl($authors[$i]['url']); if (array_key_exists('competingInterests', $authors[$i])) { $author->setCompetingInterests($authors[$i]['competingInterests'], null); // Localized } $author->setBiography($authors[$i]['biography'], null); // Localized $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0); $author->setSequence($authors[$i]['seq']); if ($isExistingAuthor == false) { $article->addAuthor($author); } } } // Remove deleted authors $deletedAuthors = explode(':', $this->getData('deletedAuthors')); for ($i = 0, $count = count($deletedAuthors); $i < $count; $i++) { $article->removeAuthor($deletedAuthors[$i]); } // Save the article $articleDao->updateArticle($article); // Update search index import('search.ArticleSearchIndex'); ArticleSearchIndex::indexArticleMetadata($article); return $article->getArticleId(); }
/** * 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); }
/** * Query parsing helper routine. * Returned structure is based on that used by the Search::QueryParser Perl module. */ function _parseQuery($signTokens, $tokens, &$pos, $total) { $return = array('+' => array(), '' => array(), '-' => array()); $postBool = $preBool = ''; $notOperator = String::strtolower(Locale::translate('search.operator.not')); $andOperator = String::strtolower(Locale::translate('search.operator.and')); $orOperator = String::strtolower(Locale::translate('search.operator.or')); while ($pos < $total) { if (!empty($signTokens[$pos])) { $sign = $signTokens[$pos]; } else { if (empty($sign)) { $sign = '+'; } } $token = String::strtolower($tokens[$pos++]); switch ($token) { case $notOperator: $sign = '-'; break; case ')': return $return; case '(': $token = ArticleSearch::_parseQuery($signTokens, $tokens, $pos, $total); default: $postBool = ''; if ($pos < $total) { $peek = String::strtolower($tokens[$pos]); if ($peek == $orOperator) { $postBool = 'or'; $pos++; } else { if ($peek == $andOperator) { $postBool = 'and'; $pos++; } } } $bool = empty($postBool) ? $preBool : $postBool; $preBool = $postBool; if ($bool == 'or') { $sign = ''; } if (is_array($token)) { $k = $token; } else { $k = ArticleSearchIndex::filterKeywords($token, true); } if (!empty($k)) { $return[$sign][] = $k; } $sign = ''; break; } } return $return; }
/** * Save changes to the galley. * @return int the galley ID */ function execute($fileName = null, $createRemote = false) { import('classes.file.ArticleFileManager'); $articleFileManager = new ArticleFileManager($this->articleId); $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO'); $fileName = isset($fileName) ? $fileName : 'galleyFile'; $journal =& Request::getJournal(); $fileId = null; $articleDao =& DAORegistry::getDAO('ArticleDAO'); $article =& $articleDao->getArticle($this->articleId, $journal->getId()); if (isset($this->galley)) { $galley =& $this->galley; // Upload galley file if ($articleFileManager->uploadedFileExists($fileName)) { if ($galley->getFileId()) { $articleFileManager->uploadPublicFile($fileName, $galley->getFileId()); $fileId = $galley->getFileId(); } else { $fileId = $articleFileManager->uploadPublicFile($fileName); $galley->setFileId($fileId); } // Update file search index import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->articleFileChanged($this->articleId, ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId()); $articleSearchIndex->articleChangesFinished(); } if ($articleFileManager->uploadedFileExists('styleFile')) { // Upload stylesheet file $styleFileId = $articleFileManager->uploadPublicFile('styleFile', $galley->getStyleFileId()); $galley->setStyleFileId($styleFileId); } else { if ($this->getData('deleteStyleFile')) { // Delete stylesheet file $styleFile =& $galley->getStyleFile(); if (isset($styleFile)) { $articleFileManager->deleteFile($styleFile->getFileId()); } } } // Update existing galley $galley->setLabel($this->getData('label')); if ($journal->getSetting('enablePublicGalleyId')) { $galley->setStoredPubId('publisher-id', $this->getData('publicGalleyId')); } $galley->setLocale($this->getData('galleyLocale')); if ($this->getData('remoteURL')) { $galley->setRemoteURL($this->getData('remoteURL')); } // consider the additional field names from the public identifer plugins import('classes.plugins.PubIdPluginHelper'); $pubIdPluginHelper = new PubIdPluginHelper(); $pubIdPluginHelper->execute($this, $galley); parent::execute(); $galleyDao->updateGalley($galley); } else { // Upload galley file if ($articleFileManager->uploadedFileExists($fileName)) { $fileType = $articleFileManager->getUploadedFileType($fileName); $fileId = $articleFileManager->uploadPublicFile($fileName); } if (isset($fileType) && strstr($fileType, 'html')) { // Assume HTML galley $galley = new ArticleHTMLGalley(); } else { $galley = new ArticleGalley(); } $galley->setArticleId($this->articleId); $galley->setFileId($fileId); if ($this->getData('label') == null) { // Generate initial label based on file type $enablePublicGalleyId = $journal->getSetting('enablePublicGalleyId'); if ($galley->isHTMLGalley()) { $galley->setLabel('HTML'); if ($enablePublicGalleyId) { $galley->setStoredPubId('publisher-id', 'html'); } } else { if ($createRemote) { $galley->setLabel(__('common.remote')); $galley->setRemoteURL(__('common.remoteURL')); if ($enablePublicGalleyId) { $galley->setStoredPubId('publisher-id', strtolower(__('common.remote'))); } } else { if (isset($fileType)) { if (strstr($fileType, 'pdf')) { $galley->setLabel('PDF'); if ($enablePublicGalleyId) { $galley->setStoredPubId('publisher-id', 'pdf'); } } else { if (strstr($fileType, 'postscript')) { $galley->setLabel('PostScript'); if ($enablePublicGalleyId) { $galley->setStoredPubId('publisher-id', 'ps'); } } else { if (strstr($fileType, 'xml')) { $galley->setLabel('XML'); if ($enablePublicGalleyId) { $galley->setStoredPubId('publisher-id', 'xml'); } } else { if (strstr($fileType, 'epub')) { $galley->setLabel('EPUB'); if ($enablePublicGalleyId) { $galley->setStoredPubId('publisher-id', 'epub'); } } } } } } } } if ($galley->getLabel() == null) { $galley->setLabel(__('common.untitled')); } } else { $galley->setLabel($this->getData('label')); } $galley->setLocale($article->getLocale()); if ($enablePublicGalleyId) { // check to make sure the assigned public id doesn't already exist for another galley of this article $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO'); /* @var $galleylDao ArticleGalleyDAO */ $publicGalleyId = $galley->getPubId('publisher-id'); $suffix = ''; $i = 1; while ($galleyDao->getGalleyByPubId('publisher-id', $publicGalleyId . $suffix, $this->articleId)) { $suffix = '_' . $i++; } $galley->setStoredPubId('publisher-id', $publicGalleyId . $suffix); } parent::execute(); // Insert new galley $galleyDao->insertGalley($galley); $this->galleyId = $galley->getId(); } if ($fileId) { // Update file search index import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->articleFileChanged($this->articleId, ARTICLE_SEARCH_GALLEY_FILE, $fileId); $articleSearchIndex->articleChangesFinished(); } // Stamp the article modification (for OAI) $articleDao->updateArticle($article); return $this->galleyId; }
/** * 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; }
/** * Expedites a submission through the submission process, if the submitter is a manager or editor. * @param $args array * @param $request PKPRequest */ function expedite($args, $request) { $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION); import('controllers.tab.issueEntry.form.IssueEntryPublicationMetadataForm'); $user = $request->getUser(); $form = new IssueEntryPublicationMetadataForm($submission->getId(), $user, null, array('expeditedSubmission' => true)); if ($submission && (int) $request->getUserVar('issueId') > 0) { // Process our submitted form in order to create the published article entry. $form->readInputData(); if ($form->validate()) { $form->execute($request); // Create trivial notification in place on the form, and log the event. $notificationManager = new NotificationManager(); $user = $request->getUser(); import('lib.pkp.classes.log.SubmissionLog'); import('classes.log.SubmissionEventLogEntry'); // Log consts SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_ISSUE_METADATA_UPDATE, 'submission.event.issueMetadataUpdated'); $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.savedIssueMetadata'))); // For indexing import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); // Now, create a galley for this submission. Assume PDF, and set to 'available'. $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO'); $articleGalley = $articleGalleyDao->newDataObject(); $articleGalley->setGalleyType('pdfarticlegalleyplugin'); $articleGalley->setIsApproved(true); $articleGalley->setSubmissionId($submission->getId()); $articleGalley->setLocale($submission->getLocale()); $articleGalley->setLabel('PDF'); $articleGalley->setSeq($articleGalleyDao->getNextGalleySequence($submission->getId())); $articleGalleyId = $articleGalleyDao->insertObject($articleGalley); // Next, create a galley PROOF file out of the submission file uploaded. $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); import('lib.pkp.classes.submission.SubmissionFile'); // SUBMISSION_FILE_... constants $submissionFiles = $submissionFileDao->getLatestRevisions($submission->getId(), SUBMISSION_FILE_SUBMISSION); // Watch for a single file, or any PDFs. foreach ($submissionFiles as $submissionFile) { // test both mime type and file extension in case the mime type isn't correct after uploading. if (count($submissionFiles) == 1 || $submissionFile->getFileType() == 'application/pdf' || preg_match('/\\.pdf$/', $submissionFile->getOriginalFileName())) { // Get the path of the current file because we change the file stage in a bit. $currentFilePath = $submissionFile->getFilePath(); // this will be a new file based on the old one. $submissionFile->setFileId(null); $submissionFile->setRevision(1); $submissionFile->setFileStage(SUBMISSION_FILE_PROOF); $submissionFile->setAssocType(ASSOC_TYPE_GALLEY); $submissionFile->setAssocId($articleGalleyId); $submissionFileDao->insertObject($submissionFile, $currentFilePath); // Update file index $articleSearchIndex->submissionFileChanged($submission->getId(), SUBMISSION_SEARCH_GALLEY_FILE, $submissionFile->getFileId()); break; } } // Update index $articleSearchIndex->articleMetadataChanged($submission); $articleSearchIndex->articleChangesFinished(); // no errors, clear all notifications for this submission which may have been created during the submission process and close the modal. $context = $request->getContext(); $notificationDao = DAORegistry::getDAO('NotificationDAO'); $notificationFactory = $notificationDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submission->getId(), null, null, $context->getId()); return new JSONMessage(true); } else { return new JSONMessage(true, $form->fetch($request)); } } return new JSONMessage(true, $form->fetch($request)); }