You are here

function spamicide_requirements in Spamicide 6

Same name and namespace in other branches
  1. 8 spamicide.install \spamicide_requirements()
  2. 5 spamicide.module \spamicide_requirements()
  3. 7 spamicide.install \spamicide_requirements()

Implementation of hook_requirements().

File

./spamicide.install, line 16
This module provides yet another tool to eliminate spam.

Code

function spamicide_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time.
  $t = get_t();
  if ($phase == 'runtime' || $phase == 'install') {
    $spamicide_directory = file_create_path() . '/spamicide';
    if (!file_check_directory($spamicide_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
      if (!is_dir($spamicide_directory)) {
        $requirements['spamicide_directory'] = array(
          'title' => $t('Spamicide Directory'),
          'value' => $t('%p is not a directory or is not readable by the webserver.', array(
            '%p' => $spamicide_directory,
          )),
          'severity' => REQUIREMENT_ERROR,
        );
      }
      elseif (!is_writable($spamicide_directory)) {
        $requirements['spamicide_directory'] = array(
          'title' => $t('Spamicide Directory'),
          'value' => $t('%p is not writeable by the webserver.', array(
            '%p' => $spamicide_directory,
          )),
          'severity' => REQUIREMENT_ERROR,
        );
      }
      else {
        $requirements['spamicide_directory'] = array(
          'title' => $t('Spamicide Directory'),
          'value' => $t('An unknown error occured.'),
          'description' => $t('An unknown error occured trying to verify %p is a directory and is writable.', array(
            '%p' => $spamicide_directory,
          )),
          'severity' => REQUIREMENT_ERROR,
        );
      }
    }
    $requirements['spamicide_attempt_counter'] = array(
      'title' => $t('Spamicide'),
      'value' => $t('Already blocked @counter form submissions', array(
        '@counter' => variable_get('spamicide_attempt_counter', 0),
      )),
      'severity' => REQUIREMENT_INFO,
    );
  }
  return $requirements;
}