diff --git a/calendar/event.php b/calendar/event.php index bd20ffae2e5..c35c4e3e07e 100644 --- a/calendar/event.php +++ b/calendar/event.php @@ -411,6 +411,10 @@ print_side_block_start(get_string('newevent', 'calendar').$header, '', 'mycalendar'); if($_REQUEST['type'] == 'select') { + optional_variable($_REQUEST['groupid']); + optional_variable($_REQUEST['courseid']); + $groupid = $_REQUEST['groupid']; + $courseid = $_REQUEST['courseid']; include('event_select.html'); } else { @@ -477,8 +481,12 @@ function calendar_get_allowed_types(&$allowed) { $allowed->user = true; // User events always allowed $allowed->groups = false; // This may change just below $allowed->courses = false; // This may change just below - $allowed->site = isadmin(); - if(!empty($USER->teacheredit)) { + $allowed->site = isadmin($USER->id); + if($allowed->site) { + $allowed->courses = get_courses('all', 'c.shortname'); + $allowed->groups = get_records_sql('SELECT g.*, c.fullname FROM '.$CFG->prefix.'groups g LEFT JOIN '.$CFG->prefix.'course c ON g.courseid = c.id ORDER BY c.shortname'); + } + else if(!empty($USER->teacheredit)) { $allowed->courses = get_records_select('course', 'id != 1 AND id IN ('.implode(',', array_keys($USER->teacheredit)).')'); $allowed->groups = get_records_sql('SELECT g.*, c.fullname FROM '.$CFG->prefix.'groups g LEFT JOIN '.$CFG->prefix.'course c ON g.courseid = c.id WHERE g.courseid IN ('.implode(',', array_keys($USER->teacheredit)).')'); } diff --git a/calendar/event_select.html b/calendar/event_select.html index 076c482e1f3..15a9fe942c8 100644 --- a/calendar/event_select.html +++ b/calendar/event_select.html @@ -1,5 +1,5 @@