--- favorite_nodes.module 2006-11-21 11:57:38.000000000 -0500 +++ favorite_nodes.module.new 2006-11-21 12:08:59.000000000 -0500 @@ -64,7 +64,7 @@ foreach ($node_types as $type => $name) { if (variable_get(FAVORITE_NODES_NODE_TYPE . $type, 0)) { $uid = intval($user->uid); - $favorites = _favorite_nodes_get($uid, $type, variable_get('favorite_nodes_block_limit', 5)); + $favorites = favorite_nodes_get($uid, $type, variable_get('favorite_nodes_block_limit', 5)); $items = array(); if (count($favorites) > 0) { foreach ($favorites as $favorite) { @@ -173,7 +173,7 @@ function favorite_nodes_view() { $uid = (int)arg(2); $type = arg(3); - print theme('page', theme('favorite_nodes_view', _favorite_nodes_get($uid, $type))); + print theme('page', theme('favorite_nodes_view', favorite_nodes_get($uid, $type))); } function theme_favorite_nodes_view($list = array()) { @@ -208,7 +208,7 @@ foreach(node_get_types() as $type => $name) { if (variable_get(FAVORITE_NODES_NODE_TYPE . $type, 0)) { $uid = intval($user->uid); - $favorites = _favorite_nodes_get($uid, $type, variable_get('favorite_nodes_block_limit', 5)); + $favorites = favorite_nodes_get($uid, $type, variable_get('favorite_nodes_block_limit', 5)); $items = array(); if (count($favorites) > 0) { foreach ($favorites as $favorite) { @@ -246,8 +246,9 @@ db_query("DELETE FROM {favorite_nodes} WHERE uid = %d", $uid); } -function _favorite_nodes_get($uid, $type = NULL, $limit = 0) { - if ($type && variable_get(FAVORITE_NODES_NODE_TYPE . $type, 0)) { +function favorite_nodes_get($uid, $type = NULL, $limit = 0) { + $row = array(); + if ($type && variable_get(FAVORITE_NODES_NODE_TYPE . $type, 0)) { $sql = "SELECT n.nid, n.title, f.uid, f.last FROM {node} n INNER JOIN {favorite_nodes} f USING(nid) WHERE n.type = '%s' AND f.uid = %d ORDER by f.last DESC"; $limit = intval($limit); @@ -260,9 +261,20 @@ while ($data = db_fetch_object($result)) { $row[$data->nid] = $data; } - return $row; } } + return $row; +} + +function favorite_nodes_get_users($nid) { + $sql = "SELECT u.*, f.last FROM {users} u INNER JOIN {favorite_nodes} f USING(uid) WHERE f.nid = %d ORDER by f.last DESC"; + $result = db_query($sql, $nid); + $row = array(); + while ($data = db_fetch_object($result)) { + $row[$data->uid] = $data; + } + + return $row; } function _favorite_nodes_check($nid) {