Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
core_communication\api Class Reference

Class api is the public endpoint of the communication api. More...

Public Member Functions

 add_members_to_room (array $userids, bool $queue=true)
 Create a communication ad-hoc task for add members operation and add the user mapping.
 
 create_and_configure_room (string $communicationroomname, ?\stored_file $avatar=null, ?\stdClass $instance=null,)
 Create a communication ad-hoc task for create operation.
 
 delete_room ()
 Create a communication ad-hoc task for delete operation.
 
 form_definition (MoodleQuickForm $mform, string $selectdefaultcommunication=processor::PROVIDER_NONE)
 Define the form elements for the communication api.
 
 form_definition_for_provider (\MoodleQuickForm $mform, string $provider=processor::PROVIDER_NONE)
 Set the form definitions for the plugins.
 
 get_avatar ()
 Get the avatar file.
 
 get_communication_room_url ()
 Get the communication room url.
 
 get_form_provider ()
 Return the form provider.
 
 get_processor ()
 Return the underlying communication processor object.
 
 get_provider ()
 Get the communication provider.
 
 get_room_name ()
 A helper to fetch the room name.
 
 get_room_provider ()
 Return the room provider.
 
 get_room_user_provider ()
 Return the room user provider.
 
 get_user_provider ()
 Return the user provider.
 
 reload ()
 Reload in the internal instance data.
 
 remove_members_from_room (array $userids, bool $queue=true)
 Create a communication ad-hoc task for remove members operation or action immediately.
 
 set_avatar (?\stored_file $avatar)
 Get the avatar file.
 
 set_data (\stdClass $instance)
 Set the form data if the data is already available.
 
 show_communication_room_status_notification ()
 Display the communication room status notification.
 
 update_room (?int $active=null, ?string $communicationroomname=null, ?\stored_file $avatar=null, ?\stdClass $instance=null,)
 Create a communication ad-hoc task for update operation.
 
 update_room_membership (array $userids, bool $queue=true)
 Create a communication ad-hoc task for updating members operation and update the user mapping.
 

Static Public Member Functions

static get_communication_plugin_list_for_form ()
 Get the list of plugins for form selection.
 
static get_enabled_providers_and_default (string $selecteddefaulprovider=null)
 Get the enabled communication providers and default provider according to the selected provider.
 
static is_available ()
 Check if the communication api is enabled.
 
static load_by_instance (context $context, string $component, string $instancetype, int $instanceid, ?string $provider=null,)
 Get the communication processor object.
 

Protected Member Functions

 get_avatar_filerecord (string $filename)
 Get the avatar file record for the avatar for filesystem.
 

Detailed Description

Class api is the public endpoint of the communication api.

This class is the point of contact for api usage.

Communication api allows to add ad-hoc tasks to the queue to perform actions on the communication providers. This api will not allow any immediate actions to be performed on the communication providers. It will only add the tasks to the queue. The exception has been made for deletion of members in case of deleting the user. This is because the user will not be available. The member management api part allows run actions immediately if required.

Communication api does allow to have form elements related to communication api in the required forms. This is done by using the form_definition method. This method will add the form elements to the form.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ add_members_to_room()

core_communication\api::add_members_to_room ( array $userids,
bool $queue = true )

Create a communication ad-hoc task for add members operation and add the user mapping.

This method will add a task to the queue to add the room users.

Parameters
array$useridsThe user ids to add to the room
bool$queueWhether to queue the task or not

◆ create_and_configure_room()

core_communication\api::create_and_configure_room ( string $communicationroomname,
?\stored_file $avatar = null,
?\stdClass $instance = null )

Create a communication ad-hoc task for create operation.

This method will add a task to the queue to create the room.

Parameters
string$communicationroomnameThe communication room name
null | stored_file$avatarThe stored file for the avatar
stdClass | null$instanceThe actual instance object

◆ delete_room()

core_communication\api::delete_room ( )

Create a communication ad-hoc task for delete operation.

This method will add a task to the queue to delete the room.

◆ form_definition()

core_communication\api::form_definition ( MoodleQuickForm $mform,
string $selectdefaultcommunication = processor::PROVIDER_NONE )

Define the form elements for the communication api.

This method will be called from the form definition method of the instance.

