function nodesymlinks_item_save in NodeSymlinks 6
Same name and namespace in other branches
- 7 nodesymlinks.inc \nodesymlinks_item_save()
Save item to database, create alias for duplicate menulink if original node has one. Returns TRUE if saving was successfull, else returns FALSE.
Parameters
item $item:
node $node:
Return value
menu link ID or FALSE
1 call to nodesymlinks_item_save()
- _nodesymlinks_nodeapi_insert_update in ./
nodesymlinks.inc - Implementation of hook_nodeapi() OP: Insert & Update.
File
- ./
nodesymlinks.inc, line 580
Code
function nodesymlinks_item_save(&$item, &$node) {
/**
* If this function is updated, please update its counterpart in
* nodesymlinks.install, which exists to restore deleted menu_links during
* module re-enable.
*/
$item['options']['fragment'] = empty($item['fragment']) ? '' : $item['fragment'];
if (menu_link_save($item)) {
// If the item is new, we need to save it second time - now with real mlid.
if ($item['is_new']) {
$item['link_path'] = nodesymlinks_create_item_path($item, $node);
menu_link_save($item);
}
// Because menu_links is wiped out on module disable (not Uninstall),
// we need to store this for later re-use if we detect a module re-enable.
if ($item['is_new']) {
// Save data in our permanent store.
db_query("INSERT INTO {nodesymlinks_link_storage} (\n mlid, nid, item_data) VALUES (\n %d, %d, '%s')", $item['mlid'], $node->nid, serialize($item));
}
else {
// Update in permanent store.
db_query("UPDATE {nodesymlinks_link_storage} SET\n nid = %d, item_data = '%s' WHERE\n mlid = %d", $node->nid, serialize($item), $item['mlid']);
}
// Creates appropriate aliases.
$item['link_path'] = nodesymlinks_create_item_path($item, $node);
nodesymlinks_item_alias_save($item, $node);
return $item['mlid'];
}
return FALSE;
}