home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (imce.install)

This example Drupal source code file (imce.install) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, description, fid, fields, foreach, function, imce, key, php, profiles, return, stores, true, unsigned

The imce.install Drupal example source code

<?php
// $Id: imce.install,v 1.3.2.7 2010/06/05 08:00:45 ufku Exp $

/**
 * @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();
  drupal_set_message(t('!module has been installed.', array('!module' => l('IMCE', 'admin/settings/imce'))));
}

/**
 * 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_scan');
}

/**
 * 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();
  $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;
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal imce.install source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.