You are here

imce.install in IMCE 6.2

Same filename and directory in other branches
  1. 8.2 imce.install
  2. 8 imce.install
  3. 6 imce.install
  4. 7 imce.install

Installs, updates, and uninstalls IMCE.

File

imce.install
View source
<?php

/**
 * @file
 * Installs, updates, and uninstalls IMCE.
 */

/**
 * Implementation of hook_install().
 */
function imce_install() {
  drupal_install_schema('imce');
  module_load_include('inc', 'imce', 'inc/imce.core.profiles');
  imce_install_profiles();
}

/**
 * Implementation of hook_uninstall().
 */
function imce_uninstall() {
  drupal_uninstall_schema('imce');
  variable_del('imce_profiles');
  variable_del('imce_roles_profiles');
  variable_del('imce_settings_textarea');
  variable_del('imce_settings_replace');
  variable_del('imce_settings_thumb_method');
  variable_del('imce_settings_disable_private');
  variable_del('imce_custom_content');
  variable_del('imce_custom_process');
  variable_del('imce_custom_init');
  variable_del('imce_custom_scan');
  variable_del('imce_custom_response');
}

/**
 * Implementation of hook_schema().
 */
function imce_schema() {
  $schema['imce_files'] = array(
    'description' => 'Stores files created by IMCE.',
    'fields' => array(
      'fid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {files}.fid that belongs to IMCE.',
      ),
    ),
    'primary key' => array(
      'fid',
    ),
  );
  return $schema;
}

/**
 * Update from 5.x to 6.x.
 */
function imce_update_6000() {
  module_load_include('inc', 'imce', 'inc/imce.core.profiles');
  imce_install_profiles();
  return array();
}

/**
 * New option: total user quota.
 */
function imce_update_6001() {
  $profiles = variable_get('imce_profiles', array());
  foreach ($profiles as $id => $profile) {
    $profiles[$id]['tuquota'] = 0;
  }
  variable_set('imce_profiles', $profiles);
  return array();
}

/**
 * Make file browser tab optional in user profiles.
 */
function imce_update_6002() {
  $profiles = variable_get('imce_profiles', array());
  foreach ($profiles as $id => $profile) {
    $profiles[$id]['usertab'] = isset($profiles[$id]['usertab']) ? $profiles[$id]['usertab'] : 1;
  }
  variable_set('imce_profiles', $profiles);
  return array(
    array(
      'success' => TRUE,
      'query' => 'File browser tab in user profiles was made optional.',
    ),
  );
}

/**
 * Convert 6.x-1.x to 6.x-2.x
 */
function imce_update_6200() {

  //delete deprecated variables.cancelled!
  return array();
}

/**
 * Introduce {imce_files} db table where IMCE files are stored.
 */
function imce_update_6201() {
  $ret = array();
  if (db_table_exists('imce_files')) {
    return $ret;
  }
  $table = array(
    'description' => 'Stores files created by IMCE.',
    'fields' => array(
      'fid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {files}.fid that belongs to IMCE.',
      ),
    ),
    'primary key' => array(
      'fid',
    ),
  );
  db_create_table($ret, 'imce_files', $table);
  return $ret;
}

/**
 * Fixes misconfigurations where anonymous user is given User-1 profile
 */
function imce_update_6202() {
  $roles = variable_get('imce_roles_profiles', array());
  $rid = DRUPAL_ANONYMOUS_RID;
  if (!empty($roles[$rid]['pid']) && $roles[$rid]['pid'] == 1) {
    $roles[$rid]['pid'] = '0';
    variable_set('imce_roles_profiles', $roles);
  }
  return array();
}

Functions

Namesort descending Description
imce_install Implementation of hook_install().
imce_schema Implementation of hook_schema().
imce_uninstall Implementation of hook_uninstall().
imce_update_6000 Update from 5.x to 6.x.
imce_update_6001 New option: total user quota.
imce_update_6002 Make file browser tab optional in user profiles.
imce_update_6200 Convert 6.x-1.x to 6.x-2.x
imce_update_6201 Introduce {imce_files} db table where IMCE files are stored.
imce_update_6202 Fixes misconfigurations where anonymous user is given User-1 profile