Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > Premium Archives > Advanced Warning System (AWS)
FAQ Community Calendar Today's Posts Search

Closed Thread
 
Thread Tools
Moderator only notes & Number of queries Details »»
Moderator only notes & Number of queries
Version: , by Delphy Delphy is offline
Developer Last Online: Oct 2010 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 08-22-2005 Last Update: Never Installs: 0
 
No support by the author.

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:
Code:
<if condition="$pnotes!='' AND $vboptions['warn_allownotes']==1">
Replace with:
Code:
<if condition="$bbuserinfo[usergroupid] == 7 || $bbuserinfo[usergroupid] == 6 || $bbuserinfo[usergroupid] == 5">
<if condition="$pnotes!='' AND $vboptions['warn_allownotes']==1">
Find:
Code:
$pnotes
</table>
<br>
</if>
Replace with:
Code:
$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:
Code:
                $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:
Code:
                $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:
Code:
                        $ids .= ',' . $post['postid'];
                        $lastpostid = $post['postid'];
Replace with:
Code:
                        $ids .= ',' . $post['postid'];
                        $userids .= ',' . $post['userid'];
                        $lastpostid = $post['postid'];
In the same file, find:
Code:
        $postids = "post.postid IN (0" . $ids . ")";
BELOW this, add:
Code:
        // 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:
Code:
                                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:
Code:
                                if ($post['warn_notes']==1 and $showviewwarnlink==1);
                {

                        global $warn_notes;
Just below, find:
Code:
                        while($notes=$DB_site->fetch_array($get_notes))
                        {
                                $d=vbdate($vboptions['dateformat'], $notes['warned_time']);
                                $t=vbdate($vboptions['timeformat'], $notes['warned_time']);
Replace with:
Code:
                        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:
Code:
                                        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:
Code:
                                        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

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 08-22-2005, 09:49 PM
beansbaxter's Avatar
beansbaxter beansbaxter is offline
 
Join Date: May 2005
Location: Seattle
Posts: 96
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'll have to try these...I am having the same problem you stated in #1. THanks for the feedback, it is appreciated!
  #3  
Old 08-24-2005, 05:55 PM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'll check your changes for (2), but for issue (1), are you sure you have made the changes suggested in functions_showthread.php?

If you have, then the parameter $pnotes should have a value only if $showviewwarnlink is set to 1. The $showviewwarnlink parameter is set to one only for admins or for admins/smods/mods depending on the usage of the hierarchical schema or not.

It should not be necessary to use the code below:

Code:
<if condition="$bbuserinfo[usergroupid] == 7 || $bbuserinfo[usergroupid] == 6 || $bbuserinfo[usergroupid] == 5">
which is actually wrong, since in the latest versions of AWS, the Admins/Smods/Mods groups are defined in the program, so you can have custom admin groups or smod or mod groups.

Check your edits in functions_showthread.php, that's where the check is made. Also check that you have defined your Warning Options about which are your admin, mod, smod groups.
  #4  
Old 08-25-2005, 02:22 AM
Delphy Delphy is offline
 
Join Date: Dec 2004
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hiya,

I made all the changes to the showthread.php, but left the admin/smod/mod fields empty in the settings page since I use the defaults. From my understanding of what you said, this would suggest if I specifically set the fields, then it should work?

I'll go through and double check everything again just to make sure.

Thanks,
Delphy
  #5  
Old 08-25-2005, 04:25 AM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, if you leave them empty the program will enter the proper groups (6,5,7) for the admins/smods/mods. From there on, the code in functions_showthread.php decides if the $pnotes will be filled up, depending on the $showviewwarnlink parameter.

If your plain users can see the notes, they should also be able to see the "View XYZ Warnings".

DARN!!! Now, I know, you have the "Who can view warning points" set to "All", right?

OK, try this. In functions_showthread.php find:

Code:
if ($post['warn_notes']==1 and $showviewwarnlink==1);
Replace that with:

Code:
if ($post['warn_notes']==1 and ($useradmin==1 OR $usersmod==1 OR $usermod==1));
That should fix it. Let me know if it works.
  #6  
Old 08-25-2005, 07:26 AM
Delphy Delphy is offline
 
Join Date: Dec 2004
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sv1,

I had "Who can view warning points?" set to Mgmt, but when the moderators where entering notes they set "private note?" to No - becuase the wording seems to indicate the only the moderator who entered the note in the first place could see the note (and not all moderators which is what I wanted). Maybe I'm just trying to use it in a way it's not supposed to be used

Regards
Delphy
  #7  
Old 08-25-2005, 10:51 AM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Notes can be either public (for all the management team to see) or private (only the person who entered it can see it). If you had set the Who can view Warning Points" to Mgm, there is no reason why the rest of your members could see the notes.

Try the change suggested above and let me know if it works OK.
  #8  
Old 08-25-2005, 12:12 PM
Delphy Delphy is offline
 
Join Date: Dec 2004
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hiya,

Nope - it didn't. Members and guests can still see the notes entered.

Regards,
Delphy
  #9  
Old 08-25-2005, 01:57 PM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am not sure if this is due to your modifications, or not. Look at the code below:

Code:
		if ($post['warn_notes']==1 and ($useradmin==1 OR $usersmod==1 OR $usermod==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");
			$pnotes='';
			$d='';
			$t='';
			while($notes=$DB_site->fetch_array($get_notes))
That says:

If the post has a note, and the user is administrator, super moderator or moderator, then do whatever follows.

If the post has no notes or if the user is nothing of the above, then obviously the parameter $pnotes never gets a value, so it should not show. I do not know if your changes have affected this procedure or not.
  #10  
Old 08-26-2005, 07:28 AM
Delphy Delphy is offline
 
Join Date: Dec 2004
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

With regards to the number of SQL queries changes I made, they dont affect that line - I was simply referencing it in my changelog becuase I needed to alter the lines below it.

I just saw you released the latest version so I'll try that out and get back to you.

Thanks for the replies. Have you managed to have a look at the single query code yet?

Regards,
Delphy
Closed Thread


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:55 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04268 seconds
  • Memory Usage 2,312KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (20)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete