Ejemplo n.º 1
0
 /**
  * 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);
     }
 }
Ejemplo n.º 2
0
 /**
  * @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;
 }
 /**
  * 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);
 }
Ejemplo n.º 4
0
 /**
  * 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();
 }
Ejemplo n.º 5
0
 /**
  * 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();
 }
Ejemplo n.º 6
0
 /**
  * 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'));
 }
Ejemplo n.º 7
0
 /**
  * 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();
 }
Ejemplo n.º 8
0
 /**
  * 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();
 }
Ejemplo n.º 9
0
 /**
  * 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));
 }
 /**
  * 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();
     }
 }
 /**
  * Set the publication date for a published article
  * @param $args array
  * @param $request object
  */
 function setDatePublished($args, $request)
 {
     $articleId = (int) array_shift($args);
     $issueId = (int) $request->getUserVar('issueId');
     $this->validate($articleId, SECTION_EDITOR_ACCESS_EDIT);
     $journal =& $request->getJournal();
     $submission =& $this->submission;
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($articleId);
     if ($publishedArticle) {
         $datePublished = $request->getUserDateVar('datePublished');
         $publishedArticle->setDatePublished($datePublished);
         $publishedArticleDao->updatePublishedArticle($publishedArticle);
         // Re-index the published article metadata.
         import('classes.search.ArticleSearchIndex');
         $articleSearchIndex = new ArticleSearchIndex();
         $articleSearchIndex->articleMetadataChanged($publishedArticle);
         $articleSearchIndex->articleChangesFinished();
     }
     $request->redirect(null, null, 'submissionEditing', array($articleId), null, 'scheduling');
 }
Ejemplo n.º 12
0
 /**
  * Save changes to submission.
  * @param $request PKPRequest
  */
 function execute($request)
 {
     parent::execute($request);
     $submission = $this->getSubmission();
     $submissionDao = Application::getSubmissionDAO();
     // if section changed consider reordering
     $reorder = false;
     $oldSectionId = $submission->getSectionId();
     if ($oldSectionId != $this->getData('sectionId')) {
         $reorder = true;
         $submission->setSectionId($this->getData('sectionId'));
     }
     $locale = AppLocale::getLocale();
     // Copy an uploaded cover file for the article, if there is one.
     if ($temporaryFileId = $this->getData('temporaryFileId')) {
         $user = $request->getUser();
         $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $newFileName = 'article_' . $submission->getId() . '_cover_' . $locale . $publicFileManager->getImageExtension($temporaryFile->getFileType());
         $journal = $request->getJournal();
         $publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName);
         $submission->setCoverImage($newFileName, $locale);
     }
     $submission->setCoverImageAltText($this->getData('coverImageAltText'), $locale);
     $submissionDao->updateObject($submission);
     if ($reorder) {
         // see if it is a published article
         $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
         $publishedArticle = $publishedArticleDao->getPublishedArticleByArticleId($submission->getId(), null, false);
         /* @var $publishedArticle PublishedArticle */
         if ($publishedArticle) {
             // Resequence the articles.
             $publishedArticle->setSequence(REALLY_BIG_NUMBER);
             $publishedArticleDao->updatePublishedArticle($publishedArticle);
             $publishedArticleDao->resequencePublishedArticles($submission->getSectionId(), $publishedArticle->getIssueId());
             // The reordering for the old section is not necessary, but for the correctness sake
             $publishedArticleDao->resequencePublishedArticles($oldSectionId, $publishedArticle->getIssueId());
         }
     }
     if ($submission->getDatePublished()) {
         import('classes.search.ArticleSearchIndex');
         ArticleSearchIndex::articleMetadataChanged($submission);
     }
 }
