Inheritance: extends PaymentManager
Example #1
0
 /**
  * Process payment form for buying a gift subscription
  * @param $args array
  * @param $request PKPRequest
  */
 function payPurchaseGiftSubscription($args, $request)
 {
     $journal = $request->getJournal();
     if (!$journal) {
         $request->redirect(null, 'index');
     }
     import('classes.payment.ojs.OJSPaymentManager');
     $paymentManager = new OJSPaymentManager($request);
     $acceptSubscriptionPayments = $paymentManager->acceptGiftSubscriptionPayments();
     if (!$acceptSubscriptionPayments) {
         $request->redirect(null, 'index');
     }
     $this->setupTemplate();
     $user = $request->getUser();
     // If buyer is logged in, save buyer user id as part of gift details
     if ($user) {
         $buyerUserId = $user->getId();
     } else {
         $buyerUserId = null;
     }
     import('classes.subscription.form.GiftIndividualSubscriptionForm');
     $giftSubscriptionForm = new GiftIndividualSubscriptionForm($buyerUserId);
     $giftSubscriptionForm->readInputData();
     if ($giftSubscriptionForm->validate()) {
         $giftSubscriptionForm->execute();
     } else {
         $giftSubscriptionForm->display();
     }
 }
 /**
  * @see BlockPlugin::getContents
  */
 function getContents(&$templateMgr, $request)
 {
     $journal =& $request->getJournal();
     if (!$journal) {
         return '';
     }
     import('classes.payment.ojs.OJSPaymentManager');
     $paymentManager = new OJSPaymentManager($request);
     $templateMgr->assign('donationEnabled', $paymentManager->donationEnabled());
     return parent::getContents($templateMgr, $request);
 }
Example #3
0
 /**
  * Display the donations page.
  * @param $args array
  * @param $request PKPRequest
  */
 function index($args, $request)
 {
     import('classes.payment.ojs.OJSPaymentManager');
     $paymentManager = new OJSPaymentManager($request);
     $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);
 }
 /**
  * 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();
     }
 }
 /**
  * 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();
 }
 /**
  * Queue payment and save gift details.
  */
 function execute()
 {
     $journal = $this->request->getJournal();
     $journalId = $journal->getId();
     // Create new gift and save details
     import('classes.gift.Gift');
     import('classes.payment.ojs.OJSPaymentManager');
     $paymentManager = new OJSPaymentManager($this->request);
     $paymentPlugin =& $paymentManager->getPaymentPlugin();
     $gift = new Gift();
     if ($paymentPlugin->getName() == 'ManualPayment') {
         $gift->setStatus(GIFT_STATUS_AWAITING_MANUAL_PAYMENT);
     } else {
         $gift->setStatus(GIFT_STATUS_AWAITING_ONLINE_PAYMENT);
     }
     $gift->setAssocType(ASSOC_TYPE_JOURNAL);
     $gift->setAssocId($journalId);
     $gift->setGiftType(GIFT_TYPE_SUBSCRIPTION);
     $gift->setGiftAssocId($this->getData('typeId'));
     $gift->setBuyerFirstName($this->getData('buyerFirstName'));
     $gift->setBuyerMiddleName($this->getData('buyerMiddleName'));
     $gift->setBuyerLastName($this->getData('buyerLastName'));
     $gift->setBuyerEmail($this->getData('buyerEmail'));
     $gift->setBuyerUserId($this->buyerUserId ? $this->buyerUserId : null);
     $gift->setRecipientFirstName($this->getData('recipientFirstName'));
     $gift->setRecipientMiddleName($this->getData('recipientMiddleName'));
     $gift->setRecipientLastName($this->getData('recipientLastName'));
     $gift->setRecipientEmail($this->getData('recipientEmail'));
     $gift->setRecipientUserId(null);
     $gift->setLocale($this->getData('giftLocale'));
     $gift->setGiftNoteTitle($this->getData('giftNoteTitle'));
     $gift->setGiftNote($this->getData('giftNote'));
     $giftDao = DAORegistry::getDAO('GiftDAO');
     $giftId = $giftDao->insertObject($gift);
     // Create new queued payment
     $subscriptionTypeDao = DAORegistry::getDAO('SubscriptionTypeDAO');
     $subscriptionType =& $subscriptionTypeDao->getSubscriptionType($this->getData('typeId'));
     $queuedPayment =& $paymentManager->createQueuedPayment($journalId, PAYMENT_TYPE_GIFT, null, $giftId, $subscriptionType->getCost(), $subscriptionType->getCurrencyCodeAlpha());
     $queuedPaymentId = $paymentManager->queuePayment($queuedPayment);
     $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment);
 }
 /**
  * Get the HTML contents for this block.
  * @param $templateMgr object
  * @param $request PKPRequest
  * @return $string
  */
 function getContents(&$templateMgr, $request)
 {
     $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);
         }
     }
     import('classes.payment.ojs.OJSPaymentManager');
     $paymentManager = new OJSPaymentManager($request);
     if (isset($individualSubscription) || isset($institutionalSubscription)) {
         $acceptSubscriptionPayments = $paymentManager->acceptSubscriptionPayments();
         $templateMgr->assign('acceptSubscriptionPayments', $acceptSubscriptionPayments);
     }
     $acceptGiftSubscriptionPayments = $paymentManager->acceptGiftSubscriptionPayments();
     $templateMgr->assign('acceptGiftSubscriptionPayments', $acceptGiftSubscriptionPayments);
     return parent::getContents($templateMgr, $request);
 }
