mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 14:03:52 +01:00
ff3caf30c0
It's still not perfect but it's much much better I think.
88 lines
2.4 KiB
PHP
88 lines
2.4 KiB
PHP
<?php // $Id$
|
|
|
|
/// Shows current group, and allows editing of the group
|
|
/// icon and other settings related to that group
|
|
|
|
/// This script appears within a popup window
|
|
|
|
require_once('../config.php');
|
|
require_once('lib.php');
|
|
|
|
$id = required_param('id'); // Course id
|
|
$group = optional_param('group', 0); // Optionally look at other groups
|
|
$edit = optional_param('edit', false); // Editing can be turned on
|
|
|
|
if (! $course = get_record('course', 'id', $id) ) {
|
|
error("That's an invalid course id");
|
|
}
|
|
|
|
require_login($course->id);
|
|
|
|
if (!isteacheredit($course->id)) {
|
|
close_window();
|
|
}
|
|
|
|
if (! $group = get_record("groups", "id", $group, "courseid", $course->id)) {
|
|
notice('Specified group could not be found!', "#");
|
|
close_window_button();
|
|
}
|
|
|
|
|
|
/// Print the headers of the page
|
|
|
|
print_header(get_string('groupinfoedit').' : '.$group->name);
|
|
|
|
|
|
/// If data submitted, then process and store.
|
|
|
|
if ($form = data_submitted() and confirm_sesskey()) {
|
|
|
|
if (empty($form->name)) {
|
|
$edit = true;
|
|
$err['name'] = get_string("missingname");
|
|
|
|
} else {
|
|
require_once($CFG->dirroot.'/lib/uploadlib.php');
|
|
|
|
$um = new upload_manager('imagefile',false,false,null,false,0,true,true);
|
|
if ($um->preprocess_files()) {
|
|
require_once("$CFG->libdir/gdlib.php");
|
|
if (save_profile_image($group->id, $um, 'groups')) {
|
|
$group->picture = 1;
|
|
}
|
|
}
|
|
$group->name = clean_text($form->name);
|
|
$group->description = clean_text($form->description);
|
|
$group->hidepicture = $form->hidepicture;
|
|
$group->password = $form->password;
|
|
if (!update_record("groups", $group)) {
|
|
notify("A strange error occurred while trying to save");
|
|
} else {
|
|
notify(get_string('changessaved'));
|
|
}
|
|
close_window(3);
|
|
}
|
|
}
|
|
|
|
|
|
/// Are we editing? If so, handle it.
|
|
|
|
if ($usehtmleditor = can_use_richtext_editor()) {
|
|
$defaultformat = FORMAT_HTML;
|
|
} else {
|
|
$defaultformat = FORMAT_MOODLE;
|
|
}
|
|
|
|
$usehtmleditor = false;
|
|
|
|
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
|
|
|
include('group-edit.html');
|
|
|
|
if ($usehtmleditor) {
|
|
use_html_editor("description");
|
|
}
|
|
|
|
echo "</body></html>";
|
|
?>
|