Commit bf501442 authored by Nelson Moller's avatar Nelson Moller Committed by Robert Lyon
Browse files

Bug #1705162 Send institution invitations in correct language.

A new method is added to treat the institution lang when an
invitation is sent to the user.

behatnotneeded

Change-Id: I0da8d8341f0dc15f13db9f80dc6f560ca924df3c
parent 4078222d
......@@ -1137,22 +1137,41 @@ class ActivityTypeInstitutionmessage extends ActivityType {
}
}
private function get_language($user) {
$userlang = get_account_preference($user->id, 'lang');
if ($userlang === 'default') {
if (!isset($this->institution->language) || $this->institution->language === '' || $this->institution->language === 'default') {
return get_config('lang');
}
else {
return $this->institution->language;
}
}
else {
return $userlang;
}
}
public function get_subject($user) {
$lang = $this->get_language($user);
if ($this->messagetype == 'request') {
$userstring = $this->fullname . ' (' . $this->username . ')';
return get_string_from_language($user->lang, 'institutionrequestsubject', 'activity', $userstring,
$this->institution->displayname);
} else if ($this->messagetype == 'invite') {
return get_string_from_language($user->lang, 'institutioninvitesubject', 'activity',
$this->institution->displayname);
return get_string_from_language($lang, 'institutionrequestsubject', 'activity', $userstring,
$this->institution->displayname);
}
else if ($this->messagetype == 'invite') {
return get_string_from_language($lang, 'institutioninvitesubject', 'activity',
$this->institution->displayname);
}
}
public function get_message($user) {
$lang = $this->get_language($user);
if ($this->messagetype == 'request') {
return $this->get_subject($user) .' '. get_string_from_language($user->lang, 'institutionrequestmessage', 'activity', $this->url);
} else if ($this->messagetype == 'invite') {
return $this->get_subject($user) .' '. get_string_from_language($user->lang, 'institutioninvitemessage', 'activity', $this->url);
return $this->get_subject($user) .' '. get_string_from_language($lang, 'institutionrequestmessage', 'activity', $this->url);
}
else if ($this->messagetype == 'invite') {
return $this->get_subject($user) .' '. get_string_from_language($lang, 'institutioninvitemessage', 'activity', $this->url);
}
}
......
......@@ -422,7 +422,7 @@ class Institution {
'messagetype' => 'request',
'username' => $user->username,
'fullname' => $user->firstname . ' ' . $user->lastname,
'institution' => (object)array('name' => $this->name, 'displayname' => $this->displayname),
'institution' => (object)array('name' => $this->name, 'displayname' => $this->displayname, 'language' => $this->lang),
);
db_begin();
if (!get_config('usersallowedmultipleinstitutions')) {
......@@ -508,7 +508,7 @@ class Institution {
activity_occurred('institutionmessage', (object) array(
'messagetype' => 'invite',
'users' => array($userid),
'institution' => (object)array('name' => $this->name, 'displayname' => $this->displayname),
'institution' => (object)array('name' => $this->name, 'displayname' => $this->displayname, 'language' => $this->lang),
));
handle_event('updateuser', $userid);
db_commit();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment