Hi
- Queries in postbit_display_complete are bad solutions
- Template edit not necessary
- Missing phrase, yours is hardcoded

- Template is uncached
- Missing table prefix
Your template is using
<normalfont>You must reply to be able to download the file</normalfont>. Never heard about such a tag <normalfont>
Better:
Template
postbit_cantseeattach:
HTML Code:
<span class="smallfont">$vbphrase[cantseeattach]</span>
My ideas, not tested, but it should work:
For template cache:
Hook cache_templates:
PHP Code:
if (THIS_SCRIPT == 'showthread')
{
$globaltemplates[] = 'postbit_cantseeattach';
}
Reduce queries in hook postbit_display_complete:
PHP Code:
if ($this->post['attach'])
{
GLOBAL $m, $vbulletin;
if (!$vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] != $m AND !can_moderate($forumid))
{
eval('$this->post[\'imageattachmentlinks\'] = "' . fetch_template('postbit_cantseeattach') . '";');
eval('$this->post[\'thumbnailattachments\'] = "' . fetch_template('postbit_cantseeattach') . '";');
eval('$this->post[\'imageattachments\'] = "' . fetch_template('postbit_cantseeattach') . '";');
eval('$this->post[\'otherattachments\'] = "' . fetch_template('postbit_cantseeattach') . '";');
eval('$this->post[\'moderatedattachments\'] = "' . fetch_template('postbit_cantseeattach') . '";');
}
}
Hook showthread_post_start:
PHP Code:
if ($thread['attach'])
{
$p = $db->query_first("SELECT userid
FROM " . TABLE_PREFIX . "post
WHERE threadid = $threadid AND userid = " . $vbulletin->userinfo['userid'] . "
");
$m = $p['userid'];
}
For showing or not showing paperclip in threadbit.
Hook threadbit_process:
PHP Code:
if ($thread['attach'])
{
GLOBAL $db, $vbulletin;
$p = $db->query_first("SELECT userid
FROM " . TABLE_PREFIX . "post
WHERE threadid = $thread[realthreadid] AND userid = " . $vbulletin->userinfo['userid'] . "
");
$m = $p['userid'];
if (!$vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] != $m AND !can_moderate($forumid))
{
$show['paperclip'] = false;
}
}
A variable/phrase
cantseeattach is needed also:
Content:
Code:
You must reply to be able to download the file
I've no idea, how can i better reduce the queries in theadbit_process.
If anyone know how we can optimize it better, please let us know.
Regards,
Stoebi