add_hook('global_start', 'quickthread_tplcache');
$plugins->add_hook('forumdisplay_end', 'quickthread_run');
function quickthread_info()
{
return array(
'name' => 'Quick Thread',
'description' => 'Makes a quick thread box on forumdisplay pages similar to the quick reply on showthread.',
'website' => 'http://mybbhacks.zingaburga.com/',
'author' => 'ZiNgA BuRgA',
'authorsite' => 'http://zingaburga.com/',
'version' => '1.4',
'compatibility' => '14*,15*,16*,17*,18*',
'guid' => ''
);
}
function quickthread_install() {
global $db, $mybb;
$db->insert_query('templates', array(
'sid' => -1,
'title' => 'forumdisplay_quick_thread',
'template' => $db->escape_string('
'),
'version' => '1411'
));
}
function quickthread_is_installed() {
return $GLOBALS['db']->fetch_field($GLOBALS['db']->simple_select('templates', 'tid', 'title="forumdisplay_quick_thread"'), 'tid');
}
function quickthread_uninstall() {
$GLOBALS['db']->delete_query('templates', 'title="forumdisplay_quick_thread"');
}
function quickthread_activate()
{
global $db, $cache;
require MYBB_ROOT.'inc/adminfunctions_templates.php';
find_replace_templatesets('forumdisplay', '~{$threadslist}~', '{$threadslist}{$quickthread}');
}
function quickthread_deactivate()
{
global $db, $cache;
require MYBB_ROOT.'inc/adminfunctions_templates.php';
find_replace_templatesets('forumdisplay', '~{$quickthread}~', '', 0);
}
function quickthread_tplcache() {
if(THIS_SCRIPT == 'forumdisplay.php') {
global $templatelist;
if(isset($templatelist)) $templatelist .= ',forumdisplay_quick_thread,post_prefixselect_prefix,post_prefixselect_single';
}
}
function quickthread_run() {
global $foruminfo, $fpermissions;
if($foruminfo['open'] == 0 || $foruminfo['type'] != 'f' || $fpermissions['canpostthreads'] == 0 || $GLOBALS['mybb']->user['suspendposting'] == 1)
return;
global $theme, $mybb, $templates, $fid, $lang, $collapsed, $collapsedimg;
if(function_exists('build_prefix_select')) {
if(!$lang->no_prefix) $lang->load('newthread');
// note that newthread lang needs to load before showthread lang, or stuff like $lang->close_thread gets overridden
$prefixselect = build_prefix_select($fid);
}
$lang->load('showthread');
if(!$lang->quick_thread) $lang->quick_thread = 'Quick New Thread';
if(!$lang->subject) $lang->subject = 'Subject';
$postoptionschecked = array('signature' => '');
if($mybb->user['signature'] != '')
$postoptionschecked['signature'] = ' checked="checked"';
/*
if($mybb->user['subscriptionmethod'] == 1)
$postoptions_subscriptionmethod_none = "checked=\"checked\"";
else if($mybb->user['subscriptionmethod'] == 2)
$postoptions_subscriptionmethod_instant = "checked=\"checked\"";
else
$postoptions_subscriptionmethod_dont = "checked=\"checked\"";
*/
if($mybb->settings['captchaimage'] && !$mybb->user['uid']) {
if(function_exists('neocaptcha_generate'))
$captcha = neocaptcha_generate('post_captcha');
elseif($mybb->version_code >= 1605) {
// new CAPTCHA system
require_once MYBB_ROOT.'inc/class_captcha.php';
$post_captcha = new captcha(false, 'post_captcha');
// wow, this really is horrible code...
if($post_captcha->type == 1)
$post_captcha->build_captcha();
elseif($post_captcha->type == 2)
$post_captcha->build_recaptcha();
$captcha = $post_captcha->html;
} elseif(function_exists('imagepng')) {
$randomstr = random_str(5);
$imagehash = md5(random_str(12));
$GLOBALS['db']->insert_query('captcha', array(
'imagehash' => $imagehash,
'imagestring' => $randomstr,
'dateline' => TIME_NOW
));
eval('$captcha = "'.$templates->get('post_captcha').'";');
}
}
$posthash = md5($mybb->user['uid'].mt_rand());
$modoptions = '';
if(is_moderator($fid, 'canopenclosethreads')) {
$modoptions .= '
';
}
if(is_moderator($fid, 'canmanagethreads')) {
$modoptions .= '
';
}
eval('$GLOBALS[\'quickthread\'] = "'.$templates->get('forumdisplay_quick_thread').'";');
if(!strpos($templates->cache['forumdisplay'], '{$quickthread}')) {
$templates->cache['forumdisplay'] = str_replace('{$threadslist}', '{$threadslist}{$quickthread}', $templates->cache['forumdisplay']);
}
}
?>