MDL-54928 notifications: Retrieve username from DB if empty

This commit is contained in:
Dani Palou
2016-07-05 10:36:13 +02:00
parent 6513308ba7
commit b65a928372
@@ -43,7 +43,7 @@ class message_output_airnotifier extends message_output {
* @return true if ok, false if error
*/
public function send_message($eventdata) {
global $CFG;
global $CFG, $DB;
require_once($CFG->libdir . '/filelib.php');
if (!empty($CFG->noemailever)) {
@@ -59,6 +59,11 @@ class message_output_airnotifier extends message_output {
return true;
}
// If username is empty we try to retrieve it, since it's required to generate the siteid.
if (empty($eventdata->userto->username)) {
$eventdata->userto->username = $DB->get_field('user', 'username', array('id' => $eventdata->userto->id));
}
// Site id, to map with Moodle Mobile stored sites.
$siteid = md5($CFG->wwwroot . $eventdata->userto->username);