Hi guys,
I'm using Kunena for quite a while now but always missed a more complex and detailed option to control user permissions.
Then I discovered this thread:
www.kunena.com/forum/114-hacks/9208-rest...it=10&start=60#22824
Well, so far, control works just fine, but unfortunately Kunena just supports usergroups assigned directly in Joomla's user admin.
As you can assign users to multiple groups in control, I thought of a solution to implement this into Kunena. So, I started with a very basic script that:
1. matches joomla user id to control user id
2. collects group ids a user was assigned to in control
3. checks if a certain usergroup is assigned to a specific user and returns true or false
Basically this works pretty fine as a standalone script. I now tried to adapt this into the kunena permissions script which did not work out, yet. I assume the error is within the groupid and userid used in the permissions but I could not figure out how to solve this, yet.
Here is the Script:
Code:
include("db_connect.php");
$userid = $_GET["id"];
$groupid = $_GET["g"];
$req = "SELECT * FROM `#___core_acl_aro` WHERE value = '$userid'";
$res = mysql_query($req) OR die(mysql_error());
while($row = mysql_fetch_object($res))
{
$usrid = $row->id;
}
$sql = "SELECT * FROM `#___core_acl_groups_aro_map` WHERE `aro_id` = '$usrid'";
$result = mysql_query($sql) OR die(mysql_error());
$data = array();
while($row=mysql_fetch_row($result))
{
$data[]=$row[0];
}
if ( in_array($groupid,$data) ){
//user is in here; let pass
return 1;
}
else {
return 0;
}
Of course, the get values have been removed for using it in kunena but it was handy to check it standalone
Now I tried to implement it into kunena permissions, right before the usual group permission check. The idea is:
a. kunena checks the control assigned user groups
b. if there is no match, it checks the groups in joomla_user_db
c. if still there is no match, it continues checking for mod/admin access.
Now, I hope you got it and maybe some of you have an idea how to make this work within Kunena?!
Thanks a lot.