|
|
| (One intermediate revision by one other user not shown) |
| Line 1: |
Line 1: |
| The Messageing API is a new core system in Moodle to allow communication of messages to users. It's based on the events system, so a module will trigger an event with the attached message data and the message output processor will try to deliver the message to the correct place.
| | This document was replaced by [[Message_API]] |
| | |
| ==Overview==
| |
| | |
| | |
| ===Setting up a provider===
| |
| * db/messages.php (list the types of providers)
| |
| * /lang/XX/messages/providercomponent_providername.html (documentation)
| |
| ...
| |
| | |
| ===Setting up a processor===
| |
| | |
| ===Sending a Message===
| |
| | |
| Whenever you need to send a message, it should “tell” the system about it. So, using the message as an example, we first define an object as follows:
| |
| | |
| $eventdata = new object();
| |
| $eventdata->component = 'message';
| |
| $eventdata->name = 'instantmessage';
| |
| $eventdata->userfrom = $userfrom;
| |
| $eventdata->userto = $userto;
| |
| $eventdata->subject = "IM";
| |
| $eventdata->fullmessage = $message;
| |
| $eventdata->fullmessageformat = FORMAT_PLAIN;
| |
| $eventdata->fullmessagehtml = '';
| |
| $eventdata->smallmessage = '';
| |
| | |
| Then we post the object as an event and forget about it:
| |
| | |
| events_trigger('message_send', $eventdata);
| |
This document was replaced by Message_API