function _nodesymlinks_nodeapi_prepare_presave in NodeSymlinks 6
Same name and namespace in other branches
- 7 nodesymlinks.inc \_nodesymlinks_nodeapi_prepare_presave()
Implementation of hook_nodeapi(); operation: prepare & presave.
See also
1 call to _nodesymlinks_nodeapi_prepare_presave()
- nodesymlinks_nodeapi in ./
nodesymlinks.module - Implementation of hook_nodeapi().
File
- ./
nodesymlinks.inc, line 152
Code
function _nodesymlinks_nodeapi_prepare_presave(&$node, $op) {
// Prepare the node for the edit form so that $node->menu always exists.
$items = array();
if (isset($node->nid)) {
// Check all menus if a link does not exist in the default menu.
$mlids = db_query("SELECT mlid FROM {menu_links} WHERE module = 'nodesymlinks' AND link_path LIKE 'node/%d/mid/%%' ORDER BY mlid ASC", $node->nid);
if ($mlids) {
while ($row = db_fetch_array($mlids)) {
$items[$row['mlid']] = $item = menu_link_load($row['mlid']);
$items[$row['mlid']]['fragment'] = empty($item['options']['fragment']) ? '' : $item['options']['fragment'];
if (module_exists('path')) {
$items[$row['mlid']]['alias'] = db_fetch_array(db_query("SELECT pid, dst as path FROM {url_alias} WHERE src = '%s' AND language = '%s'", $items[$row['mlid']]['link_path'], $node->language));
}
}
}
}
// Set default values.
$node->nodesymlinks['items'] = $items;
}