I'm planning on creating a plugin which is basically a user application, they can only submit once, once they submit they get a PM saying thank you and a bit of information regarding their application. In the ACP theres going to be another part where I review applications and send them a PM regarding if they got in or didn't.
So is there a PM Function which could save me time? Better yet, a source code documentation with the MyBB functions and things.
Start looking from line 167 of private.php
require_once MYBB_ROOT."inc/datahandlers/pm.php";
$pmhandler = new PMDataHandler();
$pm = array(
"subject" => $mybb->input['subject'],
"message" => $mybb->input['message'],
"icon" => $mybb->input['icon'],
"fromid" => $mybb->user['uid'],
"do" => $mybb->input['do'],
"pmid" => $mybb->input['pmid']
);
// Split up any recipients we have
$pm['to'] = explode(",", $mybb->input['to']);
$pm['to'] = array_map("trim", $pm['to']);
if(!empty($mybb->input['bcc']))
{
$pm['bcc'] = explode(",", $mybb->input['bcc']);
$pm['bcc'] = array_map("trim", $pm['bcc']);
}
$pm['options'] = array(
"signature" => $mybb->input['options']['signature'],
"disablesmilies" => $mybb->input['options']['disablesmilies'],
"savecopy" => $mybb->input['options']['savecopy'],
"readreceipt" => $mybb->input['options']['readreceipt']
);
if($mybb->input['saveasdraft'])
{
$pm['saveasdraft'] = 1;
}
$pmhandler->set_data($pm);
// Now let the pm handler do all the hard work.
if(!$pmhandler->validate_pm())
{
$pm_errors = $pmhandler->get_friendly_errors();
$send_errors = inline_error($pm_errors);
$mybb->input['action'] = "send";
}
else
{
$pminfo = $pmhandler->insert_pm();
$plugins->run_hooks("private_do_send_end");
if(isset($pminfo['draftsaved']))
{
redirect("private.php", $lang->redirect_pmsaved);
}
else
{
redirect("private.php", $lang->redirect_pmsent);
}
}
}