
Extensions
The following extensions are available:
Client client
getPls— get client datagetClientEmails— get client emailgetManagerEmails— get client manager emailgetClientLang— get client languagechangeStatus— change client statuschangeSubscription— change client subscription
Content content
getPls— get content datagetClientEmails— get content emailgetManagerEmails— get content manager emailchangeStatus— change content statusgetRate— get content rategetRates— get content rates
Subscription subscription
getPls— get subscription datagetClientEmails— get subscription emailgetManagerEmails— get subscription manager emailchangeStatus— change subscription statuschangeTerm— change subscription term
Access access
getContentId— get content IDgetContentAccess— get content accessgetResourceAccess— get resource access
Examples
Create a vip client that has access to all content:
- create a vip status for client
- override the
getResourceAccessmethod to check resource access. Add a plugin for theOnMODXInitevent:
php
<?php
switch ($modx->event->name) {
case 'OnMODXInit':
/** @var PayAndSee $PayAndSee */
$corePath = $modx->getOption('payandsee_core_path', null,
$modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/payandsee/');
$PayAndSee = $modx->getService('payandsee', 'PayAndSee', $corePath . 'model/payandsee/',
array('core_path' => $corePath));
if (!$PayAndSee) {
return;
}
$PayAndSee->addExtension('access', 'getResourceAccess', function ($rid = null, $uid = null, $cache = true) use (&$modx, &$PayAndSee) {
$rid = (int)$rid;
$uid = (int)$uid;
$key = "rid_{$rid}|uid_{$uid}";
if (!$cache OR ($access = $PayAndSee->getStore('access', $key)) === false) {
// get client and if status == 4 vip allow access regardless of resource content
if ($client = $modx->user->getOne('PasClient') AND $client->get('status') == 4) {
$access = true;
} else {
$cid = $PayAndSee->getContentId($rid, 10, $cache);
$access = $PayAndSee->getContentAccess($cid, $uid, $cache);
}
$PayAndSee->addStore('access', $key, $access);
}
return $access;
});
break;
}
?>