今天记录3c之家 兰州短租公寓建设过程中遇到的一点小问题。由于网站需要,找了个会员积分系统来用用,AlphaUserPoints,总体感觉很是不错,先来看看后台
还可以吧?功能很是强大。
于是,我新建了一个菜单->会员中心,指向了AlphaUserPoints的个人页面,然而在前台点击后问题出现了,错误提示:您没有权限观看此页面;是啊,没有登录。可是想想这样的话会员肯定会不高兴的,最起码让网页直接能跳转到登录页面呢。好,开始分析源代码,下面是此组件的文件列表
我们来看看控制器,
class alphauserpointsController extends JController
{
function display() {
parent::display();
}
}
里面没有东西,进controllers文件夹看看:
有这几个文件,分析url:http://3c-home.com/index.php?option=com_alphauserpoints&view=account&Itemid=103
可知此应该使用的是account视图,对于的也就是account控制器,打开文件查看display函数部分
function display ()
{
$app = JFactory::getApplication();
require_once (JPATH_ROOT.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php');
$com_params = JComponentHelper::getParams( 'com_alphauserpoints' );
$model = &$this->getModel ( 'alphauserpoints' );
$view = $this->getView ( 'account','html' );
// current user
$user = JFactory::getUser();
// profil request
$userid = JRequest::getVar( 'userid', '', 'default', 'string' );
if ( !$user->id && !$com_params->get( 'allowGuestUserViewProfil', 1 ) ) {
$msg = JText::_('ALERTNOTAUTH' );
$app->redirect('index.php', $msg);
} 这段代码就是检测是否有用户登录,如果没有用户登录就跳转到首页,并显示错误消息$msg.
/