Skip to content

List current logged-in HoO user as editable row in cms_users#817

Open
pylipp wants to merge 4 commits intomasterfrom
fix-hoo-user-editing-themselves
Open

List current logged-in HoO user as editable row in cms_users#817
pylipp wants to merge 4 commits intomasterfrom
fix-hoo-user-editing-themselves

Conversation

@pylipp
Copy link
Contributor

@pylipp pylipp commented Feb 17, 2026

https://trello.com/c/9dyeV5VR

  • make user visible (non-gray) in list (only for HoO users)
  • enable user editing themselves (no 403 error when clicking row), hence also their valid-dates
  • prevent 403 error when trying to edit (click) other HoO users
  • prevent downgrading usergroup if user is the only HoO user (display alert):
2026-02-17-160425_1019x398_scrot

⚠️ for testing, you'll have to comment the email-validation block cms_users_edit.php (lines 39-44)

@pylipp pylipp requested a review from HaGuesto February 17, 2026 10:39
@pylipp pylipp force-pushed the fix-hoo-user-editing-themselves branch 2 times, most recently from 8b05848 to a3b5b2f Compare February 17, 2026 15:22
@pylipp pylipp requested a review from Copilot February 17, 2026 15:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the CMS user listing/editing flow to better support “Head of Operations” (HoO) users, specifically allowing HoO users to see and edit themselves while preventing accidental edit attempts on peer HoO accounts.

Changes:

  • Add preventedit flags to user list queries so rows can be made non-clickable when editing would be forbidden.
  • Adjust active users query logic to include the current HoO user as visible/clickable while keeping other HoO users non-clickable.
  • Update cms_users_edit.php access logic to allow self-edit for HoO and add a guard to prevent downgrading the last HoO user.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
include/cms_users.php Makes current HoO user visible/clickable in list; marks other same/upper-level rows as non-editable via preventedit.
include/cms_users_edit.php Allows HoO self-edit, adds “last HoO cannot downgrade self” protection, and refines usergroup options filtering.
include/cms_users_expired.php Adds preventedit field to list queries for consistent non-clickable behavior.
include/cms_users_deactivated.php Adds preventedit field to list queries for consistent non-clickable behavior.

Comment on lines +141 to 147
if (!$_SESSION['user']['is_admin']
&& $data
&& $data['id'] != $_SESSION['user']['id']
&& ($data['is_admin']
|| $_SESSION['organisation']['id'] != $requesteduser['organisation_id']
|| $_SESSION['usergroup']['userlevel'] <= $requesteduser['userlevel'])) {
throw new Exception('You do not have access to this user!', 403);
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

This access check now guards on $data, but $data['cms_usergroups_id'] is still dereferenced earlier when building $requesteduser. If an invalid/non-existent id is requested, db_row() returns false and the earlier dereference will raise a PHP warning before this guard runs. Consider handling the “user not found” case immediately after loading $data (before using $data[...]).

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

- make user visible (non-gray)
- only for HoO users
- enable user editing themselves (no 403 error when clicking row)
… god

Previously, when logged in as a HoO (same userlevel as Boxtribute God)
and in organisation 1 (same organisation_id as Boxtribute God),
it was possible to select "Boxtribute God" when editing a lower-level user.
@pylipp pylipp force-pushed the fix-hoo-user-editing-themselves branch from a3b5b2f to 4b5c71a Compare February 17, 2026 16:00
@pylipp pylipp force-pushed the fix-hoo-user-editing-themselves branch from 4b5c71a to dcf960c Compare February 17, 2026 16:44
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.

1 participant