PDA

View Full Version : how to use getpermissions()


the_sisko
03-23-2002, 08:24 PM
OK, I started a little hack which mass PM all user of a thread when its moved. I know there is a hack but I want to improve it and want to check if the forum I want to move the thread is viewable for the user.

I want to user getpermissions() function as I have the forumid and userid, but as far I tested it didn't work.

When I use this one
$userid = 58;
$forumid = 21;
$forumid=verifyid("forum",$forumid);

$access = getpermissions($forumid,$userid);
print $access[canview];
I got nothing , but when I remove the userid it works, as the function then uses my cookie.
$forumid = 21;
$forumid=verifyid("forum",$forumid);

$access = getpermissions($forumid);
print $access[canview];

How do I use this function? As I cannot use the cookie as I'm doing this as admin for many users at one time, and loop through the userid's....

the_sisko
03-24-2002, 02:30 PM
I played around with the function a little bit and still don't get it.
I thought this funczion is for checking, if a user (userid) has permission to view (canview) a specific forum (forumid).

But I tested it and it doesn't work how I thought it would.

Can anybuddy show me how to do this?

the_sisko
03-24-2002, 04:06 PM
If somebody like to know , I did it another way:
// check forum permission
$parentlist=getforumarray($forumid);
$forums=getforumlist($forumid,"forumid","OR",$parentlist);
$getperms=$DB_site->query_first("SELECT *,INSTR(',$parentlist,', CONCAT(',', forumid, ',') ) AS ordercontrol FROM forumpermission WHERE usergroupid=$user[usergroupid] AND $forums ORDER BY ordercontrol LIMIT 1");

if(($getperms[canview] == 0) AND (isset($getperms[canview]) == 1)) {
$getaccess=$DB_site->query("SELECT * FROM access WHERE userid=$userid AND forumid = $forumid");
if($DB_site->num_rows($getaccess) == 1) {
$error = false;
} else{
$error = true;
}
}else{
$error = false;
}// check permission