Commit c34b0a9c authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Use user_group_access function to get group role

parent b7b9c8d4
......@@ -532,8 +532,8 @@ class User {
}
$group = $a->get('group');
if ($group) {
// @todo: Call group_user_access function once it's fixed up
$role = get_field('group_member', 'role', 'group', $group, 'member', $this->get('id'));
require_once(get_config('docroot') . 'lib/group.php');
$role = group_user_access($group, $this->get('id'));
if ($role) {
$aperms = $a->get('rolepermissions');
return $aperms->{$role}->edit;
......
......@@ -318,7 +318,9 @@ function user_can_access_group($group, $user=null) {
function group_user_access($groupid, $userid=null) {
// TODO: caching
if (!is_int($groupid) || $groupid == 0) {
$groupid = (int)$groupid;
if ($groupid == 0) {
throw new InvalidArgumentException("group_user_access: group argument appears to be invalid: $groupid");
}
......@@ -326,8 +328,11 @@ function group_user_access($groupid, $userid=null) {
global $USER;
$userid = (int)$USER->get('id');
}
else {
$userid = (int)$userid;
}
if (!is_int($userid) || $userid == 0) {
if ($userid == 0) {
throw new InvalidArgumentException("group_user_access: user argument appears to be invalid: $userid");
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment