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

Drupal example source code file (admin_menu.install)

This example Drupal source code file (admin_menu.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

100, admin_menu, admin_menu_install, admin_menu_update_6000, admin_menu_update_6001, admin_menu_update_7302, admin_menu_update_7303, cache, execute, function, if, module, php, schema

The admin_menu.install Drupal example source code

<?php
// $Id: admin_menu.install,v 1.25 2011/01/06 23:27:40 sun Exp $

/**
 * @file
 * Install, update, and uninstall functions for the admin menu module.
 */

/**
 * Implements hook_schema().
 */
function admin_menu_schema() {
  $schema['cache_admin_menu'] = drupal_get_schema_unprocessed('system', 'cache');
  $schema['cache_admin_menu']['description'] = 'Cache table for Administration menu to store client-side caching hashes.';
  return $schema;
}

/**
 * Implements hook_install().
 */
function admin_menu_install() {
  // Increase the module weight, so admin_menu catches any alterations made by
  // other modules in hook_menu_alter().
  db_update('system')
    ->fields(array('weight' => 100))
    ->condition('type', 'module')
    ->condition('name', 'admin_menu')
    ->execute();
}

/**
 * Implements hook_uninstall().
 */
function admin_menu_uninstall() {
  // Delete variables.
  variable_del('admin_menu_devel_modules');
  variable_del('admin_menu_devel_modules_enabled');
  variable_del('admin_menu_devel_modules_skip');
  variable_del('admin_menu_margin_top');
  variable_del('admin_menu_position_fixed');
  variable_del('admin_menu_tweak_modules');
  variable_del('admin_menu_tweak_tabs');
  variable_del('admin_menu_show_all');
  variable_del('admin_menu_display');
  variable_del('admin_menu_cache_server');
  variable_del('admin_menu_cache_client');
}

/**
 * Ensure that admin_menu is rebuilt after upgrading to D6.
 */
function admin_menu_update_6000() {
  // Drop the {admin_menu} table in admin_menu_update_6000() on sites that used
  // one of the later patches in #132524.
  if (db_table_exists('admin_menu')) {
    db_drop_table('admin_menu');
  }
}

/**
 * Wipe and rebuild so we can switch the icon path to <front>.
 */
function admin_menu_update_6001() {
  db_delete('menu_links')->condition('module', 'admin_menu')->execute();
  menu_cache_clear('admin_menu');
}

/**
 * Add {cache_admin_menu} table.
 */
function admin_menu_update_7300() {
  if (!db_table_exists('cache_admin_menu')) {
    $schema = drupal_get_schema_unprocessed('system', 'cache');
    db_create_table('cache_admin_menu', $schema);
  }
}

/**
 * Increase the module weight.
 *
 * @see admin_menu_install()
 */
function admin_menu_update_7302() {
  db_update('system')
    ->fields(array('weight' => 100))
    ->condition('type', 'module')
    ->condition('name', 'admin_menu')
    ->execute();
}

/**
 * Remove local tasks from {menu_links} table.
 */
function admin_menu_update_7303() {
  db_delete('menu_router')
    ->condition('path', 'admin/%', 'LIKE')
    ->condition('type', MENU_IS_LOCAL_TASK, '&')
    ->execute();
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal admin_menu.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.