You are here

function messaging_notify_messaging in Messaging 6

Implementation of hook_messaging()

File

messaging_notify/messaging_notify.module, line 226
Subscriptions to messaging events

Code

function messaging_notify_messaging($op, $arg1 = NULL, $arg2 = NULL, $arg3 = NULL, $arg4 = NULL) {
  switch ($op) {
    case 'message groups':
      $help = t('The header and footer will default to the ones from Notification events');

      // Generic notifications event
      $info['notifications-event-message'] = array(
        'module' => 'messaging_notify',
        'name' => t('Message notifications'),
        'description' => t('Notifications for messages. When a message is sent through some channel (I.e. a private message), you may want to be notified through a different one (I.e. a daily email digest).'),
        'help' => $help,
        'fallback' => 'notifications-event',
      );

      // Node group digests, will have specific help text in hook_help()
      $info['notifications-digest-message-method'] = array(
        'module' => 'messaging_notify',
        'name' => t('Message digests per method'),
        'description' => t('Digested message events grouping by sending method.'),
        'fallback' => 'notifications-digest',
      );
      return $info;
    case 'message keys':
      $type = $arg1;
      switch ($type) {
        case 'notifications-event-message':

          // Some parts may be re-used from 'notifications-event' group
          // So we specify only subject and main message
          return array(
            'subject' => t('Subject'),
            'main' => t('Content'),
            'digest' => t('Digest line'),
            'footer' => t('Footer'),
          );
        case 'notifications-digest-message-method':
          $parts['title'] = t('Group title');
          $parts['footer'] = t('Group footer');
          return $parts;
      }
      break;
    case 'messages':
      $type = $arg1;

      // Event notifications
      switch ($type) {
        case 'notifications-event-message':
          return array(
            'subject' => t('New message from [message-author-name]'),
            'main' => array(
              '[message-subject]',
              '[message-body]',
            ),
            'digest' => t('Message from [message-author-name]: [message-subject]'),
          );
        case 'notifications-digest-message-method':
          return array(
            'subject' => t('New messages for [user]'),
            'header' => t("Greetings, [user].\n\nThese are your messages"),
          );
      }
      break;
    case 'tokens':
      $tokens = array();
      switch ($arg1) {
        case 'notifications-event-message':
          $tokens[] = 'author';
          $tokens[] = 'message';
          break;
        case 'notifications-digest-message-method':
          $tokens[] = array(
            'message',
            'message-method',
          );
          break;
      }
      return $tokens;
  }
}