subscriptionRequired() public method

Checks if subscription is required for viewing the issue
public subscriptionRequired ( &$issue, $journal = null ) : boolean
$issue Issue
$journal Journal
return boolean
Exemplo n.º 1
0
 /**
  * Given an issue, set up the template with all the required variables for
  * issues/view.tpl to function properly (i.e. current issue and view issue).
  * @param $issue object The issue to display
  * @param $showToc boolean iff false and a custom cover page exists,
  * 	the cover page will be displayed. Otherwise table of contents
  * 	will be displayed.
  */
 function _setupIssueTemplate($request, $issue, $showToc = false)
 {
     $journal =& $request->getJournal();
     $journalId = $journal->getId();
     $templateMgr =& TemplateManager::getManager();
     if (IssueHandler::_isVisibleIssue($issue, $journalId)) {
         $issueHeadingTitle = $issue->getIssueIdentification(false, true);
         $issueCrumbTitle = $issue->getIssueIdentification(false, true);
         $locale = AppLocale::getLocale();
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $coverPagePath = $request->getBaseUrl() . '/';
         $coverPagePath .= $publicFileManager->getJournalFilesPath($journalId) . '/';
         $templateMgr->assign('coverPagePath', $coverPagePath);
         $templateMgr->assign('locale', $locale);
         $coverLocale = $issue->getFileName($locale) ? $locale : $journal->getPrimaryLocale();
         if (!$showToc && $issue->getFileName($coverLocale) && $issue->getShowCoverPage($coverLocale) && !$issue->getHideCoverPageCover($coverLocale)) {
             $templateMgr->assign('fileName', $issue->getFileName($coverLocale));
             $templateMgr->assign('width', $issue->getWidth($coverLocale));
             $templateMgr->assign('height', $issue->getHeight($coverLocale));
             $templateMgr->assign('coverPageAltText', $issue->getCoverPageAltText($coverLocale));
             $templateMgr->assign('originalFileName', $issue->getOriginalFileName($coverLocale));
             $showToc = false;
         } else {
             // Issue galleys
             $issueGalleyDao =& DAORegistry::getDAO('IssueGalleyDAO');
             $issueGalleys =& $issueGalleyDao->getGalleysByIssue($issue->getId());
             $templateMgr->assign_by_ref('issueGalleys', $issueGalleys);
             // Published articles
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $publishedArticles =& $publishedArticleDao->getPublishedArticlesInSections($issue->getId(), true);
             $publicFileManager = new PublicFileManager();
             $templateMgr->assign_by_ref('publishedArticles', $publishedArticles);
             $showToc = true;
         }
         $templateMgr->assign('showToc', $showToc);
         $templateMgr->assign_by_ref('issue', $issue);
         // Subscription Access
         import('classes.issue.IssueAction');
         $subscriptionRequired = IssueAction::subscriptionRequired($issue);
         $subscribedUser = IssueAction::subscribedUser($journal);
         $subscribedDomain = IssueAction::subscribedDomain($journal);
         $subscriptionExpiryPartial = $journal->getSetting('subscriptionExpiryPartial');
         if ($showToc && $subscriptionRequired && !$subscribedUser && !$subscribedDomain && $subscriptionExpiryPartial) {
             $templateMgr->assign('subscriptionExpiryPartial', true);
             // Partial subscription expiry for issue
             $partial = IssueAction::subscribedUser($journal, $issue->getId());
             if (!$partial) {
                 IssueAction::subscribedDomain($journal, $issue->getId());
             }
             $templateMgr->assign('issueExpiryPartial', $partial);
             // Partial subscription expiry for articles
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $publishedArticlesTemp =& $publishedArticleDao->getPublishedArticles($issue->getId());
             $articleExpiryPartial = array();
             foreach ($publishedArticlesTemp as $publishedArticle) {
                 $partial = IssueAction::subscribedUser($journal, $issue->getId(), $publishedArticle->getId());
                 if (!$partial) {
                     IssueAction::subscribedDomain($journal, $issue->getId(), $publishedArticle->getId());
                 }
                 $articleExpiryPartial[$publishedArticle->getId()] = $partial;
             }
             $templateMgr->assign_by_ref('articleExpiryPartial', $articleExpiryPartial);
         }
         $templateMgr->assign('subscriptionRequired', $subscriptionRequired);
         $templateMgr->assign('subscribedUser', $subscribedUser);
         $templateMgr->assign('subscribedDomain', $subscribedDomain);
         $templateMgr->assign('showGalleyLinks', $journal->getSetting('showGalleyLinks'));
         import('classes.payment.ojs.OJSPaymentManager');
         $paymentManager = new OJSPaymentManager($request);
         if ($paymentManager->onlyPdfEnabled()) {
             $templateMgr->assign('restrictOnlyPdf', true);
         }
         if ($paymentManager->purchaseArticleEnabled()) {
             $templateMgr->assign('purchaseArticleEnabled', true);
         }
     } else {
         $issueCrumbTitle = __('archive.issueUnavailable');
         $issueHeadingTitle = __('archive.issueUnavailable');
     }
     if ($issue && ($styleFileName = $issue->getStyleFileName())) {
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $templateMgr->addStyleSheet($request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journalId) . '/' . $styleFileName);
     }
     $templateMgr->assign('pageCrumbTitleTranslated', $issueCrumbTitle);
     $templateMgr->assign('issueHeadingTitle', $issueHeadingTitle);
 }
Exemplo n.º 2
0
 /**
  * See implementation of retrieveResults for a description of this
  * function.
  * Note that this function is also called externally to fetch
  * results for the title index, and possibly elsewhere.
  */
 function &formatResults(&$results)
 {
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $journalDao =& DAORegistry::getDAO('JournalDAO');
     $sectionDao =& DAORegistry::getDAO('SectionDAO');
     $publishedArticleCache = array();
     $articleCache = array();
     $issueCache = array();
     $issueAvailabilityCache = array();
     $journalCache = array();
     $sectionCache = array();
     $returner = array();
     foreach ($results as $articleId) {
         // Get the article, storing in cache if necessary.
         if (!isset($articleCache[$articleId])) {
             $publishedArticleCache[$articleId] =& $publishedArticleDao->getPublishedArticleByArticleId($articleId);
             $articleCache[$articleId] =& $articleDao->getArticle($articleId);
         }
         unset($article);
         $article =& $articleCache[$articleId];
         $publishedArticle =& $publishedArticleCache[$articleId];
         $sectionId = $article->getSectionId();
         if (!isset($sectionCache[$sectionId])) {
             $sectionCache[$sectionId] =& $sectionDao->getSection($sectionId);
         }
         if ($publishedArticle && $article) {
             // Get the journal, storing in cache if necessary.
             $journalId = $article->getJournalId();
             if (!isset($journalCache[$journalId])) {
                 $journalCache[$journalId] = $journalDao->getJournal($journalId);
             }
             // Get the issue, storing in cache if necessary.
             $issueId = $publishedArticle->getIssueId();
             if (!isset($issueCache[$issueId])) {
                 unset($issue);
                 $issue =& $issueDao->getIssueById($issueId);
                 $issueCache[$issueId] =& $issue;
                 import('issue.IssueAction');
                 $issueAvailabilityCache[$issueId] = !IssueAction::subscriptionRequired($issue) || IssueAction::subscribedUser($journalCache[$journalId], $issueId, $articleId) || IssueAction::subscribedDomain($journalCache[$journalId], $issueId, $articleId);
             }
             // Store the retrieved objects in the result array.
             $returner[] = array('article' => &$article, 'publishedArticle' => &$publishedArticleCache[$articleId], 'issue' => &$issueCache[$issueId], 'journal' => &$journalCache[$journalId], 'issueAvailable' => $issueAvailabilityCache[$issueId], 'section' => &$sectionCache[$sectionId]);
         }
     }
     return $returner;
 }
