Ignore:
Timestamp:
May 2, 2016, 12:09:23 PM (3 years ago)
Author:
jrpelegrina
Message:

Updated to moodle 3.0.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • moodle/trunk/fuentes/lib/classes/message/manager.php

    r136 r1331  
    5151     * NOTE: to be used from message_send() only.
    5252     *
    53      * @param \stdClass $eventdata fully prepared event data for processors
     53     * @param \stdClass|\core\message\message $eventdata fully prepared event data for processors
    5454     * @param \stdClass $savemessage the message saved in 'message' table
    5555     * @param array $processorlist list of processors for target user
    5656     * @return int $messageid the id from 'message' or 'message_read' table (false is not returned)
    5757     */
    58     public static function send_message(\stdClass $eventdata, \stdClass $savemessage, array $processorlist) {
     58    public static function send_message($eventdata, \stdClass $savemessage, array $processorlist) {
    5959        global $CFG;
     60
     61        if (!($eventdata instanceof \stdClass) && !($eventdata instanceof message)) {
     62            // Not a valid object.
     63            throw new \coding_exception('Message should be of type stdClass or \core\message\message');
     64        }
     65
    6066        require_once($CFG->dirroot.'/message/lib.php'); // This is most probably already included from messagelib.php file.
    6167
     
    8692     * Send message to message processors.
    8793     *
    88      * @param \stdClass $eventdata
     94     * @param \stdClass|\core\message\message $eventdata
    8995     * @param \stdClass $savemessage
    9096     * @param array $processorlist
    9197     * @return int $messageid
    9298     */
    93     protected static function send_message_to_processors(\stdClass $eventdata, \stdClass $savemessage, array $processorlist) {
     99    protected static function send_message_to_processors($eventdata, \stdClass $savemessage, array
     100    $processorlist) {
    94101        global $CFG, $DB;
    95102
     
    115122        $failed = false;
    116123        foreach ($processorlist as $procname) {
    117             if (!$processors[$procname]->object->send_message($eventdata)) {
     124            // Let new messaging class add custom content based on the processor.
     125            $proceventdata = ($eventdata instanceof message) ? $eventdata->get_eventobject_for_processor($procname) : $eventdata;
     126            if (!$processors[$procname]->object->send_message($proceventdata)) {
    118127                debugging('Error calling message processor ' . $procname);
    119128                $failed = true;
Note: See TracChangeset for help on using the changeset viewer.