You are here

function notifications_scheduler_admin_action_list in Notifications 7

Compile scheduled actions by action key

1 call to notifications_scheduler_admin_action_list()
notifications_scheduler_admin_form in notifications_scheduler/notifications_scheduler.admin.inc
Event configuration administration

File

notifications_scheduler/notifications_scheduler.admin.inc, line 139

Code

function notifications_scheduler_admin_action_list() {
  $list = array();
  foreach (notifications_event_type() as $typekey => $event_info) {
    if (!empty($event_info['scheduler'])) {
      foreach ($event_info['actions'] as $callback) {
        if ($actions = db_select('actions', 'a')
          ->fields('a')
          ->condition('callback', $callback)
          ->execute()
          ->fetchAll()) {
          foreach ($actions as $action) {
            $list[$action->aid] = (array) $action + array(
              'triggers' => array(),
              'template' => $event_info['template'],
              'event_key' => $typekey,
            );
          }
        }
      }
    }
  }
  if ($list) {

    // Compile trigger info indexed by hook
    $trigger_info = array();
    foreach (module_invoke_all('trigger_info') as $trigger_type => $type_info) {
      foreach ($type_info as $hook => $hook_info) {
        $trigger_info[$hook] = $hook_info['label'];
      }
    }
    $query = db_select('trigger_assignments', 't')
      ->fields('t')
      ->condition('aid', array_keys($list))
      ->execute();
    foreach ($query
      ->fetchAll() as $trigger) {
      $list[$trigger->aid]['triggers'][$trigger->hook] = $trigger_info[$trigger->hook];
    }
  }
  return $list;
}