You are here

function menu_position_enable_helper in Menu Position 6

Same name and namespace in other branches
  1. 7.2 menu_position.admin.inc \menu_position_enable_helper()
  2. 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 157
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 = 1 AND mlid = 0');
  $result = db_affected_rows();
  if ($result) {
    drupal_set_message(t('Existing menu position rules were discovered and have now been re-configured so they will continue to work.'));
  }
  while ($rule = db_fetch_object($rules)) {
    $mlid = menu_position_add_menu_link($rule->rid, $rule->plid, $rule->admin_title);
    db_query('UPDATE {menu_position_rules} SET mlid = %d WHERE rid = %d', $mlid, $rule->rid);
  }
}