Twitter

by acls us

Joomla! 1.5 Custom Groups in Easyblog Category Access Control

 

Introduction

In this article I will explain how to use Joomla! Custom Groups to control access to EasyBlog Categories while using Joomla! 1.5 (yes that's 1.5)

Background - Joomla!, EasyBlog and NOIXACL

JoomlaThings have moved on a lot in the last couple of years in the world of Joomla! 1.5 -> 1.6 -> 1.7 ->2.5 to infinity and beyond. From my personal point of view this has been too fast, but that's just me? There are still a whole load of Joomla! 1.5.x sites out there which, for all sorts of reasons, will remain on 1.5.x for some time but would benefits from some of the features in 1.6+. One of these features is Custom Groups that allows the creation and use of more than the standard groups available in 1.5.x and the assigning of users to more that just one group. This provides site admins with much more flexibility in controlling access to resources by users.

EasyBlogEasyBlog is one of the Joomla! extensions that makes use of Joomla! Custom Groups. In Particular, when creating a Blog Category you can assign access to Groups that control viewing and posting to Blogs. Under Joomla! 1.5.x EasyBlog just displays the standard (no-custom) Groups that are already defined in the Joomla! system and nothing more. However, the good people at Stackideas support the use of Joomla! 1.6+ in the same code used to access all releases of Joomla! As Joomla! 1.6+ has Customer Groups, the EasyBlog code supports the use of Custom Groups. So it's just a matter of telling EasyBlog (by some small code modifications) to use the Custom Group support even when running in Joomla! 1.5.x and having a means to manage the Custom Groups themselves.

NOIXACLThe Joomla! extension NOIXACL (available via the Joomla! Extension Directory) can be used to manage Custom Groups in Joomla! 1.5.x. In this particular example I only use it to edit Custom Groups and assign users to multiple Groups, although there are other features in the extension, I'm not using them. Joomla! 1.5.x already has some constructs in place to support Custom Groups, the Groups themselves are held in the 'jos_core_acl_aro_groups' table and NOIXACL can be used to edit the contents of this table and add new entries. NOIXACL also extents the normal admin back-end Joomla! user manager to include the ability to assign users to Custom Groups.

Fitting it All together

Start by installing NOIXACL (I'm using 2.06 Beta) on Joomla! (I'm using 1.5.23). This added the "Access Control" option to trhe "Components" menu in the Joomla! Admin Back-End. Here you can create your new Custom Groups. Then goto the Joomal! "User Manager", select a User and you will see the extra NOIXACL setction at the bottom of the page. Here you can assign the User to the Custom Group(s).

Next we need to made a couple of modifications to EasyBlog (I'm using 3.0.7987) code in one PHP file "/components/com_easyblog/helpers/helper.php". Remember to keep a copy of the original and modified code. If a new EasyBlog release is installed your local modifications will be lost!

Once this has been done, the new Custom Groups can be selected when setting up the access control for EasyBlog Categories.

Modifcation 1: Allows EasyBlog to "see" Custom Groups; helper.php around line 4060

// we need to filter out the ROOT and USER dummy records.
if(EasyBlogHelper::getJoomlaVersion() < '1.6')
{
$where[] = '(a.`id` > 17 AND a.`id` < 26)';
}

Change to;

// we need to filter out the ROOT and USER dummy records.
 if(EasyBlogHelper::getJoomlaVersion() < '1.6')
 {
 $where[] = '((a.`id` > 17 AND a.`id` < 26) OR a.`id` > 30)';    //  Support forCustom Groups with noixACL in Joomla 1.5
 }

 

Modifcation 2: Allows EasyBlog to "use" Custom Groups; helper.php around line 4120

if( EasyBlogHelper::getJoomlaVersion() >= '1.6' )
{
$groupIds = $user->groups;

$grpId  = array();

foreach($groupIds as $key => $val)
{
$grpId[] = $val;
}

return $grpId;
}
else
{
return array( $user->gid );

}

Change to;

if( EasyBlogHelper::getJoomlaVersion() >= '1.6' )
 {
 $groupIds = $user->groups;

$grpId  = array();

foreach($groupIds as $key => $val)
 {
 $grpId[] = $val;
 }

return $grpId;
 }
 else
 {
 // Support for Custom Groups with noixACL in Joomla 1.5
 $grps = array($user->gid);
 $db = JFactory::getDBO();
 $noixacl_query = 'select `id_group` from `#__noixacl_multigroups` where `id_user` = '.$user->id;
 $db->setQuery($noixacl_query);
 $result = $db->loadObjectList();
 foreach($result as $item)
 {
 $grps[] = $item->id_group;
 }
 return $grps;
// Support for Custom Groups with noixACL in Joomla 1.5
 }