Search moodle.org's
Developer Documentation

  • Bug fixes for general core bugs in 3.11.x will end 9 May 2022 (12 months).
  • Bug fixes for security issues in 3.11.x will end 14 November 2022 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
  • Differences Between: [Versions 310 and 311] [Versions 35 and 311] [Versions 36 and 311] [Versions 37 and 311] [Versions 38 and 311] [Versions 39 and 311]

    Contains helper class for the message area.

    Copyright: 2016 Mark Nelson <markn@moodle.com>
    License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
    File Size: 681 lines (27 kb)
    Included or required:0 times
    Referenced: 0 times
    Includes or requires: 0 files

    Defines 1 class


    Class: helper  - X-Ref

    Helper class for the message area.

    get_messages()   X-Ref


    get_conversation_messages(int $userid, int $convid, int $timedeleted = 0, int $limitfrom = 0,int $limitnum = 0, string $sort = 'timecreated ASC', int $timefrom = 0,int $timeto = 0)   X-Ref
    Helper function to retrieve conversation messages.

    return: array of messages
    param: int $userid The current user.
    param: int $convid The conversation identifier.
    param: int $timedeleted The time the message was deleted
    param: int $limitfrom Return a subset of records, starting at this point (optional).
    param: int $limitnum Return a subset comprising this many records in total (optional, required if $limitfrom is set).
    param: string $sort The column name to order by including optionally direction.
    param: int $timefrom The time from the message being sent.
    param: int $timeto The time up until the message being sent.

    format_conversation_messages(int $userid, int $convid, array $messages)   X-Ref
    Helper function to return a conversation messages with the involved members (only the ones
    who have sent any of these messages).

    return: array A conversation array with the messages and the involved members.
    param: int $userid The current userid.
    param: int $convid The conversation id.
    param: array $messages The formated array messages.

    create_messages()   X-Ref


    create_contact($contact, $prefix = '')   X-Ref
    Helper function for creating a contact object.

    return: \stdClass
    param: \stdClass $contact
    param: string $prefix

    show_online_status($user)   X-Ref
    Helper function for checking if we should show the user's online status.

    return: boolean
    param: \stdClass $user

    is_online($lastaccess)   X-Ref
    Helper function for checking the time meets the 'online' condition.

    return: boolean
    param: int $lastaccess

    get_providers_preferences($providers, $userid)   X-Ref
    Get providers preferences.

    return: \stdClass
    param: array $providers
    param: int $userid

    togglecontact_requirejs()   X-Ref
    Requires the JS libraries for the toggle contact button.

    return: void

    togglecontact_link_params($user, $iscontact = false)   X-Ref
    Returns the attributes to place on a contact button.

    return: array
    param: object $user User object.
    param: bool $iscontact

    messageuser_requirejs()   X-Ref
    Requires the JS libraries for the message user button.

    return: void

    messageuser_link_params(int $useridto)   X-Ref
    Returns the attributes to place on the message user button.

    return: array
    param: int $useridto

    get_conversation_hash(array $userids)   X-Ref
    Returns the conversation hash between users for easy look-ups in the DB.

    return: string
    param: array $userids

    get_last_message_time_created_cache_key(int $convid)   X-Ref
    Returns the cache key for the time created value of the last message of this conversation.

    return: string The key.
    param: int $convid The conversation identifier.

    legacy_messages_exist($userid)   X-Ref
    Checks if legacy messages exist for a given user.

    return: bool
    param: int $userid

    get_member_info(int $referenceuserid, array $userids, bool $includecontactrequests = false,bool $includeprivacyinfo = false)   X-Ref
    Returns conversation member info for the supplied users, relative to the supplied referenceuserid.

    This is the basic structure used when returning members, and includes information about the relationship between each member
    and the referenceuser, such as a whether the referenceuser has marked the member as a contact, or has blocked them.

    return: array the array of objects containing member info, indexed by userid.
    param: int $referenceuserid the id of the user which check contact and blocked status.
    param: array $userids
    param: bool $includecontactrequests Do we want to include contact requests with this data?
    param: bool $includeprivacyinfo Do we want to include whether the user can message another, and if the user

    get_conversations_legacy_formatter()   X-Ref


    render_messaging_widget(bool $isdrawer,int $sendtouser = null,int $conversationid = null,string $view = null)   X-Ref
    Renders the messaging widget.

    return: string The HTML.
    param: bool $isdrawer Are we are rendering the drawer or is this on a full page?
    param: int|null $sendtouser The ID of the user we want to send a message to
    param: int|null $conversationid The ID of the conversation we want to load
    param: string|null $view The first view to load in the message widget

    search_get_user_details(\stdClass $user)   X-Ref
    Returns user details for a user, if they are visible to the current user in the message search.

    This method checks the visibility of a user specifically for the purpose of inclusion in the message search results.
    Visibility depends on the site-wide messaging setting 'messagingallusers':
    If enabled, visibility depends only on the core notion of visibility; a visible site or course profile.
    If disabled, visibility requires that the user be sharing a course with the searching user, and have a visible profile there.
    The current user is always returned.

    return: array the array of userdetails, if visible, or an empty array otherwise.
    param: \stdClass $user