| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Create group OR edit group 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 12 require_once ('../config.php'); 13 require_once ('lib.php'); 14 require_once ('group_form.php'); 15 16 /// get url variables 17 $courseid = optional_param('courseid', 0, PARAM_INT); 18 $id = optional_param('id', 0, PARAM_INT); 19 $delete = optional_param('delete', 0, PARAM_BOOL); 20 $confirm = optional_param('confirm', 0, PARAM_BOOL); 21 22 if ($id) { 23 if (!$group = get_record('groups', 'id', $id)) { 24 error('Group ID was incorrect'); 25 } 26 $group->description = clean_text($group->description); 27 if (empty($courseid)) { 28 $courseid = $group->courseid; 29 30 } else if ($courseid != $group->courseid) { 31 error('Course ID was incorrect'); 32 } 33 34 if (!$course = get_record('course', 'id', $courseid)) { 35 error('Course ID was incorrect'); 36 } 37 38 } else { 39 if (!$course = get_record('course', 'id', $courseid)) { 40 error('Course ID was incorrect'); 41 } 42 $group = new object(); 43 $group->courseid = $course->id; 44 } 45 46 require_login($course); 47 $context = get_context_instance(CONTEXT_COURSE, $course->id); 48 require_capability('moodle/course:managegroups', $context); 49 50 $returnurl = $CFG->wwwroot.'/group/index.php?id='.$course->id.'&group='.$id; 51 52 if ($id and $delete) { 53 if (!$confirm) { 54 print_header(get_string('deleteselectedgroup', 'group'), get_string('deleteselectedgroup', 'group')); 55 $optionsyes = array('id'=>$id, 'delete'=>1, 'courseid'=>$courseid, 'sesskey'=>sesskey(), 'confirm'=>1); 56 $optionsno = array('id'=>$courseid); 57 notice_yesno(get_string('deletegroupconfirm', 'group', $group->name), 'group.php', 'index.php', $optionsyes, $optionsno, 'get', 'get'); 58 print_footer(); 59 die; 60 61 } else if (confirm_sesskey()){ 62 if (groups_delete_group($id)) { 63 redirect('index.php?id='.$course->id); 64 } else { 65 print_error('erroreditgroup', 'group', $returnurl); 66 } 67 } 68 } 69 70 /// First create the form 71 $editform = new group_form(); 72 $editform->set_data($group); 73 74 if ($editform->is_cancelled()) { 75 redirect($returnurl); 76 77 } elseif ($data = $editform->get_data()) { 78 79 if ($data->id) { 80 if (!groups_update_group($data, $editform->_upload_manager)) { 81 error('Error updating group'); 82 } 83 } else { 84 if (!$id = groups_create_group($data, $editform->_upload_manager)) { 85 error('Error creating group'); 86 } 87 $returnurl = $CFG->wwwroot.'/group/index.php?id='.$course->id.'&group='.$id; 88 } 89 90 redirect($returnurl); 91 } 92 93 $strgroups = get_string('groups'); 94 $strparticipants = get_string('participants'); 95 96 if ($id) { 97 $strheading = get_string('editgroupsettings', 'group'); 98 } else { 99 $strheading = get_string('creategroup', 'group'); 100 } 101 102 103 $navlinks = array(array('name'=>$strparticipants, 'link'=>$CFG->wwwroot.'/user/index.php?id='.$courseid, 'type'=>'misc'), 104 array('name'=>$strgroups, 'link'=>$CFG->wwwroot.'/group/index.php?id='.$courseid, 'type'=>'misc'), 105 array('name'=>$strheading, 'link'=>'', 'type'=>'misc')); 106 $navigation = build_navigation($navlinks); 107 108 /// Print header 109 print_header_simple($strgroups, ': '.$strgroups, $navigation, '', '', true, '', navmenu($course)); 110 111 echo '<div id="grouppicture">'; 112 if ($id) { 113 print_group_picture($group, $course->id); 114 } 115 echo '</div>'; 116 $editform->display(); 117 print_footer($course); 118 ?>
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 |