Skip to content

Commit

Permalink
MDL-14627 new mod/folder:view capability
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Oct 14, 2010
1 parent 848fe20 commit 9093de6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions mod/folder/db/access.php
Expand Up @@ -27,6 +27,15 @@
defined('MOODLE_INTERNAL') || die();

$capabilities = array(
'mod/folder:view' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'guest' => CAP_ALLOW,
'user' => CAP_ALLOW,
)
),

/* TODO: review public portfolio API first!
'mod/folder:portfolioexport' => array(
Expand Down
1 change: 1 addition & 0 deletions mod/folder/lang/en/folder.php
Expand Up @@ -26,6 +26,7 @@

$string['contentheader'] = 'Content';
$string['folder:managefiles'] = 'Manage files in folder module';
$string['folder:view'] = 'View folder content';
$string['foldercontent'] = 'Files and subfolders';
$string['modulename'] = 'Folder';
$string['modulenameplural'] = 'Folders';
Expand Down
3 changes: 3 additions & 0 deletions mod/folder/lib.php
Expand Up @@ -289,6 +289,9 @@ function folder_pluginfile($course, $cm, $context, $filearea, $args, $forcedownl
}

require_course_login($course, true, $cm);
if (!has_capability('mod/folder:view', $context)) {
return false;
}

if ($filearea !== 'content') {
// intro is handled automatically in pluginfile.php
Expand Down
2 changes: 1 addition & 1 deletion mod/folder/version.php
Expand Up @@ -26,7 +26,7 @@

defined('MOODLE_INTERNAL') || die();

$module->version = 2010080300;
$module->version = 2010101400;
$module->requires = 2010080300; // Requires this Moodle version
$module->cron = 0;

1 change: 1 addition & 0 deletions mod/folder/view.php
Expand Up @@ -45,6 +45,7 @@

require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/folder:view', $context);

add_to_log($course->id, 'folder', 'view', 'view.php?id='.$cm->id, $folder->id, $cm->id);

Expand Down

0 comments on commit 9093de6

Please sign in to comment.