6. 检查用户权限
你可能想特定用户的才能访问你的组件,这里不讲述关于ACl的问题,仅仅是告诉读者怎么区别访客,注册用户,特别用户(作者,发布者)
Joomla 1.0中 $my 对象代表了当前用户的信息
$my→gid = 0 =? 访客
$my→gid = 1 =? 注册用户
$my→gid = 2 =? 特定用户
确保不泄露任何信息给你没有权限的用户。这样的是数据查询在1.0中可以取得用户是否具有权限
Joomla 1.0
SELECT * FROM #__contact_details AS c
LEFT JOIN #__categories AS cat ON cat.id = c.catid
WHERE ( c.name LIKE '%$text%' )
AND c.published = 1
AND cat.published = 1
AND c.access <= $my->gid
AND cat.access <= $my->gid
Joomla 1.5
// Initialize variables as example how to get the current user
$app = & $this->getApplication();
$user = & $app->getUser();
SELECT * FROM #__contact_details AS c
LEFT JOIN #__categories AS cat ON cat.id = c.catid
WHERE ( c.name LIKE '%$text%' )
AND c.published = 1
AND cat.published = 1
AND c.access <= $user->get('gid')
AND cat.access <= $user->get('gid')



