function display(&$args, $request)
 {
     parent::display($args, $request);
     $templateMgr =& TemplateManager::getManager();
     $journal =& $request->getJournal();
     switch (array_shift($args)) {
         case 'export':
             @set_time_limit(0);
             $errors = array();
             $success = $this->handleExport($journal, $errors);
             if ($success === false) {
                 return $errors;
             }
             break;
         case 'import':
             AppLocale::requireComponents(LOCALE_COMPONENT_OJS_EDITOR, LOCALE_COMPONENT_OJS_AUTHOR);
             import('classes.file.TemporaryFileManager');
             $temporaryFileManager = new TemporaryFileManager();
             if ($existingFileId = $request->getUserVar('temporaryFileId')) {
                 // The user has just entered more context. Fetch an existing file.
                 $temporaryFile = $temporaryFileManager->getFile($existingFileId, $user->getId());
             } else {
                 $user = Request::getUser();
                 $temporaryFile = $temporaryFileManager->handleUpload('importFile', $user->getId());
             }
             if (!$temporaryFile) {
                 $templateMgr->assign('error', 'plugins.importexport.fullJournal.error.uploadFailed');
                 return $templateMgr->display($this->getTemplatePath() . 'importError.tpl');
             }
             @set_time_limit(0);
             $errors = array();
             if ($this->handleImport($temporaryFile->getFilePath(), $errors)) {
                 return $templateMgr->display($this->getTemplatePath() . 'importSuccess.tpl');
             } else {
                 $templateMgr->assign_by_ref('errors', $errors);
                 return $templateMgr->display($this->getTemplatePath() . 'importError.tpl');
             }
             break;
         default:
             $this->setBreadcrumbs();
             $templateMgr->display($this->getTemplatePath() . 'index.tpl');
     }
 }
예제 #2
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();
 }