Exemplo n.º 3
0
 /**
  * Show index of published articles by author.
  * @param $args array
  * @param $request PKPRequest
  */
 function authors($args, &$request)
 {
     $this->validate();
     $this->setupTemplate($request, true);
     $journal =& $request->getJournal();
     $authorDao =& DAORegistry::getDAO('AuthorDAO');
     if (isset($args[0]) && $args[0] == 'view') {
         // View a specific author
         $firstName = $request->getUserVar('firstName');
         $middleName = $request->getUserVar('middleName');
         $lastName = $request->getUserVar('lastName');
         $affiliation = $request->getUserVar('affiliation');
         $country = $request->getUserVar('country');
         $publishedArticles = $authorDao->getPublishedArticlesForAuthor($journal ? $journal->getId() : null, $firstName, $middleName, $lastName, $affiliation, $country);
         // Load information associated with each article.
         $journals = array();
         $issues = array();
         $sections = array();
         $issuesUnavailable = array();
         $issueDao =& DAORegistry::getDAO('IssueDAO');
         $sectionDao =& DAORegistry::getDAO('SectionDAO');
         $journalDao =& DAORegistry::getDAO('JournalDAO');
         foreach ($publishedArticles as $article) {
             $articleId = $article->getId();
             $issueId = $article->getIssueId();
             $sectionId = $article->getSectionId();
             $journalId = $article->getJournalId();
             if (!isset($issues[$issueId])) {
                 import('classes.issue.IssueAction');
                 $issue =& $issueDao->getIssueById($issueId);
                 $issues[$issueId] =& $issue;
                 $issuesUnavailable[$issueId] = IssueAction::subscriptionRequired($issue) && (!IssueAction::subscribedUser($journal, $issueId, $articleId) && !IssueAction::subscribedDomain($journal, $issueId, $articleId));
             }
             if (!isset($journals[$journalId])) {
                 $journals[$journalId] =& $journalDao->getById($journalId);
             }
             if (!isset($sections[$sectionId])) {
                 $sections[$sectionId] =& $sectionDao->getSection($sectionId, $journalId, true);
             }
         }
         if (empty($publishedArticles)) {
             $request->redirect(null, $request->getRequestedPage());
         }
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->assign_by_ref('publishedArticles', $publishedArticles);
         $templateMgr->assign_by_ref('issues', $issues);
         $templateMgr->assign('issuesUnavailable', $issuesUnavailable);
         $templateMgr->assign_by_ref('sections', $sections);
         $templateMgr->assign_by_ref('journals', $journals);
         $templateMgr->assign('firstName', $firstName);
         $templateMgr->assign('middleName', $middleName);
         $templateMgr->assign('lastName', $lastName);
         $templateMgr->assign('affiliation', $affiliation);
         $countryDao =& DAORegistry::getDAO('CountryDAO');
         $country = $countryDao->getCountry($country);
         $templateMgr->assign('country', $country);
         $templateMgr->display('search/authorDetails.tpl');
     } else {
         // Show the author index
         $searchInitial = $request->getUserVar('searchInitial');
         $rangeInfo = $this->getRangeInfo('authors');
         $authors =& $authorDao->getAuthorsAlphabetizedByJournal(isset($journal) ? $journal->getId() : null, $searchInitial, $rangeInfo);
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->assign('searchInitial', $request->getUserVar('searchInitial'));
         $templateMgr->assign('alphaList', explode(' ', __('common.alphaList')));
         $templateMgr->assign_by_ref('authors', $authors);
         $templateMgr->display('search/authorIndex.tpl');
     }
 }
