Skip to content

Commit

Permalink
Code Standards/PHP Doc improvements
Browse files Browse the repository at this point in the history
Improvements to code base to follow coding standards,
and improve phpdoc validation from PHP Codesniffer rules
  • Loading branch information
mantis committed Jun 30, 2014
1 parent 3a4ae91 commit 5458f70
Show file tree
Hide file tree
Showing 297 changed files with 10,187 additions and 10,605 deletions.
4 changes: 2 additions & 2 deletions account_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
require_api( 'print_api.php' );
require_api( 'user_api.php' );

form_security_validate('account_delete');
form_security_validate( 'account_delete' );

auth_ensure_user_authenticated();

Expand All @@ -86,7 +86,7 @@
helper_ensure_confirmed( lang_get( 'confirm_delete_msg' ),
lang_get( 'delete_account_button' ) );

form_security_purge('account_delete');
form_security_purge( 'account_delete' );

$t_user_id = auth_get_current_user_id();

Expand Down
2 changes: 1 addition & 1 deletion account_manage_columns_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
current_user_ensure_unprotected();

# Define constant that will be checked by the include page.
define ( 'ACCOUNT_COLUMNS', true );
define( 'ACCOUNT_COLUMNS', true );

define( 'MANAGE_COLUMNS_INC_ALLOW', true );
include ( dirname( __FILE__ ) . '/manage_columns_inc.php' );
Expand Down
8 changes: 4 additions & 4 deletions account_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
#============ Permissions ============
auth_ensure_user_authenticated();

