MDL-67060 core_h5p: Improvements to Manage H5P setting page

Co-authored by: Adrian Greeve <[email protected]>

AMOS BEGIN
 CPY [description,moodle],[description,core_h5p]
 CPY [status,moodle],[status,core_h5p]
AMOS END
This commit is contained in:
Amaia Anabitarte
2020-02-11 10:26:57 +01:00
parent d3ee08dba3
commit 4e7a035f68
9 changed files with 284 additions and 1 deletions
+29
View File
@@ -709,6 +709,35 @@ function filter_set_global_state($filtername, $state, $move = 0) {
$transaction->allow_commit();
}
/**
* Returns the active state for a filter in the given context.
*
* @param string $filtername The filter name, for example 'tex'.
* @param integer $contextid The id of the context to get the data for.
* @return int value of active field for the given filter.
*/
function filter_get_active_state(string $filtername, $contextid = null): int {
global $DB;
if ($contextid === null) {
$contextid = context_system::instance()->id;
}
if (is_object($contextid)) {
$contextid = $contextid->id;
}
if (strpos($filtername, 'filter/') === 0) {
$filtername = substr($filtername, 7);
} else if (strpos($filtername, '/') !== false) {
throw new coding_exception("Invalid filter name '$filtername' used in filter_is_enabled()");
}
if ($active = $DB->get_field('filter_active', 'active', array('filter' => $filtername, 'contextid' => $contextid))) {
return $active;
}
return TEXTFILTER_DISABLED;
}
/**
* @param string $filtername The filter name, for example 'tex'.
* @return boolean is this filter allowed to be used on this site. That is, the