You are here

function _mail_edit_key_registry_rebuild in Mail Editor 6

Same name and namespace in other branches
  1. 7 mail_edit.admin.inc \_mail_edit_key_registry_rebuild()

Builds the registry of exposed mailkeys, keeps track of which module exposed them.

Return value

unknown

1 call to _mail_edit_key_registry_rebuild()
mail_edit_list_filtered_form in ./mail_edit.admin.inc
Create $form array with filtered list.

File

./mail_edit.admin.inc, line 510
Administrative interface for the Mail Editor module.

Code

function _mail_edit_key_registry_rebuild() {

  // Fetch exposed mailkeys.
  $hook = 'mailkeys';
  $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 = "SELECT * FROM {mail_edit_registry}";
  $result = db_query($query);
  while ($row = db_fetch_object($result)) {
    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) {
      $query = "INSERT INTO {mail_edit_registry} (id, module, mailkey, description) VALUES ('%s', '%s', '%s', '%s')";
      db_query($query, $module . '_' . $key, $module, $key, $description);
    }
  }
}