Parameters
MoodleQuickForm$mformThe form element
string$selectdefaultcommunicationThe default selected communication provider in the form field

◆ form_definition_for_provider()

core_communication\api::form_definition_for_provider ( \MoodleQuickForm $mform,
string $provider = processor::PROVIDER_NONE )

Set the form definitions for the plugins.

Parameters
MoodleQuickForm$mformThe moodle form
string$providerThe provider name

◆ get_avatar()

core_communication\api::get_avatar ( )

Get the avatar file.

Return values
null|stored_file

◆ get_avatar_filerecord()

core_communication\api::get_avatar_filerecord ( string $filename)
protected

Get the avatar file record for the avatar for filesystem.

Parameters
string$filenameThe filename of the avatar
Return values
stdClass

◆ get_communication_plugin_list_for_form()

static core_communication\api::get_communication_plugin_list_for_form ( )
static

Get the list of plugins for form selection.

Return values
array

◆ get_communication_room_url()

core_communication\api::get_communication_room_url ( )

Get the communication room url.

Return values
string|null

◆ get_enabled_providers_and_default()

static core_communication\api::get_enabled_providers_and_default ( string $selecteddefaulprovider = null)
static

Get the enabled communication providers and default provider according to the selected provider.

Parameters
string | null$selecteddefaulprovider
Return values
array

◆ get_form_provider()

core_communication\api::get_form_provider ( )

Return the form provider.

Return values
core_communication\form_provider

◆ get_processor()

core_communication\api::get_processor ( )

Return the underlying communication processor object.

Return values
processor

◆ get_provider()

core_communication\api::get_provider ( )

Get the communication provider.

Return values
string

◆ get_room_name()

core_communication\api::get_room_name ( )

A helper to fetch the room name.

Return values
string

◆ get_room_provider()

core_communication\api::get_room_provider ( )

Return the room provider.

Return values
core_communication\room_chat_provider

◆ get_room_user_provider()

core_communication\api::get_room_user_provider ( )

Return the room user provider.

Return values
core_communication\room_user_provider

◆ get_user_provider()

core_communication\api::get_user_provider ( )

Return the user provider.

Return values
core_communication\user_provider

◆ load_by_instance()

static core_communication\api::load_by_instance ( context $context,
string $component,
string $instancetype,
int $instanceid,
?string $provider = null )
static

Get the communication processor object.

Parameters
context$contextThe context of the item for the instance
string$componentThe component of the item for the instance
string$instancetypeThe type of the item for the instance
int$instanceidThe id of the instance
string | null$providerThe provider type - if null will load for this context's active provider.
Return values
api

◆ remove_members_from_room()

core_communication\api::remove_members_from_room ( array $userids,
bool $queue = true )

Create a communication ad-hoc task for remove members operation or action immediately.

This method will add a task to the queue to remove the room users.

Parameters
array$useridsThe user ids to remove from the room
bool$queueWhether to queue the task or not

◆ set_avatar()

core_communication\api::set_avatar ( ?\stored_file $avatar)

Get the avatar file.

If null is set, then delete the old area file and set the avatarfilename to null. This will make sure the plugin api deletes the avatar from the room.

Parameters
null | stored_file$avatarThe stored file for the avatar
Return values
bool

◆ set_data()

core_communication\api::set_data ( \stdClass $instance)

Set the form data if the data is already available.

Parameters
stdClass$instanceThe instance object

◆ update_room()

core_communication\api::update_room ( ?int $active = null,
?string $communicationroomname = null,
?\stored_file $avatar = null,
?\stdClass $instance = null )

Create a communication ad-hoc task for update operation.

This method will add a task to the queue to update the room.

Parameters
null | int$activeThe selected active state of the provider
null | string$communicationroomnameThe communication room name
null | stored_file$avatarThe stored file for the avatar
stdClass | null$instanceThe actual instance object

◆ update_room_membership()

core_communication\api::update_room_membership ( array $userids,
bool $queue = true )

Create a communication ad-hoc task for updating members operation and update the user mapping.

This method will add a task to the queue to update the room users.

Parameters
array$useridsThe user ids to add to the room
bool$queueWhether to queue the task or not

The documentation for this class was generated from the following file: