Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
mod_bigbluebuttonbn\recording Class Reference
Inheritance diagram for mod_bigbluebuttonbn\recording:
core\persistent

Public Member Functions

 __construct ($id=0, stdClass $record=null, ?array $metadata=null)
 Create an instance of this class.
 
 create ()
 Insert a record in the DB.
 
 create_imported_recording (instance $targetinstance)
 Create a new imported recording from current recording.
 
 delete ()
 Delete an entry from the database.
 
 from_record (stdClass $record)
 Populate this class with data from a DB record.
 
 get ($property)
 Data getter.
 
 get_errors ()
 Returns the validation errors.
 
 get_instance ()
 Get the instance that this recording relates to.
 
 get_remote_playback_url (string $type)
 Get the playback URL for the specified type.
 
 is_valid ()
 Returns whether or not the model is valid.
 
 read ()
 Load the data from the DB.
 
 save ()
 Saves the record to the database.
 
 set ($property, $value)
 Data setter.
 
 set_many (array $values)
 Data setter for multiple properties.
 
 to_record ()
 Create a DB record from this class.
 
 update ()
 Update the existing record in the DB.
 
 validate ()
 Validates the data.
 

Static Public Member Functions

static count_records (array $conditions=array())
 Count a list of records.
 
static count_records_select ($select, $params=null)
 Count a list of records.
 
static extract_record ($row, $prefix=null)
 Extract a record from a row of data.
 
static get_formatted_properties ()
 Gets all the formatted properties.
 
static get_record (array $filters=[], int $strictness=IGNORE_MISSING)
 Load a single record.
 
static get_recordings_for_course (int $courseid, array $excludedinstanceid=[], bool $includeimported=false, bool $onlyimported=false, bool $includedeleted=false, bool $onlydeleted=false)
 Helper function to retrieve recordings from a given course.
 
static get_recordings_for_instance (instance $instance, bool $includeimported=false, bool $onlyimported=false)
 Helper function to retrieve recordings from the BigBlueButton.
 
static get_records ($filters=array(), $sort='', $order='ASC', $skip=0, $limit=0)
 Load a list of records.
 
static get_records_select ($select, $params=null, $sort='', $fields=' *', $limitfrom=0, $limitnum=0)
 Load a list of records based on a select query.
 
static get_sql_fields ($alias, $prefix=null)
 Return the list of fields for use in a SELECT clause.
 
static has_property ($property)
 Returns whether or not a property was defined.
 
static is_property_required ($property)
 Returns whether or not a property is required.
 
static properties_definition ()
 Get the properties definition of this model.
 
static properties_filter (stdClass $record)
 For a given record, return an array containing only those properties that are defined by the persistent.
 
static record_exists ($id)
 Check if a record exists by ID.
 
static record_exists_select ($select, array $params=null)
 Check if a records exists.
 
static sync_pending_recordings_from_server (bool $dismissedonly=false)
 Synchronise pending recordings from the server.
 

Public Attributes

bool $imported
 imported recording status
 
string const DEFAULT_RECORDING_SORT = 'timecreated ASC'
 Default sort for recordings when fetching from the database.
 
int const INCLUDE_IMPORTED_RECORDINGS = true
 Defines that the list should include imported recordings.
 
const POSSIBLE_REMOTE_META_SOURCE
 POSSIBLE_REMOTE_META_SOURCE match a field type and its metadataname (historical and current).
 
int const RECORDING_HEADLESS = 1
 Defines that the activity used to create the recording no longer exists.
 
int const RECORDING_IMPORTED = 1
 Defines that the recording is not the original but an imported one.
 
int const RECORDING_REFRESH_DEFAULT_PERIOD = 300
 A refresh period for recordings, defaults to 300s (5mins)
 
int const RECORDING_STATUS_AWAITING = 0
 A meeting set to be recorded still awaits for a recording update.
 
int const RECORDING_STATUS_DELETED = 5
 A meeting set to be recorded was deleted from bigbluebutton.
 
int const RECORDING_STATUS_DISMISSED = 1
 A meeting set to be recorded was not recorded and dismissed by BBB.
 
int const RECORDING_STATUS_NOTIFIED = 3
 A meeting set to be recorded received notification callback from BBB.
 
