Skip to content

FOUR-33773 | Add Out of Office Status and Delegation for Users With Edit Personal Profile Permission - #9098

Open
mcraeteisha wants to merge 12 commits into
developfrom
task/FOUR-33773
Open

mcraeteisha wants to merge 12 commits into
developfrom
task/FOUR-33773

Conversation

@mcraeteisha

@mcraeteisha mcraeteisha commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Issue

Ticket: FOUR-33773

Users with only Edit Personal Profile could set their own status to Active or Inactive. Out of Office and the replacement user (Delegation) were available only on Admin → Users → Edit User, along with Blocked, Scheduled, and Manager.

Edit Profile now offers Out of Office and a replacement picker for the signed-in user. Blocked, Scheduled, and Manager stay on the admin user editor.

Solution

package-advanced-user-manager

  • Add Out of Office to the Edit Profile status list
  • Add the Delegation picker to Edit Profile, using a profile lookup that returns id and full name for active users and excludes the current user
  • Clear delegation_user_id when the replacement user is deleted
  • Clear a stored replacement on save when that user is missing, soft-deleted, or a system user

processmaker

  • Load the profile settings add-on slots, passing the signed-in user, so the Delegation picker renders on Edit Profile
  • Send delegation_user_id with a personal-profile save, and send only the personal-profile fields for users who are not administrators and do not have Edit Users
  • Accept delegation_user_id on a self-service user update
  • Allow Active, Inactive, and Out of Office. Keep an administrator-assigned status, such as Scheduled, when the save does not change it
  • Before validation, clear a replacement the profile picker can no longer load so the rest of the save is not rejected
  • Give a task to an Out of Office user's replacement only when the replacement is Active and not deleted. This is checked when the task is assigned, so a replacement who later becomes Inactive, Out of Office, or Scheduled does not receive it. It applies to new tasks and to reassignment
  • When a reassignment finds nobody who can take the task, assign it to the Process Manager instead of saving it unassigned, and skip the reassignment notification when there is no assignee

With no usable replacement (none set, deleted, or not Active), a new task follows the existing empty-Delegation path and goes to the Process Manager, and a reassigned task also goes to the Process Manager. A self-service task stays unassigned. If the process has no Process Manager, the existing "no Process Manager" error is returned, as before. Tasks already moved are not pulled back, and in-progress tasks are not moved when a user goes Out of Office.

How To Test

Automated Tests

  • phpunit vendor/processmaker/package-advanced-user-manager/tests/Feature/PersonalProfileOutOfOfficeTest.php
  • phpunit tests/Feature/Api/UsersTest.php --filter testSelfServiceUpdate
  • phpunit tests/Feature/ProfileTest.php --filter testEditProfilePassesSignedInUserToSettingsAddons
  • phpunit tests/Model/UserTest.php --filter testOnlyAnActiveReplacementCanReceiveADelegatedTask
  • phpunit tests/Feature/Api/TaskAssignmentByVariableTest.php --filter testOutOfOfficeAssignmentUsesOnlyAnActiveReplacement
  • phpunit tests/Feature/Api/TaskAssignmentTest.php --filter testUnavailableReplacementResolvesToProcessManager

Manual Tests

  1. Sign in as a user whose only relevant permission is Edit Personal Profile.
  2. Open Edit Profile. Confirm the status list is Active, Inactive, and Out of Office.
  3. Confirm Delegation is shown and Manager, Blocked, and Scheduled are not.
  4. Set Out of Office, choose a replacement, and save. Refresh and confirm both values persisted.
  5. Set the status back to Active without changing Delegation. Confirm new tasks still come to that user, and the replacement remains saved.
  6. On Admin → Users → Edit User, confirm Active, Inactive, Blocked, Out of Office, Scheduled, Delegation, and Manager are still available.
  7. Set the user to Out of Office again. As an administrator, set the replacement to Inactive. Confirm new tasks for the Out of Office user go to the Process Manager, not the replacement.
  8. Delete the replacement user. Confirm Delegation is cleared on the other user.
  9. Set that user to Out of Office again without choosing a replacement. Confirm new tasks are not assigned to the deleted user.

ci:package-advanced-user-manager:task/FOUR-33773
ci:deploy

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker..

redeploy: 10 Nov .

This change enables self-service profile updates to set a valid delegation user and status values without exposing server-managed fields. The API now restricts editable statuses to the account owner’s allowed set, preserves current admin-assigned values when needed, clears invalid delegation references, and validates delegation ownership and non-system/non-deleted users. The profile editor also sends a filtered payload for self-service edits, and tests cover successful out-of-office delegation updates plus rejection of blocked/scheduled statuses.
@cursor

cursor Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes touch core task assignment and reassignment behavior for Out-of-Office users and delegation fallbacks, which can affect who receives workflow tasks across existing processes.