예제 #3
0
 /**
  * Delete all attachments associated with this message.
  * Called from send().
  * @param $userId int
  */
 function _clearAttachments($userId)
 {
     import('file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $persistAttachments = Request::getUserVar('persistAttachments');
     if (is_array($persistAttachments)) {
         foreach ($persistAttachments as $fileId) {
             $temporaryFile = $temporaryFileManager->getFile($fileId, $userId);
             if (!empty($temporaryFile)) {
                 $temporaryFileManager->deleteFile($temporaryFile->getId(), $userId);
             }
         }
     }
 }
 function display(&$args, $request)
 {
     $templateMgr =& TemplateManager::getManager();
     parent::display($args, $request);
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $journal =& $request->getJournal();
     switch (array_shift($args)) {
         case 'exportIssues':
             $issueIds = $request->getUserVar('issueId');
             if (!isset($issueIds)) {
                 $issueIds = array();
             }
             $issues = array();
             foreach ($issueIds as $issueId) {
                 $issue =& $issueDao->getIssueById($issueId, $journal->getId());
                 if (!$issue) {
                     $request->redirect();
                 }
                 $issues[] =& $issue;
                 unset($issue);
             }
             $this->exportIssues($journal, $issues);
             break;
         case 'exportIssue':
             $issueId = array_shift($args);
             $issue =& $issueDao->getIssueById($issueId, $journal->getId());
             if (!$issue) {
                 $request->redirect();
             }
             $this->exportIssue($journal, $issue);
             break;
         case 'exportArticle':
             $articleIds = array(array_shift($args));
             $result = array_shift(ArticleSearch::formatResults($articleIds));
             $this->exportArticle($journal, $result['issue'], $result['section'], $result['publishedArticle']);
             break;
         case 'exportArticles':
             $articleIds = $request->getUserVar('articleId');
             if (!isset($articleIds)) {
                 $articleIds = array();
             }
             $results =& ArticleSearch::formatResults($articleIds);
             $this->exportArticles($results);
             break;
         case 'issues':
             // Display a list of issues for export
             $this->setBreadcrumbs(array(), true);
             AppLocale::requireComponents(LOCALE_COMPONENT_OJS_EDITOR);
             $issueDao =& DAORegistry::getDAO('IssueDAO');
             $issues =& $issueDao->getIssues($journal->getId(), Handler::getRangeInfo('issues'));
             $templateMgr->assign_by_ref('issues', $issues);
             $templateMgr->display($this->getTemplatePath() . 'issues.tpl');
             break;
         case 'articles':
             // Display a list of articles for export
             $this->setBreadcrumbs(array(), true);
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $rangeInfo = Handler::getRangeInfo('articles');
             $articleIds = $publishedArticleDao->getPublishedArticleIdsAlphabetizedByJournal($journal->getId(), false);
             $totalArticles = count($articleIds);
             if ($rangeInfo->isValid()) {
                 $articleIds = array_slice($articleIds, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
             }
             import('lib.pkp.classes.core.VirtualArrayIterator');
             $iterator = new VirtualArrayIterator(ArticleSearch::formatResults($articleIds), $totalArticles, $rangeInfo->getPage(), $rangeInfo->getCount());
             $templateMgr->assign_by_ref('articles', $iterator);
             $templateMgr->display($this->getTemplatePath() . 'articles.tpl');
             break;
         case 'import':
             AppLocale::requireComponents(LOCALE_COMPONENT_OJS_EDITOR, LOCALE_COMPONENT_OJS_AUTHOR);
             import('classes.file.TemporaryFileManager');
             $issueDao =& DAORegistry::getDAO('IssueDAO');
             $sectionDao =& DAORegistry::getDAO('SectionDAO');
             $user =& $request->getUser();
             $temporaryFileManager = new TemporaryFileManager();
             if ($existingFileId = $request->getUserVar('temporaryFileId')) {
                 // The user has just entered more context. Fetch an existing file.
                 $temporaryFile = $temporaryFileManager->getFile($existingFileId, $user->getId());
             } else {
                 $temporaryFile = $temporaryFileManager->handleUpload('importFile', $user->getId());
             }
             $context = array('journal' => $journal, 'user' => $user);
             if ($sectionId = $request->getUserVar('sectionId')) {
                 $context['section'] = $sectionDao->getSection($sectionId);
             }
             if ($issueId = $request->getUserVar('issueId')) {
                 $context['issue'] = $issueDao->getIssueById($issueId, $journal->getId());
             }
             if (!$temporaryFile) {
                 $templateMgr->assign('error', 'plugins.importexport.native.error.uploadFailed');
                 return $templateMgr->display($this->getTemplatePath() . 'importError.tpl');
             }
             $doc =& $this->getDocument($temporaryFile->getFilePath());
             if (substr($this->getRootNodeName($doc), 0, 7) === 'article') {
                 // Ensure the user has supplied enough valid information to
                 // import articles within an appropriate context. If not,
                 // prompt them for the.
                 if (!isset($context['issue']) || !isset($context['section'])) {
                     $issues =& $issueDao->getIssues($journal->getId(), Handler::getRangeInfo('issues'));
                     $templateMgr->assign_by_ref('issues', $issues);
                     $templateMgr->assign('sectionOptions', array('0' => __('author.submit.selectSection')) + $sectionDao->getSectionTitles($journal->getId(), false));
                     $templateMgr->assign('temporaryFileId', $temporaryFile->getId());
                     return $templateMgr->display($this->getTemplatePath() . 'articleContext.tpl');
                 }
             }
             @set_time_limit(0);
             if ($this->handleImport($context, $doc, $errors, $issues, $articles, false)) {
                 $templateMgr->assign_by_ref('issues', $issues);
                 $templateMgr->assign_by_ref('articles', $articles);
                 return $templateMgr->display($this->getTemplatePath() . 'importSuccess.tpl');
             } else {
                 $templateMgr->assign_by_ref('errors', $errors);
                 return $templateMgr->display($this->getTemplatePath() . 'importError.tpl');
             }
             break;
         default:
             $this->setBreadcrumbs();
             $templateMgr->display($this->getTemplatePath() . 'index.tpl');
     }
 }
예제 #5
0
 function display(&$args)
 {
     $templateMgr =& TemplateManager::getManager();
     $request =& $this->getRequest();
     parent::display($args);
     $conference =& $request->getConference();
     $schedConf =& $request->getSchedConf();
     switch (array_shift($args)) {
         case 'exportPaper':
             $paperIds = array(array_shift($args));
             $result = array_shift(PaperSearch::formatResults($paperIds));
             $this->exportPaper($schedConf, $result['track'], $result['publishedPaper']);
             break;
         case 'exportPapers':
             $paperIds = $request->getUserVar('paperId');
             if (!isset($paperIds)) {
                 $paperIds = array();
             }
             $results =& PaperSearch::formatResults($paperIds);
             $this->exportPapers($results);
             break;
         case 'papers':
             // Display a list of papers for export
             $this->setBreadcrumbs(array(), true);
             $publishedPaperDao = DAORegistry::getDAO('PublishedPaperDAO');
             $rangeInfo = Handler::getRangeInfo($request, 'papers');
             $paperIds = $publishedPaperDao->getPublishedPaperIdsAlphabetizedBySchedConf($conference->getId(), $schedConf->getId());
             $totalPapers = count($paperIds);
             if ($rangeInfo->isValid()) {
                 $paperIds = array_slice($paperIds, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
             }
             import('lib.pkp.classes.core.VirtualArrayIterator');
             $iterator = new VirtualArrayIterator(PaperSearch::formatResults($paperIds), $totalPapers, $rangeInfo->getPage(), $rangeInfo->getCount());
             $templateMgr->assign_by_ref('papers', $iterator);
             $templateMgr->display($this->getTemplatePath() . 'papers.tpl');
             break;
         case 'import':
             import('classes.file.TemporaryFileManager');
             $trackDao = DAORegistry::getDAO('TrackDAO');
             $user =& $request->getUser();
             $temporaryFileManager = new TemporaryFileManager();
             if ($existingFileId = $request->getUserVar('temporaryFileId')) {
                 // The user has just entered more context. Fetch an existing file.
                 $temporaryFile = $temporaryFileManager->getFile($existingFileId, $user->getId());
             } else {
                 $temporaryFile = $temporaryFileManager->handleUpload('importFile', $user->getId());
             }
             $context = array('conference' => $conference, 'schedConf' => $schedConf, 'user' => $user);
             if ($trackId = $request->getUserVar('trackId')) {
                 $context['track'] = $trackDao->getTrack($trackId);
             }
             if (!$temporaryFile) {
                 $templateMgr->assign('error', 'plugins.importexport.native.error.uploadFailed');
                 return $templateMgr->display($this->getTemplatePath() . 'importError.tpl');
             }
             $doc =& $this->getDocument($temporaryFile->getFilePath());
             if (substr($this->getRootNodeName($doc), 0, 5) === 'paper') {
                 // Ensure the user has supplied enough valid information to
                 // import papers within an appropriate context. If not,
                 // prompt them for the.
                 if (!isset($context['track'])) {
                     AppLocale::requireComponents(LOCALE_COMPONENT_APP_AUTHOR);
                     $templateMgr->assign('trackOptions', array('0' => __('author.submit.selectTrack')) + $trackDao->getTrackTitles($schedConf->getId(), false));
                     $templateMgr->assign('temporaryFileId', $temporaryFile->getId());
                     return $templateMgr->display($this->getTemplatePath() . 'paperContext.tpl');
                 }
             }
             @set_time_limit(0);
             if ($this->handleImport($context, $doc, $errors, $papers, false)) {
                 $templateMgr->assign_by_ref('papers', $papers);
                 return $templateMgr->display($this->getTemplatePath() . 'importSuccess.tpl');
             } else {
                 $templateMgr->assign_by_ref('errors', $errors);
                 return $templateMgr->display($this->getTemplatePath() . 'importError.tpl');
             }
             break;
         default:
             $this->setBreadcrumbs();
             $templateMgr->display($this->getTemplatePath() . 'index.tpl');
     }
 }
 /**
  * Save settings.
  */
 function execute()
 {
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO');
     $application =& PKPApplication::getApplication();
     $request =& $application->getRequest();
     $user =& $request->getUser();
     $router =& $request->getRouter();
     $journal =& $router->getContext($request);
     $article = new Article();
     $article->setLocale($journal->getPrimaryLocale());
     // FIXME in bug #5543
     $article->setUserId($user->getId());
     $article->setJournalId($journal->getId());
     $article->setSectionId($this->getData('sectionId'));
     $article->setLanguage(String::substr($journal->getPrimaryLocale(), 0, 2));
     $article->setTitle($this->getData('title'), null);
     // Localized
     $article->setAbstract($this->getData('abstract'), null);
     // Localized
     $article->setDiscipline($this->getData('discipline'), null);
     // Localized
     $article->setSubjectClass($this->getData('subjectClass'), null);
     // Localized
     $article->setSubject($this->getData('subject'), null);
     // Localized
     $article->setCoverageGeo($this->getData('coverageGeo'), null);
     // Localized
     $article->setCoverageChron($this->getData('coverageChron'), null);
     // Localized
     $article->setCoverageSample($this->getData('coverageSample'), null);
     // Localized
     $article->setType($this->getData('type'), null);
     // Localized
     $article->setSponsor($this->getData('sponsor'), null);
     // Localized
     $article->setCitations($this->getData('citations'));
     $article->setPages($this->getData('pages'));
     // Set some default values so the ArticleDAO doesn't complain when adding this article
     $article->setDateSubmitted(Core::getCurrentDate());
     $article->setStatus(STATUS_PUBLISHED);
     $article->setSubmissionProgress(0);
     $article->stampStatusModified();
     $article->setCurrentRound(1);
     $article->setFastTracked(1);
     $article->setHideAuthor(0);
     $article->setCommentsStatus(0);
     // Insert the article to get it's ID
     $articleDao->insertArticle($article);
     $articleId = $article->getId();
     // Add authors
     $authors = $this->getData('authors');
     for ($i = 0, $count = count($authors); $i < $count; $i++) {
         if ($authors[$i]['authorId'] > 0) {
             // Update an existing author
             $author =& $article->getAuthor($authors[$i]['authorId']);
             $isExistingAuthor = true;
         } else {
             // Create a new author
             $author = new Author();
             $isExistingAuthor = false;
         }
         if ($author != null) {
             $author->setSubmissionId($articleId);
             $author->setFirstName($authors[$i]['firstName']);
             $author->setMiddleName($authors[$i]['middleName']);
             $author->setLastName($authors[$i]['lastName']);
             if (array_key_exists('affiliation', $authors[$i])) {
                 $author->setAffiliation($authors[$i]['affiliation'], null);
             }
             $author->setCountry($authors[$i]['country']);
             $author->setEmail($authors[$i]['email']);
             $author->setUrl($authors[$i]['url']);
             if (array_key_exists('competingInterests', $authors[$i])) {
                 $author->setCompetingInterests($authors[$i]['competingInterests'], null);
             }
             $author->setBiography($authors[$i]['biography'], null);
             $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0);
             $author->setSequence($authors[$i]['seq']);
             if ($isExistingAuthor == false) {
                 $article->addAuthor($author);
             }
         }
     }
     // Add the submission files as galleys
     import('classes.file.TemporaryFileManager');
     import('classes.file.ArticleFileManager');
     $tempFileIds = $this->getData('tempFileId');
     $temporaryFileManager = new TemporaryFileManager();
     $articleFileManager = new ArticleFileManager($articleId);
     foreach (array_keys($tempFileIds) as $locale) {
         $temporaryFile = $temporaryFileManager->getFile($tempFileIds[$locale], $user->getId());
         $fileId = null;
         if ($temporaryFile) {
             $fileId = $articleFileManager->temporaryFileToArticleFile($temporaryFile, ARTICLE_FILE_SUBMISSION);
             $fileType = $temporaryFile->getFileType();
             if (strstr($fileType, 'html')) {
                 import('classes.article.ArticleHTMLGalley');
                 $galley = new ArticleHTMLGalley();
             } else {
                 import('classes.article.ArticleGalley');
                 $galley = new ArticleGalley();
             }
             $galley->setArticleId($articleId);
             $galley->setFileId($fileId);
             $galley->setLocale($locale);
             if ($galley->isHTMLGalley()) {
                 $galley->setLabel('HTML');
             } else {
                 if (strstr($fileType, 'pdf')) {
                     $galley->setLabel('PDF');
                 } else {
                     if (strstr($fileType, 'postscript')) {
                         $galley->setLabel('Postscript');
                     } else {
                         if (strstr($fileType, 'xml')) {
                             $galley->setLabel('XML');
                         } else {
                             $galley->setLabel(__('common.untitled'));
                         }
                     }
                 }
             }
             $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO');
             $galleyDao->insertGalley($galley);
         }
         if ($locale == $journal->getPrimaryLocale()) {
             $article->setSubmissionFileId($fileId);
             $article->SetReviewFileId($fileId);
         }
         // Update file search index
         import('classes.search.ArticleSearchIndex');
         if (isset($galley)) {
             ArticleSearchIndex::updateFileIndex($galley->getArticleId(), ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId());
         }
     }
     // Designate this as the review version by default.
     $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO');
     $authorSubmission =& $authorSubmissionDao->getAuthorSubmission($articleId);
     import('classes.submission.author.AuthorAction');
     AuthorAction::designateReviewVersion($authorSubmission, true);
     // Accept the submission
     $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($articleId);
     $articleFileManager = new ArticleFileManager($articleId);
     $sectionEditorSubmission->setReviewFile($articleFileManager->getFile($article->getSubmissionFileId()));
     import('classes.submission.sectionEditor.SectionEditorAction');
     SectionEditorAction::recordDecision($sectionEditorSubmission, SUBMISSION_EDITOR_DECISION_ACCEPT);
     // Create signoff infrastructure
     $copyeditInitialSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditAuthorSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditFinalSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditInitialSignoff->setUserId(0);
     $copyeditAuthorSignoff->setUserId($user->getId());
     $copyeditFinalSignoff->setUserId(0);
     $signoffDao->updateObject($copyeditInitialSignoff);
     $signoffDao->updateObject($copyeditAuthorSignoff);
     $signoffDao->updateObject($copyeditFinalSignoff);
     $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
     $layoutSignoff->setUserId(0);
     $signoffDao->updateObject($layoutSignoff);
     $proofAuthorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
     $proofProofreaderSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId);
     $proofLayoutEditorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
     $proofAuthorSignoff->setUserId($user->getId());
     $proofProofreaderSignoff->setUserId(0);
     $proofLayoutEditorSignoff->setUserId(0);
     $signoffDao->updateObject($proofAuthorSignoff);
     $signoffDao->updateObject($proofProofreaderSignoff);
     $signoffDao->updateObject($proofLayoutEditorSignoff);
     import('classes.author.form.submit.AuthorSubmitForm');
     AuthorSubmitForm::assignEditors($article);
     $articleDao->updateArticle($article);
     // Add to end of editing queue
     import('classes.submission.editor.EditorAction');
     if (isset($galley)) {
         EditorAction::expediteSubmission($article);
     }
     if ($this->getData('destination') == "issue") {
         // Add to an existing issue
         $issueId = $this->getData('issueId');
         $this->scheduleForPublication($articleId, $issueId);
     }
     // Index article.
     import('classes.search.ArticleSearchIndex');
     ArticleSearchIndex::indexArticleMetadata($article);
     // Import the references list.
     $citationDao =& DAORegistry::getDAO('CitationDAO');
     $rawCitationList = $article->getCitations();
     $citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $articleId, $rawCitationList);
 }
 /**
  * @see ImportExportPlugin::display()
  */
 function display(&$args, $request)
 {
     $templateMgr = TemplateManager::getManager($request);
     parent::display($args, $request);
     $issueDao = DAORegistry::getDAO('IssueDAO');
     $journal = $request->getJournal();
     switch (array_shift($args)) {
         case 'exportIssues':
             $issueIds = $request->getUserVar('issueId');
             if (!isset($issueIds)) {
                 $issueIds = array();
             }
             $issues = array();
             foreach ($issueIds as $issueId) {
                 $issue = $issueDao->getById($issueId, $journal->getId());
                 if (!$issue) {
                     $request->redirect();
                 }
                 $issues[] = $issue;
             }
             $this->exportPubIdsForIssues($journal, $issues);
             break;
         case 'exportIssue':
             $issueId = array_shift($args);
             $issue = $issueDao->getById($issueId, $journal->getId());
             if (!$issue) {
                 $request->redirect();
             }
             $issues = array($issue);
             $this->exportPubIdsForIssues($journal, $issues);
             break;
         case 'selectIssue':
             // Display a list of issues for export
             AppLocale::requireComponents(array(LOCALE_COMPONENT_APP_EDITOR));
             $issueDao = DAORegistry::getDAO('IssueDAO');
             $issues = $issueDao->getIssues($journal->getId(), Handler::getRangeInfo($this->getRequest(), 'issues'));
             $templateMgr->assign('issues', $issues);
             $templateMgr->display($this->getTemplatePath() . 'selectIssue.tpl');
             break;
         case 'import':
             import('lib.pkp.classes.file.TemporaryFileManager');
             $user = $request->getUser();
             $temporaryFileManager = new TemporaryFileManager();
             if ($existingFileId = $request->getUserVar('temporaryFileId')) {
                 // The user has just entered more context. Fetch an existing file.
                 $temporaryFile = $temporaryFileManager->getFile($existingFileId, $user->getId());
             } else {
                 $temporaryFile = $temporaryFileManager->handleUpload('importFile', $user->getId());
             }
             if (!$temporaryFile) {
                 $templateMgr->assign('error', 'plugins.importexport.pubIds.import.error.uploadFailed');
                 return $templateMgr->display($this->getTemplatePath() . 'importResults.tpl');
             }
             $context = array('journal' => $journal);
             $doc =& $this->getDocument($temporaryFile->getFilePath());
             @set_time_limit(0);
             $this->handleImport($context, $doc, $errors, $pubIds, false);
             $templateMgr->assign('errors', $errors);
             $templateMgr->assign('pubIds', $pubIds);
             return $templateMgr->display($this->getTemplatePath() . 'importResults.tpl');
             break;
         default:
             $templateMgr->display($this->getTemplatePath() . 'importExportIndex.tpl');
     }
 }
 /**
  * Save settings.
  */
 function execute($editArticleId)
 {
     $this->editArticleID = $editArticleId;
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO');
     $application =& PKPApplication::getApplication();
     $request =& $application->getRequest();
     $user =& $request->getUser();
     $router =& $request->getRouter();
     $journal =& $router->getContext($request);
     $article = new Article();
     $article->setLocale($journal->getPrimaryLocale());
     // FIXME in bug #5543
     $article->setUserId($user->getId());
     $article->setJournalId($journal->getId());
     $article->setSectionId($this->getData('sectionId'));
     $article->setLanguage(String::substr($journal->getPrimaryLocale(), 0, 2));
     $article->setTitle($this->getData('title'), null);
     // Localized
     //add Original Journal to Abstract
     $orig_journal = $this->getData('originalJournal');
     $abstr = $this->getData('abstract');
     foreach (array_keys($abstr) as $abs_key) {
         $abstr[$abs_key] .= '  <p id="originalPub"> ' . $orig_journal . ' </p> ';
         //		$abstr[$abs_key] .=  '  <p id="originalPub"> ' . $orig_journal[$abs_key]. ' </p> ';
         //OriginalJournal in EditPlugin only a string and not an array...
         $this->setData('abstract', $abstr);
     }
     $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);
     // As article has an ID already set it
     $article->setId($this->editArticleID);
     $articleId = $this->editArticleID;
     //delete prior Authors to prevent from double saving the same authors
     $authorDao =& DAORegistry::getDAO('AuthorDAO');
     $authorDao->deleteAuthorsByArticle($articleId);
     // Add authors
     $authors = $this->getData('authors');
     for ($i = 0, $count = count($authors); $i < $count; $i++) {
         if ($authors[$i]['authorId'] > 0) {
             // Update an existing author
             $author =& $article->getAuthor($authors[$i]['authorId']);
             $isExistingAuthor = true;
         } else {
             // Create a new author
             $author = new Author();
             $isExistingAuthor = false;
         }
         if ($author != null) {
             $author->setSubmissionId($articleId);
             $author->setFirstName($authors[$i]['firstName']);
             $author->setMiddleName($authors[$i]['middleName']);
             $author->setLastName($authors[$i]['lastName']);
             if (array_key_exists('affiliation', $authors[$i])) {
                 $author->setAffiliation($authors[$i]['affiliation'], null);
             }
             $author->setCountry($authors[$i]['country']);
             $author->setEmail($authors[$i]['email']);
             $author->setUrl($authors[$i]['url']);
             if (array_key_exists('competingInterests', $authors[$i])) {
                 $author->setCompetingInterests($authors[$i]['competingInterests'], null);
             }
             $author->setBiography($authors[$i]['biography'], null);
             $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0);
             $author->setSequence($authors[$i]['seq']);
             if ($isExistingAuthor == false) {
                 $article->addAuthor($author);
             }
         }
     }
     // Check whether the user gave a handle and create a handleSubmissionFile in case
     $submissionHandle = $this->getData('submissionHandle');
     $handleSubmissionFileId;
     $handleCheck = FALSE;
     //import FileManager before creating files because otherwise naming of the copied files failes
     import('classes.file.ArticleFileManager');
     foreach (array_keys($submissionHandle) as $locale) {
         if (!empty($submissionHandle[$locale])) {
             $this->deleteOldFile("submission/original", $articleId);
             // $this->deleteOldFile("submission/copyedit", $articleId);
             $handleCheck = TRUE;
             $handleSubmissionId = $this->createHandleTXTFile($submissionHandle[$locale], $articleId, 'submission');
             $handleSubmissionPDFId = $this->createHandlePDF($submissionHandle[$locale], $articleId, 'submission');
             //Add the handle submission files as galley
             $this->setGalley($articleId, $handleSubmissionPDFId, $locale, 'application/pdf');
         }
         if ($handleCheck == TRUE) {
             if ($locale == $journal->getPrimaryLocale()) {
                 $article->setSubmissionFileId($handleSubmissionPDFId);
                 $article->SetReviewFileId($handleSubmissionPDFId);
             }
             // Update file search index
             import('classes.search.ArticleSearchIndex');
             if (isset($galley)) {
                 ArticleSearchIndex::updateFileIndex($galley->getArticleId(), ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId());
             }
         }
     }
     // 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);
     $tempFileCheck = FALSE;
     foreach (array_keys($tempFileIds) as $locale) {
         $temporaryFile = $temporaryFileManager->getFile($tempFileIds[$locale], $user->getId());
         $fileId = null;
         if ($temporaryFile) {
             $this->deleteOldFile("submission/original", $articleId);
             $this->deleteOldFile("submission/copyedit", $articleId);
             $tempFileCheck = TRUE;
             $fileId = $articleFileManager->temporaryFileToArticleFile($temporaryFile, ARTICLE_FILE_SUBMISSION);
             $fileType = $temporaryFile->getFileType();
             $this->setGalley($articleId, $fileId, $locale, $fileType);
             // $galley =& $this->setGalley($articleId, $fileId, $locale, $fileType);
         }
         if ($tempFileCheck == TRUE) {
             if ($locale == $journal->getPrimaryLocale()) {
                 $article->setSubmissionFileId($fileId);
                 $article->SetReviewFileId($fileId);
             }
             // Update file search index
             import('classes.search.ArticleSearchIndex');
             if (isset($galley)) {
                 ArticleSearchIndex::updateFileIndex($galley->getArticleId(), ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId());
             }
         }
     }
     //Check whether the user gave a handle and create handleSupplFile in case
     $supplHandle = $this->getData('supplHandle');
     $handleSuppFileId = null;
     foreach (array_keys($supplHandle) as $locale) {
         if (!empty($supplHandle[$locale])) {
             $this->deleteOldFile("supp", $articleId);
             $handleSuppFileId = $this->createHandleTXTFile($supplHandle[$locale], $articleId, 'supplementary');
             $handleSupplPDFFileID = $this->createHandlePDF($submissionHandle[$locale], $articleId, 'supplementary');
         }
     }
     //Add uploaded Supplementary file
     $tempSupplFileIds = $this->getData('tempSupplFileId');
     foreach (array_keys($tempSupplFileIds) as $locale) {
         $temporaryFile = $temporaryFileManager->getFile($tempSupplFileIds[$locale], $user->getId());
         $fileId = null;
         if ($temporaryFile) {
             $this->deleteOldFile("supp", $articleId);
             $fileId = $articleFileManager->temporaryFileToArticleFile($temporaryFile, ARTICLE_FILE_SUPP);
             $fileType = $temporaryFile->getFileType();
         }
     }
     // Designate this as the review version by default.
     /*$authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO');
     		$authorSubmission =& $authorSubmissionDao->getAuthorSubmission($articleId);
     		import('classes.submission.author.AuthorAction');
     		AuthorAction::designateReviewVersion($authorSubmission, true);
     */
     // Accept the submission
     /*$sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($articleId);
     		$articleFileManager = new ArticleFileManager($articleId);
     		$sectionEditorSubmission->setReviewFile($articleFileManager->getFile($article->getSubmissionFileId()));
     		import('classes.submission.sectionEditor.SectionEditorAction');
     		SectionEditorAction::recordDecision($sectionEditorSubmission, SUBMISSION_EDITOR_DECISION_ACCEPT);
     */
     // Create signoff infrastructure
     $copyeditInitialSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditAuthorSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditFinalSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditInitialSignoff->setUserId(0);
     $copyeditAuthorSignoff->setUserId($user->getId());
     $copyeditFinalSignoff->setUserId(0);
     $signoffDao->updateObject($copyeditInitialSignoff);
     $signoffDao->updateObject($copyeditAuthorSignoff);
     $signoffDao->updateObject($copyeditFinalSignoff);
     $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
     $layoutSignoff->setUserId(0);
     $signoffDao->updateObject($layoutSignoff);
     $proofAuthorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
     $proofProofreaderSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId);
     $proofLayoutEditorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
     $proofAuthorSignoff->setUserId($user->getId());
     $proofProofreaderSignoff->setUserId(0);
     $proofLayoutEditorSignoff->setUserId(0);
     $signoffDao->updateObject($proofAuthorSignoff);
     $signoffDao->updateObject($proofProofreaderSignoff);
     $signoffDao->updateObject($proofLayoutEditorSignoff);
     import('classes.author.form.submit.AuthorSubmitForm');
     AuthorSubmitForm::assignEditors($article);
     $articleDao->updateArticle($article);
     // Add to end of editing queue
     import('classes.submission.editor.EditorAction');
     if (isset($galley)) {
         EditorAction::expediteSubmission($article);
     }
     // As the article already has an issue, just get it from database
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $issue =& $issueDao->getIssueByArticleId($this->editArticleID);
     $issueId = $issue->getIssueId();
     //$this->scheduleForPublication($articleId, $issueId);
     // Index article.
     import('classes.search.ArticleSearchIndex');
     ArticleSearchIndex::indexArticleMetadata($article);
     // Import the references list.
     $citationDao =& DAORegistry::getDAO('CitationDAO');
     $rawCitationList = $article->getCitations();
     $citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $articleId, $rawCitationList);
 }