Example #8
0
 function index($args)
 {
     import('payment.ojs.OJSPaymentManager');
     $paymentManager =& OJSPaymentManager::getManager();
     $journal =& Request::getJournal();
     if (!Validation::isLoggedIn()) {
         Validation::redirectLogin("payment.loginRequired.forDonation");
     }
     $user =& Request::getUser();
     $queuedPayment =& $paymentManager->createQueuedPayment($journal->getJournalId(), PAYMENT_TYPE_DONATION, $user->getUserId(), 0, 0);
     $queuedPaymentId = $paymentManager->queuePayment($queuedPayment);
     $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment);
 }
Example #9
0
 /**
  * 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');
 }
 /**
  * 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();
 }
 /**
  * Save the metadata and store the catalog data for this published
  * monograph.
  */
 function execute($request)
 {
     parent::execute($request);
     $submission = $this->getSubmission();
     $context = $request->getContext();
     $waivePublicationFee = $request->getUserVar('waivePublicationFee') ? true : false;
     if ($waivePublicationFee) {
         $markAsPaid = $request->getUserVar('markAsPaid');
         import('classes.payment.ojs.OJSPaymentManager');
         $paymentManager = new OJSPaymentManager($request);
         $user = $request->getUser();
         // Get a list of author user IDs
         $authorUserIds = array();
         $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
         $submitterAssignments = $stageAssignmentDao->getBySubmissionAndRoleId($submission->getId(), ROLE_ID_AUTHOR);
         $submitterAssignment = $submitterAssignments->next();
         assert($submitterAssignment);
         // At least one author should be assigned
         $queuedPayment =& $paymentManager->createQueuedPayment($context->getId(), PAYMENT_TYPE_PUBLICATION, $markAsPaid ? $submitterAssignment->getUserId() : $user->getId(), $submission->getId(), $markAsPaid ? $context->getSetting('publicationFee') : 0, $markAsPaid ? $context->getSetting('currency') : '');
         $paymentManager->queuePayment($queuedPayment);
         // Since this is a waiver, fulfill the payment immediately
         $paymentManager->fulfillQueuedPayment($request, $queuedPayment, $markAsPaid ? 'ManualPayment' : 'Waiver');
     } else {
         // Get the issue for publication.
         $issueDao = DAORegistry::getDAO('IssueDAO');
         $issueId = $this->getData('issueId');
         $issue = $issueDao->getById($issueId, $context->getId());
         $sectionDao = DAORegistry::getDAO('SectionDAO');
         $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
         $publishedArticle = $publishedArticleDao->getPublishedArticleByArticleId($submission->getId(), null, false);
         /* @var $publishedArticle PublishedArticle */
         if ($publishedArticle) {
             if (!$issue || !$issue->getPublished()) {
                 $fromIssue = $issueDao->getById($publishedArticle->getIssueId(), $context->getId());
                 if ($fromIssue->getPublished()) {
                     // Insert article tombstone
                     import('classes.article.ArticleTombstoneManager');
                     $articleTombstoneManager = new ArticleTombstoneManager();
                     $articleTombstoneManager->insertArticleTombstone($submission, $context);
                 }
             }
         }
         import('classes.search.ArticleSearchIndex');
         $articleSearchIndex = new ArticleSearchIndex();
         // define the access status for the article if none is set.
         $accessStatus = $this->getData('accessStatus') != '' ? $this->getData('accessStatus') : ARTICLE_ACCESS_ISSUE_DEFAULT;
         $articleDao = DAORegistry::getDAO('ArticleDAO');
         if (!is_null($this->getData('pages'))) {
             $submission->setPages($this->getData('pages'));
         }
         if ($issue) {
             // Schedule against an issue.
             if ($publishedArticle) {
                 $publishedArticle->setIssueId($issueId);
                 $publishedArticle->setSequence(REALLY_BIG_NUMBER);
                 $publishedArticle->setDatePublished($this->getData('datePublished'));
                 $publishedArticle->setAccessStatus($accessStatus);
                 $publishedArticleDao->updatePublishedArticle($publishedArticle);
                 // Re-index the published article metadata.
                 $articleSearchIndex->articleMetadataChanged($publishedArticle);
             } else {
                 $publishedArticle = $publishedArticleDao->newDataObject();
                 $publishedArticle->setId($submission->getId());
                 $publishedArticle->setIssueId($issueId);
                 $publishedArticle->setDatePublished(Core::getCurrentDate());
                 $publishedArticle->setSequence(REALLY_BIG_NUMBER);
                 $publishedArticle->setAccessStatus($accessStatus);
                 $publishedArticleDao->insertObject($publishedArticle);
                 // If we're using custom section ordering, and if this is the first
                 // article published in a section, make sure we enter a custom ordering
                 // for it. (Default at the end of the list.)
                 if ($sectionDao->customSectionOrderingExists($issueId)) {
                     if ($sectionDao->getCustomSectionOrder($issueId, $submission->getSectionId()) === null) {
                         $sectionDao->insertCustomSectionOrder($issueId, $submission->getSectionId(), REALLY_BIG_NUMBER);
                         $sectionDao->resequenceCustomSectionOrders($issueId);
                     }
                 }
                 // Index the published article metadata and files for the first time.
                 $articleSearchIndex->articleMetadataChanged($publishedArticle);
                 $articleSearchIndex->submissionFilesChanged($publishedArticle);
             }
         } else {
             if ($publishedArticle) {
                 // This was published elsewhere; make sure we don't
                 // mess up sequencing information.
                 $issueId = $publishedArticle->getIssueId();
                 $publishedArticleDao->deletePublishedArticleByArticleId($submission->getId());
                 // Delete the article from the search index.
                 $articleSearchIndex->submissionFileDeleted($submission->getId());
             }
         }
         if ($this->getData('attachPermissions')) {
             $submission->setCopyrightYear($this->getData('copyrightYear'));
             $submission->setCopyrightHolder($this->getData('copyrightHolder'), null);
             // Localized
             $submission->setLicenseURL($this->getData('licenseURL'));
         } else {
             $submission->setCopyrightYear(null);
             $submission->setCopyrightHolder(null, null);
             $submission->setLicenseURL(null);
         }
         // Resequence the articles.
         $publishedArticleDao->resequencePublishedArticles($submission->getSectionId(), $issueId);
         $submission->stampStatusModified();
         if ($issue && $issue->getPublished()) {
             $submission->setStatus(STATUS_PUBLISHED);
             // delete article tombstone
             $tombstoneDao = DAORegistry::getDAO('DataObjectTombstoneDAO');
             $tombstoneDao->deleteByDataObjectId($submission->getId());
         } else {
             $submission->setStatus(STATUS_QUEUED);
         }
         $articleDao->updateObject($submission);
         $articleSearchIndex->articleChangesFinished();
     }
 }
