Skip to content

atto_teamsmeeting: language related improvements - #3526

Open
Lai Wei (weilai-irl) wants to merge 4 commits into
wip-137579-m405from
wip-138448-m405
Open

Lai Wei (weilai-irl) wants to merge 4 commits into
wip-137579-m405from
wip-138448-m405

Conversation

@weilai-irl

Copy link
Copy Markdown
Collaborator
  • The app's redirect back to result.php is a subframe navigation from a cross-origin iframe, so the browser may not send the Moodle session cookie. On that path, config.php starts a fresh, cookie-less session and \core\session\manager::set_user($tokenuser) only carries $tokenuser's profile default language ($USER->lang) into it - current_language()'s other inputs (a session-level language menu override, a course- or activity-forced language) never make it across, because they lived only in the original session that this request has no way to see.
  • Have result_token::generate() record current_language() - resolved from the real session at the point the dialogue is opened, before any of this - in a short-lived cache entry keyed by the token value. result.php reads it back via the new result_token::validate_lang() and applies it with force_current_language(), the same technique tiny_teamsmeeting's token already uses for the equivalent bug in its own result.php.
  • result_token is built on core's user_private_key API, which has no field to carry an arbitrary payload the way tiny_teamsmeeting's self-signed token does, so the language rides alongside it in its own cache definition (db/caches.php) instead, with a matching ttl and consumed on first read.
  • meetingsapplink_desc read "This is URL of meeting app location", which was grammatically broken; reworded to "This is the URL of the Meetings app." settings was later simplified from "Teams Meeting Settings" to "Teams Meeting" to avoid the redundant "Teams Meeting > Teams Meeting Settings" admin tree path.
  • Also add lang//atto_teamsmeeting.php for every language the Microsoft Teams meetings app (msteams-app-lms-meetings) supports, mirroring what was done for tiny_teamsmeeting: ar, bg, cs, cy, da, de, es, es_mx, fi, fr, fr_ca, he, is, it, ja, ko, nb, nl, nn, pt, pt_br, ru, sv, th, tr, zh_cn, zh_tw. Each file has exact key parity with the English source, so the plugin's own UI and the app's UI are never showing two different languages.

… app-supported languages

meetingsapplink_desc read "This is URL of meeting app location", which was
grammatically broken; reworded to "This is the URL of the Meetings app."
settings was later simplified from "Teams Meeting Settings" to "Teams
Meeting" to avoid the redundant "Teams Meeting > Teams Meeting Settings"
admin tree path.

Also add lang/<code>/atto_teamsmeeting.php for every language the Microsoft
Teams meetings app (msteams-app-lms-meetings) supports, mirroring what was
done for tiny_teamsmeeting: ar, bg, cs, cy, da, de, es, es_mx, fi, fr, fr_ca,
he, is, it, ja, ko, nb, nl, nn, pt, pt_br, ru, sv, th, tr, zh_cn, zh_tw. Each
file has exact key parity with the English source, so the plugin's own UI
and the app's UI are never showing two different languages.
…ault language

The app's redirect back to result.php is a subframe navigation from a
cross-origin iframe, so the browser may not send the Moodle session
cookie. On that path, config.php starts a fresh, cookie-less session and
\core\session\manager::set_user($tokenuser) only carries $tokenuser's
profile default language ($USER->lang) into it - current_language()'s
other inputs (a session-level language menu override, a course- or
activity-forced language) never make it across, because they lived only
in the original session that this request has no way to see.

Have result_token::generate() record current_language() - resolved from
the real session at the point the dialogue is opened, before any of this
- in a short-lived cache entry keyed by the token value. result.php reads
it back via the new result_token::validate_lang() and applies it with
force_current_language(), the same technique tiny_teamsmeeting's token
already uses for the equivalent bug in its own result.php.

result_token is built on core's user_private_key API, which has no field
to carry an arbitrary payload the way tiny_teamsmeeting's self-signed
token does, so the language rides alongside it in its own cache
definition (db/caches.php) instead, with a matching ttl and consumed on
first read.
Copilot AI lite review requested due to automatic review settings September 15, 2026 16:54
@weilai-irl Lai Wei (weilai-irl) self-assigned this Sep 15, 2026
@weilai-irl Lai Wei (weilai-irl) added this to the 2026-04 milestone Sep 15, 2026
@weilai-irl
Lai Wei (weilai-irl) added this pull request to stack #3527 September 15, 2026 16:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new language-cache path should defensively reject non-alphanumeric token keys (and the new test should use a production-realistic token) to avoid cache-key exceptions on some backends.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR improves language consistency for the Atto Teams Meeting plugin when returning from the external meetings app via a cross-origin iframe redirect, and expands the plugin’s language coverage to match the Meetings app.

