description = clean_text($group->description); if (empty($courseid)) { $courseid = $group->courseid; } else if ($courseid != $group->courseid) { error('Course ID was incorrect'); } if (!$course = get_record('course', 'id', $courseid)) { error('Course ID was incorrect'); } } else { if (!$course = get_record('course', 'id', $courseid)) { error('Course ID was incorrect'); } $group = new object(); $group->courseid = $course->id; } 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; if ($id and $delete) { if (!$confirm) { print_header(get_string('deleteselectedgroup', 'group'), get_string('deleteselectedgroup', 'group')); $optionsyes = array('id'=>$id, 'delete'=>1, 'courseid'=>$courseid, 'sesskey'=>sesskey(), 'confirm'=>1); $optionsno = array('id'=>$courseid); notice_yesno(get_string('deletegroupconfirm', 'group', $group->name), 'group.php', 'index.php', $optionsyes, $optionsno, 'get', 'get'); print_footer(); die; } else if (confirm_sesskey()){ if (groups_delete_group($id)) { 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); } $strgroups = get_string('groups'); $strparticipants = get_string('participants'); if ($id) { $strheading = get_string('editgroupsettings', 'group'); } else { $strheading = get_string('creategroup', 'group'); } $navlinks = array(array('name'=>$strparticipants, 'link'=>$CFG->wwwroot.'/user/index.php?id='.$courseid, 'type'=>'misc'), array('name'=>$strgroups, 'link'=>$CFG->wwwroot.'/group/index.php?id='.$courseid, 'type'=>'misc'), array('name'=>$strheading, 'link'=>'', 'type'=>'misc')); $navigation = build_navigation($navlinks); /// Print header print_header_simple($strgroups, ': '.$strgroups, $navigation, '', '', true, '', navmenu($course)); echo '