| 1 |
<?php |
<?php |
| 2 |
// $Id: node_recommendation.module,v 1.1.4.7 2007/05/09 17:14:45 hickory Exp $ |
// $Id: node_recommendation.module,v 1.1.4.8 2007/07/23 14:11:41 hickory Exp $ |
| 3 |
|
|
| 4 |
/* |
/* |
| 5 |
* hook_help |
* hook_help |
| 277 |
|
|
| 278 |
$recommendations = $uid ? cre_top($uid, 'node_recommendation_cre_query', $n, 'node', variable_get('node_recommendation_tag', 'vote'), 'node', array($type)) : _node_recommendation_get_top_rated_nodes($n); // return recommendations for logged-in users, top-rated nodes otherwise. |
$recommendations = $uid ? cre_top($uid, 'node_recommendation_cre_query', $n, 'node', variable_get('node_recommendation_tag', 'vote'), 'node', array($type)) : _node_recommendation_get_top_rated_nodes($n); // return recommendations for logged-in users, top-rated nodes otherwise. |
| 279 |
|
|
| 280 |
|
if($uid != 0 ) { |
| 281 |
|
$recommendations = cre_top($uid, 'node_recommendation_cre_query', $n, 'node', variable_get('node_recommendation_tag', 'vote'), 'node', array($type)); |
| 282 |
|
if($recommendations == NULL) { |
| 283 |
|
// user doesn't have any recommendations therefore! return top nodes |
| 284 |
|
$recommendations = _node_recommendation_get_top_rated_nodes($n); |
| 285 |
|
} |
| 286 |
|
} |
| 287 |
|
else { // anon user therefore just get the top rated nodes |
| 288 |
|
$recommendations = _node_recommendation_get_top_rated_nodes($n); |
| 289 |
|
} |
| 290 |
$content = array(); |
$content = array(); |
| 291 |
foreach ($recommendations as $node) { |
foreach ($recommendations as $node) { |
| 292 |
$content[] = theme('cre_node_view', $node->content_id); |
$content[] = theme('cre_node_view', $node->content_id); |
| 300 |
function _node_recommendation_get_top_rated_nodes($n) { |
function _node_recommendation_get_top_rated_nodes($n) { |
| 301 |
$result = db_query("SELECT c.content_id as content_id, c.value as avg_vote, n.title |
$result = db_query("SELECT c.content_id as content_id, c.value as avg_vote, n.title |
| 302 |
FROM {votingapi_cache} c, {node} n |
FROM {votingapi_cache} c, {node} n |
| 303 |
WHERE c.content_id = n.nid AND c.function = 'average' AND c.tag = '%s' |
WHERE c.content_id = n.nid AND c.function = 'average' AND c.tag = '%s' AND c.content_type = 'node' |
| 304 |
ORDER BY avg_vote DESC LIMIT %d", |
ORDER BY avg_vote DESC LIMIT %d", |
| 305 |
variable_get('node_recommendation_tag', 'vote'), $n); |
variable_get('node_recommendation_tag', 'vote'), $n); |
| 306 |
$voting_results = array(); |
$voting_results = array(); |