You are here

filefield_nginx_progress.install in FileField Nginx Progress 7

filefield_nginx_progress.install

@brief Install file for the filefield_nginx_progress module. The module implements a upload progress bar for filefield.

File

filefield_nginx_progress.install
View source
<?php

/**
 * @file   filefield_nginx_progress.install
 * 
 * @brief Install file for the filefield_nginx_progress module. The module
 *        implements a upload progress bar for filefield.
 * 
 */

/** 
 * Implementation of hook_install(). 
 *
 */
function filefield_nginx_progress_install() {

  // Alter the module weight to make sure we come after file fields.
  db_update('system')
    ->fields(array(
    'weight' => 20,
  ))
    ->condition('type', 'module')
    ->condition('name', 'filefield_nginx_progress')
    ->execute();
}

/**
 * Implementation of hook_requirements().
 *
 * Display information about getting upload progress bars working.
 * Mostly stolen from the filefield install file.
 */
function filefield_nginx_progress_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time
  $t = get_t();

  // The nginx upload progress module wiki page link.
  $nginx_http_progress_link = l($t('upload progress module'), 'http://wiki.nginx.org/NginxHttpUploadProgressModule');
  if ($phase == 'runtime') {

    // Compare the PHP version. Only works with versions > 5.2.0.
    if (!version_compare(phpversion(), '5.2.0', '>')) {
      $value = $t('Not enabled');
      $description = $t('Your server is not capable of displaying file upload progress. File upload progress requires PHP 5.2 and nginx with the ' . $nginx_http_progress_link . ' compiled in.');
      $severity = REQUIREMENT_INFO;
    }
    else {
      $value = $t('Enabled (' . $nginx_http_progress_link . ' )');
      $description = '';
      $severity = REQUIREMENT_OK;
    }
    $requirements['filefield_nginx_progress'] = array(
      'title' => $t('Upload progress nginx'),
      'value' => $value,
      'severity' => $severity,
      'description' => $description,
    );
  }

  // runtime
  return $requirements;
}

// filefield_nginx_progress_requirements

/** 
 * 
 * Set the upload progress in the status report page.
 * 
 */
function filefield_nginx_progress_update_7100() {
  db_update('system')
    ->fields(array(
    'weight' => 20,
  ))
    ->condition('type', 'module')
    ->condition('name', 'filefield_nginx_progress')
    ->execute();
}

Functions

Namesort descending Description
filefield_nginx_progress_install Implementation of hook_install().
filefield_nginx_progress_requirements Implementation of hook_requirements().
filefield_nginx_progress_update_7100 Set the upload progress in the status report page.