]> git.mjollnir.org Git - moodle.git/commitdiff
Fixes bug MDL-8454, "students can't post to forums"
authornfreear <nfreear>
Wed, 7 Feb 2007 12:14:11 +0000 (12:14 +0000)
committernfreear <nfreear>
Wed, 7 Feb 2007 12:14:11 +0000 (12:14 +0000)
group/lib/basicgrouplib.php
group/lib/legacylib.php

index 8cb78c83930cc5ab15a0aedcfe6d692429af0927..3a8687a878e3365fad096b6016efb8261a43f43a 100644 (file)
@@ -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;
index ec12819d08b13b1b6642eb113d3531d1b08b9cb7..514c453e95e504711a3245ac20e104107d2ae882 100644 (file)
@@ -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);
 }