public static function data_for_messagearea_get_most_recent_message($currentuserid, $otheruserid) {
        global $CFG, $PAGE, $USER;

        // Check if messaging is enabled.
        if (empty($CFG->messaging)) {
            throw new moodle_exception('disabled', 'message');
        }

        $systemcontext = context_system::instance();

        $params = array(
            'currentuserid' => $currentuserid,
            'otheruserid' => $otheruserid
        );
        $params = self::validate_parameters(self::data_for_messagearea_get_most_recent_message_parameters(), $params);
        self::validate_context($systemcontext);

        if (($USER->id != $params['currentuserid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
            throw new moodle_exception('You do not have permission to perform this action.');
        }

        $message = \core_message\api::get_most_recent_message($params['currentuserid'], $params['otheruserid']);
        $message = new \core_message\output\messagearea\message($message);

        $renderer = $PAGE->get_renderer('core_message');
        return $message->export_for_template($renderer);
    }
public static function data_for_messagearea_get_most_recent_message($currentuserid, $otheruserid) {
        global $CFG, $PAGE, $USER;

        // Check if messaging is enabled.
        if (empty($CFG->messaging)) {
            throw new moodle_exception('disabled', 'message');
        }

        $systemcontext = context_system::instance();

        $params = array(
            'currentuserid' => $currentuserid,
            'otheruserid' => $otheruserid
        );
        $params = self::validate_parameters(self::data_for_messagearea_get_most_recent_message_parameters(), $params);
        self::validate_context($systemcontext);

        if (($USER->id != $params['currentuserid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
            throw new moodle_exception('You do not have permission to perform this action.');
        }

        $message = \core_message\api::get_most_recent_message($params['currentuserid'], $params['otheruserid']);
        $message = new \core_message\output\messagearea\message($message);

        $renderer = $PAGE->get_renderer('core_message');
        return $message->export_for_template($renderer);
    }
public static function data_for_messagearea_get_most_recent_message ( $ currentuserid , $ otheruserid ) { global $ CFG , $ PAGE , $ USER ; // Check if messaging is enabled. if ( empty ( $ CFG -> messaging ) ) { throw new moodle_exception ( 'disabled' , 'message' ) ; } $ systemcontext = context_system :: instance ( ) ; $ params = array ( 'currentuserid' => $ currentuserid , 'otheruserid' => $ otheruserid ) ; $ params = self :: validate_parameters ( self :: data_for_messagearea_get_most_recent_message_parameters ( ) , $ params ) ; self :: validate_context ( $ systemcontext ) ; if ( ( $ USER -> id != $ params [ 'currentuserid' ] ) && ! has_capability ( 'moodle/site:readallmessages' , $ systemcontext ) ) { throw new moodle_exception ( 'You do not have permission to perform this action.' ) ; } $ message = \ core_message \ api :: get_most_recent_message ( $ params [ 'currentuserid' ] , $ params [ 'otheruserid' ] ) ; $ message = new \ core_message \ output \ messagearea \ message ( $ message ) ; $ renderer = $ PAGE -> get_renderer ( 'core_message' ) ; return $ message -> export_for_template ( $ renderer ) ; }
Get the most recent message in a conversation.

@deprecated since 3.6
@param int $currentuserid The current user's id
@param int $otheruserid The other user's id
@return stdClass
@throws moodle_exception
@since 3.2
Get the most recent message in a conversation .