Skip to content

Commit

Permalink
Added some consistency with the show/hide feature in Moodle.
Browse files Browse the repository at this point in the history
Now if the course is hidden or the activity is hidden, only
teachers cand download the feed.
  • Loading branch information
stronk7 committed May 9, 2004
1 parent ca87cbe commit c0f778a
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions rss/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// course: the course id
// user: the user id
// name: the name of the module (forum...)
// id: the id of the module (forumid...)
// id: the id (instance) of the module (forumid...)
//If the course has a password or it doesn't
//allow guest access then the user field is
//required to see that the user is enrolled
Expand Down Expand Up @@ -45,16 +45,34 @@
}

$courseid = (integer)$args[0];
$userid = (integer)$args[1];
$modulename = $args[2];
$instance = (integer)$args[3];

if (! $course = get_record("course", "id", $courseid)) {
$error = true;
}

//Get course_module to check it's visible
if (! $cm = get_coursemodule_from_instance($modulename,$instance,$courseid)) {
$error = true;
}
$cmvisible = $cm->visible;

$isstudent = isstudent($courseid,$userid);
$isteacher = isteacher($courseid,$userid);

//Check for "security" if !course->guest or course->password
if (!$course->guest || $course->password) {
$allowed = (isstudent($course->id,$args[1]) || isteacher($course->id,$args[1]));
$allowed = ($isstudent || $isteacher);
}

//Check for "security" if the course is hidden or the activity is hidden
if ($allowed && (!$course->visible || !$cmvisible)) {
$allowed = $isteacher;
}

$pathname = $CFG->dataroot."/rss/".$args[2]."/".$args[3].".xml";
$pathname = $CFG->dataroot."/rss/".$modulename."/".$instance.".xml";
$filename = $args[$numargs-1];

//If the file exists and its allowed for me, download it!
Expand Down

0 comments on commit c0f778a

Please sign in to comment.