Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

(no description)

File Size: 776 lines (27 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: communication_feature  - X-Ref

class communication_feature to handle matrix specific actions.

load_for_instance(processor $communication)   X-Ref
Load the communication provider for the communication api.

param: processor $communication The communication processor object
return: communication_feature The communication provider object

reload()   X-Ref
Reload the room information.
This may be necessary after a room has been created or updated via the adhoc task.
This is primarily intended for use in unit testing, but may have real world cases too.


__construct(private \core_communication\processor $processor,)   X-Ref
Constructor for communication provider to initialize necessary objects for api cals etc..

param: processor $processor The communication processor object

room_exists()   X-Ref
Check whether the room configuration has been created yet.

return: bool

remote_room_exists()   X-Ref
Whether the room exists on the remote server.
This does not involve a remote call, but checks whether Moodle is aware of the room id.

return: bool

get_room_configuration()   X-Ref
Get the stored room configuration.

return: null|matrix_room

get_room_id()   X-Ref
Return the current room id.

return: string|null

create_members(array $userids)   X-Ref
Create members.

param: array $userids The Moodle user ids to create

update_room_membership(array $userids)   X-Ref
No description

add_members_to_room(array $userids)   X-Ref
Add members to a room.

param: array $userids The user ids to add

add_registered_matrix_user_to_room(string $matrixuserid)   X-Ref
Adds the registered matrix user id to room.

param: string $matrixuserid Registered matrix user id

remove_members_from_room(array $userids)   X-Ref
Remove members from a room.

param: array $userids The Moodle user ids to remove

check_user_exists(string $matrixuserid)   X-Ref
Check if a user exists in Matrix.
Use if user existence is needed before doing something else.

param: string $matrixuserid The Matrix user id to check
return: bool

check_room_membership(string $matrixuserid)   X-Ref
Check if a user is a member of a room.
Use if membership confirmation is needed before doing something else.

param: string $matrixuserid The Matrix user id to check
return: bool

create_chat_room()   X-Ref
Create a room based on the data in the communication instance.

return: bool

update_chat_room()   X-Ref
No description

delete_chat_room()   X-Ref
No description

update_room_avatar()   X-Ref
Update the room avatar when an instance image is added or updated.


get_chat_room_url()   X-Ref
No description

save_form_data(\stdClass $instance)   X-Ref
No description

set_form_data(\stdClass $instance)   X-Ref
No description

set_form_definition(\MoodleQuickForm $mform)   X-Ref
No description

get_body(Response $response)   X-Ref
Get the body of a response as a stdClass.

param: Response $response
return: stdClass

set_matrix_power_levels(array $forceremoval = [],)   X-Ref
Set the matrix power level with the room.

Users with a non-moodle power level are not typically removed unless specified in the $forceremoval param.
Matrix Admin users are never removed.

param: array $forceremoval The users to force removal from the room, even if they have a custom power level

get_users_with_custom_power_level(array $users)   X-Ref
Filter the list of users provided to remove those with a moodle-related power level.

param: array $users
return: array

power_levels_changed(array $currentuserpowerlevels,array $newuserpowerlevels,)   X-Ref
No description

get_current_powerlevel_data()   X-Ref
Get the current power level for the room.

return: stdClass

is_power_levels_update_required(array $userids)   X-Ref
Determine if a power level update is required.
Matrix will always set a user to the default power level of 0 when a power level update is made.
That is, unless we specify another level. As long as one person's level is greater than the default,
we will need to set the power levels of all users greater than the default.

param: array $userids The users to evaluate
return: boolean Returns true if an update is required

get_user_allowed_power_level(int $userid)   X-Ref
Get the allowed power level for the user id according to perms/site admin or default.

param: int $userid
return: int

is_configured()   X-Ref
No description