elfinder.install in elFinder file manager 7.2
Same filename and directory in other branches
Installation file for elfinder.
File
elfinder.installView 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;
$ver_release = 0;
$min_major = 2;
$min_minor = 0;
$min_ver = "{$min_major}.{$min_minor}";
$libpath = elfinder_lib_path();
$ver = '';
$install_t = t('Please download it from <a href="@url">@url</a> and install to @libpath.', array(
'@url' => 'http://elfinder.org',
'@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|\\.prototype)\\.version\\s*=\\s*[\"\\']([^\"\\']+)[\"\\']/", $editor_file_content, $matches)) {
$ver = $matches[1];
$value = t('@ver', array(
'@ver' => $ver,
));
}
$description = '';
if (preg_match("/^(\\d+)\\.(\\d+|x)(\\.(\\d+))?/", $ver, $matches)) {
$ver_major = (int) $matches[1];
$ver_minor = $matches[2];
$ver = "{$ver_major}.{$ver_minor}";
if (count($matches) == 5) {
$ver_release = (int) $matches[4];
$ver = "{$ver_major}.{$ver_minor}.{$ver_release}";
}
}
if ($ver_major < $min_major || $ver_major == 2 && $ver_minor == '1' && $ver_release < 38) {
$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_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() {
}
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_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
Name![]() |
Description |
---|---|
elfinder_requirements | Implements hook_requirements(). |
elfinder_schema | |
elfinder_uninstall | |
elfinder_update_7101 | |
elfinder_update_7102 | |
elfinder_update_7103 | |
elfinder_update_7104 | Reformat the setting profile_role in elfinder_profile table. |