add sms broadcast to broadcasting
darcs-hash:20080720195549-84dde-4193f27f8efda497fbe55f1c514fe30e4dd8a69d.gz
This commit is contained in:
parent
b6756fc8d1
commit
3372a98f8e
32
lib/mail.php
32
lib/mail.php
@ -157,3 +157,35 @@ function mail_new_incoming_address() {
|
|||||||
$suffix = mail_domain();
|
$suffix = mail_domain();
|
||||||
return $prefix . '@' . $suffix;
|
return $prefix . '@' . $suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mail_broadcast_notice_sms($notice) {
|
||||||
|
$user = new User();
|
||||||
|
$user->smsnotify = 1;
|
||||||
|
$user->whereAdd('EXISTS (select subscriber from subscriptions where '
|
||||||
|
' subscriber = user.id and subscribed = ' . $notice->profile_id);
|
||||||
|
$user->whereAdd('sms is not null');
|
||||||
|
|
||||||
|
$cnt = $user->find();
|
||||||
|
|
||||||
|
while ($user->fetch()) {
|
||||||
|
mail_send_sms_notice($notice, $user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function mail_send_notice($notice, $user) {
|
||||||
|
$profile = $user->getProfile();
|
||||||
|
$name = $profile->getBestName();
|
||||||
|
$carrier = Sms_carrier::staticGet($user->carrier);
|
||||||
|
$sms_email = $carrier->toEmailAddress($user->sms);
|
||||||
|
$to = $name . ' <' . $sms_email . '>';
|
||||||
|
$other = $notice->getProfile();
|
||||||
|
|
||||||
|
$headers = array();
|
||||||
|
$headers['From'] = $user->incomingemail;
|
||||||
|
$headers['To'] = $name . ' <' . $sms_email . '>';
|
||||||
|
$headers['Subject'] = sprintf(_('%s status on %s'),
|
||||||
|
$other->getBestName(),
|
||||||
|
common_exact_date($notice->created));
|
||||||
|
$body = $notice->content;
|
||||||
|
mail_send($sms_email, $headers, $body);
|
||||||
|
}
|
||||||
|
@ -971,7 +971,13 @@ function common_real_broadcast($notice, $remote=false) {
|
|||||||
common_log(LOG_ERR, 'Error in jabber broadcast for notice ' . $notice->id);
|
common_log(LOG_ERR, 'Error in jabber broadcast for notice ' . $notice->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// XXX: broadcast notices to SMS
|
if ($success) {
|
||||||
|
require_once(INSTALLDIR.'/lib/mail.php');
|
||||||
|
$success = mail_broadcast_notice_sms($notice);
|
||||||
|
if (!$success) {
|
||||||
|
common_log(LOG_ERR, 'Error in sms broadcast for notice ' . $notice->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
// XXX: broadcast notices to other IM
|
// XXX: broadcast notices to other IM
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user