Skip to content

DASH-1281 block_dash: add "Hide suspended users" condition - #130

Draft
stefanscholz wants to merge 2 commits into
devfrom
DASH-1281
Draft

DASH-1281 block_dash: add "Hide suspended users" condition#130
stefanscholz wants to merge 2 commits into
devfrom
DASH-1281

Conversation

@stefanscholz

Copy link
Copy Markdown
Member

The users data source excludes deleted users (u.deleted = 0) but still lists suspended accounts, with no way to filter them out. This adds an opt-in condition — "Hide suspended users" — that restricts results to u.suspended = 0.

Behaviour

Off by default, like every other Dash condition. abstract_data_source::before_data() removes any filter whose preferences[filters][<name>][enabled] is falsy (and removes all filters when no filters preference exists at all), so existing block instances are unaffected until someone ticks the box on the block's Conditions tab.

Block state SQL Suspended user
Fresh, no saved preferences no u.suspended clause visible
Condition explicitly disabled no u.suspended clause visible
Condition enabled u.suspended = :hide_suspended_users hidden

Notes

  • get_operation() returns OPERATION_EQUAL rather than the inherited OPERATION_IN_OR_EQUAL. The latter routes through $DB->get_in_or_equal(), which names its placeholder from a process-wide counter (param1, param2, …), making the emitted SQL depend on how many unrelated DML calls preceded it. OPERATION_EQUAL yields the stable u.suspended = :hide_suspended_users.
  • Registered outside the block_dash_has_pro() guard, so it is available (and unit-testable) without local_dash.
  • version.php bumped to refresh the lang-string cache on upgrade. No db/upgrade.php savepoint — this is not a DB upgrade.

Tests

New tests/hide_suspended_users_condition_test.php covers the generated SQL and params, that the condition is registered on the users data source but disabled by default, and that suspended users drop out of the result set only once it is enabled.

Follow-up (not in this PR)

Conditions do not propagate — each data source hard-codes its own set in build_filter_collection(). Wiring this into the local_dash addon data sources is a separate ticket. Two of them need care: calendar_events LEFT JOINs {user} on ce.userid (0 for site/course/category events) so it would need a null-safe (u.id IS NULL OR u.suspended = 0), and badges LEFT JOINs {user} pinned to $USER->id, so u is the viewer rather than the row subject and the condition would be meaningless there.

@stefanscholz
stefanscholz marked this pull request as draft July 24, 2026 10:23
@stefanscholz stefanscholz changed the title DASH-1281 block_dash: add "Hide suspended users" condition DASH-1282 block_dash: add "Hide suspended users" condition Jul 24, 2026
@stefanscholz stefanscholz changed the title DASH-1282 block_dash: add "Hide suspended users" condition DASH-1281 block_dash: add "Hide suspended users" condition Jul 24, 2026
stefanscholz and others added 2 commits August 10, 2026 10:43
The users data source excludes deleted users but still lists suspended
accounts, with no way to filter them out. Add an opt-in condition that
restricts results to u.suspended = 0.

Use OPERATION_EQUAL rather than the inherited OPERATION_IN_OR_EQUAL so the
placeholder is named after the condition instead of $DB->get_in_or_equal()'s
process-wide counter.
Pull requests are built on every branch, so every commit that lands on dev
has already been built by the pull request that introduced it. Building the
dev push as well duplicates the matrix for no extra signal. main still keeps
its push trigger because release commits land there directly.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@stefanscholz
stefanscholz changed the base branch from main to dev August 10, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant