本文整理汇总了PHP中IssueAction::allowedPrePublicationAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP IssueAction::allowedPrePublicationAccess方法的具体用法?PHP IssueAction::allowedPrePublicationAccess怎么用?PHP IssueAction::allowedPrePublicationAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IssueAction
的用法示例。
在下文中一共展示了IssueAction::allowedPrePublicationAccess方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: subscribedUser
/**
* Checks if user has subscription
* @return bool
*/
function subscribedUser(&$journal, $issueId = null, $articleId = null)
{
$user =& Request::getUser();
$subscriptionDao =& DAORegistry::getDAO('SubscriptionDAO');
$result = false;
if (isset($user) && isset($journal)) {
if (IssueAction::allowedPrePublicationAccess($journal)) {
$result = true;
} else {
$result = $subscriptionDao->isValidSubscription(null, null, $user->getUserId(), $journal->getJournalId());
}
// If no valid subscription, check if there is an expired subscription
// that was valid during publication date of requested content
if (!$result && $journal->getSetting('subscriptionExpiryPartial')) {
if (isset($articleId)) {
$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
$publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($articleId);
if (isset($publishedArticle)) {
import('subscription.SubscriptionDAO');
$result = $subscriptionDao->isValidSubscription(null, null, $user->getUserId(), $journal->getJournalId(), SUBSCRIPTION_DATE_END, $publishedArticle->getDatePublished());
}
} else {
if (isset($issueId)) {
$issueDao =& DAORegistry::getDAO('IssueDAO');
$issue =& $issueDao->getIssueById($issueId);
if (isset($issue) && $issue->getPublished()) {
import('subscription.SubscriptionDAO');
$result = $subscriptionDao->isValidSubscription(null, null, $user->getUserId(), $journal->getJournalId(), SUBSCRIPTION_DATE_END, $issue->getDatePublished());
}
}
}
}
}
HookRegistry::call('IssueAction::subscribedUser', array(&$journal, &$result));
return $result;
}
示例3: validate
/**
* 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);
}