Moodle
  1. Moodle
  2. MDL-6926

Force language does not override Profile settings in Forum display settings

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.1, 1.6.2, 1.6.3, 1.7, 1.8
    • Fix Version/s: 1.7.7, 1.8.8, 1.9.4
    • Component/s: Forum, Language
    • Labels:
      None
    • Affected Branches:
      MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE

      Description

      Force language parameter in Course Admin settings does not override user's personal Profile settings in Forum display settings.
      Example:
      User's Personal profile Preferred language = French
      Course settings: Force language = English
      When user views a forum in that course, all the elements in the interface are in English except the drop-down box of forum discussions display settings, which remain in the user's preferred language, i.e. French. See attached screen shot.

      Joseph

        Gliffy Diagrams

        1. MDL-6926_ab_sq.diff
          6 kB
          Anthony Borrow
        2. MDL-6926_ab.diff
          2 kB
          Anthony Borrow
        3. MDL-6926-18.patch
          4 kB
          Dongsheng Cai
        4. MDL-6926-19.patch
          4 kB
          Dongsheng Cai
        1. screenshot-1.jpg
          60 kB

          Activity

          Hide
          Yu Zhang added a comment -

          Hi,

          I think the problem is that the string definition is loaded before the course, should be fixed now, thanks.

          Show
          Yu Zhang added a comment - Hi, I think the problem is that the string definition is loaded before the course, should be fixed now, thanks.
          Hide
          Ralf Hilgenstock added a comment -

          The problem came back when require_once("lib.php"); was moved back to the top of discuss.php

          http://cvs.moodle.org/moodle/mod/forum/discuss.php?r1=1.85&r2=1.84

          Show
          Ralf Hilgenstock added a comment - The problem came back when require_once("lib.php"); was moved back to the top of discuss.php http://cvs.moodle.org/moodle/mod/forum/discuss.php?r1=1.85&r2=1.84
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Assigning to Dongsheng... can you take a look to this?

          Show
          Eloy Lafuente (stronk7) added a comment - Assigning to Dongsheng... can you take a look to this?
          Hide
          Dongsheng Cai added a comment -

          This patch is against moodle 1.8.

          Also fix the other strings in post page and forum frontpage.

          Show
          Dongsheng Cai added a comment - This patch is against moodle 1.8. Also fix the other strings in post page and forum frontpage.
          Hide
          Dongsheng Cai added a comment -

          Patch against 1.9

          Show
          Dongsheng Cai added a comment - Patch against 1.9
          Hide
          Dongsheng Cai added a comment -

          Fixed, please review

          Show
          Dongsheng Cai added a comment - Fixed, please review
          Hide
          Tim Hunt added a comment -

          Good fix. Thanks.

          Show
          Tim Hunt added a comment - Good fix. Thanks.
          Hide
          Anthony Borrow added a comment -

          Dongsheng - I am going to re-open this to address what I think may be a regression. When clicking on the forum name in the navigation bar, I receive the following PHP Notice:

          Notice: Undefined variable: strforum in /home/arborrow/Moodle/code/18stable/mod/forum/view.php on line 48)

          Looks like we are trying to use it before we define it. It looks like the logic is a little tricky and I think we need an additional if statement. I'm attaching a patch to show you want I'm thinking but I did not test this thoroughly. I simply wanted to show you the change in logic of getting the $cm first, then requiring login, assigning the string values, and then setting the buttontext (unless there is no $cm). Since the require_login requires the $cm we have to set buttontext afterwards.

          Peace - Anthony

          Show
          Anthony Borrow added a comment - Dongsheng - I am going to re-open this to address what I think may be a regression. When clicking on the forum name in the navigation bar, I receive the following PHP Notice: Notice: Undefined variable: strforum in /home/arborrow/Moodle/code/18stable/mod/forum/view.php on line 48) Looks like we are trying to use it before we define it. It looks like the logic is a little tricky and I think we need an additional if statement. I'm attaching a patch to show you want I'm thinking but I did not test this thoroughly. I simply wanted to show you the change in logic of getting the $cm first, then requiring login, assigning the string values, and then setting the buttontext (unless there is no $cm). Since the require_login requires the $cm we have to set buttontext afterwards. Peace - Anthony
          Hide
          Anthony Borrow added a comment -

          For 18STABLE we now have a PHP notice with the code as it is. Please re-check the logic.

          Show
          Anthony Borrow added a comment - For 18STABLE we now have a PHP notice with the code as it is. Please re-check the logic.
          Hide
          Anthony Borrow added a comment -

          Here is the revised logic that I think accomplishes what we are aiming for. Peace - Anthony

          Show
          Anthony Borrow added a comment - Here is the revised logic that I think accomplishes what we are aiming for. Peace - Anthony
          Hide
          Anthony Borrow added a comment -

          Here is a second version that also replaces all the get_string statements that were using double quotes with single quotes which I believe is preferred for memory usage. I don't believe the get_string function requires any of the escaped characters so I cannot think of a time when double quotes would be used with get_string except perhaps to pass it a $a with escaped characters. Feel free to ignore this as one of my OCD moments. Peace - Anthony

          Show
          Anthony Borrow added a comment - Here is a second version that also replaces all the get_string statements that were using double quotes with single quotes which I believe is preferred for memory usage. I don't believe the get_string function requires any of the escaped characters so I cannot think of a time when double quotes would be used with get_string except perhaps to pass it a $a with escaped characters. Feel free to ignore this as one of my OCD moments. Peace - Anthony
          Hide
          Anthony Borrow added a comment -

          I verified this is not an issue for 1.9 because the buttontext is not set for when there might not be a $cm. I'm not sure why would couldn't or didn't just give an error when there was no $cm in 1.8 as it is done in 1.9. This would seem simplify the code as we could do:

          if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id))

          { error("Course Module missing"); }


          // move require_course_login here to use forced language for course
          // fix for MDL-6926
          require_course_login($course, true, $cm);
          $strforums = get_string("modulenameplural", "forum");
          $strforum = get_string("modulename", "forum");
          $buttontext = update_module_button($cm->id, $course->id, $strforum);

          as we do in 1.9. Peace - Anthony

          Show
          Anthony Borrow added a comment - I verified this is not an issue for 1.9 because the buttontext is not set for when there might not be a $cm. I'm not sure why would couldn't or didn't just give an error when there was no $cm in 1.8 as it is done in 1.9. This would seem simplify the code as we could do: if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { error("Course Module missing"); } // move require_course_login here to use forced language for course // fix for MDL-6926 require_course_login($course, true, $cm); $strforums = get_string("modulenameplural", "forum"); $strforum = get_string("modulename", "forum"); $buttontext = update_module_button($cm->id, $course->id, $strforum); as we do in 1.9. Peace - Anthony
          Hide
          Dongsheng Cai added a comment -

          Thanks, Anthony, commited your patch to moodle 1.8

          Show
          Dongsheng Cai added a comment - Thanks, Anthony, commited your patch to moodle 1.8
          Hide
          Dongsheng Cai added a comment -

          Fixed PHP warning, please review, thanks

          Show
          Dongsheng Cai added a comment - Fixed PHP warning, please review, thanks

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: