diff --git a/mod/page/db/access.php b/mod/page/db/access.php index 6c773e662e4..debd91f6864 100644 --- a/mod/page/db/access.php +++ b/mod/page/db/access.php @@ -27,6 +27,15 @@ defined('MOODLE_INTERNAL') || die; $capabilities = array( + 'mod/page:view' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_MODULE, + 'archetypes' => array( + 'guest' => CAP_ALLOW, + 'user' => CAP_ALLOW, + ) + ), + /* TODO: review public portfolio API first! 'mod/page:portfolioexport' => array( diff --git a/mod/page/lang/en/page.php b/mod/page/lang/en/page.php index 692cff4bccc..341a8ae5d77 100644 --- a/mod/page/lang/en/page.php +++ b/mod/page/lang/en/page.php @@ -37,6 +37,7 @@ $string['modulename_help'] = 'A page enables a web page to be displayed and edit $string['modulenameplural'] = 'Pages'; $string['neverseen'] = 'Never seen'; $string['optionsheader'] = 'Options'; +$string['page:view'] = 'View page content'; $string['pluginadministration'] = 'Page module administration'; $string['pluginname'] = 'Page'; $string['popupheight'] = 'Popup height (in pixels)'; diff --git a/mod/page/lib.php b/mod/page/lib.php index cc1f7074fd4..ce8aef1f278 100644 --- a/mod/page/lib.php +++ b/mod/page/lib.php @@ -351,6 +351,9 @@ function page_pluginfile($course, $cm, $context, $filearea, $args, $forcedownloa } require_course_login($course, true, $cm); + if (!has_capability('mod/page:view', $context)) { + return false; + } if ($filearea !== 'content') { // intro is handled automatically in pluginfile.php diff --git a/mod/page/version.php b/mod/page/version.php index d0bd5cef2ed..4a557ce46d6 100644 --- a/mod/page/version.php +++ b/mod/page/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die; -$module->version = 2010080300; +$module->version = 2010101400; $module->requires = 2010080300; // Requires this Moodle version $module->cron = 0; diff --git a/mod/page/view.php b/mod/page/view.php index 9c69f9c1223..8b888dd4bf7 100644 --- a/mod/page/view.php +++ b/mod/page/view.php @@ -48,6 +48,7 @@ $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); require_course_login($course, true, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); +require_capability('mod/page:view', $context); add_to_log($course->id, 'page', 'view', 'view.php?id='.$cm->id, $page->id, $cm->id);