You are here

function activity_cache_api_load in Activity 7

1 call to activity_cache_api_load()
activity_cache_get in ./activity.module

File

./activity.module, line 604
Records Activity across the site and surfaces that to Views.

Code

function activity_cache_api_load() {
  $info_cache =& drupal_static(__FUNCTION__);
  if (empty($info_cache)) {
    $info_cache = array(
      'realms' => array(),
      'hooks' => array(),
      'all_realms' => array(),
    );
    foreach (module_implements('activity_api') as $module) {
      $module_result = module_invoke($module, 'activity_api');

      // @TODO: use version_compare: http://php.net/manual/en/function.version-compare.php
      if ($module_result['api'] == '3.0-alpha1') {
        $module_result += array(
          'realms' => array(),
          'hooks' => array(),
        );
        foreach ($module_result['realms'] as $realm => $data) {
          $module_result['realms'][$realm] += array(
            'module' => $module,
          );
        }
        $info_cache['hooks'] += $module_result['hooks'];
        $info_cache['realms'] += $module_result['realms'];
        $info_cache['all_realms'] += $module_result['realms'];
        if (isset($module_result['file'])) {
          require_once './' . $module_result['file'];
        }
      }
      $enabled_realms = variable_get('activity_access_realms', array(
        'node_author',
      ));
      if (!empty($enabled_realms)) {
        foreach (array_diff(array_keys($info_cache['realms']), $enabled_realms) as $key) {
          unset($info_cache['realms'][$key]);
        }
      }
    }
    drupal_alter('activity_api', $info_cache);
  }
  return $info_cache;
}