Projet

Général

Profil

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

root / drupal7 / sites / all / modules / admin_menu / admin_menu.install @ db9ffd17

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_devel_modules');
37
  variable_del('admin_menu_devel_modules_enabled');
38
  variable_del('admin_menu_devel_modules_skip');
39
  variable_del('admin_menu_margin_top');
40
  variable_del('admin_menu_position_fixed');
41
  variable_del('admin_menu_tweak_modules');
42
  variable_del('admin_menu_tweak_tabs');
43
  variable_del('admin_menu_show_all');
44
  variable_del('admin_menu_display');
45
  variable_del('admin_menu_cache_server');
46
  variable_del('admin_menu_cache_client');
47
}
48

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

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

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

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

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

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

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