/** * Display the form. */ function display() { $journal =& Request::getJournal(); $user =& Request::getUser(); $templateMgr =& TemplateManager::getManager(); // Get sections for this journal $sectionDao =& DAORegistry::getDAO('SectionDAO'); // If this user is a section editor or an editor, they are allowed // to submit to sections flagged as "editor-only" for submissions. // Otherwise, display only sections they are allowed to submit to. $roleDao =& DAORegistry::getDAO('RoleDAO'); $isEditor = $roleDao->roleExists($journal->getId(), $user->getId(), ROLE_ID_EDITOR) || $roleDao->roleExists($journal->getId(), $user->getId(), ROLE_ID_SECTION_EDITOR); // Set up required Payment Related Information import('payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); if ($paymentManager->submissionEnabled() || $paymentManager->fastTrackEnabled() || $paymentManager->publicationEnabled()) { $templateMgr->assign('authorFees', true); $completedPaymentDAO =& DAORegistry::getDAO('OJSCompletedPaymentDAO'); $articleId = $this->articleId; if ($paymentManager->submissionEnabled()) { $templateMgr->assign_by_ref('submissionPayment', $completedPaymentDAO->getSubmissionCompletedPayment($journal->getId(), $articleId)); } if ($paymentManager->fastTrackEnabled()) { $templateMgr->assign_by_ref('fastTrackPayment', $completedPaymentDAO->getFastTrackCompletedPayment($journal->getId(), $articleId)); } } $templateMgr->assign('sectionOptions', array('0' => Locale::translate('author.submit.selectSection')) + $sectionDao->getSectionTitles($journal->getId(), !$isEditor)); parent::display(); }
/** * Validate the form */ function validate() { import('payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); if ($paymentManager->submissionEnabled()) { if (!$this->isValid()) { return false; } $journal =& Request::getJournal(); $journalId = $journal->getJournalId(); $articleId = $this->articleId; $user =& Request::getUser(); $completedPaymentDAO =& DAORegistry::getDAO('OJSCompletedPaymentDAO'); if ($completedPaymentDAO->hasPaidSubmission($journalId, $articleId)) { return parent::validate(); } elseif (Request::getUserVar('qualifyForWaiver') && Request::getUserVar('commentsToEditor') != '') { return parent::validate(); } elseif (Request::getUserVar('paymentSent')) { return parent::validate(); } else { $queuedPayment =& $paymentManager->createQueuedPayment($journalId, PAYMENT_TYPE_SUBMISSION, $user->getUserId(), $articleId, $journal->getSetting('submissionFee')); $queuedPaymentId = $paymentManager->queuePayment($queuedPayment); $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment); exit; } } else { return parent::validate(); } }
function getContents(&$templateMgr) { $journal =& Request::getJournal(); if (!$journal) { return ''; } import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $templateMgr->assign('donationEnabled', $paymentManager->donationEnabled()); return parent::getContents($templateMgr); }
function index($args) { import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $journal =& Request::getJournal(); if (!Validation::isLoggedIn()) { Validation::redirectLogin("payment.loginRequired.forDonation"); } $user =& Request::getUser(); $queuedPayment =& $paymentManager->createQueuedPayment($journal->getId(), PAYMENT_TYPE_DONATION, $user->getId(), 0, 0); $queuedPaymentId = $paymentManager->queuePayment($queuedPayment); $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment); }
/** * Display journal author index page. */ function index($args) { list($journal) = AuthorHandler::validate(); AuthorHandler::setupTemplate(); $user =& Request::getUser(); $rangeInfo =& Handler::getRangeInfo('submissions'); $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $page = isset($args[0]) ? $args[0] : ''; switch ($page) { case 'completed': $active = false; break; default: $page = 'active'; $active = true; } $submissions = $authorSubmissionDao->getAuthorSubmissions($user->getUserId(), $journal->getJournalId(), $active, $rangeInfo); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('pageToDisplay', $page); if (!$active) { // Make view counts available if enabled. $templateMgr->assign('statViews', $journal->getSetting('statViews')); } $templateMgr->assign_by_ref('submissions', $submissions); // assign payment import('payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); if ($paymentManager->isConfigured()) { $templateMgr->assign('submissionEnabled', $paymentManager->submissionEnabled()); $templateMgr->assign('fastTrackEnabled', $paymentManager->fastTrackEnabled()); $templateMgr->assign('publicationEnabled', $paymentManager->publicationEnabled()); $completedPaymentDAO =& DAORegistry::getDAO('OJSCompletedPaymentDAO'); $templateMgr->assign_by_ref('completedPaymentDAO', $completedPaymentDAO); } /** Opatan Inc. **/ $journalPath = $journal->getPath(); $templateMgr->assign('journalTitle', $journalPath); import('issue.IssueAction'); $issueAction =& new IssueAction(); $templateMgr->register_function('print_issue_id', array($issueAction, 'smartyPrintIssueId')); $templateMgr->assign('helpTopicId', 'editorial.authorsRole.submissions'); $templateMgr->display('author/index.tpl'); }
/** * Get the HTML contents for this block. * @param $templateMgr object * @return $string */ function getContents(&$templateMgr) { $journal =& Request::getJournal(); $journalId = $journal ? $journal->getId() : null; if (!$journal) { return ''; } if ($journal->getSetting('publishingMode') != PUBLISHING_MODE_SUBSCRIPTION) { return ''; } $user =& Request::getUser(); $userId = $user ? $user->getId() : null; $templateMgr->assign('userLoggedIn', isset($userId) ? true : false); if (isset($userId)) { $subscriptionDao =& DAORegistry::getDAO('IndividualSubscriptionDAO'); $individualSubscription =& $subscriptionDao->getSubscriptionByUserForJournal($userId, $journalId); $templateMgr->assign_by_ref('individualSubscription', $individualSubscription); } // If no individual subscription or if not valid, check for institutional subscription if (!isset($individualSubscription) || !$individualSubscription->isValid()) { $IP = Request::getRemoteAddr(); $domain = Request::getRemoteDomain(); $subscriptionDao =& DAORegistry::getDAO('InstitutionalSubscriptionDAO'); $subscriptionId = $subscriptionDao->isValidInstitutionalSubscription($domain, $IP, $journalId); if ($subscriptionId) { $institutionalSubscription =& $subscriptionDao->getSubscription($subscriptionId); $templateMgr->assign_by_ref('institutionalSubscription', $institutionalSubscription); $templateMgr->assign('userIP', $IP); } } if (isset($individualSubscription) || isset($institutionalSubscription)) { import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $acceptSubscriptionPayments = $paymentManager->acceptSubscriptionPayments(); $templateMgr->assign('acceptSubscriptionPayments', $acceptSubscriptionPayments); } return parent::getContents($templateMgr); }
/** * Display the form. */ function display() { $journal =& Request::getJournal(); $user =& Request::getUser(); $templateMgr =& TemplateManager::getManager(); // Get sections for this journal $sectionDao =& DAORegistry::getDAO('SectionDAO'); // If this user is a section editor or an editor, they are // allowed to submit to sections flagged as "editor-only" for // submissions. Otherwise, display only sections they are // allowed to submit to. $roleDao =& DAORegistry::getDAO('RoleDAO'); $isEditor = $roleDao->roleExists($journal->getId(), $user->getId(), ROLE_ID_EDITOR) || $roleDao->roleExists($journal->getId(), $user->getId(), ROLE_ID_SECTION_EDITOR); $templateMgr->assign('sectionOptions', array('0' => Locale::translate('author.submit.selectSection')) + $sectionDao->getSectionTitles($journal->getId(), !$isEditor)); // Set up required Payment Related Information import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); if ($paymentManager->submissionEnabled() || $paymentManager->fastTrackEnabled() || $paymentManager->publicationEnabled()) { $templateMgr->assign('authorFees', true); $completedPaymentDAO =& DAORegistry::getDAO('OJSCompletedPaymentDAO'); $articleId = $this->articleId; if ($paymentManager->submissionEnabled()) { $templateMgr->assign_by_ref('submissionPayment', $completedPaymentDAO->getSubmissionCompletedPayment($journal->getId(), $articleId)); } if ($paymentManager->fastTrackEnabled()) { $templateMgr->assign_by_ref('fastTrackPayment', $completedPaymentDAO->getFastTrackCompletedPayment($journal->getId(), $articleId)); } } // Provide available submission languages. (Convert the array // of locale symbolic names xx_XX into an associative array // of symbolic names => readable names.) $supportedSubmissionLocales = $journal->getSetting('supportedSubmissionLocales'); if (empty($supportedSubmissionLocales)) { $supportedSubmissionLocales = array($journal->getPrimaryLocale()); } $templateMgr->assign('supportedSubmissionLocaleNames', array_flip(array_intersect(array_flip(Locale::getAllLocales()), $supportedSubmissionLocales))); parent::display(); }
/** * Handle incoming requests/notifications */ function handle($args) { $journal =& Request::getJournal(); $templateMgr =& TemplateManager::getManager(); $user =& Request::getUser(); $op = isset($args[0]) ? $args[0] : null; $queuedPaymentId = isset($args[1]) ? (int) $args[1] : 0; import('classes.payment.ojs.OJSPaymentManager'); $ojsPaymentManager =& OJSPaymentManager::getManager(); $queuedPayment =& $ojsPaymentManager->getQueuedPayment($queuedPaymentId); // if the queued payment doesn't exist, redirect away from payments if (!$queuedPayment) { Request::redirect(null, 'index'); } switch ($op) { case 'notify': import('classes.mail.MailTemplate'); Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON)); $contactName = $journal->getSetting('contactName'); $contactEmail = $journal->getSetting('contactEmail'); $mail = new MailTemplate('MANUAL_PAYMENT_NOTIFICATION'); $mail->setFrom($contactEmail, $contactName); $mail->addRecipient($contactEmail, $contactName); $mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'userFullName' => $user ? $user->getFullName() : '(' . Locale::translate('common.none') . ')', 'userName' => $user ? $user->getUsername() : '(' . Locale::translate('common.none') . ')', 'itemName' => $queuedPayment->getName(), 'itemCost' => $queuedPayment->getAmount(), 'itemCurrencyCode' => $queuedPayment->getCurrencyCode())); $mail->send(); $templateMgr->assign(array('currentUrl' => Request::url(null, null, 'payment', 'plugin', array('notify', $queuedPaymentId)), 'pageTitle' => 'plugins.paymethod.manual.paymentNotification', 'message' => 'plugins.paymethod.manual.notificationSent', 'backLink' => $queuedPayment->getRequestUrl(), 'backLinkLabel' => 'common.continue')); $templateMgr->display('common/message.tpl'); exit; break; } parent::handle($args); // Don't know what to do with it }
/** * Display subscriptions page. */ function memberships() { $this->addCheck(new HandlerValidatorJournal($this)); $this->validate(); $this->setupTemplate(true); $journal =& Request::getJournal(); $journalId = $journal->getId(); import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $membershipEnabled = $paymentManager->membershipEnabled(); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('membershipEnabled', $membershipEnabled); if ($membershipEnabled) { $membershipFee = $journal->getSetting('membershipFee'); $membershipFeeName =& $journal->getLocalizedSetting('membershipFeeName'); $membershipFeeDescription =& $journal->getLocalizedSetting('membershipFeeDescription'); $currency = $journal->getSetting('currency'); $templateMgr->assign('membershipFee', $membershipFee); $templateMgr->assign('currency', $currency); $templateMgr->assign('membershipFeeName', $membershipFeeName); $templateMgr->assign('membershipFeeDescription', $membershipFeeDescription); $templateMgr->display('about/memberships.tpl'); return; } Request::redirect(null, 'about'); }
function payMembership($args) { $this->validate(); $this->setupTemplate(); import('payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $journal =& Request::getJournal(); $user =& Request::getUser(); $queuedPayment =& $paymentManager->createQueuedPayment($journal->getId(), PAYMENT_TYPE_MEMBERSHIP, $user->getId(), null, $journal->getSetting('membershipFee')); $queuedPaymentId = $paymentManager->queuePayment($queuedPayment); $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment); }
/** * Save subscription policies for the current journal. */ function saveSubscriptionPolicies($args = array()) { import('classes.subscription.form.SubscriptionPolicyForm'); $subscriptionPolicyForm = new SubscriptionPolicyForm(); $subscriptionPolicyForm->readInputData(); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('helpTopicId', 'journal.managementPages.subscriptions'); if (Config::getVar('general', 'scheduled_tasks')) { $templateMgr->assign('scheduledTasksEnabled', true); } import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $templateMgr->assign('acceptSubscriptionPayments', $paymentManager->acceptSubscriptionPayments()); if ($subscriptionPolicyForm->validate()) { $subscriptionPolicyForm->execute(); $templateMgr->assign('subscriptionPoliciesSaved', '1'); $subscriptionPolicyForm->display(); } else { $subscriptionPolicyForm->display(); } }
/** * Display journal author index page. */ function index($args) { $this->validate(); $this->setupTemplate(); $journal =& Request::getJournal(); $user =& Request::getUser(); $rangeInfo =& Handler::getRangeInfo('submissions'); $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $page = isset($args[0]) ? $args[0] : ''; switch ($page) { case 'completed': $active = false; break; default: $page = 'active'; $active = true; } $sort = Request::getUserVar('sort'); $sort = isset($sort) ? $sort : 'title'; $sortDirection = Request::getUserVar('sortDirection'); $sortDirection = isset($sortDirection) && ($sortDirection == SORT_DIRECTION_ASC || $sortDirection == SORT_DIRECTION_DESC) ? $sortDirection : SORT_DIRECTION_ASC; if ($sort == 'status') { // FIXME Does not pass $rangeInfo else we only get partial results $unsortedSubmissions = $authorSubmissionDao->getAuthorSubmissions($user->getId(), $journal->getId(), $active, null, $sort, $sortDirection); // Sort all submissions by status, which is too complex to do in the DB $submissionsArray = $unsortedSubmissions->toArray(); $compare = create_function('$s1, $s2', 'return strcmp($s1->getSubmissionStatus(), $s2->getSubmissionStatus());'); usort($submissionsArray, $compare); if ($sortDirection == SORT_DIRECTION_DESC) { $submissionsArray = array_reverse($submissionsArray); } // Convert submission array back to an ItemIterator class import('core.ArrayItemIterator'); $submissions =& ArrayItemIterator::fromRangeInfo($submissionsArray, $rangeInfo); } else { $submissions = $authorSubmissionDao->getAuthorSubmissions($user->getId(), $journal->getId(), $active, $rangeInfo, $sort, $sortDirection); } $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('pageToDisplay', $page); if (!$active) { // Make view counts available if enabled. $templateMgr->assign('statViews', $journal->getSetting('statViews')); } $templateMgr->assign_by_ref('submissions', $submissions); // assign payment import('payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); if ($paymentManager->isConfigured()) { $templateMgr->assign('submissionEnabled', $paymentManager->submissionEnabled()); $templateMgr->assign('fastTrackEnabled', $paymentManager->fastTrackEnabled()); $templateMgr->assign('publicationEnabled', $paymentManager->publicationEnabled()); $completedPaymentDAO =& DAORegistry::getDAO('OJSCompletedPaymentDAO'); $templateMgr->assign_by_ref('completedPaymentDAO', $completedPaymentDAO); } import('issue.IssueAction'); $issueAction = new IssueAction(); $templateMgr->register_function('print_issue_id', array($issueAction, 'smartyPrintIssueId')); $templateMgr->assign('helpTopicId', 'editorial.authorsRole.submissions'); $templateMgr->assign('sort', $sort); $templateMgr->assign('sortDirection', $sortDirection); $templateMgr->display('author/index.tpl'); }
/** * Get the HTML contents for this block. * @param $templateMgr object * @return $string */ function getContents(&$templateMgr) { $journal =& Request::getJournal(); $journalId = $journal ? $journal->getJournalId() : null; if (!$journal) { return ''; } $user =& Request::getUser(); $userId = $user ? $user->getUserId() : null; $domain = Request::getRemoteDomain(); $IP = Request::getRemoteAddr(); // This replicates the order of SubscriptionDAO::isValidSubscription // Checks for valid Subscription and assigns vars accordingly for display $subscriptionDao =& DAORegistry::getDAO('SubscriptionDAO'); $subscriptionId = false; $userHasSubscription = false; if ($userId != null) { $subscriptionId = $subscriptionDao->isValidSubscriptionByUser($userId, $journalId); $userHasSubscription = true; } if (!$userHasSubscription && $domain != null) { $subscriptionId = $subscriptionDao->isValidSubscriptionByDomain($domain, $journalId); } if (!$userHasSubscription && $IP != null) { $subscriptionId = $subscriptionDao->isValidSubscriptionByIP($IP, $journalId); } if ($subscriptionId !== false) { $subscription =& $subscriptionDao->getSubscription($subscriptionId); $templateMgr->assign('userHasSubscription', $userHasSubscription); if ($userHasSubscription) { import('payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $subscriptionEnabled = $paymentManager->acceptSubscriptionPayments(); $templateMgr->assign('subscriptionEnabled', $subscriptionEnabled); } $templateMgr->assign('subscriptionMembership', $subscription->getMembership()); $templateMgr->assign('subscriptionDateEnd', $subscription->getDateEnd()); $templateMgr->assign('subscriptionTypeName', $subscription->getSubscriptionTypeName()); $templateMgr->assign('userIP', $IP); return parent::getContents($templateMgr); } return ''; }
/** * Constructor. * Initialize template engine and assign basic template variables. */ function TemplateManager() { parent::PKPTemplateManager(); // Are we using implicit authentication? $this->assign('implicitAuth', Config::getVar('security', 'implicit_auth')); if (!defined('SESSION_DISABLE_INIT')) { /** * Kludge to make sure no code that tries to connect to * the database is executed (e.g., when loading * installer pages). */ $journal =& Request::getJournal(); $site =& Request::getSite(); $siteFilesDir = Request::getBaseUrl() . '/' . PublicFileManager::getSiteFilesPath(); $this->assign('sitePublicFilesDir', $siteFilesDir); $this->assign('publicFilesDir', $siteFilesDir); // May be overridden by journal $siteStyleFilename = PublicFileManager::getSiteFilesPath() . '/' . $site->getSiteStyleFilename(); if (file_exists($siteStyleFilename)) { $this->addStyleSheet(Request::getBaseUrl() . '/' . $siteStyleFilename); } if (isset($journal)) { $this->assign_by_ref('currentJournal', $journal); $journalTitle = $journal->getJournalTitle(); $this->assign('siteTitle', $journalTitle); $this->assign('publicFilesDir', Request::getBaseUrl() . '/' . PublicFileManager::getJournalFilesPath($journal->getJournalId())); $this->assign('primaryLocale', $journal->getPrimaryLocale()); $this->assign('alternateLocales', $journal->getSetting('alternateLocales')); // Assign additional navigation bar items $navMenuItems =& $journal->getLocalizedSetting('navItems'); $this->assign_by_ref('navMenuItems', $navMenuItems); // Assign journal page header $this->assign('displayPageHeaderTitle', $journal->getJournalPageHeaderTitle()); $this->assign('displayPageHeaderLogo', $journal->getJournalPageHeaderLogo()); $this->assign('alternatePageHeader', $journal->getLocalizedSetting('journalPageHeader')); $this->assign('metaSearchDescription', $journal->getLocalizedSetting('searchDescription')); $this->assign('metaSearchKeywords', $journal->getLocalizedSetting('searchKeywords')); $this->assign('metaCustomHeaders', $journal->getLocalizedSetting('customHeaders')); $this->assign('numPageLinks', $journal->getSetting('numPageLinks')); $this->assign('itemsPerPage', $journal->getSetting('itemsPerPage')); $this->assign('enableAnnouncements', $journal->getSetting('enableAnnouncements')); // Load and apply theme plugin, if chosen $themePluginPath = $journal->getSetting('journalTheme'); if (!empty($themePluginPath)) { // Load and activate the theme $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath); if ($themePlugin) { $themePlugin->activate($this); } } // Assign stylesheets and footer $journalStyleSheet = $journal->getSetting('journalStyleSheet'); if ($journalStyleSheet) { $this->addStyleSheet(Request::getBaseUrl() . '/' . PublicFileManager::getJournalFilesPath($journal->getJournalId()) . '/' . $journalStyleSheet['uploadName']); } import('payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $this->assign('journalPaymentsEnabled', $paymentManager->isConfigured()); $this->assign('pageFooter', $journal->getLocalizedSetting('journalPageFooter')); } else { // Add the site-wide logo, if set for this locale or the primary locale $this->assign('displayPageHeaderTitle', $site->getSitePageHeaderTitle()); $this->assign('siteTitle', $site->getSiteTitle()); } if (!$site->getRedirect()) { $this->assign('hasOtherJournals', true); } } }
/** * 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); }
/** * Constructor. * Initialize template engine and assign basic template variables. */ function TemplateManager() { parent::Smarty(); import('file.PublicFileManager'); import('cache.CacheManager'); // Set up Smarty configuration $baseDir = Core::getBaseDir(); $cachePath = CacheManager::getFileCachePath(); $this->template_dir = $baseDir . DIRECTORY_SEPARATOR . 'templates'; $this->compile_dir = $cachePath . DIRECTORY_SEPARATOR . 't_compile'; $this->config_dir = $cachePath . DIRECTORY_SEPARATOR . 't_config'; $this->cache_dir = $cachePath . DIRECTORY_SEPARATOR . 't_cache'; // Assign common variables $this->styleSheets = array(); $this->assign_by_ref('stylesheets', $this->styleSheets); $this->cacheability = CACHEABILITY_NO_STORE; // Safe default $this->assign('defaultCharset', Config::getVar('i18n', 'client_charset')); $this->assign('baseUrl', Request::getBaseUrl()); $this->assign('pageTitle', 'common.openJournalSystems'); $this->assign('requestedPage', Request::getRequestedPage()); $this->assign('currentUrl', Request::getCompleteUrl()); $this->assign('dateFormatTrunc', Config::getVar('general', 'date_format_trunc')); $this->assign('dateFormatShort', Config::getVar('general', 'date_format_short')); $this->assign('dateFormatLong', Config::getVar('general', 'date_format_long')); $this->assign('datetimeFormatShort', Config::getVar('general', 'datetime_format_short')); $this->assign('datetimeFormatLong', Config::getVar('general', 'datetime_format_long')); // Are we using implicit authentication? $this->assign('implicitAuth', Config::getVar('security', 'implicit_auth')); $locale = Locale::getLocale(); $this->assign('currentLocale', $locale); if (!defined('SESSION_DISABLE_INIT')) { /* Kludge to make sure no code that tries to connect to the database is executed * (e.g., when loading installer pages). */ $this->assign('isUserLoggedIn', Validation::isLoggedIn()); $journal =& Request::getJournal(); $site =& Request::getSite(); $versionDAO =& DAORegistry::getDAO('VersionDAO'); $currentVersion = $versionDAO->getCurrentVersion(); $this->assign('currentVersionString', $currentVersion->getVersionString()); $siteFilesDir = Request::getBaseUrl() . '/' . PublicFileManager::getSiteFilesPath(); $this->assign('sitePublicFilesDir', $siteFilesDir); $this->assign('publicFilesDir', $siteFilesDir); // May be overridden by journal $siteStyleFilename = PublicFileManager::getSiteFilesPath() . '/' . $site->getSiteStyleFilename(); if (file_exists($siteStyleFilename)) { $this->addStyleSheet(Request::getBaseUrl() . '/' . $siteStyleFilename); } if (isset($journal)) { $this->assign_by_ref('currentJournal', $journal); $journalTitle = $journal->getJournalTitle(); $this->assign('siteTitle', $journalTitle); $this->assign('publicFilesDir', Request::getBaseUrl() . '/' . PublicFileManager::getJournalFilesPath($journal->getJournalId())); $this->assign('primaryLocale', $journal->getPrimaryLocale()); $this->assign('alternateLocales', $journal->getSetting('alternateLocales')); // Assign additional navigation bar items $navMenuItems =& $journal->getLocalizedSetting('navItems'); $this->assign_by_ref('navMenuItems', $navMenuItems); // Assign journal page header $this->assign('displayPageHeaderTitle', $journal->getJournalPageHeaderTitle()); $this->assign('displayPageHeaderLogo', $journal->getJournalPageHeaderLogo()); $this->assign('alternatePageHeader', $journal->getLocalizedSetting('journalPageHeader')); $this->assign('metaSearchDescription', $journal->getLocalizedSetting('searchDescription')); $this->assign('metaSearchKeywords', $journal->getLocalizedSetting('searchKeywords')); $this->assign('metaCustomHeaders', $journal->getLocalizedSetting('customHeaders')); $this->assign('numPageLinks', $journal->getSetting('numPageLinks')); $this->assign('itemsPerPage', $journal->getSetting('itemsPerPage')); $this->assign('enableAnnouncements', $journal->getSetting('enableAnnouncements')); // Load and apply theme plugin, if chosen $themePluginPath = $journal->getSetting('journalTheme'); if (!empty($themePluginPath)) { // Load and activate the theme $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath); if ($themePlugin) { $themePlugin->activate($this); } } // Assign stylesheets and footer $journalStyleSheet = $journal->getSetting('journalStyleSheet'); if ($journalStyleSheet) { $this->addStyleSheet(Request::getBaseUrl() . '/' . PublicFileManager::getJournalFilesPath($journal->getJournalId()) . '/' . $journalStyleSheet['uploadName']); } import('payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $this->assign('journalPaymentsEnabled', $paymentManager->isConfigured()); $this->assign('pageFooter', $journal->getLocalizedSetting('journalPageFooter')); } else { // Add the site-wide logo, if set for this locale or the primary locale $this->assign('displayPageHeaderTitle', $site->getSitePageHeaderTitle()); $this->assign('siteTitle', $site->getSiteTitle()); $this->assign('itemsPerPage', Config::getVar('interface', 'items_per_page')); $this->assign('numPageLinks', Config::getVar('interface', 'page_links')); } if (!$site->getJournalRedirect()) { $this->assign('hasOtherJournals', true); } } // If there's a locale-specific stylesheet, add it. if (($localeStyleSheet = Locale::getLocaleStyleSheet($locale)) != null) { $this->addStyleSheet(Request::getBaseUrl() . '/' . $localeStyleSheet); } // Register custom functions $this->register_modifier('translate', array('Locale', 'translate')); $this->register_modifier('strip_unsafe_html', array('String', 'stripUnsafeHtml')); $this->register_modifier('String_substr', array('String', 'substr')); $this->register_modifier('to_array', array(&$this, 'smartyToArray')); $this->register_modifier('escape', array(&$this, 'smartyEscape')); $this->register_modifier('explode', array(&$this, 'smartyExplode')); $this->register_modifier('assign', array(&$this, 'smartyAssign')); $this->register_function('translate', array(&$this, 'smartyTranslate')); $this->register_function('flush', array(&$this, 'smartyFlush')); $this->register_function('call_hook', array(&$this, 'smartyCallHook')); $this->register_function('html_options_translate', array(&$this, 'smartyHtmlOptionsTranslate')); $this->register_block('iterate', array(&$this, 'smartyIterate')); $this->register_function('call_progress_function', array(&$this, 'smartyCallProgressFunction')); $this->register_function('page_links', array(&$this, 'smartyPageLinks')); $this->register_function('page_info', array(&$this, 'smartyPageInfo')); $this->register_function('get_help_id', array(&$this, 'smartyGetHelpId')); $this->register_function('icon', array(&$this, 'smartyIcon')); $this->register_function('help_topic', array(&$this, 'smartyHelpTopic')); $this->register_function('get_debug_info', array(&$this, 'smartyGetDebugInfo')); $this->register_function('assign_mailto', array(&$this, 'smartyAssignMailto')); $this->register_function('display_template', array(&$this, 'smartyDisplayTemplate')); $this->register_function('url', array(&$this, 'smartyUrl')); $this->initialized = false; }
function waivePublicationFee($args) { $articleId = (int) array_shift($args); $markAsPaid = Request::getUserVar('markAsPaid'); $sendToScheduling = Request::getUserVar('sendToScheduling') ? true : false; list($journal, $submission) = SubmissionEditHandler::validate($articleId, SECTION_EDITOR_ACCESS_EDIT); import('payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $user =& Request::getUser(); $queuedPayment =& $paymentManager->createQueuedPayment($journal->getJournalId(), PAYMENT_TYPE_PUBLICATION, $markAsPaid ? $submission->getUserId() : $user->getUserId(), $articleId, $markAsPaid ? $journal->getSetting('publicationFee') : 0, $markAsPaid ? $journal->getSetting('currency') : ''); $queuedPaymentId = $paymentManager->queuePayment($queuedPayment); // Since this is a waiver, fulfill the payment immediately $paymentManager->fulfillQueuedPayment($queuedPayment, $markAsPaid ? 'ManualPayment' : 'Waiver'); if ($sendToScheduling) { Request::redirect(null, null, 'submissionEditing', array($articleId), null, 'scheduling'); } else { Request::redirect(null, null, 'submission', array($articleId)); } }
/** * Constructor. * Initialize template engine and assign basic template variables. * @param $request PKPRequest FIXME: is optional for backwards compatibility only - make mandatory */ function TemplateManager($request = null) { // FIXME: for backwards compatibility only - remove if (!isset($request)) { // FIXME: Trigger a deprecation warning when enough instances of this // call have been fixed to not clutter the error log. $request =& Registry::get('request'); } assert(is_a($request, 'PKPRequest')); parent::PKPTemplateManager($request); // Retrieve the router $router =& $request->getRouter(); assert(is_a($router, 'PKPRouter')); // Are we using implicit authentication? $this->assign('implicitAuth', Config::getVar('security', 'implicit_auth')); if (!defined('SESSION_DISABLE_INIT')) { /** * Kludge to make sure no code that tries to connect to * the database is executed (e.g., when loading * installer pages). */ $journal =& $router->getContext($request); $site =& $request->getSite(); $siteFilesDir = $request->getBaseUrl() . '/' . PublicFileManager::getSiteFilesPath(); $this->assign('sitePublicFilesDir', $siteFilesDir); $this->assign('publicFilesDir', $siteFilesDir); // May be overridden by journal $siteStyleFilename = PublicFileManager::getSiteFilesPath() . '/' . $site->getSiteStyleFilename(); if (file_exists($siteStyleFilename)) { $this->addStyleSheet($request->getBaseUrl() . '/' . $siteStyleFilename); } $this->assign('homeContext', array()); if (isset($journal)) { $this->assign_by_ref('currentJournal', $journal); $journalTitle = $journal->getLocalizedTitle(); $this->assign('siteTitle', $journalTitle); $this->assign('publicFilesDir', $request->getBaseUrl() . '/' . PublicFileManager::getJournalFilesPath($journal->getId())); $this->assign('primaryLocale', $journal->getPrimaryLocale()); $this->assign('alternateLocales', $journal->getSetting('alternateLocales')); // Assign additional navigation bar items $navMenuItems =& $journal->getLocalizedSetting('navItems'); $this->assign_by_ref('navMenuItems', $navMenuItems); // Assign journal page header $this->assign('displayPageHeaderTitle', $journal->getLocalizedPageHeaderTitle()); $this->assign('displayPageHeaderLogo', $journal->getLocalizedPageHeaderLogo()); $this->assign('displayPageHeaderTitleAltText', $journal->getLocalizedSetting('pageHeaderTitleImageAltText')); $this->assign('displayPageHeaderLogoAltText', $journal->getLocalizedSetting('pageHeaderLogoImageAltText')); $this->assign('displayFavicon', $journal->getLocalizedFavicon()); $this->assign('faviconDir', $request->getBaseUrl() . '/' . PublicFileManager::getJournalFilesPath($journal->getId())); $this->assign('alternatePageHeader', $journal->getLocalizedSetting('journalPageHeader')); $this->assign('metaSearchDescription', $journal->getLocalizedSetting('searchDescription')); $this->assign('metaSearchKeywords', $journal->getLocalizedSetting('searchKeywords')); $this->assign('metaCustomHeaders', $journal->getLocalizedSetting('customHeaders')); $this->assign('numPageLinks', $journal->getSetting('numPageLinks')); $this->assign('itemsPerPage', $journal->getSetting('itemsPerPage')); $this->assign('enableAnnouncements', $journal->getSetting('enableAnnouncements')); $this->assign('hideRegisterLink', !$journal->getSetting('allowRegReviewer') && !$journal->getSetting('allowRegReader') && !$journal->getSetting('allowRegAuthor')); // Load and apply theme plugin, if chosen $themePluginPath = $journal->getSetting('journalTheme'); if (!empty($themePluginPath)) { // Load and activate the theme $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath); if ($themePlugin) { $themePlugin->activate($this); } } // Assign stylesheets and footer $journalStyleSheet = $journal->getSetting('journalStyleSheet'); if ($journalStyleSheet) { $this->addStyleSheet($request->getBaseUrl() . '/' . PublicFileManager::getJournalFilesPath($journal->getId()) . '/' . $journalStyleSheet['uploadName']); } import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $this->assign('journalPaymentsEnabled', $paymentManager->isConfigured()); $this->assign('pageFooter', $journal->getLocalizedSetting('journalPageFooter')); } else { // Add the site-wide logo, if set for this locale or the primary locale $displayPageHeaderTitle = $site->getLocalizedPageHeaderTitle(); $this->assign('displayPageHeaderTitle', $displayPageHeaderTitle); if (isset($displayPageHeaderTitle['altText'])) { $this->assign('displayPageHeaderTitleAltText', $displayPageHeaderTitle['altText']); } $this->assign('siteTitle', $site->getLocalizedTitle()); } if (!$site->getRedirect()) { $this->assign('hasOtherJournals', true); } // Add java script for notifications $user =& $request->getUser(); if ($user) { $this->addJavaScript('lib/pkp/js/jquery.pnotify.js'); } } }
/** * Create/update individual subscription. */ function execute() { $journal =& Request::getJournal(); $journalId = $journal->getId(); $typeId = $this->getData('typeId'); $subscriptionTypeDao =& DAORegistry::getDAO('SubscriptionTypeDAO'); $nonExpiring = $subscriptionTypeDao->getSubscriptionTypeNonExpiring($typeId); $today = date('Y-m-d'); $insert = false; if (!isset($this->subscription)) { import('classes.subscription.IndividualSubscription'); $subscription = new IndividualSubscription(); $subscription->setJournalId($journalId); $subscription->setUserId($this->userId); $subscription->setReferenceNumber(null); $subscription->setNotes(null); $insert = true; } else { $subscription =& $this->subscription; } import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $paymentPlugin =& $paymentManager->getPaymentPlugin(); if ($paymentPlugin->getName() == 'ManualPayment') { $subscription->setStatus(SUBSCRIPTION_STATUS_AWAITING_MANUAL_PAYMENT); } else { $subscription->setStatus(SUBSCRIPTION_STATUS_AWAITING_ONLINE_PAYMENT); } $subscription->setTypeId($typeId); $subscription->setMembership($this->getData('membership') ? $this->getData('membership') : null); $subscription->setDateStart($nonExpiring ? null : $today); $subscription->setDateEnd($nonExpiring ? null : $today); $individualSubscriptionDao =& DAORegistry::getDAO('IndividualSubscriptionDAO'); if ($insert) { $individualSubscriptionDao->insertSubscription($subscription); } else { $individualSubscriptionDao->updateSubscription($subscription); } $subscriptionTypeDao =& DAORegistry::getDAO('SubscriptionTypeDAO'); $subscriptionType =& $subscriptionTypeDao->getSubscriptionType($this->getData('typeId')); $queuedPayment =& $paymentManager->createQueuedPayment($journalId, PAYMENT_TYPE_PURCHASE_SUBSCRIPTION, $this->userId, $subscription->getId(), $subscriptionType->getCost(), $subscriptionType->getCurrencyCodeAlpha()); $queuedPaymentId = $paymentManager->queuePayment($queuedPayment); $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment); }
/** * Display a form to pay for Publishing an article * @param $args array ($articleId) */ function payPublicationFee($args) { $articleId = isset($args[0]) ? $args[0] : 0; list($journal, $submission) = TrackSubmissionHandler::validate($articleId); parent::setupTemplate(true, $articleId); import('payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $user =& Request::getUser(); $queuedPayment =& $paymentManager->createQueuedPayment($journal->getJournalId(), PAYMENT_TYPE_PUBLICATION, $user->getUserId(), $articleId, $journal->getSetting('publicationFee')); $queuedPaymentId = $paymentManager->queuePayment($queuedPayment); $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment); }
/** * Display journal author index page. */ function index($args) { $this->validate(); $this->setupTemplate(); $journal =& Request::getJournal(); $user =& Request::getUser(); $rangeInfo =& Handler::getRangeInfo('submissions'); $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $searchField = Request::getUserVar('searchField'); $dateSearchField = Request::getUserVar('dateSearchField'); $searchMatch = Request::getUserVar('searchMatch'); $search = Request::getUserVar('search'); $fromDate = Request::getUserDateVar('dateFrom', 1, 1); if ($fromDate !== null) { $fromDate = date('Y-m-d H:i:s', $fromDate); } $toDate = Request::getUserDateVar('dateTo', 32, 12, null, 23, 59, 59); if ($toDate !== null) { $toDate = date('Y-m-d H:i:s', $toDate); } $page = isset($args[0]) ? $args[0] : ''; switch ($page) { case 'proposalsInReview': $functionName = 'getAuthorProposalsInReviewIterator'; break; case 'ongoingResearches': $functionName = 'getAuthorOngoingResearchesIterator'; break; case 'completedResearches': $functionName = 'getAuthorCompletedResearchesIterator'; break; case 'submissionsArchives': $functionName = 'getAuthorArchivesIterator'; break; default: $functionName = 'getAuthorProposalsToSubmitIterator'; $page = 'proposalsToSubmit'; } $sort = Request::getUserVar('sort'); $sort = isset($sort) ? $sort : 'title'; $sortDirection = Request::getUserVar('sortDirection'); $sortDirection = isset($sortDirection) && ($sortDirection == SORT_DIRECTION_ASC || $sortDirection == SORT_DIRECTION_DESC) ? $sortDirection : SORT_DIRECTION_ASC; $submissions = $authorSubmissionDao->{$functionName}($user->getId(), $journal->getId(), $searchField, $searchMatch, $search, $dateSearchField, $fromDate, $toDate, $rangeInfo, $sort, $sortDirection); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('pageToDisplay', $page); $templateMgr->assign_by_ref('submissions', $submissions); /********************************************************************* * Add search fields to template * Added by: Ayvee Mallare * Last Updated: Sept 25, 2011 *********************************************************************/ $duplicateParameters = array('searchField', 'searchMatch', 'search', 'dateFromMonth', 'dateFromDay', 'dateFromYear', 'dateToMonth', 'dateToDay', 'dateToYear', 'dateSearchField'); foreach ($duplicateParameters as $param) { $templateMgr->assign($param, Request::getUserVar($param)); } $templateMgr->assign('dateFrom', $fromDate); $templateMgr->assign('dateTo', $toDate); $templateMgr->assign('fieldOptions', array(SUBMISSION_FIELD_TITLE => 'article.title', SUBMISSION_FIELD_AUTHOR => 'user.role.author', SUBMISSION_FIELD_EDITOR => 'user.role.editor')); $templateMgr->assign('dateFieldOptions', array(SUBMISSION_FIELD_DATE_SUBMITTED => 'submissions.submitted')); $extraFieldDao =& DAORegistry::getDAO('ExtraFieldDAO'); $countries =& $extraFieldDao->getExtraFieldsList(EXTRA_FIELD_GEO_AREA); $templateMgr->assign_by_ref('countries', $countries); // assign payment import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); if ($paymentManager->isConfigured()) { $templateMgr->assign('submissionEnabled', $paymentManager->submissionEnabled()); $templateMgr->assign('fastTrackEnabled', $paymentManager->fastTrackEnabled()); $templateMgr->assign('publicationEnabled', $paymentManager->publicationEnabled()); $completedPaymentDAO =& DAORegistry::getDAO('OJSCompletedPaymentDAO'); $templateMgr->assign_by_ref('completedPaymentDAO', $completedPaymentDAO); } import('classes.issue.IssueAction'); $issueAction = new IssueAction(); $templateMgr->register_function('print_issue_id', array($issueAction, 'smartyPrintIssueId')); $templateMgr->assign('helpTopicId', 'editorial.authorsRole.submissions'); $templateMgr->assign('sort', $sort); $templateMgr->assign('sortDirection', $sortDirection); $templateMgr->display('author/index.tpl'); }
/** * 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); }
/** * Display a form to pay for Publishing an article * @param $args array ($articleId) */ function payPublicationFee($args) { $articleId = isset($args[0]) ? $args[0] : 0; $this->validate($articleId); $this->setupTemplate(true, $articleId); $journal =& Request::getJournal(); import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $user =& Request::getUser(); $queuedPayment =& $paymentManager->createQueuedPayment($journal->getId(), PAYMENT_TYPE_PUBLICATION, $user->getId(), $articleId, $journal->getSetting('publicationFee')); $queuedPaymentId = $paymentManager->queuePayment($queuedPayment); $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment); }
/** * Returns an array of information on the journal's subscription settings * @return array */ function getSubscriptionSettings() { $journal = Request::getJournal(); if (!$journal) { return array(); } import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $settings = array('subscriptionsEnabled' => $paymentManager->acceptSubscriptionPayments(), 'allowRegReviewer' => $journal->getSetting('allowRegReviewer'), 'allowRegAuthor' => $journal->getSetting('allowRegAuthor')); return $settings; }
/** * Handle incoming requests/notifications */ function handle($args) { $templateMgr =& TemplateManager::getManager(); $journal =& Request::getJournal(); if (!$journal) { return parent::handle($args); } // Just in case we need to contact someone import('classes.mail.MailTemplate'); $contactName = $journal->getSetting('contactName'); $contactEmail = $journal->getSetting('contactEmail'); $mail = new MailTemplate('PAYPAL_INVESTIGATE_PAYMENT'); $mail->setFrom($contactEmail, $contactName); $mail->addRecipient($contactEmail, $contactName); $paymentStatus = Request::getUserVar('payment_status'); switch (array_shift($args)) { case 'ipn': // Build a confirmation transaction. $req = 'cmd=_notify-validate'; if (get_magic_quotes_gpc()) { foreach ($_POST as $key => $value) { $req .= '&' . urlencode(stripslashes($key)) . '=' . urlencode(stripslashes($value)); } } else { foreach ($_POST as $key => $value) { $req .= '&' . urlencode($key) . '=' . urlencode($value); } } // Create POST response $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->getSetting($journal->getId(), 'paypalurl')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Content-Length: ' . strlen($req))); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); $ret = curl_exec($ch); $curlError = curl_error($ch); curl_close($ch); // Check the confirmation response and handle as necessary. if (strcmp($ret, 'VERIFIED') == 0) { switch ($paymentStatus) { case 'Completed': $payPalDao =& DAORegistry::getDAO('PayPalDAO'); $transactionId = Request::getUserVar('txn_id'); if ($payPalDao->transactionExists($transactionId)) { // A duplicate transaction was received; notify someone. $mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Duplicate transaction ID: {$transactionId}", 'serverVars' => print_r($_SERVER, true))); $mail->send(); exit; } else { // New transaction succeeded. Record it. $payPalDao->insertTransaction($transactionId, Request::getUserVar('txn_type'), Request::getUserVar('payer_email'), Request::getUserVar('receiver_email'), Request::getUserVar('item_number'), Request::getUserVar('payment_date'), Request::getUserVar('payer_id'), Request::getUserVar('receiver_id')); $queuedPaymentId = Request::getUserVar('custom'); import('classes.payment.ojs.OJSPaymentManager'); $ojsPaymentManager =& OJSPaymentManager::getManager(); // Verify the cost and user details as per PayPal spec. $queuedPayment =& $ojsPaymentManager->getQueuedPayment($queuedPaymentId); if (!$queuedPayment) { // The queued payment entry is missing. Complain. $mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Missing queued payment ID: {$queuedPaymentId}", 'serverVars' => print_r($_SERVER, true))); $mail->send(); exit; } //NB: if/when paypal subscriptions are enabled, these checks will have to be adjusted // because subscription prices may change over time if (($queuedAmount = $queuedPayment->getAmount()) != ($grantedAmount = Request::getUserVar('mc_gross')) && $queuedAmount > 0 || ($queuedCurrency = $queuedPayment->getCurrencyCode()) != ($grantedCurrency = Request::getUserVar('mc_currency')) || ($grantedEmail = Request::getUserVar('receiver_email')) != ($queuedEmail = $this->getSetting($journal->getId(), 'selleraccount'))) { // The integrity checks for the transaction failed. Complain. $mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Granted amount: {$grantedAmount}\n" . "Queued amount: {$queuedAmount}\n" . "Granted currency: {$grantedCurrency}\n" . "Queued currency: {$queuedCurrency}\n" . "Granted to PayPal account: {$grantedEmail}\n" . "Configured PayPal account: {$queuedEmail}", 'serverVars' => print_r($_SERVER, true))); $mail->send(); exit; } // Update queued amount if amount set by user (e.g. donation) if ($queuedAmount == 0 && $grantedAmount > 0) { $queuedPaymentDao =& DAORegistry::getDAO('QueuedPaymentDAO'); $queuedPayment->setAmount($grantedAmount); $queuedPayment->setCurrencyCode($grantedCurrency); $queuedPaymentDao->updateQueuedPayment($queuedPaymentId, $queuedPayment); } // Fulfill the queued payment. if ($ojsPaymentManager->fulfillQueuedPayment($queuedPayment, $this->getName())) { exit; } // If we're still here, it means the payment couldn't be fulfilled. $mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Queued payment ID {$queuedPaymentId} could not be fulfilled.", 'serverVars' => print_r($_SERVER, true))); $mail->send(); } exit; case 'Pending': // Ignore. exit; default: // An unhandled payment status was received; notify someone. $mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Payment status: {$paymentStatus}", 'serverVars' => print_r($_SERVER, true))); $mail->send(); exit; } } else { // An unknown confirmation response was received; notify someone. $mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Confirmation return: {$ret}\nCURL error: {$curlError}", 'serverVars' => print_r($_SERVER, true))); $mail->send(); exit; } break; case 'cancel': Handler::setupTemplate(); $templateMgr->assign(array('currentUrl' => Request::url(null, 'index'), 'pageTitle' => 'plugins.paymethod.paypal.purchase.cancelled.title', 'message' => 'plugins.paymethod.paypal.purchase.cancelled', 'backLink' => Request::getUserVar('ojsReturnUrl'), 'backLinkLabel' => 'common.continue')); $templateMgr->display('common/message.tpl'); exit; break; } parent::handle($args); // Don't know what to do with it }
/** * 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 = AppLocale::getLocale(); import('classes.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->getId(), 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('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 = __('archive.issueUnavailable'); $issueHeadingTitle = __('archive.issueUnavailable'); } if ($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); }