我正在开发一个Joomla!1.5扩展有两种类型的注册用户,每一种都可以访问他们的特定内容。
我已经做了很多关于利用Joomla ACL实现来实现这一点的阅读。我知道它是基于phpacl的。
我正在寻求任何指导或建议,如果我打算做的是正确的方法。
假设我的扩展名为"教室"。
假设我有两个用户类型:"student"answers"teacher"
都是注册用户。
"student"可以访问"ebooks"teacher"可以访问"classregister"
我假设我使用访问扩展对象来扩展访问控制对象。
$extACL = & JFactory::getACL();
//define permissions for teacher
$extACL->_mos_add_acl('com_classroom','accessdata','users','registered','usersection','classregister');
//define permissions for student
$extACL->_mos_add_acl('com_classroom','accessdata','users','registered','usersection','ebooks');
然后根据需要,我可以使用下面的
检查"电子书"区域的权限(例如)//After checking if it is the right user
$user = & JFactory->getUser();
if(! $user->authorize('com_classroom','accessdata','usersection','ebooks'))
{
JError::raiseError('403',JText::_('You are not logged in as a student'));
}
我明白Joomla的正确用法了吗?ACL为我的扩展或它是错误的?或者我必须定义我自己的访问控制。
希望我说得有意义。
谢谢你的时间!
我同意udjamaflip的观点。Joomla 1.5已经过时了,在1.6和1.7中可以很容易地完成您正在寻找的功能。为什么要重新发明轮子呢?