<?php
/* ====================
[BEGIN_COT_EXT]
Hooks=forums.topics.tags
Tags=forums.topics.tpl:{FORUMS_TOPICS_VIEWERS},{FORUMS_TOPICS_VIEWER_NAMES}
[END_COT_EXT]
==================== */

/**
 * Forums online users in section display
 *
 * @package WhosOnline
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */

defined('COT_CODE') or die('Wrong URL');

if (Cot::$cfg['forums']['cat_' . $s]['allowviewers']) {
    $fs_viewers_names = '';
	$v = 0;
	$sql_forums_view = Cot::$db->query("SELECT online_name, online_userid FROM $db_online WHERE online_location='Forums' 
                                               AND online_subloc=".Cot::$db->quote(Cot::$structure['forums'][$s]['title']));
	while ($rowv = $sql_forums_view->fetch()) {
		if ($rowv['online_name'] != 'v') {
			$fs_viewers_names .= ($v > 0) ? ', ' : '';
			$fs_viewers_names .= cot_build_user($rowv['online_userid'], $rowv['online_name']);
			$v++;
		}
	}
	$sql_forums_view->closeCursor();
	$fs_viewers = $v;

	$t->assign(array(
		'FORUMS_TOPICS_VIEWERS' => $fs_viewers,
		'FORUMS_TOPICS_VIEWER_NAMES' => $fs_viewers_names
	));
	$t->parse('MAIN.FORUMS_SECTIONS_VIEWERS');
}
