message MDL-25114 tried to provide a more helpful error message for when code sending a message supplied an unknown component or event name

This commit is contained in:
Andrew Davis 2010-11-09 06:01:20 +00:00
parent c8fdd86791
commit 60dd7688a8
2 changed files with 7 additions and 0 deletions

View File

@ -41,6 +41,7 @@ $string['cannotsavemessageprefs'] = 'Could not save user messaging preferences';
$string['contactlistempty'] = 'Your contact list is empty';
$string['contacts'] = 'Contacts';
$string['context'] = 'context';
$string['couldnotfindpreference'] = 'Could not load preference {$a}. Does the component and name you supplied match a row in message_provider?';
$string['deletemessagesdays'] = 'Number of days before old messages are automatically deleted';
$string['disabled'] = 'Messaging is disabled on this site';
$string['discussion'] = 'Discussion';

View File

@ -115,6 +115,12 @@ function message_send($eventdata) {
print_error('cannotsavemessageprefs', 'message');
}
$processor = get_user_preferences($preferencename, NULL, $eventdata->userto->id);
if (empty($processor)) {
//this means they supplied an $eventdata->component $eventdata->name combination which doesn't
//exist in the message_provider table
$preferrormsg = get_string('couldnotfindpreference', 'message', $preferencename);
throw new coding_exception($preferrormsg);
}
}
if ($processor=='none' && $savemessage->notification) {