Exemplo n.º 4
0
 /**
  * @see OAIMetadataFormat#toXml
  * TODO:
  *  <copyright-holder>
  *  In Isabelle's mapping document:
  *   Article order in the issue's Table of Contents
  */
 function toXml(&$record, $format = null)
 {
     $article =& $record->getData('article');
     $journal =& $record->getData('journal');
     $section =& $record->getData('section');
     $issue =& $record->getData('issue');
     $galleys =& $record->getData('galleys');
     $articleId = $article->getId();
     // Cache issue ordering information.
     static $issueId;
     static $sectionSeq;
     if (!isset($issueId) || $issueId != $issue->getId()) {
         $sectionDao = DAORegistry::getDAO('SectionDAO');
         $issueId = $issue->getId();
         $sections = $sectionDao->getByIssueId($issueId);
         $sectionSeq = array();
         $i = 0;
         foreach ($sections as $thisSection) {
             $sectionSeq[$thisSection->getId()] = $i++;
         }
         unset($sections);
     }
     $abbreviation = $journal->getLocalizedSetting('abbreviation');
     $printIssn = $journal->getSetting('printIssn');
     $onlineIssn = $journal->getSetting('onlineIssn');
     $primaryLocale = $article->getLanguage() != '' ? $article->getLanguage() : $journal->getPrimaryLocale();
     $publisherInstitution = $journal->getSetting('publisherInstitution');
     $datePublished = $article->getDatePublished();
     if (!$datePublished) {
         $datePublished = $issue->getDatePublished();
     }
     if ($datePublished) {
         $datePublished = strtotime($datePublished);
     }
     $response = "<article\n" . "\txmlns=\"http://dtd.nlm.nih.gov/publishing/2.3\"\n" . "\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" . "\txmlns:mml=\"http://www.w3.org/1998/Math/MathML\"\n" . "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" . "\txsi:schemaLocation=\"http://dtd.nlm.nih.gov/publishing/2.3\n" . "\thttp://dtd.nlm.nih.gov/publishing/2.3/xsd/journalpublishing.xsd\"\n" . (($s = $section->getLocalizedIdentifyType()) != '' ? "\tarticle-type=\"" . htmlspecialchars(Core::cleanVar($s)) . "\"" : '') . "\txml:lang=\"" . strtoupper(substr($primaryLocale, 0, 2)) . "\">\n" . "\t<front>\n" . "\t\t<journal-meta>\n" . "\t\t\t<journal-id journal-id-type=\"other\">" . htmlspecialchars(Core::cleanVar(($s = Config::getVar('oai', 'nlm_journal_id')) != '' ? $s : $journal->getPath())) . "</journal-id>\n" . "\t\t\t<journal-title>" . htmlspecialchars(Core::cleanVar($journal->getLocalizedName())) . "</journal-title>\n";
     // Include translated journal titles
     foreach ($journal->getName(null) as $locale => $title) {
         if ($locale == $primaryLocale) {
             continue;
         }
         $response .= "\t\t\t<trans-title xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">" . htmlspecialchars(Core::cleanVar($title)) . "</trans-title>\n";
     }
     $response .= (!empty($onlineIssn) ? "\t\t\t<issn pub-type=\"epub\">" . htmlspecialchars(Core::cleanVar($onlineIssn)) . "</issn>" : '') . (!empty($printIssn) ? "\t\t\t<issn pub-type=\"ppub\">" . htmlspecialchars(Core::cleanVar($printIssn)) . "</issn>" : '') . ($publisherInstitution != '' ? "\t\t\t<publisher><publisher-name>" . htmlspecialchars(Core::cleanVar($publisherInstitution)) . "</publisher-name></publisher>\n" : '') . "\t\t</journal-meta>\n" . "\t\t<article-meta>\n" . "\t\t\t<article-id pub-id-type=\"other\">" . htmlspecialchars(Core::cleanVar($article->getBestArticleId())) . "</article-id>\n" . (($s = $article->getPubId('doi')) ? "\t\t\t<article-id pub-id-type=\"doi\">" . htmlspecialchars(Core::cleanVar($s)) . "</article-id>\n" : '') . "\t\t\t<article-categories><subj-group subj-group-type=\"heading\"><subject>" . htmlspecialchars(Core::cleanVar($section->getLocalizedTitle())) . "</subject></subj-group></article-categories>\n" . "\t\t\t<title-group>\n" . "\t\t\t\t<article-title>" . htmlspecialchars(Core::cleanVar(strip_tags($article->getLocalizedTitle()))) . "</article-title>\n";
     // Include translated journal titles
     foreach ($article->getTitle(null) as $locale => $title) {
         if ($locale == $primaryLocale) {
             continue;
         }
         $response .= "\t\t\t\t<trans-title xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">" . htmlspecialchars(Core::cleanVar(strip_tags($title))) . "</trans-title>\n";
     }
     $response .= "\t\t\t</title-group>\n" . "\t\t\t<contrib-group>\n";
     // Include authors
     foreach ($article->getAuthors() as $author) {
         $response .= "\t\t\t\t<contrib " . ($author->getPrimaryContact() ? 'corresp="yes" ' : '') . "contrib-type=\"author\">\n" . "\t\t\t\t\t<name name-style=\"western\">\n" . "\t\t\t\t\t\t<surname>" . htmlspecialchars(Core::cleanVar($author->getLastName())) . "</surname>\n" . "\t\t\t\t\t\t<given-names>" . htmlspecialchars(Core::cleanVar($author->getFirstName()) . (($s = $author->getMiddleName()) != '' ? " {$s}" : '')) . "</given-names>\n" . "\t\t\t\t\t</name>\n" . (($s = $author->getLocalizedAffiliation()) != '' ? "\t\t\t\t\t<aff>" . htmlspecialchars(Core::cleanVar($s)) . "</aff>\n" : '') . "\t\t\t\t\t<email>" . htmlspecialchars(Core::cleanVar($author->getEmail())) . "</email>\n" . (($s = $author->getUrl()) != '' ? "\t\t\t\t\t<uri>" . htmlspecialchars(Core::cleanVar($s)) . "</uri>\n" : '') . "\t\t\t\t</contrib>\n";
     }
     // Include editorships (optimized)
     $response .= $this->getEditorialInfo($journal->getId());
     $response .= "\t\t\t</contrib-group>\n";
     if ($datePublished) {
         $response .= "\t\t\t<pub-date pub-type=\"epub\">\n" . "\t\t\t\t<day>" . strftime('%d', $datePublished) . "</day>\n" . "\t\t\t\t<month>" . strftime('%m', $datePublished) . "</month>\n" . "\t\t\t\t<year>" . strftime('%Y', $datePublished) . "</year>\n" . "\t\t\t</pub-date>\n";
     }
     $response .= ($issue->getShowYear() ? "\t\t\t<pub-date pub-type=\"collection\"><year>" . htmlspecialchars(Core::cleanVar($issue->getYear())) . "</year></pub-date>\n" : '') . ($issue->getShowVolume() ? "\t\t\t<volume>" . htmlspecialchars(Core::cleanVar($issue->getVolume())) . "</volume>\n" : '') . ($issue->getShowNumber() ? "\t\t\t<issue seq=\"" . htmlspecialchars(Core::cleanVar($sectionSeq[$section->getId()] * 100 + $article->getSequence())) . "\">" . htmlspecialchars(Core::cleanVar($issue->getNumber())) . "</issue>\n" : '') . "\t\t\t<issue-id pub-id-type=\"other\">" . htmlspecialchars(Core::cleanVar($issue->getBestIssueId())) . "</issue-id>\n" . ($issue->getShowTitle() ? "\t\t\t<issue-title>" . htmlspecialchars(Core::cleanVar($issue->getLocalizedTitle())) . "</issue-title>\n" : '');
     // Include page info, if available and parseable.
     $matches = null;
     if (PKPString::regexp_match_get('/^[Pp][Pp]?[.]?[ ]?(\\d+)$/', $article->getPages(), $matches)) {
         $matchedPage = htmlspecialchars(Core::cleanVar($matches[1]));
         $response .= "\t\t\t\t<fpage>{$matchedPage}</fpage><lpage>{$matchedPage}</lpage>\n";
         $pageCount = 1;
     } elseif (PKPString::regexp_match_get('/^[Pp][Pp]?[.]?[ ]?(\\d+)[ ]?(-|–)[ ]?([Pp][Pp]?[.]?[ ]?)?(\\d+)$/', $article->getPages(), $matches)) {
         $matchedPageFrom = htmlspecialchars(Core::cleanVar($matches[1]));
         $matchedPageTo = htmlspecialchars(Core::cleanVar($matches[4]));
         $response .= "\t\t\t\t<fpage>{$matchedPageFrom}</fpage>\n" . "\t\t\t\t<lpage>{$matchedPageTo}</lpage>\n";
         $pageCount = $matchedPageTo - $matchedPageFrom + 1;
     }
     $response .= "\t\t\t<permissions>\n" . "\t\t\t\t<copyright-statement>" . htmlspecialchars(__('submission.copyrightStatement', array('copyrightYear' => $article->getCopyrightYear(), 'copyrightHolder' => $article->getLocalizedCopyrightHolder()))) . "</copyright-statement>\n" . ($datePublished ? "\t\t\t\t<copyright-year>" . $article->getCopyrightYear() . "</copyright-year>\n" : '') . "\t\t\t\t<license xlink:href=\"" . $article->getLicenseURL() . "\">\n" . (($s = Application::getCCLicenseBadge($article->getLicenseURL())) ? "\t\t\t\t\t<license-p>" . strip_tags($s) . "</license-p>\n" : '') . "\t\t\t\t</license>\n" . "\t\t\t</permissions>\n" . "\t\t\t<self-uri xlink:href=\"" . htmlspecialchars(Core::cleanVar(Request::url($journal->getPath(), 'article', 'view', $article->getBestArticleId()))) . "\" />\n";
     // Include galley links
     foreach ($article->getGalleys() as $galley) {
         $response .= "\t\t\t<self-uri content-type=\"" . htmlspecialchars(Core::cleanVar($galley->getFileType())) . "\" xlink:href=\"" . htmlspecialchars(Core::cleanVar(Request::url($journal->getPath(), 'article', 'view', array($article->getBestArticleId(), $galley->getId())))) . "\" />\n";
     }
     // Include abstract(s)
     $abstract = htmlspecialchars(Core::cleanVar(strip_tags($article->getLocalizedAbstract())));
     if (!empty($abstract)) {
         $abstract = "<p>{$abstract}</p>";
         // $abstract = '<p>' . PKPString::regexp_replace('/\n+/', '</p><p>', $abstract) . '</p>';
         $response .= "\t\t\t<abstract xml:lang=\"" . strtoupper(substr($primaryLocale, 0, 2)) . "\">{$abstract}</abstract>\n";
     }
     if (is_array($article->getAbstract(null))) {
         foreach ($article->getAbstract(null) as $locale => $abstract) {
             if ($locale == $primaryLocale || empty($abstract)) {
                 continue;
             }
             $abstract = htmlspecialchars(Core::cleanVar(strip_tags($abstract)));
             if (empty($abstract)) {
                 continue;
             }
             $abstract = "<p>{$abstract}</p>";
             //$abstract = '<p>' . PKPString::regexp_replace('/\n+/', '</p><p>', $abstract) . '</p>';
             $response .= "\t\t\t<abstract-trans xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">{$abstract}</abstract-trans>\n";
         }
     }
     $subjects = array();
     if (is_array($article->getSubject(null))) {
         foreach ($article->getSubject(null) as $locale => $subject) {
             $s = array_map('trim', explode(';', Core::cleanVar($subject)));
             if (!empty($s)) {
                 $subjects[$locale] = $s;
             }
         }
     }
     if (!empty($subjects)) {
         foreach ($subjects as $locale => $s) {
             $response .= "\t\t\t<kwd-group xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">\n";
             foreach ($s as $subject) {
                 $response .= "\t\t\t\t<kwd>" . htmlspecialchars($subject) . "</kwd>\n";
             }
             $response .= "\t\t\t</kwd-group>\n";
         }
     }
     $response .= (isset($pageCount) ? "\t\t\t<counts><page-count count=\"" . (int) $pageCount . "\" /></counts>\n" : '') . "\t\t</article-meta>\n" . "\t</front>\n";
     // Include body text (for search indexing only)
     import('classes.search.ArticleSearchIndex');
     $text = '';
     $galleys = $article->getGalleys();
     // Give precedence to HTML galleys, as they're quickest to parse
     usort($galleys, create_function('$a, $b', 'return $a->getFileType()==\'text/html\')?-1:1;'));
     // Determine any access limitations. If there are, do not
     // provide the full-text.
     import('classes.issue.IssueAction');
     $issueAction = new IssueAction();
     $subscriptionRequired = $issueAction->subscriptionRequired($issue);
     $isSubscribedDomain = $issueAction->subscribedDomain($journal, $issue->getId(), $article->getId());
     if (!$subscriptionRequired || $isSubscribedDomain) {
         foreach ($galleys as $galley) {
             $parser =& SearchFileParser::fromFile($galley);
             if ($parser && $parser->open()) {
                 while (($s = $parser->read()) !== false) {
                     $text .= $s;
                 }
                 $parser->close();
             }
             if ($galley->getFileType() == 'text/html') {
                 $text = strip_tags($text);
             }
             unset($galley);
             // Use the first parseable galley.
             if (!empty($text)) {
                 break;
             }
         }
     }
     if (!empty($text)) {
         $response .= "\t<body><p>" . htmlspecialchars(Core::cleanVar(Core::cleanVar($text))) . "</p></body>\n";
     }
     // Add NLM citation info
     $filterDao = DAORegistry::getDAO('FilterDAO');
     /* @var $filterDao FilterDAO */
     $nlmFilters = $filterDao->getObjectsByGroup('submission=>nlm23-article-xml');
     assert(count($nlmFilters) == 1);
     $nlmFilter = array_pop($nlmFilters);
     $nlmXmlDom = new DOMDocument();
     $nlmXmlDom->loadXML($nlmFilter->execute($article));
     $documentElement =& $nlmXmlDom->documentElement;
     // Work-around for hasChildNodes being stupid about whitespace.
     $hasChildren = false;
     if (isset($documentElement->childNodes)) {
         foreach ($documentElement->childNodes as $c) {
             if ($c->nodeType == XML_ELEMENT_NODE) {
                 $hasChildren = true;
             }
         }
     }
     // If there were any citations, include them.
     if ($hasChildren) {
         $innerXml = $nlmXmlDom->saveXML($documentElement);
         $response .= "<back>{$innerXml}</back>\n";
     }
     $response .= "</article>";
     return $response;
 }
