You are here

function acquia_spi_get_modules in Acquia Connector 6.2

Same name and namespace in other branches
  1. 6 acquia_spi/acquia_spi.module \acquia_spi_get_modules()
  2. 7.3 acquia_spi/acquia_spi.module \acquia_spi_get_modules()
  3. 7 acquia_spi/acquia_spi.module \acquia_spi_get_modules()
  4. 7.2 acquia_spi/acquia_spi.module \acquia_spi_get_modules()

Gather information about modules on the site.

Return value

An associative array keyed by filename of associative arrays with information on the modules.

1 call to acquia_spi_get_modules()
acquia_spi_get in acquia_spi/acquia_spi.module
Gather site profile information about this site.

File

acquia_spi/acquia_spi.module, line 1440
Send site profile information (NSPI) and system data to Acquia Insight.

Code

function acquia_spi_get_modules() {

  // Only do a full rebuild of the module cache every 1 at the most
  $last_build = variable_get('acquia_spi_module_rebuild', 0);
  if ($last_build < time() - 86400) {
    $modules = module_rebuild_cache();
    variable_set('acquia_spi_module_rebuild', time());
  }
  else {
    $result = db_query("SELECT filename, name, type, status, throttle, schema_version, info FROM {system} WHERE type = 'module'");
    while ($file = db_fetch_object($result)) {
      $file->info = unserialize($file->info);
      $modules[$file->filename] = $file;
    }
  }
  $result = array();
  $keys_to_send = array(
    'name',
    'version',
    'package',
    'core',
    'project',
  );
  foreach ($modules as $filename => $file) {
    $info = array();
    $info['status'] = $file->status;
    foreach ($keys_to_send as $key) {
      $info[$key] = isset($file->info[$key]) ? $file->info[$key] : '';
    }
    $info['filename'] = $file->filename;

    // Determine which files belong to this module and hash them
    $module_path = explode('/', $file->filename);
    array_pop($module_path);

    // We really only care about this module if it is in 'sites' folder.
    // Otherwise it is covered by the hash of the distro's modules
    if ($module_path[0] == 'sites') {
      $contrib_path = implode('/', $module_path);

      // Get a hash for this module's files. If we nest into another module, we'll return
      // and that other module will be covered by it's entry in the system table.
      //
      // !! At present we aren't going to do a per module hash, but rather a per-project hash. The reason being that it is
      // too hard to tell an individual module appart from a project

      //$info['module_data'] = _acquia_spi_generate_hashes($contrib_path,array(),array(),TRUE,$contrib_path);
      list($info['module_data']['hashes'], $info['module_data']['fileinfo']) = _acquia_spi_generate_hashes($contrib_path);
    }
    else {
      $info['module_data']['hashes'] = array();
      $info['module_data']['fileinfo'] = array();
    }
    $result[] = $info;
  }
  return $result;
}