Example #1
0
 /**
  * Return string containing the contents of the HTML file.
  * This function performs any necessary filtering, like image URL replacement.
  * @param $baseImageUrl string base URL for image references
  * @return string
  */
 function getHTMLContents()
 {
     import('classes.file.ArticleFileManager');
     $fileManager = new ArticleFileManager($this->getArticleId());
     $contents = $fileManager->readFile($this->getFileId());
     $journal =& Request::getJournal();
     // Replace media file references
     $images =& $this->getImageFiles();
     foreach ($images as $image) {
         $imageUrl = Request::url(null, 'article', 'viewFile', array($this->getArticleId(), $this->getBestGalleyId($journal), $image->getFileId()));
         $pattern = preg_quote(rawurlencode($image->getOriginalFileName()));
         $contents = preg_replace('/([Ss][Rr][Cc]|[Hh][Rr][Ee][Ff]|[Dd][Aa][Tt][Aa])\\s*=\\s*"([^"]*' . $pattern . ')"/', '\\1="' . $imageUrl . '"', $contents);
         // Replacement for Flowplayer
         $contents = preg_replace('/[Uu][Rr][Ll]\\s*\\:\\s*\'(' . $pattern . ')\'/', 'url:\'' . $imageUrl . '\'', $contents);
         // Replacement for other players (ested with odeo; yahoo and google player won't work w/ OJS URLs, might work for others)
         $contents = preg_replace('/[Uu][Rr][Ll]=([^"]*' . $pattern . ')/', 'url=' . $imageUrl, $contents);
     }
     // Perform replacement for ojs://... URLs
     $contents = String::regexp_replace_callback('/(<[^<>]*")[Oo][Jj][Ss]:\\/\\/([^"]+)("[^<>]*>)/', array(&$this, '_handleOjsUrl'), $contents);
     // Perform variable replacement for journal, issue, site info
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $issue =& $issueDao->getIssueByArticleId($this->getArticleId());
     $journal =& Request::getJournal();
     $site =& Request::getSite();
     $paramArray = array('issueTitle' => $issue ? $issue->getIssueIdentification() : Locale::translate('editor.article.scheduleForPublication.toBeAssigned'), 'journalTitle' => $journal->getLocalizedTitle(), 'siteTitle' => $site->getLocalizedTitle(), 'currentUrl' => Request::getRequestUrl());
     foreach ($paramArray as $key => $value) {
         $contents = str_replace('{$' . $key . '}', $value, $contents);
     }
     return $contents;
 }
 public function testNativeDoiImport()
 {
     $testfile = 'tests/functional/plugins/importexport/native/testissue.xml';
     $args = array('import', $testfile, 'test', 'admin');
     $result = $this->executeCli('NativeImportExportPlugin', $args);
     self::assertRegExp('/##plugins.importexport.native.import.success.description##/', $result);
     $daos = array('Issue' => 'IssueDAO', 'PublishedArticle' => 'PublishedArticleDAO', 'Galley' => 'ArticleGalleyDAO', 'SuppFile' => 'SuppFileDAO');
     $articelId = null;
     foreach ($daos as $objectType => $daoName) {
         $dao = DAORegistry::getDAO($daoName);
         $pubObject = call_user_func(array($dao, "get{$objectType}ByPubId"), 'doi', $this->expectedDois[$objectType]);
         self::assertNotNull($pubObject, "Error while testing {$objectType}: object or DOI has not been imported.");
         $pubObjectByURN = call_user_func(array($dao, "get{$objectType}ByPubId"), 'other::urn', $this->expectedURNs[$objectType]);
         self::assertNotNull($pubObjectByURN, "Error while testing {$objectType}: object or URN has not been imported.");
         if ($objectType == 'PublishedArticle') {
             $articelId = $pubObject->getId();
         }
     }
     // Trying to import the same file again should lead to an error.
     $args = array('import', $testfile, 'test', 'admin');
     $result = $this->executeCli('NativeImportExportPlugin', $args);
     self::assertRegExp('/##plugins.importexport.native.import.error.duplicatePubId##/', $result);
     // Delete inserted article files from the filesystem.
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($articelId);
     $articleFileManager->deleteArticleTree();
 }
Example #3
0
 /**
  * Return absolute path to the file on the host filesystem.
  * @return string
  */
 function getFilePath()
 {
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $article =& $articleDao->getArticle($this->getArticleId());
     $journalId = $article->getJournalId();
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($this->getArticleId());
     return Config::getVar('files', 'files_dir') . '/journals/' . $journalId . '/articles/' . $this->getArticleId() . '/' . $articleFileManager->fileStageToPath($this->getFileStage()) . '/' . $this->getFileName();
 }
 /**
  * Delete a submission.
  */
 function deleteSubmission($args)
 {
     $articleId = isset($args[0]) ? (int) $args[0] : 0;
     $this->validate($articleId);
     $authorSubmission =& $this->submission;
     $this->setupTemplate(true);
     // If the submission is incomplete, allow the author to delete it.
     if ($authorSubmission->getSubmissionProgress() != 0) {
         import('classes.file.ArticleFileManager');
         $articleFileManager = new ArticleFileManager($articleId);
         $articleFileManager->deleteArticleTree();
         $articleDao =& DAORegistry::getDAO('ArticleDAO');
         $articleDao->deleteArticleById($args[0]);
     }
     Request::redirect(null, null, 'index');
 }
 /**
  * Upload the submission file.
  * @param $fileName string
  * @return boolean
  */
 function uploadSubmissionFile($fileName)
 {
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($this->articleId);
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     if ($articleFileManager->uploadedFileExists($fileName)) {
         // upload new submission file, overwriting previous if necessary
         $submissionFileId = $articleFileManager->uploadSubmissionFile($fileName, $this->article->getSubmissionFileId(), true);
     }
     if (isset($submissionFileId)) {
         $this->article->setSubmissionFileId($submissionFileId);
         return $articleDao->updateArticle($this->article);
     } else {
         return false;
     }
 }
 /**
  * Add a file to the search index.
  * @param $articleId int
  * @param $type int
  * @param $fileId int
  */
 function updateFileIndex($articleId, $type, $fileId)
 {
     import('classes.file.ArticleFileManager');
     $fileMgr = new ArticleFileManager($articleId);
     $file =& $fileMgr->getFile($fileId);
     if (isset($file)) {
         $parser =& SearchFileParser::fromFile($file);
     }
     if (isset($parser)) {
         if ($parser->open()) {
             $searchDao =& DAORegistry::getDAO('ArticleSearchDAO');
             $objectId = $searchDao->insertObject($articleId, $type, $fileId);
             $position = 0;
             while (($text = $parser->read()) !== false) {
                 ArticleSearchIndex::indexObjectKeywords($objectId, $text, $position);
             }
             $parser->close();
         }
     }
 }
 /**
  * Delete a submission.
  * @param $args array
  * @param $request PKPRequest
  */
 function deleteSubmission($args, $request)
 {
     $articleId = (int) array_shift($args);
     $this->validate($request, $articleId);
     $authorSubmission =& $this->submission;
     $this->setupTemplate($request, true);
     // If the submission is incomplete, allow the author to delete it.
     if ($authorSubmission->getSubmissionProgress() != 0) {
         import('classes.file.ArticleFileManager');
         $articleFileManager = new ArticleFileManager($articleId);
         $articleFileManager->deleteArticleTree();
         $articleDao =& DAORegistry::getDAO('ArticleDAO');
         $articleDao->deleteArticleById($articleId);
         import('classes.search.ArticleSearchIndex');
         $articleSearchIndex = new ArticleSearchIndex();
         $articleSearchIndex->articleDeleted($articleId);
         $articleSearchIndex->articleChangesFinished();
     }
     $request->redirect(null, null, 'index');
 }
 /**
  * Delete submission data and associated files
  */
 function execute()
 {
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     foreach ($this->parameters as $articleId) {
         $article =& $articleDao->getArticle($articleId);
         if (isset($article)) {
             // remove files first, to prevent orphans
             $articleFileManager = new ArticleFileManager($articleId);
             if (!file_exists($articleFileManager->filesDir)) {
                 printf("Warning: no files found for submission {$articleId}.\n");
             } else {
                 if (!is_writable($articleFileManager->filesDir)) {
                     printf("Error: Skipping submission {$articleId}. Can't delete files in " . $articleFileManager->filesDir . "\n");
                     continue;
                 } else {
                     $articleFileManager->deleteArticleTree();
                 }
             }
             $articleDao->deleteArticleById($articleId);
             continue;
         }
         printf("Error: Skipping {$articleId}. Unknown submission.\n");
     }
 }
