From 35987665f4863ffe7432bbc71b4d548985b18ddc Mon Sep 17 00:00:00 2001 From: skodak Date: Thu, 1 May 2008 22:30:28 +0000 Subject: [PATCH] MDL-14617 removed some legacy group code --- admin/uploaduser.php | 2 +- lib/deprecatedlib.php | 114 ----------------------------- mod/feedback/analysis.php | 2 +- mod/feedback/show_entries.php | 2 +- mod/forum/subscribe.php | 2 +- search/documents/chat_document.php | 2 +- search/documents/data_document.php | 2 +- 7 files changed, 6 insertions(+), 120 deletions(-) diff --git a/admin/uploaduser.php b/admin/uploaduser.php index bafcf4ad85..6a4c411ade 100755 --- a/admin/uploaduser.php +++ b/admin/uploaduser.php @@ -644,7 +644,7 @@ if ($formdata = $mform->is_cancelled()) { //build group cache if (is_null($ccache[$shortname]->groups)) { $ccache[$shortname]->groups = array(); - if ($groups = get_groups($courseid)) { + if ($groups = groups_get_all_groups($courseid)) { foreach ($groups as $gid=>$group) { $ccache[$shortname]->groups[$gid] = new object(); $ccache[$shortname]->groups[$gid]->id = $gid; diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 9d5b78bf3c..7be45bf4e2 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -733,88 +733,6 @@ function detect_munged_arguments($string, $allowdots=1) { /** various deprecated groups function **/ -/** - * Returns the table in which group members are stored, with a prefix 'gm'. - * @return SQL string. - */ -function groups_members_from_sql() { - global $CFG; - return " {$CFG->prefix}groups_members gm "; -} - -/** - * Returns a join testing user.id against member's user ID. - * Relies on 'user' table being included as 'user u'. - * Used in Quiz module reports. - * @param group ID, optional to include a test for this in the SQL. - * @return SQL string. - */ -function groups_members_join_sql($groupid=false) { - $sql = ' JOIN '.groups_members_from_sql().' ON u.id = gm.userid '; - if ($groupid) { - $sql = "AND gm.groupid = '$groupid' "; - } - return $sql; - //return ' INNER JOIN '.$CFG->prefix.'role_assignments ra ON u.id=ra.userid'. - // ' INNER JOIN '.$CFG->prefix.'context c ON ra.contextid=c.id AND c.contextlevel='.CONTEXT_GROUP.' AND c.instanceid='.$groupid; -} - -/** - * Returns SQL for a WHERE clause testing the group ID. - * Optionally test the member's ID against another table's user ID column. - * @param groupid - * @param userid_sql Optional user ID column selector, example "mdl_user.id", or false. - * @return SQL string. - */ -function groups_members_where_sql($groupid, $userid_sql=false) { - $sql = " gm.groupid = '$groupid' "; - if ($userid_sql) { - $sql .= "AND $userid_sql = gm.userid "; - } - return $sql; -} - - -/** - * Returns an array of group objects that the user is a member of - * in the given course. If userid isn't specified, then return a - * list of all groups in the course. - * - * @uses $CFG - * @param int $courseid The id of the course in question. - * @param int $userid The id of the user in question as found in the 'user' table 'id' field. - * @return object - */ -function get_groups($courseid, $userid=0) { - return groups_get_all_groups($courseid, $userid); -} - -/** - * Returns the user's groups in a particular course - * note: this function originally returned only one group - * - * @uses $CFG - * @param int $courseid The course in question. - * @param int $userid The id of the user as found in the 'user' table. - * @param int $groupid The id of the group the user is in. - * @return aray of groups - */ -function user_group($courseid, $userid) { - return groups_get_all_groups($courseid, $userid); -} - - -/** - * Determines if the user is a member of the given group. - * - * @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 = null) { - return groups_is_member($groupid, $userid); -} - /** * Get the IDs for the user's groups in the given course. * @@ -832,21 +750,6 @@ function mygroupid($courseid) { } } -/** - * Add a user to a group, return true upon success or if user already a group - * member - * - * @param int $groupid The group id to add user to - * @param int $userid The user id to add to the group - * @return bool - */ -function add_user_to_group($groupid, $userid) { - global $CFG; - require_once($CFG->dirroot.'/group/lib.php'); - - return groups_add_member($groupid, $userid); -} - /** * Returns an array of user objects @@ -895,23 +798,6 @@ function groupmode($course, $cm=null) { } -/** - * Sets the current group in the session variable - * When $SESSION->currentgroup[$courseid] is set to 0 it means, show all groups. - * Sets currentgroup[$courseid] in the session variable appropriately. - * Does not do any permission checking. - * @uses $SESSION - * @param int $courseid The course being examined - relates to id field in - * 'course' table. - * @param int $groupid The group being examined. - * @return int Current group id which was set by this function - */ -function set_current_group($courseid, $groupid) { - global $SESSION; - return $SESSION->currentgroup[$courseid] = $groupid; -} - - /** * Gets the current group - either from the session variable or from the database. * diff --git a/mod/feedback/analysis.php b/mod/feedback/analysis.php index 7ce9cd9cd9..12fb2e244d 100644 --- a/mod/feedback/analysis.php +++ b/mod/feedback/analysis.php @@ -86,7 +86,7 @@ if( $capabilities->viewreports ) { //available group modes (NOGROUPS, SEPARATEGROUPS or VISIBLEGROUPS) - $feedbackgroups = get_groups($course->id); + $feedbackgroups = groups_get_all_groups($course->id); //get the effective groupmode of this course and module $groupmode = groupmode($course, $cm); if(is_array($feedbackgroups) && $groupmode > 0){ diff --git a/mod/feedback/show_entries.php b/mod/feedback/show_entries.php index d81078ce5e..d6ee4cd396 100644 --- a/mod/feedback/show_entries.php +++ b/mod/feedback/show_entries.php @@ -156,7 +156,7 @@ print_box_start('generalbox boxaligncenter boxwidthwide'); //available group modes (NOGROUPS, SEPARATEGROUPS or VISIBLEGROUPS) - $feedbackgroups = get_groups($course->id); + $feedbackgroups = groups_get_all_groups($course->id); //if(is_array($feedbackgroups) && $groupmode != SEPARATEGROUPS){ if(is_array($feedbackgroups) && $groupmode > 0){ require_once('choose_group_form.php'); diff --git a/mod/forum/subscribe.php b/mod/forum/subscribe.php index 01c26c5c24..1a685c16b5 100644 --- a/mod/forum/subscribe.php +++ b/mod/forum/subscribe.php @@ -38,7 +38,7 @@ if (groupmode($course, $cm) and !forum_is_subscribed($user->id, $forum) and !has_capability('moodle/site:accessallgroups', $context)) { - if (!mygroupid($course->id)) { + if (!groups_get_all_groups($course->id, $USER->id)) { error('Sorry, but you must be a group member to subscribe.'); } } diff --git a/search/documents/chat_document.php b/search/documents/chat_document.php index acc4ffb479..371c8584c9 100644 --- a/search/documents/chat_document.php +++ b/search/documents/chat_document.php @@ -273,7 +273,7 @@ function chat_check_text_access($path, $itemtype, $this_id, $user, $group_id, $c // trap if user is not same group and groups are separated $current_group = get_current_group($course->id); $course = get_record('course', 'id', $chat->course); - if ((groupmode($course, $cm) == SEPARATEGROUPS) && !ismember($group_id) && !has_capability('moodle/site:accessallgroups', $context)){ + if ((groupmode($course, $cm) == SEPARATEGROUPS) && !groups_is_member($group_id) && !has_capability('moodle/site:accessallgroups', $context)){ if (!empty($CFG->search_access_debug)) echo "search reject : chat element is in separated group "; return false; } diff --git a/search/documents/data_document.php b/search/documents/data_document.php index 4b301ffaa8..655b5d5ae0 100644 --- a/search/documents/data_document.php +++ b/search/documents/data_document.php @@ -350,7 +350,7 @@ function data_check_text_access($path, $itemtype, $this_id, $user, $group_id, $c // trap if user is not same group and groups are separated $current_group = get_current_group($course->id); $course = get_record('course', 'id', $data->course); - if ((groupmode($course, $cm) == SEPARATEGROUPS) && !ismember($group_id) && !has_capability('moodle/site:accessallgroups', $context)){ + if ((groupmode($course, $cm) == SEPARATEGROUPS) && !groups_is_member($group_id) && !has_capability('moodle/site:accessallgroups', $context)){ if (!empty($CFG->search_access_debug)) echo "search reject : separated group owned resource "; return false; } -- 2.39.5