1.9.4 "roles" branch not working
Brought to you by:
jberanek
Hi
I need to get the "roles" branch working in 1.9.4 to be able to have a per-ldap group for each room within an area.
This worked fine in 1.9.2 by tweaking the following files (as per https://sourceforge.net/p/mrbs/support-requests/2314/) and using the "roles" branch (hq snapshot)
lib/MRBS/Room.php (added on the bottom)
public function getDefaultRule($user)
{
$area = Area::getById($this->area_id);
return $area->getDefaultRule($user);
}
lib/MRBS/Area.php (added on the bottom)
// Function to define that all areas except one special area (uses ldap-roles) should have the default behaviour
public function getDefaultRule($user)
{
// Every area except one has the default permissions
if ($this->id != 21) // or whatever the id of your area is
{
return parent::getDefaultRule($user);
}
// The special area has restricted permissions
$result = new AreaRule();
$result->state = $result::GRANTED;
if (!isset($user) || empty($user->level))
{
$result->permission = $result::READ;
}
elseif ($user->isAdmin())
{
$result->permission = $result::ALL;
}
else
{
// Modified from the standard WRITE
$result->permission = $result::READ;
}
return $result;
}
}
Now i checked out the 1.9.4 branch of "roles", copied config.inc.php, areadefaults.inc.php and made the changes to the two files above.
The database upgrades fine to the newest version but then, i see a white page. My apache error logs lists
[Fri Dec 03 13:47:27.180844 2021] [php7:error] [pid 16683] [client 1x.x.x.x:56196] PHP Fatal error: Declaration of MRBS\\Room::getDefaultRule($user) must be compatible with MRBS\\Location::getDefaultRule(?MRBS\\User $user): object in /var/www/html/mrbs-code/lib/MRBS/Room.php on line 5
What am i doing wrong here?
Best,
Thomas
You are probably running PHP 8.1 which now throws a deprecation error if the declaration of a method is not compatible with its parent's. You should declare your methods as
This should get rid of the deprecation message. However I don't think it explains the white page. If you still get the white page let me know.
Now its gone, thanks :)