MyBB Community Forums

Full Version: Post Warning Notification (Icon).
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Author: Pratik Unadkat.
Author site: -
License: Mentioned below.

Description: This plugin shows notification icon to mods/admins in postbit whether/if the post is already warned to avoid confusions amongst other moderators.

Also, it only shows the notification icon if the browsing user is moderator of the forum in which the thread is situated, or super moderator or administrator.

The warning notification icon only shows up if the warning is not expired and active.

The plugin comes with one simple setting to enable/disable whenever you want. By default, it is disabled upon the activation of the plugin.

Changelogs:

1. Update v1.1 - The plugin now only runs 1 query on showthread/postbit and is well optimized. It is advised to update to this version ASAP.

Installation instructions:

1. Unzip the archive.
2. Upload pwn.png found inside images folder in the zip to ./images/ directory of your server.
3. Upload pwn.php inside the inc/plugins/ folder which we just extracted now to (root)./inc/plugins directory of your website's server.
4. Go to ACP > Plugins and activate it.
5. Next, proceed to ACP > Settings > Configuration and find post warning notification settings and configure them.
6. Done, enjoy.

Previews:


[attachment=27303][attachment=27304]

License:

Anyone who have downloaded this, the below but not limited to rules applies to them:

1. Not distributed under GNU/GPL.
2. You may modify the codes or plugin for your personal use but cannot claim it to be own or remodify and sell or reproduce under any cirumstances.
3. Free to edit for personal use but not allowed to distribute the plugin by modifying any codes.

Download:

http://mods.mybb.com/view/post-warning-notification

Support shall be provided in this thread.
Approved, bump Smile
Thanks Paul. Smile
You're making a very big query Unadkat. You do not have to use users and posts tables since you can directly fetch the warned post from its pid on postbit from warnings table.

Anyway, querying on each post is too weighty. I would suggest to create a column in posts table, and then update this column when warning issues and on warning expires. You can then simply use $post['column_name'] and check if its true then shows the icon and if its false removes the icon.
(2012-09-23, 05:43 PM)Yaldaram Wrote: [ -> ]You're making a very big query Unadkat. You do not have to use users and posts tables since you can directly fetch the warned post from its pid on postbit from warnings table.
Yes, I think I gave it a try but just pid didn't worked, so I added uid, I will retry it and give it a try tomorrow. Yes, that unfortunately runs around 9-10 queries on showthread. I also tried caching it, but I'm not too good with cache and unfortunately that didn't worked, if you've any suggestion for cache, that would be appreciated.

Quote:Anyway, querying on each post is too weighty. I would suggest to create a column in posts table, and then update this column when warning issues and on warning expires. You can then simply use $post['column_name'] and check if its true then shows the icon and if its false removes the icon.
This seems a great idea, I think I shall also try to do this, thanks. Smile
Can't look at your plugin right now (not got a computer), but are you running a query on the postbit hook per chance that causes the "9 - 10 extra queries"? If so, I have a blog post that might help with that.
(2012-09-23, 07:16 PM)euantor Wrote: [ -> ]Can't look at your plugin right now (not got a computer), but are you running a query on the postbit hook per chance that causes the "9 - 10 extra queries"? If so, I have a blog post that might help with that.

Yes he is running it on the postbit hook.
This is what I have as a query as of now:

$plugins->add_hook("postbit", "pwn");

function pwn(&$post)
{
    global $mybb, $pwn, $db, $thread;
	$uid = $post['uid'];
	
	$post['pwn'] = '';
	
	if($mybb->settings['pwn_enabled'] == 1)
	{
	
	$query = $db->query("
                SELECT u.uid
                FROM ".TABLE_PREFIX."users u
                JOIN ".TABLE_PREFIX."posts p ON (u.uid=p.uid)
				JOIN ".TABLE_PREFIX."warnings uw ON (uw.pid=p.pid)
                WHERE uw.expired='0'
            ");			

			
	while($warnings = $db->fetch_array($query))
	{
	
	$tid = intval($mybb->input['tid']);
	$thread = get_thread($tid);
	$fid = $thread['fid'];
	
	
if($post['uid'] == $warnings['uid'] AND is_moderator($fid))
{
	$warning_title = "This user is currently warned for this post.";
	
	$post['pwn'] = '
    
   <img src="images/pwn.png" title="'.$warning_title.'" />
   ';
} 
   } 
				 
	}		
	
return $post;

}

Yes, that runs each single query per post, which is little nifty. I think the second suggestion which Yaldaram suggested could really do well, I shall modify this and see it tomorrow.

But I am looking forward to hear to you, euantor.
Ok, take a peak at this: http://euantor.com/4-reducing-mybb-plugi...he-postbit

It should help you cut the query count to just one if you do it right. Also, why are you looking up the uid from the user's table? Just use $post['uid'] unless I'm missing something by skim reading on my phone.
Also, why are you running get_forum within a loop? I'm sure it runs a query too...
Pages: 1 2 3 4