filters: MDL-7336 backup and restore of local filter settings.

This commit is contained in:
tjhunt
2009-04-13 07:06:02 +00:00
parent c9a2ecfa1b
commit 34f07866ba
3 changed files with 163 additions and 0 deletions
+27
View File
@@ -586,6 +586,23 @@ function filter_get_local_config($filter, $contextid) {
return $DB->get_records_menu('filter_config', array('filter' => $filter, 'contextid' => $contextid), '', 'name,value');
}
/**
* This function is for use by backup. Gets all the filter information specific
* to one context.
* @return array with two elements. The first element is an array of objects with
* fields filter and active. These come from the filter_active table. The
* second element is an array of objects with fields filter, name and value
* from the filter_config table.
*/
function filter_get_all_local_settings($contextid) {
global $DB;
$context = get_context_instance(CONTEXT_SYSTEM);
return array(
$DB->get_records('filter_active', array('contextid' => $contextid), 'filter', 'filter,active'),
$DB->get_records('filter_config', array('contextid' => $contextid), 'filter,name', 'filter,name,value'),
);
}
/**
* Get the list of active filters, in the order that they should be used
* for a particular context, along with any local configuration variables.
@@ -670,6 +687,16 @@ function filter_has_global_settings($filter) {
return is_readable($settingspath);
}
/**
* Certain types of context (block and user) may not have local filter settings.
* the function checks a context to see whether it may have local config.
* @param object $context a context.
* @return boolean whether this context may have local filter settings.
*/
function filter_context_may_have_filter_settings($context) {
return $context->contextlevel != CONTEXT_BLOCK && $context->contextlevel != CONTEXT_USER;
}
/**
* Process phrases intelligently found within a HTML text (such as adding links)
*