We are developing a feature that needs to be ONLY available to paid subscribers on a journal. To that end, we need to figure out how to validate if a used is actually a paid user, a comp user like a board member, etc. Below is a technical “sketch” of what may be needed. Is there someone skilled who can tell me if this makes sense? Or, is there a more well defined way to execute what we are trying to do. Thanks!
“OJS subscriptions are a bit nuanced (individual vs institutional, IP ranges, expiry, etc.). The “right” way is to consult the subscription DAOs and/or the access policy OJS uses to decide subscription access for paywalled content. That typically involves checking individual and institutional subscriptions for the current user within the current journal context and ensuring they’re active (not expired).”
At a high level (pseudocode-ish):
import('classes.subscription.IndividualSubscriptionDAO');
import('classes.subscription.InstitutionalSubscriptionDAO');
$journal = $request->getContext();
$journalId = $journal ? (int)$journal->getId() : 0;
$ok = false;
// 1) Individual subscription
$indDao = DAORegistry::getDAO('IndividualSubscriptionDAO');
if ($indDao && $indDao->isValidIndividualSubscription($user->getId(), $journalId)) {
$ok = true;
}
// 2) Institutional subscription (based on user's affiliation/IP)
// You may need to pass the request IP and/or user’s affiliation to a helper
$instDao = DAORegistry::getDAO('InstitutionalSubscriptionDAO');
if (!$ok && $instDao && $instDao->isValidInstitutionalSubscriptionByIP($journalId, $request->getRemoteAddr())) {
$ok = true;
}
if (!$ok) {
return new JSONMessage(false, '<div class="pkpNotification">A current subscription is required.</div>');
}