You are here

pdfthumb.install in PDFThumb 7

Install, update and uninstall functions for the PDFThumb module.

File

pdfthumb.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the PDFThumb module.
 */

/**
 * Implements hook_requirements().
 */
function pdfthumb_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $open_basedir = ini_get("open_basedir");
    $safe_mode_exec_dir = ini_get("safe_mode_exec_dir");
    $requirements['pdfthumb'] = array(
      'title' => t('PDFthumb'),
    );
    $requirements['pdfthumb']['description'] = t('Check for convert path.');
    if (!empty($open_basedir)) {
      $requirements['pdfthumb']['severity'] = REQUIREMENT_WARNING;
      $requirements['pdfthumb']['value'] = t('open_base_dir restriction in effect. Not possible to check convert path.');
    }
    else {
      if (!file_exists(variable_get('pdfthumb_convertpath', NULL))) {
        $requirements['pdfthumb']['severity'] = REQUIREMENT_ERROR;
        $requirements['pdfthumb']['value'] = t('Can not find convert to this path. Go to the <a href="@pdfthumb_url">PDFThumb configuration page</a> to define it.', array(
          '@pdfthumb_url' => url('admin/config/media/pdfthumb'),
        ));
      }
      else {
        $requirements['pdfthumb']['severity'] = REQUIREMENT_OK;
        $requirements['pdfthumb']['value'] = variable_get('pdfthumb_convertpath');
      }
    }
    if (!empty($safe_mode_exec_dir)) {
      $requirements['pdfthumb']['severity'] = REQUIREMENT_WARNING;
      $requirements['pdfthumb']['value'] = t('open_base_dir restriction in effect. Make sure of <i>convert</i> is to this directory : @directory', array(
        '@directory' => $safe_mode_exec_dir,
      ));
    }
  }
  return $requirements;
}

/**
 * Implements hook_uninstall().
 */
function pdfthumb_uninstall() {
  db_delete('variable')
    ->condition('name', 'pdfthumb_%', 'LIKE')
    ->execute();
}

/**
 * Implements hook_schema().
 */
function pdfthumb_schema() {
  $schema['pdfthumb'] = array(
    'fields' => array(
      'pdffid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'fid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
  );
  return $schema;
}

Functions