开发者

Using Joomla 1.5 ACL for custom extension content - is this the right way?

开发者 https://www.devze.com 2023-03-31 13:05 出处:网络
I 开发者_开发百科am developing a Joomla! 1.5 extention that has two types of registered users, each with access to their particular content.

I 开发者_开发百科am developing a Joomla! 1.5 extention that has two types of registered users, each with access to their particular content.

I have done alot of reading on utilising the Joomla ACL implementation to achieve this. I understand that it is based on phpGACL.

I am seeking any guidance or advice if what I intend to do is the right approach.

Suppose my extension is called "classroom".

Suppose I have user types: "student" and "teacher"

Both are registered users.

"student" has access to "ebooks" "teacher" has access to "classregister"

i assume that I use Access Extension Objects that will extend the Access Control Objects.

$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');

Then as need arises, I can check permissions for (say) the "ebooks" area using the following

//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'));
}

Have I understood the right use of the Joomla! ACL for my extension or is it wrong? Or will I have to define my own access controls.

Hope I made sense.

Thanks for your time!


I agree with udjamaflip. Joomla 1.5 is outdated, and what you're looking for can easily be done in 1.6 and 1.7. Why re-invent the wheel?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号