int const RECORDING_STATUS_PROCESSED = 2
 A meeting set to be recorded has a recording processed.
 
int const RECORDING_STATUS_RESET = 4
 A meeting set to be recorded was processed and set back to an awaiting state.
 
int const RECORDING_TIME_LIMIT_DAYS = 30
 A time limit for recordings to be dismissed, defaults to 30d (30days)
 
const TABLE = 'bigbluebuttonbn_recordings'
 The table name.
 

Protected Member Functions

 after_create ()
 Hook to execute after a create.
 
 after_delete ($result)
 Hook to execute after a delete.
 
 after_update ($result)
 Hook to execute after an update.
 
 before_create ()
 Hook to execute before a create.
 
 before_delete ()
 Delete the recording in the BBB button.
 
 before_update ()
 Before doing the database update, let's check if we need to update metadata.
 
 before_validate ()
 Hook to execute before the validation.
 
 fetch_metadata (bool $force=false)
 Fetch metadata.
 
 get_description ()
 Description is stored in the metadata, so we sometimes needs to do some conversion.
 
 get_endtime ()
 Start time.
 
 get_name ()
 Name is stored in the metadata.
 
 get_playbacks ()
 List of playbacks for this recording.
 
 get_possible_meta_name_for_source ($sourcetype, $metadata)
 Get the real metadata name for the possible source.
 
 get_protected ()
 Is protected.
 
 get_published ()
 Is published.
 
 get_starttime ()
 Start time.
 
 metadata_get ($fieldname)
 Get information stored in the recording metadata such as description, name and other info.
 
 metadata_set ($fieldname, $value)
 Set locally stored metadata from this instance.
 
 raw_get ($property)
 Internal Data getter.
 
 raw_set ($property, $value)
 Data setter.
 
 refresh_metadata_if_required ()
 Refresh metadata if required.
 
 remote_meta_convert ()
 Convert string (metadata) to json object.
 
 set_description ($value)
 Set Description.
 
 set_endtime ($value)
 Recording endtime.
 
 set_name ($value)
 Set name.
 
 set_protected ($value)
 Recording is protected.
 
 set_published ($value)
 Recording is published.
 
 set_starttime ($value)
 Recording starttime.
 
 set_status ($value)
 Update recording status.
 
 verify_protected_methods ()
 This function is used to verify that custom getters and setters are declared as protected.
 

Static Protected Member Functions

static define_properties ()
 Return the definition of the properties of this model.
 
static fetch_records (array $selects, array $params)
 Fetch all records which match the specified parameters, including all metadata that relates to them.
 
static get_basic_select_from_parameters (bool $includedeleted=false, bool $includeimported=false, bool $onlyimported=false, bool $onlydeleted=false)
 Get basic sql select from given parameters.
 
static get_property_default_value ($property)
 Gets the default value for a property.
 
static get_property_error_message ($property)
 Gets the error message for a property.
 
static get_select_for_group ($groupmode, $context, $courseid, $groupid=0, $groupingid=0)
 Get select for given group mode and context.
 

Protected Attributes

instance $instance
 A cached copy of the instance.
 
array $metadata = null
 A cached copy of the metadata.
 
bool $metadatachanged = false
 Whether metadata been changed so the remote information needs to be updated ?
 

Constructor & Destructor Documentation

◆ __construct()

mod_bigbluebuttonbn\recording::__construct ( $id = 0,
stdClass $record = null,
?array $metadata = null )

Create an instance of this class.

Parameters
int$idIf set, this is the id of an existing record, used to load the data.
stdClass | null$recordIf set will be passed to from_record
null | array$metadata

Member Function Documentation

◆ after_create()

core\persistent::after_create ( )
protectedinherited

◆ after_delete()

core\persistent::after_delete ( $result)
protectedinherited

◆ after_update()

core\persistent::after_update ( $result)
protectedinherited

◆ before_create()

core\persistent::before_create ( )
protectedinherited

Hook to execute before a create.

Please note that at this stage the data has already been validated and therefore any new data being set will not be validated before it is sent to the database.

This is only intended to be used by child classes, do not put any logic here!

Return values
void

Reimplemented in quizaccess_seb\seb_quiz_settings, and quizaccess_seb\template.

◆ before_delete()

