In order to be consistent with the permission function (there's also an error on argument name), the access function should be :
/**
* Determines whether the given user has access to a bookable unit.
*
* @param $op
* The operation being performed. One of 'view', 'update', 'create', 'delete'
* or just 'edit' (being the same as 'create' or 'update').
* @param $room
* Optionally a unit or a unit type to check access for. If nothing is
* given, access for all units is determined.
* @param $account
* The user to check for. Leave it to NULL to check for the global user.
* @return boolean
* Whether access is allowed or not.
*/
function rooms_unit_access($op, $room = NULL, $account = NULL) {
if (user_access('administer bookable units', $account)) {
return TRUE;
}
if (isset($room) && $type_name = $room->type) {
$op = ($op == 'view') ? 'view' : 'edit';
if (user_access("$op any $type_name bookable unit", $account)) {
return TRUE;
}
}
return FALSE;
}
Comments
Comment #1
ronald_istos commentedTs, ts a couple of errors here. Thanks for bringing it up. Fixed in HEAD.
http://drupalcode.org/project/rooms.git/commit/96d589a
Comment #2.0
(not verified) commentedRemove dsm calls