示例#1
0
文件: helper.php 项目: JozefAB/qk
 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);
     }
 }
示例#2
0
 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);
     }
 }