Anyone inteterested:
PHP Code:
$show['threadcomments'] = false;
if ($vbulletin->options['threadcomments'])
{
if ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['ismoderator'])
{
$show['threadcomments'] = true;
}
if ($vbulletin->options['threadcomment_moderator'] AND can_moderate($threadinfo['forumid']))
{
$show['threadcomments'] = true;
}
$vbulletin->input->clean_array_gpc('r', array(
'page' => TYPE_UINT,
'showall' => TYPE_BOOL,
'deletecomment' => TYPE_BOOL,
'commentid' => TYPE_UINT
));
if ($vbulletin->GPC['deletecomment'])
{
$threadcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "threadcomment WHERE threadcommentid = " . $vbulletin->GPC['commentid']);
if ($threadcomment AND (
$threadcomment['userid'] == $vbulletin->userinfo['userid'] OR
$permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']
))
{
$db->query_write("DELETE FROM " . TABLE_PREFIX . "threadcomment WHERE threadcommentid = $threadcomment[threadcommentid]");
$threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$threadman->set_existing($threadinfo);
$threadman->set('threadcomments', $threadinfo['threadcomments'] - 1);
$threadman->save();
eval(exec_header_redirect("showthread.php?$session[sessionurl]t=$threadinfo[threadid]" . iif($vbulletin->GPC['page'],"page=" . $vbulletin->GPC['page'])));
}
else
{
eval(print_no_permission());
}
}
if ($show['threadcomments'])
{
if ($threadinfo['threadcomments'])
{
$limit = '';
if (!$vbulletin->GPC['showall'] AND $threadinfo['threadcomments'] > $vbulletin->options['threadcomments_maxcomments'])
{
$limit = 'LIMIT ' . ($threadinfo['threadcomments'] - $vbulletin->options['threadcomments_maxcomments']) . ',' . $vbulletin->options['threadcomments_maxcomments'];
$show['morethreadcomments'] = true;
}
$commentbits = '';
$allcomments = $db->query_read("
SELECT * FROM " . TABLE_PREFIX . "threadcomment
WHERE threadid = $threadinfo[threadid]
ORDER BY dateline ASC
$limit
");
while ($comment = $db->fetch_array($allcomments))
{
$show['threadcommentdelete'] = $permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'] ? true : false;
if ($comment['userid'] == $vbulletin->userinfo['userid'])
{
$show['threadcommentdelete'] = true;
}
$comment['date'] = vbdate($vbulletin->options['dateformat'], $comment['dateline'], true) . ' ' . vbdate($vbulletin->options['timeformat'], $comment['dateline']);
$templater = vB_Template::create('threadcommentbit');
$templater->register('comment', $comment);
$templater->register('threadinfo', $threadinfo);
$commentbits = $templater->render();
}
}
$page = $vbulletin->GPC['page'];
$templater = vB_Template::create('THREADCOMMENT');
$templater->register('commentbits', $commentbits);
$templater->register('page', $page);
$templater->register('threadinfo', $threadinfo);
$threadcomments = $templater->render();
$template_hook[showthread_above_posts] .= $threadcomments;
}
$vbulletin->input->clean_array_gpc('p', array(
'addcomment' => TYPE_BOOL,
'threadcomment' => TYPE_STR_NOHTML
));
if ($vbulletin->GPC['addcomment'])
{
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$vbulletin->GPC['threadcomment'] = $bbcode_parser->parse($vbulletin->GPC['threadcomment'], $threadinfo['forumid']);
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "threadcomment
(threadid, userid, username, dateline, comment)
VALUES (
$threadinfo[threadid],
" . $vbulletin->userinfo['userid'] . ",
'" . $db->escape_string(htmlspecialchars_uni($vbulletin->userinfo['username'])) . "',
" . TIMENOW . ",
'" . $db->escape_string($vbulletin->GPC['threadcomment']) . "'
)");
$threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$threadman->set_existing($threadinfo);
$threadman->set('threadcomments', $threadinfo['threadcomments'] + 1);
$threadman->save();
eval(exec_header_redirect("showthread.php?$session[sessionurl]t=$threadinfo[threadid]" . iif(intval($_REQUEST['page']),"page=" . intval($_REQUEST['page']))));
}
}
Updating the templates shouldn't be too hard. Shame Zoints didn't mark this as reusable else I'd release it again for 4.x