Projet

Général

Profil

Paste
Télécharger (3,42 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / admin_menu / admin_menu.install @ 76df55b7

1
<?php
2

    
3
/**
4
 * @file
5
 * Install, update, and uninstall functions for the admin menu module.
6
 */
7

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

    
17
/**
18
 * Implements hook_install().
19
 */
20
function admin_menu_install() {
21
  // Increase the module weight, so admin_menu catches any alterations made by
22
  // other modules in hook_menu_alter().
23
  db_update('system')
24
    ->fields(array('weight' => 100))
25
    ->condition('type', 'module')
26
    ->condition('name', 'admin_menu')
27
    ->execute();
28
}
29

    
30
/**
31
 * Implements hook_uninstall().
32
 */
33
function admin_menu_uninstall() {
34
  // Delete variables.
35
  variable_del('admin_menu_components');
36
  variable_del('admin_menu_margin_top');
37
  variable_del('admin_menu_position_fixed');
38
  variable_del('admin_menu_tweak_modules');
39
  variable_del('admin_menu_tweak_tabs');
40
  variable_del('admin_menu_show_all');
41
  variable_del('admin_menu_display');
42
  variable_del('admin_menu_cache_server');
43
  variable_del('admin_menu_cache_client');
44
  // Unused variables still should be deleted.
45
  variable_del('admin_menu_devel_modules');
46
  variable_del('admin_menu_devel_modules_enabled');
47
  variable_del('admin_menu_devel_modules_skip');
48
}
49

    
50
/**
51
 * Ensure that admin_menu is rebuilt after upgrading to D6.
52
 */
53
function admin_menu_update_6000() {
54
  // Drop the {admin_menu} table in admin_menu_update_6000() on sites that used
55
  // one of the later patches in #132524.
56
  if (db_table_exists('admin_menu')) {
57
    db_drop_table('admin_menu');
58
  }
59
}
60

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

    
69
/**
70
 * Add {cache_admin_menu} table.
71
 */
72
function admin_menu_update_7300() {
73
  if (!db_table_exists('cache_admin_menu')) {
74
    $schema = drupal_get_schema_unprocessed('system', 'cache');
75
    db_create_table('cache_admin_menu', $schema);
76
  }
77
}
78

    
79
/**
80
 * Increase the module weight.
81
 *
82
 * @see admin_menu_install()
83
 */
84
function admin_menu_update_7302() {
85
  db_update('system')
86
    ->fields(array('weight' => 100))
87
    ->condition('type', 'module')
88
    ->condition('name', 'admin_menu')
89
    ->execute();
90
}
91

    
92
/**
93
 * Remove local tasks from {menu_links} table.
94
 */
95
function admin_menu_update_7303() {
96
  db_delete('menu_router')
97
    ->condition('path', 'admin/%', 'LIKE')
98
    ->condition('type', MENU_IS_LOCAL_TASK, '&')
99
    ->execute();
100
}
101

    
102
/**
103
 * Remove obsolete 'admin_menu' menu and all orphan links in it.
104
 */
105
function admin_menu_update_7304() {
106
  // Remove the custom menu used by 6.x-1.x.
107
  if (db_table_exists('menu_custom')) {
108
    db_delete('menu_custom')->condition('menu_name', 'admin_menu')->execute();
109
  }
110

    
111
  // 6.x-1.x cloned the entire link structure below the path 'admin' into a
112
  // separate 'menu_name' "admin_menu" with 'module' "admin_menu". 6.x-3.x and
113
  // early alpha versions of 7.x-3.x still did something similar. All of these
114
  // records are obsolete. Removal of the 'module' records (without different
115
  // menu_name) is particularly important, since they would otherwise appear
116
  // as duplicate links.
117
  db_delete('menu_links')
118
    ->condition(db_or()
119
      ->condition('module', 'admin_menu')
120
      ->condition('menu_name', 'admin_menu')
121
    )
122
    ->execute();
123
}