You are here

function notifications_subscription_info_field in Notifications 6.3

Same name and namespace in other branches
  1. 6.2 notifications.pages.inc \notifications_subscription_info_field()

Subscription information field for several forms

3 calls to notifications_subscription_info_field()
notifications_form_subscribe_confirm in ./notifications.pages.inc
Form for subscription confirmation
notifications_form_unsubscribe_confirm in ./notifications.pages.inc
Form for unsubscription confirmation
notifications_subscription_form in ./notifications.pages.inc
Edit subscription

File

./notifications.pages.inc, line 492
User pages for Notifications

Code

function notifications_subscription_info_field($subscription) {
  $info = notifications_subscription_types($subscription->type);
  $format = notifications_format_subscription($subscription, 'array');
  if (!empty($info['name'])) {

    // This subscription type already have a name
    $value = $format['name'];
  }
  else {
    if (empty($format['names'])) {

      // No name, maybe no fields it should be enough with the title
      $value = '';
    }
    elseif (count($format['names']) == 1) {

      // If the field is unique, we don't need a table nor a name for it
      $value = array_shift($format['values']);
    }
    else {

      // Multiple fields, format as a table
      foreach ($format['names'] as $index => $value) {
        $rows[] = array(
          $value,
          $format['values'][$index],
        );
      }
      $value = theme('table', array(), $rows);
    }
  }

  // Build a form field
  $field = array(
    '#type' => 'item',
    '#title' => t('!type subscription', array(
      '!type' => $format['type'],
    )),
    '#value' => $value,
  );
  if (!empty($info['description'])) {
    $field['#description'] = $info['description'];
  }
  return $field;
}