Example #9
0
 /**
  * Upload the copyedited version of an article.
  * @param $copyeditorSubmission object
  * @param $copyeditStage string
  * @param $request object
  */
 function uploadCopyeditVersion($copyeditorSubmission, $copyeditStage, $request)
 {
     import('classes.file.ArticleFileManager');
     $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
     $copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO');
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     if ($copyeditStage == 'initial') {
         $signoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $copyeditorSubmission->getId());
     } else {
         if ($copyeditStage == 'final') {
             $signoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $copyeditorSubmission->getId());
         }
     }
     // Only allow an upload if they're in the initial or final copyediting
     // stages.
     if ($copyeditStage == 'initial' && ($signoff->getDateNotified() == null || $signoff->getDateCompleted() != null)) {
         return;
     } else {
         if ($copyeditStage == 'final' && ($signoff->getDateNotified() == null || $signoff->getDateCompleted() != null)) {
             return;
         } else {
             if ($copyeditStage != 'initial' && $copyeditStage != 'final') {
                 return;
             }
         }
     }
     $articleFileManager = new ArticleFileManager($copyeditorSubmission->getId());
     $user =& $request->getUser();
     $fileName = 'upload';
     if ($articleFileManager->uploadedFileExists($fileName)) {
         HookRegistry::call('CopyeditorAction::uploadCopyeditVersion', array(&$copyeditorSubmission));
         if ($signoff->getFileId() != null) {
             $fileId = $articleFileManager->uploadCopyeditFile($fileName, $copyeditorSubmission->getFileBySignoffType('SIGNOFF_COPYEDITING_INITIAL', true));
         } else {
             $fileId = $articleFileManager->uploadCopyeditFile($fileName);
         }
     }
     if (isset($fileId) && $fileId != 0) {
         $signoff->setFileId($fileId);
         $signoff->setFileRevision($articleFileDao->getRevisionNumber($fileId));
         $signoffDao->updateObject($signoff);
         // Add log
         import('classes.article.log.ArticleLog');
         ArticleLog::logEvent($request, $copyeditorSubmission, ARTICLE_LOG_COPYEDITOR_FILE, 'log.copyedit.copyeditorFile', array('copyeditorName' => $user->getFullName(), 'fileId' => $fileId));
     }
 }
 function &generateArticleDom(&$doc, &$journal, &$issue, &$article, &$galley)
 {
     $unavailableString = Locale::translate('plugins.importexport.erudit.unavailable');
     $root =& XMLCustomWriter::createElement($doc, 'article');
     XMLCustomWriter::setAttribute($root, 'idprop', $journal->getId() . '-' . $issue->getId() . '-' . $article->getId() . '-' . $galley->getId(), false);
     XMLCustomWriter::setAttribute($root, 'arttype', 'article');
     $lang = $article->getLanguage();
     XMLCustomWriter::setAttribute($root, 'lang', isset($lang) ? $lang : 'en');
     XMLCustomWriter::setAttribute($root, 'processing', 'cart');
     /* --- admin --- */
     $adminNode =& XMLCustomWriter::createElement($doc, 'admin');
     XMLCustomWriter::appendChild($root, $adminNode);
     /* --- articleinfo --- */
     $articleInfoNode =& XMLCustomWriter::createElement($doc, 'articleinfo');
     XMLCustomWriter::appendChild($adminNode, $articleInfoNode);
     // The first public ID should be a full URL to the article.
     $urlIdNode =& XMLCustomWriter::createChildWithText($doc, $articleInfoNode, 'idpublic', Request::url($journal->getPath(), 'article', 'view', array($article->getId(), $galley->getId())));
     XMLCustomWriter::setAttribute($urlIdNode, 'scheme', 'sici');
     /* --- journal --- */
     $journalNode =& XMLCustomWriter::createElement($doc, 'journal');
     XMLCustomWriter::appendChild($adminNode, $journalNode);
     XMLCustomWriter::setAttribute($journalNode, 'id', 'ojs-' . $journal->getPath());
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'jtitle', $journal->getLocalizedTitle());
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'jshorttitle', $journal->getLocalizedSetting('initials'), false);
     if (!($printIssn = $journal->getSetting('printIssn'))) {
         $printIssn = $unavailableString;
     }
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'idissn', $printIssn);
     if (!($onlineIssn = $journal->getSetting('onlineIssn'))) {
         $onlineIssn = $unavailableString;
     }
     XMLCustomWriter::createChildWithText($doc, $journalNode, 'iddigissn', $onlineIssn);
     /* --- issue --- */
     $issueNode =& XMLCustomWriter::createElement($doc, 'issue');
     XMLCustomWriter::appendChild($adminNode, $issueNode);
     XMLCustomWriter::setAttribute($issueNode, 'id', 'ojs-' . $issue->getBestIssueId());
     XMLCustomWriter::createChildWithText($doc, $issueNode, 'volume', $issue->getVolume(), false);
     XMLCustomWriter::createChildWithText($doc, $issueNode, 'issueno', $issue->getNumber(), false);
     $pubNode =& XMLCustomWriter::createElement($doc, 'pub');
     XMLCustomWriter::appendChild($issueNode, $pubNode);
     XMLCustomWriter::createChildWithText($doc, $pubNode, 'year', $issue->getYear());
     $digPubNode =& XMLCustomWriter::createElement($doc, 'digpub');
     XMLCustomWriter::appendChild($issueNode, $digPubNode);
     if ($issue->getDatePublished()) {
         XMLCustomWriter::createChildWithText($doc, $digPubNode, 'date', EruditExportDom::formatDate($issue->getDatePublished()));
     }
     /* --- Publisher & DTD --- */
     $publisherInstitution =& $journal->getSetting('publisherInstitution');
     $publisherNode =& XMLCustomWriter::createElement($doc, 'publisher');
     XMLCustomWriter::setAttribute($publisherNode, 'id', 'ojs-' . $journal->getId() . '-' . $issue->getId() . '-' . $article->getId());
     XMLCustomWriter::appendChild($adminNode, $publisherNode);
     $publisherInstitution = $unavailableString;
     if (empty($publisherInstitution)) {
         $publisherInstitution = $unavailableString;
     }
     XMLCustomWriter::createChildWithText($doc, $publisherNode, 'orgname', $publisherInstitution);
     $digprodNode =& XMLCustomWriter::createElement($doc, 'digprod');
     XMLCustomWriter::createChildWithText($doc, $digprodNode, 'orgname', $publisherInstitution);
     XMLCustomWriter::setAttribute($digprodNode, 'id', 'ojs-prod-' . $journal->getId() . '-' . $issue->getId() . '-' . $article->getId());
     XMLCustomWriter::appendChild($adminNode, $digprodNode);
     $digdistNode =& XMLCustomWriter::createElement($doc, 'digdist');
     XMLCustomWriter::createChildWithText($doc, $digdistNode, 'orgname', $publisherInstitution);
     XMLCustomWriter::setAttribute($digdistNode, 'id', 'ojs-dist-' . $journal->getId() . '-' . $issue->getId() . '-' . $article->getId());
     XMLCustomWriter::appendChild($adminNode, $digdistNode);
     $dtdNode =& XMLCustomWriter::createElement($doc, 'dtd');
     XMLCustomWriter::appendChild($adminNode, $dtdNode);
     XMLCustomWriter::setAttribute($dtdNode, 'name', 'Erudit Article');
     XMLCustomWriter::setAttribute($dtdNode, 'version', '3.0.0');
     /* --- copyright --- */
     $copyright = $journal->getLocalizedSetting('copyrightNotice');
     XMLCustomWriter::createChildWithText($doc, $adminNode, 'copyright', empty($copyright) ? $unavailableString : $copyright);
     /* --- frontmatter --- */
     $frontMatterNode =& XMLCustomWriter::createElement($doc, 'frontmatter');
     XMLCustomWriter::appendChild($root, $frontMatterNode);
     $titleGroupNode =& XMLCustomWriter::createElement($doc, 'titlegr');
     XMLCustomWriter::appendChild($frontMatterNode, $titleGroupNode);
     XMLCustomWriter::createChildWithText($doc, $titleGroupNode, 'title', strip_tags($article->getLocalizedTitle()));
     /* --- authorgr --- */
     $authorGroupNode =& XMLCustomWriter::createElement($doc, 'authorgr');
     XMLCustomWriter::appendChild($frontMatterNode, $authorGroupNode);
     $authorNum = 1;
     foreach ($article->getAuthors() as $author) {
         $authorNode =& XMLCustomWriter::createElement($doc, 'author');
         XMLCustomWriter::appendChild($authorGroupNode, $authorNode);
         XMLCustomWriter::setAttribute($authorNode, 'id', 'ojs-' . $journal->getId() . '-' . $issue->getId() . '-' . $article->getId() . '-' . $galley->getId() . '-' . $authorNum);
         $persNameNode =& XMLCustomWriter::createElement($doc, 'persname');
         XMLCustomWriter::appendChild($authorNode, $persNameNode);
         XMLCustomWriter::createChildWithText($doc, $persNameNode, 'firstname', $author->getFirstName());
         XMLCustomWriter::createChildWithText($doc, $persNameNode, 'middlename', $author->getMiddleName(), false);
         XMLCustomWriter::createChildWithText($doc, $persNameNode, 'familyname', $author->getLastName());
         if ($author->getLocalizedAffiliation() != '') {
             $affiliationNode =& XMLCustomWriter::createElement($doc, 'affiliation');
             XMLCustomWriter::appendChild($authorNode, $affiliationNode);
             XMLCustomWriter::createChildWithText($doc, $affiliationNode, 'blocktext', $author->getLocalizedAffiliation(), false);
         }
         $authorNum++;
     }
     /* --- abstract and keywords --- */
     foreach ((array) $article->getAbstract(null) as $locale => $abstract) {
         $abstract = strip_tags($abstract);
         $abstractNode =& XMLCustomWriter::createElement($doc, 'abstract');
         XMLCustomWriter::setAttribute($abstractNode, 'lang', $locale);
         XMLCustomWriter::appendChild($frontMatterNode, $abstractNode);
         XMLCustomWriter::createChildWithText($doc, $abstractNode, 'blocktext', $abstract);
         unset($abstractNode);
     }
     if ($keywords = $article->getLocalizedSubject()) {
         $keywordGroupNode =& XMLCustomWriter::createElement($doc, 'keywordgr');
         XMLCustomWriter::setAttribute($keywordGroupNode, 'lang', ($language = $article->getLanguage()) ? $language : 'en');
         foreach (explode(';', $keywords) as $keyword) {
             XMLCustomWriter::createChildWithText($doc, $keywordGroupNode, 'keyword', trim($keyword), false);
         }
         XMLCustomWriter::appendChild($frontMatterNode, $keywordGroupNode);
     }
     /* --- body --- */
     $bodyNode =& XMLCustomWriter::createElement($doc, 'body');
     XMLCustomWriter::appendChild($root, $bodyNode);
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($article->getId());
     $file =& $articleFileManager->getFile($galley->getFileId());
     $parser =& SearchFileParser::fromFile($file);
     if (isset($parser)) {
         if ($parser->open()) {
             // File supports text indexing.
             $textNode =& XMLCustomWriter::createElement($doc, 'text');
             XMLCustomWriter::appendChild($bodyNode, $textNode);
             while (($line = $parser->read()) !== false) {
                 $line = trim($line);
                 if ($line != '') {
                     XMLCustomWriter::createChildWithText($doc, $textNode, 'blocktext', $line, false);
                 }
             }
             $parser->close();
         }
     }
     return $root;
 }
 /**
  * Save the email in the article email log.
  */
 function log()
 {
     import('classes.article.log.ArticleEmailLogEntry');
     import('classes.article.log.ArticleLog');
     $entry = new ArticleEmailLogEntry();
     $article =& $this->article;
     // Log data
     $entry->setEventType($this->eventType);
     $entry->setAssocType($this->assocType);
     $entry->setAssocId($this->assocId);
     // Email data
     $entry->setSubject($this->getSubject());
     $entry->setBody($this->getBody());
     $entry->setFrom($this->getFromString(false));
     $entry->setRecipients($this->getRecipientString());
     $entry->setCcs($this->getCcString());
     $entry->setBccs($this->getBccString());
     // Add log entry
     $logEntryId = ArticleLog::logEmailEntry($article->getId(), $entry);
     // Add attachments
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($article->getId());
     foreach ($this->getAttachmentFiles() as $attachment) {
         $articleFileManager->temporaryFileToArticleFile($attachment, ARTICLE_FILE_ATTACHMENT, $logEntryId);
     }
 }
 /**
  * Upload a review on behalf of its reviewer.
  * @param $reviewId int
  */
 function uploadReviewForReviewer($reviewId, $article, $request)
 {
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $user =& $request->getUser();
     $reviewAssignment =& $reviewAssignmentDao->getById($reviewId);
     $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId(), true);
     if (HookRegistry::call('SectionEditorAction::uploadReviewForReviewer', array(&$reviewAssignment, &$reviewer))) {
         return;
     }
     // Upload the review file.
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($reviewAssignment->getSubmissionId());
     // Only upload the file if the reviewer has yet to submit a recommendation
     if (($reviewAssignment->getRecommendation() === null || $reviewAssignment->getRecommendation() === '') && !$reviewAssignment->getCancelled()) {
         $fileName = 'upload';
         if ($articleFileManager->uploadedFileExists($fileName)) {
             if ($reviewAssignment->getReviewerFileId() != null) {
                 $fileId = $articleFileManager->uploadReviewFile($fileName, $reviewAssignment->getReviewerFileId());
             } else {
                 $fileId = $articleFileManager->uploadReviewFile($fileName);
             }
         }
     }
     if (isset($fileId) && $fileId != 0) {
         // Only confirm the review for the reviewer if
         // he has not previously done so.
         if ($reviewAssignment->getDateConfirmed() == null) {
             $reviewAssignment->setDeclined(0);
             $reviewAssignment->setDateConfirmed(Core::getCurrentDate());
         }
         $reviewAssignment->setReviewerFileId($fileId);
         $reviewAssignment->stampModified();
         $reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
         // Add log
         import('classes.article.log.ArticleLog');
         ArticleLog::logEvent($request, $article, ARTICLE_LOG_REVIEW_FILE_BY_PROXY, 'log.review.reviewFileByProxy', array('reviewerName' => $reviewer->getFullName(), 'round' => $reviewAssignment->getRound(), 'userName' => $user->getFullName(), 'reviewId' => $reviewAssignment->getId()));
     }
 }
