function _customfilter_get_rules in Custom filter 7
Same name and namespace in other branches
- 6.2 customfilter.module \_customfilter_get_rules()
- 6 customfilter.module \_customfilter_get_rules()
- 7.2 customfilter.module \_customfilter_get_rules()
Retrieve the replacement rules for a specific filter.
Parameters
$fid: The filter ID.
$root: The root rule.
$nocache: If FALSE, the function will get the rules from the cache table, if there are any.
Return value
An array of rules, which include any subrules.
2 calls to _customfilter_get_rules()
- customfilter_rules_form in ./
customfilter.module - Return the list of replacement rules form.
- _customfilter_filter_process in ./
customfilter.module - Process the text, apply the filters
File
- ./
customfilter.module, line 441 - Allows the users with the right permission to define custom filters.
Code
function _customfilter_get_rules($fid, $root = 0, $nocache = FALSE) {
if (!$nocache && ($cache = cache_get("rules:{$fid}:{$root}", 'cache_customfilter'))) {
$rules = $cache->data;
}
else {
$rules = array();
$result = db_query("SELECT * FROM {customfilter_rule} WHERE fid = :fid and prid = :prid ORDER BY weight", array(
':fid' => $fid,
':prid' => $root,
));
while ($rule = $result
->fetchAssoc()) {
$rule['sub'] = _customfilter_get_rules($fid, $rule['rid'], TRUE);
$rules[$rule['rid']] = $rule;
}
if (!$nocache) {
cache_set("rules:{$fid}:{$root}", $rules, 'cache_customfilter');
}
}
return $rules;
}