You are here

function subscriptions_types in Subscriptions 7

Same name and namespace in other branches
  1. 5.2 subscriptions.module \subscriptions_types()
  2. 6 subscriptions.module \subscriptions_types()
  3. 2.0.x subscriptions.module.old.php \subscriptions_types()

Hook subscription_types(). Get info about subscription types.

Parameters

string|null $field:

string|null $type:

Return value

array|null Information for a given field and type or information for a given field for all types

6 calls to subscriptions_types()
subscriptions_menu in ./subscriptions.module
Implements hook_menu().
subscriptions_page_form in ./subscriptions.admin.inc
Display subscribed content data on the user and site subscriptions pages. @ TODO clean up all of these parts
subscriptions_page_user_overview in ./subscriptions.admin.inc
Construct the overview page, which displays a summary of subscriptions per type as well as the user settings at user/UID/subscriptions. This form is also used for admin/settings/subscriptions/userdefaults.
subscriptions_permission in ./subscriptions.module
Implements hook_permission().
subscriptions_write in ./subscriptions.module
Helper function to do access checking and create a subscription.

... See full list

File

./subscriptions.module, line 752
Subscriptions module.

Code

function subscriptions_types($field = NULL, $type = NULL) {
  $types =& drupal_static(__FUNCTION__ . '_types');
  $list =& drupal_static(__FUNCTION__ . '_list');
  if (!isset($types)) {
    $types = module_invoke_all('subscriptions', 'types');

    // Allow other modules to alter the data.
    drupal_alter('subscriptions_types', $types);
    foreach ($types as $stype => $data) {
      if (!_subscriptions_validate_hook_result($stype, $data)) {
        continue;
      }
      foreach ($data as $name => $value) {
        $list[$name][$stype] = $value;
      }
    }
  }
  if ($type) {
    return isset($types[$type][$field]) ? $types[$type][$field] : NULL;
  }
  elseif ($field) {
    if ($field == 'permission' && isset($list['access']) && is_array($list['access'])) {
      $result = array();
      foreach ($list['access'] as $type => $access) {
        if (isset($list['permission'][$type]) && is_array($list['permission'][$type])) {
          $result[$access] = $list['permission'][$type];
        }
      }
      return $result;
    }
    return isset($list[$field]) ? $list[$field] : array();
  }
  else {
    return $types;
  }
}