当前位置: 首页>>代码示例>>PHP>>正文


PHP RSMembershipHelper::getUserSubscriptions方法代码示例

本文整理汇总了PHP中RSMembershipHelper::getUserSubscriptions方法的典型用法代码示例。如果您正苦于以下问题:PHP RSMembershipHelper::getUserSubscriptions方法的具体用法?PHP RSMembershipHelper::getUserSubscriptions怎么用?PHP RSMembershipHelper::getUserSubscriptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RSMembershipHelper的用法示例。


在下文中一共展示了RSMembershipHelper::getUserSubscriptions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onAfterRender

 public function onAfterRender()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     if ($app->isAdmin() || !class_exists('RSMembershipHelper')) {
         return;
     }
     $body = JResponse::getBody();
     if (strpos($body, '{rsmembership-subscribe') !== false) {
         $pattern = '#\\{rsmembership-subscribe ([0-9]+)\\}#i';
         if (preg_match_all($pattern, $body, $matches)) {
             $find = array();
             $replace = array();
             foreach ($matches[1] as $i => $membership_id) {
                 $membership_id = (int) $membership_id;
                 $query = $db->getQuery(true);
                 $query->select($db->qn('id') . ', ' . $db->qn('name'))->from($db->qn('#__rsmembership_memberships'))->where($db->qn('published') . ' = ' . $db->q(1))->where($db->qn('id') . ' = ' . $db->q($membership_id));
                 $db->setQuery($query);
                 if ($membership = $db->loadObject()) {
                     $find[] = $matches[0][$i];
                     $replace[] = JRoute::_('index.php?option=com_rsmembership&task=subscribe&cid=' . $membership_id . ':' . JFilterOutput::stringURLSafe($membership->name));
                 }
             }
             $body = str_replace($find, $replace, $body);
             JResponse::setBody($body);
         }
     }
     if (strpos($body, '{rsmembership ') !== false) {
         $pattern = '#\\{rsmembership (id|category)="([0-9,\\s]+)"\\}(.*?){/rsmembership}#is';
         if (preg_match_all($pattern, $body, $matches)) {
             $find = array();
             $replace = array();
             // Get current user's memberships and extras
             list($userMemberships, $userExtras) = RSMembershipHelper::getUserSubscriptions();
             foreach ($matches[0] as $i => $fullmatch) {
                 $type = strtolower($matches[1][$i]);
                 $values = explode(',', $matches[2][$i]);
                 $inside = $matches[3][$i];
                 $find[] = $fullmatch;
                 // Make sure we have only numbers.
                 JArrayHelper::toInteger($values);
                 // Two argument types: either membership IDs or category IDs
                 if ($type == 'id') {
                     $sharedMemberships = $values;
                 } elseif ($type == 'category') {
                     $query = $db->getQuery(true);
                     $query->select('id')->from($db->qn('#__rsmembership_memberships'))->where($db->qn('category_id') . ' IN (' . implode(',', $values) . ')');
                     $sharedMemberships = $db->setQuery($query)->loadColumn();
                 }
                 // Do we have an {else} statement?
                 if (strpos($inside, '{else}') !== false) {
                     list($inside, $other) = explode('{else}', $inside, 2);
                 } else {
                     $other = '';
                 }
                 // Does the user have the required memberships?
                 if (array_intersect($sharedMemberships, $userMemberships)) {
                     $replace[] = $inside;
                 } else {
                     $replace[] = $other;
                 }
             }
             $body = str_replace($find, $replace, $body);
             JResponse::setBody($body);
         }
     }
 }
开发者ID:JozefAB,项目名称:qk,代码行数:67,代码来源:rsmembership.php

