You are here

function _subscriptions_validate_hook_result in Subscriptions 2.0.x

Same name and namespace in other branches
  1. 5.2 subscriptions.module \_subscriptions_validate_hook_result()
  2. 6 subscriptions.module \_subscriptions_validate_hook_result()
  3. 7 subscriptions.module \_subscriptions_validate_hook_result()

Checks return values of hook_subscriptions().

Parameters

mixed $stype:

array $data:

Return value

bool

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

File

./subscriptions.module.old.php, line 798
Subscriptions module.

Code

function _subscriptions_validate_hook_result($stype, array $data) {
  if (isset($stype)) {
    if (!is_numeric($stype) && is_array($data) && isset($data['title']) && isset($data['access']) && ($data['title'] === '' || isset($data['page']) && isset($data['fields']) && is_array($data['fields']))) {
      return TRUE;
    }
  }
  static $already_reported = FALSE;
  if (!$already_reported) {
    $modules = array();
    $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;
}