Skip to content

Commit e4d4c24

Browse files
committed
fix(formanswer): more permissive READ access to formanswers
if a user is no longer a validator of a formanswer but was choosen as a validator, READ ccess should be still granted Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent cacd832 commit e4d4c24

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

inc/formanswer.class.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,17 @@ public function canViewItem() {
7676
return true;
7777
}
7878

79-
if ($_SESSION['glpiID'] == $this->getField('requester_id')) {
79+
if ($_SESSION['glpiID'] == $this->fields['requester_id']) {
80+
return true;
81+
}
82+
83+
if ($_SESSION['glpiID'] == $this->fields['users_id_validator']) {
84+
return true;
85+
}
86+
87+
$groupUser = new Group_User();
88+
$groups = $groupUser->getUserGroups($_SESSION['glpiID']);
89+
if (in_array($this->fields['users_id_validator'], $groups)) {
8090
return true;
8191
}
8292

@@ -105,12 +115,8 @@ public function canViewItem() {
105115
return true;
106116
}
107117
} else {
108-
$groupUser = new Group_User();
109-
$groups = $groupUser->getUserGroups($_SESSION['glpiID']);
110-
foreach ($groups as $group) {
111-
if ($row['items_id'] == $group['id']) {
112-
return true;
113-
}
118+
if (in_array($row['items_id'], $groups)) {
119+
return true;
114120
}
115121
}
116122
}

0 commit comments

Comments
 (0)