Ejemplo n.º 13
0
 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
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $article = new Article();
     if ($locale = $articleNode->getAttribute('locale')) {
         $article->setLocale($locale);
     } else {
         $article->setLocale($journal->getPrimaryLocale());
     }
     if (($value = $articleNode->getAttribute('public_id')) != '') {
         $anotherArticle = $publishedArticleDao->getPublishedArticleByPubId('publisher-id', $value, $journal->getId());
         if ($anotherArticle) {
             $errors[] = array('plugins.importexport.native.import.error.duplicatePublicArticleId', array('articleTitle' => $article->getLocalizedTitle(), 'otherArticleTitle' => $anotherArticle->getLocalizedTitle()));
             $hasErrors = true;
         } else {
             $issue->setStoredPubId('publisher-id', $value);
         }
     }
     $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 = $article->getLocale();
         } 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($article->getLocale()) == '') {
         $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 = $article->getLocale();
         } 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 = $article->getLocale();
             } 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 = $article->getLocale();
             } 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 = $article->getLocale();
             } 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 = $article->getLocale();
             } 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 = $article->getLocale();
                 } 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 = $article->getLocale();
                 } 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 = $article->getLocale();
                 } 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 = $article->getLocale();
         } 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 covers --- */
     $hasErrors = false;
     for ($index = 0; $node = $articleNode->getChildByName('cover', $index); $index++) {
         if (!NativeImportDom::handleArticleCoverNode($journal, $node, $article, $coverErrors, $isCommandLine)) {
             $errors = array_merge($errors, $coverErrors);
             $hasErrors = true;
         }
     }
     /* --- Set IDs --- */
     if (!NativeImportDom::handlePubIds($articleNode, $article, $journal, $issue, $article, $errors)) {
         $hasErrors = true;
     }
     $articleDao->insertArticle($article);
     $dependentItems[] = array('article', $article);
     /* --- Handle authors --- */
     for ($index = 0; $node = $articleNode->getChildByName('author', $index); $index++) {
         if (!NativeImportDom::handleAuthorNode($journal, $node, $issue, $section, $article, $authorErrors, $index)) {
             $errors = array_merge($errors, $authorErrors);
             $hasErrors = true;
         }
     }
     if ($hasErrors) {
         return false;
     }
     // 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');
     ArticleLog::logEventHeadless($journal, $user->getId(), $article, ARTICLE_LOG_ARTICLE_IMPORT, 'log.imported', array('userName' => $user->getFullName(), 'articleId' => $article->getId()));
     // Insert published article entry.
     $publishedArticle = new PublishedArticle();
     $publishedArticle->setId($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->setPublishedArticleId($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++;
     }
     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 = new ArticleSearchIndex();
     $articleSearchIndex->articleMetadataChanged($article);
     $articleSearchIndex->articleFilesChanged($article);
     $articleSearchIndex->articleChangesFinished();
     return true;
 }
Ejemplo n.º 14
0
 /**
  * Save changes to submission.
  * @param $request PKPRequest
  */
 function execute($request)
 {
     parent::execute($request);
     $submission = $this->getSubmission();
     $submissionDao = Application::getSubmissionDAO();
     $submission->setSectionId($this->getData('sectionId'));
     // Copy an uploaded cover file for the article, if there is one.
     if ($temporaryFileId = $this->getData('temporaryFileId')) {
         $user = $request->getUser();
         $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $newFileName = 'article_' . $submission->getId() . '_cover' . $publicFileManager->getImageExtension($temporaryFile->getFileType());
         $journal = $request->getJournal();
         $publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName);
         $submission->setCoverImage($newFileName);
     }
     $submission->setCoverImageAltText($this->getData('coverImageAltText'));
     $submissionDao->updateObject($submission);
     if ($submission->getDatePublished()) {
         import('classes.search.ArticleSearchIndex');
         ArticleSearchIndex::articleMetadataChanged($submission);
     }
 }
 /**
  * Publish issue
  * @param $args array
  * @param $request Request
  */
 function publishIssue($args, $request)
 {
     $issueId = (int) array_shift($args);
     $this->validate($issueId);
     $issue =& $this->issue;
     $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->getArticle($publishedArticle->getId());
             if ($article && $article->getStatus() == STATUS_QUEUED) {
                 $article->setStatus(STATUS_PUBLISHED);
                 $article->stampStatusModified();
                 $articleDao->updateArticle($article);
                 // Call initialize permissions again to check if copyright year needs to be initialized.
                 $article->initializePermissions();
                 $articleDao->updateLocaleFields($article);
                 if (!$articleSearchIndex) {
                     import('classes.search.ArticleSearchIndex');
                     $articleSearchIndex = new ArticleSearchIndex();
                 }
                 $articleSearchIndex->articleMetadataChanged($publishedArticle);
             }
             // delete article tombstone
             $tombstoneDao =& DAORegistry::getDAO('DataObjectTombstoneDAO');
             $tombstoneDao->deleteByDataObjectId($article->getId());
             unset($article);
         }
     }
     $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->updateCurrentIssue($journalId, $issue);
     if ($articleSearchIndex) {
         $articleSearchIndex->articleChangesFinished();
     }
     // Send a notification to associated users
     import('classes.notification.NotificationManager');
     $notificationManager = new NotificationManager();
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $notificationUsers = array();
     $allUsers = $roleDao->getUsersByJournalId($journalId);
     while (!$allUsers->eof()) {
         $user =& $allUsers->next();
         $notificationUsers[] = array('id' => $user->getId());
         unset($user);
     }
     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));
     $request->redirect(null, null, 'issueToc', $issue->getId());
 }