** Changed in: mahara
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask 
on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1703608

Title:
  Institution addUserAsMember lang logic is flawed

Status in Mahara:
  Fix Released

Bug description:
  The logic in charge of selecting the lang for the message does not work as 
expected.
  The condition:

  if ($lang = get_account_preference($user->id, 'lang')) {
              // The user has a preset lang preference so we will use this
          }
          else if ($this->lang != 'default') {
              // The user hasn't been added yet, so we have to manually use 
this institution's lang
              $lang = $this->lang;
          }
          else {
              $lang = get_user_language($user->id);
          }

  gets always sent in english if the site default lang is french.

  To reproduce it:
  You set another language than english as default language. You an institution 
with default lang and then you add a user (his lang preference is not setting) 
into this institution. He is going to receive an english message in that case 
and also in the case that the institution language is explicitly set to the 
additional lang.

  That is corrected with the following:

  $lang = get_account_preference($user->id, 'lang');

          if ($lang == 'default') {
              // The user has not a preset lang preference so we will use the 
institution if it has one.
              $institution_lang = get_record_sql(
                "SELECT value FROM {institution_config} ic where 
ic.institution= ? and ic.field = 'lang' ",
                [$this->name],
                IGNORE_MULTIPLE
              );
              $this->lang = $institution_lang->value? $institution_lang->value: 
'default';
              if ($this->lang != 'default') {
                  // The user hasn't been added yet, so we have to manually use 
this institution's lang
                  $lang = $this->lang;
              }
              else {
                  $lang = get_config('lang')? get_config('lang'): '';
              }
          }

  We have also opened a PR in github:
  https://github.com/MaharaProject/mahara/pull/7

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1703608/+subscriptions

_______________________________________________
Mailing list: https://launchpad.net/~mahara-contributors
Post to     : mahara-contributors@lists.launchpad.net
Unsubscribe : https://launchpad.net/~mahara-contributors
More help   : https://help.launchpad.net/ListHelp

Reply via email to