From: nfreear Date: Wed, 7 Feb 2007 12:14:11 +0000 (+0000) Subject: Fixes bug MDL-8454, "students can't post to forums" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=df0332886359d28cda7b7dd4632082d3d91801c1;p=moodle.git Fixes bug MDL-8454, "students can't post to forums" --- diff --git a/group/lib/basicgrouplib.php b/group/lib/basicgrouplib.php index 8cb78c8393..3a8687a878 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 ec12819d08..514c453e95 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); }