MyBB Community Forums

Full Version: Questions before adopting MyBB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I realize that my questions may fall outside of what is stipulated as appropriate questions for this section of the forum. However, I went to the Mod site, and there was no place to register as a new user for that forum. With that in mind, I hope my questions will be indulged here.

I am comparing different PHP based bulletin boards, mainly phpBB, Simple Machines, PunBB, and MyBB. Before deciding and adopting one, I'm trying to get a sense of their capabilities.

One of my main objectives is to be able to insert a posting from outside of the MyBB interface.

I have a weekly newsletter that goes out, which I send from a custom PHP script of my own design. The sending of that newsletter is the trigger for inserting events into a calendar and for people to be able to sign up for events.

I'd like to make the text of the newsletter also be placed into a forum so people can comment on it.

Because the newsletter is tied to other events, the ideal scenario is to be able to automatically have a new thread started with the text of newsletter included, and a link to that thread included in the email that goes out.

I hope what I am describing is clear, and I hope someone can let me know if what I hope to achieve is possible with MyBB.

Thank you.
Registering for the mods forum could have been done here: http://mods.mybboard.com/forum/member.ph...n=register
Yes you can do what you are asking with MyBB. The MyBB database is very easy to handle and maintain, and I have written a php program that links threads to my homepage. It is easy to modify your program to write your newsletters to the database, and put them in the calendar.
If you write it using a custom script, you don't even need to know much of php anyway. You can do it with a simple html form. You can always secure it with some php.

The following is an example on how you can do it:
<form action="[color=blue]yourforum/[/color]newthread.php" method="post">

<input type="hidden" name="action" value="do_newthread">

<input type="hidden" name="fid" value="2">

SUBJECT: <input type="text" name="subject" value="your subject here..."><br>

<textarea name="message" rows="5" cols="20">your message here...</textarea><br>

<input type="hidden" name="replyto" value="">

username: <input type="text" name="username" value="you write your username here"><br>

password: <input type="password" name="password">

<input type="submit" value="send">

</form>
If you submit, everything will be done by itself. These are things that should be required. The replyto has no value, so a new thread will automatically be started. The fid is also required. This is the forum's ID where you want the new threads to be posted in.
Where yourforum/ stands, you write the url to your forum's main directory. After it is processed, you will be redirected to the thread you started.
It'd take a bit of code in MyBB currently to do that..

In our upcoming release, it works like this:
	// Set up posthandler.
	require_once MYBB_ROOT."inc/datahandlers/post.php";
	$posthandler = new PostDataHandler("insert");
	$posthandler->action = "thread";

	// Set the thread data that came from the input to the $thread array.
	$new_thread = array(
		"fid" => $forum['fid'],
		"subject" => $mybb->input['subject'],
		"icon" => $mybb->input['icon'],
		"uid" => $mybb->user['uid'],
		"username" => $mybb->user['username'],
		"message" => $mybb->input['message'],
		"ipaddress" => getip(),
		"posthash" => $mybb->input['posthash']
	);

	// Are we saving a draft thread?
	if($mybb->input['savedraft'] && $mybb->user['uid'])
	{
		$new_thread['savedraft'] = 1;
	}
	else
	{
		$new_thread['savedraft'] = 0;
	}
	
	// Is this thread already a draft and we're updating it?
	if(isset($thread['tid']) && $thread['visible'] == -2)
	{
		$new_thread['tid'] = $thread['tid'];
	}

	// Set up the thread options from the input.
	$new_thread['options'] = array(
		"signature" => $mybb->input['postoptions']['signature'],
		"emailnotify" => $mybb->input['postoptions']['emailnotify'],
		"disablesmilies" => $mybb->input['postoptions']['disablesmilies']
	);
	
	// Apply moderation options if we have them
	$new_thread['modoptions'] = $mybb->input['modoptions'];

	$posthandler->set_data($new_thread);
	
	// Now let the post handler do all the hard work.
	if(!$posthandler->validate_thread())
	{
		$post_errors = $posthandler->get_friendly_errors();
		print_r($post_errors);
	}
	
	// No errors were found, it is safe to insert the thread.
	else
	{
		$thread_info = $posthandler->insert_thread();
		$tid = $thread_info['tid'];
		$visible = $thread_info['visible'];[/quote]
	}
Chris Boulton Wrote:It'd take a bit of code in MyBB currently to do that..

In our upcoming release, it works like this:
	*snip*
Just to clarify, the code that Chris posted above is an example of what can be achieved in MyBB 1.2. It won't work on 1.1.x