Delphy
08-22-2005, 04:10 PM
Hiya,
I installed the latest version a couple of days ago after having used the older one a while back (but lost it in an upgrade). Two things I've noticed:
1. All members can see the warning notes in the default install
2. 1 query is performed per post to get the warning notes
I have 3.0.7 so the fixes below work ONLY on that version. The template fix could work on others, and the logic behind the query too.
To fix #1, do the following:
Edit the postbit / postbit_legacy template.
Find:
<if condition="$pnotes!='' AND $vboptions['warn_allownotes']==1">
Replace with:
<if condition="$bbuserinfo[usergroupid] == 7 || $bbuserinfo[usergroupid] == 6 || $bbuserinfo[usergroupid] == 5">
<if condition="$pnotes!='' AND $vboptions['warn_allownotes']==1">
Find:
$pnotes
</table>
<br>
</if>
Replace with:
$pnotes
</table>
<br>
</if>
</if>
To fix #2 requires editing of 2 files, but caches all warning notes in 1 query instead of 1 query per post.
First, edit showthread.php
Find:
$getpostids = $DB_site->query("
SELECT postid NOT ISNULL(deletionlog.primaryid) AS isdeleted
FROM " . TABLE_PREFIX . "post AS post
LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(post.postid = deletionlog.primaryid AND type = 'post')
WHERE threadid = $threadid AND visible = 1
ORDER BY postid $postorder
");
Replace with:
$getpostids = $DB_site->query("
SELECT postid, post.userid, NOT ISNULL(deletionlog.primaryid) AS isdeleted
FROM " . TABLE_PREFIX . "post AS post
LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(post.postid = deletionlog.primaryid AND type = 'post')
WHERE threadid = $threadid AND visible = 1
ORDER BY postid $postorder
");
Just below this, find:
$ids .= ',' . $post['postid'];
$lastpostid = $post['postid'];
Replace with:
$ids .= ',' . $post['postid'];
$userids .= ',' . $post['userid'];
$lastpostid = $post['postid'];
In the same file, find:
$postids = "post.postid IN (0" . $ids . ")";
BELOW this, add:
// Start Cached Warning Notes
global $warn_notes;
$warn_query = $DB_site->query("SELECT w.*, u.username as warner from " . TABLE_PREFIX. "warn_notes w LEFT JOIN " . TABLE_PREFIX . "user u on (u.userid=w.warned_by) WHERE warned_user IN (0". $userids. ") ORDER BY warned_time DESC");
while ($warn_note = $DB_site->fetch_array($warn_query))
{
$warn_notes[$warn_note[warned_user]] = $warn_note;
}
$DB_site->free_result($warn_query);
// End Cached Warning Notes
Save the file, and upload.
Next, edit includes/functions_showthread.php
Find:
if ($post['warn_notes']==1 and $showviewwarnlink==1);
{
$get_notes=$DB_site->query("select w.*, u.username as warner from ".TABLE_PREFIX."warn_notes w
LEFT JOIN ".TABLE_PREFIX."user u on(u.userid=w.warned_by)
where warned_user='{$post['userid']}' order by warned_time desc");
Replace with:
if ($post['warn_notes']==1 and $showviewwarnlink==1);
{
global $warn_notes;
Just below, find:
while($notes=$DB_site->fetch_array($get_notes))
{
$d=vbdate($vboptions['dateformat'], $notes['warned_time']);
$t=vbdate($vboptions['timeformat'], $notes['warned_time']);
Replace with:
foreach ($warn_notes as $notes)
{
if ($notes[warned_user] == $post[userid]) {
$d=vbdate($vboptions['dateformat'], $notes['warned_time']);
$t=vbdate($vboptions['timeformat'], $notes['warned_time']);
Find:
elseif ($notes['warned_type']==0)
{
$pnotes = $pnotes . "<tr><td width='15%' class='smallfont'>$notes[warner]</td><td width='15%' class='smallfont'>$d, $t</td><td class='smallfont'>$notes[warned_note]</td><td class='smallfont' align='center'>$r</td></tr>";
}
}
Replace with:
elseif ($notes['warned_type']==0)
{
$pnotes = $pnotes . "<tr><td width='15%' class='smallfont'>$notes[warner]</td><td width='15%' class='smallfont'>$d, $t</td><td class='smallfont'>$notes[warned_note]</td><td class='smallfont' align='center'>$r</td></tr>";
}
}
}
Save and upload.
This cuts the number of queries from 1 per post to 1 on the entire page.
Hope this helps.
Regards,
Delphy
I installed the latest version a couple of days ago after having used the older one a while back (but lost it in an upgrade). Two things I've noticed:
1. All members can see the warning notes in the default install
2. 1 query is performed per post to get the warning notes
I have 3.0.7 so the fixes below work ONLY on that version. The template fix could work on others, and the logic behind the query too.
To fix #1, do the following:
Edit the postbit / postbit_legacy template.
Find:
<if condition="$pnotes!='' AND $vboptions['warn_allownotes']==1">
Replace with:
<if condition="$bbuserinfo[usergroupid] == 7 || $bbuserinfo[usergroupid] == 6 || $bbuserinfo[usergroupid] == 5">
<if condition="$pnotes!='' AND $vboptions['warn_allownotes']==1">
Find:
$pnotes
</table>
<br>
</if>
Replace with:
$pnotes
</table>
<br>
</if>
</if>
To fix #2 requires editing of 2 files, but caches all warning notes in 1 query instead of 1 query per post.
First, edit showthread.php
Find:
$getpostids = $DB_site->query("
SELECT postid NOT ISNULL(deletionlog.primaryid) AS isdeleted
FROM " . TABLE_PREFIX . "post AS post
LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(post.postid = deletionlog.primaryid AND type = 'post')
WHERE threadid = $threadid AND visible = 1
ORDER BY postid $postorder
");
Replace with:
$getpostids = $DB_site->query("
SELECT postid, post.userid, NOT ISNULL(deletionlog.primaryid) AS isdeleted
FROM " . TABLE_PREFIX . "post AS post
LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(post.postid = deletionlog.primaryid AND type = 'post')
WHERE threadid = $threadid AND visible = 1
ORDER BY postid $postorder
");
Just below this, find:
$ids .= ',' . $post['postid'];
$lastpostid = $post['postid'];
Replace with:
$ids .= ',' . $post['postid'];
$userids .= ',' . $post['userid'];
$lastpostid = $post['postid'];
In the same file, find:
$postids = "post.postid IN (0" . $ids . ")";
BELOW this, add:
// Start Cached Warning Notes
global $warn_notes;
$warn_query = $DB_site->query("SELECT w.*, u.username as warner from " . TABLE_PREFIX. "warn_notes w LEFT JOIN " . TABLE_PREFIX . "user u on (u.userid=w.warned_by) WHERE warned_user IN (0". $userids. ") ORDER BY warned_time DESC");
while ($warn_note = $DB_site->fetch_array($warn_query))
{
$warn_notes[$warn_note[warned_user]] = $warn_note;
}
$DB_site->free_result($warn_query);
// End Cached Warning Notes
Save the file, and upload.
Next, edit includes/functions_showthread.php
Find:
if ($post['warn_notes']==1 and $showviewwarnlink==1);
{
$get_notes=$DB_site->query("select w.*, u.username as warner from ".TABLE_PREFIX."warn_notes w
LEFT JOIN ".TABLE_PREFIX."user u on(u.userid=w.warned_by)
where warned_user='{$post['userid']}' order by warned_time desc");
Replace with:
if ($post['warn_notes']==1 and $showviewwarnlink==1);
{
global $warn_notes;
Just below, find:
while($notes=$DB_site->fetch_array($get_notes))
{
$d=vbdate($vboptions['dateformat'], $notes['warned_time']);
$t=vbdate($vboptions['timeformat'], $notes['warned_time']);
Replace with:
foreach ($warn_notes as $notes)
{
if ($notes[warned_user] == $post[userid]) {
$d=vbdate($vboptions['dateformat'], $notes['warned_time']);
$t=vbdate($vboptions['timeformat'], $notes['warned_time']);
Find:
elseif ($notes['warned_type']==0)
{
$pnotes = $pnotes . "<tr><td width='15%' class='smallfont'>$notes[warner]</td><td width='15%' class='smallfont'>$d, $t</td><td class='smallfont'>$notes[warned_note]</td><td class='smallfont' align='center'>$r</td></tr>";
}
}
Replace with:
elseif ($notes['warned_type']==0)
{
$pnotes = $pnotes . "<tr><td width='15%' class='smallfont'>$notes[warner]</td><td width='15%' class='smallfont'>$d, $t</td><td class='smallfont'>$notes[warned_note]</td><td class='smallfont' align='center'>$r</td></tr>";
}
}
}
Save and upload.
This cuts the number of queries from 1 per post to 1 on the entire page.
Hope this helps.
Regards,
Delphy