You are here

function spamicide_requirements in Spamicide 5

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

Implementation of hook_requirements().

File

./spamicide.module, line 79
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') {
    $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 does 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,
        );
      }
    }
    if (!is_writable(file_directory_temp())) {
      $requirements['spamicide_directory'] = array(
        'title' => $t('Spamicide Temp Directory'),
        'value' => $t('%p is not writeable by the webserver.', array(
          '%p' => file_directory_temp(),
        )),
        'severity' => REQUIREMENT_ERROR,
      );
    }

    //variable_set('spamicide_attempt_counter', variable_get('spamicide_attempt_counter', 0) + 1);
    $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;
}