You are here

elfinder.install in elFinder file manager 7.3

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();
  $elfinder_installed_version = elfinder_get_installed_version();
  $elfinder_lib_path = elfinder_lib_path();
  $install_t = t('Version @ver or newer is required. Download it from <a href="@url">@url</a> and install to @libpath.', array(
    '@ver' => ELFINDER_MINIUM_VERSION,
    '@url' => elfinder_download_url(),
    '@libpath' => $elfinder_lib_path ? $elfinder_lib_path : 'sites/all/libraries/elfinder',
  ));
  if ($phase == 'runtime') {
    if (!$elfinder_installed_version) {
      $requirements['elfinder'] = array(
        'title' => t('elFinder file manager'),
        'value' => $elfinder_installed_version ? $elfinder_installed_version : t('not found'),
        'severity' => REQUIREMENT_ERROR,
        'description' => t('elFinder library was not found.') . ' ' . $install_t,
      );
    }
    elseif (!version_compare($elfinder_installed_version, ELFINDER_MINIUM_VERSION, '>=')) {
      $requirements['elfinder'] = array(
        'title' => t('elFinder file manager'),
        'value' => $elfinder_installed_version,
        'severity' => REQUIREMENT_ERROR,
        'description' => t('Unsupported elFinder library.') . ' ' . $install_t,
      );
    }
    elseif ($badfiles_msg = elfinder_badfiles_exist()) {
      $requirements['elfinder'] = array(
        'title' => t('elFinder file manager'),
        'value' => $elfinder_installed_version,
        'severity' => REQUIREMENT_ERROR,
        'description' => $badfiles_msg,
      );
    }
    else {
      $requirements['elfinder'] = array(
        'title' => t('elFinder file manager'),
        'severity' => REQUIREMENT_OK,
        'value' => $elfinder_installed_version,
      );
    }
  }
  return $requirements;
}
function elfinder_uninstall() {
  db_delete('variable')
    ->condition('name', 'elfinder_%', 'like')
    ->execute();
  cache_clear_all('variables', 'cache');
}
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_ffield($ret, 'elfinder_profile', 'settings', array(
      'type' => 'text',
      'not null' => FALSE,
    ));
  }
  return $ret;
}
function elfinder_update_7103() {
  drupal_flush_all_caches();
}

/**
 * Reformat the setting profile_role in elfinder_profile table.
 */
function elfinder_update_7104() {
  $results = db_query("SELECT pid, name, description, settings from {elfinder_profile}");
  foreach ($results as $row) {
    $settings = unserialize($row->settings);
    if (!is_array($settings['profile_role'])) {
      if (isset($settings['profile_role']) && $settings['profile_role'] > 0) {
        $settings['profile_role'] = array(
          $settings['profile_role'] => $settings['profile_role'],
        );
      }
      else {
        $settings['profile_role'] = array();
      }
      db_update('elfinder_profile')
        ->fields(array(
        'settings' => serialize($settings),
      ))
        ->condition('pid', $row->pid)
        ->execute();
    }
  }
}

Functions