Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
core_communication\api Class Reference

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.
 
 configure_room_and_membership_by_provider (string $provider, stdClass $instance, string $communicationroomname, array $users, ?\stored_file $instanceimage=null, bool $queue=true,)
 Configure the room and membership by provider selected for the communication instance.
 
 create_and_configure_room (string $communicationroomname, ?\stored_file $avatar=null, ?\stdClass $instance=null, bool $queue=true,)
 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_all_members_from_room (bool $queue=true)
 Remove all users from the room.
 
 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.
 
 sync_provider ()
 Add the task to sync the provider data with local Moodle data.
 
 update_room (?int $active=null, ?string $communicationroomname=null, ?\stored_file $avatar=null, ?\stdClass $instance=null, bool $queue=true,)
 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.
 

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

◆ configure_room_and_membership_by_provider()

core_communication\api::configure_room_and_membership_by_provider ( string $provider,
stdClass $instance,
string $communicationroomname,
array $users,
?\stored_file $instanceimage = null,
bool $queue = true )

Configure the room and membership by provider selected for the communication instance.

This method will add a task to the queue to configure the room and membership by comparing the change of provider. There are some major cases to consider for this method to allow minimum duplication when this api is used. Some of the major cases are:

  1. If the communication instance is not created at all, then create it and add members.
  2. If the current provider is none and the new provider is also none, then nothing to do.
  3. If the current and existing provider is the same, don't need to do anything.
  4. If provider set to none, remove all the members.
  5. If previous provider was not none and current provider is not none, but a different provider, remove members and add for the new one.
  6. If previous provider was none and current provider is not none, don't need to remove, just update the selected provider and add users to that provider. Do not queue the task to add members to room as the room might not have created yet. The add room task adds the task to add members to room anyway.
  7. If it's a new provider, never used/created, now create the room after considering all these cases for a new provider.
Parameters
string$providerThe provider name
stdClass$instanceThe instance object
string$communicationroomnameThe communication room name
array$usersThe user ids to add to the room
null | stored_file$instanceimageThe stored file for the avatar
bool$queueQueue the task for the provider room or not

◆ create_and_configure_room()

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

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
bool$queueWhether to queue the task or not

◆ 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_all_members_from_room()

core_communication\api::remove_all_members_from_room ( bool $queue = true)

Remove all users from the room.

Parameters
bool$queueWhether to queue the task or not

◆ 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,
bool $queue = true )

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
bool$queueWhether to queue the task or not

◆ 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: