Skip to content

Commit e2eda19

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 <[email protected]>
1 parent c611a0c commit e2eda19

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
@@ -72,7 +72,17 @@ public function canViewItem() {
7272
return true;
7373
}
7474

75-
if ($_SESSION['glpiID'] == $this->getField('requester_id')) {
75+
if ($_SESSION['glpiID'] == $this->fields['requester_id']) {
76+
return true;
77+
}
78+
79+
if ($_SESSION['glpiID'] == $this->fields['users_id_validator']) {
80+
return true;
81+
}
82+
83+
$groupUser = new Group_User();
84+
$groups = $groupUser->getUserGroups($_SESSION['glpiID']);
85+
if (in_array($this->fields['users_id_validator'], $groups)) {
7686
return true;
7787
}
7888

@@ -101,12 +111,8 @@ public function canViewItem() {
101111
return true;
102112
}
103113
} else {
104-
$groupUser = new Group_User();
105-
$groups = $groupUser->getUserGroups($_SESSION['glpiID']);
106-
foreach ($groups as $group) {
107-
if ($row['items_id'] == $group['id']) {
108-
return true;
109-
}
114+
if (in_array($row['items_id'], $groups)) {
115+
return true;
110116
}
111117
}
112118
}

0 commit comments

Comments
 (0)