You are here

elfinder.install in elFinder file manager 8.2

Installation file for elfinder.

File

elfinder.install
View source
<?php

/**
 * @file
 * Installation file for elfinder.
 */

/**
 * Implements hook_requirements().
 */
function elfinder_requirements($phase) {
  require_once drupal_get_path('module', 'elfinder') . "/elfinder.module";
  $requirements = array();
  $ver_major = 0;
  $ver_minor = 0;
  $min_major = 2;
  $min_minor = 0;
  $min_ver = "{$min_major}.{$min_minor}";
  $libpath = elfinder_lib_path();
  $install_t = t('Please download it from @url and install to @libpath.', array(
    '@url' => 'http://sourceforge.net/projects/elfinder/files/',
    '@libpath' => $libpath,
  ));
  if ($phase == 'runtime' || $phase == 'install' || $phase == 'update') {
    $description = t('elFinder library was not found.') . ' ' . $install_t;
    $severity = '';
    $value = t('Not found');
    if ((is_readable($libpath . '/connectors/php/elFinder.class.php') || is_readable($libpath . '/php/elFinder.class.php')) && is_readable($libpath . '/js/elfinder.min.js')) {
      $editor_file_content = file_get_contents($libpath . '/js/elfinder.min.js');
      $value = t('Exists');
      if (preg_match("/(?:this|elFinder\\.prototype)\\.version\\s*=\\s*[\"\\']([^\"\\']+)[\"\\']/", $editor_file_content, $matches)) {
        $ver = $matches[1];
        $value = t('@ver', array(
          '@ver' => $ver,
        ));
      }
      $description = '';
      if (preg_match("/^(\\d+)\\.(\\d+|x)/", $ver, $matches)) {
        $ver_major = $matches[1];
        $ver_minor = $matches[2];
      }
      $ver = "{$ver_major}.{$ver_minor}";
      if ($ver_major < $min_major) {
        $description = t('Not supported elFinder library. Please upgrade to @minver.', array(
          '@ver' => $ver,
          '@minver' => $min_ver,
        )) . ' ' . $install_t;
        $severity = REQUIREMENT_ERROR;
      }
      else {
        $severity = REQUIREMENT_OK;
      }
      $badpaths_check = elfinder_check_badpaths();
      if ($badpaths_check['result'] == FALSE) {
        $severity = REQUIREMENT_ERROR;
        $description = $badpaths_check['message'];
      }
    }
    else {
      $severity = REQUIREMENT_ERROR;
    }
    $requirements['elfinder'] = array(
      'title' => 'elFinder',
      'description' => $description,
      'value' => $value,
      'severity' => $severity,
    );
  }
  return $requirements;
}
function elfinder_uninstall() {

  //db_query("DELETE FROM {variable} WHERE name LIKE 'elfinder_%%'");
}
function elfinder_schema() {
  $schema = array();
  $schema['elfinder_file_extinfo'] = array(
    'description' => 'Stores additional filesystem attributes',
    'fields' => array(
      'extid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'fid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'description' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'extid',
    ),
  );
  $schema['elfinder_profile'] = array(
    'description' => 'Stores configuration profiles',
    'fields' => array(
      'pid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => '',
      ),
      'description' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => '',
      ),
      'settings' => array(
        'type' => 'text',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'pid',
    ),
  );
  return $schema;
}
function elfinder_update_7101() {

  // drupal_install_schema('elfinder');
}
function elfinder_update_7102() {
  $ret = array();
  if (db_table_exists('elfinder_profile') == FALSE) {
    drupal_install_schema('elfinder');
  }
  if (!db_field_exists('elfinder_profile', 'settings')) {
    db_add_field($ret, 'elfinder_profile', 'settings', array(
      'type' => 'text',
      'not null' => FALSE,
    ));
  }
  return $ret;
}

/*function elfinder_update_8000() {
  update_variables_to_config('elfinder.settings', array(
    'elfinder_settings_thumbnail_size' => 'thumbnail.size',
    'elfinder_settings_thumbnail_dirname' => 'thumbnail.dirname',
    'elfinder_settings_thumbnail_tmbcrop' => 'thumbnail.tmbcrop',
    'elfinder_settings_thumbnail_imglib' => 'thumbnail.imglib',
    'elfinder_settings_filesystem_mimedetect' => 'filesystem.mimedetect',
    'elfinder_settings_filesystem_fileperm' => 'filesystem.fileperm', 
    'elfinder_settings_filesystem_dirperm' => 'filesystem.dirperm',
    'elfinder_settings_filesystem_maxfilesize' => 'filesystem.maxfilesize',
    'elfinder_settings_filesystem_public_root_label' => 'filesystem.public_root_label',
    'elfinder_settings_filesystem_private_root_label' => 'filesystem.private_root_label',
    'elfinder_settings_filesystem_unmanaged_root_label' => 'filesystem.unmanaged_root_label',
    'elfinder_settings_filesystem_root_custom' => 'filesystem.root_custom',
    'elfinder_settings_filesystem_url_custom' => 'filesystem.url_custom',
    'elfinder_settings_filesystem_handleprivate' => 'filesystem.handleprivate',
    'elfinder_settings_filesystem_owner_format' => 'filesystem.owner_format',
    'elfinder_settings_filesystem_allowed_extensions' => 'filesystem.allowed_extensions',
    'elfinder_settings_filesystem_fileurl' => 'filesystem.fileurl',
    'elfinder_settings_misc_rememberlastdir' => 'misc.rememberlastdir',
    'elfinder_settings_misc_requesttype' => 'misc.requesttype',
    'elfinder_settings_misc_manager_width' => 'misc.manager_width',
    'elfinder_settings_misc_manager_height' => 'misc.manager_height',
    'elfinder_settings_misc_usesystemjquery' => 'misc.usesystemjquery',
  ));
}*/