mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
Merge branch 'MDL-79256' of https://github.com/paulholden/moodle
This commit is contained in:
commit
ba86cb79aa
@ -477,7 +477,7 @@ class backup_course_structure_step extends backup_structure_step {
|
||||
|
||||
$customfields = new backup_nested_element('customfields');
|
||||
$customfield = new backup_nested_element('customfield', array('id'), array(
|
||||
'shortname', 'type', 'value', 'valueformat'
|
||||
'shortname', 'type', 'value', 'valueformat', 'valuetrust',
|
||||
));
|
||||
|
||||
$courseformatoptions = new backup_nested_element('courseformatoptions');
|
||||
@ -1361,7 +1361,7 @@ class backup_groups_structure_step extends backup_structure_step {
|
||||
|
||||
$groupcustomfields = new backup_nested_element('groupcustomfields');
|
||||
$groupcustomfield = new backup_nested_element('groupcustomfield', ['id'], [
|
||||
'shortname', 'type', 'value', 'valueformat', 'groupid']);
|
||||
'shortname', 'type', 'value', 'valueformat', 'valuetrust', 'groupid']);
|
||||
|
||||
$members = new backup_nested_element('group_members');
|
||||
|
||||
@ -1376,7 +1376,7 @@ class backup_groups_structure_step extends backup_structure_step {
|
||||
|
||||
$groupingcustomfields = new backup_nested_element('groupingcustomfields');
|
||||
$groupingcustomfield = new backup_nested_element('groupingcustomfield', ['id'], [
|
||||
'shortname', 'type', 'value', 'valueformat', 'groupingid']);
|
||||
'shortname', 'type', 'value', 'valueformat', 'valuetrust', 'groupingid']);
|
||||
|
||||
$groupinggroups = new backup_nested_element('grouping_groups');
|
||||
|
||||
|
@ -231,6 +231,7 @@ class course_handler extends \core_customfield\handler {
|
||||
$d->set($d->datafield(), $data['value']);
|
||||
$d->set('value', $data['value']);
|
||||
$d->set('valueformat', $data['valueformat']);
|
||||
$d->set('valuetrust', !empty($data['valuetrust']));
|
||||
$d->set('contextid', $context->id);
|
||||
$d->save();
|
||||
}
|
||||
|
@ -96,6 +96,12 @@ class data extends persistent {
|
||||
'default' => FORMAT_MOODLE,
|
||||
'optional' => true
|
||||
],
|
||||
'valuetrust' => [
|
||||
'type' => PARAM_BOOL,
|
||||
'null' => NULL_NOT_ALLOWED,
|
||||
'default' => false,
|
||||
'optional' => true,
|
||||
],
|
||||
'contextid' => [
|
||||
'type' => PARAM_INT,
|
||||
'optional' => false,
|
||||
|
@ -354,7 +354,10 @@ abstract class data_controller {
|
||||
} else if ($this->datafield() === 'decvalue') {
|
||||
return (float)$value;
|
||||
} else if ($this->datafield() === 'value') {
|
||||
return format_text($value, $this->get('valueformat'), ['context' => $this->get_context()]);
|
||||
return format_text($value, $this->get('valueformat'), [
|
||||
'context' => $this->get_context(),
|
||||
'trusted' => $this->get('valuetrust'),
|
||||
]);
|
||||
} else {
|
||||
return format_string($value, true, ['context' => $this->get_context()]);
|
||||
}
|
||||
|
@ -512,7 +512,9 @@ abstract class handler {
|
||||
'shortname' => $d->get_field()->get('shortname'),
|
||||
'type' => $d->get_field()->get('type'),
|
||||
'value' => $d->get_value(),
|
||||
'valueformat' => $d->get('valueformat')];
|
||||
'valueformat' => $d->get('valueformat'),
|
||||
'valuetrust' => $d->get('valuetrust'),
|
||||
];
|
||||
}
|
||||
}
|
||||
return $finalfields;
|
||||
|
@ -72,6 +72,7 @@ class provider implements
|
||||
'charvalue' => 'privacy:metadata:customfield_data:charvalue',
|
||||
'value' => 'privacy:metadata:customfield_data:value',
|
||||
'valueformat' => 'privacy:metadata:customfield_data:valueformat',
|
||||
'valuetrust' => 'privacy:metadata:customfield_data:valuetrust',
|
||||
'timecreated' => 'privacy:metadata:customfield_data:timecreated',
|
||||
'timemodified' => 'privacy:metadata:customfield_data:timemodified',
|
||||
'contextid' => 'privacy:metadata:customfield_data:contextid',
|
||||
@ -485,7 +486,10 @@ class provider implements
|
||||
$record->timecreated = \core_privacy\local\request\transform::datetime($record->timecreated);
|
||||
$record->timemodified = \core_privacy\local\request\transform::datetime($record->timemodified);
|
||||
unset($record->contextid);
|
||||
$record->value = format_text($record->value, $record->valueformat, ['context' => $context]);
|
||||
$record->value = format_text($record->value, $record->valueformat, [
|
||||
'context' => $context,
|
||||
'trusted' => $record->valuetrust,
|
||||
]);
|
||||
writer::with_context($context)->export_data($subcontext, $record);
|
||||
}
|
||||
}
|
||||
|
@ -93,17 +93,21 @@ class data_controller extends \core_customfield\data_controller {
|
||||
if (!$this->get('id')) {
|
||||
$this->data->set('value', '');
|
||||
$this->data->set('valueformat', FORMAT_MOODLE);
|
||||
$this->data->set('valuetrust', false);
|
||||
$this->save();
|
||||
}
|
||||
|
||||
if (array_key_exists('text', $fromform)) {
|
||||
$textoptions = $this->value_editor_options();
|
||||
$context = $textoptions['context'];
|
||||
|
||||
$data = (object) ['field_editor' => $fromform];
|
||||
$data = file_postupdate_standard_editor($data, 'field', $textoptions, $textoptions['context'],
|
||||
$data = file_postupdate_standard_editor($data, 'field', $textoptions, $context,
|
||||
'customfield_textarea', 'value', $this->get('id'));
|
||||
|
||||
$this->data->set('value', $data->field);
|
||||
$this->data->set('valueformat', $data->fieldformat);
|
||||
|
||||
$this->data->set('valuetrust', trusttext_trusted($context));
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
@ -118,18 +122,19 @@ class data_controller extends \core_customfield\data_controller {
|
||||
*/
|
||||
public function instance_form_before_set_data(\stdClass $instance) {
|
||||
$textoptions = $this->value_editor_options();
|
||||
$context = $textoptions['context'];
|
||||
if ($this->get('id')) {
|
||||
$text = $this->get('value');
|
||||
$format = $this->get('valueformat');
|
||||
$temp = (object)['field' => $text, 'fieldformat' => $format];
|
||||
file_prepare_standard_editor($temp, 'field', $textoptions, $textoptions['context'], 'customfield_textarea',
|
||||
$temp = (object) ['field' => $text, 'fieldformat' => $format, 'fieldtrust' => trusttext_trusted($context)];
|
||||
file_prepare_standard_editor($temp, 'field', $textoptions, $context, 'customfield_textarea',
|
||||
'value', $this->get('id'));
|
||||
$value = $temp->field_editor;
|
||||
} else {
|
||||
$text = $this->get_field()->get_configdata_property('defaultvalue');
|
||||
$format = $this->get_field()->get_configdata_property('defaultvalueformat');
|
||||
$temp = (object)['field' => $text, 'fieldformat' => $format];
|
||||
file_prepare_standard_editor($temp, 'field', $textoptions, $textoptions['context'], 'customfield_textarea',
|
||||
$temp = (object) ['field' => $text, 'fieldformat' => $format, 'fieldtrust' => trusttext_trusted($context)];
|
||||
file_prepare_standard_editor($temp, 'field', $textoptions, $context, 'customfield_textarea',
|
||||
'defaultvalue', $this->get_field()->get('id'));
|
||||
$value = $temp->field_editor;
|
||||
}
|
||||
@ -194,14 +199,20 @@ class data_controller extends \core_customfield\data_controller {
|
||||
$context = $this->get_context();
|
||||
$processed = file_rewrite_pluginfile_urls($value, 'pluginfile.php',
|
||||
$context->id, 'customfield_textarea', 'value', $dataid);
|
||||
$value = format_text($processed, $this->get('valueformat'), ['context' => $context]);
|
||||
$value = format_text($processed, $this->get('valueformat'), [
|
||||
'context' => $context,
|
||||
'trusted' => $this->get('valuetrust'),
|
||||
]);
|
||||
} else {
|
||||
$fieldid = $this->get_field()->get('id');
|
||||
$configcontext = $this->get_field()->get_handler()->get_configuration_context();
|
||||
$field = $this->get_field();
|
||||
|
||||
$context = $field->get_handler()->get_configuration_context();
|
||||
$processed = file_rewrite_pluginfile_urls($value, 'pluginfile.php',
|
||||
$configcontext->id, 'customfield_textarea', 'defaultvalue', $fieldid);
|
||||
$valueformat = $this->get_field()->get_configdata_property('defaultvalueformat');
|
||||
$value = format_text($processed, $valueformat, ['context' => $configcontext]);
|
||||
$context->id, 'customfield_textarea', 'defaultvalue', $field->get('id'));
|
||||
$value = format_text($processed, $field->get_configdata_property('defaultvalueformat'), [
|
||||
'context' => $context,
|
||||
'trusted' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
@ -110,10 +110,17 @@ class field_controller extends \core_customfield\field_controller {
|
||||
public function value_editor_options(\context $context = null) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
if (!$context) {
|
||||
$context = $this->get_handler()->get_configuration_context();
|
||||
}
|
||||
return ['maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'context' => $context];
|
||||
|
||||
return [
|
||||
'context' => $context,
|
||||
'trusttext' => true,
|
||||
'maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'maxbytes' => $CFG->maxbytes,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,6 +149,7 @@ class group_handler extends handler {
|
||||
'type' => $data->get_field()->get('type'),
|
||||
'value' => $data->get_value(),
|
||||
'valueformat' => $data->get('valueformat'),
|
||||
'valuetrust' => $data->get('valuetrust'),
|
||||
'groupid' => $data->get('instanceid'),
|
||||
];
|
||||
}
|
||||
@ -175,6 +176,7 @@ class group_handler extends handler {
|
||||
$d->set($d->datafield(), $data['value']);
|
||||
$d->set('value', $data['value']);
|
||||
$d->set('valueformat', $data['valueformat']);
|
||||
$d->set('valuetrust', !empty($data['valuetrust']));
|
||||
$d->set('contextid', $context->id);
|
||||
$d->save();
|
||||
}
|
||||
|
@ -148,6 +148,7 @@ class grouping_handler extends handler {
|
||||
'type' => $data->get_field()->get('type'),
|
||||
'value' => $data->get_value(),
|
||||
'valueformat' => $data->get('valueformat'),
|
||||
'valuetrust' => $data->get('valuetrust'),
|
||||
'groupingid' => $data->get('instanceid'),
|
||||
];
|
||||
}
|
||||
@ -176,6 +177,7 @@ class grouping_handler extends handler {
|
||||
$d->set($d->datafield(), $data['value']);
|
||||
$d->set('value', $data['value']);
|
||||
$d->set('valueformat', $data['valueformat']);
|
||||
$d->set('valuetrust', !empty($data['valuetrust']));
|
||||
$d->set('contextid', $context->id);
|
||||
$d->save();
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ $string['privacy:metadata:customfield_data:timecreated'] = 'Time when data was c
|
||||
$string['privacy:metadata:customfield_data:timemodified'] = 'Time when data was last modified';
|
||||
$string['privacy:metadata:customfield_data:value'] = 'Data value, when it is a text';
|
||||
$string['privacy:metadata:customfield_data:valueformat'] = 'The format of the value, when it is a text';
|
||||
$string['privacy:metadata:customfield_data:valuetrust'] = 'The trust flag of the value, when it is text';
|
||||
$string['privacy:metadata:customfieldpluginsummary'] = 'Fields for various components';
|
||||
$string['privacy:metadata:filepurpose'] = 'File attached to the custom field data';
|
||||
$string['shortname'] = 'Short name';
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20240110" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20240123" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@ -4332,6 +4332,7 @@
|
||||
<FIELD NAME="charvalue" TYPE="char" LENGTH="1333" NOTNULL="false" SEQUENCE="false"/>
|
||||
<FIELD NAME="value" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
|
||||
<FIELD NAME="valueformat" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
||||
<FIELD NAME="valuetrust" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
||||
<FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
|
||||
|
@ -964,5 +964,20 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2024010400.01);
|
||||
}
|
||||
|
||||
if ($oldversion < 2024012300.00) {
|
||||
|
||||
// Define field valuetrust to be added to customfield_data.
|
||||
$table = new xmldb_table('customfield_data');
|
||||
$field = new xmldb_field('valuetrust', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'valueformat');
|
||||
|
||||
// Conditionally launch add field valuetrust.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2024012300.00);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -41,12 +41,13 @@ class backup_qbank_customfields_plugin extends \backup_qbank_plugin {
|
||||
$plugin->add_child($pluginwrapper);
|
||||
|
||||
$customfields = new backup_nested_element('customfields');
|
||||
$customfield = new backup_nested_element('customfield', ['id'], ['shortname', 'type', 'value', 'valueformat']);
|
||||
$customfield = new backup_nested_element('customfield', ['id'],
|
||||
['shortname', 'type', 'value', 'valueformat', 'valuetrust']);
|
||||
|
||||
$pluginwrapper->add_child($customfields);
|
||||
$customfields->add_child($customfield);
|
||||
|
||||
$customfield->set_source_sql("SELECT cfd.id, cff.shortname, cff.type, cfd.value, cfd.valueformat
|
||||
$customfield->set_source_sql("SELECT cfd.id, cff.shortname, cff.type, cfd.value, cfd.valueformat, cfd.valuetrust
|
||||
FROM {customfield_data} cfd
|
||||
JOIN {customfield_field} cff ON cff.id = cfd.fieldid
|
||||
JOIN {customfield_category} cfc ON cfc.id = cff.categoryid
|
||||
|
@ -318,6 +318,7 @@ class question_handler extends \core_customfield\handler {
|
||||
$d->set($d->datafield(), $data['value']);
|
||||
$d->set('value', $data['value']);
|
||||
$d->set('valueformat', $data['valueformat']);
|
||||
$d->set('valuetrust', !empty($data['valuetrust']));
|
||||
$d->set('contextid', $data['fieldcontextid']);
|
||||
$d->save();
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ class custom_fields {
|
||||
$selectfields = "{$customdatatablealias}.id, {$customdatatablealias}.contextid";
|
||||
if ($datafield === 'value') {
|
||||
// We will take the format into account when displaying the individual values.
|
||||
$selectfields .= ", {$customdatatablealias}.valueformat";
|
||||
$selectfields .= ", {$customdatatablealias}.valueformat, {$customdatatablealias}.valuetrust";
|
||||
}
|
||||
|
||||
$columns[] = (new column(
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2024011900.01; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2024012300.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
$release = '4.4dev (Build: 20240119)'; // Human-friendly version name
|
||||
|
Loading…
x
Reference in New Issue
Block a user