MyBB Hacks

Full Version: [Update2] Admin email for send errant post link back to user for fix ???
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Way to email user from admin login, after checking post at moderation queue, a notice to fix errors in a post ?

Modified some email text and links at messages.lang.php and member.php, for email message and post link language to user with 'Send this Thread to a Friend' (SPTAF), but there seems no other way for user to go back to the post and fix... only way seems to be user needs to create a new post, and admin needs to delete old errant post ?

Is there another way, from admin login, to email users about errant posts and a way they may go back and edit accordingly... maybe approve post for limited time frame 4 fix ?

Would also like to keep a copy of the email, possibly by creating a way to bcc: to admin archive email... or maybe way to put multiple email addresses (to archive@domain.name) in SPTAF ?

Thoughts on where to look, or how to do ?

Ps:
Modified 'Template: sendthread' for second email address field, but doesnt get sent to addressees... any idea if way to modify member.php to make that work ?

Ps2:
Forgot to include sendthread.php in file list above.
Maybe could somehow, at least, add second email addressee at ?...

Code:
if($mybb->input['action'] == "do_sendtofriend" && $mybb->request_method == "post")
{
	// Verify incoming POST request
	verify_post_check($mybb->input['my_post_key']);

	$plugins->run_hooks("sendthread_do_sendtofriend_start");
	
	if(!validate_email_format($mybb->input['email']))
	{
		$errors[] = $lang->error_invalidemail;
	}
	
	if(empty($mybb->input['subject']))
	{
		$errors[] = $lang->error_nosubject;
	}	
	
	if(empty($mybb->input['message']))
	{
		$errors[] = $lang->error_nomessage;
	}

	// No errors detected
	if(count($errors) == 0)
	{
		if($mybb->settings['mail_handler'] == 'smtp')
		{
			$from = $mybb->user['email'];
		}
		else
		{
			$from = "{$mybb->user['username']} <{$mybb->user['email']}>";
		}
		
		$threadlink = get_thread_link($thread['tid']);
		
		$message = $lang->sprintf($lang->email_sendtofriend, $mybb->user['username'], $mybb->settings['bbname'], $mybb->settings['bburl']."/".$threadlink, $mybb->input['message']);
		
		// Send the actual message
		my_mail($mybb->input['email'], $mybb->input['subject'], $message, $from, "", "", false, "text", "", $mybb->user['email']);
		
		if($mybb->settings['mail_logging'] > 0)
		{
			// Log the message
			$log_entry = array(
				"subject" => $db->escape_string($mybb->input['subject']),
				"message" => $db->escape_string($message),
				"dateline" => TIME_NOW,
				"fromuid" => $mybb->user['uid'],
				"fromemail" => $db->escape_string($mybb->user['email']),
				"touid" => 0,
				"toemail" => $db->escape_string($mybb->input['email']),
				"tid" => $thread['tid'],
				"ipaddress" => $db->escape_string($session->ipaddress)
			);
			$db->insert_query("maillogs", $log_entry);
		}

		$plugins->run_hooks("sendthread_do_sendtofriend_end");
		redirect(get_thread_link($thread['tid']), $lang->redirect_emailsent);
	}
	else
	{
		$mybb->input['action'] = '';
	}
}

if(!$mybb->input['action'])
{
	$plugins->run_hooks("sendthread_start");

	// Do we have some errors?
	if(count($errors) >= 1)
	{
		$errors = inline_error($errors);
		$email = htmlspecialchars_uni($mybb->input['email']);
		$subject = htmlspecialchars_uni($mybb->input['subject']);
		$message = htmlspecialchars_uni($mybb->input['message']);
	}
	else
	{
		$errors = '';
		$email = '';
		$subject = $lang->sprintf($lang->emailsubject_sendtofriend, $mybb->settings['bbname']);
		$message = '';
	}
	
	$plugins->run_hooks("sendthread_end");

	eval("\$sendtofriend = \"".$templates->get("sendthread")."\";");
	output_page($sendtofriend);
}

...guess, if possible, little T&E, and some luck ?

MyBB won't show unapproved posts to their authors.  This is a MyBB limitation.
This is something I have pondered on for a long time - a process I thought of for mysite which has upload submissions (though I have no idea how to implement it) is as below:

1) Define a forum as the "upload forum" - users can see only their own posts, staff/moderators can see all
2) On submit - the post is approved and auto-moved to another forum - staff only.
3) Post is reviewed: if ok, it is moved to the correct forum - user gets a PM on move.
4) Post is reviewed: if NOT ok, it is moved back to the upload forum - user gets a PM on move
5) User edits - resubmits - back to point 2

This process really would not work at all if ever in a discussions forum. (IMO)
Reference URL's