Exemplo n.º 5
0
 /**
  * Determines whether a user can view this article galley or not.
  * @param $request Request
  * @param $articleId string
  * @param $galleyId int or string
  */
 function userCanViewGalley($request, $articleId, $galleyId = null)
 {
     import('classes.issue.IssueAction');
     $issueAction = new IssueAction();
     $journal = $request->getJournal();
     $publishedArticle = $this->article;
     $issue = $this->issue;
     $journalId = $journal->getId();
     $user = $request->getUser();
     $userId = $user ? $user->getId() : 0;
     // If this is an editorial user who can view unpublished/unscheduled
     // articles, bypass further validation. Likewise for its author.
     if ($publishedArticle && $issueAction->allowedPrePublicationAccess($journal, $publishedArticle)) {
         return true;
     }
     // Make sure the reader has rights to view the article/issue.
     if ($issue && $issue->getPublished() && $publishedArticle->getStatus() == STATUS_PUBLISHED) {
         $subscriptionRequired = $issueAction->subscriptionRequired($issue);
         $isSubscribedDomain = $issueAction->subscribedDomain($journal, $issue->getId(), $publishedArticle->getId());
         // Check if login is required for viewing.
         if (!$isSubscribedDomain && !Validation::isLoggedIn() && $journal->getSetting('restrictArticleAccess') && isset($galleyId) && $galleyId) {
             Validation::redirectLogin();
         }
         // bypass all validation if subscription based on domain or ip is valid
         // or if the user is just requesting the abstract
         if (!$isSubscribedDomain && $subscriptionRequired && (isset($galleyId) && $galleyId)) {
             // Subscription Access
             $subscribedUser = $issueAction->subscribedUser($journal, $issue->getId(), $publishedArticle->getId());
             import('classes.payment.ojs.OJSPaymentManager');
             $paymentManager = new OJSPaymentManager($request);
             $purchasedIssue = false;
             if (!$subscribedUser && $paymentManager->purchaseIssueEnabled()) {
                 $completedPaymentDao = DAORegistry::getDAO('OJSCompletedPaymentDAO');
                 $purchasedIssue = $completedPaymentDao->hasPaidPurchaseIssue($userId, $issue->getId());
             }
             if (!(!$subscriptionRequired || $publishedArticle->getAccessStatus() == ARTICLE_ACCESS_OPEN || $subscribedUser || $purchasedIssue)) {
                 if ($paymentManager->purchaseArticleEnabled() || $paymentManager->membershipEnabled()) {
                     /* if only pdf files are being restricted, then approve all non-pdf galleys
                      * and continue checking if it is a pdf galley */
                     if ($paymentManager->onlyPdfEnabled()) {
                         if ($this->galley && !$this->galley->isPdfGalley()) {
                             $this->issue = $issue;
                             $this->article = $publishedArticle;
                             return true;
                         }
                     }
                     if (!Validation::isLoggedIn()) {
                         Validation::redirectLogin("payment.loginRequired.forArticle");
                     }
                     /* if the article has been paid for then forget about everything else
                      * and just let them access the article */
                     $completedPaymentDao = DAORegistry::getDAO('OJSCompletedPaymentDAO');
                     $dateEndMembership = $user->getSetting('dateEndMembership', 0);
                     if ($completedPaymentDao->hasPaidPurchaseArticle($userId, $publishedArticle->getId()) || !is_null($dateEndMembership) && $dateEndMembership > time()) {
                         $this->issue = $issue;
                         $this->article = $publishedArticle;
                         return true;
                     } else {
                         $queuedPayment = $paymentManager->createQueuedPayment($journalId, PAYMENT_TYPE_PURCHASE_ARTICLE, $user->getId(), $publishedArticle->getId(), $journal->getSetting('purchaseArticleFee'));
                         $queuedPaymentId = $paymentManager->queuePayment($queuedPayment);
                         $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment);
                         exit;
                     }
                 }
                 if (!isset($galleyId) || $galleyId) {
                     if (!Validation::isLoggedIn()) {
                         Validation::redirectLogin('reader.subscriptionRequiredLoginText');
                     }
                     $request->redirect(null, 'about', 'subscriptions');
                 }
             }
         }
     } else {
         $request->redirect(null, 'search');
     }
     return true;
 }
