salesagility / SuiteCRM

SuiteCRM - Open source CRM for the world
https://www.suitecrm.com
GNU Affero General Public License v3.0
4.44k stars 2.07k forks source link

Fix #10337 - In inheritance, current user groups are used instead of creator's groups when current user is not the same as creator #10338

Open SinergiaCRM opened 8 months ago

SinergiaCRM commented 8 months ago

Description

On SecurityGroups, when generating the SQL query to retrieve creator's groups, current user was always used. Instead, now if "created_by" is filled, that user is used to generate the SQL query.

Motivation and Context

With creator inheritance set, when current user and created by differ, current user groups were used.

How To Test This

Same steps that needed to check the issue:

1. Create a new entrypoint which does not require login (and uses $current_user->getSystemUser();)
2. Create a user with some security groups
3. Assign some groups to system user (different from groups assigned to the previous user)
4. Create a new record on the new entrypoint on behalf of the previous user
5. Check that the new record has the user groups instead of system user's groups

Types of changes

Final checklist