示例2: checkShared

 public static function checkShared()
 {
     $option = RSMembershipHelper::getOption();
     if (!$option) {
         return;
     }
     $app = JFactory::getApplication();
     // Get the language
     $lang = JFactory::getLanguage();
     $lang->load('com_rsmembership');
     $msg = JText::_('COM_RSMEMBERSHIP_MEMBERSHIP_NEED_SUBSCRIPTION');
     // Get the database object
     $db = JFactory::getDBO();
     list($memberships, $extras) = RSMembershipHelper::getUserSubscriptions();
     $has_access = false;
     $found_shared = false;
     $redirect = '';
     if (!$app->isAdmin()) {
         // Check the articles, categories and sections
         if ($option == 'com_content') {
             RSMembershipHelper::checkContent($has_access, $found_shared, $redirect, $memberships, $extras);
         }
         // Menu - Itemid
         RSMembershipHelper::checkMenu($has_access, $found_shared, $redirect, $memberships, $extras);
     }
     $instances = RSMembership::getSharedContentPlugins();
     foreach ($instances as $instance) {
         if (method_exists($instance, 'checkShared')) {
             $instance->checkShared($option, $has_access, $found_shared, $redirect, $memberships, $extras);
         }
     }
     // Custom URL
     RSMembershipHelper::checkURL($has_access, $found_shared, $redirect, $memberships, $extras);
     if (!$found_shared) {
         $has_access = true;
     }
     if ($found_shared && $has_access) {
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_rsmembership/tables');
         $row = JTable::getInstance('Log', 'RSMembershipTable');
         $row->date = JFactory::getDate()->toSql();
         $row->user_id = JFactory::getUser()->get('id');
         $row->path = '[URL] ' . JUri::getInstance()->toString();
         $row->ip = $_SERVER['REMOTE_ADDR'];
         $row->store();
     }
     if (!$has_access) {
         $redirect = empty($redirect) ? JURI::root() : JRoute::_($redirect, false);
         $app->redirect($redirect, $msg);
     }
 }
开发者ID:JozefAB,项目名称:qk,代码行数:50,代码来源:helper.php

示例3: cancel

 public function cancel()
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $id = $this->user->id;
     $cid = $this->getCid();
     $transaction = JTable::getInstance('Transaction', 'RSMembershiptable');
     $transaction->load($this->_data->from_transaction_id);
     $membership = JTable::getInstance('Membership', 'RSMembershiptable');
     $membership->load($this->_data->membership_id);
     $plugins = RSMembership::getPlugins();
     // Keep a legacy mode for Authorize.net
     if (in_array($transaction->gateway, $plugins) || $transaction->gateway == 'Authorize.Net') {
         $plugin = array_search($transaction->gateway, $plugins);
         if ($plugin === false) {
             $plugin = 'rsmembershipauthorize';
         }
         $args = array('plugin' => $plugin, 'data' => &$this->_data, 'membership' => $membership, 'transaction' => &$transaction);
         JFactory::getApplication()->triggerEvent('onMembershipCancelPayment', $args);
     }
     $query->clear();
     $query->update($db->qn('#__rsmembership_membership_subscribers'))->set($db->qn('status') . ' = ' . $db->q('3'))->where($db->qn('id') . ' = ' . $db->q($cid));
     $db->setQuery($query);
     $db->execute();
     if (!is_array($membership->gid_expire)) {
         $membership->gid_expire = explode(',', $membership->gid_expire);
     }
     if ($membership->gid_enable) {
         RSMembership::updateGid($id, $membership->gid_expire, false, 'remove');
     }
     if ($membership->disable_expired_account) {
         list($memberships, $extras) = RSMembershipHelper::getUserSubscriptions($id);
         if (!$memberships) {
             RSMembership::disableUser($id);
             $app = JFactory::getApplication();
             $app->logout();
         }
     }
 }
开发者ID:JozefAB,项目名称:qk,代码行数:39,代码来源:mymembership.php

示例4: checkShared

 function checkShared()
 {
     $option = RSMembershipHelper::getOption();
     if (!$option) {
         return;
     }
     $mainframe =& JFactory::getApplication();
     // Get the language
     $lang =& JFactory::getLanguage();
     $lang->load('com_rsmembership');
     $msg = JText::_('RSM_MEMBERSHIP_NEED_SUBSCRIPTION');
     // Get the database object
     $db = JFactory::getDBO();
     list($memberships, $extras) = RSMembershipHelper::getUserSubscriptions();
     $has_access = false;
     $found_shared = false;
     $redirect = '';
     if (!$mainframe->isAdmin()) {
         // Check the articles, categories and sections
         if ($option == 'com_content') {
             RSMembershipHelper::checkContent($has_access, $found_shared, $redirect, $memberships, $extras);
         }
         // Menu - Itemid
         RSMembershipHelper::checkMenu($has_access, $found_shared, $redirect, $memberships, $extras);
     }
     $instances = RSMembership::getSharedContentPlugins();
     foreach ($instances as $instance) {
         if (method_exists($instance, 'checkShared')) {
             $instance->checkShared($option, $has_access, $found_shared, $redirect, $memberships, $extras);
         }
     }
     // Custom URL
     RSMembershipHelper::checkURL($has_access, $found_shared, $redirect, $memberships, $extras);
     if (!$found_shared) {
         $has_access = true;
     }
     if (!$has_access) {
         $redirect = empty($redirect) ? JURI::root() : JRoute::_($redirect, false);
         $mainframe->redirect($redirect, $msg);
     }
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:41,代码来源:rsmembership.php


注:本文中的RSMembershipHelper::getUserSubscriptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。