Skip to content

Commit

Permalink
Must use false === when using array_search because first element retu…
Browse files Browse the repository at this point in the history
…rns 0
  • Loading branch information
Isaac Connor committed Nov 2, 2022
1 parent 7e82159 commit ea6d999
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions web/includes/Monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1019,21 +1019,26 @@ class="monitorStream imageFeed"
} // end getStreamHTML

public function effectivePermission($u=null) {
if ($u=== null) {
if ($u === null) {
global $user;
$u = new User($user);
}
$monitor_permission = $u->Monitor_Permission($this->Id());
if ($monitor_permission->Permission() != 'Inherit') return $monitor_permission->Permission();
if ($monitor_permission->Permission() != 'Inherit') {
return $monitor_permission->Permission();
}
$gp_permissions = array();
foreach ($u->Group_Permissions() as $gp) {
if (!array_search($this->Id(), $gp->Group()->MonitorIds())) continue;
if ($gp->Permission() == 'None') return $gp->Permission();
if (false === array_search($this->Id(), $gp->Group()->MonitorIds())) {
continue;
}
if ($gp->Permission() == 'None') {
return $gp->Permission();
}
$gp_permissions[$gp->Permission()] = 1;
}
if (isset($gp_permissions['View'])) return 'View';
if (isset($gp_permissions['Edit'])) return 'Edit';

return $u->Monitors();
}
} // end class Monitor
Expand Down

0 comments on commit ea6d999

Please sign in to comment.