mod_bigbluebuttonbn\recording::before_delete ( )
protected

Delete the recording in the BBB button.

Return values
void

Reimplemented from core\persistent.

◆ before_update()

mod_bigbluebuttonbn\recording::before_update ( )
protected

Before doing the database update, let's check if we need to update metadata.

Return values
void

Reimplemented from core\persistent.

◆ before_validate()

core\persistent::before_validate ( )
protectedinherited

Hook to execute before the validation.

This hook will not affect the validation results in any way but is useful to internally set properties which will need to be validated.

This is only intended to be used by child classes, do not put any logic here!

Return values
void

Reimplemented in core\oauth2\issuer, core_competency\competency, core_competency\competency_framework, core_competency\course_competency, core_competency\course_module_competency, core_competency\plan, core_competency\plan_competency, core_competency\template, core_competency\template_competency, and quizaccess_seb\seb_quiz_settings.

◆ count_records()

static core\persistent::count_records ( array $conditions = array())
staticinherited

Count a list of records.

Parameters
array$conditionsAn array of conditions.
Return values
int

◆ count_records_select()

static core\persistent::count_records_select ( $select,
$params = null )
staticinherited

Count a list of records.

Parameters
string$select
array$params
Return values
int

◆ create()

core\persistent::create ( )
finalinherited

Insert a record in the DB.

Return values
static

◆ create_imported_recording()

mod_bigbluebuttonbn\recording::create_imported_recording ( instance $targetinstance)

Create a new imported recording from current recording.

Parameters
instance$targetinstance
Return values
recording

◆ define_properties()

static mod_bigbluebuttonbn\recording::define_properties ( )
staticprotected

Return the definition of the properties of this model.

Return values
array

Reimplemented from core\persistent.

◆ delete()

core\persistent::delete ( )
finalinherited

Delete an entry from the database.

Return values
boolTrue on success.

◆ extract_record()

static core\persistent::extract_record ( $row,
$prefix = null )
staticinherited

Extract a record from a row of data.

Most likely used in combination with self::get_sql_fields(). This method is simple enough to be used by non-persistent classes, keep that in mind when modifying it.

e.g. persistent\extract_record($row, 'user'); should work.

Parameters
stdClass$rowThe row of data.
string$prefixThe prefix the data fields are prefixed with, defaults to the table name followed by underscore.
Return values
stdClassThe extracted data.

◆ fetch_metadata()

mod_bigbluebuttonbn\recording::fetch_metadata ( bool $force = false)
protected

Fetch metadata.

If metadata has changed locally or if it an imported recording, nothing will be done.

Parameters
bool$force
Return values
array

◆ fetch_records()

static mod_bigbluebuttonbn\recording::fetch_records ( array $selects,
array $params )
staticprotected

Fetch all records which match the specified parameters, including all metadata that relates to them.

Parameters
array$selects
array$params
Return values
recording[]

◆ from_record()

core\persistent::from_record ( stdClass $record)
finalinherited

Populate this class with data from a DB record.

Note that this does not use any custom setter because the data here is intended to represent what is stored in the database.

Parameters
stdClass$recordA DB record.
Return values
static

◆ get()

core\persistent::get ( $property)
finalinherited

Data getter.

This is the main getter for all the properties. Developers can implement their own getters (get_propertyname) and they will be called by this function. Custom getters can use raw_get to get the raw value. Internally this is not used by self::to_record() or self::from_record() because the data is not expected to be validated or changed when reading/writing raw records from the DB.

Parameters
string$propertyThe property name.
Return values
mixed

◆ get_basic_select_from_parameters()

static mod_bigbluebuttonbn\recording::get_basic_select_from_parameters ( bool $includedeleted = false,
bool $includeimported = false,
bool $onlyimported = false,
bool $onlydeleted = false )
staticprotected

Get basic sql select from given parameters.

Parameters
bool$includedeleted
bool$includeimported
bool$onlyimported
bool$onlydeleted
Return values
array

◆ get_endtime()

mod_bigbluebuttonbn\recording::get_endtime ( )
protected

Start time.

Return values
mixed|null

◆ get_errors()

core\persistent::get_errors ( )
finalinherited

Returns the validation errors.

Return values
array

◆ get_formatted_properties()