Exemplo n.º 6
0
 /**
  * Check whether access to the given article
  * is authorized to the requesting party (i.e. the
  * Solr server).
  *
  * @param $article Article
  * @return boolean True if authorized, otherwise false.
  */
 function _isArticleAccessAuthorized(&$article)
 {
     // Did we get a published article?
     if (!is_a($article, 'PublishedArticle')) {
         return false;
     }
     // Get the article's journal.
     $journal = $this->_getJournal($article->getJournalId());
     if (!is_a($journal, 'Journal')) {
         return false;
     }
     // Get the article's issue.
     $issue = $this->_getIssue($article->getIssueId(), $journal->getId());
     if (!is_a($issue, 'Issue')) {
         return false;
     }
     // Only index published articles.
     if (!$issue->getPublished() || $article->getStatus() != STATUS_PUBLISHED) {
         return false;
     }
     // Make sure the requesting party is authorized to acces the article/issue.
     import('classes.issue.IssueAction');
     $issueAction = new IssueAction();
     $subscriptionRequired = $issueAction->subscriptionRequired($issue, $journal);
     if ($subscriptionRequired) {
         $isSubscribedDomain = $issueAction->subscribedDomain($journal, $issue->getId(), $article->getId());
         if (!$isSubscribedDomain) {
             return false;
         }
     }
     // All checks passed successfully - allow access.
     return true;
 }
Exemplo n.º 7
0
 /**
  * Given an issue, set up the template with all the required variables for
  * frontend/objects/issue_toc.tpl to function properly (i.e. current issue
  * and view issue).
  * @param $issue object The issue to display
  * @param $showToc boolean iff false and a custom cover page exists,
  * 	the cover page will be displayed. Otherwise table of contents
  * 	will be displayed.
  */
 function _setupIssueTemplate($request, $issue, $showToc = false)
 {
     $journal = $request->getJournal();
     $templateMgr = TemplateManager::getManager($request);
     // Determine pre-publication access
     // FIXME: Do that. (Bug #8278)
     if (!$issue) {
         $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
     }
     $templateMgr->assign(array('issueIdentification' => $issue->getIssueIdentification(), 'issueTitle' => $issue->getLocalizedTitle(), 'issueSeries' => $issue->getIssueIdentification(array('showTitle' => false))));
     $locale = AppLocale::getLocale();
     import('classes.file.PublicFileManager');
     $publicFileManager = new PublicFileManager();
     $templateMgr->assign(array('coverPagePath' => $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journal->getId()) . '/', 'locale' => $locale));
     if (!$showToc && $issue->getFileName($locale) && $issue->getShowCoverPage($locale) && !$issue->getHideCoverPageCover($locale)) {
         $templateMgr->assign(array('fileName' => $issue->getFileName($locale), 'width' => $issue->getWidth($locale), 'height' => $issue->getHeight($locale), 'coverPageAltText' => $issue->getCoverPageAltText($locale), 'originalFileName' => $issue->getOriginalFileName($locale), 'originalFileName' => $issue->getOriginalFileName($locale)));
     } else {
         $issueGalleyDao = DAORegistry::getDAO('IssueGalleyDAO');
         $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
         $templateMgr->assign(array('issueGalleys' => $issueGalleyDao->getByIssueId($issue->getId()), 'publishedArticles' => $publishedArticleDao->getPublishedArticlesInSections($issue->getId(), true)));
         $showToc = true;
     }
     $templateMgr->assign(array('showToc' => $showToc, 'issue' => $issue));
     // Subscription Access
     import('classes.issue.IssueAction');
     $issueAction = new IssueAction();
     $subscriptionRequired = $issueAction->subscriptionRequired($issue);
     $subscribedUser = $issueAction->subscribedUser($journal);
     $subscribedDomain = $issueAction->subscribedDomain($journal);
     if ($showToc && $subscriptionRequired && !$subscribedUser && !$subscribedDomain) {
         $templateMgr->assign('subscriptionExpiryPartial', true);
         // Partial subscription expiry for issue
         $partial = $issueAction->subscribedUser($journal, $issue->getId());
         if (!$partial) {
             $issueAction->subscribedDomain($journal, $issue->getId());
         }
         $templateMgr->assign('issueExpiryPartial', $partial);
         // Partial subscription expiry for articles
         $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
         $publishedArticlesTemp =& $publishedArticleDao->getPublishedArticles($issue->getId());
         $articleExpiryPartial = array();
         foreach ($publishedArticlesTemp as $publishedArticle) {
             $partial = $issueAction->subscribedUser($journal, $issue->getId(), $publishedArticle->getId());
             if (!$partial) {
                 $issueAction->subscribedDomain($journal, $issue->getId(), $publishedArticle->getId());
             }
             $articleExpiryPartial[$publishedArticle->getId()] = $partial;
         }
         $templateMgr->assign('articleExpiryPartial', $articleExpiryPartial);
     }
     $templateMgr->assign(array('showGalleyLinks' => !$subscriptionRequired || $journal->getSetting('showGalleyLinks'), 'hasAccess' => !$subscriptionRequired || $issue->getAccessStatus() == ISSUE_ACCESS_OPEN || $subscribedUser || $subscribedDomain));
     import('classes.payment.ojs.OJSPaymentManager');
     $paymentManager = new OJSPaymentManager($request);
     if ($paymentManager->onlyPdfEnabled()) {
         $templateMgr->assign('restrictOnlyPdf', true);
     }
     if ($paymentManager->purchaseArticleEnabled()) {
         $templateMgr->assign('purchaseArticleEnabled', true);
     }
     if ($styleFileName = $issue->getStyleFileName()) {
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $templateMgr->addStyleSheet($request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $styleFileName);
     }
 }
