-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature : targeted private saved searches #17587
base: main
Are you sure you want to change the base?
Feature : targeted private saved searches #17587
Conversation
…+ target form SavedSearch done
…-main # Conflicts: # front/savedsearch.form.php # src/CommonDBVisible.php # src/SavedSearch.php
…t visibility for users & groups accordingly
Could you add some screenshots to your PR description? |
I've edited it to add several screenshoots, showing an example and the added functionnalities. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed about it with @orthagh and we think that the is_private
flag should be removed from the database. Indeed, having both a public/private management + a entity/groups/users visibility management is redundant and can be a bit complex to handle for the end user.
At creation, if the saved search is created as public, then it a visibility on the root entity + recursive should be automatically created. If it is created as private, the lack of visibility filters should be sufficient to make it private.
It would require to add a migration to add a new visibility filter to all existing public searches.
If everything is OK from a pratical point of view, I will start working on updating the current test functions and adding a new one for the targets. |
… targeted-saved-search-main # Conflicts: # phpunit/functional/SavedSearchTest.php
Tests are updated.
|
It seems like there are still some small lint issues. For the sonar cloud report, it does not like that you are created an item using a class supplied by the browser: This has created security issues in the past as malicious users can supply some unwanted class names. |
I've added suggestions that should fix the typing issues. For the "always true" issue, this is because the condition exist twice: So when you reach the second condition, it will always be true because if the first one was false then the function would have returned a value already. I'll let you review to see which one you need to keep. |
install/migrations/update_10.0.x_to_11.0.0/group_savedsearch.php
Outdated
Show resolved
Hide resolved
install/migrations/update_10.0.x_to_11.0.0/entity_savedsearch.php
Outdated
Show resolved
Hide resolved
I added the suggested fix. I will remember those for future developments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok for me besides the right check.
Add option to choose targets for private saved searches.
Modify CommonDBVisible to make it possible to restrict the types of target available, and to choose the right used to determine the availability of user type targets.
For a saved search, a target can either be a user or a group.
User and group dropdown take into account entity of the item when loading available targets.
The class used for the user target might need to be changed (SavedSearch_User is already used so I couldn't follow the naming convention set by the other CommonDBVisible items, so I created SavedSearch_UserTarget for now).
Also the new method getVisibilityRight could be used to dynamically get the right for the itemtype associated with the saved search (to only be able to targets users with the read right on the itemtype).
Example :
![image](https://private-user-images.githubusercontent.com/155963006/351765350-cb009220-fe71-4abc-8f30-a8656a42d3af.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNzM2MDcsIm5iZiI6MTczOTM3MzMwNywicGF0aCI6Ii8xNTU5NjMwMDYvMzUxNzY1MzUwLWNiMDA5MjIwLWZlNzEtNGFiYy04ZjMwLWE4NjU2YTQyZDNhZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMlQxNTE1MDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hOTc0ZjQzZDI0YzQ4MmIzNjAyMTg2ZTQ5YjJjZWVhNWU1ZjQ5YThlYzcyYzljYTRjZTU3NjM0MDE4NDJjYjhmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.DvUx9JreI6BCxvV9-jTwhkfmey-IzKwxQ8kVcG33dpg)
![image](https://private-user-images.githubusercontent.com/155963006/351765643-74dcedbd-23d2-448a-8f3e-ca4e41f22a50.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3Lmd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d3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMlQxNTE1MDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jMDU0YmZkNDQ4ZWU0OGU3NDI5MjZiN2U2YWY4MzdhZWU4YzRjMzcyZWM3NDFhMDQyOWQwOWJhMGM5YTQyZmQxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.82GPzaVau7s_hBwetl6mx_SKWSUWxlMHrJ-HYO3S8bw)
![image](https://private-user-images.githubusercontent.com/155963006/351766353-dd3c8625-9202-4d7e-9663-d886f92f2907.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNzM2MDcsIm5iZiI6MTczOTM3MzMwNywicGF0aCI6Ii8xNTU5NjMwMDYvMzUxNzY2MzUzLWRkM2M4NjI1LTkyMDItNGQ3ZS05NjYzLWQ4ODZmOTJmMjkwNy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMlQxNTE1MDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mZDNkYTk0ZDE1Zjk5NzllYWUxNGJhNDVlMGMzNzhiYjY0NzFhNjZiNzZjMWQwNjg5Yjk3NDE4ZDE0Yjg5ZTA3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.EK7QWwM6Adc87ryuST5B8SGxAyOEdufu5I3WAeWl8k4)
![image](https://private-user-images.githubusercontent.com/155963006/351766686-af50c271-4a17-4603-b9a1-846952037bbd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNzM2MDcsIm5iZiI6MTczOTM3MzMwNywicGF0aCI6Ii8xNTU5NjMwMDYvMzUxNzY2Njg2LWFmNTBjMjcxLTRhMTctNDYwMy1iOWExLTg0Njk1MjAzN2JiZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMlQxNTE1MDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03YTE5N2Q0MTU1Mzk2MDJiYTUzYThjZTQ3ODIzMmI4NGZiNGRhZWI5ODUyZjlhOGQ2NzgyYmRhYzdjZTg3MmQyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.-enJdyyBi_cO-nLkalXOUWGenZn7tixgJ88jLQyPjfI)
Target tab for SavedSearch :
Corresponding record in DB :
Available saved searches for the itemtype for users 2 without any target set :
User 2 added as a target :
Available saved searches on the itemtype for user 2 after being added added as a target :
Type of targets available set through the static variable $types :
![image](https://private-user-images.githubusercontent.com/155963006/351767094-f3d93a4b-8cc2-4542-ac8e-095b10c23de4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNzM2MDcsIm5iZiI6MTczOTM3MzMwNywicGF0aCI6Ii8xNTU5NjMwMDYvMzUxNzY3MDk0LWYzZDkzYTRiLThjYzItNDU0Mi1hYzhlLTA5NWIxMGMyM2RlNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMlQxNTE1MDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05OGU2MmRhMWQ2NzRlMTJhZDRmZjY5Y2Y0MzA1YmQ4NjAyZWQ0M2ZmOGM1ZTEwNjkzZjNmMTdkMTlhZTkzYWM2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.v7dA5YzdpKmt08VoIsjeuGEZ7j6TijmCtOsejJ7Wr7k)
Restrictions on groups available as targets based on the item's entity (for the example entity set as 1 instead of root) :
![image](https://private-user-images.githubusercontent.com/155963006/351770872-91bb39e4-4baa-4f42-95ac-351289850fc1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNzM2MDcsIm5iZiI6MTczOTM3MzMwNywicGF0aCI6Ii8xNTU5NjMwMDYvMzUxNzcwODcyLTkxYmIzOWU0LTRiYWEtNGY0Mi05NWFjLTM1MTI4OTg1MGZjMS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMlQxNTE1MDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00M2MyNDI4NjEyNTZmOWJjOGE5M2E1NmEzNDU0ZjE1NmNlNTg3NWZkOGFhZmFlZjFlMzcyYWUxNjE4MDQ4ZDgzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.8ofBNXdNWV_k4HqzQ3sxsTXDIHCezSYuAN6sl-bv5S4)
![image](https://private-user-images.githubusercontent.com/155963006/351769519-9f2cd874-f13b-4c02-9e96-c20496d2b0e6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNzM2MDcsIm5iZiI6MTczOTM3MzMwNywicGF0aCI6Ii8xNTU5NjMwMDYvMzUxNzY5NTE5LTlmMmNkODc0LWYxM2ItNGMwMi05ZTk2LWMyMDQ5NmQyYjBlNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMlQxNTE1MDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iNjNkMTQ1ZDE2ZDJmYmM5N2ExZDFiMTliZWE3ZWU1ZDQxZjcwYWEzMjA4OTk5YzFiYzBkYTVmN2ZmNWQ5Y2UyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.ywVpFA4TQWsrrtKiqiYon2CzcnWf4NDg7bx85xMEZVw)
![image](https://private-user-images.githubusercontent.com/155963006/351770038-6627c57b-e3b4-4595-b9f0-7a52dc7ef0f8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkI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MlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMlQxNTE1MDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mOWJiNGVjOGVkOTJmODU3NWQxMTJmY2QwOWQ3NjRkM2E4ZWVlMTliMzI0YjVkNjcxNzQ2YTBiYzU5MjkyNzNlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.brlu02YXz3HiMpxwLtsUpbBlNnzjey56dTxXikbDmWg)
List of entities :
List of groups with entity restrictions :
Visibility for groups :
Subvisibility :