Example #12
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;
 }
 /**
  * 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');
 }
 /**
  * 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)
 {
     parent::PKPTemplateManager($request);
     // Retrieve the router
     $router =& $this->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($this->request);
         $site =& $this->request->getSite();
         $publicFileManager = new PublicFileManager();
         $siteFilesDir = $this->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($this->request->getBaseUrl() . '/' . $siteStyleFilename);
         }
         $this->assign('homeContext', array());
         $this->assign('siteCategoriesEnabled', $site->getSetting('categoriesEnabled'));
         if (isset($journal)) {
             $this->assign_by_ref('currentJournal', $journal);
             $journalTitle = $journal->getLocalizedTitle();
             $this->assign('siteTitle', $journalTitle);
             $this->assign('publicFilesDir', $this->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', $this->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($this->request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $journalStyleSheet['uploadName']);
             }
             import('classes.payment.ojs.OJSPaymentManager');
             $paymentManager = new OJSPaymentManager($this->request);
             $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());
             // Load and apply theme plugin, if chosen
             $themePluginPath = $site->getSetting('siteTheme');
             if (!empty($themePluginPath)) {
                 // Load and activate the theme
                 $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath);
                 if ($themePlugin) {
                     $themePlugin->activate($this);
                 }
             }
         }
         if (!$site->getRedirect()) {
             $this->assign('hasOtherJournals', true);
         }
         // Add java script for notifications
         $user =& $this->request->getUser();
         if ($user) {
             $this->addJavaScript('lib/pkp/js/lib/jquery/plugins/jquery.pnotify.js');
         }
     }
 }
 /**
  * Handle incoming requests/notifications
  * @param $args array
  * @param $request PKPRequest
  */
 function handle($args, $request)
 {
     $journal = $request->getJournal();
     $templateMgr = TemplateManager::getManager($request);
     $user = $request->getUser();
     $op = isset($args[0]) ? $args[0] : null;
     $queuedPaymentId = isset($args[1]) ? (int) $args[1] : 0;
     import('classes.payment.ojs.OJSPaymentManager');
     $ojsPaymentManager = new OJSPaymentManager($request);
     $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('lib.pkp.classes.mail.MailTemplate');
             AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON);
             $contactName = $journal->getSetting('contactName');
             $contactEmail = $journal->getSetting('contactEmail');
             $mail = new MailTemplate('MANUAL_PAYMENT_NOTIFICATION');
             $mail->setReplyTo(null);
             $mail->addRecipient($contactEmail, $contactName);
             $mail->assignParams(array('journalName' => $journal->getLocalizedName(), 'userFullName' => $user ? $user->getFullName() : '(' . __('common.none') . ')', 'userName' => $user ? $user->getUsername() : '(' . __('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;
     }
     parent::handle($args, $request);
     // Don't know what to do with it
 }
 /**
  * Save subscription policies for the current journal.
  * @param $args array
  * @param $request PKPRequest
  */
 function saveSubscriptionPolicies($args, &$request)
 {
     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 = new OJSPaymentManager($request);
     $templateMgr->assign('acceptSubscriptionPayments', $paymentManager->acceptSubscriptionPayments());
     if ($subscriptionPolicyForm->validate()) {
         $subscriptionPolicyForm->execute();
         $templateMgr->assign('subscriptionPoliciesSaved', '1');
         $subscriptionPolicyForm->display();
     } else {
         $subscriptionPolicyForm->display();
     }
 }
Example #17
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);
     }
 }
 /**
  * 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);
 }
 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));
     }
 }
Example #20
0
 /**
  * Constructor.
  * Initialize template engine and assign basic template variables.
  * @param $request PKPRequest
  */
 function TemplateManager($request)
 {
     parent::PKPTemplateManager($request);
     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).
          */
         $context = $request->getContext();
         $site = $request->getSite();
         $publicFileManager = new PublicFileManager();
         $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, STYLE_SEQUENCE_LAST);
         }
         $this->assign('siteCategoriesEnabled', $site->getSetting('categoriesEnabled'));
         if (isset($context)) {
             $this->assign('currentJournal', $context);
             $this->assign('siteTitle', $context->getLocalizedName());
             $this->assign('publicFilesDir', $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId()));
             $this->assign('primaryLocale', $context->getPrimaryLocale());
             $this->assign('alternateLocales', $context->getSetting('alternateLocales'));
             // Assign page header
             $this->assign('displayPageHeaderTitle', $context->getLocalizedPageHeaderTitle());
             $this->assign('displayPageHeaderLogo', $context->getLocalizedPageHeaderLogo());
             $this->assign('displayPageHeaderLogoAltText', $context->getLocalizedSetting('pageHeaderLogoImageAltText'));
             $this->assign('displayFavicon', $context->getLocalizedFavicon());
             $this->assign('faviconDir', $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId()));
             $this->assign('metaSearchDescription', $context->getLocalizedSetting('searchDescription'));
             $this->assign('metaSearchKeywords', $context->getLocalizedSetting('searchKeywords'));
             $this->assign('metaCustomHeaders', $context->getLocalizedSetting('customHeaders'));
             $this->assign('numPageLinks', $context->getSetting('numPageLinks'));
             $this->assign('itemsPerPage', $context->getSetting('itemsPerPage'));
             $this->assign('enableAnnouncements', $context->getSetting('enableAnnouncements'));
             $this->assign('contextSettings', $context->getSettingsDAO()->getSettings($context->getId()));
             // Assign stylesheets and footer
             $contextStyleSheet = $context->getSetting('journalStyleSheet');
             if ($contextStyleSheet) {
                 $this->addStyleSheet($request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId()) . '/' . $contextStyleSheet['uploadName'], STYLE_SEQUENCE_LAST);
             }
             // Get a link to the settings page for the current context.
             // This allows us to reduce template duplication by using this
             // variable in templates/common/header.tpl, instead of
             // reproducing a lot of OMP/OJS-specific logic there.
             $router = $request->getRouter();
             $dispatcher = $request->getDispatcher();
             $this->assign('contextSettingsUrl', $dispatcher->url($request, ROUTE_PAGE, null, 'management', 'settings', 'journal'));
             import('classes.payment.ojs.OJSPaymentManager');
             $paymentManager = new OJSPaymentManager($request);
             $this->assign('journalPaymentsEnabled', $paymentManager->isConfigured());
             $this->assign('pageFooter', $context->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());
             $this->assign('primaryLocale', $site->getPrimaryLocale());
         }
     }
 }
