Moodle

reverting to 'do not force' in 'category' -> 'force theme' does not work

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9.2
  • Fix Version/s: 1.9.3
  • Component/s: Themes
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

If a theme is forced in a category and then the setting is reverted to 'do not force', this new setting is not saved, but the forced theme remains in place.

Activity

Hide
Helen Foster added a comment -

I can confirm this issue.

Forum discussion: http://moodle.org/mod/forum/discuss.php?d=103715

Show
Helen Foster added a comment - I can confirm this issue. Forum discussion: http://moodle.org/mod/forum/discuss.php?d=103715
Hide
Urs Hunkler added a comment -

That's an issue for another developer.

Show
Urs Hunkler added a comment - That's an issue for another developer.
Hide
Caio SBA added a comment -

Hi everyone!

I think i fixed this. It seems to be very simple.
The problem is that when you set the option to be "Do not force" an empty value is set, but in course/editcategory.php, you have this near line 64:

if (!empty($data->theme) && !empty($CFG->allowcategorythemes)) { $newcategory->theme = $data->theme; theme_setup(); }

It's where the theme option for the category is set. But when you set it to "Do not force", an empty value is sent to the script, so it will not match the "if" condition "!empty($data->theme)".
I changed this to "isset($data->theme)", which just verify if the variable has a value (empty or not).
So, with just this modification, we have:

if (isset($data->theme) && !empty($CFG->allowcategorythemes)) { $newcategory->theme = $data->theme; theme_setup(); } }

I tested hard after this modification and it works! Now you can revert to "do not force" and have this working

I attached the modified course/editcategory.php in this issue.

Hope to be useful,

Caio

Show
Caio SBA added a comment - Hi everyone! I think i fixed this. It seems to be very simple. The problem is that when you set the option to be "Do not force" an empty value is set, but in course/editcategory.php, you have this near line 64: if (!empty($data->theme) && !empty($CFG->allowcategorythemes)) { $newcategory->theme = $data->theme; theme_setup(); } It's where the theme option for the category is set. But when you set it to "Do not force", an empty value is sent to the script, so it will not match the "if" condition "!empty($data->theme)". I changed this to "isset($data->theme)", which just verify if the variable has a value (empty or not). So, with just this modification, we have: if (isset($data->theme) && !empty($CFG->allowcategorythemes)) { $newcategory->theme = $data->theme; theme_setup(); } } I tested hard after this modification and it works! Now you can revert to "do not force" and have this working I attached the modified course/editcategory.php in this issue. Hope to be useful, Caio
Hide
Caio SBA added a comment -

Fixed!

Show
Caio SBA added a comment - Fixed!
Hide
Eloy Lafuente (stronk7) added a comment -

Fixed in 19_STABLE and HEAD.

Thanks for the proposed change, Caio SBA. Was perfect! B-)

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Fixed in 19_STABLE and HEAD. Thanks for the proposed change, Caio SBA. Was perfect! B-) Ciao
Hide
Caio SBA added a comment -

Yeah! Happy to be useful
I'll try to help fixing other bugs.

Show
Caio SBA added a comment - Yeah! Happy to be useful I'll try to help fixing other bugs.
Hide
Helen Foster added a comment -

Ulrich, thanks for reporting this issue
Caio, thanks for providing a fix
Eloy, thanks for applying Caio's fix

Tested in 1.9.2+ and found to be working perfectly!

Show
Helen Foster added a comment - Ulrich, thanks for reporting this issue Caio, thanks for providing a fix Eloy, thanks for applying Caio's fix Tested in 1.9.2+ and found to be working perfectly!

Dates

  • Created:
    Updated:
    Resolved: