You are here

function update_status_get_projects in Update Status 5

Same name and namespace in other branches
  1. 5.2 update_status.module \update_status_get_projects()

Fetch an array of installed and enabled projects.

@todo Extend this to include themes and theme engines when they get .info files.

3 calls to update_status_get_projects()
update_status_calculate_project_data in ./update_status.module
update_status_refresh in ./update_status.module
Fetch data from a central server and save as a variable.
update_status_settings in ./update_status.module
Menu callback. Show the settings for the update status module.

File

./update_status.module, line 265

Code

function update_status_get_projects() {
  $projects = array();

  // Get current list of modules.
  $files = drupal_system_listing('\\.module$', 'modules', 'name', 0);

  // Extract current files from database.
  system_get_files_database($files, 'module');
  foreach ($files as $filename => $file) {

    // Skip not enabled modules.
    if (empty($file->status)) {
      continue;
    }
    $info = _module_parse_info_file(dirname($file->filename) . '/' . $file->name . '.info');

    // Skip if this is broken.
    if (empty($info)) {
      continue;
    }
    $info['check'] = TRUE;
    if (!array_key_exists('project', $info)) {

      // guess the project from the directory.
      $last = '';
      foreach (array_reverse(explode('/', $file->filename)) as $dir) {
        if ($dir == 'modules') {
          break;
        }
        $last = $dir;
      }
      if ($last) {
        $info['project'] = $last;
      }
      else {
        continue;
      }
    }
    if (!array_key_exists($info['project'], $projects)) {
      if (!array_key_exists('version', $info)) {
        $info['check'] = FALSE;
        $info['version'] = t('Unknown');
      }
      if (strpos($info['version'], '$Name') !== FALSE) {
        $info['version'] = update_status_make_nice_version($info['version'], $info['check']);
      }
      $projects[$info['project']] = array(
        'name' => $info['project'],
        'existing_version' => $info['version'],
        'check' => $info['check'],
        'modules' => array(
          $file->name => $info['name'],
        ),
      );
    }
    else {
      $projects[$info['project']]['modules'][$file->name] = $info['name'];
    }
  }
  asort($projects);
  return $projects;
}