K2 uses:
//Access check
$user = & JFactory::getUser();
if ($category->access > $user->get('aid', 0)) {
JError::raiseError( 403, JText::_("ALERTNOTAUTH") );
}
if (!$category->published || $category->trash) {
JError::raiseError( 404, JText::_("Category not found") );
}
Joomla 1.5 uses:
// Check to see if the user has access to view the full article
$aid = $user->get('aid');
if ($article->access <= $aid) {
$article->readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));;
} else {
if ( ! $aid )
{
// Redirect to login
$uri = JFactory::getURI();
$return = $uri->toString();
$url = 'index.php?option=com_user&view=login';
$url .= '&return='.base64_encode($return);;
//$url = JRoute::_($url, false);
$mainframe->redirect($url, JText::_('You must login first') );
}
else{
JError::raiseWarning( 403, JText::_('ALERTNOTAUTH') );
return;
}
}
I am using a hack a custom error.php
if ($this->error->code == '403') {
$uri = JFactory::getURI();
$return = $uri->toString();
$url = 'index.php?option=com_user&view=login';
$url .= '&return='.base64_encode($return);
header('Location:'.$url); die();
}