You are here

function notifications_lite_notifications in Notifications 5

Same name and namespace in other branches
  1. 6.4 notifications_lite/notifications_lite.module \notifications_lite_notifications()
  2. 6 notifications_lite/notifications_lite.module \notifications_lite_notifications()
  3. 6.2 notifications_lite/notifications_lite.module \notifications_lite_notifications()
  4. 6.3 notifications_lite/notifications_lite.module \notifications_lite_notifications()

Implementation of hook_notifications()

It handles event texts

File

notifications_lite/notifications_lite.module, line 97
Simple notifications API

Code

function notifications_lite_notifications($op, &$arg0, $arg1 = NULL, $arg2 = NULL) {
  switch ($op) {
    case 'event load':

      // $arg0 is event
      $event =& $arg0;
      if ($event->type == 'lite') {
        if (!empty($event->params['subject'])) {
          $event->text['subject'] = $event->params['subject'];
          $event->text['digest'] = $event->params['subject'];
        }
        if (!empty($event->params['body'])) {
          $event->text['main'] = $event->params['body'];
        }
      }
      break;

    // By queueing the event here we gain access to some features, like inmediate sending
    case 'event queued':

      // $event is arg0
      $event =& $arg0;
      if ($event->type == 'lite') {
        notifications_lite_queue_event($event);
      }
      break;
    case 'event types':

      // We just define event type 'lite', action 'default'
      $types[] = array(
        'type' => 'lite',
        'action' => 'default',
        'name' => t('Message for [user]'),
        'digest' => NULL,
        // This means grouping by: event type, event action
        'description' => t('Notifications lite message'),
      );
      return $types;
  }
}