Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Public Member Functions | |
afterExportCreated ($content, $filename) | |
Will trigger after the export file is created. | |
alterLibrarySemantics (&$semantics, $machineName, $majorVersion, $minorVersion) | |
Makes it possible to alter the semantics, adding custom fields, etc. | |
clearFilteredParameters ($library_ids) | |
Will clear filtered params for all the content that uses the specified libraries. | |
copyLibraryUsage ($contentId, $copyFromId, $contentMainId=NULL) | |
Give an H5P the same library dependencies as a given H5P. | |
deleteCachedAssets ($library_id) | |
Locate hash keys for given library and delete them. | |
deleteContentData ($contentId) | |
Deletes content data. | |
deleteLibrary ($library) | |
Delete a library from database and file system. | |
deleteLibraryDependencies ($libraryId) | |
Delete all dependencies belonging to given library. | |
deleteLibraryUsage ($contentId) | |
Delete what libraries a content item is using. | |
fetchExternalData ($url, $data=NULL, $blocking=TRUE, $stream=NULL, $fullData=FALSE, $headers=array(), $files=array(), $method='POST') | |
Fetches a file from a remote server using HTTP GET. | |
getAdminUrl () | |
Returns the URL to the library admin page. | |
getContentHubMetadataCache ($lang='en') | |
Get content hub metadata cache from db. | |
getContentHubMetadataChecked ($lang='en') | |
Get time of last content hub metadata check. | |
getLibraryConfig ($libraries=NULL) | |
Load config for libraries. | |
getLibraryContentCount () | |
Get the amount of content items associated to a library return int. | |
getLibraryFileUrl ($libraryFolderName, $fileName) | |
Get URL to file in the specific library. | |
getLibraryId ($machineName, $majorVersion=NULL, $minorVersion=NULL) | |
Get id to an existing library. | |
getLibraryStats ($type) | |
Generates statistics from the event log per library. | |
getLibraryUsage ($libraryId, $skipContent=FALSE) | |
Get number of content/nodes using a library, and the number of dependencies to other libraries. | |
getMessages ($type) | |
Return messages. | |
getNumAuthors () | |
Aggregate the current number of H5P authors. | |
getNumContent ($libraryId, $skip=NULL) | |
Get number of contents using library as main library. | |
getNumNotFiltered () | |
Get number of contents that has to get their content dependencies rebuilt and parameters re-filtered. | |
getOption ($name, $default=NULL) | |
Get stored setting. | |
getPlatformInfo () | |
Returns info for the current platform. | |
getUploadedH5pFolderPath () | |
Get the Path to the last uploaded h5p. | |
getUploadedH5pPath () | |
Get the path to the last uploaded h5p file. | |
getWhitelist ($isLibrary, $defaultContentWhitelist, $defaultLibraryWhitelist) | |
Get file extension whitelist. | |
hasPermission ($permission, $id=NULL) | |
Check if user has permissions to an action. | |
insertContent ($content, $contentMainId=NULL) | |
Insert new content. | |
isContentSlugAvailable ($slug) | |
Determines if content slug is used. | |
isInDevMode () | |
Is H5P in development mode? | |
isPatchedLibrary ($library) | |
Is the library a patched version of an existing library? | |
libraryHasUpgrade ($library) | |
Checks if the given library has a higher version. | |
loadAddons () | |
Load addon libraries. | |
loadContent ($id) | |
Load content. | |
loadContentDependencies ($id, $type=NULL) | |
Load dependencies for the given content of the given type. | |
loadLibraries () | |
Get a list of the current installed libraries. | |
loadLibrary ($machineName, $majorVersion, $minorVersion) | |
Loads a library. | |
loadLibrarySemantics ($machineName, $majorVersion, $minorVersion) | |
Loads library semantics. | |
lockDependencyStorage () | |
Start an atomic operation against the dependency storage. | |
mayUpdateLibraries () | |
Is the current user allowed to update libraries? | |
replaceContentHubMetadataCache ($metadata, $lang) | |
Replace content hub metadata cache. | |
replaceContentTypeCache ($contentTypeCache) | |
Replaces existing content type cache with the one passed in. | |
resetContentUserData ($contentId) | |
Resets marked user data for the given content. | |
saveCachedAssets ($key, $libraries) | |
Stores hash keys for cached assets, aggregated JavaScripts and stylesheets, and connects it to libraries so that we know which cache file to delete when a library is updated. | |
saveLibraryData (&$libraryData, $new=TRUE) | |
Store data about a library. | |
saveLibraryDependencies ($libraryId, $dependencies, $dependency_type) | |
Save what libraries a library is depending on. | |
saveLibraryUsage ($contentId, $librariesInUse) | |
Saves what libraries the content uses. | |
setContentHubMetadataChecked ($time, $lang='en') | |
Set time of last content hub metadata check. | |
setErrorMessage ($message, $code=NULL) | |
Show the user an error message. | |
setInfoMessage ($message) | |
Show the user an information message. | |
setLibraryTutorialUrl ($machineName, $tutorialUrl) | |
Set the tutorial URL for a library. | |
setOption ($name, $value) | |
Stores the given setting. | |
t ($message, $replacements=array()) | |
Translation function. | |
unlockDependencyStorage () | |
Stops an atomic operation against the dependency storage. | |
updateContent ($content, $contentMainId=NULL) | |
Update old content. | |
updateContentFields ($id, $fields) | |
This will update selected fields on the given content. | |
Moodle\H5PFrameworkInterface::afterExportCreated | ( | $content, | |
$filename ) |
Will trigger after the export file is created.
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::alterLibrarySemantics | ( | & | $semantics, |
$machineName, | |||
$majorVersion, | |||
$minorVersion ) |
Makes it possible to alter the semantics, adding custom fields, etc.
array | $semantics | Associative array representing the semantics |
string | $machineName | The library's machine name |
int | $majorVersion | The library's major version |
int | $minorVersion | The library's minor version |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::clearFilteredParameters | ( | $library_ids | ) |
Will clear filtered params for all the content that uses the specified libraries.
This means that the content dependencies will have to be rebuilt, and the parameters re-filtered.
array | $library_ids |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::copyLibraryUsage | ( | $contentId, | |
$copyFromId, | |||
$contentMainId = NULL ) |
Give an H5P the same library dependencies as a given H5P.
int | $contentId | Id identifying the content |
int | $copyFromId | Id identifying the content to be copied |
int | $contentMainId | Main id for the content, typically used in frameworks That supports versions. (In this case the content id will typically be the version id, and the contentMainId will be the frameworks content id |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::deleteCachedAssets | ( | $library_id | ) |
Locate hash keys for given library and delete them.
Used when cache file are deleted.
int | $library_id | Library identifier |
array | List of hash keys removed |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::deleteContentData | ( | $contentId | ) |
Deletes content data.
int | $contentId | Id identifying the content |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::deleteLibrary | ( | $library | ) |
Delete a library from database and file system.
stdClass | $library | Library object with id, name, major version and minor version. |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::deleteLibraryDependencies | ( | $libraryId | ) |
Delete all dependencies belonging to given library.
int | $libraryId | Library identifier |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::deleteLibraryUsage | ( | $contentId | ) |
Delete what libraries a content item is using.
int | $contentId | Content Id of the content we'll be deleting library usage for |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::fetchExternalData | ( | $url, | |
$data = NULL, | |||
$blocking = TRUE, | |||
$stream = NULL, | |||
$fullData = FALSE, | |||
$headers = array(), | |||
$files = array(), | |||
$method = 'POST' ) |
Fetches a file from a remote server using HTTP GET.
string | $url | Where you want to get or send data. |
array | $data | Data to post to the URL. |
bool | $blocking | Set to 'FALSE' to instantly time out (fire and forget). |
string | $stream | Path to where the file should be saved. |
bool | $fullData | Return additional response data such as headers and potentially other data |
array | $headers | Headers to send |
array | $files | Files to send |
string | $method |
string|array | The content (response body), or an array with data. NULL if something went wrong |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getAdminUrl | ( | ) |
Returns the URL to the library admin page.
string | URL to admin page |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getContentHubMetadataCache | ( | $lang = 'en' | ) |
Get content hub metadata cache from db.
string | $lang | Language code in ISO 639-1 |
JsonSerializable | Json string |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getContentHubMetadataChecked | ( | $lang = 'en' | ) |
Get time of last content hub metadata check.
string | $lang | Language code iin ISO 639-1 format |
string|null | Time in RFC7231 format |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getLibraryConfig | ( | $libraries = NULL | ) |
Load config for libraries.
array | $libraries |
array |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getLibraryContentCount | ( | ) |
Get the amount of content items associated to a library return int.
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getLibraryFileUrl | ( | $libraryFolderName, | |
$fileName ) |
Get URL to file in the specific library.
string | $libraryFolderName | |
string | $fileName |
string | URL to file |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getLibraryId | ( | $machineName, | |
$majorVersion = NULL, | |||
$minorVersion = NULL ) |
Get id to an existing library.
If version number is not specified, the newest version will be returned.
string | $machineName | The librarys machine name |
int | $majorVersion | Optional major version number for library |
int | $minorVersion | Optional minor version number for library |
int | The id of the specified library or FALSE |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getLibraryStats | ( | $type | ) |
Generates statistics from the event log per library.
string | $type | Type of event to generate stats for |
array | Number values indexed by library name and version |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getLibraryUsage | ( | $libraryId, | |
$skipContent = FALSE ) |
Get number of content/nodes using a library, and the number of dependencies to other libraries.
int | $libraryId | Library identifier |
boolean | $skipContent | Flag to indicate if content usage should be skipped |
array | Associative array containing:
|
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getMessages | ( | $type | ) |
Return messages.
string | $type | 'info' or 'error' |
string[] |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getNumAuthors | ( | ) |
Moodle\H5PFrameworkInterface::getNumContent | ( | $libraryId, | |
$skip = NULL ) |
Get number of contents using library as main library.
int | $libraryId | |
array | $skip |
int |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getNumNotFiltered | ( | ) |
Get number of contents that has to get their content dependencies rebuilt and parameters re-filtered.
int |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getOption | ( | $name, | |
$default = NULL ) |
Get stored setting.
string | $name | Identifier for the setting |
string | $default | Optional default value if settings is not set |
mixed | Whatever has been stored as the setting |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getPlatformInfo | ( | ) |
Returns info for the current platform.
array | An associative array containing:
|
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::getUploadedH5pFolderPath | ( | ) |
Get the Path to the last uploaded h5p.
string | Path to the folder where the last uploaded h5p for this session is located. |
Moodle\H5PFrameworkInterface::getUploadedH5pPath | ( | ) |
Get the path to the last uploaded h5p file.
string | Path to the last uploaded h5p |
Moodle\H5PFrameworkInterface::getWhitelist | ( | $isLibrary, | |
$defaultContentWhitelist, | |||
$defaultLibraryWhitelist ) |
Get file extension whitelist.
The default extension list is part of h5p, but admins should be allowed to modify it
boolean | $isLibrary | TRUE if this is the whitelist for a library. FALSE if it is the whitelist for the content folder we are getting |
string | $defaultContentWhitelist | A string of file extensions separated by whitespace |
string | $defaultLibraryWhitelist | A string of file extensions separated by whitespace |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::hasPermission | ( | $permission, | |
$id = NULL ) |
Check if user has permissions to an action.
@method hasPermission
[H5PPermission] | $permission Permission type, ref H5PPermission |
[int] | $id Id need by platform to determine permission |
boolean |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::insertContent | ( | $content, | |
$contentMainId = NULL ) |
Insert new content.
array | $content | An associative array containing:
|
int | $contentMainId | Main id for the content if this is a system that supports versions |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::isContentSlugAvailable | ( | $slug | ) |
Determines if content slug is used.
string | $slug |
boolean |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::isInDevMode | ( | ) |
Is H5P in development mode?
boolean | TRUE if H5P development mode is active FALSE otherwise |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::isPatchedLibrary | ( | $library | ) |
Is the library a patched version of an existing library?
object | $library | An associative array containing:
|
boolean | TRUE if the library is a patched version of an existing library FALSE otherwise |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::libraryHasUpgrade | ( | $library | ) |
Checks if the given library has a higher version.
array | $library |
boolean |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::loadAddons | ( | ) |
Moodle\H5PFrameworkInterface::loadContent | ( | $id | ) |
Load content.
int | $id | Content identifier |
array | Associative array containing:
|
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::loadContentDependencies | ( | $id, | |
$type = NULL ) |
Load dependencies for the given content of the given type.
int | $id | Content identifier |
int | $type | Dependency types. Allowed values:
|
array | List of associative arrays containing:
|
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::loadLibraries | ( | ) |
Get a list of the current installed libraries.
array | Associative array containing one entry per machine name. For each machineName there is a list of libraries(with different versions) |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::loadLibrary | ( | $machineName, | |
$majorVersion, | |||
$minorVersion ) |
Loads a library.
string | $machineName | The library's machine name |
int | $majorVersion | The library's major version |
int | $minorVersion | The library's minor version |
array|FALSE | FALSE if the library does not exist. Otherwise an associative array containing:
|
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::loadLibrarySemantics | ( | $machineName, | |
$majorVersion, | |||
$minorVersion ) |
Loads library semantics.
string | $machineName | Machine name for the library |
int | $majorVersion | The library's major version |
int | $minorVersion | The library's minor version |
string | The library's semantics as json |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::lockDependencyStorage | ( | ) |
Start an atomic operation against the dependency storage.
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::mayUpdateLibraries | ( | ) |
Is the current user allowed to update libraries?
boolean | TRUE if the user is allowed to update libraries FALSE if the user is not allowed to update libraries |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::replaceContentHubMetadataCache | ( | $metadata, | |
$lang ) |
Replace content hub metadata cache.
JsonSerializable | $metadata | Metadata as received from content hub |
string | $lang | Language in ISO 639-1 |
mixed |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::replaceContentTypeCache | ( | $contentTypeCache | ) |
Replaces existing content type cache with the one passed in.
object | $contentTypeCache | Json with an array called 'libraries' containing the new content type cache that should replace the old one. |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::resetContentUserData | ( | $contentId | ) |
Resets marked user data for the given content.
int | $contentId |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::saveCachedAssets | ( | $key, | |
$libraries ) |
Stores hash keys for cached assets, aggregated JavaScripts and stylesheets, and connects it to libraries so that we know which cache file to delete when a library is updated.
string | $key | Hash key for the given libraries |
array | $libraries | List of dependencies(libraries) used to create the key |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::saveLibraryData | ( | & | $libraryData, |
$new = TRUE ) |
Store data about a library.
Also fills in the libraryId in the libraryData object if the object is new
object | $libraryData | Associative array containing:
|
bool | $new |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::saveLibraryDependencies | ( | $libraryId, | |
$dependencies, | |||
$dependency_type ) |
Save what libraries a library is depending on.
int | $libraryId | Library Id for the library we're saving dependencies for |
array | $dependencies | List of dependencies as associative arrays containing:
|
string | $dependency_type | What type of dependency this is, the following values are allowed:
|
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::saveLibraryUsage | ( | $contentId, | |
$librariesInUse ) |
Saves what libraries the content uses.
int | $contentId | Id identifying the content |
array | $librariesInUse | List of libraries the content uses. Libraries consist of associative arrays with:
|
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::setContentHubMetadataChecked | ( | $time, | |
$lang = 'en' ) |
Set time of last content hub metadata check.
int | null | $time | Time in RFC7231 format |
string | $lang | Language code iin ISO 639-1 format |
bool | True if successful |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::setErrorMessage | ( | $message, | |
$code = NULL ) |
Show the user an error message.
string | $message | The error message |
string | $code | An optional code |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::setInfoMessage | ( | $message | ) |
Show the user an information message.
string | $message | The error message |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::setLibraryTutorialUrl | ( | $machineName, | |
$tutorialUrl ) |
Set the tutorial URL for a library.
All versions of the library is set
string | $machineName | |
string | $tutorialUrl |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::setOption | ( | $name, | |
$value ) |
Stores the given setting.
For example when did we last check h5p.org for updates to our libraries.
string | $name | Identifier for the setting |
mixed | $value | Data Whatever we want to store as the setting |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::t | ( | $message, | |
$replacements = array() ) |
Translation function.
string | $message | The english string to be translated. |
array | $replacements | An associative array of replacements to make after translation. Incidences of any key in this array are replaced with the corresponding value. Based on the first character of the key, the value is escaped and/or themed:
|
string | Translated string Translated string |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::unlockDependencyStorage | ( | ) |
Stops an atomic operation against the dependency storage.
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::updateContent | ( | $content, | |
$contentMainId = NULL ) |
Update old content.
array | $content | An associative array containing:
|
int | $contentMainId | Main id for the content if this is a system that supports versions |
Implemented in core_h5p\framework.
Moodle\H5PFrameworkInterface::updateContentFields | ( | $id, | |
$fields ) |
This will update selected fields on the given content.
int | $id | Content identifier |
array | $fields | Content fields, e.g. filtered or slug. |
Implemented in core_h5p\framework.