View source
<?php
function admin_install() {
if (db_table_exists('menu_custom') && !db_result(db_query("SELECT menu_name FROM {menu_custom} WHERE menu_name = 'admin'"))) {
$t = get_t();
db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'admin', $t('Admin'), $t('Administrative links.'));
}
}
function admin_uninstall() {
if (db_table_exists('menu_custom')) {
db_query("DELETE FROM {menu_custom} WHERE menu_name = 'admin'");
}
variable_del('admin_toolbar');
}
function admin_enable() {
$result = db_query("SELECT * FROM {menu_links} WHERE link_path LIKE 'admin%'");
while ($item = db_fetch_array($result)) {
_menu_delete_item($item, TRUE);
}
menu_rebuild();
db_query("UPDATE {system} SET weight = 1 WHERE name = 'admin' AND type = 'module'");
}
function admin_update_6001() {
$return = array();
$return[] = update_sql("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('admin', 'Admin', 'Admin links.')");
return $return;
}
function admin_update_6002() {
db_query("DELETE FROM {system} WHERE name = 'admin' AND type = 'theme'");
_admin_theme_rebuild(TRUE);
if (variable_get('admin_theme', NULL) == 'admin') {
variable_set('admin_theme', 'slate');
}
$result = db_query("SELECT * FROM {menu_links} WHERE link_path LIKE 'admin%'");
while ($item = db_fetch_array($result)) {
_menu_delete_item($item, TRUE);
}
menu_rebuild();
return array();
}
function admin_update_6003() {
$return = array();
$return[] = update_sql("UPDATE {system} SET weight = 1 WHERE name = 'admin' AND type = 'module'");
return $return;
}
function admin_update_6201() {
$return = array();
$result = db_query("SELECT * FROM {permission}");
while ($row = db_fetch_object($result)) {
$perms = explode(', ', $row->perm);
if (in_array('admin menu', $perms, TRUE)) {
$key = array_search('admin menu', $perms);
$perms[$key] = 'use admin toolbar';
$perms = implode(', ', $perms);
$return[] = update_sql("UPDATE {permission} SET perm = '{$perms}' WHERE pid = {$row->pid}");
}
}
variable_del('admin_theme_invalidated');
$theme = variable_get('admin_theme', '0');
if ($theme === 'admin' || $theme === 'slate') {
variable_del('admin_theme');
}
return $return;
}
function admin_update_6202() {
$ret = array();
$settings = variable_get('admin_toolbar', array());
if (isset($settings['blocks'])) {
$needs_update = FALSE;
foreach ($settings['blocks'] as $bid => $status) {
if (!is_numeric($status)) {
$needs_update = TRUE;
break;
}
}
if ($needs_update) {
module_load_include('module', 'admin', 'admin');
$defaults = admin_get_default_blocks(TRUE);
foreach ($settings['blocks'] as $bid => $status) {
if ($status) {
$settings['blocks'][$bid] = isset($defaults[$bid]) ? $defaults[$bid] : BLOCK_NO_CACHE;
}
else {
unset($settings['blocks'][$bid]);
}
}
variable_set('admin_toolbar', $settings);
$ret[] = array(
'success' => TRUE,
'query' => 'Updated admin settings.',
);
}
}
return $ret;
}