if (confirm_sesskey()) { if (groups_delete_group($id)) { // MDL-9983 $eventdata = new object(); $eventdata->group = $id; $eventdata->course = $courseid; events_trigger('group_deleted', $eventdata); redirect('index.php?id=' . $course->id); } else { print_error('erroreditgroup', 'group', $returnurl); } } } } /// First create the form $editform = new group_form(); $editform->set_data($group); if ($editform->is_cancelled()) { redirect($returnurl); } elseif ($data = $editform->get_data()) { if ($data->id) { if (!groups_update_group($data, $editform->_upload_manager)) { error('Error updating group'); } } else { if (!($id = groups_create_group($data, $editform->_upload_manager))) { error('Error creating group'); } $returnurl = $CFG->wwwroot . '/group/index.php?id=' . $course->id . '&group=' . $id; } redirect($returnurl);
} else { $PAGE->set_url('/group/group.php', array('courseid' => $courseid)); } require_login($course); $context = get_context_instance(CONTEXT_COURSE, $course->id); require_capability('moodle/course:managegroups', $context); $returnurl = $CFG->wwwroot . '/group/index.php?id=' . $course->id . '&group=' . $id; // Prepare the description editor: We do support files for group descriptions $editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $course->maxbytes, 'trust' => false, 'context' => $context, 'noclean' => true); if (!empty($group->id)) { $group = file_prepare_standard_editor($group, 'description', $editoroptions, $context, 'group', 'description', $group->id); } else { $group = file_prepare_standard_editor($group, 'description', $editoroptions, $context, 'group', 'description', null); } /// First create the form $editform = new group_form(null, array('editoroptions' => $editoroptions)); $editform->set_data($group); if ($editform->is_cancelled()) { redirect($returnurl); } elseif ($data = $editform->get_data()) { if (!has_capability('moodle/course:changeidnumber', $context)) { // Remove the idnumber if the user doesn't have permission to modify it unset($data->idnumber); } if ($data->id) { groups_update_group($data, $editform, $editoroptions); } else { $id = groups_create_group($data, $editform, $editoroptions); $returnurl = $CFG->wwwroot . '/group/index.php?id=' . $course->id . '&group=' . $id; } redirect($returnurl);