You are here

function notifications_format_subscription in Notifications 6

Same name and namespace in other branches
  1. 6.2 notifications.module \notifications_format_subscription()
  2. 6.3 notifications.module \notifications_format_subscription()

Format subscription for display

Return value

array() Array with type_name, field_names (array), field_values (array)

1 call to notifications_format_subscription()
notifications_multiple_delete_confirm in ./notifications.manage.inc
Form for multiple delete. When account passed check that all subscriptions belong to the user account

File

./notifications.module, line 1645
Notifications module

Code

function notifications_format_subscription($subscription, $format = 'short', $html = TRUE) {

  // Build array and add subscription type name
  $type_name = notifications_subscription_types($subscription->type, 'title');
  $names = $values = array();

  // Format every field separately
  foreach ($subscription->fields as $key => $data) {
    if (is_array($data)) {
      $item = notifications_format_subscription_field($data['type'], $data['value'], $html);
    }
    else {
      $item = notifications_format_subscription_field($key, $data, $html);
    }
    $names[$key] = $item['name'];
    $values[$key] = $item['value'];
  }

  // Now do the formatting
  switch ($format) {
    case 'array':
      return array(
        'type' => $type_name,
        'names' => $names,
        'values' => $values,
      );
    case 'short':
      return t('@type: !values', array(
        '@type' => $type_name,
        '!values' => implode(', ', $values),
      ));
    case 'long':
      return t('Subscription %id of type %type to: !values', array(
        '%id' => $subscription->sid,
        '%type' => $type_name,
        '!values' => implode(', ', $values),
      ));
  }
}