Skip to content

Commit

Permalink
Reduce the table field name length for the recently added flavour set…
Browse files Browse the repository at this point in the history
…tings as they were too long for legacy Moodle versions
  • Loading branch information
abias committed Jan 4, 2025
1 parent 166fd4d commit 347c245
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 46 deletions.
14 changes: 7 additions & 7 deletions classes/form/flavour_edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -290,13 +290,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.
Expand Down
16 changes: 8 additions & 8 deletions db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@
<FIELD NAME="look_logocompact" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_favicon" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_backgroundimage" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_backgroundimageposition" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_backgroundimagepos" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_rawscss" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_rawscsspre" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_brandcolor" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_bootstrapcolorsuccess" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_bootstrapcolorinfo" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_bootstrapcolorwarning" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_bootstrapcolordanger" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_activityiconcoloradministration" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_activityiconcolorassessment" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_activityiconcolorcollaboration" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_activityiconcolorcommunication" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_activityiconcolorcontent" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_activityiconcolorinteractivecontent" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_activityiconcolorinterface" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_aicoladministration" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_aicolassessment" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_aicolcollaboration" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_aicolcommunication" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_aicolcontent" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_aicolinteractivecontent" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_aicolinterface" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="look_navbarcolor" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false"/>
</FIELDS>
<KEYS>
Expand Down
48 changes: 24 additions & 24 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,67 +410,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);
}
Expand Down
4 changes: 2 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ function theme_boost_union_get_pre_scss($theme) {
if ($flavourid != null) {
// Get color setting from flavour.
$activityiconcolorflavour = theme_boost_union_get_flavour_config_item_for_flavourid($flavourid,
'look_activityiconcolor'.$purpose);
'look_aicol'.$purpose);

// If a flavour color is set.
if (!empty($activityiconcolorflavour)) {
Expand Down Expand Up @@ -487,7 +487,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.
Expand Down
10 changes: 5 additions & 5 deletions tests/behat/theme_boost_union_flavourssettings_look.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<position>"
And I set the field "look_backgroundimagepos" to "<position>"
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
Expand All @@ -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 "<position>"
And I set the field "look_backgroundimagepos" to "<position>"
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<purposename>" to "<colorhex>"
And I set the field "look_aicol<purposename>" to "<colorhex>"
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
Expand Down Expand Up @@ -484,7 +484,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<purposename>" to "<colorhex>"
And I set the field "look_aicol<purposename>" to "<colorhex>"
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
Expand Down

0 comments on commit 347c245

Please sign in to comment.