Example #13
0
 /**
  * Save changes to the report file.
  * @return int the report file ID
  */
 function execute($fileName = null)
 {
     $sectionDecisionDao =& DAORegistry::getDAO('SectionDecisionDAO');
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($this->article->getArticleId());
     $fileName = isset($fileName) ? $fileName : 'uploadReportFile';
     $lastDecision = $this->article->getLastSectionDecision();
     $lastDecisionDecision = $lastDecision->getDecision();
     $lastDecisionType = $lastDecision->getReviewType();
     // Ensure to start a new round of review when needed, and if the file to upload is correct
     if (($lastDecisionDecision == SUBMISSION_SECTION_DECISION_APPROVED || $lastDecisionDecision == SUBMISSION_SECTION_DECISION_EXEMPTED || $lastDecisionType == REVIEW_TYPE_SAE && ($lastDecisionDecision == SUBMISSION_SECTION_DECISION_INCOMPLETE || $lastDecisionDecision == SUBMISSION_SECTION_DECISION_RESUBMIT)) && $articleFileManager->uploadedFileExists($fileName)) {
         $this->fileId = $articleFileManager->uploadSAEFile($fileName);
     } else {
         $this->fileId = 0;
     }
     if ($this->fileId && $this->fileId > 0) {
         $sectionDecision =& new SectionDecision();
         $sectionDecision->setSectionId($lastDecision->getSectionId());
         $sectionDecision->setDecision(0);
         $sectionDecision->setDateDecided(date(Core::getCurrentDate()));
         $sectionDecision->setArticleId($this->article->getArticleId());
         $sectionDecision->setReviewType(REVIEW_TYPE_SAE);
         if ($lastDecisionType == $sectionDecision->getReviewType()) {
             $lastRound = (int) $lastDecision->getRound();
             $sectionDecision->setRound($lastRound + 1);
         } else {
             $sectionDecision->setRound(1);
         }
         $sectionDecisionDao->insertSectionDecision($sectionDecision);
         $articleDao->changeArticleStatus($this->article->getArticleId(), STATUS_QUEUED);
     }
     // Notifications
     import('lib.pkp.classes.notification.NotificationManager');
     $notificationManager = new NotificationManager();
     $journal =& Request::getJournal();
     $url = Request::url($journal->getPath(), 'sectionEditor', 'submission', array($this->article->getArticleId(), 'submissionReview'));
     $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
     $sectionEditors =& $sectionEditorsDao->getEditorsBySectionId($journal->getId(), $lastDecision->getSectionId());
     foreach ($sectionEditors as $sectionEditor) {
         $notificationSectionEditors[] = array('id' => $sectionEditor->getId());
     }
     foreach ($notificationSectionEditors as $userRole) {
         $notificationManager->createNotification($userRole['id'], 'notification.type.sae', $this->article->getProposalId(), $url, 1, NOTIFICATION_TYPE_METADATA_MODIFIED);
     }
     return $this->fileId;
 }
