Needs review
Project:
Kudos
Version:
5.x-1.1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
11 Mar 2008 at 14:06 UTC
Updated:
11 Mar 2008 at 14:06 UTC
I extended the MySQL-Query of _kudos_get_content_stats to get detailled information about users gave kudos.
//@@ ++2015,8 --2015,6
$query = "
SELECT i.*, c.num_given, gu.*
FROM {kudos_cached} c
JOIN {kudos_info} i ON c.kudo_id = i.id AND i.status = 1
+ JOIN (SELECT g.kudo_id, GROUP_CONCAT(g.uid ORDER BY u.name DESC SEPARATOR ',') uids, GROUP_CONCAT(u.name ORDER BY u.name DESC SEPARATOR ',') unames, GROUP_CONCAT(g.created ORDER BY u.name DESC SEPARATOR ',') createds FROM {kudos_granted} g JOIN {users} u ON g.uid = u.uid GROUP BY g.content_type, g.content_id) gu
+ ON c.kudo_id = gu.kudo_id
WHERE
";
This query only works for MySQL 5, due to subquery.
To provide this information in the template files, the results have to be put in the $response-array:
//@@ ++2044,13 --2042,11
//while we have results
while ($row = db_fetch_array($result)) {
$response[$row['name']] = array();
$response[$row['name']]['name'] = $row['name'];
$response[$row['name']]['id'] = $row['id'];
$response[$row['name']]['label'] = $row['label'];
$response[$row['name']]['num_given'] = $row['num_given'];
$response[$row['name']]['icon']['give'] = $_image_path . $row['icon_give'];
$response[$row['name']]['icon']['rescind'] = $_image_path . $row['icon_rescind'];
$response[$row['name']]['icon']['disabled'] = $_image_path . $row['icon_disabled'];
+ $response[$row['name']]['users'] = array_combine(explode(',',$row['uids']),explode(',',$row['unames']));
+ $response[$row['name']]['createds'] = array_combine(explode(',',$row['uids']),explode(',',$row['createds']));
}//end - while
So, now you can provide more details with changing the theming function theme_kudos_content_stats_item
function mytheme_kudos_content_stats_item($vars) {
switch ($vars['name']){
case 'thanks':
$content = t('This users thanked for this content: @users',array('@users'=>implode(', ',$vars['details']['users']));
break;
default:
$content = $vars['details']['label'] . '(' . $vars['details']['num_given'] . ')';
break;
}
return $content;
}//end - function
Perhaps this could be available in a future version by being selected optionally - e.g. variable_get('kudos_get_more_content_stats_'.$node->type,0)