Development:Messaging 2.0: Difference between revisions
No edit summary |
(→Input) |
||
Line 29: | Line 29: | ||
events_trigger('message_send', $eventdata); | events_trigger('message_send', $eventdata); | ||
</ | </code> | ||
More of these can be added throughout Moodle as necessary, it's quite easy. | More of these can be added throughout Moodle as necessary, it's quite easy. |
Revision as of 04:19, 25 November 2008
The messaging system in 2.0 has been revamped significantly. It is now event-driven, and allows users to control exactly what messages they receive and how.
How to enable it
Admin > Optional subsystems > Enable messaging system = Yes
How to configure it
Visit your own profile page (you need moodle/user:editownmessageprofile permission).
How it works
Input
We have events called "message_send" that look like this:
$eventdata = new object();
$eventdata->component = 'mod/forum';
$eventdata->name = 'posts';
$eventdata->userfrom = $userfrom; // object
$eventdata->userto = $userto; // object
$eventdata->subject = $postsubject;
$eventdata->fullmessage = $posttext; // raw text
$eventdata->fullmessageformat = FORMAT_PLAIN; // text format
$eventdata->fullmessagehtml = $posthtml; // html rendered version
$eventdata->smallmessage = ; // useful for plugins like sms or twitter
events_trigger('message_send', $eventdata);
More of these can be added throughout Moodle as necessary, it's quite easy.
Output
In /message/output there are full Moodle plugins for each type of output.
Currently we have support for email, jabber and web-based popups. Could add twitter and SMS quite easily.
Each plugin simply extends a class called "message_output" in /message/output/lib.php with methods for:
- send_message()
- config_form()
- process_form()
- load_data()
See also
- GSOC/2008
- Messaging improvements, a GSOC 2007 project
- MDL-10107