Overview
Users with Edit Personal Profile can set Out of Office and an active replacement (delegation_user_id) from Edit Profile and via the self-service PUT /users path. Self-service updates are restricted to ACTIVE, INACTIVE, and OUT_OF_OFFICE (admin-assigned statuses like Scheduled remain valid if unchanged), validate replacements as non-system ACTIVE users, and clear stale delegation when the picker can no longer load a valid user.

Task assignment and reassignment now route Out-of-Office work only to replacements who are still ACTIVE (activeDelegationUserId / acceptResolvedAssignee), including raw SQL assignment paths. When resolution yields nobody, tasks fall back to the process manager instead of staying unassigned; reassignment notifications are skipped when there is no assignee.

The profile UI sends a trimmed profilePayload for self-service saves, loads edit.settings addons with the signed-in user for the delegation picker, and UserController::update is refactored into focused helpers for self-service prep, password/email, save, and avatar handling.

Reviewed by Cursor Bugbot for commit 0e25936. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://tenant-1.ci-8cc146d8fa.engk8s.processmaker.net

@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://tenant-1.ci-8cc146d8fa.engk8s.processmaker.net

@eiresendez eiresendez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved! I'm just adding a possible edge case but not a blocker, if replacements are required to remain assignable.

Ensure assignments for out-of-office users only resolve to active, valid replacements. This adds active delegation checks and assignee validation to task assignment flows, updates the raw repository queries to ignore soft-deleted/inactive delegation targets, and covers the behavior with regression tests for variable-based task assignment and user delegation rules.

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

When an assignment resolves to a user who cannot take the task, the token now falls back to the process manager instead of leaving the task unassigned. This also clears stale user relationships before notifying reassignees and adds a feature test covering inactive, out-of-office, and empty replacement cases.

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

Comment thread ProcessMaker/Models/Process.php Resolved
@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://tenant-1.ci-8cc146d8fa.engk8s.processmaker.net

This change restricts delegation assignment validation to non-system, non-deleted, ACTIVE users and clears stale delegation_user_id values for missing, deleted, system, or inactive delegates. It also fixes assignee resolution during escalation so the resolved manager user is used consistently before accepting the final assignee.
@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-8cc146d8fa.engk8s.processmaker.net

@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-8cc146d8fa.engk8s.processmaker.net

@mcraeteisha mcraeteisha closed this Nov 6, 2026
@mcraeteisha mcraeteisha reopened this Nov 6, 2026

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3dbaf73. Configure here.


// Send a notification to the user
$notification = new TaskReassignmentNotification($this);
$this->user->notify($notification);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reassign persists original user data

Medium Severity

When reassignTo() now falls back to the Process Manager because nobody can take the task, reassign() still calls persistUserData() with the original $toUserId. Request _user then keeps the Out of Office or unavailable user while the token is assigned to the manager, so later screens, scripts, and _user-based notifications can run as the wrong person. The same method already uses the resolved user for the reassignment email.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3dbaf73. Configure here.

Extract self-service validation, password hashing, email change checks,
save, and avatar upload into helpers so the Quality Gate stops failing
on S3776.

Co-authored-by: Cursor <cursoragent@cursor.com>
$rules['meta'] = ['sometimes', 'array'];
$rules['meta.disableRecommendations'] = ['sometimes', 'boolean'];
$rules['status'] = ['required', Rule::in($this->selfServiceStatuses($user))];
$rules['delegation_user_id'] = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Agentic Security Review

Severity: MEDIUM

Description: A user with only edit-personal-profile can PUT /api/1.0/users/{self} and store status OUT_OF_OFFICE plus delegation_user_id set to any other active, non-system user. Process-variable assignment then puts that delegate into the assignee pool with no check that they are on the task's user or group list. The resulting process_request_tokens.user_id is enough for ProcessRequestTokenPolicy to allow view and complete, and for ForUserScope to show the parent request.

Impact: The previous self-service denylist kept delegation_user_id with manager_id, so only an edit-users administrator could name a backup. This change lets an ordinary profile user redirect future process-variable work — including request data and task completion — to an account the process never assigned. That is a cross-user task and request-data boundary, not a personal display preference. Fixed user, group, and user_by_id assignment do not perform this substitution, and delegateTask only writes an assignee when an external assignment process exists.

Remediation: Do not accept an unconstrained delegation_user_id on the personal-profile allowlist. Keep the column admin-managed, or before saving it require a relationship that is allowed to receive this user's work (same task assignment list, shared group, or an explicit delegate grant). Apply that same check in getNextUserFromProcessVariable and getNextUserFromProcessVariableRaw before copying the id into process_request_tokens.user_id.

@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-8cc146d8fa.engk8s.processmaker.net

@decisions-sonarqube

Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
2 New issues
2 New Maintainability Issues (required ≤ 0)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE SonarQube for IDE

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.

4 participants