Exemplo n.º 8
0
 /**
  * Validation
  */
 function validate($articleId, $galleyId = null)
 {
     parent::validate(true);
     import('issue.IssueAction');
     $journal =& Request::getJournal();
     $journalId = $journal->getJournalId();
     $article = $publishedArticle = $issue = null;
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     if ($journal->getSetting('enablePublicArticleId')) {
         $publishedArticle =& $publishedArticleDao->getPublishedArticleByBestArticleId($journalId, $articleId);
     } else {
         $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId((int) $articleId, $journalId);
     }
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     if (isset($publishedArticle)) {
         $issue =& $issueDao->getIssueByArticleId($publishedArticle->getArticleId(), $journalId);
     } else {
         $articleDao =& DAORegistry::getDAO('ArticleDAO');
         $article =& $articleDao->getArticle((int) $articleId, $journalId);
     }
     // If this is an editorial user who can view unpublished/unscheduled
     // articles, bypass further validation.
     if (($article || $publishedArticle) && IssueAction::allowedPrePublicationAccess($journal)) {
         return array($journal, $issue, $publishedArticle ? $publishedArticle : $article);
     }
     // Make sure the reader has rights to view the article/issue.
     if ($issue && $issue->getPublished()) {
         $subscriptionRequired = IssueAction::subscriptionRequired($issue);
         $isSubscribedDomain = IssueAction::subscribedDomain($journal, $issue->getIssueId(), $articleId);
         // Check if login is required for viewing.
         if (!$isSubscribedDomain && !Validation::isLoggedIn() && $journal->getSetting('restrictArticleAccess') && isset($galleyId) && $galleyId != 0) {
             Validation::redirectLogin();
         }
         // bypass all validation if subscription based on domain or ip is valid
         // or if the user is just requesting the abstract
         if (!$isSubscribedDomain && $subscriptionRequired && (isset($galleyId) && $galleyId != 0)) {
             // Subscription Access
             $subscribedUser = IssueAction::subscribedUser($journal, $issue->getIssueId(), $articleId);
             if (!(!$subscriptionRequired || $publishedArticle->getAccessStatus() || $subscribedUser)) {
                 // if payment information is enabled,
                 import('payment.ojs.OJSPaymentManager');
                 $paymentManager =& OJSPaymentManager::getManager();
                 if ($paymentManager->purchaseArticleEnabled() || $paymentManager->membershipEnabled()) {
                     /* if only pdf files are being restricted, then approve all non-pdf galleys
                      * and continue checking if it is a pdf galley */
                     if ($paymentManager->onlyPdfEnabled()) {
                         $galleyDAO =& DAORegistry::getDAO('ArticleGalleyDAO');
                         $galley =& $galleyDAO->getGalley($galleyId, $articleId);
                         if ($galley && !$galley->isPdfGalley()) {
                             return array($journal, $issue, $publishedArticle);
                         }
                     }
                     if (!Validation::isLoggedIn()) {
                         Validation::redirectLogin("payment.loginRequired.forArticle");
                     }
                     $user =& Request::getUser();
                     $userId = $user->getUserId();
                     /* if the article has been paid for then forget about everything else
                      * and just let them access the article */
                     $completedPaymentDAO =& DAORegistry::getDAO('OJSCompletedPaymentDAO');
                     if ($completedPaymentDAO->hasPaidPerViewArticle($userId, $articleId) || !is_null($user->getDateEndMembership()) && strtotime($user->getDateEndMembership()) > time()) {
                         return array($journal, $issue, $publishedArticle);
                     } else {
                         $queuedPayment =& $paymentManager->createQueuedPayment($journalId, PAYMENT_TYPE_PURCHASE_ARTICLE, $user->getUserId(), $articleId, $journal->getSetting('purchaseArticleFee'));
                         $queuedPaymentId = $paymentManager->queuePayment($queuedPayment);
                         $templateMgr =& TemplateManager::getManager();
                         $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment);
                         exit;
                     }
                 }
                 if (!isset($galleyId) || $galleyId) {
                     if (!Validation::isLoggedIn()) {
                         Validation::redirectLogin("reader.subscriptionRequiredLoginText");
                     }
                     Request::redirect(null, 'about', 'subscriptions');
                 }
             }
         }
     } else {
         Request::redirect(null, 'index');
     }
     return array($journal, $issue, $publishedArticle);
 }
Exemplo n.º 9
0
 /**
  * Validation
  * @param $request PKPRequest
  * @param $articleId int
  */
 function validate(&$request, $articleId)
 {
     parent::validate();
     $journal =& $request->getJournal();
     $journalId = $journal->getId();
     $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     $article =& $publishedArticleDao->getPublishedArticleByArticleId($articleId);
     // Bring in comment constants
     $commentDao =& DAORegistry::getDAO('CommentDAO');
     $enableComments = $journal->getSetting('enableComments');
     if (!Validation::isLoggedIn() && $journalSettingsDao->getSetting($journalId, 'restrictArticleAccess') || $article && !$article->getEnableComments() || $enableComments != COMMENTS_ANONYMOUS && $enableComments != COMMENTS_AUTHENTICATED && $enableComments != COMMENTS_UNAUTHENTICATED) {
         Validation::redirectLogin();
     }
     // Subscription Access
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $issue =& $issueDao->getIssueByArticleId($articleId);
     if (isset($issue) && isset($article)) {
         import('classes.issue.IssueAction');
         $subscriptionRequired = IssueAction::subscriptionRequired($issue);
         $subscribedUser = IssueAction::subscribedUser($journal, $issue->getId(), $articleId);
         if (!(!$subscriptionRequired || $article->getAccessStatus() == ARTICLE_ACCESS_OPEN || $subscribedUser)) {
             $request->redirect(null, 'index');
         }
     } else {
         $request->redirect(null, 'index');
     }
     $this->issue =& $issue;
     $this->article =& $article;
     return true;
 }
Exemplo n.º 10
0
 /**
  * Given an issue, set up the template with all the required variables for
  * frontend/objects/issue_toc.tpl to function properly (i.e. current issue
  * and view issue).
  * @param $issue object The issue to display
  * @param $showToc boolean iff false and a custom cover page exists,
  * 	the cover page will be displayed. Otherwise table of contents
  * 	will be displayed.
  */
 function _setupIssueTemplate($request, $issue, $showToc = false)
 {
     $journal = $request->getJournal();
     $templateMgr = TemplateManager::getManager($request);
     // Determine pre-publication access
     // FIXME: Do that. (Bug #8278)
     if (!$issue) {
         $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
     }
     $templateMgr->assign(array('issueIdentification' => $issue->getIssueIdentification(), 'issueTitle' => $issue->getLocalizedTitle(), 'issueSeries' => $issue->getIssueIdentification(array('showTitle' => false))));
     $locale = AppLocale::getLocale();
     $templateMgr->assign(array('locale' => $locale));
     $issueGalleyDao = DAORegistry::getDAO('IssueGalleyDAO');
     $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
     $templateMgr->assign(array('issue' => $issue, 'issueGalleys' => $issueGalleyDao->getByIssueId($issue->getId()), 'publishedArticles' => $publishedArticleDao->getPublishedArticlesInSections($issue->getId(), true)));
     // Subscription Access
     import('classes.issue.IssueAction');
     $issueAction = new IssueAction();
     $subscriptionRequired = $issueAction->subscriptionRequired($issue);
     $subscribedUser = $issueAction->subscribedUser($journal);
     $subscribedDomain = $issueAction->subscribedDomain($journal);
     if ($subscriptionRequired && !$subscribedUser && !$subscribedDomain) {
         $templateMgr->assign('subscriptionExpiryPartial', true);
         // Partial subscription expiry for issue
         $partial = $issueAction->subscribedUser($journal, $issue->getId());
         if (!$partial) {
             $issueAction->subscribedDomain($journal, $issue->getId());
         }
         $templateMgr->assign('issueExpiryPartial', $partial);
         // Partial subscription expiry for articles
         $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
         $publishedArticlesTemp =& $publishedArticleDao->getPublishedArticles($issue->getId());
         $articleExpiryPartial = array();
         foreach ($publishedArticlesTemp as $publishedArticle) {
             $partial = $issueAction->subscribedUser($journal, $issue->getId(), $publishedArticle->getId());
             if (!$partial) {
                 $issueAction->subscribedDomain($journal, $issue->getId(), $publishedArticle->getId());
             }
             $articleExpiryPartial[$publishedArticle->getId()] = $partial;
         }
         $templateMgr->assign('articleExpiryPartial', $articleExpiryPartial);
     }
     $templateMgr->assign(array('hasAccess' => !$subscriptionRequired || $issue->getAccessStatus() == ISSUE_ACCESS_OPEN || $subscribedUser || $subscribedDomain));
     import('classes.payment.ojs.OJSPaymentManager');
     $paymentManager = new OJSPaymentManager($request);
     if ($paymentManager->onlyPdfEnabled()) {
         $templateMgr->assign('restrictOnlyPdf', true);
     }
     if ($paymentManager->purchaseArticleEnabled()) {
         $templateMgr->assign('purchaseArticleEnabled', true);
     }
 }
