public static function checkContent(&$has_access, &$found_shared, &$redirect, $memberships, $extras) { // Get the database object $db = JFactory::getDBO(); $query = $db->getQuery(true); $shared = RSMembershipHelper::getShared(array('article', 'category')); $view = JFactory::getApplication()->input->get('view', '', 'cmd'); $id = JFactory::getApplication()->input->get('id', 0, 'int'); if ($view == 'article') { $categories = RSMembershipHelper::_getItemCategories($id); foreach ($shared as $share) { $what = isset($share->membership_id) ? 'membership_id' : 'extra_value_id'; $where = isset($share->membership_id) ? $memberships : $extras; $table = isset($share->membership_id) ? '#__rsmembership_memberships' : '#__rsmembership_extra_values'; if ($share->type == 'article' && $share->params == $id || $share->type == 'category' && in_array($share->params, $categories)) { $found_shared = true; // Found a membership that shares this article if (!empty($where) && in_array($share->{$what}, $where)) { $has_access = true; break; } else { // Get the redirect page $query->clear(); $query->select($db->qn('share_redirect'))->from($db->qn($table))->where($db->qn('id') . ' = ' . $db->q($share->{$what})); $db->setQuery($query); $redirect = $db->loadResult(); } } } } elseif ($view == 'category') { $categories = RSMembershipHelper::_getCategoryParents($id); array_push($categories, $id); foreach ($shared as $share) { $what = isset($share->membership_id) ? 'membership_id' : 'extra_value_id'; $where = isset($share->membership_id) ? $memberships : $extras; $table = isset($share->membership_id) ? '#__rsmembership_memberships' : '#__rsmembership_extra_values'; if ($share->type == 'category' && in_array($share->params, $categories)) { $found_shared = true; // Found a membership that shares this article if (!empty($where) && in_array($share->{$what}, $where)) { $has_access = true; break; } else { // Get the redirect page $query->clear(); $query->select($db->qn('share_redirect'))->from($db->qn($table))->where($db->qn('id') . ' = ' . $db->q($share->{$what})); $db->setQuery($query); $redirect = $db->loadResult(); } } } } }
function checkContentJ16(&$has_access, &$found_shared, &$redirect, $memberships, $extras) { // Get the database object $db =& JFactory::getDBO(); $shared = RSMembershipHelper::getShared(array('article', 'category')); $view = JRequest::getVar('view'); $id = JRequest::getInt('id'); if ($view == 'article') { $categories = RSMembershipHelper::_getItemCategories($id); foreach ($shared as $share) { $what = isset($share->membership_id) ? 'membership_id' : 'extra_value_id'; $where = isset($share->membership_id) ? $memberships : $extras; $table = isset($share->membership_id) ? '#__rsmembership_memberships' : '#__rsmembership_extra_values'; if ($share->type == 'article' && $share->params == $id || $share->type == 'category' && in_array($share->params, $categories)) { $found_shared = true; // Found a membership that shares this article if (!empty($where) && in_array($share->{$what}, $where)) { $has_access = true; break; } else { // Get the redirect page $db->setQuery("SELECT `share_redirect` FROM " . $table . " WHERE `id`='" . $share->{$what} . "'"); $redirect = $db->loadResult(); } } } } elseif ($view == 'category') { $categories = RSMembershipHelper::_getCategoryParents($id); array_push($categories, $id); foreach ($shared as $share) { $what = isset($share->membership_id) ? 'membership_id' : 'extra_value_id'; $where = isset($share->membership_id) ? $memberships : $extras; $table = isset($share->membership_id) ? '#__rsmembership_memberships' : '#__rsmembership_extra_values'; if ($share->type == 'category' && in_array($share->params, $categories)) { $found_shared = true; // Found a membership that shares this article if (!empty($where) && in_array($share->{$what}, $where)) { $has_access = true; break; } else { // Get the redirect page $db->setQuery("SELECT `share_redirect` FROM " . $table . " WHERE `id`='" . $share->{$what} . "'"); $redirect = $db->loadResult(); } } } } }