| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
interface SH4_Conflicts_IAcl |
| 3 |
{ |
| 4 |
public function checkView( $shiftId ); |
| 5 |
} |
| 6 |
|
| 7 |
class SH4_Conflicts_Acl implements SH4_Conflicts_IAcl |
| 8 |
{ |
| 9 |
public $self, $auth, $shiftsQuery; |
| 10 |
|
| 11 |
public function __construct( |
| 12 |
HC3_Hooks $hooks, |
| 13 |
SH4_Shifts_Query $shiftsQuery, |
| 14 |
HC3_Auth $auth |
| 15 |
) |
| 16 |
{ |
| 17 |
$this->self = $hooks->wrap( $this ); |
| 18 |
$this->auth = $hooks->wrap( $auth ); |
| 19 |
$this->shiftsQuery = $hooks->wrap( $shiftsQuery ); |
| 20 |
} |
| 21 |
|
| 22 |
public function checkView( $shiftId ) |
| 23 |
{ |
| 24 |
$return = FALSE; |
| 25 |
|
| 26 |
$shift = $this->shiftsQuery->findById( $shiftId ); |
| 27 |
if( ! ($shift && $shift->getId()) ){ |
| 28 |
return $return; |
| 29 |
} |
| 30 |
|
| 31 |
$currentUser = $this->auth->getCurrentUser(); |
| 32 |
$currentUserId = $currentUser->getId(); |
| 33 |
if( ! $currentUserId ){ |
| 34 |
return $return; |
| 35 |
} |
| 36 |
|
| 37 |
$return = TRUE; |
| 38 |
return $return; |
| 39 |
} |
| 40 |
} |