function _menu_position_save_rule in Menu Position 7
Saves a menu position to the database.
Parameters
array $field_data: The field data to save.
1 call to _menu_position_save_rule()
- menu_position_features_revert in ./
menu_position.features.inc - Implements hook_features_revert().
File
- ./
menu_position.features.inc, line 81 - Integration with the Features module.
Code
function _menu_position_save_rule(array $field_data) {
module_load_include('inc', 'menu_position', 'menu_position.admin');
// Update/insert the rule.
db_merge('menu_position_rules')
->key(array(
'machine_name' => $field_data['machine_name'],
))
->fields($field_data)
->execute();
// Update the menu link.
$result = db_query('SELECT rid FROM {menu_position_rules} WHERE machine_name = :machine_name', array(
':machine_name' => $field_data['machine_name'],
))
->fetchAssoc();
menu_position_edit_menu_link($result['rid'], $field_data['mlid'], $field_data['plid'], $field_data['admin_title']);
// Override the menu link id.
$query = db_update('menu_links')
->fields(array(
'mlid' => $field_data['mlid'],
))
->condition('menu_name', $field_data['menu_name'])
->condition('plid', $field_data['plid'])
->condition('module', 'menu_position')
->condition('link_title', $field_data['admin_title'] . ' (menu position rule)');
$query
->execute();
}