<?php
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook("postbit", "threads_postbit");

function threads_info() {
	return array(
		"name"			=> "Threads!",
		"description"	=> "This plugin show a numbers of threads added by user.",
		"website"		=> "http://mybboard.pl",
		"author"		=> "GiboneKPL",
		"authorsite"	=> "http://mybboard.pl",
		"version"		=> "1.0",
		"guid" 			=> "",
		"compatibility" => "16*"
	);
}

function threads_active() {


}

function threads_deactive() {


}

function threads_postbit (&$post) {
	global $db;
    static $cache;
    
    if (empty($cache[$post['uid']]))
    {
        $sql = "SELECT COUNT(tid) as num_threads 
                FROM ".TABLE_PREFIX."threads 
                WHERE uid = '{$post['uid']}'"; 
        $result = $db->query($sql);
        $cache[$post['uid']] = (int) $db->fetch_field($result, 'num_threads');
    }
    
    $post['num_threads'] = $cache[$post['uid']];
} 

?>