From f4e637994883404c3af1d062840146c517d78686 Mon Sep 17 00:00:00 2001 From: Bruce Bannon Date: Sat, 16 Sep 2023 02:10:05 -0600 Subject: [PATCH 1/2] example of converting ==|!= to ===|!== --- access.php | 73 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/access.php b/access.php index 75eb09dcf..da62eec6c 100644 --- a/access.php +++ b/access.php @@ -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(); @@ -30,7 +29,8 @@ $defConfigStr = translate( 'DEFAULT CONFIGURATION' ); $goStr = ' - + '; $saveStr = translate( 'Save' ); $undoStr = translate( 'Undo' ); @@ -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 @@ -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' ); @@ -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' )] ) ) @@ -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__'; } @@ -155,8 +158,7 @@ . filemtime( 'includes/js/access.js' ) . '"> ', - ( ! empty( $op['time'] ) && $op['time'] == 'Y' - ? 'onload="enableAll( true );"' : '' ) ); + ( $op['time'] === 'Y' ? 'onload="enableAll(true);"' : '' ) ); echo print_success( $saved ); @@ -178,20 +180,20 @@ // Add a DEFAULT CONFIGURATION to be used as a mask. . ' '; for( $i = 0, $cnt = count( $userlist ); $i < $cnt; $i++ ) { echo ' '; } for( $i = 0, $cnt = count( $nonuserlist ); $i < $cnt; $i++ ) { echo ' '; + . ( $nonuserlist[$i]['cal_is_public'] === 'Y' ? '*' : '' ) . ''; } echo $goStr; @@ -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 '
'; print_form_key(); @@ -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: @@ -248,7 +250,7 @@ access_get_function_description( $order[$i] ), substr( $access, $order[$i], 1 )], 'dito' ) . '
'; - if( ( $i + 1 ) % $div == 0 ) + if ( ( $i + 1 ) % $div === 0 ) echo ' '; @@ -260,19 +262,20 @@ - +
'; $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; @@ -289,14 +292,14 @@ // Add a DEFAULT CONFIGURATION to be used as a mask. . ' '; for( $i = 0, $cnt = count( $userlist ); $i < $cnt; $i++ ) { - if( $userlist[$i]['cal_login'] != $guser ) + if ( $userlist[$i]['cal_login'] !== $guser ) echo ' '; } @@ -341,23 +344,23 @@ for( $j = 1; $j < 5; $j++ ) { $bottomedge = ''; - if( $j == 3 ) + if ( $j === 3 ) continue; echo ' ' . 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'; @@ -377,7 +380,7 @@ . $j * 64 . '" name="v_' . $j * 64 . '"' . ( ! empty( $op['view'] ) && ( $op['view'] & ( $j * 64 ) ) ? $checked : '' ) . '>' - . ( $guser != '__public__' ? ' + . ( $guser !== '__public__' ? ' ' - . ( $otheruser != '__default__' && $otheruser != '__public__' ? ' + . ( $otheruser !== '__default__' && $otheruser !== '__public__' ? '   ' : '' ) . '