Saves a shortcut set.
$shortcut_set: An object containing the following properties:
Any other keys accepted by menu_link_save() may also be provided.
A constant which is either SAVED_NEW or SAVED_UPDATED depending on whether a new set was created or an existing one was updated.
function shortcut_set_save(&$shortcut_set) {
// First save the shortcut set itself.
if (isset($shortcut_set->set_name)) {
$return = drupal_write_record('shortcut_set', $shortcut_set, 'set_name');
}
else {
$shortcut_set->set_name = shortcut_set_get_unique_name();
$return = drupal_write_record('shortcut_set', $shortcut_set);
}
// If links were provided for the set, save them.
if (isset($shortcut_set->links)) {
foreach ($shortcut_set->links as &$link) {
// Do not specifically associate these links with the shortcut module,
// since other modules may make them editable via the menu system.
// However, we do need to specify the correct menu name.
$link['menu_name'] = $shortcut_set->set_name;
$link['plid'] = 0;
menu_link_save($link);
}
// Make sure that we have a return value, since if the links were updated
// but the shortcut set was not, the call to drupal_write_record() above
// would not return an indication that anything had changed.
if (empty($return)) {
$return = SAVED_UPDATED;
}
}
return $return;
}