Thread Rating:
  • 6 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[For 1.6] Release: Report system like in vBulletin
#51
My report forum is hidden to normal users. Some Moderators would subscribe to new threads in the Reports forum.

I don't know much about MyBB, or PHP/MySQL, but I think I've changed this plugin to work a little better....

function reporttoforum_run($post) {
	global $mybb, $db, $post, $thread, $pid, $forum, $templates, $cache;
	
	if(intval($mybb->settings['reporttoforum_forum']) > 0 && $mybb->settings['reporttoforum_switch'] == "1")
	{
		if(!trim($mybb->input['reason']))
		{
			global $lang, $settings, $theme, $plugins, $mybbuser, $mybbgroup, $headerinclude;
			global $querytime, $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;
			eval("\$report = \"".$templates->get("report_noreason")."\";");
			output_page($report);
			exit;
		}
	
		// Message template
		$forum = $db->fetch_array($db->simple_select("forums", "*", "fid={$post['fid']}"));
		
		// Put the message together. The post datahandler will sanitize and verify
		 $message = "
			Reported by [b][url={$mybb->settings['bburl']}/member.php?action=profile&uid={$mybb->user['uid']}]{$mybb->user['username']}[/url][/b] because...
			[quote={$mybb->user['username']}]{$mybb->input['reason']}[/quote]\n
			Offending post by [b][url={$mybb->settings['bburl']}/member.php?action=profile&uid={$post['uid']}]{$post['username']}[/url][/b]
			[url={$mybb->settings['bburl']}/forumdisplay.php?fid={$forum['fid']}]{$forum['name']}[/url] -> [url={$mybb->settings['bburl']}/showthread.php?tid={$post['tid']}&pid={$post['pid']}#pid{$post['pid']}]{$post['subject']}[/url]
			[quote={$post['username']}]{$post['message']}[/quote]
		 ";
			
		// Random thought: you could merge later reports against the same post into the same thread. Maybe I'll do this later
			
		$posthash = md5($message);
		
		// Set up post datahandler
		require_once MYBB_ROOT."inc/datahandlers/post.php";
		$posthandler = new PostDataHandler("insert");
		$posthandler->action = "thread";
		
		// Building the report thread
		$new_thread = array(
		   "fid" => $mybb->settings['reporttoforum_forum'],
		   "subject" => $post['username'].": ".$post['subject'],
		   "icon" => "2",
		   "uid" => $mybb->user['uid'],
		   "username" => $mybb->user['username'],
		   "message" => $message,
			"ipaddress" => get_ip(),
			"posthash" => $posthash
		 );    
		    
		$posthandler->set_data($new_thread);
		$valid_thread = $posthandler->validate_thread();
		$thread_info = $posthandler->insert_thread();
		 
/*		// We do not need to do this; the datahandler will do it for us

		 // Updates user's post count.
		 $user_posts = $db->fetch_array($db->simple_select("users", "*", "uid={$mybb->user['uid']}")) or die(mysqli_error());
		 $user_posts['postnum'] = $user_posts['postnum']+1;
		 
		 $query = $db->write_query("
		 	UPDATE ".TABLE_PREFIX."users
		    SET postnum={$user_posts['postnum']}
		    WHERE uid={$mybb->user['uid']}");
*/
		
		// If reports are posted on the forum only, then we display a thank you and close the process.
		if($mybb->settings['reporttoforum_only'] == "1")
		{
			global $lang, $settings, $theme, $plugins, $mybbuser, $mybbgroup, $headerinclude;
			global $querytime, $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;
			
			eval("\$report = \"".$templates->get("report_thanks")."\";");
			$plugins->run_hooks("report_do_report_end");
			output_page($report);
			die();
		}		
	}
}

Replace the above function and it will make posts properly.
Reply
#52
how i can modified to post warnigns??
Exclamation MyBB-Es.Com, spanish support for MyBB Wink
Reply
#53
The warning system is separate and not as straightforward. Besides - do you want your users to have the ability to suspend or ban another user?
Reply
#54
(2010-08-15, 06:42 AM)Walkman 5.0 Wrote: how i can modified to post warnigns??

You can set up permissions in admin control panel => giving a group permissions to give warnings. ( Users & Groups -> Groups -> (some group) -> Users and Permissions -> Warning System).

@ImperfectShaun : Thanks for sharing the code, I will check it out!
@AJS : Hmm, well if people use that kind of stuff, I might incorporate it in the next release. Smile
Reply
#55
Wow! very good idea!

love it, will install it soon!

thanks for making it!
Reply
#56
Ok maybe I'm just dumb but how do you install this? I tried to download the plugin but I cannot download it and yes I'm a member just not a subscriber.
Reply
#57
This user has been denied support. This user has been denied support.
I just downloaded it fine. Just click on the attached file in the first post and click OK when you get the pop up.
Reply
#58
(2010-11-10, 01:51 AM)Melbelle Wrote: Ok maybe I'm just dumb but how do you install this? I tried to download the plugin but I cannot download it and yes I'm a member just not a subscriber.

Hey there!

Simply download the .php file attached in the first post, and upload it to your: /your_forum_directory/inc/plugins/ directory. Then you can activate it in your Admin CP Smile

Hope it helps,
~John

Reply
#59
Thank you that worked Smile
Reply
#60
Hello all!
This plugin has been updated to run smoothly with MybB 1.6 (Tested on 1.6.8)
I also introduced in code modification proposed by ImperfectShaun.

Enjoy!
Reply


Forum Jump:


Users browsing this thread: 29 Guest(s)