Okay, it was really pretty easy to make the change for the PM (private messenging) from creating an inbox message to creating an e-mail message. There are two things to do. First, edit XOOPS_ROOT/pmlite.php. Secondly, add a template file to your language/<lang>/mail_templates directory.
I'll note, too, that there is a hack on SmartFactory's website, I think called PM Notification that will notify users via e-mail about new PM messages (this is ala eBay style). This was another thought I had, but my clients have generally preferred to just straight e-mail (and it keeps your database smaller).
Edit XOOPS_ROOT/pmlite.phpComment out or remove the following code (lines 66-76 in 2.0.16 release v2 dated 2005-11-02 by skalpa):
$pm_handler =& xoops_gethandler('privmessage');
$pm =& $pm_handler->create();
$pm->setVar("subject", $_POST['subject']);
$pm->setVar("msg_text", $_POST['message']);
$pm->setVar("to_userid", $_POST['to_userid']);
$pm->setVar("from_userid", $xoopsUser->getVar("uid"));
if (!$pm_handler->insert($pm)) {
echo $pm->getHtmlErrors();
echo "<br /><a href='javascript:history.go(-1)'>"._PM_GOBACK."</a>";
} else {
echo "<br /><br /><div style='text-align:center;'><h4>"._PM_MESSAGEPOSTED."</h4><br /><a href="javascript:window.opener.location='".XOOPS_URL."/viewpmsg.php';window.close();">"._PM_CLICKHERE."</a><br /><br /><a href="javascript:window.close();">"._PM_ORCLOSEWINDOW."</a></div>";
}
replace it with:
$xoopsMailer =& getMailer();
$xoopsMailer->useMail();
$xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH."/language/".$xoopsConfig['language']."/mail_template");
$xoopsMailer->setTemplate('pmsg.tpl');
$xoopsMailer->assign("SITENAME", $xoopsConfig['sitename']);
$xoopsMailer->assign("SITEURL", XOOPS_URL."/");
$xoopsMailer->assign("SITESLOGAN", $xoopsConfig['slogan']);
$xoopsMailer->assign("FROM_NAME", $xoopsUser->getVar('name'));
$toUser = new XoopsUser($_POST['to_userid']);
$xoopsMailer->assign("TO_NAME", $toUser->getVar('name'));
$xoopsMailer->assign("ADMINMAIL", $xoopsConfig['adminmail']);
$xoopsMailer->assign("BODY", stripSlashes($_POST['message']));
$xoopsMailer->assign("REPLY_URL", XOOPS_URL."/pmlite.php?send2=1&to_userid=".$xoopsUser->getVar('uid'));
$xoopsMailer->setToEmails($toUser->getVar('email'));
$xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
$xoopsMailer->setFromName($xoopsConfig['sitename']);
$xoopsMailer->setSubject($_POST['subject']);
if ($xoopsMailer->send()) {
echo "<div style='text-align:center;'><h4>"._PM_MESSAGEPOSTED."</h4><br /><a href="javascript:window.close();">"._PM_ORCLOSEWINDOW."</a></div>";
} else {
//relevant error messages
echo $xoopsMailer->getErrors();
echo "<br /><a href='javascript:history.go(-1)'>"._PM_GOBACK."</a>";
}
Add Mail TemplateThen you need to add a new template that matches the one used in this code (i used pmsg.tpl). I placed mine in XOOPS_ROOT/language/english/mail_templates/pmsg.tpl. Place yours in the appropriate language area.
{TO_NAME}:
{FROM_NAME} has sent the message below using anonymous messenging on {SITENAME} ({SITESLOGAN}). To reply to the author, please use the Reply URL below the message. Do not reply to this message; it will not be received.
From: {FROM_NAME}
{BODY}
Reply URL (cut and paste if necessary):
{REPLY_URL}
If you have any problems with this service or users of this service, please contact the site administrators at {SITENAME}.
Best Regards,
{SITENAME} Team
{SITEURL}
Finally, you can use other variables and such in the template as long as you edit the code in pmlite.php to match it and contain the right information. Also note that j-a-v-a-s-c-r-i-p-t is replaced in postings with tammairanslip, so the code above reflects that replacement and you will have to replace it back. I will eventually do a better write-up than this and post it here in the forums along with a link to download the files.
If one wanted, they could likely easily edit this to do both, or you could try the SmartFactory's hack to notify users.
Let me know if you run into problems using it. I did some basic testing although I didn't try to abuse it too much. It doesn't do HTML, but that is next on my list of things related to this.
Generally, my philosophy is to not touch the core because I don't want to spend hours on all my websites updating core. This is such a simple one, though, that I did it. You'll also likely want to remove links to the Inbox from the User Menu and other locations that link to it and/or just redirect them somewhere else if they try (like the home page).
Good luck!