Example #1
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();
 }
 /**
  * Save changes to article.
  * @param $request Request
  * @return int the article ID
  */
 function execute()
 {
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $authorDao =& DAORegistry::getDAO('AuthorDAO');
     $article =& $this->article;
     // Retrieve the previous citation list for comparison.
     $previousRawCitationList = $article->getCitations();
     // Update article
     $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->setLanguage($this->getData('language'));
     $article->setSponsor($this->getData('sponsor'), null);
     // Localized
     $article->setCitations($this->getData('citations'));
     if ($article->getSubmissionProgress() <= $this->step) {
         $article->stampStatusModified();
         $article->setSubmissionProgress($this->step + 1);
     }
     // 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
             $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);
             $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);
             }
             $author->setBiography($authors[$i]['biography'], null);
             $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0);
             $author->setSequence($authors[$i]['seq']);
             HookRegistry::call('Author::Form::Submit::AuthorSubmitStep3Form::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());
     }
     parent::execute();
     // Save the article
     $articleDao->updateArticle($article);
     // Update references list if it changed.
     $citationDao =& DAORegistry::getDAO('CitationDAO');
     $rawCitationList = $article->getCitations();
     if ($previousRawCitationList != $rawCitationList) {
         $citationDao->importCitations($this->request, ASSOC_TYPE_ARTICLE, $article->getId(), $rawCitationList);
     }
     return $this->articleId;
 }
 /**
  * Save changes to article.
  * @return int the article ID
  */
 function execute()
 {
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     if (isset($this->article)) {
         // Update existing article
         $this->article->setSectionId($this->getData('sectionId'));
         $this->article->setLocale($this->getData('locale'));
         $this->article->setCommentsToEditor($this->getData('commentsToEditor'));
         if ($this->article->getSubmissionProgress() <= $this->step) {
             $this->article->stampStatusModified();
             $this->article->setSubmissionProgress($this->step + 1);
         }
         $articleDao->updateArticle($this->article);
     } else {
         // Insert new article
         $journal =& $this->request->getJournal();
         $user =& $this->request->getUser();
         $this->article = new Article();
         $this->article->setLocale($this->getData('locale'));
         $this->article->setUserId($user->getId());
         $this->article->setJournalId($journal->getId());
         $this->article->setSectionId($this->getData('sectionId'));
         $this->article->stampStatusModified();
         $this->article->setSubmissionProgress($this->step + 1);
         $this->article->setLanguage(String::substr($this->article->getLocale(), 0, 2));
         $this->article->setCommentsToEditor($this->getData('commentsToEditor'));
         $articleDao->insertArticle($this->article);
         $this->articleId = $this->article->getId();
         // Set user to initial author
         $authorDao =& DAORegistry::getDAO('AuthorDAO');
         /* @var $authorDao AuthorDAO */
         $user =& $this->request->getUser();
         $author = new Author();
         $author->setSubmissionId($this->articleId);
         $author->setFirstName($user->getFirstName());
         $author->setMiddleName($user->getMiddleName());
         $author->setLastName($user->getLastName());
         $author->setAffiliation($user->getAffiliation(null), null);
         $author->setCountry($user->getCountry());
         $author->setEmail($user->getEmail());
         $author->setData('orcid', $user->getData('orcid'));
         $author->setUrl($user->getUrl());
         $author->setBiography($user->getBiography(null), null);
         $author->setPrimaryContact(1);
         $authorDao->insertAuthor($author);
     }
     return $this->articleId;
 }
 /**
  * @see MetadataDataObjectAdapter::injectMetadataIntoDataObject()
  * @param $mods34Description MetadataDescription
  * @param $submission Submission
  * @param $authorClassName string the application specific author class name
  */
 function &injectMetadataIntoDataObject(&$mods34Description, &$submission, $authorClassName)
 {
     assert(is_a($submission, 'Submission'));
     assert($mods34Description->getMetadataSchemaName() == 'plugins.metadata.mods34.schema.Mods34Schema');
     // Get the cataloging language.
     $catalogingLanguage = $mods34Description->getStatement('recordInfo/languageOfCataloging/languageTerm[@authority="iso639-2b"]');
     $catalogingLocale = Locale::getLocaleFrom3LetterIso($catalogingLanguage);
     assert(!is_null($catalogingLocale));
     // Title
     $localizedTitles = $mods34Description->getStatementTranslations('titleInfo/title');
     if (is_array($localizedTitles)) {
         foreach ($localizedTitles as $locale => $title) {
             $submission->setTitle($title, $locale);
         }
     }
     // Names: authors and sponsor
     $foundSponsor = false;
     $nameDescriptions =& $mods34Description->getStatement('name');
     if (is_array($nameDescriptions)) {
         foreach ($nameDescriptions as $nameDescription) {
             /* @var $nameDescription MetadataDescription */
             // Check that we find the expected name schema.
             assert($nameDescription->getMetadataSchemaName() == 'lib.pkp.plugins.metadata.mods34.schema.Mods34NameSchema');
             // Retrieve the name type and role.
             $nameType = $nameDescription->getStatement('[@type]');
             $nameRoles = $nameDescription->getStatement('role/roleTerm[@type="code" @authority="marcrelator"]');
             // Transport the name into the submission depending
             // on name type and role.
             // FIXME: Move this to a dedicated adapter in the Author class.
             if (is_array($nameRoles)) {
                 switch ($nameType) {
                     // Authors
                     case 'personal':
                         // Only authors go into the submission.
                         if (in_array('aut', $nameRoles)) {
                             // Instantiate a new author object.
                             import($authorClassName);
                             $author = new Author();
                             // Family Name
                             $author->setLastName($nameDescription->getStatement('namePart[@type="family"]'));
                             // Given Names
                             $givenNames = $nameDescription->getStatement('namePart[@type="given"]');
                             if (!empty($givenNames)) {
                                 $givenNames = explode(' ', $givenNames, 2);
                                 if (isset($givenNames[0])) {
                                     $author->setFirstName($givenNames[0]);
                                 }
                                 if (isset($givenNames[1])) {
                                     $author->setMiddleName($givenNames[1]);
                                 }
                             }
                             // Affiliation
                             // NB: Our MODS mapping currently doesn't support translation for names.
                             // This can be added when required by data providers. We assume the cataloging
                             // language for the record.
                             $affiliation = $nameDescription->getStatement('affiliation');
                             if (!empty($affiliation)) {
                                 $author->setAffiliation($affiliation, $catalogingLocale);
                             }
                             // Terms of address (unmapped field)
                             $termsOfAddress = $nameDescription->getStatement('namePart[@type="termsOfAddress"]');
                             if ($termsOfAddress) {
                                 $author->setData('nlm34:namePart[@type="termsOfAddress"]', $termsOfAddress);
                             }
                             // Date (unmapped field)
                             $date = $nameDescription->getStatement('namePart[@type="date"]');
                             if ($date) {
                                 $author->setData('nlm34:namePart[@type="date"]', $date);
                             }
                             // Add the author to the submission.
                             $submission->addAuthor($author);
                             unset($author);
                         }
                         break;
                         // Sponsor
                         // NB: Our MODS mapping currently doesn't support translation for names.
                         // This can be added when required by data providers. We assume the cataloging
                         // language for the record.
                     // Sponsor
                     // NB: Our MODS mapping currently doesn't support translation for names.
                     // This can be added when required by data providers. We assume the cataloging
                     // language for the record.
                     case 'corporate':
                         // Only the first sponsor goes into the submission.
                         if (!$foundSponsor && in_array('spn', $nameRoles)) {
                             $foundSponsor = true;
                             $submission->setSponsor($nameDescription->getStatement('namePart'), $catalogingLocale);
                         }
                         break;
                 }
             }
             unset($nameDescription);
         }
     }
     // Creation date
     $dateSubmitted = $mods34Description->getStatement('originInfo/dateCreated[@encoding="w3cdtf"]');
     if ($dateSubmitted) {
         $submission->setDateSubmitted($dateSubmitted);
     }
     // Submission language
     $submissionLanguage = $mods34Description->getStatement('language/languageTerm[@type="code" @authority="iso639-2b"]');
     $submissionLocale = Locale::get2LetterFrom3LetterIsoLanguage($submissionLanguage);
     if ($submissionLocale) {
         $submission->setLanguage($submissionLocale);
     }
     // Pages (extent)
     $pages = $mods34Description->getStatement('physicalDescription/extent');
     if ($pages) {
         $submission->setPages($pages);
     }
     // Abstract
     $localizedAbstracts = $mods34Description->getStatementTranslations('abstract');
     if (is_array($localizedAbstracts)) {
         foreach ($localizedAbstracts as $locale => $abstract) {
             $submission->setAbstract($abstract, $locale);
         }
     }
     // Discipline, subject class and subject
     // FIXME: We currently ignore discipline, subject class and subject because we cannot
     // distinguish them within a list of MODS topic elements. Can we use several subject
     // statements with different authorities instead?
     // Geographical coverage
     $localizedCoverageGeos = $mods34Description->getStatementTranslations('subject/geographic');
     if (is_array($localizedCoverageGeos)) {
         foreach ($localizedCoverageGeos as $locale => $localizedCoverageGeo) {
             $submission->setCoverageGeo($localizedCoverageGeo, $locale);
         }
     }
     // Chronological coverage
     $localizedCoverageChrons = $mods34Description->getStatementTranslations('subject/temporal');
     if (is_array($localizedCoverageChrons)) {
         foreach ($localizedCoverageChrons as $locale => $localizedCoverageChron) {
             $submission->setCoverageChron($localizedCoverageChron, $locale);
         }
     }
     // Record identifier
     // NB: We currently don't override the submission id with the record identifier in MODS
     // to make sure that MODS records can be transported between different installations.
     // Handle unmapped fields.
     $this->injectUnmappedDataObjectMetadataFields($mods34Description, $submission);
     return $submission;
 }
 /**
  * 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 = new Article();
     $article->setLocale($this->getData('locale'));
     $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($this->getData('destination') == 'queue' ? STATUS_QUEUED : 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
     $authorDao =& DAORegistry::getDAO('AuthorDAO');
     /* @var $authorDao AuthorDAO */
     $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->setData('orcid', $authors[$i]['orcid']);
             $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->insertAuthor($author);
             }
         }
     }
     // Setup default copyright/license metadata after status is set and authors are attached.
     $article->initializePermissions();
     $articleDao->updateLocaleFields($article);
     // 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);
     $designatedPrimary = false;
     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 (!$designatedPrimary) {
                 $article->setSubmissionFileId($fileId);
                 $article->setReviewFileId($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(), ARTICLE_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);
     $sectionEditorSubmission->setReviewFile($articleFileManager->getFile($article->getSubmissionFileId()));
     import('classes.submission.sectionEditor.SectionEditorAction');
     SectionEditorAction::recordDecision($sectionEditorSubmission, SUBMISSION_EDITOR_DECISION_ACCEPT, $this->request);
     // 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, $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();
 }