You are here

function l10n_update_requirements in Localization update 7

Same name and namespace in other branches
  1. 6 l10n_update.install \l10n_update_requirements()
  2. 7.2 l10n_update.install \l10n_update_requirements()

Implements hook_requirements().

File

./l10n_update.install, line 183
Install file for l10n remote updates.

Code

function l10n_update_requirements($phase) {
  if ($phase == 'runtime') {
    $requirements['l10n_update']['title'] = t('Translation update status');
    if (variable_get('l10n_update_check_frequency', 0)) {
      if (l10n_update_get_projects() && l10n_update_language_list()) {
        if (l10n_update_available_updates()) {
          $requirements['l10n_update']['severity'] = REQUIREMENT_WARNING;
          $requirements['l10n_update']['value'] = t('There are available updates');
          $requirements['l10n_update']['description'] = t('There are new or updated translations available for currently installed modules and themes. To check for updates, you can visit the <a href="@check_manually">translation update page</a>.', array(
            '@check_manually' => url('admin/config/regional/translate/update'),
          ));
        }
        else {
          $requirements['l10n_update']['severity'] = REQUIREMENT_OK;
          $requirements['l10n_update']['value'] = t('All your translations are up to date');
        }
      }
      else {
        $requirements['l10n_update']['value'] = t('No update data available');
        $requirements['l10n_update']['severity'] = REQUIREMENT_WARNING;
        $requirements['l10n_update']['description'] = _l10n_update_no_data();
      }
    }
    else {
      $requirements['l10n_update']['value'] = t('Not enabled');
      $requirements['l10n_update']['severity'] = REQUIREMENT_INFO;
    }

    // Test the contents of the .htaccess file in the translations directory.
    $directory = variable_get('l10n_update_download_store', '');
    if ($directory) {
      l10n_update_ensure_htaccess();
      $htaccess_file = $directory . '/.htaccess';

      // Check for the string which was added to the recommended .htaccess file
      // in the latest security update.
      if (!file_exists($htaccess_file) || !($contents = @file_get_contents($htaccess_file)) || strpos($contents, 'Drupal_Security_Do_Not_Remove_See_SA_2013_003') === FALSE) {
        $requirements['l10n_update_htaccess'] = array(
          'title' => t('Translations directory'),
          'value' => t('Not fully protected'),
          'severity' => REQUIREMENT_ERROR,
          'description' => t('See <a href="@url">@url</a> for information about the recommended .htaccess file which should be added to the %directory directory to help protect against arbitrary code execution.', array(
            '@url' => 'http://drupal.org/SA-CORE-2013-003',
            '%directory' => $directory,
          )),
        );
      }
    }
    return $requirements;
  }

  // We must always return array, the installer doesn't use module_invoke_all()
  return array();
}