1
<?php // $Id: groups.php,v 1.19.2.2 2005/10/30 22:14:03 skodak Exp $
1
<?php // $Id: groups.php,v 1.24 2006/03/07 19:36:12 skodak Exp $
3
///////////////////////////////////////////////////////////////////////////
5
// NOTICE OF COPYRIGHT //
7
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
8
// http://moodle.org //
10
// Copyright (C) 1999-2004 Martin Dougiamas http://dougiamas.com //
12
// This program is free software; you can redistribute it and/or modify //
13
// it under the terms of the GNU General Public License as published by //
14
// the Free Software Foundation; either version 2 of the License, or //
15
// (at your option) any later version. //
17
// This program is distributed in the hope that it will be useful, //
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20
// GNU General Public License for more details: //
22
// http://www.gnu.org/copyleft/gpl.html //
24
///////////////////////////////////////////////////////////////////////////
3
26
/// Editing interface to edit all the groups in a course
5
28
require_once('../config.php');
6
29
require_once('lib.php');
8
$courseid = required_param('id'); // Course id
9
$selectedgroup = optional_param('group', NULL); // Current group id
31
$courseid = required_param('id', PARAM_INT); // Course id
32
$selectedgroup = optional_param('group', NULL, PARAM_INT); // Current group id
11
34
if (! $course = get_record('course', 'id', $courseid) ) {
12
35
error("That's an invalid course id");
42
65
"-> $strgroups", "", "", true, '', user_login_string($course, $USER));
46
68
/// First, process any inputs there may be.
48
70
if ($data = data_submitted() and confirm_sesskey()) {
57
79
if (!empty($data->nonmembers) and !empty($data->groupid)) {
58
80
$groupmodified = false;
59
81
foreach ($data->nonmembers as $userid) {
60
if (!user_group($course->id, $userid)) { // Just to make sure (another teacher could be editing)
82
//since we allow people to be in more than 1 group, this has to go.
83
if (!ismember($data->groupid,$userid)) {// Just to make sure (another teacher could be editing)
61
84
$record->groupid = $data->groupid;
62
85
$record->userid = $userid;
63
86
$record->timeadded = time();
126
149
/// Calculate data ready to create the editing interface
151
$strmemberincourse = get_string('memberincourse');
128
152
$strgroupnonmembers = get_string('groupnonmembers');
129
153
$strgroupmembersselected = get_string('groupmembersselected');
130
154
$strgroupremovemembers = get_string('groupremovemembers');
172
196
if ($groupusers = get_group_users($group->id)) {
173
197
foreach ($groupusers as $groupuser) {
174
198
$listmembers[$group->id][$groupuser->id] = $nonmembers[$groupuser->id];
175
unset($nonmembers[$groupuser->id]);
199
//we do not remove people from $nonmembers, everyone is displayed
200
//this is to enable people to be registered in multiple groups
201
//unset($nonmembers[$groupuser->id]);
178
204
natcasesort($listmembers[$group->id]);