mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
This is the first check-in of support for groups.
It's very early (it doesn't actually do anything yet!) but you can define groups and get an idea of how the interface is shaping up. I also wanted to show that I have actually done something on this! :-) From here my plan is to add group support to the modules, one by one (forums first), then go back and clean up some of the central interfaces, graphics etc. Finally, test, test, test and get 1.2 out well before the end of February.
This commit is contained in:
parent
ee39bbe0ee
commit
f374fb1006
22 changed files with 1029 additions and 57 deletions
|
@ -34,6 +34,12 @@
|
|||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// CONSTANTS /////////////////////////////////////////////////////////////
|
||||
|
||||
define('NOGROUPS', 0);
|
||||
define('SEPARATEGROUPS', 1);
|
||||
define('VISIBLEGROUPS', 2);
|
||||
|
||||
|
||||
/// PARAMETER HANDLING ////////////////////////////////////////////////////
|
||||
|
||||
|
@ -504,7 +510,11 @@ function fullname($user, $override=false) {
|
|||
/// or language. 'override' will force both names
|
||||
/// to be used even if system settings specify one.
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $SESSION;
|
||||
|
||||
if (!empty($SESSION->fullnamedisplay)) {
|
||||
$CFG->fullnamedisplay = $SESSION->fullnamedisplay;
|
||||
}
|
||||
|
||||
if ($CFG->fullnamedisplay == 'firstname lastname') {
|
||||
return "$user->firstname $user->lastname";
|
||||
|
@ -865,6 +875,76 @@ function remove_course_contents($courseid, $showfeedback=true) {
|
|||
}
|
||||
|
||||
|
||||
/// GROUPS /////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Returns a boolean: is the user a member of the given group?
|
||||
*
|
||||
* @param type description
|
||||
*/
|
||||
function ismember($groupid, $userid=0) {
|
||||
global $USER;
|
||||
|
||||
if (!$userid) {
|
||||
return !empty($USER->groupmember[$groupid]);
|
||||
}
|
||||
|
||||
return record_exists("group_members", "groupid", $groupid, "userid", $userid);
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given course, and possibly course module, determine
|
||||
* what the current default groupmode is:
|
||||
* NOGROUPS, SEPARATEGROUPS or VISIBLEGROUPS
|
||||
*
|
||||
* @param type description
|
||||
*/
|
||||
function groupmode($course, $cm=null) {
|
||||
|
||||
if ($cm and !$course->groupmodeforce) {
|
||||
return $cm->groupmode;
|
||||
}
|
||||
return $course->groupmode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the current group in the session variable
|
||||
*
|
||||
* @param type description
|
||||
*/
|
||||
function set_current_group($courseid, $groupid) {
|
||||
global $SESSION;
|
||||
|
||||
return $SESSION->currentgroup[$courseid] = $groupid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the current group for the current user as an id or an object
|
||||
*
|
||||
* @param type description
|
||||
*/
|
||||
function get_current_group($courseid, $full=false) {
|
||||
global $SESSION, $USER;
|
||||
|
||||
if (empty($SESSION->currentgroup[$courseid])) {
|
||||
if (empty($USER->groupmember[$courseid])) {
|
||||
return false;
|
||||
} else {
|
||||
$SESSION->currentgroup[$courseid] = $USER->groupmember[$courseid];
|
||||
}
|
||||
}
|
||||
|
||||
if ($full) {
|
||||
return get_record('group', 'id', $SESSION->currentgroup[$courseid]);
|
||||
} else {
|
||||
return $SESSION->currentgroup[$courseid];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// CORRESPONDENCE ////////////////////////////////////////////////
|
||||
|
||||
function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $attachment="", $attachname="") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue