You are here

function menu_position_add_rule in Menu Position 6

Same name and namespace in other branches
  1. 7.2 menu_position.admin.inc \menu_position_add_rule()
  2. 7 menu_position.admin.inc \menu_position_add_rule()

Adds a menu position rule.

1 call to menu_position_add_rule()
menu_position_rule_form_submit in ./menu_position.admin.inc
Handles form submission for menu_position_rule_form().

File

./menu_position.admin.inc, line 481
Provides infrequently used functions and hooks for menu_position.

Code

function menu_position_add_rule($rule) {
  $fields = array(
    'admin_title' => $rule['admin_title'],
    'conditions' => $rule['conditions'],
    'menu_name' => $rule['menu_name'],
    'plid' => $rule['plid'],
  );
  db_query('INSERT INTO {menu_position_rules} (' . implode(', ', array_keys($fields)) . ') VALUES ("%s", "%s", "%s", %d)', array_values($fields));
  $rid = db_last_insert_id('menu_position_rules', 'rid');
  $mlid = menu_position_add_menu_link($rid, $rule['plid'], $rule['admin_title']);

  // Now add the mlid back to the rule.
  db_query('UPDATE {menu_position_rules} SET mlid = %d WHERE rid = %d', $mlid, $rid);
}