Index: lib/grouplib.php =================================================================== RCS file: /globalcvs/ou-moodle/lib/grouplib.php,v retrieving revision 1.6 diff -u -r1.6 grouplib.php --- lib/grouplib.php 17 Mar 2008 11:18:06 -0000 1.6 +++ lib/grouplib.php 2 May 2008 11:37:30 -0000 @@ -92,7 +92,7 @@ /** * Gets array of all groups in a specified course. - * @param int $courseid The id of the course. + * @param int $courseid The id of the course or 0 for any.. * @param mixed $userid optional user id or array of ids, returns only groups of the user. * @param int $groupingid optional returns only groups in the specified grouping. * @return array | false Returns an array of the group objects or false if no records @@ -127,10 +127,19 @@ $groupingfrom = ""; $groupingwhere = ""; } + + if(!empty($courseid)) { + if(empty($userid) && empty($groupingid)) { + // The list would be too large as sites may have tens of thousands + // of groups (or more) - require some kind of restriction + error('Cannot request list of all groups across entire site'); + } + $coursewhere = "AND g.courseid = '$courseid'"; + } return get_records_sql("SELECT $fields FROM {$CFG->prefix}groups g $userfrom $groupingfrom - WHERE g.courseid = $courseid $userwhere $groupingwhere + WHERE $coursewhere $userwhere $groupingwhere ORDER BY name ASC"); }