1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8function smarty_function_rating_choice($params, $smarty)
9{
10	global $prefs, $user;
11	$ratinglib = TikiLib::lib('rating');
12
13	if (! isset($params['comment_author'], $params['type'], $params['id'])) {
14		return tra('No object information provided for rating.');
15	}
16
17	$comment_author = $params['comment_author'];
18	$type = $params['type'];
19	$id = $params['id'];
20
21	$vote = $ratinglib->get_vote_comment_author($comment_author, $type, $id);
22	$options = $ratinglib->get_options($type, $id);
23
24	if ($prefs['rating_smileys'] == 'y') {
25		$smiles = $ratinglib->get_options_smiles($type, $id);
26		$smarty->assign('rating_smiles', $smiles);
27	}
28
29	$smarty->assign('rating_type', $type);
30	$smarty->assign('rating_id', $id);
31	$smarty->assign('rating_options', $options);
32	$smarty->assign('current_rating', $vote);
33	return $smarty->fetch('rating_choice.tpl');
34}
35