MDL-74584 course: New optional parameter in get_module_types_names()

Adds new parameter in get_module_types_names() to optionally reset
the $modnames static cache.
This commit is contained in:
Mihail Geshoski
2022-05-06 14:39:06 +08:00
parent c23b67be46
commit 90f517cf1f
+3 -2
View File
@@ -391,12 +391,13 @@ function course_integrity_check($courseid, $rawmods = null, $sections = null, $f
* and the value is a lang_string object with a human-readable string.
*
* @param bool $plural If true, the function returns the plural forms of the names.
* @param bool $resetcache If true, the static cache will be reset
* @return lang_string[] Localised human-readable names of all used modules.
*/
function get_module_types_names($plural = false) {
function get_module_types_names($plural = false, $resetcache = false) {
static $modnames = null;
global $DB, $CFG;
if ($modnames === null) {
if ($modnames === null || $resetcache) {
$modnames = array(0 => array(), 1 => array());
if ($allmods = $DB->get_records("modules")) {
foreach ($allmods as $mod) {