Permalink
Browse files

On the front page, if the user is logged in then the calendar blocks

now only show events from their own courses.   bug 1957.
  • Loading branch information...
1 parent f8ab1da commit 1cca75d2573259e760b02e239504cc3fe23c2538 moodler committed Sep 18, 2004
@@ -32,12 +32,22 @@ function get_content() {
$courseshown = $this->course->id;
- if($this->course->id == SITEID) {
- // Being displayed at site level. This will cause the filter to fall back to auto-detecting
- // the list of courses it will be grabbing events from.
- $filtercourse = NULL;
- }
- else {
+ if ($this->course->id == SITEID) { // Site-level calendar
+ if (!empty($USER) and !isadmin()) { /// Normal users just see their own courses
+ if (!empty($USER->student)) {
+ foreach ($USER->student as $courseid => $info) {
+ $filtercourse[$courseid] = 1;
+ }
+ }
+ if (!empty($USER->teacher)) {
+ foreach ($USER->teacher as $courseid => $info) {
+ $filtercourse[$courseid] = 1;
+ }
+ }
+ } else { /// Let the filter sort it out for admins and guests
+ $filtercourse = NULL;
+ }
+ } else {
// Forcibly filter events to include only those from the particular course we are in.
$filtercourse = array($courseshown => 1);
}
@@ -38,10 +38,22 @@ function get_content() {
'/calendar/event.php?action=new&course='.$this->course->id.'">'.
get_string('newevent', 'calendar').'</a>...';
- if($this->course->id == SITEID) {
- // Being displayed at site level. This will cause the filter to fall back to auto-detecting
- // the list of courses it will be grabbing events from.
- $filtercourse = NULL;
+ if($this->course->id == SITEID) { // Being displayed at site level.
+
+ if (!empty($USER) and !isadmin()) { /// Normal users just see their own courses
+ if (!empty($USER->student)) {
+ foreach ($USER->student as $courseid => $info) {
+ $filtercourse[$courseid] = 1;
+ }
+ }
+ if (!empty($USER->teacher)) {
+ foreach ($USER->teacher as $courseid => $info) {
+ $filtercourse[$courseid] = 1;
+ }
+ }
+ } else { /// Let the filter sort it out for admins and guests
+ $filtercourse = NULL;
+ }
}
else {
// Forcibly filter events to include only those from the particular course we are in.

0 comments on commit 1cca75d

Please sign in to comment.