Example #14
0
 /**
  * Delete a supplementary file.
  * @param $args array, the first parameter is the supplementary file to delete
  * @param $request PKPRequest
  */
 function deleteSubmitSuppFile($args, $request)
 {
     import('classes.file.ArticleFileManager');
     $articleId = (int) $request->getUserVar('articleId');
     $suppFileId = (int) array_shift($args);
     $this->validate($request, $articleId, 4);
     $article =& $this->article;
     $this->setupTemplate($request, true);
     $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
     $suppFile = $suppFileDao->getSuppFile($suppFileId, $articleId);
     $suppFileDao->deleteSuppFileById($suppFileId, $articleId);
     if ($suppFile->getFileId()) {
         $articleFileManager = new ArticleFileManager($articleId);
         $articleFileManager->deleteFile($suppFile->getFileId());
     }
     $request->redirect(null, null, 'submit', '4', array('articleId' => $articleId));
 }
Example #15
0
 /**
  * Retrieve all article files for a type and assoc ID.
  * @param $assocId int
  * @param $type int
  * @return array ArticleFiles
  */
 function &getArticleFilesByAssocId($assocId, $type)
 {
     import('file.ArticleFileManager');
     $articleFiles = array();
     $result =& $this->retrieve('SELECT * FROM article_files WHERE assoc_id = ? AND type = ?', array($assocId, ArticleFileManager::typeToPath($type)));
     while (!$result->EOF) {
         $articleFiles[] =& $this->_returnArticleFileFromRow($result->GetRowAssoc(false));
         $result->moveNext();
     }
     $result->Close();
     unset($result);
     return $articleFiles;
 }
Example #16
0
 /**
  * Delete a submission.
  */
 function deleteSubmission($args, $request)
 {
     $articleId = (int) array_shift($args);
     $this->validate($articleId);
     parent::setupTemplate(true);
     $journal =& $request->getJournal();
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $article =& $articleDao->getArticle($articleId);
     $status = $article->getStatus();
     if ($article->getJournalId() == $journal->getId() && ($status == STATUS_DECLINED || $status == STATUS_ARCHIVED)) {
         // Delete article files
         import('classes.file.ArticleFileManager');
         $articleFileManager = new ArticleFileManager($articleId);
         $articleFileManager->deleteArticleTree();
         // Delete article database entries
         $articleDao->deleteArticleById($articleId);
     }
     $request->redirect(null, null, 'submissions', 'submissionsArchives');
 }
