You are here

function sweaver_requirements in Sweaver 7

Same name and namespace in other branches
  1. 6 sweaver.install \sweaver_requirements()

Implements hook_requirements().

File

./sweaver.install, line 11
Sweaver install file.

Code

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

  // Ensure translations don't break at install time.
  $t = get_t();
  if ($phase == 'runtime' || $phase == 'install') {
    $sweaver_directory = 'public://sweaver';
    if (!file_prepare_directory($sweaver_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
      if (!is_dir($sweaver_directory)) {
        $requirements['sweaver_directory'] = array(
          'title' => $t('sweaver directory'),
          'value' => $t('%p is not a directory or is not readable by the webserver.', array(
            '%p' => $sweaver_directory,
          )),
          'severity' => REQUIREMENT_ERROR,
        );
      }
      elseif (!is_writable($sweaver_directory)) {
        $requirements['sweaver_directory'] = array(
          'title' => $t('sweaver directory'),
          'value' => $t('%p is not writeable by the webserver.', array(
            '%p' => $sweaver_directory,
          )),
          'severity' => REQUIREMENT_ERROR,
        );
      }
      else {
        $requirements['sweaver_directory'] = array(
          'title' => $t('sweaver 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' => $sweaver_directory,
          )),
          'severity' => REQUIREMENT_ERROR,
        );
      }
    }
    else {
      $requirements['sweaver_directory'] = array(
        'title' => t('sweaver directory'),
        'severity' => REQUIREMENT_OK,
        'value' => t('Exists'),
      );
    }
  }
  return $requirements;
}