/* ==================== [BEGIN_COT_EXT] Hooks=forums.posts.tags [END_COT_EXT] ==================== */ /** * Polls * * @package Polls * @copyright (c) Cotonti Team * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt */ defined('COT_CODE') or die('Wrong URL'); cot_poll_vote(); $poll_form = cot_poll_form($q, cot_url('forums', 'm=posts&q=' . $q), '', 'forum'); if ($poll_form) { $t->assign(array('POLLS_TITLE' => cot_parse($poll_form['poll_text'], $cfg['polls']['markup']), 'POLLS_FORM' => $poll_form['poll_block'])); $t->parse('MAIN.POLLS_VIEW'); if ($poll_form['poll_alreadyvoted']) { $extra = $votecasted ? $L['polls_votecasted'] : $L['polls_alreadyvoted']; } else { $extra = $L['polls_notyetvoted']; } $t->assign('POLLS_EXTRATEXT', $extra); $t->parse('MAIN.POLLS_EXTRA'); if (!empty($poll_form['poll_text'])) { $rowt['ft_title'] = $L['Poll'] . ": " . $rowt['ft_title']; } $crumbs = cot_forums_buildpath($s); $toppath = cot_breadcrumbs($crumbs, $cfg['homebreadcrumb']);
foreach (cot_getextplugins('polls.main') as $pl) { include $pl; } /* ===== */ require_once $cfg['system_dir'] . '/header.php'; $t = new XTemplate(cot_tplfile('polls')); if (cot_check_messages()) { cot_display_messages($t); } if ((int) $id > 0) { $id = (int) cot_import($id, 'D', 'INT'); if ((int) $db->query("SELECT COUNT(*) FROM {$db_polls} WHERE poll_id={$id} AND poll_type='index'")->fetchColumn() != 1) { cot_die_message(404, TRUE); } cot_poll_vote(); $poll_form = cot_poll_form($id); $t->assign(array('POLLS_TITLE' => cot_parse($poll_form['poll_text'], $cfg['polls']['markup']), 'POLLS_FORM' => $poll_form['poll_block'], 'POLLS_VIEWALL' => cot_rc_link(cot_url('polls', 'id=viewall'), $L['polls_viewarchives']))); /* === Hook === */ foreach (cot_getextplugins('polls.view.tags') as $pl) { include $pl; } /* ===== */ $t->parse('MAIN.POLLS_VIEW'); $extra = $L['polls_notyetvoted']; if ($alreadyvoted) { $extra = $votecasted ? $L['polls_votecasted'] : $L['polls_alreadyvoted']; } $t->assign(array('POLLS_EXTRATEXT' => $extra)); $t->parse('MAIN.POLLS_EXTRA'); } else { $jj = 0;
* @license https://github.com/Cotonti/Cotonti/blob/master/License.txt */ defined('COT_CODE') or die('Wrong URL'); if ($cfg['polls']['maxpolls'] > 0) { require_once cot_incfile('polls', 'module'); cot_poll_vote(); $indexpolls = new XTemplate(cot_tplfile(array('polls', 'index'), false)); $sqlmode = $cfg['polls']['mode'] == 'Recent polls' ? 'poll_creationdate DESC' : 'RAND()'; $res = 0; $sql_polls = $db->query("SELECT * FROM {$db_polls} WHERE poll_type='index' AND poll_state='0' ORDER by {$sqlmode} LIMIT " . $cfg['polls']['maxpolls']); /* === Hook - Part1 === */ $extp = cot_getextplugins('polls.index.tags'); /* ===== */ foreach ($sql_polls->fetchAll() as $row_p) { $res++; $poll_form = cot_poll_form($row_p, cot_url('index', ''), 'index'); $indexpolls->assign(array('IPOLLS_ID' => $row_p['poll_id'], 'IPOLLS_TITLE' => cot_parse($row_p['poll_text'], $cfg['polls']['markup']), 'IPOLLS_URL' => cot_url('polls', 'id=' . $row_p['poll_id']), 'IPOLLS_FORM' => $poll_form['poll_block'])); /* === Hook - Part2 === */ foreach ($extp as $pl) { include $pl; } /* ===== */ $indexpolls->parse('INDEXPOLLS.POLL'); } $indexpolls->assign('IPOLLS_ALL', cot_url('polls', 'id=viewall')); if (!$res) { $indexpolls->assign('IPOLLS_ERROR', $L['None']); $indexpolls->parse('INDEXPOLLS.ERROR'); } $indexpolls->parse('INDEXPOLLS'); $t->assign('INDEX_POLLS', $indexpolls->text('INDEXPOLLS'));