Exemplo n.º 11
0
 /**
  * Given an issue, set up the template with all the required variables for
  * issues/view.tpl to function properly.
  * @param $issue object The issue to display
  * @param $showToc boolean iff false and a custom cover page exists,
  * 	the cover page will be displayed. Otherwise table of contents
  * 	will be displayed.
  */
 function setupIssueTemplate(&$issue, $showToc = false)
 {
     $journal =& Request::getJournal();
     $journalId = $journal->getJournalId();
     $templateMgr =& TemplateManager::getManager();
     if (isset($issue) && ($issue->getPublished() || Validation::isEditor($journalId) || Validation::isLayoutEditor($journalId) || Validation::isProofreader($journalId)) && $issue->getJournalId() == $journalId) {
         $issueHeadingTitle = $issue->getIssueIdentification(false, true);
         $issueCrumbTitle = $issue->getIssueIdentification(false, true);
         $locale = Locale::getLocale();
         import('file.PublicFileManager');
         $publicFileManager =& new PublicFileManager();
         $coverPagePath = Request::getBaseUrl() . '/';
         $coverPagePath .= $publicFileManager->getJournalFilesPath($journalId) . '/';
         $templateMgr->assign('coverPagePath', $coverPagePath);
         $templateMgr->assign('locale', $locale);
         if (!$showToc && $issue->getFileName($locale) && $issue->getShowCoverPage($locale) && !$issue->getHideCoverPageCover($locale)) {
             $templateMgr->assign('fileName', $issue->getFileName($locale));
             $templateMgr->assign('width', $issue->getWidth($locale));
             $templateMgr->assign('height', $issue->getHeight($locale));
             $templateMgr->assign('coverPageAltText', $issue->getCoverPageAltText($locale));
             $templateMgr->assign('originalFileName', $issue->getOriginalFileName($locale));
             $showToc = false;
         } else {
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $publishedArticles =& $publishedArticleDao->getPublishedArticlesInSections($issue->getIssueId(), true);
             $publicFileManager =& new PublicFileManager();
             $templateMgr->assign('publishedArticles', $publishedArticles);
             $showToc = true;
         }
         $templateMgr->assign('showToc', $showToc);
         $templateMgr->assign('issueId', $issue->getBestIssueId());
         $templateMgr->assign('issue', $issue);
         // Subscription Access
         import('issue.IssueAction');
         $subscriptionRequired = IssueAction::subscriptionRequired($issue);
         $subscribedUser = IssueAction::subscribedUser($journal);
         $subscribedDomain = IssueAction::subscribedDomain($journal);
         $subscriptionExpiryPartial = $journal->getSetting('subscriptionExpiryPartial');
         if ($showToc && $subscriptionRequired && !$subscribedUser && !$subscribedDomain && $subscriptionExpiryPartial) {
             $templateMgr->assign('subscriptionExpiryPartial', true);
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $publishedArticlesTemp =& $publishedArticleDao->getPublishedArticles($issue->getIssueId(), null, true);
             $articleExpiryPartial = array();
             foreach ($publishedArticlesTemp as $publishedArticle) {
                 $partial = IssueAction::subscribedUser($journal, $issue->getIssueId(), $publishedArticle->getArticleId());
                 if (!$partial) {
                     IssueAction::subscribedDomain($journal, $issue->getIssueId(), $publishedArticle->getArticleId());
                 }
                 $articleExpiryPartial[$publishedArticle->getArticleId()] = $partial;
             }
             $templateMgr->assign_by_ref('articleExpiryPartial', $articleExpiryPartial);
         }
         $templateMgr->assign('subscriptionRequired', $subscriptionRequired);
         $templateMgr->assign('subscribedUser', $subscribedUser);
         $templateMgr->assign('subscribedDomain', $subscribedDomain);
         $templateMgr->assign('showGalleyLinks', $journal->getSetting('showGalleyLinks'));
         import('payment.ojs.OJSPaymentManager');
         $paymentManager =& OJSPaymentManager::getManager();
         if ($paymentManager->onlyPdfEnabled()) {
             $templateMgr->assign('restrictOnlyPdf', true);
         }
     } else {
         $issueCrumbTitle = Locale::translate('archive.issueUnavailable');
         $issueHeadingTitle = Locale::translate('archive.issueUnavailable');
     }
     if ($styleFileName = $issue->getStyleFileName()) {
         import('file.PublicFileManager');
         $publicFileManager =& new PublicFileManager();
         $templateMgr->addStyleSheet(Request::getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journalId) . '/' . $styleFileName);
     }
     $templateMgr->assign('pageCrumbTitleTranslated', $issueCrumbTitle);
     $templateMgr->assign('issueHeadingTitle', $issueHeadingTitle);
 }
Exemplo n.º 12
0
 /**
  * See SubmissionSearch::formatResults()
  *
  * @return array An array with the articles, published articles,
  *  issue, journal, section and the issue availability.
  */
 static function formatResults(&$results)
 {
     $articleDao = DAORegistry::getDAO('ArticleDAO');
     $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
     $issueDao = DAORegistry::getDAO('IssueDAO');
     $journalDao = DAORegistry::getDAO('JournalDAO');
     $sectionDao = DAORegistry::getDAO('SectionDAO');
     $publishedArticleCache = array();
     $articleCache = array();
     $issueCache = array();
     $issueAvailabilityCache = array();
     $journalCache = array();
     $sectionCache = array();
     $returner = array();
     foreach ($results as $articleId) {
         // Get the article, storing in cache if necessary.
         if (!isset($articleCache[$articleId])) {
             $publishedArticleCache[$articleId] = $publishedArticleDao->getPublishedArticleByArticleId($articleId);
             $articleCache[$articleId] = $articleDao->getById($articleId);
         }
         $article = $articleCache[$articleId];
         $publishedArticle = $publishedArticleCache[$articleId];
         if ($publishedArticle && $article) {
             $sectionId = $article->getSectionId();
             if (!isset($sectionCache[$sectionId])) {
                 $sectionCache[$sectionId] = $sectionDao->getById($sectionId);
             }
             // Get the journal, storing in cache if necessary.
             $journalId = $article->getJournalId();
             if (!isset($journalCache[$journalId])) {
                 $journalCache[$journalId] = $journalDao->getById($journalId);
             }
             // Get the issue, storing in cache if necessary.
             $issueId = $publishedArticle->getIssueId();
             if (!isset($issueCache[$issueId])) {
                 $issue = $issueDao->getById($issueId);
                 $issueCache[$issueId] = $issue;
                 import('classes.issue.IssueAction');
                 $issueAction = new IssueAction();
                 $issueAvailabilityCache[$issueId] = !$issueAction->subscriptionRequired($issue) || $issueAction->subscribedUser($journalCache[$journalId], $issueId, $articleId) || $issueAction->subscribedDomain($journalCache[$journalId], $issueId, $articleId);
             }
             // Only display articles from published issues.
             if (!$issueCache[$issueId]->getPublished()) {
                 continue;
             }
             // Store the retrieved objects in the result array.
             $returner[] = array('article' => $article, 'publishedArticle' => $publishedArticleCache[$articleId], 'issue' => $issueCache[$issueId], 'journal' => $journalCache[$journalId], 'issueAvailable' => $issueAvailabilityCache[$issueId], 'section' => $sectionCache[$sectionId]);
         }
     }
     return $returner;
 }
