You are here

function notifications_custom_rebuild in Notifications 6.4

Same name and namespace in other branches
  1. 6 notifications_custom/notifications_custom.module \notifications_custom_rebuild()

Rebuild list of custom subscriptions from modules and the database

2 calls to notifications_custom_rebuild()
notifications_custom_admin_page in notifications_custom/notifications_custom.admin.inc
Page callback, administer custom subscriptions
notifications_custom_form_submit in notifications_custom/notifications_custom.admin.inc
Form submission for custom subscriptions form

File

notifications_custom/notifications_custom.module, line 292
Custom notifications module

Code

function notifications_custom_rebuild() {
  $custom = array();
  $result = db_query("SELECT * FROM {notifications_custom}");
  while ($subs = db_fetch_object($result)) {
    $custom[$subs->type] = $subs;
  }

  // Get custom subscriptions defined by modules and merge with the ones in db
  $modules = notifications_info('custom subscriptions');
  foreach ($modules as $type => $subs) {
    if (empty($custom[$type])) {
      $subs = (object) $subs;
      $subs->type = $type;
      drupal_write_record('notifications_custom', $subs);
      $custom[$type] = $subs;
    }
  }
}