summaryrefslogtreecommitdiff
path: root/smartyplugins/function.poll.php
blob: ad7b96e2803b92f0284448cd84f93a7ec42f29e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace Bitweaver\Plugins;

/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * smarty_function_base
 */
use Bitweaver\BitBase;

/**
 * smarty_function_poll
 */
function smarty_function_poll($params, &$gBitSmarty) {
    global $polllib, $gBitSystem;

    extract($params);
    // Param = zone
	include_once( POLLS_PKG_PATH.'poll_lib.php' );

    if (empty($id)) {
      $id = $polllib->get_random_active_poll();
    }
    if($id) {
      $menu_info = $polllib->get_poll($id);
      $channels = $polllib->list_poll_options($id,0,-1,'option_id_asc','');
			if ($gBitSystem->getConfig('feature_poll_comments') == 'y') {
				$comments = new LibertyComment();
				$comments_count = $comments->count_comments("poll:".$menu_info["poll_id"]);
			}
			$gBitSmarty->assign('comments', $comments_count);
      $gBitSmarty->assign('ownurl',POLLS_PKG_URL.'results.php?poll_id='.$id);
      $gBitSmarty->assign('menu_info',$menu_info);
      $gBitSmarty->assign('channels',$channels["data"]);
      $gBitSmarty->display('bitpackage:polls/poll.tpl');
    }
}