Changes:

  • Persist current_language() alongside the single-use result_token (via a short-lived cache) and apply it in result.php after token-based authentication.
  • Add PHPUnit coverage for result_token::validate_lang() behavior and one-time consumption.
  • Add/adjust language string files across many locales and refine English admin/help text.
File summaries
File Description
lib/editor/atto/plugins/teamsmeeting/classes/result_token.php Store the resolved language at token creation time and expose validate_lang() to read/consume it.
lib/editor/atto/plugins/teamsmeeting/db/caches.php Add an application cache definition (resultlang) to carry language values keyed by token.
lib/editor/atto/plugins/teamsmeeting/result.php Apply cached language after set_user() on token-authenticated returns.
lib/editor/atto/plugins/teamsmeeting/tests/result_token_test.php Add tests for token validation and language caching/consumption behavior.
lib/editor/atto/plugins/teamsmeeting/lang/en/atto_teamsmeeting.php Improve grammar for meetingsapplink_desc and simplify settings label.
lib/editor/atto/plugins/teamsmeeting/lang/ar/atto_teamsmeeting.php Add Arabic strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/bg/atto_teamsmeeting.php Add Bulgarian strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/cs/atto_teamsmeeting.php Add Czech strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/cy/atto_teamsmeeting.php Add Welsh strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/da/atto_teamsmeeting.php Add Danish strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/de/atto_teamsmeeting.php Add German strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/es/atto_teamsmeeting.php Add Spanish strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/es_mx/atto_teamsmeeting.php Add Spanish (Mexico) strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/fi/atto_teamsmeeting.php Add Finnish strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/fr/atto_teamsmeeting.php Add French strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/fr_ca/atto_teamsmeeting.php Add French (Canada) strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/he/atto_teamsmeeting.php Add Hebrew strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/is/atto_teamsmeeting.php Add Icelandic strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/it/atto_teamsmeeting.php Add Italian strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/ja/atto_teamsmeeting.php Add Japanese strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/ko/atto_teamsmeeting.php Add Korean strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/nb/atto_teamsmeeting.php Add Norwegian Bokmål strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/nl/atto_teamsmeeting.php Add Dutch strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/nn/atto_teamsmeeting.php Add Norwegian Nynorsk strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/pt/atto_teamsmeeting.php Add Portuguese strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/pt_br/atto_teamsmeeting.php Add Portuguese (Brazil) strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/ru/atto_teamsmeeting.php Add Russian strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/sv/atto_teamsmeeting.php Add Swedish strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/th/atto_teamsmeeting.php Add Thai strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/tr/atto_teamsmeeting.php Add Turkish strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/zh_cn/atto_teamsmeeting.php Add Simplified Chinese strings for atto_teamsmeeting.
lib/editor/atto/plugins/teamsmeeting/lang/zh_tw/atto_teamsmeeting.php Add Traditional Chinese strings for atto_teamsmeeting.
Review details
  • Files reviewed: 32/32 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/editor/atto/plugins/teamsmeeting/classes/result_token.php
Comment thread lib/editor/atto/plugins/teamsmeeting/tests/result_token_test.php
… cache

validate_lang() passed its raw $token argument straight into a cache
definition with simplekeys => true ([a-zA-Z0-9_] only) before checking
its shape, so a malformed token (e.g. containing '-') tripped the cache
layer's own key format check instead of returning ''. Guard with
ctype_alnum(), matching the PARAM_ALPHANUM filter result.php actually
reads the token through, rather than coupling the guard to
create_user_key()'s current md5-hex output format.

Also drop the unneeded MOODLE_INTERNAL check from result_token_test.php
(the file has no side effects) and swap the unknown-token test fixture
for an alphanumeric string, since 'not-a-real-token' is not
representative of what PARAM_ALPHANUM would let through in production.
…d the edit flow

token.php re-mints a single-use token for every meeting after the first dialog open, but it runs via require_login() with no course, so $PAGE->course there is always the frontpage course and current_language() can never see a course-forced language. result_token::generate() now accepts an optional language override, and the dialogue (button.js) passes through the value it already resolved correctly at page load (this._locale), when $PAGE->course was the real course.

The edit/view-existing flow has the same blind spot in result.php, and atto_teamsmeeting records carry no course or context at all, so there is no stored value to resolve it from server-side. button.js now forwards this._locale as a lang URL param instead, and result.php applies it via force_current_language() when authenticating through the real session cookie rather than the signed token.

The locale sent to the external Teams app itself was already correct (lib.php resolves it via current_language() at real page load), so no change was needed there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants