58 lines
1.4 KiB
Plaintext
58 lines
1.4 KiB
Plaintext
<?php
|
|
// $Id$
|
|
|
|
/**
|
|
* @file
|
|
* Installation functions for admin toolbar.
|
|
*/
|
|
|
|
/**
|
|
* Implementation of hook_install().
|
|
*
|
|
* @todo
|
|
* Implement role based shortcut bars.
|
|
*/
|
|
function toolbar_install() {
|
|
$t = get_t();
|
|
$query = db_insert('menu_custom')
|
|
->fields(array(
|
|
'menu_name' => 'admin_shortcuts',
|
|
'title' => $t('Administration shortcuts'),
|
|
'description' => $t('The <em>Admininstration shortcuts</em> menu contains commonly used links for administrative tasks.')
|
|
))
|
|
->execute();
|
|
|
|
// Add starter convenience shortcuts.
|
|
menu_rebuild();
|
|
$items = array(
|
|
'node/add' => 'Add content',
|
|
'admin/content' => 'Find content',
|
|
'admin' => 'Dashboard',
|
|
);
|
|
$weight = -20;
|
|
foreach ($items as $path => $title) {
|
|
$link = array(
|
|
'mlid' => 0,
|
|
'link_title' => $title,
|
|
'link_path' => $path,
|
|
'router_path' => $path,
|
|
'menu_name' => 'admin_shortcuts',
|
|
'module' => 'menu',
|
|
'weight' => $weight,
|
|
);
|
|
|
|
// Check for an existing menu item before attempting to create a new one.
|
|
$menu_link = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :path AND menu_name = :menu_name", array(
|
|
':path' => $link['link_path'],
|
|
':menu_name' => $link['menu_name']
|
|
))
|
|
->fetchField();
|
|
if (!$menu_link) {
|
|
menu_link_save($link);
|
|
}
|
|
|
|
// Increment weight so items can be displayed in desired order.
|
|
$weight++;
|
|
}
|
|
}
|