mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
message MDL-24873 changes to reduce server load and also get the forum's custom email headers passed through correctly
This commit is contained in:
parent
9e32912bca
commit
fe983847dd
4 changed files with 47 additions and 29 deletions
|
@ -38,21 +38,20 @@ class message_output_jabber extends message_output {
|
|||
|
||||
/**
|
||||
* Processes the message (sends using jabber).
|
||||
* @param object $message the message to be sent
|
||||
* @param object $eventdata the event data submitted by the message sender plus $eventdata->savedmessageid
|
||||
* @return true if ok, false if error
|
||||
*/
|
||||
function send_message($message){
|
||||
global $DB, $CFG;
|
||||
function send_message($eventdata){
|
||||
global $CFG;
|
||||
|
||||
if (!$userfrom = $DB->get_record('user', array('id' => $message->useridfrom))) {
|
||||
return false;
|
||||
}
|
||||
if (!$userto = $DB->get_record('user', array('id' => $message->useridto))) {
|
||||
return false;
|
||||
}
|
||||
if (!$jabberaddress = get_user_preferences('message_processor_jabber_jabberid', $userto->email, $userto->id)) {
|
||||
$jabberaddress = $userto->email;
|
||||
//hold onto jabber id preference because /admin/cron.php sends a lot of messages at once
|
||||
static $jabberaddresses = array();
|
||||
|
||||
if (!array_key_exists($eventdata->userto->id, $jabberaddresses)) {
|
||||
$jabberaddresses[$eventdata->userto->id] = get_user_preferences('message_processor_jabber_jabberid', $eventdata->userto->email, $eventdata->userto->id);
|
||||
}
|
||||
$jabberaddress = $jabberaddresses[$eventdata->userto->id];
|
||||
|
||||
$jabbermessage = fullname($userfrom).': '.$message->smallmessage;
|
||||
|
||||
$conn = new XMPPHP_XMPP($CFG->jabberhost,$CFG->jabberport,$CFG->jabberusername,$CFG->jabberpassword,'moodle',$CFG->jabberserver);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue