Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Static Public Member Functions | List of all members
core_h5p\helper Class Reference

Helper class for the H5P area. More...

Static Public Member Functions

static can_deploy_package (\stored_file $file)
 Checks if the author of the .h5p file is "trustable". More...
 
static can_update_library (\stored_file $file)
 Checks if the content-type libraries can be upgraded. More...
 
static create_fake_stored_file_from_path (string $filepath, int $userid=0, context $context=null)
 Convenience to take a fixture test file and create a stored_file. More...
 
static get_display_options (core $core, stdClass $config)
 Get the representation of display options as int. More...
 
static save_h5p (factory $factory, stored_file $file, stdClass $config, bool $onlyupdatelibs=false, bool $skipcontent=false)
 Store an H5P file. More...
 

Detailed Description

Helper class for the H5P area.

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

Member Function Documentation

◆ can_deploy_package()

static core_h5p\helper::can_deploy_package ( \stored_file  $file)
static

Checks if the author of the .h5p file is "trustable".

If the file hasn't been uploaded by a user with the required capability, the content won't be deployed.

Parameters
stored_file$fileThe .h5p file to be deployed
Return values
boolReturns true if the file can be deployed, false otherwise.

◆ can_update_library()

static core_h5p\helper::can_update_library ( \stored_file  $file)
static

Checks if the content-type libraries can be upgraded.

The H5P content-type libraries can only be upgraded if the author of the .h5p file can manage content-types or if all the content-types exist, to avoid users without the required capability to upload malicious content.

Parameters
stored_file$fileThe .h5p file to be deployed
Return values
boolReturns true if the content-type libraries can be created/updated, false otherwise.

◆ create_fake_stored_file_from_path()

static core_h5p\helper::create_fake_stored_file_from_path ( string  $filepath,
int  $userid = 0,
context  $context = null 
)
static

Convenience to take a fixture test file and create a stored_file.

Parameters
string$filepathThe filepath of the file
int$useridThe author of the file
context$contextThe context where the file will be created
Return values
stored_fileThe file created

◆ get_display_options()

static core_h5p\helper::get_display_options ( core  $core,
stdClass  $config 
)
static

Get the representation of display options as int.

Parameters
core$coreThe core_h5p\core object
stdClass$configButton options config
Return values
intThe representation of display options as int

◆ save_h5p()

static core_h5p\helper::save_h5p ( factory  $factory,
stored_file  $file,
stdClass  $config,
bool  $onlyupdatelibs = false,
bool  $skipcontent = false 
)
static

Store an H5P file.

Parameters
factory$factoryThe core_h5p\factory object
stored_file$fileMoodle file instance
stdClass$configButton options config
bool$onlyupdatelibsWhether new libraries can be installed or only the existing ones can be updated
bool$skipcontentShould the content be skipped (so only the libraries will be saved)?
Return values
int|false|nullThe H5P identifier or null if there is an error when saving or false if it's not a valid H5P package

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