diff options
Diffstat (limited to 'modules/shortcut/shortcut.install')
-rw-r--r-- | modules/shortcut/shortcut.install | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/modules/shortcut/shortcut.install b/modules/shortcut/shortcut.install new file mode 100644 index 000000000..8fd57f0cc --- /dev/null +++ b/modules/shortcut/shortcut.install @@ -0,0 +1,109 @@ +<?php +// $Id$ + +/** + * @file + * Install, update and uninstall functions for the shortcut module. + */ + +/** + * Implement hook_enable(). + */ +function shortcut_enable() { + if (shortcut_set_load(SHORTCUT_DEFAULT_SET_NAME)) { + // Quit out; this module has already been installed before. + return; + } + + $t = get_t(); + // Create an initial default shortcut set. + $shortcut_set = new StdClass(); + $shortcut_set->title = $t('Default'); + $shortcut_set->links = array( + array( + 'link_path' => 'node/add', + 'link_title' => $t('Add content'), + 'weight' => -20, + ), + array( + 'link_path' => 'admin/content', + 'link_title' => $t('Find content'), + 'weight' => -19, + ), + array( + 'link_path' => 'admin/dashboard', + 'link_title' => $t('Dashboard'), + 'weight' => -18, + ), + ); + shortcut_set_save($shortcut_set); +} + +/** + * Implement hook_uninstall(). + */ +function shortcut_uninstall() { + // Delete the menu links associated with each shortcut set. + foreach (shortcut_sets() as $shortcut_set) { + menu_delete_links($shortcut_set->set_name); + } +} + +/** + * Implement hook_schema(). + */ +function shortcut_schema() { + $schema['shortcut_set'] = array( + 'description' => 'Stores information about sets of shortcuts links.', + 'fields' => array( + 'set_name' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE, + 'default' => '', + 'description' => "Primary Key: The {menu_links}.menu_name under which the set's links are stored.", + ), + 'title' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + 'description' => 'The title of the set.', + ), + ), + 'primary key' => array('set_name'), + 'foreign keys' => array( + 'set_name' => array('menu_links' => 'menu_name'), + ), + ); + + $schema['shortcut_set_users'] = array( + 'description' => 'Maps users to shortcut sets.', + 'fields' => array( + 'uid' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'The {users}.uid for this set.', + ), + 'set_name' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE, + 'default' => '', + 'description' => "The {shortcut_set}.set_name that will be displayed for this user.", + ), + ), + 'primary key' => array('uid'), + 'indexes' => array( + 'set_name' => array('set_name'), + ), + 'foreign keys' => array( + 'uid' => array('users' => 'uid'), + 'set_name' => array('shortcut_set' => 'set_name'), + ), + ); + + return $schema; +} |