MDL-83985 mod_book: change name, chapter title to 1333 chars

This commit is contained in:
Luca Bösch
2025-05-16 13:49:50 +02:00
parent 5a3b6b9965
commit c00b022c29
5 changed files with 30 additions and 7 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/book/db" VERSION="20220530" COMMENT="XMLDB file for Moodle mod_book"
<XMLDB PATH="mod/book/db" VERSION="20250414" COMMENT="XMLDB file for Moodle mod_book"
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="false" SEQUENCE="false"/>
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="numbering" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
@@ -29,7 +29,7 @@
<FIELD NAME="bookid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="pagenum" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="subchapter" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="title" TYPE="char" LENGTH="1333" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="content" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="contentformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="hidden" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
+23
View File
@@ -28,6 +28,9 @@
* @return bool always true
*/
function xmldb_book_upgrade($oldversion) {
global $DB;
$dbman = $DB->get_manager();
// Automatically generated Moodle v4.2.0 release upgrade line.
// Put any upgrade step following this.
@@ -43,5 +46,25 @@ function xmldb_book_upgrade($oldversion) {
// Automatically generated Moodle v5.0.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2025041401) {
// Changing precision of field name on table book to (1333).
$table = new xmldb_table('book');
$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);
// Changing precision of field title on table book_chapters to (1333).
$table = new xmldb_table('book_chapters');
$field = new xmldb_field('title', XMLDB_TYPE_CHAR, '1333', null, XMLDB_NOTNULL, null, null, 'subchapter');
// Launch change of precision for field title.
$dbman->change_field_precision($table, $field);
// Book savepoint reached.
upgrade_mod_savepoint(true, 2025041401, 'book');
}
return true;
}
+2 -2
View File
@@ -56,10 +56,10 @@ class book_chapter_edit_form extends moodleform {
}
$mform->addElement('text', 'title', get_string('chaptertitle', 'mod_book'),
['size' => '30', 'maxlength' => '255']);
['size' => '30', 'maxlength' => '1333']);
$mform->setType('title', PARAM_RAW);
$mform->addRule('title', null, 'required', null, 'client');
$mform->addRule('title', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$mform->addRule('title', get_string('maximumchars', '', 1333), 'maxlength', 1333, 'client');
$mform->addElement('advcheckbox', 'subchapter', get_string('subchapter', 'mod_book'), $disabledmsg);
+1 -1
View File
@@ -45,7 +45,7 @@ class mod_book_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$mform->addRule('name', get_string('maximumchars', '', 1333), 'maxlength', 1333, 'client');
$this->standard_intro_elements(get_string('moduleintro'));
// Appearance.
+1 -1
View File
@@ -25,6 +25,6 @@
defined('MOODLE_INTERNAL') || die;
$plugin->component = 'mod_book'; // Full name of the plugin (used for diagnostics)
$plugin->version = 2025041400; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2025041401; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2025040800; // Requires this Moodle version.
$plugin->cron = 0; // Period for cron to check this module (secs)