You are here

function quickupdate_load_missing_dependencies in Quick update 7

Same name and namespace in other branches
  1. 8 quickupdate.module \quickupdate_load_missing_dependencies()

Loads all missing dependency projects.

Parameters

array $projects: The short name of the projects or leave empty. If empty, then loads all dependency projects. Otherwise, only loads the dependency projects of the specific projects.

Return value

array An array that contains the missing dependency project's title, installed version, and recommended version.

3 calls to quickupdate_load_missing_dependencies()
drush_quickupdate_qup_download_missing_dependencies in ./quickupdate.drush.inc
Command handler. Downloads missing dependency projects.
drush_quickupdate_qup_list_missing_dependencies in ./quickupdate.drush.inc
Command handler. Lists missing dependency projects.
quickupdate_form_update_manager_update_form_alter in ./quickupdate.module
Implements hook_form_FORM_ID_alter().

File

./quickupdate.module, line 572
Primarily Drupal hooks and global API functions.

Code

function quickupdate_load_missing_dependencies($projects = array()) {

  // Resets the modules cache.
  drupal_static('system_rebuild_module_data', NULL, TRUE);

  // Resets the themes cache.
  drupal_static('system_rebuild_theme_data', NULL, TRUE);
  $module_files = system_rebuild_module_data();
  $theme_files = system_rebuild_theme_data();
  $themes_list = list_themes(TRUE);
  $entry = array();
  $counts = count($projects);
  foreach ($module_files as $module) {
    if ($counts > 0 && !in_array($module->name, $projects)) {
      continue;
    }
    foreach ($module->requires as $requires => $v) {
      if (!isset($module_files[$requires]) && $requires != '_missing_dependency') {
        $entry[$requires] = array(
          'title' => drupal_ucfirst($requires),
          'installed_version' => t('None'),
          'recommended_version' => t('Unknown'),
          'required_by' => $module->name,
        );
      }
    }
  }
  foreach ($theme_files as $theme) {
    if ($counts > 0 && !in_array($theme->name, $projects)) {
      continue;
    }
    if (isset($theme->base_themes)) {
      foreach ($theme->base_themes as $short_name => $v) {
        if (!array_key_exists($short_name, $themes_list)) {
          $entry[$short_name] = array(
            'title' => drupal_ucfirst($short_name),
            'installed_version' => t('None'),
            'recommended_version' => t('Unknown'),
            'required_by' => $theme->name,
          );
        }
      }
    }
  }
  return $entry;
}