From b5ef326c03a3252f4b47184042e4acdf947ebd0f Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Tue, 13 Jun 2017 13:01:33 +0100 Subject: [PATCH] MDL-26976 files: Display space usage message in private files --- lang/en/moodle.php | 1 + user/files.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 07e154d24c6..cb129061a1a 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1505,6 +1505,7 @@ $string['publicsitefileswarning3'] = 'Note: Files placed here can be accessed by $string['publish'] = 'Publish'; $string['question'] = 'Question'; $string['questionsinthequestionbank'] = 'Questions in the question bank'; +$string['quotausage'] = 'You have currently used {$a->used} of your {$a->total} limit.'; $string['readinginfofrombackup'] = 'Reading info from backup'; $string['readme'] = 'README'; $string['recentactivity'] = 'Recent activity'; diff --git a/user/files.php b/user/files.php index 32c99f4f244..dadaf619d94 100644 --- a/user/files.php +++ b/user/files.php @@ -82,6 +82,20 @@ if ($mform->is_cancelled()) { echo $OUTPUT->header(); echo $OUTPUT->box_start('generalbox'); +// Show file area space usage. +if ($maxareabytes != FILE_AREA_MAX_BYTES_UNLIMITED) { + $fileareainfo = file_get_file_area_info($context->id, 'user', 'private'); + // Display message only if we have files. + if ($fileareainfo['filecount']) { + $a = (object) [ + 'used' => display_size($fileareainfo['filesize_without_references']), + 'total' => display_size($maxareabytes) + ]; + $quotamsg = get_string('quotausage', 'moodle', $a); + $notification = new \core\output\notification($quotamsg, \core\output\notification::NOTIFY_INFO); + echo $OUTPUT->render($notification); + } +} $mform->display(); echo $OUTPUT->box_end(); -- 2.17.1