Development:Messaging 2.0
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 such as:
function send_message($message) {
}
function config_form($preferences) {
}
function process_form($form, &$preferences) {
}
function load_data(&$preferences, $userid) {
}
See also
- GSOC/2008
- Messaging improvements, a GSOC 2007 project
- MDL-10107