Note: You are currently viewing documentation for Moodle 2.2. Up-to-date documentation for the latest stable version is available here: Messaging 2.0.

Development:Messaging 2.0: Difference between revisions

From MoodleDocs
Line 39: Line 39:
Currently we have support for email, jabber and web-based popups.  Could add twitter and SMS quite easily.
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 [http://cvs.moodle.org/moodle/message/output/lib.php /message/output/lib.php] with methods for:
Each plugin simply extends a class called "message_output" in [http://cvs.moodle.org/moodle/message/output/lib.php /message/output/lib.php] with methods such as:


* send_message()
<code php>
* config_form()
function send_message($message) {
* process_form()
}
* load_data()


function config_form($preferences) {
}
function process_form($form, &$preferences) {
}
function load_data(&$preferences, $userid) {
}
</code>


==See also==
==See also==

Revision as of 04:21, 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 such as:

function send_message($message) { }

function config_form($preferences) { }

function process_form($form, &$preferences) { }

function load_data(&$preferences, $userid) { }

See also