rendered paste bodyIndex: myplay_navigation/myplay_navigation.module===================================================================--- myplay_navigation/myplay_navigation.module (revision 1896)+++ myplay_navigation/myplay_navigation.module (working copy)@@ -261,13 +261,7 @@ $node_type = $node_type == 'photos' ? 'photo' : $node_type; $panel_path = $node_type .'_asset'; $artist_nid = myplay_navigation_get_nid($artist_name, 'artist');- if ($node_type == 'photo') { - $nid = array_reverse(explode('-', $node_title));- $asset_nid = $nid[0];- }- else {- $asset_nid = myplay_navigation_get_nid($node_title, $node_type, $artist_nid, 'node');- }+ $asset_nid = myplay_navigation_get_nid($node_title, $node_type, $artist_nid, 'node'); $primary_url = url('node/'. $asset_nid); $args[] = $asset_nid; $args[] = $artist_nid;@@ -424,15 +418,37 @@ */ function myplay_navigation_get_nid($word, $type, $pid = NULL, $ptype = NULL, $reset = FALSE) { static $nodes;- ++ if ($type == 'photo') {+ $type = array('photo', 'official_photo');+ }+ $word = myplay_navigation_clean_word($word); if (!isset($nodes[$type][$word]) || $reset) {- $query = "SELECT id FROM {myplay_navigation} n WHERE safe_title = '%s' AND type = 'node' AND subtype = '%s'";+ $query = "SELECT id FROM {myplay_navigation} n WHERE safe_title = '%s' AND type = 'node'";+ $args = array($word);++ // Allow for type to be an array, such as photo and official_photo+ if (is_array($type)) {+ // Safe IN clauses: http://heine.familiedeelstra.com/security-overview-module+ $placeholders = implode(',', array_fill(0, count($type), "%d"));+ $query .= "' AND subtype IN ($placeholders)";+ $args += $type;+ }+ else {+ $query .= "' AND subtype = '%s'";+ $args += array($type);+ }++ // Increase accuracy by checking parent id and parent type. if ($pid && $ptype) { $query .= " AND pid = %d AND ptype = '%s'";+ $args += array($pid, $ptype); }- $result = db_query($query, $word, $type, $pid, $ptype);++ // Make the query.+ $result = db_query($query, $args); $nodes[$type][$word] = db_result($result); } @@ -678,8 +694,7 @@ return $artist_nid; } elseif ($args[2]) {- $type = 'official_photo';- return myplay_navigation_get_nid($args[2], $type, $artist_nid, 'node');+ return myplay_navigation_get_nid($args[2], 'photo', $artist_nid, 'node'); } break; }@@ -767,13 +782,7 @@ */ function myplay_navigation_check_url_word($word, $type, $pid = NULL, $ptype = NULL) { $clean_word = myplay_navigation_clean_word($word); // Justin Timberlake => justin-timberlake- if ($type == 'photo') {- $nid = array_reverse(explode('-', $clean_word));- $nid = $nid[0];- }- else {- $nid = myplay_navigation_get_nid($clean_word, $type, $pid, $ptype);- }+ $nid = myplay_navigation_get_nid($clean_word, $type, $pid, $ptype); // If we're unsuccessful in finding a nid, try expanding the word out and inserting a hyphen. if (empty($nid)) {