if( !$t_account_verification ) {
if( !$t_account_verification ) {
auth_reauthenticate();
}

Expand All @@ -88,9 +88,9 @@

# extracts the user information for the currently logged in user
# and prefixes it with u_
$row = user_get_row( auth_get_current_user_id() );
$t_row = user_get_row( auth_get_current_user_id() );

extract( $row, EXTR_PREFIX_ALL, 'u' );
extract( $t_row, EXTR_PREFIX_ALL, 'u' );

$t_ldap = ( LDAP == config_get( 'login_method' ) );

Expand Down Expand Up @@ -230,7 +230,7 @@
echo '<span class="display-label"><span>' . lang_get( 'assigned_projects' ) . '</span></span>';
echo '<div class="input">';
echo '<ul class="project-list">';
foreach( $t_projects AS $t_project_id=>$t_project ) {
foreach( $t_projects as $t_project_id=>$t_project ) {
$t_project_name = string_attribute( $t_project['name'] );
$t_view_state = $t_project['view_state'];
$t_access_level = $t_project['access_level'];
Expand Down
13 changes: 7 additions & 6 deletions account_prefs_inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@
/**
* Display html form to edit account preferences
*
* @param int $p_user_id user id
* @param bool $p_error_if_protected error if account is protected
* @param bool $p_accounts_menu display account preferences menu
* @param string $p_redirect_url redirect URI
* @param integer $p_user_id A valid user identifier.
* @param boolean $p_error_if_protected Whether to error if the account is protected.
* @param boolean $p_accounts_menu Display account preferences menu.
* @param string $p_redirect_url Redirect URI.
* @return void
*/
function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_accounts_menu = true, $p_redirect_url = '') {
function edit_account_prefs( $p_user_id = null, $p_error_if_protected = true, $p_accounts_menu = true, $p_redirect_url = '' ) {
if( null === $p_user_id ) {
$p_user_id = auth_get_current_user_id();
}
Expand Down Expand Up @@ -241,7 +242,7 @@ function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_
</fieldset>
<fieldset class="field-container">
<legend><label for="email-on-priority-change"><?php echo lang_get( 'email_on_priority_change' ) ?></label></legend>
<span class="checkbox"><input id="email-on-priority-change" type="checkbox" name="email_on_priority" <?php check_checked( (int)$t_pref->email_on_priority , ON); ?> /></span>
<span class="checkbox"><input id="email-on-priority-change" type="checkbox" name="email_on_priority" <?php check_checked( (int)$t_pref->email_on_priority, ON ); ?> /></span>
<label for="email-on-priority-min-severity" class="email-on-severity-label"><span><?php echo lang_get( 'with_minimum_severity' ) ?></span></label>
<span class="select email-on-severity">
<select id="email-on-priority-min-severity" name="email_on_priority_min_severity">
Expand Down
2 changes: 1 addition & 1 deletion account_prefs_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
$t_prefs->email_bugnote_limit = gpc_get_int( 'email_bugnote_limit' );

# make sure the delay isn't too low
if(( config_get( 'min_refresh_delay' ) > $t_prefs->refresh_delay )&&
if( ( config_get( 'min_refresh_delay' ) > $t_prefs->refresh_delay )&&
( $t_prefs->refresh_delay != 0 )) {
$t_prefs->refresh_delay = config_get( 'min_refresh_delay' );
}
Expand Down
6 changes: 3 additions & 3 deletions account_prof_edit_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@
if( profile_is_global( $f_profile_id ) ) {
access_ensure_global_level( config_get( 'manage_global_profile_threshold' ) );

$row = profile_get_row( ALL_USERS, $f_profile_id );
$t_row = profile_get_row( ALL_USERS, $f_profile_id );
} else {
$row = profile_get_row( auth_get_current_user_id(), $f_profile_id );
$t_row = profile_get_row( auth_get_current_user_id(), $f_profile_id );
}

extract( $row, EXTR_PREFIX_ALL, 'v' );
extract( $t_row, EXTR_PREFIX_ALL, 'v' );

html_page_top();

Expand Down
21 changes: 11 additions & 10 deletions account_prof_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@
trigger_error( ERROR_ACCESS_DENIED, ERROR );
}

form_security_validate('profile_update');
form_security_validate( 'profile_update' );

auth_ensure_user_authenticated();

current_user_ensure_unprotected();

$f_action = gpc_get_string('action');
if( $f_action != 'add') {
$f_action = gpc_get_string( 'action' );

if( $f_action != 'add' ) {
$f_profile_id = gpc_get_int( 'profile_id' );

# Make sure user did select an existing profile from the list
Expand All @@ -69,7 +70,7 @@

switch ( $f_action ) {
case 'edit':
form_security_purge('profile_update');
form_security_purge( 'profile_update' );
print_header_redirect( 'account_prof_edit_page.php?profile_id=' . $f_profile_id );
break;

Expand All @@ -91,7 +92,7 @@
}

profile_create( $t_user_id, $f_platform, $f_os, $f_os_build, $f_description );
form_security_purge('profile_update');
form_security_purge( 'profile_update' );

if( ALL_USERS == $t_user_id ) {
print_header_redirect( 'manage_prof_menu_page.php' );
Expand All @@ -110,11 +111,11 @@
access_ensure_global_level( config_get( 'manage_global_profile_threshold' ) );

profile_update( ALL_USERS, $f_profile_id, $f_platform, $f_os, $f_os_build, $f_description );
form_security_purge('profile_update');
form_security_purge( 'profile_update' );
print_header_redirect( 'manage_prof_menu_page.php' );
} else {
profile_update( auth_get_current_user_id(), $f_profile_id, $f_platform, $f_os, $f_os_build, $f_description );
form_security_purge('profile_update');
form_security_purge( 'profile_update' );
print_header_redirect( 'account_prof_menu_page.php' );
}
break;
Expand All @@ -124,18 +125,18 @@
access_ensure_global_level( config_get( 'manage_global_profile_threshold' ) );

profile_delete( ALL_USERS, $f_profile_id );
form_security_purge('profile_update');
form_security_purge( 'profile_update' );
print_header_redirect( 'manage_prof_menu_page.php' );
} else {
profile_delete( auth_get_current_user_id(), $f_profile_id );
form_security_purge('profile_update');
form_security_purge( 'profile_update' );
print_header_redirect( 'account_prof_menu_page.php' );
}
break;

case 'make_default':
current_user_set_pref( 'default_profile', $f_profile_id );
form_security_purge('profile_update');
form_security_purge( 'profile_update' );
print_header_redirect( 'account_prof_menu_page.php' );
break;
}
20 changes: 10 additions & 10 deletions account_sponsor_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
$t_result = db_query_bound( $t_query, $t_show_all ? array( $t_user ) : array( $t_user , $t_resolved ) );

$t_sponsors = array();
while ( $t_row = db_fetch_array( $t_result ) ) {
while( $t_row = db_fetch_array( $t_result ) ) {
$t_sponsors[] = $t_row;
}

Expand Down Expand Up @@ -160,7 +160,7 @@
<?php
$t_total_owing = 0;
$t_total_paid = 0;
for ( $i = 0; $i < $t_sponsor_count; ++$i ) {
for( $i = 0; $i < $t_sponsor_count; ++$i ) {
$t_sponsor_row = $t_sponsors[$i];
$t_bug = bug_get( $t_sponsor_row['bug'] );
$t_sponsor = sponsorship_get( $t_sponsor_row['sponsor'] );
Expand All @@ -176,9 +176,9 @@
}

# choose color based on status
$status_label = html_get_status_css_class( $t_bug->status, auth_get_current_user_id(), $t_bug->project_id );
$t_status_label = html_get_status_css_class( $t_bug->status, auth_get_current_user_id(), $t_bug->project_id );

echo '<tr class="' . $status_label . '">';
echo '<tr class="' . $t_status_label . '">';
echo '<td><a href="' . string_get_bug_view_url( $t_sponsor_row['bug'] ) . '">' . bug_format_id( $t_sponsor_row['bug'] ) . '</a></td>';
echo '<td>' . string_display_line( project_get_field( $t_bug->project_id, 'name' ) ) . '&#160;</td>';
echo '<td class="right">' . $t_released_label . '&#160;</td>';
Expand Down Expand Up @@ -241,7 +241,7 @@
$t_result = db_query_bound( $t_query, $t_show_all ? array( $t_user ) : array( $t_user , $t_resolved ) );

$t_sponsors = array();
while ( $t_row = db_fetch_array( $t_result ) ) {
while( $t_row = db_fetch_array( $t_result ) ) {
$t_sponsors[] = $t_row;
}

Expand Down Expand Up @@ -278,7 +278,7 @@
$t_bug_list = array();
$t_total_owing = 0;
$t_total_paid = 0;
for ( $i = 0; $i < $t_sponsor_count; ++$i ) {
for( $i = 0; $i < $t_sponsor_count; ++$i ) {
$t_sponsor_row = $t_sponsors[$i];
$t_bug = bug_get( $t_sponsor_row['bug'] );
$t_sponsor = sponsorship_get( $t_sponsor_row['sponsor'] );
Expand All @@ -295,9 +295,9 @@
}

# choose color based on status
$status_label = html_get_status_css_class( $t_bug->status, auth_get_current_user_id(), $t_bug->project_id );
$t_status_label = html_get_status_css_class( $t_bug->status, auth_get_current_user_id(), $t_bug->project_id );

echo '<tr class="' . $status_label . '">';
echo '<tr class="' . $t_status_label . '">';
echo '<td><a href="' . string_get_bug_view_url( $t_sponsor_row['bug'] ) . '">' . bug_format_id( $t_sponsor_row['bug'] ) . '</a></td>';
echo '<td>' . string_display_line( project_get_field( $t_bug->project_id, 'name' ) ) . '&#160;</td>';
echo '<td class="right">' . $t_released_label . '&#160;</td>';
Expand All @@ -315,7 +315,7 @@
print_user( $t_sponsor->user_id );
echo '</td>';
echo '<td class="right">' . sponsorship_format_amount( $t_sponsor->amount ) . '</td>';
echo '<td><select name="sponsor_' . $row['bug'] . '_' . $t_sponsor->id . '">';
echo '<td><select name="sponsor_' . $t_row['bug'] . '_' . $t_sponsor->id . '">';
print_enum_string_option_list( 'sponsorship', $t_sponsor->paid );
echo '</select></td>';

Expand Down Expand Up @@ -359,7 +359,7 @@
<br />
<div>
<?php
html_button ( 'account_sponsor_page.php',
html_button( 'account_sponsor_page.php',
lang_get( ( $t_show_all ? 'sponsor_hide' : 'sponsor_show' ) ),
array( 'show_all' => ( $t_show_all ? 0 : 1 ) ) );
?>
Expand Down
6 changes: 3 additions & 3 deletions account_sponsor_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@
$f_bug_list = gpc_get_string( 'buglist', '' );
$t_bug_list = explode( ',', $f_bug_list );

foreach ( $t_bug_list as $t_bug ) {
foreach( $t_bug_list as $t_bug ) {
list( $t_bug_id, $t_sponsor_id ) = explode( ':', $t_bug );
$c_bug_id = (int) $t_bug_id;
$c_bug_id = (int)$t_bug_id;

bug_ensure_exists( $c_bug_id ); # dies if bug doesn't exist

access_ensure_bug_level( config_get( 'handle_sponsored_bugs_threshold' ), $c_bug_id ); # dies if user can't handle bug

$t_bug = bug_get( $c_bug_id );
$t_sponsor = sponsorship_get( (int) $t_sponsor_id );
$t_sponsor = sponsorship_get( (int)$t_sponsor_id );

$t_new_payment = gpc_get_int( 'sponsor_' . $c_bug_id . '_' . $t_sponsor->id, $t_sponsor->paid );
if( $t_new_payment != $t_sponsor->paid ) {
Expand Down
6 changes: 3 additions & 3 deletions account_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
require_api( 'user_api.php' );
require_api( 'utility_api.php' );

form_security_validate('account_update');
form_security_validate( 'account_update' );

$t_user_id = auth_get_current_user_id();

Expand All @@ -78,7 +78,7 @@

$t_redirect_url = 'index.php';

/** @todo Listing what fields were updated is not standard behaviour of MantisBT - it also complicates the code. */
# @todo Listing what fields were updated is not standard behaviour of MantisBT - it also complicates the code.
$t_email_updated = false;
$t_password_updated = false;
$t_realname_updated = false;
Expand Down Expand Up @@ -125,7 +125,7 @@
}
}

form_security_purge('account_update');
form_security_purge( 'account_update' );

# Clear the verification token
if( $t_account_verification ) {
Expand Down
3 changes: 0 additions & 3 deletions adm_config_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
* @uses project_api.php
*/

/**
* MantisBT Core API's
*/
require_once( 'core.php' );
require_api( 'access_api.php' );
require_api( 'config_api.php' );
Expand Down
Loading

0 comments on commit 5458f70

Please sign in to comment.