简体   繁体   中英

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

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM