MDL-14617 removed some legacy group code
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user