From 380c122fe2ab4d3b44b688dbf18ab21109d5e5ad Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Wed, 31 Oct 2012 15:48:43 +0800 Subject: [PATCH] MDL-33766 files: Capability to ignore userquota --- lib/db/access.php | 9 +++++++++ user/files.php | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/db/access.php b/lib/db/access.php index 297083ade9b..1ad3a5817d9 100644 --- a/lib/db/access.php +++ b/lib/db/access.php @@ -574,6 +574,15 @@ $capabilities = array( ) ), + // Can the user ignore the setting userquota? + // The permissions are cloned from ignorefilesizelimits as it was partly used for that purpose. + 'moodle/user:ignoreuserquota' => array( + 'riskbitmap' => RISK_SPAM, + 'captype' => 'write', + 'contextlevel' => CONTEXT_SYSTEM, + 'clonepermissionsfrom' => 'moodle/course:ignorefilesizelimits' + ), + // can the user manage the system default dashboard page? 'moodle/my:configsyspages' => array( diff --git a/user/files.php b/user/files.php index be694b5de9f..fa85a64bcf9 100644 --- a/user/files.php +++ b/user/files.php @@ -51,10 +51,15 @@ $PAGE->set_heading($title); $PAGE->set_pagelayout('mydashboard'); $PAGE->set_pagetype('user-files'); +$maxareabytes = $CFG->userquota; +if (has_capability('moodle/user:ignoreuserquota', $context)) { + $maxareabytes = -1; +} + $data = new stdClass(); $data->returnurl = $returnurl; $options = array('subdirs' => 1, 'maxbytes' => $CFG->userquota, 'maxfiles' => -1, 'accepted_types' => '*', - 'areamaxbytes' => $CFG->userquota); + 'areamaxbytes' => $maxareabytes); file_prepare_standard_filemanager($data, 'files', $options, $context, 'user', 'private', 0); $mform = new user_files_form(null, array('data'=>$data, 'options'=>$options));