Hey guys,
During the development of my submission plugin I want to send messages to other users!
I've found the Message API
http://docs.moodle.org/dev/Message_API#How_to_send_a_message
And I've already tried to do this:
global $DB;
$user = $DB->get_record('user', array('id'=>2));
$userto = $DB->get_record('user', array('id'=>3));
$subject = 'Testnachricht!';
$message = 'Hier ist der Inhalt für den Test';
$eventdata = new stdClass();
$eventdata->modulename = 'assign';
$eventdata->userfrom = $user;
$eventdata->userto = $userto;
$eventdata->subject = $subject;
$eventdata->fullmessage = $message;
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
$eventdata->name = 'assign_notification';
$eventdata->component = 'mod_assign';
$eventdata->notification = 1;
message_send($eventdata);
The appearing error is about writing the database:
error/moodle/dmlwriteexception
I'm totally sure that it is a problem of the lines above. I've already tested it without them and it works!
Thanks for every comment!
René