| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Create grouping OR edit grouping settings. 4 * 5 * @copyright © 2006 The Open University 6 * @author N.D.Freear AT open.ac.uk 7 * @author J.White AT open.ac.uk 8 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 9 * @package groups 10 */ 11 require_once ('../config.php'); 12 require_once ('lib.php'); 13 require_once ('grouping_form.php'); 14 15 /// get url variables 16 $courseid = optional_param('courseid', 0, PARAM_INT); 17 $id = optional_param('id', 0, PARAM_INT); 18 $delete = optional_param('delete', 0, PARAM_BOOL); 19 $confirm = optional_param('confirm', 0, PARAM_BOOL); 20 21 if ($id) { 22 if (!$grouping = get_record('groupings', 'id', $id)) { 23 error('Group ID was incorrect'); 24 } 25 $grouping->description = clean_text($grouping->description); 26 if (empty($courseid)) { 27 $courseid = $grouping->courseid; 28 29 } else if ($courseid != $grouping->courseid) { 30 error('Course ID was incorrect'); 31 } 32 33 if (!$course = get_record('course', 'id', $courseid)) { 34 error('Course ID was incorrect'); 35 } 36 37 } else { 38 if (!$course = get_record('course', 'id', $courseid)) { 39 error('Course ID was incorrect'); 40 } 41 $grouping = new object(); 42 $grouping->courseid = $course->id; 43 } 44 45 require_login($course); 46 $context = get_context_instance(CONTEXT_COURSE, $course->id); 47 require_capability('moodle/course:managegroups', $context); 48 49 $returnurl = $CFG->wwwroot.'/group/groupings.php?id='.$course->id; 50 51 52 if ($id and $delete) { 53 if (!$confirm) { 54 print_header(get_string('deletegrouping', 'group'), get_string('deletegrouping', 'group')); 55 $optionsyes = array('id'=>$id, 'delete'=>1, 'courseid'=>$courseid, 'sesskey'=>sesskey(), 'confirm'=>1); 56 $optionsno = array('id'=>$courseid); 57 notice_yesno(get_string('deletegroupingconfirm', 'group', $grouping->name), 'grouping.php', 'groupings.php', $optionsyes, $optionsno, 'get', 'get'); 58 print_footer(); 59 die; 60 61 } else if (confirm_sesskey()){ 62 if (groups_delete_grouping($id)) { 63 redirect($returnurl); 64 } else { 65 print_error('erroreditgrouping', 'group', $returnurl); 66 } 67 } 68 } 69 70 /// First create the form 71 $editform = new grouping_form(); 72 $editform->set_data($grouping); 73 74 if ($editform->is_cancelled()) { 75 redirect($returnurl); 76 77 } elseif ($data = $editform->get_data()) { 78 $success = true; 79 80 if ($data->id) { 81 if (!groups_update_grouping($data)) { 82 error('Error updating grouping'); 83 } 84 85 } else { 86 if (!groups_create_grouping($data)) { 87 error('Error creating grouping'); 88 } 89 } 90 91 redirect($returnurl); 92 93 } 94 95 $strgroupings = get_string('groupings', 'group'); 96 $strparticipants = get_string('participants'); 97 98 if ($id) { 99 $strheading = get_string('editgroupingsettings', 'group'); 100 } else { 101 $strheading = get_string('creategrouping', 'group'); 102 } 103 104 $navlinks = array(array('name'=>$strparticipants, 'link'=>$CFG->wwwroot.'/user/index.php?id='.$courseid, 'type'=>'misc'), 105 array('name'=>$strgroupings, 'link'=>$CFG->wwwroot.'/group/groupings.php?id='.$courseid, 'type'=>'misc'), 106 array('name'=>$strheading, 'link'=>'', 'type'=>'misc')); 107 $navigation = build_navigation($navlinks); 108 109 /// Print header 110 print_header_simple($strgroupings, ': '.$strgroupings, $navigation, '', '', true, '', navmenu($course)); 111 112 113 print_heading($strheading); 114 $editform->display(); 115 print_footer($course); 116 117 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |