Skip to content

Hack: Multi-groups in Joomla and Kunena with NOIXACL

by Raween on May 17th, 2010

After a few weeks of searching, trying and debugging how to apply multi-groups to users in Joomla and in Kunena (= a forum for Joomla), I found the solution for fixing this!

After a Google-search, I found this helpful topic, but after trying, it wasn’t that good. You can only apply 2 groups to your users. Not 3 or more!

So, let’s edit the suggested code. Here’s the final code for class.kunena.php (line 913-972):

function getAllowedForums($uid = 0, $gid = 0, &$kunena_acl) {
$kunena_db = &JFactory::getDBO();
/*function _has_rights(&$kunena_acl, $gid, $access, $recurse) {

if ($gid == $access) return 1;

if ($recurse) {
$childs = $kunena_acl->get_group_children($access, 'ARO', 'RECURSE');

return (is_array($childs) and in_array($gid, $childs));
}

return 0;
}*/
function _has_rights($uid, &$kunena_acl, $gid, $access, $recurse) {
$kunena_db = &JFactory::getDBO();
$query = "SELECT id_group from #__noixacl_multigroups where id_user='{$uid}'";
$kunena_db->setQuery($query);
$rows = $kunena_db->loadObjectList();

if($rows){

foreach($rows as $row) {

if ($row->id_group == $access) return 1;
$recurse = array();

if ($recurse) {
$childs = $kunena_acl->get_group_children($access, 'ARO', 'RECURSE');

return (is_array($childs) and in_array($row->id_group, $childs));
}
}
}

if ($gid== $access) return 1;

if ($recurse) {
$childs = $kunena_acl->get_group_children($access, 'ARO', 'RECURSE');

return (is_array($childs) and in_array($gid, $childs));
}

return 0;
}
$catlist = '';
$query = "SELECT c.id, c.pub_access, c.pub_recurse, c.admin_access, c.admin_recurse, c.moderated"
. ",(m.userid IS NOT NULL) AS ismod FROM #__fb_categories c"
. " LEFT JOIN #__fb_moderation m ON c.id=m.catid AND m.userid='{$uid}' WHERE published='1'";
$kunena_db->setQuery($query);
$rows = $kunena_db->loadObjectList();
check_dberror("Unable to load category list.");

if ($rows) {

foreach($rows as $row) {

if (($gid == 24 || $gid == 25) or
($row->moderated and $row->ismod) or
($row->pub_access == 0) or
($row->pub_access == -1 and $uid > 0) or
/*($row->pub_access > 0 and _has_rights($kunena_acl, $gid, $row->pub_access, $row->pub_recurse)) or
($row->admin_access > 0 and _has_rights($kunena_acl, $gid, $row->admin_access, $row->admin_recurse))*/
($row->pub_access > 0 and _has_rights($uid, $kunena_acl, $gid, $row->pub_access, $row->pub_recurse)) or
($row->admin_access > 0 and _has_rights($uid, $kunena_acl, $gid, $row->admin_access, $row->admin_recurse))
) $catlist .= (($catlist == '')?'':',').$row->id;
}
}

return $catlist;
}
} // end of class

After this, you should clear the user-cache of the Kunena forum in the settings:

Clear user-cache in Kunena

To bad nor Joomla 1.5.15, nor Kunena or nor the combination NOIXACL-Kunena-Joomla can do this automatically… Hopefully things will change with Joomla 1.6!

Stem of voeg toe aanUitleg over het gebruik van deze icons :  Plaatsen/stemmen op NUjij Plaatsen/stemmen op eKudos Plaatsen/stemmen op MSN Reporter Plaatsen/stemmen op Digg Toevoegen aan Symbaloo Stumble it! Voeg dit artikel toe aan Del.icio.us Voeg toe aan je Google bladwijzers Abonneer je op de RSS-feed van deze site

From → Tech

2 Comments
  1. Few weeks of searching? I switched to Agora Olympus and I have that by default. Also many other features which i can’t find in Kunena.

  2. You are right, this is much easier!
    But, my other components/plugins are using NOIXACL as well. So I can’t make the switch (anymore)… If I knew this from the beginning, Agora was definitely been chosen :-)

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS