Permalink
Browse files

completing access policy with course state examination

  • Loading branch information...
diml
diml committed Dec 27, 2008
1 parent 0f2f336 commit 85203af7a39570f4636060274cf3131a05a878bf
Showing with 11 additions and 0 deletions.
  1. +11 −0 search/documents/resource_document.php
@@ -307,6 +307,17 @@ function resource_check_text_access($path, $itemtype, $this_id, $user, $group_id
$r = get_record('resource', 'id', $this_id);
$module_context = get_record('context', 'id', $context_id);
$cm = get_record('course_modules', 'id', $module_context->instanceid);
+ $course_context = get_context_instance(CONTEXT_COURSE, $r->course);
+
+ //check if course is visible
+ if (!$course->visible && !has_capability('moodle/course:viewhiddencourses', $course_context)) {
+ return false;
+ }
+
+ //check if user is registered in course or course is open to guests
+ if (!$course->guest && !has_capability('moodle/course:view', $course_context)) {
+ return false;
+ }
//check if found course module is visible
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $module_context)){

0 comments on commit 85203af

Please sign in to comment.