You are here

function notifications_notifications_templates in Notifications 6.4

Same name and namespace in other branches
  1. 7 includes/templates.inc \notifications_notifications_templates()

Implementation of hook_notifications_templates()

File

includes/templates.inc, line 121
Notifications templates

Code

function notifications_notifications_templates($op = 'info', $type = 'all', $language = NULL) {
  switch ($op) {
    case 'info':
      $info = array();

      // Generic notifications event
      if ($type == 'all' || $type == 'notifications-event') {
        $info['notifications-event'] = array(
          'module' => 'notifications',
          'name' => t('Notifications event'),
          '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.'),
          'fallback' => FALSE,
        );
      }
      if ($type == 'digest' || $type == 'notifications-digest') {
        $info['notifications-digest'] = array(
          'module' => 'notifications',
          'name' => t('Notifications digest'),
          '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.'),
          'fallback' => FALSE,
        );
      }
      return $info;
    case 'parts':
      switch ($type) {
        case 'notifications-event':
        case 'notifications-message':
        case 'notifications-user-unsubscribe':
        case 'notifications-destination-unsubscribe':

          // Event notifications
          return array(
            'subject' => t('Subject'),
            'header' => t('Header'),
            'main' => t('Content'),
            'footer' => t('Footer'),
          );
        case 'notifications-digest':
          return array(
            'subject' => t('Subject'),
            'header' => t('Header'),
            'main' => t('Line for digested events'),
            'closing' => t('Group closing'),
            'footer' => t('Footer'),
          );
      }
      break;
    case 'defaults':
      switch ($type) {

        // Event notifications
        case 'notifications-event':
          return array(
            'subject' => t('Event notification for [user] from [site-name]', array(), $language->language),
            'header' => t("Greetings [user],", array(), $language->language),
            'main' => t("A item to which you are subscribed has been updated", array(), $language->language),
            'footer' => array(
              t('This is an automatic message from [site-name]', array(), $language->language),
              t('To manage your subscriptions, browse to [subscriptions-manage]', array(), $language->language),
              t('You can unsubscribe at [unsubscribe-url]', array(), $language->language),
            ),
          );
        case 'notifications-message':
          return array(
            'subject' => t('This is a message for [user] from [site-name]', array(), $language->language),
            'header' => t("Greetings [user],", array(), $language->language),
            'footer' => array(
              t('This is an automatic message from [site-name]', array(), $language->language),
            ),
          );

        // Digested messages
        case 'notifications-digest':
          return array(
            'subject' => t('[site-name] subscription update for [user]', array(), $language->language),
            'header' => t("Greetings, [user].\n\nThese are your messages", array(), $language->language),
            'main' => t("A [type] has been updated: [title]\n\n[event_list]", array(), $language->language),
            'closing' => '...',
            'footer' => array(
              t('This is an automatic message from [site-name]', array(), $language->language),
              t('To manage your subscriptions, browse to [subscriptions-manage]', array(), $language->language),
            ),
          );
        case 'notifications-user-unsubscribe':
          return array(
            'subject' => t('Cancel all subscriptions to [site-name]', array(), $language->language),
            'header' => t("Greetings [user],\n\nSomeone has requested to cancel all subscriptions for your account.", array(), $language->language),
            'main' => array(
              t("To cancel all your subscriptions, browse to [unsubscribe-url-global]", array(), $language->language),
              t('To edit your subscriptions, browse to [subscriptions-manage]', array(), $language->language),
            ),
          );
        case 'notifications-destination-unsubscribe':
          return array(
            'subject' => t('Cancel all subscriptions to [site-name]', array(), $language->language),
            'header' => t("Greetings from [site-name]\n\nSomeone has requested to cancel all subscriptions for [destination-address]", array(), $language->language),
            'main' => array(
              t("To cancel all your subscriptions, browse to [destination-unsubscribe-url]", array(), $language->language),
              t('To edit your subscriptions, browse to [destination-manage-url]', array(), $language->language),
            ),
          );
      }
      break;
    case 'tokens':
      $args = explode('-', $type);
      $tokens = array();
      switch ($type) {
        case 'notifications-user-unsubscribe':

          // This one has all of the following two plus 'user'
          $tokens[] = 'user';
        case 'notifications-destination-unsubscribe':
        case 'notifications-message':
          $tokens[] = 'destination';
          break;
        default:

          // These are the token groups that will be used for this module's messages
          if ($args[0] == 'notifications') {
            $tokens = array(
              'subscription',
              'user',
            );
            if ($args[1] == 'event') {

              // If the template is for a single event, it can use event tokens
              $tokens[] = 'event';
            }
            elseif ($args[1] == 'digest') {

              // Template for multiple events, can use events (note the plural) tokens
              $tokens[] = 'events';
            }
          }
      }
      return $tokens;
  }
}