Example #17
0
 /**
  * Upload the revised version of a copyedit file.
  * @param $authorSubmission object
  * @param $copyeditStage string
  */
 function uploadCopyeditVersion($authorSubmission, $copyeditStage)
 {
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($authorSubmission->getId());
     $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO');
     $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     // Authors cannot upload if the assignment is not active, i.e.
     // they haven't been notified or the assignment is already complete.
     $authorSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $authorSubmission->getId());
     if (!$authorSignoff->getDateNotified() || $authorSignoff->getDateCompleted()) {
         return;
     }
     $fileName = 'upload';
     if ($articleFileManager->uploadedFileExists($fileName)) {
         HookRegistry::call('AuthorAction::uploadCopyeditVersion', array(&$authorSubmission, &$copyeditStage));
         if ($authorSignoff->getFileId() != null) {
             $fileId = $articleFileManager->uploadCopyeditFile($fileName, $authorSignoff->getFileId());
         } else {
             $fileId = $articleFileManager->uploadCopyeditFile($fileName);
         }
     }
     $authorSignoff->setFileId($fileId);
     if ($copyeditStage == 'author') {
         $authorSignoff->setFileRevision($articleFileDao->getRevisionNumber($fileId));
     }
     $signoffDao->updateObject($authorSignoff);
 }
 /**
  * Save changes to the supplementary file.
  * @return int the supplementary file ID
  */
 function execute($fileName = null)
 {
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($this->article->getArticleId());
     $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
     $fileName = isset($fileName) ? $fileName : 'uploadSuppFile';
     if (isset($this->suppFile)) {
         parent::execute();
         // Upload file, if file selected.
         if ($articleFileManager->uploadedFileExists($fileName)) {
             $fileId = $this->suppFile->getFileId();
             if ($fileId != 0) {
                 $articleFileManager->uploadSuppFile($fileName, $fileId);
             } else {
                 $fileId = $articleFileManager->uploadSuppFile($fileName);
                 $this->suppFile->setFileId($fileId);
             }
             import('classes.search.ArticleSearchIndex');
             ArticleSearchIndex::updateFileIndex($this->article->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
         }
         // Index metadata
         ArticleSearchIndex::indexSuppFileMetadata($this->suppFile);
         // Update existing supplementary file
         $this->setSuppFileData($this->suppFile);
         $suppFileDao->updateSuppFile($this->suppFile);
     } else {
         // Upload file, if file selected.
         if ($articleFileManager->uploadedFileExists($fileName)) {
             $fileId = $articleFileManager->uploadSuppFile($fileName);
             import('classes.search.ArticleSearchIndex');
             ArticleSearchIndex::updateFileIndex($this->article->getArticleId(), ARTICLE_SEARCH_SUPPLEMENTARY_FILE, $fileId);
         } else {
             $fileId = 0;
         }
         // Insert new supplementary file
         $this->suppFile = new SuppFile();
         $this->suppFile->setArticleId($this->article->getArticleId());
         $this->suppFile->setFileId($fileId);
         parent::execute();
         $this->setSuppFileData($this->suppFile);
         $suppFileDao->insertSuppFile($this->suppFile);
         $this->suppFileId = $this->suppFile->getId();
     }
     return $this->suppFileId;
 }
    function importArticles()
    {
        assert($this->xml->name == 'articles');
        $articleDAO =& DAORegistry::getDAO('ArticleDAO');
        $articles = $articleDAO->getArticlesByJournalId($this->journal->getId());
        $journalFileManager = new JournalFileManager($this->journal);
        $publicFileManager =& new PublicFileManager();
        $this->nextElement();
        while ($this->xml->name == 'article') {
            $articleXML = $this->getCurrentElementAsDom();
            $article = new Article();
            $article->setJournalId($this->journal->getId());
            $article->setUserId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $articleXML->userId));
            $article->setSectionId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_SECTION, (int) $articleXML->sectionId));
            $article->setLocale((string) $articleXML->locale);
            $article->setLanguage((string) $articleXML->language);
            $article->setCommentsToEditor((string) $articleXML->commentsToEditor);
            $article->setCitations((string) $articleXML->citations);
            $article->setDateSubmitted((string) $articleXML->dateSubmitted);
            $article->setDateStatusModified((string) $articleXML->dateStatusModified);
            $article->setLastModified((string) $articleXML->lastModified);
            $article->setStatus((int) $articleXML->status);
            $article->setSubmissionProgress((int) $articleXML->submissionProgress);
            $article->setCurrentRound((int) $articleXML->currentRound);
            $article->setPages((string) $articleXML->pages);
            $article->setFastTracked((int) $articleXML->fastTracked);
            $article->setHideAuthor((int) $articleXML->hideAuthor);
            $article->setCommentsStatus((int) $articleXML->commentsStatus);
            $articleDAO->insertArticle($article);
            $oldArticleId = (int) $articleXML->oldId;
            $this->restoreDataObjectSettings($articleDAO, $articleXML->settings, 'article_settings', 'article_id', $article->getId());
            $article =& $articleDAO->getArticle($article->getId());
            // Reload article with restored settings
            $covers = $article->getFileName(null);
            if ($covers) {
                foreach ($covers as $locale => $oldCoverFileName) {
                    $sourceFile = $this->publicFolderPath . '/' . $oldCoverFileName;
                    $extension = $publicFileManager->getExtension($oldCoverFileName);
                    $destFile = 'cover_issue_' . $article->getId() . "_{$locale}.{$extension}";
                    $publicFileManager->copyJournalFile($this->journal->getId(), $sourceFile, $destFile);
                    unlink($sourceFile);
                    $article->setFileName($destFile, $locale);
                    $articleDAO->updateArticle($article);
                }
            }
            $articleFileManager = new ArticleFileManager($article->getId());
            $authorDAO =& DAORegistry::getDAO('AuthorDAO');
            foreach ($articleXML->author as $authorXML) {
                $author = new Author();
                $author->setArticleId($article->getId());
                $author->setFirstName((string) $authorXML->firstName);
                $author->setMiddleName((string) $authorXML->middleName);
                $author->setLastName((string) $authorXML->lastName);
                $author->setSuffix((string) $authorXML->suffix);
                $author->setCountry((string) $authorXML->country);
                $author->setEmail((string) $authorXML->email);
                $author->setUrl((string) $authorXML->url);
                $author->setUserGroupId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_GROUP, (int) $authorXML->userGroupId));
                $author->setPrimaryContact((int) $authorXML->primaryContact);
                $author->setSequence((int) $authorXML->sequence);
                $authorDAO->insertAuthor($author);
                $this->restoreDataObjectSettings($authorDAO, $authorXML->settings, 'author_settings', 'author_id', $author->getId());
                unset($author);
            }
            $articleEmailLogDAO =& DAORegistry::getDAO('ArticleEmailLogDAO');
            $emailLogsXML = array();
            foreach ($articleXML->emailLogs->emailLog as $emailLogXML) {
                array_unshift($emailLogsXML, $emailLogXML);
            }
            foreach ($emailLogsXML as $emailLogXML) {
                $emailLog = new ArticleEmailLogEntry();
                $emailLog->setAssocType(ASSOC_TYPE_ARTICLE);
                $emailLog->setAssocId($article->getId());
                $emailLog->setSenderId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $emailLogXML->senderId));
                $emailLog->setDateSent((string) $emailLogXML->dateSent);
                $emailLog->setIPAddress((string) $emailLogXML->IPAddress);
                $emailLog->setEventType((int) $emailLogXML->eventType);
                $emailLog->setFrom((string) $emailLogXML->from);
                $emailLog->setRecipients((string) $emailLogXML->recipients);
                $emailLog->setCcs((string) $emailLogXML->ccs);
                $emailLog->setBccs((string) $emailLogXML->bccs);
                $emailLog->setSubject((string) $emailLogXML->subject);
                $emailLog->setBody((string) $emailLogXML->body);
                $articleEmailLogDAO->insertObject($emailLog);
                $this->idTranslationTable->register(INTERNAL_TRANSFER_OBJECT_ARTICLE_EMAIL_LOG, (int) $emailLogXML->oldId, $emailLog->getId());
            }
            $articleFileDAO =& DAORegistry::getDAO('ArticleFileDAO');
            foreach ($articleXML->articleFile as $articleFileXML) {
                try {
                    $articleFile = new ArticleFile();
                    $articleFile->setArticleId($article->getId());
                    $articleFile->setSourceFileId((int) $articleFileXML->sourceFileId);
                    $articleFile->setSourceRevision((int) $articleFileXML->sourceRevision);
                    $articleFile->setRevision((int) $articleFileXML->revision);
                    $articleFile->setFileName((string) $articleFileXML->fileName);
                    $articleFile->setFileType((string) $articleFileXML->fileType);
                    $articleFile->setFileSize((string) $articleFileXML->fileSize);
                    $articleFile->setOriginalFileName((string) $articleFileXML->originalFileName);
                    $articleFile->setFileStage((int) $articleFileXML->fileStage);
                    $articleFile->setAssocId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_EMAIL_LOG, (int) $articleFileXML->assocId));
                    $articleFile->setDateUploaded((string) $articleFileXML->dateUploaded);
                    $articleFile->setDateModified((string) $articleFileXML->dateModified);
                    $articleFile->setRound((int) $articleFileXML->round);
                    $articleFile->setViewable((int) $articleFileXML->viewable);
                    $articleFileDAO->insertArticleFile($articleFile);
                    $oldArticleFileId = (int) $articleFileXML->oldId;
                    $oldFileName = $articleFile->getFileName();
                    $stagePath = $articleFileManager->fileStageToPath($articleFile->getFileStage());
                    $fileInTransferPackage = $this->journalFolderPath . "/articles/{$oldArticleId}/{$stagePath}/{$oldFileName}";
                    $newFileName = $articleFileManager->generateFilename($articleFile, $articleFile->getFileStage(), $articleFile->getOriginalFileName());
                    $newFilePath = "/articles/" . $article->getId() . "/{$stagePath}/{$newFileName}";
                    $journalFileManager->copyFile($fileInTransferPackage, $journalFileManager->filesDir . $newFilePath);
                    unlink($fileInTransferPackage);
                    $articleFileDAO->updateArticleFile($articleFile);
                    $this->idTranslationTable->register(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, $oldArticleFileId, $articleFile->getFileId());
                } catch (Exception $e) {
                }
            }
            $articleFiles = $articleFileDAO->getArticleFilesByArticle($article->getId());
            foreach ($articleFiles as $articleFile) {
                try {
                    $articleFile->setSourceFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, $articleFile->getSourceFileId()));
                    $articleFileDAO->updateArticleFile($articleFile);
                } catch (Exception $e) {
                }
            }
            $suppFileDAO =& DAORegistry::getDAO('SuppFileDAO');
            foreach ($articleXML->suppFile as $suppFileXML) {
                $suppFile =& new SuppFile();
                $suppFile->setArticleId($article->getId());
                $suppFile->setRemoteURL((string) $suppFileXML->remoteURL);
                $suppFile->setFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $suppFileXML->fileId));
                $suppFile->setType((string) $suppFileXML->type);
                $suppFile->setDateCreated((string) $suppFileXML->dateCreated);
                $suppFile->setLanguage((string) $suppFileXML->language);
                $suppFile->setShowReviewers((int) $suppFileXML->showReviewers);
                $suppFile->setDateSubmitted((string) $suppFileXML->dateSubmitted);
                $suppFile->setSequence((int) $suppFileXML->sequence);
                $suppFileDAO->insertSuppFile($suppFile);
                $this->restoreDataObjectSettings($suppFileDAO, $suppFileXML->settings, 'article_supp_file_settings', 'supp_id', $suppFile->getId());
            }
            $articleCommentDAO =& DAORegistry::getDAO('ArticleCommentDAO');
            foreach ($articleXML->articleComment as $articleCommentXML) {
                $articleComment = new ArticleComment();
                $articleComment->setArticleId($article->getId());
                $articleComment->setAssocId($article->getId());
                $articleComment->setCommentType((int) $articleCommentXML->commentType);
                $articleComment->setRoleId((int) $articleCommentXML->roleId);
                $articleComment->setAuthorId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $articleCommentXML->authorId));
                $articleComment->setCommentTitle((string) $articleCommentXML->commentTitle);
                $articleComment->setComments((string) $articleCommentXML->comments);
                $articleComment->setDatePosted((string) $articleCommentXML->datePosted);
                $articleComment->setDateModified((string) $articleCommentXML->dateModified);
                $articleComment->setViewable((int) $articleCommentXML->viewable);
                $articleCommentDAO->insertArticleComment($articleComment);
            }
            $articleGalleyDAO =& DAORegistry::getDAO('ArticleGalleyDAO');
            foreach ($articleXML->articleGalley as $articleGalleyXML) {
                $articleGalley = null;
                if ($articleGalleyXML->htmlGalley == "1") {
                    $articleGalley = new ArticleHTMLGalley();
                } else {
                    $articleGalley = new ArticleGalley();
                }
                $articleGalley->setArticleId($article->getId());
                $articleGalley->setLocale((string) $articleGalleyXML->locale);
                $articleGalley->setFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleGalleyXML->fileId));
                $articleGalley->setLabel((string) $articleGalleyXML->label);
                $articleGalley->setSequence((int) $articleGalleyXML->sequence);
                $articleGalley->setRemoteURL((string) $articleGalleyXML->remoteURL);
                if ($articleGalley instanceof ArticleHTMLGalley) {
                    $articleGalley->setStyleFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleGalleyXML->styleFileId));
                }
                $articleGalleyDAO->insertGalley($articleGalley);
                if ($articleGalley instanceof ArticleHTMLGalley) {
                    foreach ($articleGalleyXML->htmlGalleyImage as $articleGalleyImageXML) {
                        $imageId = $this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleGalleyImageXML);
                        $articleGalleyDAO->insertGalleyImage($articleGalley->getId(), $imageId);
                    }
                }
                $this->restoreDataObjectSettings($articleGalleyDAO, $articleGalleyXML->settings, 'article_galley_settings', 'galley_id', $articleGalley->getId());
            }
            $noteDAO =& DAORegistry::getDAO('NoteDAO');
            foreach ($articleXML->articleNote as $articleNoteXML) {
                $articleNote = new Note();
                $articleNote->setUserId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $articleNoteXML->userId));
                $articleNote->setFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleNoteXML->fileId));
                $articleNote->setAssocType(ASSOC_TYPE_ARTICLE);
                $articleNote->setAssocId($article->getId());
                $articleNote->setDateCreated((string) $articleNoteXML->dateCreated);
                $articleNote->setDateModified((string) $articleNoteXML->dateModified);
                $articleNote->setContents((string) $articleNoteXML->contents);
                $articleNote->setTitle((string) $articleNoteXML->title);
                $noteDAO->insertObject($articleNote);
            }
            $editAssignmentDAO =& DAORegistry::getDAO('EditAssignmentDAO');
            foreach ($articleXML->editAssignment as $editAssignmentXML) {
                $editAssignment = new EditAssignment();
                $editAssignment->setArticleId($article->getId());
                $editAssignment->setEditorId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $editAssignmentXML->editorId));
                $editAssignment->setCanReview((int) $editAssignmentXML->canReview);
                $editAssignment->setCanEdit((int) $editAssignmentXML->canEdit);
                $editAssignment->setDateUnderway((string) $editAssignmentXML->dateUnderway);
                $editAssignment->setDateNotified((string) $editAssignmentXML->dateNotified);
                $editAssignmentDAO->insertEditAssignment($editAssignment);
            }
            $reviewAssignmentDAO =& DAORegistry::getDAO('ReviewAssignmentDAO');
            $reviewFormResponseDAO =& DAORegistry::getDAO('ReviewFormResponseDAO');
            foreach ($articleXML->reviewAssignment as $reviewAssignmentXML) {
                $reviewAssignment = new ReviewAssignment();
                $reviewAssignment->setSubmissionId($article->getId());
                $reviewAssignment->setReviewerId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $reviewAssignmentXML->reviewerId));
                try {
                    $reviewAssignment->setReviewerFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $reviewAssignmentXML->reviewerFileId));
                } catch (Exception $e) {
                    $this->logger->log("Arquivo do artigo {$oldArticleId} não encontrado. ID: " . (int) $reviewAssignmentXML->reviewerFileId . "\n");
                }
                $reviewAssignment->setReviewFormId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_REVIEW_FORM, (int) $reviewAssignmentXML->reviewFormId));
                $reviewAssignment->setReviewRoundId((int) $reviewAssignmentXML->reviewRoundId);
                $reviewAssignment->setStageId((int) $reviewAssignmentXML->stageId);
                $reviewAssignment->setReviewerFullName((string) $reviewAssignmentXML->reviewerFullName);
                $reviewAssignment->setCompetingInterests((string) $reviewAssignmentXML->competingInterests);
                $reviewAssignment->setRegretMessage((string) $reviewAssignmentXML->regretMessage);
                $reviewAssignment->setRecommendation((string) $reviewAssignmentXML->recommendation);
                $reviewAssignment->setDateAssigned((string) $reviewAssignmentXML->dateAssigned);
                $reviewAssignment->setDateNotified((string) $reviewAssignmentXML->dateNotified);
                $reviewAssignment->setDateConfirmed((string) $reviewAssignmentXML->dateConfirmed);
                $reviewAssignment->setDateCompleted((string) $reviewAssignmentXML->dateCompleted);
                $reviewAssignment->setDateAcknowledged((string) $reviewAssignmentXML->dateAcknowledged);
                $reviewAssignment->setDateDue((string) $reviewAssignmentXML->dateDue);
                $reviewAssignment->setDateResponseDue((string) $reviewAssignmentXML->dateResponseDue);
                $reviewAssignment->setLastModified((string) $reviewAssignmentXML->lastModified);
                $reviewAssignment->setDeclined((int) $reviewAssignmentXML->declined);
                $reviewAssignment->setReplaced((int) $reviewAssignmentXML->replaced);
                $reviewAssignment->setCancelled((int) $reviewAssignmentXML->cancelled);
                $reviewAssignment->setQuality((int) $reviewAssignmentXML->quality);
                $reviewAssignment->setDateRated((string) $reviewAssignmentXML->dateRated);
                $reviewAssignment->setDateReminded((string) $reviewAssignmentXML->dateReminded);
                $reviewAssignment->setReminderWasAutomatic((int) $reviewAssignmentXML->reminderWasAutomatic);
                $reviewAssignment->setRound((int) $reviewAssignmentXML->round);
                $reviewAssignment->setReviewRevision((int) $reviewAssignmentXML->reviewRevision);
                $reviewAssignment->setReviewMethod((int) $reviewAssignmentXML->reviewMethod);
                $reviewAssignment->setUnconsidered((int) $reviewAssignmentXML->unconsidered);
                $reviewAssignmentDAO->insertObject($reviewAssignment);
                foreach ($reviewAssignmentXML->formResponses->formResponse as $formResponseXML) {
                    $reviewFormResponseDAO->update('INSERT INTO review_form_responses
							(review_form_element_id, review_id, response_type, response_value)
							VALUES
							(?, ?, ?, ?)', array($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_REVIEW_FORM_ELEMENT, (int) $formResponseXML->reviewFormElementId), $reviewAssignment->getId(), (string) $formResponseXML->responseType, (string) $formResponseXML->responseValue));
                }
            }
            $signoffDAO =& DAORegistry::getDAO('SignoffDAO');
            foreach ($articleXML->signoff as $signoffXML) {
                $signoff = new Signoff();
                $signoff->setAssocType(ASSOC_TYPE_ARTICLE);
                $signoff->setAssocId($article->getId());
                $signoff->setUserId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $signoffXML->userId));
                $signoff->setFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $signoffXML->fileId));
                $signoff->setUserGroupId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_GROUP, (int) $signoffXML->userGroupId));
                $signoff->setSymbolic((string) $signoffXML->symbolic);
                $signoff->setFileRevision((int) $signoffXML->fileRevision);
                $signoff->setDateUnderway((string) $signoffXML->dateUnderway);
                $signoff->setDateNotified((string) $signoffXML->dateNotified);
                $signoff->setDateCompleted((string) $signoffXML->dateCompleted);
                $signoff->setDateAcknowledged((string) $signoffXML->dateAcknowledged);
                $signoffDAO->insertObject($signoff);
            }
            $editorSubmissionDAO =& DAORegistry::getDAO('EditorSubmissionDAO');
            foreach ($articleXML->editDecisions as $editDecisionXML) {
                $editDecisions =& $editorSubmissionDAO->update('INSERT INTO edit_decisions (article_id, round, editor_id, decision, date_decided) values (?, ?, ?, ?, ?)', array($article->getId(), (string) $editDecisionXML->round, $this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $editDecisionXML->editorId), (string) $editDecisionXML->decision, (string) $editDecisionXML->dateDecided));
            }
            $publishedArticleDAO =& DAORegistry::getDAO('PublishedArticleDAO');
            if (isset($articleXML->publishedArticle)) {
                $publishedArticleXML = $articleXML->publishedArticle;
                $publishedArticle = new PublishedArticle();
                $publishedArticle->setId($article->getId());
                $publishedArticle->setIssueId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ISSUE, (int) $publishedArticleXML->issueId));
                $publishedArticle->setDatePublished((string) $publishedArticleXML->datePublished);
                $publishedArticle->setSeq((int) $publishedArticleXML->seq);
                $publishedArticle->setAccessStatus((int) $publishedArticleXML->accessStatus);
                $publishedArticleDAO->insertPublishedArticle($publishedArticle);
            }
            $articleEventLogDAO =& DAORegistry::getDAO('ArticleEventLogDAO');
            $eventLogsXML =& iterator_to_array($articleXML->eventLogs->eventLog);
            $eventLogsXML = array();
            foreach ($articleXML->eventLogs->eventLog as $eventLogXML) {
                array_unshift($eventLogsXML, $eventLogXML);
            }
            foreach ($eventLogsXML as $eventLogXML) {
                $eventLog = new ArticleEventLogEntry();
                $eventLog->setAssocType(ASSOC_TYPE_ARTICLE);
                $eventLog->setAssocId($article->getId());
                $eventLog->setUserId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_USER, (int) $eventLogXML->userId));
                $eventLog->setDateLogged((string) $eventLogXML->dateLogged);
                $eventLog->setIPAddress((string) $eventLogXML->IPAddress);
                $eventLog->setEventType((int) $eventLogXML->eventType);
                $eventLog->setMessage((string) $eventLogXML->message);
                $eventLog->setIsTranslated((int) $eventLogXML->isTranslated);
                $articleEventLogDAO->insertObject($eventLog);
                $this->restoreDataObjectSettings($articleEventLogDAO, $eventLogXML->settings, 'event_log_settings', 'log_id', $eventLog->getId());
            }
            try {
                $article->setSubmissionFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleXML->submissionFileId));
            } catch (Exception $e) {
            }
            try {
                $article->setRevisedFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleXML->revisedFileId));
            } catch (Exception $e) {
            }
            try {
                $article->setReviewFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleXML->reviewFileId));
            } catch (Exception $e) {
            }
            try {
                $article->setEditorFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $articleXML->editorFileId));
            } catch (Exception $e) {
            }
            $articleDAO->updateArticle($article);
            $this->nextElement();
        }
    }
