Skip to content

Commit

Permalink
example of chaining elvis
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannon committed Oct 7, 2023
1 parent 033e6a1 commit 8086c95
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions includes/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,22 +519,13 @@ function access_user_calendar( $cal_can_xxx, $other_user, $cur_user = '',
if( empty( $access_other_cals ) )
access_load_user_permissions();

$key1 = $cur_user . '.' . $other_user;
$key2 = $cur_user . '.__default__';
$key3 = '__default__.' . $other_user;
$key4 = '__default__.__default__';

if( isset( $access_other_cals[$key1][$cal_can_xxx] ) )
$ret = $access_other_cals[$key1][$cal_can_xxx];
else
if( isset( $access_other_cals[$key2][$cal_can_xxx] ) )
$ret = $access_other_cals[$key2][$cal_can_xxx];
else
if( isset( $access_other_cals[$key3][$cal_can_xxx] ) )
$ret = $access_other_cals[$key3][$cal_can_xxx];
else
if( isset( $access_other_cals[$key4][$cal_can_xxx] ) )
$ret = $access_other_cals[$key4][$cal_can_xxx];
$ret = (
$access_other_cals["$cur_user.$other_user"][$cal_can_xxx] ?:
$access_other_cals["$cur_user.__default__"][$cal_can_xxx] ?:
$access_other_cals["__default__.$other_user"][$cal_can_xxx] ?:
$access_other_cals['__default__.__default__'][$cal_can_xxx] ?:
''
);

// Check type and access levels.
if( ! empty( $access ) && ! empty( $type ) ) {
Expand Down

0 comments on commit 8086c95

Please sign in to comment.