Skip to content

Commit

Permalink
example of converting ==|!= to ===|!==
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannon committed Sep 16, 2023
1 parent 55b1648 commit f4e6379
Showing 1 changed file with 38 additions and 35 deletions.
73 changes: 38 additions & 35 deletions access.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/
require_once 'includes/init.php';

$allow_view_other =
( ! empty( $ALLOW_VIEW_OTHER ) && $ALLOW_VIEW_OTHER == 'Y' );
$allow_view_other = ( $ALLOW_VIEW_OTHER === 'Y' );

if( ! access_is_enabled() ) {
echo print_not_auth();
Expand All @@ -30,7 +29,8 @@
$defConfigStr = translate( 'DEFAULT CONFIGURATION' );
$goStr = '
</select>
<input class="btn btn-primary" type="submit" value="' . translate( 'Go' ) . '">
<input class="btn btn-primary" type="submit" value="'
. translate ( 'Go' ) . '">
</form>';
$saveStr = translate( 'Save' );
$undoStr = translate( 'Undo' );
Expand All @@ -40,11 +40,12 @@
// Are we handling the access form?
// If so, do that, then redirect.
// Handle function access first.
if( getPostValue( 'auser' ) != '' && getPostValue( 'submit' ) == $saveStr ) {
if ( getPostValue ( 'auser' ) !== '' &&
getPostValue ( 'submit' ) === $saveStr ) {
$auser = getPostValue( 'auser' );
$perm = '';
for( $i = 0; $i < ACCESS_NUMBER_FUNCTIONS; $i++ ) {
$perm .= ( getPostValue( 'access_' . $i ) == 'Y' ? 'Y' : 'N' );
$perm .= ( getPostValue ( 'access_' . $i ) === 'Y' ? 'Y' : 'N' );
}

dbi_execute( 'DELETE FROM webcal_access_function
Expand All @@ -58,7 +59,8 @@
}

// Are we handling the other user form? If so, do that, then redirect.
if( getPostValue( 'otheruser' ) != '' && getPostValue( 'submit' ) == $saveStr ) {
if ( getPostValue ( 'otheruser' ) !== '' &&
getPostValue ( 'submit' ) === $saveStr ) {
$puser = getPostValue( 'guser' );
$pouser = getPostValue( 'otheruser' );

Expand Down Expand Up @@ -92,8 +94,9 @@
$puser,
$pouser,
( $view_total > 0 ? $view_total : 0 ),
( $edit_total > 0 && $puser != '__public__' ? $edit_total : 0 ),
( $approve_total > 0 && $puser != '__public__' ? $approve_total : 0 ),
( $puser !== '__public__' && $edit_total > 0 ? $edit_total : 0 ),
( $puser !== '__public__' && $approve_total > 0
? $approve_total : 0 ),
( strlen( $invite ) ? $invite : 'N' ),
( strlen( $email ) ? $email : 'N' ),
( strlen( $time ) ? $time : 'N' )] ) )
Expand All @@ -106,16 +109,16 @@
$guser = getPostValue( 'guser' );
$selected = ' selected';

if( $guser == '__default__' ) {
if ( $guser === '__default__' ) {
$otheruser = $guser;
$user_fullname = $defConfigStr;
} else
$otheruser = getPostValue( 'otheruser' );

if( $otheruser == '__default__' ) {
if ( $otheruser === '__default__' ) {
$otheruser_fullname = $defConfigStr;
$otheruser_login = '__default__';
} elseif( $otheruser == '__public__' ) {
} elseif ( $otheruser === '__public__' ) {
$otheruser_fullname = translate( 'Public Access' );
$otheruser_login = '__public__';
}
Expand Down Expand Up @@ -155,8 +158,7 @@
. filemtime( 'includes/js/access.js' ) . '"></script>
<link href="includes/css/access.css?'
. filemtime( 'includes/css/access.css' ) . '" rel="stylesheet">',
( ! empty( $op['time'] ) && $op['time'] == 'Y'
? 'onload="enableAll( true );"' : '' ) );
( $op['time'] === 'Y' ? 'onload="enableAll(true);"' : '' ) );

echo print_success( $saved );

Expand All @@ -178,20 +180,20 @@
// Add a DEFAULT CONFIGURATION to be used as a mask.
. '
<option value="__default__"'
. ( $guser == '__default__' ? $selected : '' )
. ( $guser === '__default__' ? $selected : '' )
. '>' . $defConfigStr . '</option>';
for( $i = 0, $cnt = count( $userlist ); $i < $cnt; $i++ ) {
echo '
<option value="' . $userlist[$i]['cal_login'] . '"'
. ( $guser == $userlist[$i]['cal_login'] ? $selected : '' )
. ( $guser === $userlist[$i]['cal_login'] ? $selected : '' )
. '>' . $userlist[$i]['cal_fullname'] . '</option>';
}
for( $i = 0, $cnt = count( $nonuserlist ); $i < $cnt; $i++ ) {
echo '
<option value="' . $nonuserlist[$i]['cal_login'] . '"'
. ( $guser == $nonuserlist[$i]['cal_login'] ? $selected : '' )
. ( $guser === $nonuserlist[$i]['cal_login'] ? $selected : '' )
. '>' . $nonuserlist[$i]['cal_fullname'] . ' '
. ( $nonuserlist[$i]['cal_is_public'] == 'Y' ? '*' : '' ) . '</option>';
. ( $nonuserlist[$i]['cal_is_public'] === 'Y' ? '*' : '' ) . '</option>';
}

echo $goStr;
Expand All @@ -209,7 +211,7 @@
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26];
// Make sure that we have defined all the types of access
// defined in access.php.
assert( count( $order ) == ACCESS_NUMBER_FUNCTIONS );
assert ( count ( $order ) === ACCESS_NUMBER_FUNCTIONS );

echo '<form action="access.php" method="post" id="accessform" name="accessform">';
print_form_key();
Expand All @@ -225,8 +227,8 @@
// Public access and NUCs can never use some of these functions.
$show = true;

if( $guser == '__public__'
|| substr( $guser, 0, 5 ) == $NONUSER_PREFIX ) {
if ( $guser === '__public__' ||
substr ( $guser, 0, 5 ) === $NONUSER_PREFIX ) {
switch( $order[$i] ) {
case ACCESS_ACCESS_MANAGEMENT:
case ACCESS_ACCOUNT_INFO:
Expand All @@ -248,7 +250,7 @@
access_get_function_description( $order[$i] ),
substr( $access, $order[$i], 1 )], 'dito' ) . '<br>';

if( ( $i + 1 ) % $div == 0 )
if ( ( $i + 1 ) % $div === 0 )
echo '
</td>
<td>';
Expand All @@ -260,19 +262,20 @@
</tbody>
</table>
<input class="btn btn-secondary" type="submit" value="' . $undoStr . '">
<input class="btn btn-primary" type="submit" name="submit" value="' . $saveStr . '">
<input class="btn btn-primary" type="submit" name="submit" value="'
. $saveStr . '">
</form>';

$pagetitle = translate( 'Allow Access to Other Users Calendar' );
} else {
// Get list of users that this user can see (may depend on group settings)
// along with all nonuser calendars.
// if( $guser != '__default__' ) {
// if ( $guser !== '__default__' ) {
$guser = $login;
$pagetitle = translate( 'Grant This User Access to My Calendar' );
}

if( $guser == '__default__' ) {
if ( $guser === '__default__' ) {
$userlist = ['__default__'];
$otheruser = $otheruser_login = '__default__';
$otheruser_fullname = $defConfigStr;
Expand All @@ -289,14 +292,14 @@
// Add a DEFAULT CONFIGURATION to be used as a mask.
. '
<option value="__default__"'
. ( $otheruser == '__default__' ? $selected : '' )
. ( $otheruser === '__default__' ? $selected : '' )
. '>' . $defConfigStr . '</option>';

for( $i = 0, $cnt = count( $userlist ); $i < $cnt; $i++ ) {
if( $userlist[$i]['cal_login'] != $guser )
if ( $userlist[$i]['cal_login'] !== $guser )
echo '
<option value="' . $userlist[$i]['cal_login'] . '"'
. ( ! empty( $otheruser ) && $otheruser == $userlist[$i]['cal_login']
. ( ! empty ( $otheruser ) && $otheruser === $userlist[$i]['cal_login']
? $selected : '' )
. '>' . $userlist[$i]['cal_fullname'] . '</option>';
}
Expand Down Expand Up @@ -341,23 +344,23 @@

for( $j = 1; $j < 5; $j++ ) {
$bottomedge = '';
if( $j == 3 )
if ( $j === 3 )
continue;
echo '
<tr>
<td class="boxleft leftpadded' . ( $j > 3 ? ' boxbottom' : '' )
. '"><input class="form-control-sm" type="checkbox" value="Y" name=';
if( $j == 1 )
if ( $j === 1 )
echo '"invite"'
. ( ! empty( $op['invite'] ) && $op['invite'] == 'N' ? '' : $checked )
. ( $op['invite'] === 'N' ? '' : $checked )
. '>' . translate( 'Can Invite' );
elseif( $j == 2 )
elseif ( $j === 2 )
echo '"email"'
. ( ! empty( $op['email'] ) && $op['email'] == 'N' ? '' : $checked )
. ( $op['email'] === 'N' ? '' : $checked )
. '>' . translate( 'Can Email' );
else {
echo '"time"'
. ( ! empty( $op['time'] ) && $op['time'] == 'Y' ? $checked : '' )
. ( $op['time'] === 'Y' ? $checked : '' )
. ' onclick="enableAll( this.checked );">'
. translate( 'Can See Time Only' );
$bottomedge = 'boxbottom';
Expand All @@ -377,7 +380,7 @@
. $j * 64 . '" name="v_' . $j * 64 . '"'
. ( ! empty( $op['view'] ) && ( $op['view'] & ( $j * 64 ) )
? $checked : '' ) . '></td>'
. ( $guser != '__public__' ? '
. ( $guser !== '__public__' ? '
<td class="aligncenter boxleft pub ' . $bottomedge . '"><input '
. 'class="form-control-sm" type="checkbox" value="' . $j . '" name="e_' . $j . '"'
. ( ! empty( $op['edit'] ) && ( $op['edit'] & $j ) ? $checked : '' )
Expand Down Expand Up @@ -408,7 +411,7 @@
echo '
<tr>
<td colspan="2" class="boxleft alignright">'
. ( $otheruser != '__default__' && $otheruser != '__public__' ? '
. ( $otheruser !== '__default__' && $otheruser !== '__public__' ? '
<input class="btn btn-secondary" type="button" value="' . translate( 'Assistant' )
. '" onclick="selectAll(63);">&nbsp;&nbsp;' : '' ) . '
<input class="btn btn-secondary" type="button" value="' . translate( 'Select All' )
Expand Down

0 comments on commit f4e6379

Please sign in to comment.