From eea7932f14d6212d0aaa9810ec17725294b400d6 Mon Sep 17 00:00:00 2001 From: Alexander Bias Date: Sat, 4 Jan 2025 09:26:54 +0100 Subject: [PATCH] Reduce the table field name length for the recently added flavour settings as they were too long for legacy Moodle versions --- classes/form/flavour_edit_form.php | 14 +++--- db/install.xml | 16 +++---- db/upgrade.php | 48 +++++++++---------- lib.php | 4 +- ..._boost_union_flavourssettings_look.feature | 10 ++-- 5 files changed, 46 insertions(+), 46 deletions(-) diff --git a/classes/form/flavour_edit_form.php b/classes/form/flavour_edit_form.php index 00def216c6b..e515ef758a2 100644 --- a/classes/form/flavour_edit_form.php +++ b/classes/form/flavour_edit_form.php @@ -189,13 +189,13 @@ public function definition() { THEME_BOOST_UNION_SETTING_IMAGEPOSITION_RIGHT_BOTTOM, ]; $backgroundimagepositionselect = $mform->addElement( 'select', - 'look_backgroundimageposition', + 'look_backgroundimagepos', get_string('flavoursbackgroundimageposition', 'theme_boost_union'), $backgroundimagepositionoptions, ); - $mform->setType('look_backgroundimageposition', PARAM_TEXT); + $mform->setType('look_backgroundimagepos', PARAM_TEXT); $backgroundimagepositionselect->setSelected([THEME_BOOST_UNION_SETTING_SELECT_NOCHANGE]); - $mform->addHelpButton('look_backgroundimageposition', 'flavoursbackgroundimageposition', 'theme_boost_union'); + $mform->addHelpButton('look_backgroundimagepos', 'flavoursbackgroundimageposition', 'theme_boost_union'); // Add brand colors heading. $context = new \stdClass(); @@ -289,13 +289,13 @@ public function definition() { $this->check_slasharguments_warning($mform); $mform->addElement( 'theme_boost_union_colorpicker', - 'look_activityiconcolor'.$purpose, + 'look_aicol'.$purpose, get_string('flavoursactivityiconcolor'.$purpose, 'theme_boost_union'), ['id' => 'colourpicker-activityiconcolor'.$purpose]); - $mform->setType('look_activityiconcolor'.$purpose, PARAM_TEXT); - $mform->addRule('look_activityiconcolor'.$purpose, get_string('validateerror', 'admin'), + $mform->setType('look_aicol'.$purpose, PARAM_TEXT); + $mform->addRule('look_aicol'.$purpose, get_string('validateerror', 'admin'), 'theme_boost_union_colorpicker_rule'); - $mform->addHelpButton('look_activityiconcolor'.$purpose, 'flavoursactivityiconcolor'.$purpose, 'theme_boost_union'); + $mform->addHelpButton('look_aicol'.$purpose, 'flavoursactivityiconcolor'.$purpose, 'theme_boost_union'); } // Add navbar heading. diff --git a/db/install.xml b/db/install.xml index 4eecc040196..9b704270823 100644 --- a/db/install.xml +++ b/db/install.xml @@ -20,7 +20,7 @@ - + @@ -28,13 +28,13 @@ - - - - - - - + + + + + + + diff --git a/db/upgrade.php b/db/upgrade.php index 6a0ee5989a3..0d99165cc66 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -400,67 +400,67 @@ function xmldb_theme_boost_union_upgrade($oldversion) { // Define table theme_boost_union_flavours to be altered. $table = new xmldb_table('theme_boost_union_flavours'); - // Define field look_backgroundimageposition to be added to theme_boost_union_flavours. - $field = new xmldb_field('look_backgroundimageposition', XMLDB_TYPE_CHAR, '32', null, null, null, null, + // Define field look_backgroundimagepos to be added to theme_boost_union_flavours. + $field = new xmldb_field('look_backgroundimagepos', XMLDB_TYPE_CHAR, '32', null, null, null, null, 'look_backgroundimage'); - // Conditionally launch add field look_backgroundimageposition. + // Conditionally launch add field look_backgroundimagepos. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - // Define field look_activityiconcoloradministration to be added to theme_boost_union_flavours. - $field = new xmldb_field('look_activityiconcoloradministration', XMLDB_TYPE_CHAR, '32', null, null, null, null); + // Define field look_aicoladministration to be added to theme_boost_union_flavours. + $field = new xmldb_field('look_aicoladministration', XMLDB_TYPE_CHAR, '32', null, null, null, null); - // Conditionally launch add field look_activityiconcoloradministration. + // Conditionally launch add field look_aicoladministration. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - // Define field look_activityiconcolorasessment to be added to theme_boost_union_flavours. - $field = new xmldb_field('look_activityiconcolorasessment', XMLDB_TYPE_CHAR, '32', null, null, null, null); + // Define field look_aicolassessment to be added to theme_boost_union_flavours. + $field = new xmldb_field('look_aicolassessment', XMLDB_TYPE_CHAR, '32', null, null, null, null); - // Conditionally launch add field look_activityiconcolorasessment. + // Conditionally launch add field look_aicolassessment. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - // Define field look_activityiconcolorcollaboration to be added to theme_boost_union_flavours. - $field = new xmldb_field('look_activityiconcolorcollaboration', XMLDB_TYPE_CHAR, '32', null, null, null, null); + // Define field look_aicolcollaboration to be added to theme_boost_union_flavours. + $field = new xmldb_field('look_aicolcollaboration', XMLDB_TYPE_CHAR, '32', null, null, null, null); - // Conditionally launch add field look_activityiconcolorcollaboration. + // Conditionally launch add field look_aicolcollaboration. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - // Define field look_activityiconcolorcommunication to be added to theme_boost_union_flavours. - $field = new xmldb_field('look_activityiconcolorcommunication', XMLDB_TYPE_CHAR, '32', null, null, null, null); + // Define field look_aicolcommunication to be added to theme_boost_union_flavours. + $field = new xmldb_field('look_aicolcommunication', XMLDB_TYPE_CHAR, '32', null, null, null, null); - // Conditionally launch add field look_activityiconcolorcommunication. + // Conditionally launch add field look_aicolcommunication. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - // Define field look_activityiconcolorcontent to be added to theme_boost_union_flavours. - $field = new xmldb_field('look_activityiconcolorcontent', XMLDB_TYPE_CHAR, '32', null, null, null, null); + // Define field look_aicolcontent to be added to theme_boost_union_flavours. + $field = new xmldb_field('look_aicolcontent', XMLDB_TYPE_CHAR, '32', null, null, null, null); - // Conditionally launch add field look_activityiconcolorcontent. + // Conditionally launch add field look_aicolcontent. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - // Define field look_activityiconcolorinteractivecontent to be added to theme_boost_union_flavours. - $field = new xmldb_field('look_activityiconcolorinteractivecontent', XMLDB_TYPE_CHAR, '32', null, null, null, null); + // Define field look_aicolinteractivecontent to be added to theme_boost_union_flavours. + $field = new xmldb_field('look_aicolinteractivecontent', XMLDB_TYPE_CHAR, '32', null, null, null, null); - // Conditionally launch add field look_activityiconcolorinteractivecontent. + // Conditionally launch add field look_aicolinteractivecontent. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - // Define field look_activityiconcolorinterface to be added to theme_boost_union_flavours. - $field = new xmldb_field('look_activityiconcolorinterface', XMLDB_TYPE_CHAR, '32', null, null, null, null); + // Define field look_aicolinterface to be added to theme_boost_union_flavours. + $field = new xmldb_field('look_aicolinterface', XMLDB_TYPE_CHAR, '32', null, null, null, null); - // Conditionally launch add field look_activityiconcolorinterface. + // Conditionally launch add field look_aicolinterface. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } diff --git a/lib.php b/lib.php index 22e3a48e5e5..4490d2bf23a 100644 --- a/lib.php +++ b/lib.php @@ -322,7 +322,7 @@ function theme_boost_union_get_pre_scss($theme) { // If any flavour applies to this page. if ($flavourid != null) { // Get the activity icon color value for the given flavour id. - $flavourvalue = theme_boost_union_get_flavour_config_item_for_flavourid($flavourid, 'look_activityiconcolor'.$purpose); + $flavourvalue = theme_boost_union_get_flavour_config_item_for_flavourid($flavourid, 'look_aicol'.$purpose); // If a flavour value is set. if ($flavourvalue != null && !empty($flavourvalue)) { // Override the global config value with the flavour value. @@ -494,7 +494,7 @@ function theme_boost_union_get_extra_scss($theme) { } // And if a background image position is set in the flavour. $backgroundimageposition = theme_boost_union_get_flavour_config_item_for_flavourid($flavourid, - 'look_backgroundimageposition'); + 'look_backgroundimagepos'); if ($backgroundimageposition != null && $backgroundimageposition != THEME_BOOST_UNION_SETTING_SELECT_NOCHANGE) { // Set the background position in the SCSS code, adhering the fact that we must not overwrite the login page // background image position again. diff --git a/tests/behat/theme_boost_union_flavourssettings_look.feature b/tests/behat/theme_boost_union_flavourssettings_look.feature index 959452970b1..b7d10420373 100644 --- a/tests/behat/theme_boost_union_flavourssettings_look.feature +++ b/tests/behat/theme_boost_union_flavourssettings_look.feature @@ -204,7 +204,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi And I expand all fieldsets And I set the field "Title" to "My shiny new flavour" And I upload "theme/boost_union/tests/fixtures/login_bg1.png" file to "Background image" filemanager - And I set the field "look_backgroundimageposition" to "" + And I set the field "look_backgroundimagepos" to "" And I select "Yes" from the "Apply to course categories" singleselect And I click on ".form-autocomplete-downarrow" "css_element" in the "#fitem_id_applytocategories_ids" "css_element" And I click on "Cat 1" item in the autocomplete list @@ -231,7 +231,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi And I expand all fieldsets And I set the field "Title" to "My shiny new flavour" And I upload "theme/boost_union/tests/fixtures/login_bg1.png" file to "Background image" filemanager - And I set the field "look_backgroundimageposition" to "" + And I set the field "look_backgroundimagepos" to "" And I select "Yes" from the "Apply to course categories" singleselect And I click on ".form-autocomplete-downarrow" "css_element" in the "#fitem_id_applytocategories_ids" "css_element" And I click on "Cat 1" item in the autocomplete list @@ -259,7 +259,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi And I expand all fieldsets And I set the field "Title" to "My shiny new flavour" And I upload "theme/boost_union/tests/fixtures/login_bg1.png" file to "Background image" filemanager - And I set the field "look_backgroundimageposition" to "No change" + And I set the field "look_backgroundimagepos" to "No change" And I select "Yes" from the "Apply to course categories" singleselect And I click on ".form-autocomplete-downarrow" "css_element" in the "#fitem_id_applytocategories_ids" "css_element" And I click on "Cat 1" item in the autocomplete list @@ -444,7 +444,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi And I should see "Create flavour" in the "#page-header h1" "css_element" And I expand all fieldsets And I set the field "Title" to "My shiny new flavour" - And I set the field "look_activityiconcolor" to "" + And I set the field "look_aicol" to "" And I select "Yes" from the "Apply to course categories" singleselect And I click on ".form-autocomplete-downarrow" "css_element" in the "#fitem_id_applytocategories_ids" "css_element" And I click on "Cat 1" item in the autocomplete list @@ -480,7 +480,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi And I should see "Create flavour" in the "#page-header h1" "css_element" And I expand all fieldsets And I set the field "Title" to "My shiny new flavour" - And I set the field "look_activityiconcolor" to "" + And I set the field "look_aicol" to "" And I select "Yes" from the "Apply to course categories" singleselect And I click on ".form-autocomplete-downarrow" "css_element" in the "#fitem_id_applytocategories_ids" "css_element" And I click on "Cat 1" item in the autocomplete list