本文整理汇总了PHP中OJSPaymentManager::membershipEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP OJSPaymentManager::membershipEnabled方法的具体用法?PHP OJSPaymentManager::membershipEnabled怎么用?PHP OJSPaymentManager::membershipEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OJSPaymentManager
的用法示例。
在下文中一共展示了OJSPaymentManager::membershipEnabled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validation
* @see lib/pkp/classes/handler/PKPHandler#validate()
* @param $request Request
* @param $issueId int
* @param $galleyId int
*/
function validate($request, $issueId = null, $galleyId = null)
{
$returner = parent::validate(null, $request);
// Validate requests that don't specify an issue or galley
if (!$issueId && !$galleyId) {
return $returner;
}
// Require an issue id to continue
if (!$issueId) {
$request->redirect(null, 'index');
}
import('classes.issue.IssueAction');
$journal =& $request->getJournal();
$journalId = $journal->getId();
$user =& $request->getUser();
$userId = $user ? $user->getId() : 0;
$issue = null;
$galley = null;
// Get the issue
$issueDao =& DAORegistry::getDAO('IssueDAO');
if ($journal->getSetting('enablePublicIssueId')) {
$issue =& $issueDao->getIssueByBestIssueId($issueId, $journalId);
} else {
$issue =& $issueDao->getIssueById((int) $issueId, null, true);
}
// Invalid issue id, redirect to current issue
if (!$issue || !$this->_isVisibleIssue($issue, $journalId)) {
$request->redirect(null, null, 'current');
}
$this->setIssue($issue);
// If no issue galley id provided, then we're done
if (!$galleyId) {
return true;
}
// Get the issue galley
$galleyDao =& DAORegistry::getDAO('IssueGalleyDAO');
if ($journal->getSetting('enablePublicGalleyId')) {
$galley =& $galleyDao->getGalleyByBestGalleyId($galleyId, $issue->getId());
} else {
$galley =& $galleyDao->getGalley($galleyId, $issue->getId());
}
// Invalid galley id, redirect to issue page
if (!$galley) {
$request->redirect(null, null, 'view', $issueId);
}
$this->setGalley($galley);
// If this is an editorial user who can view unpublished issue galleys,
// bypass further validation
if (IssueAction::allowedIssuePrePublicationAccess($journal)) {
return true;
}
// Ensure reader has rights to view the issue galley
if ($issue->getPublished()) {
$subscriptionRequired = IssueAction::subscriptionRequired($issue);
$isSubscribedDomain = IssueAction::subscribedDomain($journal, $issueId);
// Check if login is required for viewing.
if (!$isSubscribedDomain && !Validation::isLoggedIn() && $journal->getSetting('restrictArticleAccess')) {
Validation::redirectLogin();
}
// If no domain/ip subscription, check if user has a valid subscription
// or if the user has previously purchased the issue
if (!$isSubscribedDomain && $subscriptionRequired) {
// Check if user has a valid subscription
$subscribedUser = IssueAction::subscribedUser($journal, $issueId);
if (!$subscribedUser) {
// Check if payments are enabled,
import('classes.payment.ojs.OJSPaymentManager');
$paymentManager = new OJSPaymentManager($request);
if ($paymentManager->purchaseIssueEnabled() || $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() && !$galley->isPdfGalley()) {
return true;
}
if (!Validation::isLoggedIn()) {
Validation::redirectLogin("payment.loginRequired.forIssue");
}
// If the issue galley has been purchased, then allow reader access
$completedPaymentDao =& DAORegistry::getDAO('OJSCompletedPaymentDAO');
$dateEndMembership = $user->getSetting('dateEndMembership', 0);
if ($completedPaymentDao->hasPaidPurchaseIssue($userId, $issueId) || !is_null($dateEndMembership) && $dateEndMembership > time()) {
return true;
} else {
// Otherwise queue an issue purchase payment and display payment form
$queuedPayment =& $paymentManager->createQueuedPayment($journalId, PAYMENT_TYPE_PURCHASE_ISSUE, $userId, $issueId, $journal->getSetting('purchaseIssueFee'));
$queuedPaymentId = $paymentManager->queuePayment($queuedPayment);
$templateMgr =& TemplateManager::getManager();
$paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment);
exit;
}
}
if (!Validation::isLoggedIn()) {
Validation::redirectLogin("reader.subscriptionRequiredLoginText");
//.........这里部分代码省略.........
示例2: userCanViewGalley
/**
* 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;
}
示例3: userCanViewGalley
/**
* Determines whether or not a user can view an issue galley.
* @param $request Request
*/
function userCanViewGalley($request)
{
import('classes.issue.IssueAction');
$issueAction = new IssueAction();
$journal = $request->getJournal();
$user = $request->getUser();
$userId = $user ? $user->getId() : 0;
$issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
$galley = $this->getGalley();
// If this is an editorial user who can view unpublished issue galleys,
// bypass further validation
if ($issueAction->allowedIssuePrePublicationAccess($journal)) {
return true;
}
// Ensure reader has rights to view the issue galley
if ($issue->getPublished()) {
$subscriptionRequired = $issueAction->subscriptionRequired($issue);
$isSubscribedDomain = $issueAction->subscribedDomain($journal, $issue->getId());
// Check if login is required for viewing.
if (!$isSubscribedDomain && !Validation::isLoggedIn() && $journal->getSetting('restrictArticleAccess')) {
Validation::redirectLogin();
}
// If no domain/ip subscription, check if user has a valid subscription
// or if the user has previously purchased the issue
if (!$isSubscribedDomain && $subscriptionRequired) {
// Check if user has a valid subscription
$subscribedUser = $issueAction->subscribedUser($journal, $issue->getId());
if (!$subscribedUser) {
// Check if payments are enabled,
import('classes.payment.ojs.OJSPaymentManager');
$paymentManager = new OJSPaymentManager($request);
if ($paymentManager->purchaseIssueEnabled() || $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() && !$galley->isPdfGalley()) {
return true;
}
if (!Validation::isLoggedIn()) {
Validation::redirectLogin("payment.loginRequired.forIssue");
}
// If the issue galley has been purchased, then allow reader access
$completedPaymentDao = DAORegistry::getDAO('OJSCompletedPaymentDAO');
$dateEndMembership = $user->getSetting('dateEndMembership', 0);
if ($completedPaymentDao->hasPaidPurchaseIssue($userId, $issue->getId()) || !is_null($dateEndMembership) && $dateEndMembership > time()) {
return true;
} else {
// Otherwise queue an issue purchase payment and display payment form
$queuedPayment =& $paymentManager->createQueuedPayment($journal->getId(), PAYMENT_TYPE_PURCHASE_ISSUE, $userId, $issue->getId(), $journal->getSetting('purchaseIssueFee'));
$queuedPaymentId = $paymentManager->queuePayment($queuedPayment);
$paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment);
exit;
}
}
if (!Validation::isLoggedIn()) {
Validation::redirectLogin("reader.subscriptionRequiredLoginText");
}
$request->redirect(null, 'about', 'subscriptions');
}
}
} else {
$request->redirect(null, 'index');
}
return true;
}
示例4: index
/**
* Display user index page.
* @param $args array
* @param $request PKPRequest
*/
function index($args, &$request)
{
$this->validate();
$sessionManager =& SessionManager::getManager();
$session =& $sessionManager->getUserSession();
$roleDao =& DAORegistry::getDAO('RoleDAO');
$this->setupTemplate($request);
$templateMgr =& TemplateManager::getManager();
$journal =& $request->getJournal();
$templateMgr->assign('helpTopicId', 'user.userHome');
$user =& $request->getUser();
$userId = $user->getId();
$setupIncomplete = array();
$submissionsCount = array();
$isValid = array();
if ($journal == null) {
// Curently at site level
unset($journal);
// Show roles for all journals
$journalDao =& DAORegistry::getDAO('JournalDAO');
$journals =& $journalDao->getJournals();
// Fetch the user's roles for each journal
while ($journal =& $journals->next()) {
$journalId = $journal->getId();
// Determine if journal setup is incomplete, to provide a message for JM
$setupIncomplete[$journalId] = $this->_checkIncompleteSetup($journal);
$roles =& $roleDao->getRolesByUserId($userId, $journalId);
if (!empty($roles)) {
$userJournals[] =& $journal;
$this->_getRoleDataForJournal($userId, $journalId, $submissionsCount, $isValid);
}
unset($journal);
}
$templateMgr->assign_by_ref('userJournals', $userJournals);
$templateMgr->assign('showAllJournals', 1);
$allJournals =& $journalDao->getJournals();
$templateMgr->assign_by_ref('allJournals', $allJournals->toArray());
} else {
// Currently within a journal's context.
$journalId = $journal->getId();
// Determine if journal setup is incomplete, to provide a message for JM
$setupIncomplete[$journalId] = $this->_checkIncompleteSetup($journal);
$userJournals = array($journal);
$this->_getRoleDataForJournal($userId, $journalId, $submissionsCount, $isValid);
$subscriptionTypeDao =& DAORegistry::getDAO('SubscriptionTypeDAO');
$subscriptionsEnabled = $journal->getSetting('publishingMode') == PUBLISHING_MODE_SUBSCRIPTION && ($subscriptionTypeDao->subscriptionTypesExistByInstitutional($journalId, false) || $subscriptionTypeDao->subscriptionTypesExistByInstitutional($journalId, true)) ? true : false;
$templateMgr->assign('subscriptionsEnabled', $subscriptionsEnabled);
import('classes.payment.ojs.OJSPaymentManager');
$paymentManager = new OJSPaymentManager($request);
$acceptGiftPayments = $paymentManager->acceptGiftPayments();
$templateMgr->assign('acceptGiftPayments', $acceptGiftPayments);
$membershipEnabled = $paymentManager->membershipEnabled();
$templateMgr->assign('membershipEnabled', $membershipEnabled);
if ($membershipEnabled) {
$templateMgr->assign('dateEndMembership', $user->getSetting('dateEndMembership', 0));
}
$templateMgr->assign('allowRegAuthor', $journal->getSetting('allowRegAuthor'));
$templateMgr->assign('allowRegReviewer', $journal->getSetting('allowRegReviewer'));
$templateMgr->assign_by_ref('userJournals', $userJournals);
}
$templateMgr->assign('isValid', $isValid);
$templateMgr->assign('submissionsCount', $submissionsCount);
$templateMgr->assign('setupIncomplete', $setupIncomplete);
$templateMgr->assign('isSiteAdmin', $roleDao->getRole(0, $userId, ROLE_ID_SITE_ADMIN));
$templateMgr->display('user/index.tpl');
}
示例5: memberships
/**
* Display subscriptions page.
* @param $args array
* @param $request PKPRequest
*/
function memberships($args, &$request)
{
$this->addCheck(new HandlerValidatorJournal($this));
$this->validate();
$this->setupTemplate(true);
$journal =& Request::getJournal();
$journalId = $journal->getId();
import('classes.payment.ojs.OJSPaymentManager');
$paymentManager = new OJSPaymentManager($request);
$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');
}