MDL-23302 Credit to Aparup. New cap moodle/user:manageownfiles to control private user files area

This commit is contained in:
Martin Dougiamas 2010-07-22 09:05:13 +00:00
parent a2580005a5
commit e4f413b4b3
4 changed files with 19 additions and 4 deletions

View file

@ -60,7 +60,9 @@ class block_private_files extends block_base {
$renderer = $this->page->get_renderer('block_private_files'); $renderer = $this->page->get_renderer('block_private_files');
$this->content->text = $renderer->private_files_tree(); $this->content->text = $renderer->private_files_tree();
if (has_capability('moodle/user:manageownfiles', $this->context)) {
$this->content->text .= $OUTPUT->single_button(new moodle_url('/user/filesedit.php'), get_string('myfilesmanage'), 'get'); $this->content->text .= $OUTPUT->single_button(new moodle_url('/user/filesedit.php'), get_string('myfilesmanage'), 'get');
}
$this->content->footer = ''; $this->content->footer = '';
} }

View file

@ -353,6 +353,7 @@ $string['user:editprofile'] = 'Edit user profile';
$string['user:loginas'] = 'Login as other users'; $string['user:loginas'] = 'Login as other users';
$string['user:manageblocks'] = 'Manage blocks on user profile of other users'; $string['user:manageblocks'] = 'Manage blocks on user profile of other users';
$string['user:manageownblocks'] = 'Manage blocks on own public user profile'; $string['user:manageownblocks'] = 'Manage blocks on own public user profile';
$string['user:manageownfiles'] = 'Manage files on own private file areas';
$string['user:managesyspages'] = 'Configure default page layout for public user profiles'; $string['user:managesyspages'] = 'Configure default page layout for public user profiles';
$string['user:readuserblogs'] = 'See all user blogs'; $string['user:readuserblogs'] = 'See all user blogs';
$string['user:readuserposts'] = 'See all user posts'; $string['user:readuserposts'] = 'See all user posts';

View file

@ -522,7 +522,19 @@ $capabilities = array(
'captype' => 'write', 'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM, 'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array( 'archetypes' => array(
'user' => CAP_ALLOW, 'user' => CAP_ALLOW
)
),
// can the user manage their own files?
'moodle/user:manageownfiles' => array(
'riskbitmap' => RISK_SPAM | RISK_PERSONAL,
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'user' => CAP_ALLOW
) )
), ),

View file

@ -31,9 +31,9 @@ require_login();
if (isguestuser()) { if (isguestuser()) {
die(); die();
} }
//TODO: add capability check here!
$context = get_context_instance(CONTEXT_USER, $USER->id); $context = get_context_instance(CONTEXT_USER, $USER->id);
require_capability('moodle/user:manageownfiles', $context);
$title = get_string('myfiles'); $title = get_string('myfiles');
$struser = get_string('user'); $struser = get_string('user');