You are here

function notifications_ui_notifications in Notifications 5

Same name and namespace in other branches
  1. 6 notifications_ui/notifications_ui.module \notifications_ui_notifications()
  2. 6.2 notifications_ui/notifications_ui.module \notifications_ui_notifications()
  3. 6.3 notifications_ui/notifications_ui.module \notifications_ui_notifications()
  4. 7 notifications_ui/notifications_ui.module \notifications_ui_notifications()

Implementation of hook_notifications.

File

notifications_ui/notifications_ui.module, line 43
User Interface for subscriptions modules

Code

function notifications_ui_notifications($op, $arg0, $arg1 = NULL, $arg2 = NULL) {
  if ($op == 'event trigger') {
    $event = $arg0;
    if ($event->type == 'node' && isset($event->node->subscriptions)) {
      if ($event->action == 'insert') {

        // On insert some field information will be missing, we need to recreate it.
        foreach ($event->node->subscriptions['params'] as $i => $subscriptions) {
          foreach ($subscriptions['fields'] as $key => $value) {
            if (!$value && isset($event->params[$key])) {
              $event->node->subscriptions['params'][$i]['fields'][$key] = $event->params[$key];
            }
          }
        }
      }
      notifications_ui_node_form_submit('', array(
        'subscriptions' => $event->node->subscriptions,
      ));
    }
    elseif ($event->type == 'node' && isset($event->comment->subscriptions)) {
      notifications_ui_node_form_submit('', array(
        'subscriptions' => $event->comment->subscriptions,
      ));
    }
  }
}