function menu_position_enable_helper in Menu Position 7.2
Same name and namespace in other branches
- 6 menu_position.admin.inc \menu_position_enable_helper()
- 7 menu_position.admin.inc \menu_position_enable_helper()
Fix rules after module has been re-enabled.
During menu_position_enable(), existing rules are flagged with a zero-value mlid. We fix that here.
1 call to menu_position_enable_helper()
- menu_position_rules_form_callback in ./
menu_position.admin.inc - Menu callback: orders rules.
File
- ./
menu_position.admin.inc, line 132 - Provides infrequently used functions and hooks for menu_position.
Code
function menu_position_enable_helper() {
// Find rules with zero-value menu links.
$rules = db_query('SELECT rid, plid, admin_title FROM {menu_position_rules} WHERE enabled = :enabled AND mlid = :mlid', array(
':enabled' => 1,
':mlid' => 0,
))
->fetchAll();
if (!empty($rules)) {
drupal_set_message(t('Existing menu position rules were discovered and have now been re-configured so they will continue to work.'));
}
foreach ($rules as $rule) {
$mlid = menu_position_add_menu_link($rule->rid, $rule->plid, $rule->admin_title);
db_update('menu_position_rules')
->fields(array(
'mlid' => $mlid,
))
->condition('rid', $rule->rid)
->execute();
}
}