function _notifications_node_references in Notifications 6
Same name and namespace in other branches
- 6.4 includes/node.inc \_notifications_node_references()
- 6.2 notifications.node.inc \_notifications_node_references()
- 6.3 notifications.node.inc \_notifications_node_references()
- 7 includes/node.inc \_notifications_node_references()
Find node title matches.
Some code from CCK's nodereference.module
3 calls to _notifications_node_references()
- notifications_node_autocomplete_title in ./
notifications.node.inc - Menu callback; Retrieve a pipe delimited string of autocomplete suggestions for existing users
- notifications_node_autocomplete_type in ./
notifications.node.inc - Menu callback; Retrieve a pipe delimited string of autocomplete suggestions for existing users
- notifications_node_title2nid in ./
notifications.node.inc - Reverse mapping from node title to nid
File
- ./
notifications.node.inc, line 101 - Notifications node API for use by plug-in modules providing node related features
Code
function _notifications_node_references($string, $match = 'contains', $types = array(), $limit = 10) {
$match_operators = array(
'contains' => "LIKE '%%%s%%'",
'equals' => "= '%s'",
'starts_with' => "LIKE '%s%%'",
);
if ($types) {
$where[] = 'n.type IN (' . db_placeholders($types, 'string') . ') ';
$args = $types;
}
$where[] = 'n.title ' . (isset($match_operators[$match]) ? $match_operators[$match] : $match_operators['contains']);
$args[] = $string;
$sql = db_rewrite_sql('SELECT n.nid, n.title, n.type FROM {node} n WHERE ' . implode(' AND ', $where) . ' ORDER BY n.title, n.type');
$result = db_query_range($sql, $args, 0, $limit);
$references = array();
while ($node = db_fetch_object($result)) {
$references[$node->nid] = array(
'title' => check_plain($node->title),
'rendered' => check_plain($node->title),
);
}
return $references;
}