Example #20
0
 /**
  * Rush a new submission into the end of the editing queue.
  * @param $article object
  */
 function expediteSubmission($article, $request)
 {
     $user =& $request->getUser();
     import('classes.submission.editor.EditorAction');
     import('classes.submission.sectionEditor.SectionEditorAction');
     import('classes.submission.proofreader.ProofreaderAction');
     $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO');
     $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($article->getId());
     $submissionFile = $sectionEditorSubmission->getSubmissionFile();
     // Add a log entry before doing anything.
     import('classes.article.log.ArticleLog');
     import('classes.article.log.ArticleEventLogEntry');
     ArticleLog::logEvent($request, $article, ARTICLE_LOG_EDITOR_EXPEDITE, 'log.editor.submissionExpedited', array('editorName' => $user->getFullName()));
     // 1. Ensure that an editor is assigned.
     $editAssignments =& $sectionEditorSubmission->getEditAssignments();
     if (empty($editAssignments)) {
         // No editors are currently assigned; assign self.
         EditorAction::assignEditor($article->getId(), $user->getId(), true, false, $request);
     }
     // 2. Accept the submission and send to copyediting.
     $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($article->getId());
     if (!$sectionEditorSubmission->getFileBySignoffType('SIGNOFF_COPYEDITING_INITIAL', true)) {
         SectionEditorAction::recordDecision($sectionEditorSubmission, SUBMISSION_EDITOR_DECISION_ACCEPT, $request);
         $reviewFile = $sectionEditorSubmission->getReviewFile();
         SectionEditorAction::setCopyeditFile($sectionEditorSubmission, $reviewFile->getFileId(), $reviewFile->getRevision(), $request);
     }
     // 3. Add a galley.
     $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($article->getId());
     $galleys =& $sectionEditorSubmission->getGalleys();
     if (empty($galleys)) {
         // No galley present -- use copyediting file.
         import('classes.file.ArticleFileManager');
         $copyeditFile =& $sectionEditorSubmission->getFileBySignoffType('SIGNOFF_COPYEDITING_INITIAL');
         $fileType = $copyeditFile->getFileType();
         $articleFileManager = new ArticleFileManager($article->getId());
         $fileId = $articleFileManager->copyPublicFile($copyeditFile->getFilePath(), $fileType);
         if (strstr($fileType, 'html')) {
             $galley = new ArticleHTMLGalley();
         } else {
             $galley = new ArticleGalley();
         }
         $galley->setArticleId($article->getId());
         $galley->setFileId($fileId);
         $galley->setLocale(AppLocale::getLocale());
         if ($galley->isHTMLGalley()) {
             $galley->setLabel('HTML');
         } else {
             if (strstr($fileType, 'pdf')) {
                 $galley->setLabel('PDF');
             } else {
                 if (strstr($fileType, 'postscript')) {
                     $galley->setLabel('Postscript');
                 } else {
                     if (strstr($fileType, 'xml')) {
                         $galley->setLabel('XML');
                     } else {
                         $galley->setLabel(__('common.untitled'));
                     }
                 }
             }
         }
         $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO');
         $galleyDao->insertGalley($galley);
         // Update file search index
         import('classes.search.ArticleSearchIndex');
         ArticleSearchIndex::updateFileIndex($article->getId(), ARTICLE_SEARCH_GALLEY_FILE, $fileId);
     }
     $sectionEditorSubmission->setStatus(STATUS_QUEUED);
     $sectionEditorSubmissionDao->updateSectionEditorSubmission($sectionEditorSubmission);
 }
 /**
  * Save changes to the supplementary file.
  * @return int the supplementary file ID
  */
 function execute()
 {
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($this->articleId);
     $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
     $fileName = 'uploadSuppFile';
     // edit an existing supp file, otherwise create new supp file entry
     if (isset($this->suppFile)) {
         $suppFile =& $this->suppFile;
         // Remove old file and upload new, if file is selected.
         if ($articleFileManager->uploadedFileExists($fileName)) {
             $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
             $suppFileId = $articleFileManager->uploadSuppFile($fileName, $suppFile->getFileId(), true);
             $suppFile->setFileId($suppFileId);
         }
         // Update existing supplementary file
         $this->setSuppFileData($suppFile);
         $suppFileDao->updateSuppFile($suppFile);
     } else {
         // Upload file, if file selected.
         if ($articleFileManager->uploadedFileExists($fileName)) {
             $fileId = $articleFileManager->uploadSuppFile($fileName);
             // Insert new supplementary file
             $suppFile = new SuppFile();
             $suppFile->setArticleId($this->articleId);
             $suppFile->setFileId($fileId);
             $this->setSuppFileData($suppFile);
             $suppFileDao->insertSuppFile($suppFile);
             $this->suppFileId = $suppFile->getId();
         } else {
             $fileId = 0;
         }
     }
     return $this->suppFileId;
 }
 /**
  * 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);
 }
Example #23
0
 /**
  * Download published final report
  * @param $args ($articleId, fileId)
  */
 function downloadFinalReport($args)
 {
     $articleId = isset($args[0]) ? $args[0] : 0;
     $fileId = isset($args[1]) ? $args[1] : 0;
     import("classes.file.ArticleFileManager");
     $articleFileManager = new ArticleFileManager($articleId);
     return $articleFileManager->downloadFile($fileId);
 }
 /**
  * Delete an image from an HTML galley.
  * @param $imageId int the file ID of the image
  */
 function deleteImage($imageId)
 {
     import('classes.file.ArticleFileManager');
     $fileManager = new ArticleFileManager($this->articleId);
     $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO');
     if (isset($this->galley)) {
         $images =& $this->galley->getImageFiles();
         if (isset($images)) {
             for ($i = 0, $count = count($images); $i < $count; $i++) {
                 if ($images[$i]->getFileId() == $imageId) {
                     $fileManager->deleteFile($images[$i]->getFileId());
                     $galleyDao->deleteGalleyImage($this->galleyId, $imageId);
                     unset($images[$i]);
                     break;
                 }
             }
         }
     }
 }
 /**
  * Download a file.
  * @param $args array ($articleId, $fileId, [$revision])
  */
 function downloadFile($args)
 {
     $articleId = isset($args[0]) ? $args[0] : 0;
     $fileId = isset($args[1]) ? $args[1] : 0;
     $revision = isset($args[2]) ? $args[2] : null;
     $articleIdRepo = isset($args[3]) ? $args[3] : null;
     //TODO: validation
     //%CBP% is we have passed a PID and namespace, download the file from the repository
     import('classes.file.ArticleFileManager');
     // FIXME
     if (intval($articleId) == false && intval($fileId) == false) {
         return ArticleFileManager::downloadFile($articleId, $fileId, false, false, false, $articleIdRepo);
     } else {
         $articleFileManager = new ArticleFileManager($articleId);
         return $articleFileManager->downloadFile($fileId, $revision);
     }
 }
