You are here

function _subscriptions_validate_hook_result in Subscriptions 6

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

Check return values of hook_subscriptions().

1 call to _subscriptions_validate_hook_result()
subscriptions_types in ./subscriptions.module
Hook subscription_types(). Get info about subscription types.

File

./subscriptions.module, line 544
Subscriptions module.

Code

function _subscriptions_validate_hook_result($stype, $data) {
  if (isset($stype)) {
    if (!is_numeric($stype) && is_array($data) && isset($data['title']) && isset($data['access']) && isset($data['page']) && isset($data['fields']) && is_array($data['fields'])) {
      return TRUE;
    }
  }
  static $already_reported = FALSE;
  if (!$already_reported) {
    $already_reported = TRUE;
    foreach (module_implements('subscriptions') as $module) {
      $hook = $module . '_subscriptions';
      $types = $hook('types');
      foreach ($types as $stype => $data) {
        if (!_subscriptions_validate_hook_result($stype, $data)) {
          $modules[$module] = $module;
        }
      }
    }
    drupal_set_message(t('The following modules return invalid data from %hook: !modules   Either they are buggy !Subscriptions add-ons, or they are unrelated to !Subscriptions and should not define %hook!', array(
      '%hook' => 'hook_subscriptions()',
      '!modules' => '<ul><li>' . implode($modules, '</li><li>') . '</li></ul>',
      '!Subscriptions' => 'Subscriptions',
    )), 'error', FALSE);
  }
  return FALSE;
}