function _mail_edit_key_registry_rebuild in Mail Editor 7
Same name and namespace in other branches
- 6 mail_edit.admin.inc \_mail_edit_key_registry_rebuild()
Builds the registry of exposed mailkeys, keeps track of which module exposed them.
This function uses the cache system to control when it needs actual rebuilding. It returns immediately, of the general cache has not been cleared, so we can call it everytime before reading the registry.
Return value
void
4 calls to _mail_edit_key_registry_rebuild()
- mail_edit_list_filter in ./
mail_edit.admin.inc - Filter the mail_edit table.
- mail_edit_list_filtered_form in ./
mail_edit.admin.inc - Create $form array with filtered list.
- _mail_edit_load in ./
mail_edit.alter.inc - Loads and returns a template.
- _mail_edit_modules_uninstalled in ./
mail_edit.admin.inc - Implements hook_modules_uninstalled().
File
- ./
mail_edit.admin.inc, line 620 - Administrative interface for the Mail Editor module.
Code
function _mail_edit_key_registry_rebuild() {
if (cache_get('mail_edit_registry')) {
return;
}
// Fetch exposed mailkeys.
$hook = 'mailkeys';
_mail_edit_include();
module_implements($hook, FALSE, TRUE);
$mailkeys = array();
foreach (module_implements($hook) as $module) {
$function = $module . '_' . $hook;
$result = $function();
if (isset($result)) {
$mailkeys[$module] = $result;
}
}
// Find out if we already have record of the exposed keys.
$query = db_select('mail_edit_registry', 'mer')
->fields('mer');
foreach ($query
->execute() as $row) {
if (isset($mailkeys[$row->module][$row->mailkey])) {
unset($mailkeys[$row->module][$row->mailkey]);
}
}
// Insert any new mailkeys into our registry table.
foreach ($mailkeys as $module => $keys) {
foreach ($keys as $key => $description) {
db_insert('mail_edit_registry')
->fields(array(
'id' => $module . '_' . $key,
'module' => $module,
'mailkey' => $key,
'description' => $description,
))
->execute();
}
}
cache_set('mail_edit_registry', TRUE, 'cache', CACHE_TEMPORARY);
}