Fix for bug 2578:

Editing teachers for the site can now add global events.
This was previously limited to admins only.
This commit is contained in:
defacer 2005-02-18 01:37:56 +00:00
parent 6c40f0dc2a
commit bb8392589b
2 changed files with 2 additions and 14 deletions

View File

@ -539,24 +539,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($USER->id);
$allowed->site = isteacheredit(SITEID);
if(!empty($SESSION->cal_course_referer) && $SESSION->cal_course_referer != SITEID && isteacheredit($SESSION->cal_course_referer, $USER->id)) {
$allowed->courses = array($SESSION->cal_course_referer => 1);
$allowed->groups = get_groups($SESSION->cal_course_referer);
}
//[pj]: This was used when we wanted to display all legal choices
/*
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)).')');
}
*/
}
?>

View File

@ -1067,7 +1067,7 @@ function calendar_edit_event_allowed($event) {
if (isadmin($USER->id)) return true; // Admins are allowed anything
if ($event->courseid != 0 && $event->courseid != SITEID) {
if ($event->courseid != 0) {
// Course event, only editing teachers may... edit :P
if(isteacheredit($event->courseid)) {
return true;