Hey all!
I've got this problem and I can't understand what's going wrong..
I've got a class (simplified below).. the array is set up fine, print_r() works perfectly. echo $user_permissions[25]['auth_read'] proves this works too, returning the correct value..
However my function allowed($forum_id, $access_mode) never works.. always returns false.. and I can't understand why, when both should be doing EXACTLY the same thing..
I've also tried returning count($user_permissions) in the function allowed().. which returns 0, so I'm assuming that function isn't getting the array.. but why?
Does anyone have any ideas? or know why this might be happening?
Many thanks 😃
<?php
class PageAccess
{
private $user_permissions;
public function __construct($required_page_level = 0) {
// COLLATE USER PERMISSIONS
$user_permissions = array();
// code which sets up array $user_permissions[id][mode] = 1 or 0
echo $user_permissions[25]['auth_read'] . '<br>'; // returns the correct value
echo $this->allowed(25, 'auth_read'); // returns false everytime
echo '<p>';
print_r($user_permissions);
}
public function allowed($forum_id, $access_mode) {
global $user_permissions;
//return count($user_permissions);
return $user_permissions[$forum_id][$access_mode] ? 1 : 0;
}
} // end class
?>