function menu_position_enable in Menu Position 6
Same name and namespace in other branches
- 7.2 menu_position.install \menu_position_enable()
- 7 menu_position.install \menu_position_enable()
Implements hook_enable().
When the module is disabled, the menu links it owns are deleted. When re-enabling this module, we need to ensure that any menu links are re-created and to re-configure any old rules existing in the database.
File
- ./
menu_position.install, line 86 - Provides install, update and un-install functions for menu_position.
Code
function menu_position_enable() {
$enabled_rules = db_result(db_query('SELECT count(*) AS rule_count FROM {menu_position_rules} WHERE enabled = 1'));
if ($enabled_rules) {
drupal_set_message(t('Existing menu position rules were discovered. To ensure they continue to work, visit the <a href="!url">menu position rules admin page</a>.', array(
'!url' => url('admin/build/menu-position'),
)), 'error');
// If we were to attempt menu_position_add_menu_link() here it would fail
// because the module's router item isn't in the system yet. Instead we flag
// the rule with a zero-value mlid and fix it in
// menu_position_rules_form_callback().
db_query('UPDATE {menu_position_rules} SET mlid = 0 WHERE enabled = 1');
}
}