This can be done, but you should keep in mind that:
1. Sending a PM to a user, necessitates only an insertion of a new row in a table in the database.
2. Any part of vB can therefore send a PM to a user, by just doing such an insert.
3. The only way to catch the "user away" condition, for each program which tries to insert a PM in the PMs table, is to have a trigger within the table. This I cannot do, I am not that good in MySQL, I do not even know if it supports triggers.
So, what I did, is the next best thing. I modified the code of the private.php program, which is the one you use, when you send a PM to a user. To do this, follow the steps below:
1. Edit private.php and find :
PHP Code:
if (!($user['options'] & $_USEROPTIONS['receivepm']))
{
// recipient has private messaging disabled
eval('$errors[] = "' . fetch_phrase('pmrecipturnedoff', PHRASETYPEID_ERROR) . '";');
}
Right below it, add :
PHP Code:
else if ($user['awaystatus'] == 1)
{
$awaysincedate = vbdate($vboptions['dateformat'], $user['awaysince']);
if ($user['awayuntildate'] == "")
{
$awayuntilmsg = "not given";
}
else
{
$awayuntilmsg = $user['awayuntildate'];
}
eval('$pmuseraway[] = "' . fetch_phrase('userawaynopm', PHRASETYPEID_ERROR) . '";');
}
Now go into your Admin CP, Phrase Manager and add a new phrase. The type is "Front-End Error Messages" and the phrase name should be "userawaynopm". The text of the phrase should be something like:
PHP Code:
<u><b>Attention : </b></u> Your PM cannot be send to its intended recipients.<br>User <b>$user[username]</b> is away since the $awaysincedate.<br> Expected return date was $awayuntilmsg.<br>Your PM was not delivered to <b>$user[username]</b>.
Please keep in mind that I've added some custom fields in this hack, so if you get error messages about awayuntildate etc., you should remove those bits from the code and the phrase. Let me know if you have problems and I'll try to help.
With this, when you try to PM a user who is away, you will receive the above message and your PM is not send. I am not sure if this is the best way to handle this though, maybe, one should issue a warning to the sender, that the recipient is away, and let the PM go through. I would appreciate if you could let me know what you think about this question.
Finally, with this mod, if your PM is send to many recipients, the user(s) who is/are away, will not receive the PM, while the rest of them will.
Let me know if you have problems.
Rgds
------------
John