Example #21
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);
     }
 }
Example #22
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);
 }
 /**
  * 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);
 }
Example #24
0
 /**
  * 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');
 }
 /**
  * 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
 }
Example #26
0
 function payMembership($args)
 {
     UserHandler::validate();
     UserHandler::setupTemplate();
     import('payment.ojs.OJSPaymentManager');
     $paymentManager =& OJSPaymentManager::getManager();
     $journal =& Request::getJournal();
     $user =& Request::getUser();
     $queuedPayment =& $paymentManager->createQueuedPayment($journal->getJournalId(), PAYMENT_TYPE_MEMBERSHIP, $user->getUserId(), null, $journal->getSetting('membershipFee'));
     $queuedPaymentId = $paymentManager->queuePayment($queuedPayment);
     $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment);
 }
Example #27
0
 /**
  * Pay for a membership.
  * @param $args array
  * @param $request PKPRequest
  */
 function payMembership($args, $request)
 {
     $this->validate();
     $this->setupTemplate($request);
     import('classes.payment.ojs.OJSPaymentManager');
     $paymentManager = new OJSPaymentManager($request);
     $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);
 }
Example #28
0
 /**
  * Constructor.
  * Initialize template engine and assign basic template variables.
  * @param $request PKPRequest
  */
 function TemplateManager($request)
 {
     parent::PKPTemplateManager($request);
     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).
          */
         $context = $request->getContext();
         $site = $request->getSite();
         $publicFileManager = new PublicFileManager();
         $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, STYLE_SEQUENCE_LAST);
         }
         $this->assign('siteCategoriesEnabled', $site->getSetting('categoriesEnabled'));
         if (isset($context)) {
             $this->assign('currentJournal', $context);
             $this->assign('siteTitle', $context->getLocalizedName());
             $this->assign('publicFilesDir', $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId()));
             $this->assign('primaryLocale', $context->getPrimaryLocale());
             $this->assign('alternateLocales', $context->getSetting('alternateLocales'));
             // Assign page header
             $this->assign('displayPageHeaderTitle', $context->getLocalizedPageHeaderTitle());
             $this->assign('displayPageHeaderLogo', $context->getLocalizedPageHeaderLogo());
             $this->assign('displayPageHeaderTitleAltText', $context->getLocalizedSetting('pageHeaderTitleImageAltText'));
             $this->assign('displayPageHeaderLogoAltText', $context->getLocalizedSetting('pageHeaderLogoImageAltText'));
             $this->assign('displayFavicon', $context->getLocalizedFavicon());
             $this->assign('faviconDir', $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId()));
             $this->assign('alternatePageHeader', $context->getLocalizedSetting('journalPageHeader'));
             $this->assign('metaSearchDescription', $context->getLocalizedSetting('searchDescription'));
             $this->assign('metaSearchKeywords', $context->getLocalizedSetting('searchKeywords'));
             $this->assign('metaCustomHeaders', $context->getLocalizedSetting('customHeaders'));
             $this->assign('numPageLinks', $context->getSetting('numPageLinks'));
             $this->assign('itemsPerPage', $context->getSetting('itemsPerPage'));
             $this->assign('enableAnnouncements', $context->getSetting('enableAnnouncements'));
             // Assign stylesheets and footer
             $contextStyleSheet = $context->getSetting('journalStyleSheet');
             if ($contextStyleSheet) {
                 $this->addStyleSheet($request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId()) . '/' . $contextStyleSheet['uploadName'], STYLE_SEQUENCE_LAST);
             }
             import('classes.payment.ojs.OJSPaymentManager');
             $paymentManager = new OJSPaymentManager($request);
             $this->assign('journalPaymentsEnabled', $paymentManager->isConfigured());
             // Include footer links if they have been defined.
             $footerCategoryDao = DAORegistry::getDAO('FooterCategoryDAO');
             $footerCategories = $footerCategoryDao->getNotEmptyByContextId($context->getId());
             $this->assign('footerCategories', $footerCategories->toArray());
             $footerLinkDao = DAORegistry::getDAO('FooterLinkDAO');
             $this->assign('maxLinks', $footerLinkDao->getLargestCategoryTotalbyContextId($context->getId()));
             $this->assign('pageFooter', $context->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());
             $this->assign('primaryLocale', $site->getPrimaryLocale());
         }
     }
 }
 /**
  * Create institutional subscription. 
  */
 function execute()
 {
     $journal = $this->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.InstitutionalSubscription');
         $subscription = new InstitutionalSubscription();
         $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 = new OJSPaymentManager($this->request);
     $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);
     $subscription->setInstitutionName($this->getData('institutionName'));
     $subscription->setInstitutionMailingAddress($this->getData('institutionMailingAddress'));
     $subscription->setDomain($this->getData('domain'));
     $subscription->setIPRanges($this->getData('ipRanges'));
     $institutionalSubscriptionDao = DAORegistry::getDAO('InstitutionalSubscriptionDAO');
     if ($insert) {
         $institutionalSubscriptionDao->insertSubscription($subscription);
     } else {
         $institutionalSubscriptionDao->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);
 }
 /**
  * Returns an array of information on the journal's subscription settings
  * @return array
  */
 function getSubscriptionSettings(&$request)
 {
     $journal = $request->getJournal();
     if (!$journal) {
         return array();
     }
     import('classes.payment.ojs.OJSPaymentManager');
     $paymentManager = new OJSPaymentManager($request);
     $settings = array('subscriptionsEnabled' => $paymentManager->acceptSubscriptionPayments(), 'allowRegReviewer' => $journal->getSetting('allowRegReviewer'), 'allowRegAuthor' => $journal->getSetting('allowRegAuthor'));
     return $settings;
 }