You are here

function notifications_format_subscription_field in Notifications 6

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

Format subscriptions field for display and get some more information

Return value

array() Array with 'name' and 'value' elements

3 calls to notifications_format_subscription_field()
notifications_custom_form in notifications_custom/notifications_custom.admin.inc
Edit / create custom subscriptions
notifications_format_subscription in ./notifications.module
Format subscription for display
notifications_manage_subscriptions_form in ./notifications.manage.inc
Administer user subscriptions

File

./notifications.module, line 1679
Notifications module

Code

function notifications_format_subscription_field($type, $value, $html = TRUE) {
  $format_name = $format_value = t('Unknown');
  if ($info = notifications_subscription_fields($type)) {
    $format_name = $info['name'];
    if (!empty($info['format callback'])) {
      $format_value = call_user_func($info['format callback'], $value, $html);
    }
    elseif (!empty($info['options callback'])) {
      $options = call_user_func($info['options callback']);
      $format_value = isset($options[$value]) ? $options[$value] : t('Not available');
    }
    else {
      $format_value = check_plain($value);
    }
  }
  return array(
    'name' => $format_name,
    'value' => $format_value,
  );
}