简体   繁体   English

将Joomla 1.5 ACL用于自定义扩展内容-这是正确的方法吗?

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

I am developing a Joomla! 我正在开发Joomla! 1.5 extention that has two types of registered users, each with access to their particular content. 1.5扩展具有两种类型的注册用户,每种用户都可以访问其特定内容。

I have done alot of reading on utilising the Joomla ACL implementation to achieve this. 我已经阅读了很多有关使用Joomla ACL实现来实现这一目标的内容。 I understand that it is based on phpGACL. 我了解它基于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" “学生”有权访问“电子书”“教师”有权访问“ 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! 我了解Joomla的正确用法! ACL for my extension or is it wrong? 我的扩展程序的ACL还是错? Or will I have to define my own access controls. 还是我必须定义自己的访问控制。

Hope I made sense. 希望我有道理。

Thanks for your time! 谢谢你的时间!

I agree with udjamaflip. 我同意udjamaflip。 Joomla 1.5 is outdated, and what you're looking for can easily be done in 1.6 and 1.7. Joomla 1.5已过时,您正在寻找的内容可以在1.6和1.7中轻松完成。 Why re-invent the wheel? 为什么要重新发明轮子?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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