public static function data_for_messagearea_search_users($userid, $search, $limitnum = 0) {
        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(
            'userid' => $userid,
            'search' => $search,
            'limitnum' => $limitnum
        );
        $params = self::validate_parameters(self::data_for_messagearea_search_users_parameters(), $params);
        self::validate_context($systemcontext);

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

        list($contacts, $courses, $noncontacts) = \core_message\api::search_users(
            $params['userid'],
            $params['search'],
            $params['limitnum']
        );

        $search = new \core_message\output\messagearea\user_search_results($contacts, $courses, $noncontacts);

        $renderer = $PAGE->get_renderer('core_message');
        return $search->export_for_template($renderer);
    }
public static function data_for_messagearea_search_users($userid, $search, $limitnum = 0) {
        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(
            'userid' => $userid,
            'search' => $search,
            'limitnum' => $limitnum
        );
        $params = self::validate_parameters(self::data_for_messagearea_search_users_parameters(), $params);
        self::validate_context($systemcontext);

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

        list($contacts, $courses, $noncontacts) = \core_message\api::search_users(
            $params['userid'],
            $params['search'],
            $params['limitnum']
        );

        $search = new \core_message\output\messagearea\user_search_results($contacts, $courses, $noncontacts);

        $renderer = $PAGE->get_renderer('core_message');
        return $search->export_for_template($renderer);
    }
public static function data_for_messagearea_search_users ( $ userid , $ search , $ limitnum = 0 ) { 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 ( 'userid' => $ userid , 'search' => $ search , 'limitnum' => $ limitnum ) ; $ params = self :: validate_parameters ( self :: data_for_messagearea_search_users_parameters ( ) , $ params ) ; self :: validate_context ( $ systemcontext ) ; if ( ( $ USER -> id != $ params [ 'userid' ] ) && ! has_capability ( 'moodle/site:readallmessages' , $ systemcontext ) ) { throw new moodle_exception ( 'You do not have permission to perform this action.' ) ; } list ( $ contacts , $ courses , $ noncontacts ) = \ core_message \ api :: search_users ( $ params [ 'userid' ] , $ params [ 'search' ] , $ params [ 'limitnum' ] ) ; $ search = new \ core_message \ output \ messagearea \ user_search_results ( $ contacts , $ courses , $ noncontacts ) ; $ renderer = $ PAGE -> get_renderer ( 'core_message' ) ; return $ search -> export_for_template ( $ renderer ) ; }
Get messagearea search users results.

@deprecated since 3.6

@param int $userid The id of the user who is performing the search
@param string $search The string being searched
@param int $limitnum
@return stdClass
@throws moodle_exception
@since 3.2
Get messagearea search users results .