Exemplo n.º 13
0
 /**
  * Given an issue, set up the template with all the required variables for
  * issues/view.tpl to function properly.
  * @param $issue object The issue to display
  * @param $showToc boolean iff false and a custom cover page exists,
  * 	the cover page will be displayed. Otherwise table of contents
  * 	will be displayed.
  */
 function setupIssueTemplate(&$issue, $showToc = false)
 {
     $journal =& Request::getJournal();
     $journalId = $journal->getId();
     $templateMgr =& TemplateManager::getManager();
     if (isset($issue) && ($issue->getPublished() || Validation::isEditor($journalId) || Validation::isLayoutEditor($journalId) || Validation::isProofreader($journalId)) && $issue->getJournalId() == $journalId) {
         $issueHeadingTitle = $issue->getIssueIdentification(false, true);
         $issueCrumbTitle = $issue->getIssueIdentification(false, true);
         $locale = Locale::getLocale();
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $coverPagePath = Request::getBaseUrl() . '/';
         $coverPagePath .= $publicFileManager->getJournalFilesPath($journalId) . '/';
         $templateMgr->assign('coverPagePath', $coverPagePath);
         $templateMgr->assign('locale', $locale);
         if ($issue->getFileName($locale) && $issue->getShowCoverPage($locale) && !$issue->getHideCoverPageCover($locale)) {
             //%LP% show thumbnail version rather than full-size front cover
             $filename = $issue->getThumbFileName($issue->getFileName($locale));
             $templateMgr->assign('fileName', $filename);
             $templateMgr->assign('coverPageAltText', $issue->getCoverPageAltText($locale));
             $templateMgr->assign('originalFileName', $issue->getOriginalFileName($locale));
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $publishedArticles =& $publishedArticleDao->getPublishedArticlesInSections($issue->getId(), true);
             $publicFileManager = new PublicFileManager();
             $templateMgr->assign('publishedArticles', $publishedArticles);
         }
         $templateMgr->assign('showToc', $showToc);
         $templateMgr->assign('issueId', $issue->getBestIssueId());
         $templateMgr->assign('issue', $issue);
         // Subscription Access
         import('classes.issue.IssueAction');
         $subscriptionRequired = IssueAction::subscriptionRequired($issue);
         $subscribedUser = IssueAction::subscribedUser($journal);
         $subscribedDomain = IssueAction::subscribedDomain($journal);
         $subscriptionExpiryPartial = $journal->getSetting('subscriptionExpiryPartial');
         if ($showToc && $subscriptionRequired && !$subscribedUser && !$subscribedDomain && $subscriptionExpiryPartial) {
             $templateMgr->assign('subscriptionExpiryPartial', true);
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $publishedArticlesTemp =& $publishedArticleDao->getPublishedArticles($issue->getId());
             $articleExpiryPartial = array();
             foreach ($publishedArticlesTemp as $publishedArticle) {
                 $partial = IssueAction::subscribedUser($journal, $issue->getId(), $publishedArticle->getId());
                 if (!$partial) {
                     IssueAction::subscribedDomain($journal, $issue->getId(), $publishedArticle->getId());
                 }
                 $articleExpiryPartial[$publishedArticle->getId()] = $partial;
             }
             $templateMgr->assign_by_ref('articleExpiryPartial', $articleExpiryPartial);
         }
         $templateMgr->assign('subscriptionRequired', $subscriptionRequired);
         $templateMgr->assign('subscribedUser', $subscribedUser);
         $templateMgr->assign('subscribedDomain', $subscribedDomain);
         $templateMgr->assign('showGalleyLinks', $journal->getSetting('showGalleyLinks'));
         import('classes.payment.ojs.OJSPaymentManager');
         $paymentManager =& OJSPaymentManager::getManager();
         if ($paymentManager->onlyPdfEnabled()) {
             $templateMgr->assign('restrictOnlyPdf', true);
         }
         if ($paymentManager->purchaseArticleEnabled()) {
             $templateMgr->assign('purchaseArticleEnabled', true);
         }
     } else {
         $issueCrumbTitle = Locale::translate('archive.issueUnavailable');
         $issueHeadingTitle = Locale::translate('archive.issueUnavailable');
     }
     if ($styleFileName = $issue->getStyleFileName()) {
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $templateMgr->addStyleSheet(Request::getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journalId) . '/' . $styleFileName);
     }
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
     //%CBP% get repository object information for download links
     $CBPPlatformDao =& DAORegistry::getDAO('CBPPlatformDAO');
     $issueObject = $CBPPlatformDao->getFedoraIssueObjectInformation($issue->getIssueId());
     $objectPid = $issueObject['fedora_namespace'] . ":" . $issueObject['fedora_pid'];
     $objectDsid = $issueObject['fedora_dsid'];
     $templateMgr->assign_by_ref('repositoryObjectPid', $objectPid);
     $templateMgr->assign_by_ref('repositoryObjectDsid', $objectDsid);
     $locale = Config::getVar('i18n', 'locale');
     //%LP% show associated artefacts (supplementary files) related to the submission
     foreach ($publishedArticles as $section) {
         foreach ($section['articles'] as $article) {
             $supplementaryFilesTemp[] = $article->getSuppFiles();
         }
     }
     foreach ($supplementaryFilesTemp as $supplementaryFile) {
         if ($supplementaryFile[0]) {
             $suppFile = $supplementaryFile[0];
             $article = $articleDao->getArticle($suppFile->getArticleId());
             $title = $suppFile->getTitle();
             if (stristr($title['en_US'], "Author Biography") == false) {
                 // don't list author biographies
                 $supplementaryFiles[] = array('title' => $title['en_US'], 'articleTitle' => $article->getArticleTitle(), 'articleId' => $article->getArticleId(), 'fileId' => $suppFile->getFileId());
             }
         }
     }
     $templateMgr->assign_by_ref('supplementaryFiles', $supplementaryFiles);
     $atomistic = $templateMgr->_tpl_vars;
     $atomistic = $atomistic['atomistic'];
     $templateMgr->assign_by_ref('atomistic', $atomistic);
     //%CBP% show issue/book ISBN
     $isbn = $CBPPlatformDao->getIssueISBN($issue->getIssueId());
     $templateMgr->assign_by_ref('isbn', $isbn);
     $templateMgr->assign('pageCrumbTitleTranslated', $issueCrumbTitle);
     $templateMgr->assign('issueHeadingTitle', $issueHeadingTitle);
 }