New function setup_and_print_groups() makes it much easier to set
up groups everywhere else.
This commit is contained in:
@@ -1165,6 +1165,38 @@ function get_and_set_current_group($course, $groupmode, $groupid=0) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A big combination function to make it easier for modules
|
||||
* to set up groups.
|
||||
*
|
||||
* Terminates if the current user shouldn't be looking at this group
|
||||
* Otherwise returns the current group if there is one
|
||||
* Otherwise returns false if groups aren't relevant
|
||||
*
|
||||
* @param type description
|
||||
*/
|
||||
function setup_and_print_groups($course, $groupmode, $urlroot) {
|
||||
|
||||
$currentgroup = get_and_set_current_group($course, $groupmode, $_GET['group']);
|
||||
|
||||
if ($currentgroup == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isteacheredit($course->id) and $groupmode and !$currentgroup) {
|
||||
print_heading();
|
||||
print_footer($course);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) {
|
||||
if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) {
|
||||
print_group_menu($groups, $groupmode, $currentgroup, $urlroot);
|
||||
}
|
||||
}
|
||||
|
||||
return $currentgroup;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+39
-21
@@ -1222,29 +1222,31 @@ function print_user($user, $course) {
|
||||
function print_group_picture($group, $courseid, $large=false, $returnstring=false, $link=true) {
|
||||
global $CFG;
|
||||
|
||||
if ($link) {
|
||||
$output = "<a href=\"$CFG->wwwroot/course/groupphp?id=$courseid&group=$group->id\">";
|
||||
} else {
|
||||
$output = "";
|
||||
}
|
||||
if ($large) {
|
||||
$file = "f1";
|
||||
$size = 100;
|
||||
} else {
|
||||
$file = "f2";
|
||||
$size = 35;
|
||||
}
|
||||
if ($group->picture) { // Print custom group picture
|
||||
if ($CFG->slasharguments) { // Use this method if possible for better caching
|
||||
$output .= "<img align=\"absmiddle\" src=\"$CFG->wwwroot/user/pixgroup.php/$group->id/$file.jpg\"".
|
||||
" border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" />";
|
||||
$output = '';
|
||||
|
||||
if ($group->showpicture) {
|
||||
if ($link) {
|
||||
$output = "<a href=\"$CFG->wwwroot/course/groupphp?id=$courseid&group=$group->id\">";
|
||||
}
|
||||
if ($large) {
|
||||
$file = "f1";
|
||||
$size = 100;
|
||||
} else {
|
||||
$output .= "<img align=\"absmiddle\" src=\"$CFG->wwwroot/user/pixgroup.php?file=/$group->id/$file.jpg\"".
|
||||
" border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" />";
|
||||
$file = "f2";
|
||||
$size = 35;
|
||||
}
|
||||
if ($group->picture) { // Print custom group picture
|
||||
if ($CFG->slasharguments) { // Use this method if possible for better caching
|
||||
$output .= "<img align=\"absmiddle\" src=\"$CFG->wwwroot/user/pixgroup.php/$group->id/$file.jpg\"".
|
||||
" border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" />";
|
||||
} else {
|
||||
$output .= "<img align=\"absmiddle\" src=\"$CFG->wwwroot/user/pixgroup.php?file=/$group->id/$file.jpg\"".
|
||||
" border=\"0\" width=\"$size\" height=\"$size\" alt=\"\" />";
|
||||
}
|
||||
}
|
||||
if ($link) {
|
||||
$output .= "</a>";
|
||||
}
|
||||
}
|
||||
if ($link) {
|
||||
$output .= "</a>";
|
||||
}
|
||||
|
||||
if ($returnstring) {
|
||||
@@ -1654,6 +1656,22 @@ function update_groups_button($courseid) {
|
||||
}
|
||||
}
|
||||
|
||||
function print_group_menu($groups, $groupmode, $currentgroup, $urlroot) {
|
||||
/// Prints an appropriate group selection menu
|
||||
|
||||
echo '<table><tr><td>';
|
||||
if ($groupmode == VISIBLEGROUPS) {
|
||||
print_string('groupsvisible');
|
||||
} else {
|
||||
print_string('groupsseparate');
|
||||
}
|
||||
echo ':';
|
||||
echo '</td><td nowrap="nowrap" align="left" width="50%">';
|
||||
popup_form($urlroot.'&group=', $groups, 'selectgroup', $currentgroup, "", "", "", false, "self");
|
||||
echo '</tr></table>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
function navmenu($course, $cm=NULL, $targetwindow="self") {
|
||||
// Given a course and a (current) coursemodule
|
||||
|
||||
Reference in New Issue
Block a user