You are here

function notifications_anonymous_messaging in Notifications 6.4

Implementation of hook_messaging()

This hook provides information about the mensaje templates this module uses and related tokens.

Depending on $op, this hook takes different parameters and returns different pieces of information:

  • 'message groups' Get array of message groups, each of which will have one or more keys for different templates Each group should have a unique key, so it should start with the module name
  • 'message keys' Get message template parts for a given group ($arg1) Return array of key => name for each part
  • 'messages' Get default message templates for a given group ($arg1). It should return default texts, indexed by message key that will be the default templates These templates may be edited on the 'Messaging templates' page
  • 'tokens' Get available tokens for a given message group and key ($arg1). Return array of token keys that will be available for this message templates The tokens themselves may be default tokens (provided by token module) or we can add new tokens implementing hook_token_list() and hook_token_value()

Parameters

$op: Operation, type of information to retrieve

$arg1, $arg2...: Different parameters depending on $op

File

notifications_anonymous/notifications_anonymous.module, line 328
Notifications for anonymous users

Code

function notifications_anonymous_messaging($op, $type = 'all', $language = NULL) {
  switch ($op) {
    case 'message types':
      $info['notifications-anonymous'] = array(
        'name' => t('Anonymous Notifications'),
        'description' => t('Confirmation messages for anonymous users'),
      );
      return $info;
    case 'message groups':

      // Generic notifications event
      $info['notifications-anonymous-subscribe'] = array(
        'module' => 'notifications_anonymous',
        'name' => t('Confirm subscription'),
        'description' => t('Common parts for all Notifications messages for a single event. This is useful for defining a common header and/or footer for all these messages.'),
      );
      $info['notifications-anonymous-unsubscribe'] = array(
        'module' => 'notifications_anonymous',
        'name' => t('Cancel subscription'),
        'description' => t('Depending on your settings for each Send interval, Notifications may be digested, this is grouped and summarized in a single message. These are the common parts for Notifications digests.'),
      );
      return $info;
    case 'message keys':
      switch ($type) {
        case 'notifications-anonymous':
          return array(
            'subject' => t('Subject'),
            'footer' => t('Footer'),
          );
        case 'notifications-anonymous-subscribe':
        case 'notifications-anonymous-unsubscribe':
        case 'notifications-anonymous-manage':

          // Anonymous confirmation mails
          return array(
            'subject' => t('Subject'),
            'header' => t('Header'),
            'main' => t('Content'),
            'footer' => t('Footer'),
          );
      }
      break;
    case 'messages':
      switch ($type) {
        case 'notifications-anonymous':
          return array(
            'subject' => t('Message from [site-name]', array(), $language->language),
            'footer' => array(
              t('This is an automatic message from [site-name]', array(), $language->language),
              t('To manage your subscriptions, browse to [destination-manage-url]', array(), $language->language),
              t('You can unsubscribe at [destination-unsubscribe-url]', array(), $language->language),
            ),
          );

        // Subscribe confirmation
        case 'notifications-anonymous-subscribe':
          return array(
            'subject' => t('Confirm your subscription to [site-name]', array(), $language->language),
            'header' => t("Someone has subscribed to [site-name] using [destination-address],", array(), $language->language),
            'main' => t("To confirm your subscription, browse to [subscription-confirm]", array(), $language->language),
          );

        // Unsubscribe all message for a destination
        case 'notifications-anonymous-unsubscribe':
          return array(
            'subject' => t('Cancel subscription to [site-name]', array(), $language->language),
            'header' => t('Someone has requested to cancel all subscriptions for [destination-address]', array(), $language->language),
            'main' => array(
              t("To cancel your subscription, browse to [subscription-unsubscribe-url]", array(), $language->language),
              t('To edit your subscription, browse to [subscription-edit-url]', array(), $language->language),
            ),
          );
        case 'notifications-anonymous-manage':
          return array(
            'subject' => t('Edit your subscriptions to [site-name]', array(), $language->language),
            'header' => t('Someone has requested to change the subscriptions for [destination-address]', array(), $language->language),
            'main' => array(
              t('To edit your subscriptions, browse to [destination-manage-url]', array(), $language->language),
              t("To cancel all your subscriptions, browse to [destination-unsubscribe-url]", array(), $language->language),
            ),
          );
      }
      break;
    case 'tokens':
      $tokens = array();

      // These are the token groups that will be used for this module's messages
      if (strpos($type, 'notifications-anonymous') === 0) {
        $tokens = array(
          'subscription',
          'destination',
        );
      }
      return $tokens;
  }
}