mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Merge branch 'MDL-68921-master' of git://github.com/vmdef/moodle
This commit is contained in:
commit
9b9ee2fac7
@ -164,6 +164,7 @@ class api {
|
||||
unset($library->major_version);
|
||||
$library->minorVersion = (int) $library->minorversion;
|
||||
unset($library->minorversion);
|
||||
$library->metadataSettings = json_decode($library->metadatasettings);
|
||||
|
||||
// If we already add this library means that it is an old version,as the previous query was sorted by version.
|
||||
if (isset($added[$library->name])) {
|
||||
|
@ -228,7 +228,7 @@ class editor_framework implements H5peditorStorage {
|
||||
if ($libraries !== null) {
|
||||
// Get details for the specified libraries.
|
||||
$librariesin = [];
|
||||
$fields = 'title, runnable';
|
||||
$fields = 'title, runnable, metadatasettings';
|
||||
|
||||
foreach ($libraries as $library) {
|
||||
$params = [
|
||||
@ -242,11 +242,12 @@ class editor_framework implements H5peditorStorage {
|
||||
if ($details) {
|
||||
$library->title = $details->title;
|
||||
$library->runnable = $details->runnable;
|
||||
$library->metadataSettings = json_decode($details->metadatasettings);
|
||||
$librariesin[] = $library;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$fields = 'id, machinename as name, title, majorversion, minorversion';
|
||||
$fields = 'id, machinename as name, title, majorversion, minorversion, metadatasettings';
|
||||
$librariesin = api::get_contenttype_libraries($fields);
|
||||
}
|
||||
|
||||
|
@ -685,6 +685,9 @@ class framework implements \H5PFrameworkInterface {
|
||||
* - dropLibraryCss(optional): list of associative arrays containing:
|
||||
* - machineName: machine name for the librarys that are to drop their css
|
||||
* - semantics(optional): Json describing the content structure for the library
|
||||
* - metadataSettings(optional): object containing:
|
||||
* - disable: 1 if metadata is disabled completely
|
||||
* - disableExtraTitleField: 1 if the title field is hidden in the form
|
||||
* @param bool $new Whether it is a new or existing library.
|
||||
*/
|
||||
public function saveLibraryData(&$librarydata, $new = true) {
|
||||
@ -722,6 +725,7 @@ class framework implements \H5PFrameworkInterface {
|
||||
'addto' => isset($librarydata['addTo']) ? json_encode($librarydata['addTo']) : null,
|
||||
'coremajor' => isset($librarydata['coreApi']['majorVersion']) ? $librarydata['coreApi']['majorVersion'] : null,
|
||||
'coreminor' => isset($librarydata['coreApi']['majorVersion']) ? $librarydata['coreApi']['minorVersion'] : null,
|
||||
'metadatasettings' => isset($librarydata['metadataSettings']) ? $librarydata['metadataSettings'] : null,
|
||||
);
|
||||
|
||||
if ($new) {
|
||||
|
@ -246,6 +246,7 @@ class generator_testcase extends \advanced_testcase {
|
||||
'addto' => '/regex11/',
|
||||
'coremajor' => null,
|
||||
'coreminor' => null,
|
||||
'metadatasettings' => null,
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $data);
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20200707" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20200804" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@ -4188,6 +4188,7 @@
|
||||
<FIELD NAME="addto" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Plugin configuration data"/>
|
||||
<FIELD NAME="coremajor" TYPE="int" LENGTH="4" NOTNULL="false" SEQUENCE="false" COMMENT="H5P core API major version required"/>
|
||||
<FIELD NAME="coreminor" TYPE="int" LENGTH="4" NOTNULL="false" SEQUENCE="false" COMMENT="H5P core API minor version required"/>
|
||||
<FIELD NAME="metadatasettings" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Library metadata settings"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
|
@ -2575,5 +2575,46 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2021052500.02);
|
||||
}
|
||||
|
||||
if ($oldversion < 2021052500.04) {
|
||||
|
||||
// Define field metadatasettings to be added to h5p_libraries.
|
||||
$table = new xmldb_table('h5p_libraries');
|
||||
$field = new xmldb_field('metadatasettings', XMLDB_TYPE_TEXT, null, null, null, null, null, 'coreminor');
|
||||
|
||||
// Conditionally launch add field metadatasettings.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Get installed library files that have no metadata settings value.
|
||||
$params = [
|
||||
'component' => 'core_h5p',
|
||||
'filearea' => 'libraries',
|
||||
'filename' => 'library.json',
|
||||
];
|
||||
$sql = "SELECT l.id, f.id as fileid
|
||||
FROM {files} f
|
||||
LEFT JOIN {h5p_libraries} l ON f.itemid = l.id
|
||||
WHERE f.component = :component
|
||||
AND f.filearea = :filearea
|
||||
AND f.filename = :filename";
|
||||
$libraries = $DB->get_records_sql($sql, $params);
|
||||
|
||||
// Update metadatasettings field when the attribute is present in the library.json file.
|
||||
$fs = get_file_storage();
|
||||
foreach ($libraries as $library) {
|
||||
$jsonfile = $fs->get_file_by_id($library->fileid);
|
||||
$jsoncontent = json_decode($jsonfile->get_content());
|
||||
if (isset($jsoncontent->metadataSettings)) {
|
||||
unset($library->fileid);
|
||||
$library->metadatasettings = json_encode($jsoncontent->metadataSettings);
|
||||
$DB->update_record('h5p_libraries', $library);
|
||||
}
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2021052500.04);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2021052500.03; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2021052500.04; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
$release = '4.0dev (Build: 20200822)'; // Human-friendly version name
|
||||
|
Loading…
x
Reference in New Issue
Block a user