MDL-83985 mod_label: change name to 1333 chars

This commit is contained in:
Luca Bösch
2025-05-16 13:53:16 +02:00
parent 4626347d77
commit a4ac449be8
4 changed files with 20 additions and 5 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/label/db" VERSION="20120122" COMMENT="XMLDB file for Moodle mod/label"
<XMLDB PATH="mod/label/db" VERSION="20250514" COMMENT="XMLDB file for Moodle mod/label"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
@@ -8,7 +8,7 @@
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="name" TYPE="char" LENGTH="1333" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="intro" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
+15
View File
@@ -43,6 +43,8 @@
// before any action that may take longer time to finish.
function xmldb_label_upgrade($oldversion) {
global $DB;
$dbman = $DB->get_manager();
// Automatically generated Moodle v4.2.0 release upgrade line.
// Put any upgrade step following this.
@@ -66,5 +68,18 @@ function xmldb_label_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2025051300, 'label');
}
if ($oldversion < 2025051301) {
// Changing precision of field name on table label to (1333).
$table = new xmldb_table('label');
$field = new xmldb_field('name', XMLDB_TYPE_CHAR, '1333', null, XMLDB_NOTNULL, null, null, 'course');
// Launch change of precision for field name.
$dbman->change_field_precision($table, $field);
// Label savepoint reached.
upgrade_mod_savepoint(true, 2025051301, 'label');
}
return true;
}
+2 -2
View File
@@ -39,13 +39,13 @@ class mod_label_mod_form extends moodleform_mod {
$mform->addElement('header', 'generalhdr', get_string('general'));
// Add element for name.
$mform->addElement('text', 'name', get_string('labelname', 'label'), ['size' => '64', 'maxlength' => 255]);
$mform->addElement('text', 'name', get_string('labelname', 'label'), ['size' => '64', 'maxlength' => 1333]);
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
} else {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$mform->addRule('name', get_string('maximumchars', '', 1333), 'maxlength', 1333, 'client');
$mform->addHelpButton('name', 'labelname', 'label');
$this->standard_intro_elements(get_string('labeltext', 'label'));
+1 -1
View File
@@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2025051300; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2025051301; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2025040800; // Requires this Moodle version.
$plugin->component = 'mod_label'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 0;