Admins can now filter events by course and set events for groups and courses

regardless of whether they are course members.
This commit is contained in:
defacer 2004-04-20 09:21:30 +00:00
parent 6c127628a7
commit 1f695119c5
3 changed files with 18 additions and 5 deletions

View File

@ -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)).')');
}

View File

@ -1,5 +1,5 @@
<table class="formtable">
<form method="post" action="event.php" name="edit">
<form method="post" action="event.php">
<p>
<input type="hidden" name="action" value="new" />
<input type="hidden" name="timestart" value="<?php echo $form->timestart; ?>" />
@ -26,7 +26,7 @@
<select name='courseid'>
<option value=''></option>
<?php foreach($allowed->courses as $course) {?>
<option value='<?php echo $course->id?>' <?php if($course->id == $courseid) echo 'selected="selected"';?>><?php echo $course->fullname?></option>
<option value='<?php echo $course->id?>' <?php if($course->id == $courseid) echo 'selected="selected"';?>><?php echo $course->shortname.' - '.$course->fullname?></option>
<?php }?>
</select>
</div>

View File

@ -549,7 +549,12 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
}
echo 'style="width: 8px;"></td><td><strong>'.get_string('courseevents', 'calendar').':</strong> ';
$coursesdata = get_my_courses($USER->id);
if(isadmin($USER->id)) {
$coursesdata = get_courses('all', 'c.shortname');
}
else {
$coursesdata = get_my_courses($USER->id);
}
$coursesdata = array_diff_assoc($coursesdata, array(1 => 1));
echo '<select name="course" onchange="document.location.href=\''.CALENDAR_URL.'set.php?var=setcourse&amp;'.$getvars.'&amp;id=\' + this.value;">';