static core\persistent::get_formatted_properties ( )
staticfinalinherited

Gets all the formatted properties.

Formatted properties are properties which have a format associated with them.

Return values
arrayKeys are property names, values are property format names.

◆ get_instance()

mod_bigbluebuttonbn\recording::get_instance ( )

Get the instance that this recording relates to.

Return values
instance

◆ get_playbacks()

mod_bigbluebuttonbn\recording::get_playbacks ( )
protected

List of playbacks for this recording.

Return values
array[]

◆ get_possible_meta_name_for_source()

mod_bigbluebuttonbn\recording::get_possible_meta_name_for_source ( $sourcetype,
$metadata )
protected

Get the real metadata name for the possible source.

Parameters
string$sourcetypethe name of the source we look for (name, description...)
array$metadatacurrent metadata

◆ get_property_default_value()

static core\persistent::get_property_default_value ( $property)
staticfinalprotectedinherited

Gets the default value for a property.

This assumes that the property exists.

Parameters
string$propertyThe property name.
Return values
mixed

◆ get_property_error_message()

static core\persistent::get_property_error_message ( $property)
staticfinalprotectedinherited

Gets the error message for a property.

This assumes that the property exists.

Parameters
string$propertyThe property name.
Return values
lang_string

◆ get_protected()

mod_bigbluebuttonbn\recording::get_protected ( )
protected

Is protected.

Return null if protected is not implemented.

Return values
bool|null

◆ get_published()

mod_bigbluebuttonbn\recording::get_published ( )
protected

Is published.

Return values
bool

◆ get_record()

static core\persistent::get_record ( array $filters = [],
int $strictness = IGNORE_MISSING )
staticinherited

Load a single record.

Parameters
array$filtersFilters to apply.
int$strictnessSimilar to the internal DB get_record call, indicate whether a missing record should be ignored/return false ({
See also
IGNORE_MISSING}) or should cause an exception to be thrown ({
MUST_EXIST})
Return values
false|static

◆ get_recordings_for_course()

static mod_bigbluebuttonbn\recording::get_recordings_for_course ( int $courseid,
array $excludedinstanceid = [],
bool $includeimported = false,
bool $onlyimported = false,
bool $includedeleted = false,
bool $onlydeleted = false )
static

Helper function to retrieve recordings from a given course.

Parameters
int$courseidid for a course record or null
array$excludedinstanceidexclude recordings from instance ids
bool$includeimported
bool$onlyimported
bool$includedeleted
bool$onlydeleted
Return values
recording[]containing the recordings indexed by recordID, each recording is also a non sequential associative array itself that corresponds to the actual recording in BBB

◆ get_recordings_for_instance()

static mod_bigbluebuttonbn\recording::get_recordings_for_instance ( instance $instance,
bool $includeimported = false,
bool $onlyimported = false )
static

Helper function to retrieve recordings from the BigBlueButton.

Parameters
instance$instance
bool$includeimported
bool$onlyimported
Return values
recording[]containing the recordings indexed by recordID, each recording is also a non sequential associative array itself that corresponds to the actual recording in BBB

◆ get_records()

static core\persistent::get_records ( $filters = array(),
$sort = '',
$order = 'ASC',
$skip = 0,
$limit = 0 )
staticinherited

Load a list of records.

Parameters
array$filtersFilters to apply.
string$sortField to sort by.
string$orderSort order.
int$skipLimitstart.
int$limitNumber of rows to return.
Return values
static[]

◆ get_records_select()

static core\persistent::get_records_select ( $select,
$params = null,
$sort = '',
$fields = '*',
$limitfrom = 0,
$limitnum = 0 )
staticinherited

Load a list of records based on a select query.

Parameters
string$select
array$params
string$sort
string$fields
int$limitfrom
int$limitnum
Return values
static[]

◆ get_remote_playback_url()

mod_bigbluebuttonbn\recording::get_remote_playback_url ( string $type)

Get the playback URL for the specified type.

Parameters
string$type
Return values
null|string

◆ get_select_for_group()

static mod_bigbluebuttonbn\recording::get_select_for_group ( $groupmode,
$context,
$courseid,
$groupid = 0,
$groupingid = 0 )
staticprotected

Get select for given group mode and context.