Example #26
0
 /**
  * Signal to the indexing back-end that an article file changed.
  *
  * @see ArticleSearchIndex::articleMetadataChanged() above for more
  * comments.
  *
  * @param $articleId int
  * @param $type int
  * @param $fileId int
  */
 function articleFileChanged($articleId, $type, $fileId)
 {
     // Check whether a search plug-in jumps in.
     $hookResult =& HookRegistry::call('ArticleSearchIndex::articleFileChanged', array($articleId, $type, $fileId));
     // If no search plug-in is activated then fall back to the
     // default database search implementation.
     if ($hookResult === false || is_null($hookResult)) {
         import('classes.file.ArticleFileManager');
         $fileManager = new ArticleFileManager($articleId);
         $file =& $fileManager->getFile($fileId);
         if (isset($file)) {
             $parser =& SearchFileParser::fromFile($file);
         }
         if (isset($parser)) {
             if ($parser->open()) {
                 $searchDao =& DAORegistry::getDAO('ArticleSearchDAO');
                 $objectId = $searchDao->insertObject($articleId, $type, $fileId);
                 $position = 0;
                 while (($text = $parser->read()) !== false) {
                     $this->_indexObjectKeywords($objectId, $text, $position);
                 }
                 $parser->close();
             }
         }
     }
 }
