| 1 |
<?php
|
| 2 |
// $Id: toolbar.install,v 1.5 2009/10/09 08:02:25 webchick Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Installation functions for admin toolbar.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_install().
|
| 11 |
*
|
| 12 |
* @todo
|
| 13 |
* Implement role based shortcut bars.
|
| 14 |
*/
|
| 15 |
function toolbar_install() {
|
| 16 |
$t = get_t();
|
| 17 |
$menu = array(
|
| 18 |
'menu_name' => 'admin_shortcuts',
|
| 19 |
'title' => $t('Administration shortcuts'),
|
| 20 |
'description' => $t('The <em>Administration shortcuts</em> menu contains commonly used links for administrative tasks.'),
|
| 21 |
);
|
| 22 |
menu_save($menu);
|
| 23 |
|
| 24 |
// Add starter convenience shortcuts.
|
| 25 |
menu_rebuild();
|
| 26 |
$items = array(
|
| 27 |
'node/add' => 'Add content',
|
| 28 |
'admin/content' => 'Find content',
|
| 29 |
'admin/dashboard' => 'Dashboard',
|
| 30 |
);
|
| 31 |
$weight = -20;
|
| 32 |
foreach ($items as $path => $title) {
|
| 33 |
$link = array(
|
| 34 |
'mlid' => 0,
|
| 35 |
'link_title' => $title,
|
| 36 |
'link_path' => $path,
|
| 37 |
'router_path' => $path,
|
| 38 |
'menu_name' => 'admin_shortcuts',
|
| 39 |
'module' => 'menu',
|
| 40 |
'weight' => $weight,
|
| 41 |
);
|
| 42 |
|
| 43 |
// Check for an existing menu item before attempting to create a new one.
|
| 44 |
$menu_link = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :path AND menu_name = :menu_name", array(
|
| 45 |
':path' => $link['link_path'],
|
| 46 |
':menu_name' => $link['menu_name']
|
| 47 |
))
|
| 48 |
->fetchField();
|
| 49 |
if (!$menu_link) {
|
| 50 |
menu_link_save($link);
|
| 51 |
}
|
| 52 |
|
| 53 |
// Increment weight so items can be displayed in desired order.
|
| 54 |
$weight++;
|
| 55 |
}
|
| 56 |
}
|