Parameters
int$groupmode
context$context
int$courseid
int$groupid
int$groupingid
Return values
array

◆ get_sql_fields()

static core\persistent::get_sql_fields ( $alias,
$prefix = null )
staticinherited

Return the list of fields for use in a SELECT clause.

Having the complete list of fields prefixed allows for multiple persistents to be fetched in a single query. Use self::extract_record() to extract the records from the query result.

Parameters
string$aliasThe alias used for the table.
string$prefixThe prefix to use for each field, defaults to the table name followed by underscore.
Return values
stringThe SQL fragment.

◆ get_starttime()

mod_bigbluebuttonbn\recording::get_starttime ( )
protected

Start time.

Return values
mixed|null

◆ has_property()

static core\persistent::has_property ( $property)
staticfinalinherited

Returns whether or not a property was defined.

Parameters
string$propertyThe property name.
Return values
boolean

◆ is_property_required()

static core\persistent::is_property_required ( $property)
staticfinalinherited

Returns whether or not a property is required.

By definition a property with a default value is not required.

Parameters
string$propertyThe property name.
Return values
boolean

◆ is_valid()

core\persistent::is_valid ( )
finalinherited

Returns whether or not the model is valid.

Return values
booleanTrue when it is.

◆ metadata_get()

mod_bigbluebuttonbn\recording::metadata_get ( $fieldname)
protected

Get information stored in the recording metadata such as description, name and other info.

Parameters
string$fieldname
Return values
mixed|null

◆ metadata_set()

mod_bigbluebuttonbn\recording::metadata_set ( $fieldname,
$value )
protected

Set locally stored metadata from this instance.

Parameters
string$fieldname
mixed$value

◆ properties_definition()

static core\persistent::properties_definition ( )
staticfinalinherited

Get the properties definition of this model.

Return values
array

◆ properties_filter()

static core\persistent::properties_filter ( stdClass $record)
staticfinalinherited

For a given record, return an array containing only those properties that are defined by the persistent.

Parameters
stdClass$record
Return values
array

◆ raw_get()

core\persistent::raw_get ( $property)
finalprotectedinherited

Internal Data getter.

This is the main getter for all the properties. Developers can implement their own getters but they should be calling self::get() in order to retrieve the value. Essentially the getters defined by the developers would only ever be used as helper methods and will not be called internally at this stage. In other words, do not expect self::to_record() or self::from_record() to use them.

This is protected because it is only for raw low level access to the data fields. Note this function is named raw_get and not get_raw to avoid naming clashes with a property named raw.

Parameters
string$propertyThe property name.
Return values
mixed

◆ raw_set()

core\persistent::raw_set ( $property,
$value )
finalprotectedinherited

Data setter.

This is the main setter for all the properties. Developers can implement their own setters but they should always be calling self::set() in order to set the value. Essentially the setters defined by the developers are helper methods and will not be called internally at this stage. In other words do not expect self::to_record() or self::from_record() to use them.

This is protected because it is only for raw low level access to the data fields.

Parameters
string$propertyThe property name.
mixed$valueThe value.
Return values
$this

◆ read()

core\persistent::read ( )
finalinherited

Load the data from the DB.

Return values
static

◆ record_exists()

static core\persistent::record_exists ( $id)
staticinherited

Check if a record exists by ID.

Parameters
int$idRecord ID.
Return values
bool

◆ record_exists_select()

static core\persistent::record_exists_select ( $select,
array $params = null )
staticinherited

Check if a records exists.

Parameters
string$select
array$params
Return values
bool

◆ refresh_metadata_if_required()

mod_bigbluebuttonbn\recording::refresh_metadata_if_required ( )
protected

Refresh metadata if required.

If this is a protected recording which whose data was not fetched in the current request, then the metadata will be purged and refetched. This ensures that the url is safe for use with a protected recording.

◆ remote_meta_convert()

mod_bigbluebuttonbn\recording::remote_meta_convert ( )
protected

Convert string (metadata) to json object.

Return values
mixed|null

◆ save()

core\persistent::save ( )
finalinherited

Saves the record to the database.

If this record has an ID, then self::update() is called, otherwise self::create() is called. Before and after hooks for create() or update() will be called appropriately.

Return values
void

◆ set()

core\persistent::set ( $property,
$value )
finalinherited

