You are here

function itweak_upload_requirements in iTweak Upload 6.2

Same name and namespace in other branches
  1. 7.3 itweak_upload.install \itweak_upload_requirements()

Implementation of hook_requirements()

File

./itweak_upload.install, line 111
Installation code for iTweakUpload.

Code

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

  // Ensure translations don't break at install time
  $t = get_t();
  switch ($phase) {
    case 'install':
      $error = FALSE;

      //      if (!module_exists('content_copy')) {
      //        $error = TRUE;
      //        $value = $t('Content Copy module to be pre-installed.');
      //        $severity = REQUIREMENT_ERROR;
      //      }
      if (!module_exists('imagecache')) {
        if ($error) {
          $value .= ' ';
        }
        else {
          $error = TRUE;
          $value = '';
        }
        $value .= $t('ImageCache module to be pre-installed.');
        $severity = REQUIREMENT_ERROR;
      }

      //      if ($error) {
      //        $requirements['cck_gallery'] = array(
      //          'title' => $t('CCK Gallery requirements'),
      //          'value' => $value . $t(' If the required modules are now installed, please enable CCK Gallery again.'),
      //          'severity' => $severity,
      //        );
      //      }
      break;

    // Check progress bar capability
    case 'runtime':
      if (!module_exists('filefield')) {

        // This code copied verbatim from filefield.install
        // We don't want to repeat axact same message twice
        $implementation = itweak_upload_progress_implementation();
        $apache = strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== FALSE;
        $fastcgi = strpos($_SERVER['SERVER_SOFTWARE'], 'mod_fastcgi') !== FALSE || strpos($_SERVER["SERVER_SOFTWARE"], 'mod_fcgi') !== FALSE;
        $php_52 = version_compare(phpversion(), '5.2.0', '>');
        $description = NULL;
        if (!$apache || !$php_52) {
          $value = $t('Not enabled');
          $description = $t('Your server is not capable of displaying file upload progress. File upload progress requires PHP 5.2 and an Apache server.');
          $severity = REQUIREMENT_INFO;
        }
        elseif ($fastcgi) {
          $value = $t('Not enabled');
          $description = $t('Your server is not capable of displaying file upload progress. File upload progress requires PHP be run with mod_php and not as FastCGI.');
          $severity = REQUIREMENT_INFO;
        }
        elseif (!$implementation && extension_loaded('apc')) {
          $value = $t('Not enabled');
          $description = $t('Your server is capable of displaying file upload progress through APC, but it is not enabled. Add <code>apc.rfc1867 = 1</code> to your php.ini configuration. Alternatively, it is recommended to use <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>, which supports more than one simultaneous upload.');
          $severity = REQUIREMENT_WARNING;
        }
        elseif (!$implementation) {
          $value = $t('Not enabled');
          $description = t('Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> (preferred) or to install <a href="http://us2.php.net/apc">APC</a>.');
          $severity = REQUIREMENT_WARNING;
        }
        elseif ($implementation == 'apc') {
          $value = $t('Enabled (<a href="http://php.net/manual/en/apc.configuration.php#ini.apc.rfc1867">APC RFC1867</a>)');
          $description = t('Your server is capable of displaying file upload progress using APC RFC1867. Note that only one upload at a time is supported. It is recommended to use the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> if possible.');
          $severity = REQUIREMENT_OK;
        }
        elseif ($implementation == 'uploadprogress') {
          $value = $t('Enabled (<a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>)');
          $severity = REQUIREMENT_OK;
        }
        $requirements['itweak_upload_progress'] = array(
          'title' => $t('Upload progress'),
          'value' => $value,
          'severity' => $severity,
          'description' => $description,
        );
      }
      break;
  }
  return $requirements;
}