Skip to content

v2.5.0

Choose a tag to compare

@tkorner tkorner released this 24 Sep 15:09
· 12 commits to main since this release

Closes the remaining gaps found when auditing SPEC-admincockpit.md against the shipped code.

New: one-click impersonate (SPEC section 5)

Search for a user on the dashboard and switch straight into their session, without going through a course participants list first.

Built as a thin wrapper around core rather than a reimplementation:

  • User search is core's own core_user/form_user_selector autocomplete, backed by the existing core_user_search_identity web service — no bespoke search endpoint, no new web service.
  • Authorisation delegates to \core\session\loginas_helper::get_context_user_can_login_as(), the same helper core's own course/loginas.php uses.

Verified in core first: \core\session\manager::loginas() performs no capability check of its own, so every guard is the caller's responsibility. On top of core's rules, one stricter rule is added per SPEC section 5: a site admin is never a valid target, because core deliberately permits admin-to-admin impersonation and a one-click dashboard shortcut is a different risk profile from core's deliberate multi-step flow. The decision lives in classes/loginas_guard.php — page-free and unit-tested. The control is hidden entirely from anyone without moodle/user:loginas, and while already impersonating someone.

New: two health signals (from the SPEC section 11 backlog)

  • Expired enrolments — still-active enrolments whose end date has passed. Drill-down links into each course's participants page.
  • Self-enrolment without key or end date — enabled self-enrolment methods missing an enrolment key, an end date, or both. Per-row flags show which weakness applies; drill-down links into the course's enrolment methods.

Both field conventions were verified against lib/enrollib.php and enrol/self/lib.php rather than assumed.

Fixed

  • Plugins overview was listed under System in SPEC section 6 but had never been added to the default navigation links. Existing installs keep their customised setting untouched.

Verification

61 PHPUnit tests green (10 new), and the whole plugin is clean under the official Moodle code checker (moodlehq/moodle-cs, 0 errors / 0 warnings). All new UI was additionally exercised end to end against a live Moodle 5.3dev instance with real fixture data — including confirming that impersonating an ordinary user really switches the session, and that targeting the site admin is refused with the session left untouched.