Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
|
Helper class for the message area. More...
Static Public Member Functions | |
static | create_contact ($contact, $prefix='') |
Helper function for creating a contact object. | |
static | create_messages () |
static | format_conversation_messages (int $userid, int $convid, array $messages) |
Helper function to return a conversation messages with the involved members (only the ones who have sent any of these messages). | |
static | get_conversation_hash (array $userids) |
Returns the conversation hash between users for easy look-ups in the DB. | |
static | 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) |
Helper function to retrieve conversation messages. | |
static | get_conversations_legacy_formatter () |
static | get_last_message_time_created_cache_key (int $convid) |
Returns the cache key for the time created value of the last message of this conversation. | |
static | get_member_info (int $referenceuserid, array $userids, bool $includecontactrequests=false, bool $includeprivacyinfo=false) |
Returns conversation member info for the supplied users, relative to the supplied referenceuserid. | |
static | get_messages () |
static | get_providers_preferences ($providers, $userid) |
Get providers preferences. | |
static | is_online ($lastaccess) |
Helper function for checking the time meets the 'online' condition. | |
static | legacy_messages_exist ($userid) |
Checks if legacy messages exist for a given user. | |
static | messageuser_link_params (int $useridto) |
Returns the attributes to place on the message user button. | |
static | messageuser_requirejs () |
Requires the JS libraries for the message user button. | |
static | prevent_unclosed_html_tags (string $message, bool $removebody=false) |
Prevent unclosed HTML elements in a message. | |
static | render_messaging_widget (bool $isdrawer, int $sendtouser=null, int $conversationid=null, string $view=null) |
Renders the messaging widget. | |
static | search_get_user_details (\stdClass $user, array $userfields=[]) |
Returns user details for a user, if they are visible to the current user in the message search. | |
static | show_online_status ($user) |
Helper function for checking if we should show the user's online status. | |
static | togglecontact_link_params ($user, $iscontact=false, bool $displaytextlabel=true) |
Returns the attributes to place on a contact button. | |
static | togglecontact_requirejs () |
Requires the JS libraries for the toggle contact button. | |
Helper class for the message area.
|
static |
Helper function for creating a contact object.
stdClass | $contact | |
string | $prefix |
stdClass |
|
static |
|
static |
Helper function to return a conversation messages with the involved members (only the ones who have sent any of these messages).
int | $userid | The current userid. |
int | $convid | The conversation id. |
array | $messages | The formated array messages. |
array | A conversation array with the messages and the involved members. |
|
static |
Returns the conversation hash between users for easy look-ups in the DB.
array | $userids |
string |
|
static |
Helper function to retrieve conversation messages.
int | $userid | The current user. |
int | $convid | The conversation identifier. |
int | $timedeleted | The time the message was deleted |
int | $limitfrom | Return a subset of records, starting at this point (optional). |
int | $limitnum | Return a subset comprising this many records in total (optional, required if $limitfrom is set). |
string | $sort | The column name to order by including optionally direction. |
int | $timefrom | The time from the message being sent. |
int | $timeto | The time up until the message being sent. |
array | of messages |
|
static |
|
static |
Returns the cache key for the time created value of the last message of this conversation.
int | $convid | The conversation identifier. |
string | The key. |
|
static |
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.
int | $referenceuserid | the id of the user which check contact and blocked status. |
array | $userids | |
bool | $includecontactrequests | Do we want to include contact requests with this data? |
bool | $includeprivacyinfo | Do we want to include whether the user can message another, and if the user requires a contact. |
array | the array of objects containing member info, indexed by userid. |
coding_exception | |
dml_exception |
|
static |
|
static |
Get providers preferences.
array | $providers | |
int | $userid |
stdClass |
|
static |
Helper function for checking the time meets the 'online' condition.
int | $lastaccess |
boolean |
|
static |
Checks if legacy messages exist for a given user.
int | $userid |
bool |
|
static |
Returns the attributes to place on the message user button.
int | $useridto |
array |
|
static |
Requires the JS libraries for the message user button.
void |
|
static |
Prevent unclosed HTML elements in a message.
string | $message | The html message. |
bool | $removebody | True if we want to remove tag body. |
string | The html properly structured. |
|
static |
Renders the messaging widget.
bool | $isdrawer | Are we are rendering the drawer or is this on a full page? |
int | null | $sendtouser | The ID of the user we want to send a message to |
int | null | $conversationid | The ID of the conversation we want to load |
string | null | $view | The first view to load in the message widget |
string | The HTML. |
|
static |
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.
You can use the $userfields parameter to reduce the amount of a user record that is required by the method. The minimum user fields are:
stdClass | $user | |
array | $userfields | An array of userfields to be returned, the values must be a subset of user_get_default_fields (optional) |
array | the array of userdetails, if visible, or an empty array otherwise. |
|
static |
Helper function for checking if we should show the user's online status.
stdClass | $user |
boolean |
|
static |
Returns the attributes to place on a contact button.
object | $user | User object. |
bool | $iscontact | |
bool | $displaytextlabel | Instructs whether to display a text label. |
array |
|
static |
Requires the JS libraries for the toggle contact button.
void |