-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix(Notifications): attached documents in private followup #21225
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
base: 10.0/bugfixes
Are you sure you want to change the base?
Conversation
Seems to replace #17544 |
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.
LTM. Maybe ask for customer validation
The customer has just approved (with the latest commit) |
src/User.php
Outdated
$profile = new Profile(); | ||
$profile->getFromDB($profile_id); | ||
$profile->cleanProfile(); | ||
if ($profile->haveUserRight($user_id, $module, $right, 0)) { |
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.
Yous should check the user rights on the entity of the ITIL object. Indeed, the user may not have the right to see private items on the root entity, but have rights to view them in a sub-entity.
src/CommonITILObject.php
Outdated
if ($user === null) { | ||
$user = new User(); | ||
$user->getFromDB(Session::getLoginUserID()); | ||
} |
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.
Using the $user
object instead of the session will add, at least, 5 SQL queries more to display the ticket timeline. It should keep the checks on session when the $user
param is null.
if (
!$bypass_rights
&& (
($user === null && !Session::haveRight(ITILFollowup::$rightname, ITILFollowup::SEEPRIVATE))
|| ($user !== null && !$user->hasRight(ITILFollowup::$rightname, ITILFollowup::SEEPRIVATE))
)
) {
src/User.php
Outdated
if ($this->isNewItem()) { | ||
throw new \LogicException('Cannot check rights for a user not yet saved'); |
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.
Could you check the behaviour with an "external" user? For instance for a ticket with a requester that does not correspond to a valid GLPI user but is targetted only with an email (anonymous tickets from helpdesk).
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.
With an anonymous user, $user
is null in getAssociatedDocumentsCriteria()
, so do not call hasRight()
.
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.
Unless I miss something, $user
will be an instance of User
, but getFromDBbyEmail()
will have fail, and I think isNewItem
will return true
in this case.
$user = new User();
$user->getFromDBbyEmail($current->fields['recipient']);
$doc_crit = $item->getAssociatedDocumentsCriteria(false, $user);
Checklist before requesting a review
Please delete options that are not relevant.
Description
It checks that the recipient user has the necessary permissions to view the documents in private follow-ups before attaching them to the notification.
NB: rework of #17544
Screenshots (if appropriate):