Data setter.

This is the main setter for all the properties. Developers can implement their own setters (set_propertyname) and they will be called by this function. Custom setters should call internal_set() to finally set the value. Internally this is not used self::to_record() or self::from_record() because the data is not expected to be validated or changed when reading/writing raw records from the DB.

Parameters
string$propertyThe property name.
Return values
$this
Exceptions
coding_exception

◆ set_description()

mod_bigbluebuttonbn\recording::set_description ( $value)
protected

Set Description.

Parameters
string$value

◆ set_endtime()

mod_bigbluebuttonbn\recording::set_endtime ( $value)
protected

Recording endtime.

Parameters
int$value

◆ set_many()

core\persistent::set_many ( array $values)
finalinherited

Data setter for multiple properties.

Internally calls {

See also
set} on each property
Parameters
array$valuesArray of property => value elements
Return values
$this

◆ set_name()

mod_bigbluebuttonbn\recording::set_name ( $value)
protected

Set name.

Parameters
string$value

◆ set_protected()

mod_bigbluebuttonbn\recording::set_protected ( $value)
protected

Recording is protected.

Parameters
bool$value

◆ set_published()

mod_bigbluebuttonbn\recording::set_published ( $value)
protected

Recording is published.

Parameters
bool$value

◆ set_starttime()

mod_bigbluebuttonbn\recording::set_starttime ( $value)
protected

Recording starttime.

Parameters
int$value

◆ set_status()

mod_bigbluebuttonbn\recording::set_status ( $value)
protected

Update recording status.

Parameters
bool$value

◆ sync_pending_recordings_from_server()

static mod_bigbluebuttonbn\recording::sync_pending_recordings_from_server ( bool $dismissedonly = false)
static

Synchronise pending recordings from the server.

This function should be called by the check_pending_recordings scheduled task.

Parameters
bool$dismissedonlyfetch dismissed recording only

◆ to_record()

core\persistent::to_record ( )
finalinherited

Create a DB record from this class.

Note that this does not use any custom getter because the data here is intended to represent what is stored in the database.

Return values
stdClass

◆ update()

core\persistent::update ( )
finalinherited

Update the existing record in the DB.

Return values
boolTrue on success.

◆ validate()

core\persistent::validate ( )
finalinherited

Validates the data.

Developers can implement addition validation by defining a method as follows. Note that the method MUST return a lang_string() when there is an error, and true when the data is valid.

protected function validate_propertyname($value) { if ($value !== 'My expected value') { return new lang_string('invaliddata', 'error'); } return true }

It is OK to use other properties in your custom validation methods when you need to, however note they might not have been validated yet, so try not to rely on them too much.

Note that the validation methods should be protected. Validating just one field is not recommended because of the possible dependencies between one field and another,also the field ID can be used to check whether the object is being updated or created.

When validating foreign keys the persistent should only check that the associated model exists. The validation methods should not be used to check for a change in that relationship. The API method setting the attributes on the model should be responsible for that. E.g. On a course model, the method validate_categoryid will check that the category exists. However, if a course can never be moved outside of its category it would be up to the calling code to ensure that the category ID will not be altered.

Return values
array|trueReturns true when the validation passed, or an array of properties with errors.

◆ verify_protected_methods()

core\persistent::verify_protected_methods ( )
finalprotectedinherited

This function is used to verify that custom getters and setters are declared as protected.

Persistent properties should always be accessed via get('property') and set('property', 'value') which will call the custom getter or setter if it exists. We do not want to allow inconsistent access to the properties.

Member Data Documentation

◆ POSSIBLE_REMOTE_META_SOURCE

const mod_bigbluebuttonbn\recording::POSSIBLE_REMOTE_META_SOURCE
Initial value:
= [
'description' => ['meta_bbb-recording-description', 'meta_contextactivitydescription'],
'name' => ['meta_bbb-recording-name', 'meta_contextactivity', 'meetingName'],
'playbacks' => ['playbacks'],
'starttime' => ['startTime'],
'endtime' => ['endTime'],
'published' => ['published'],
'protected' => ['protected'],
'tags' => ['meta_bbb-recording-tags']
]

POSSIBLE_REMOTE_META_SOURCE match a field type and its metadataname (historical and current).


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