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


Messages In This Thread
RE: Release: Report system like in vBulletin - by ImperfectShaun - 2010-08-15, 01:50 AM

Forum Jump:


Users browsing this thread: 12 Guest(s)