Reviewed:  https://reviews.mahara.org/7877
Committed: 
https://git.mahara.org/mahara/mahara/commit/4078222d49fca56c359f1640a608265380f5872a
Submitter: Robert Lyon ([email protected])
Branch:    master

commit 4078222d49fca56c359f1640a608265380f5872a
Author: Nelson Moller <[email protected]>
Date:   Mon Jul 17 15:12:05 2017 +1200

Bug 1703608: Selecting the lang for inst membership confirmation
messages

Choosing the correct language for the confirmation message sent when
a user is added to an institution that has a different language than
the site default.

behatnotneeded

Change-Id: I832a18777654dc82d506e3d3a1238a74c6a6bdd7

-- 
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 Committed

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     : [email protected]
Unsubscribe : https://launchpad.net/~mahara-contributors
More help   : https://help.launchpad.net/ListHelp

Reply via email to