summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2008-09-17 13:47:41 -0400
committerEvan Prodromou <evan@controlyourself.ca>2008-09-17 13:47:41 -0400
commit130ba2888643992943780962dd4efcca3c595735 (patch)
treef1aa8a3b4157a6d61d636ae7f3060ed94d159a1c /lib
parent7f8aaf46c8279c120c012d2b479e592bfa9611cf (diff)
newmessage and showmessage
darcs-hash:20080917174741-5ed1f-c090055487bab0df52d25ad6550d3850ef5f7661.gz
Diffstat (limited to 'lib')
-rw-r--r--lib/mail.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/mail.php b/lib/mail.php
index 162669eaa..4788ccb91 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -231,3 +231,39 @@ function mail_confirm_sms($code, $nickname, $address) {
mail_send($recipients, $headers, $body);
}
+
+function mail_notify_message($message, $from=NULL, $to=NULL) {
+
+ if (is_null($from)) {
+ $from = User::staticGet($message->from_profile);
+ }
+
+ if (is_null($to)) {
+ $to = User::staticGet($message->to_profile);
+ }
+
+ if (!$to->email || !$to->emailnotifymsg) {
+ return true;
+ }
+
+ $subject = sprintf(_('New private message from %s'), $from->nickname);
+
+ $from_profile = $from->getProfile();
+
+ $body = sprintf(_("%1\$s (%2\$s) sent you a private message:\n\n".
+ "------------------------------------------------------\n".
+ "%3\$s\n".
+ "------------------------------------------------------\n\n".
+ "You can reply to their message here:\n\n".
+ "%4\$s\n\n".
+ "Don't reply to this email; it won't get to them.\n\n".
+ "With kind regards,\n",
+ "%5\$s\n"),
+ $from_profile->getBestName(),
+ $from->nickname,
+ $message->content,
+ common_local_url('newmessage', array('to' => $from->id)),
+ common_config('site', 'name'));
+
+ return mail_to_user($to, $subject, $body);
+}