Example #27
0
 /**
  * View file.
  * @param $articleId int
  * @param $fileId int
  * @param $revision int
  */
 function viewFile($articleId, $fileId, $revision = null)
 {
     import('classes.file.ArticleFileManager');
     $articleFileManager = new ArticleFileManager($articleId);
     return $articleFileManager->downloadFile($fileId, $revision, true);
 }
Example #28
0
 /**
  * Download a supplementary file
  * @param $args array
  * @param $request Request
  */
 function downloadSuppFile($args, &$request)
 {
     $articleId = isset($args[0]) ? $args[0] : 0;
     $suppId = isset($args[1]) ? $args[1] : 0;
     $this->validate($request, $articleId);
     $journal =& $this->journal;
     $issue =& $this->issue;
     $article =& $this->article;
     $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
     if ($journal->getSetting('enablePublicSuppFileId')) {
         $suppFile =& $suppFileDao->getSuppFileByBestSuppFileId($article->getId(), $suppId);
     } else {
         $suppFile =& $suppFileDao->getSuppFile((int) $suppId, $article->getId());
     }
     if ($article && $suppFile) {
         import('file.ArticleFileManager');
         $articleFileManager = new ArticleFileManager($article->getId());
         if ($suppFile->isInlineable()) {
             $articleFileManager->viewFile($suppFile->getFileId());
         } else {
             $articleFileManager->downloadFile($suppFile->getFileId());
         }
     }
 }
Example #29
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();
 }
Example #30
0
 /**
  * Delete an annotated version of an article.
  * @param $reviewId int
  * @param $fileId int
  */
 function deleteReviewerVersion($reviewId, $fileId, $articleId)
 {
     import('classes.file.ArticleFileManager');
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     $reviewAssignment =& $reviewAssignmentDao->getById($reviewId);
     if (!HookRegistry::call('ReviewerAction::deleteReviewerVersion', array(&$reviewAssignment, &$fileId))) {
         $articleFileManager = new ArticleFileManager($articleId);
         $articleFileManager->deleteFile($fileId);
         //Send a notification to section editors
         import('lib.pkp.classes.notification.NotificationManager');
         $articleDao =& DAORegistry::getDAO('ArticleDAO');
         $article =& $articleDao->getArticle($articleId);
         $notificationManager = new NotificationManager();
         $notificationUsers = $article->getAssociatedUserIds(false, false);
         $user =& Request::getUser();
         $message = $article->getProposalId() . ':<br/>' . $user->getUsername();
         foreach ($notificationUsers as $userRole) {
             $url = Request::url(null, $userRole['role'], 'submission', array($article->getId(), 'submissionReview'), null, 'peerReview');
             $notificationManager->createNotification($userRole['id'], 'notification.type.reviewerFileDeleted', $message, $url, 1, NOTIFICATION_TYPE_REVIEWER_COMMENT);
         }
     }
 }