diff --git a/group/lib/basicgrouplib.php b/group/lib/basicgrouplib.php index 8cb78c83930..3a8687a878e 100644 --- a/group/lib/basicgrouplib.php +++ b/group/lib/basicgrouplib.php @@ -208,12 +208,18 @@ function groups_group_matches($courseid, $grp_name, $grp_description) { /** - * Determines if a specified user is a member of a specified group - * @param int $groupid The group about which the request has been made - * @param int $userid The user about which the request has been made - * @return boolean True if the user is a member of the group, false otherwise + * Determines if the user is a member of the given group. + * + * @uses $USER If $userid is null, use the global object. + * @param int $groupid The group to check for membership. + * @param int $userid The user to check against the group. + * @return boolean True if the user is a member, false otherwise. */ - function groups_is_member($groupid, $userid) { +function groups_is_member($groupid, $userid = null) { + if (! $userid) { + global $USER; + $userid = $USER->id; + } $ismember = groups_db_is_member($groupid, $userid); return $ismember; diff --git a/group/lib/legacylib.php b/group/lib/legacylib.php index ec12819d08b..514c453e95e 100644 --- a/group/lib/legacylib.php +++ b/group/lib/legacylib.php @@ -76,16 +76,14 @@ function user_group($courseid, $userid) { /** - * Determines if the user a member of the given group + * Determines if the user is a member of the given group. + * TODO: replace all calls with 'groups_is_member'. * - * @uses $USER - * @param int $groupid The group to check the membership of - * @param int $userid The user to check against the group - * @return bool + * @param int $groupid The group to check for membership. + * @param int $userid The user to check against the group. + * @return boolean True if the user is a member, false otherwise. */ -function ismember($groupid, $userid=0) { - if (!$userid) { - } +function ismember($groupid, $userid = null) { return groups_is_member($groupid, $userid); }