From 6b5a9b83241731d65001b691ab910d8f42af7874 Mon Sep 17 00:00:00 2001 From: Michael Milette Date: Thu, 2 Jul 2020 22:14:59 -0400 Subject: [PATCH] Added new {diskfreespacedata} tag. --- CHANGELOG.md | 1 + README.md | 4 +++- filter.php | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed1c7d9..8d95b54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. ### Added - New configurable setting to enable/disable escaped [{braces}] (e.g. for creating documentation). Default is enabled. - You can now escape tags so they are not processed by wrapping them in [{brackets}]. {{double-braces}} are no longer supported. +- New {diskfreespacedata} tag. - New {diskfreespace} tag. - New {help}{/help} tags. - New {info}{/info} tags. diff --git a/README.md b/README.md index 7ba23b9..adf5846 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ Moodle metadata filters * {courseimage} : Display's the course image. * {courseparticipantcount} : Displays the number of students enrolled in the current course. * {diskfreespace} : Display amount of free disk space for application folder. +* {diskfreespacedata} : Display amount of free disk space for moodledata folder. * {mycourses} : Display an unordered list of links to all my enrolled courses. * {mycoursesmenu} : A second level list of courses with links for use in custom menus (filtering must be supported by the theme). * {categoryid} : If in a course, the ID of the course's parent category, the category ID of a course category page, otherwise 0. @@ -507,7 +508,8 @@ Create a Page on your Moodle site and include the following code: * Course custom fields [{coursefields}]: {coursefields} * Section ID [{sectionid}]: {sectionid} * Section ID (encoded) [%7Bsectionid%7D]: %7Bsectionid%7D -* Available free disk space [{diskfreespace}]: {diskfreespace} +* Available free application disk space [{diskfreespace}]: {diskfreespace} +* Available free moodledata disk space [{diskfreespacedata}]: {diskfreespacedata} * My Enrolled Courses [{mycourses}]: {mycourses} * My Enrolled Courses menu [{mycoursesmenu}]: {mycoursesmenu} * Course category ID (0 if not in a course or category list of course) [{categoryid}]: {categoryid} diff --git a/filter.php b/filter.php index 1f174be..4da6397 100644 --- a/filter.php +++ b/filter.php @@ -520,11 +520,16 @@ function ($matches) { } } - // Tag: {diskfreespace}. + // Tag: {diskfreespace} - free space of Moodle application volume. if (stripos($text, '{diskfreespace}') !== false) { $replace['/\{diskfreespace\}/i'] = display_size(disk_free_space('.')); } + // Tag: {diskfreespacedata} - free space of Moodledata volume. + if (stripos($text, '{diskfreespacedata}') !== false) { + $replace['/\{diskfreespacedata\}/i'] = display_size(disk_free_space($CFG->dataroot)); + } + // Any {user*} tags. if (stripos($text, '{user') !== false) {