Skip to content

Commit

Permalink
Implementing PR revision comments
Browse files Browse the repository at this point in the history
- Fix param type in PHPDoc
- Consistency in variables init sequence in switch statement
- Renamed html_operation_successful_buttons() function to
  html_operation_confirmation()
- Restored wrongly deleted init of $t_access_level
- Action 2 leftover TODOs, use the new warning/failure functions
  • Loading branch information
dregad committed Sep 21, 2016
1 parent 4972883 commit 68bd874
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bug_report.php
Expand Up @@ -323,7 +323,7 @@
}
}

html_operation_successful_buttons( array(
html_operation_confirmation( array(
array( string_get_bug_view_url( $t_bug_id ), sprintf( lang_get( 'view_submitted_bug_link' ), $t_bug_id ) ),
array( 'view_all_bug_page.php', lang_get( 'view_bugs_link' ) ),
) );
Expand Down
18 changes: 9 additions & 9 deletions core/html_api.php
Expand Up @@ -369,25 +369,25 @@ function html_top_banner() {
}

/**
* Outputs an operation successful message with multiple redirection buttons.
* @param array $p_buttons Array of (URL, label) pairs used to generate
* Outputs a message to confirm an operation's result.
* @param array $p_buttons Array of (URL, label) pairs used to generate
* the buttons; if label is null or unspecified,
* the default 'proceed' text will be displayed.
* @param string $p_message Message to display to the user. If none is
* @param string $p_message Message to display to the user. If none is
* provided, a default message will be printed
* @param string $p_type One of the constants CONFIRMATION_TYPE_SUCCESS,
* @param integer $p_type One of the constants CONFIRMATION_TYPE_SUCCESS,
* CONFIRMATION_TYPE_WARNING, CONFIRMATION_TYPE_FAILURE
* @return void
*/
function html_operation_successful_buttons( array $p_buttons, $p_message = '', $p_type = CONFIRMATION_TYPE_SUCCESS ) {
function html_operation_confirmation( array $p_buttons, $p_message = '', $p_type = CONFIRMATION_TYPE_SUCCESS ) {
switch( $p_type ) {
case CONFIRMATION_TYPE_FAILURE:
$t_alert_css = 'alert-danger';
$t_message = 'operation_failed';
break;
case CONFIRMATION_TYPE_WARNING:
$t_message = 'operation_warnings';
$t_alert_css = 'alert-warning';
$t_message = 'operation_warnings';
break;
case CONFIRMATION_TYPE_SUCCESS:
default:
Expand Down Expand Up @@ -429,7 +429,7 @@ function html_operation_successful_buttons( array $p_buttons, $p_message = '', $
* @return void
*/
function html_operation_successful( $p_redirect_url, $p_message = '' ) {
html_operation_successful_buttons( array( array( $p_redirect_url ) ), $p_message );
html_operation_confirmation( array( array( $p_redirect_url ) ), $p_message );
}

/**
Expand All @@ -439,7 +439,7 @@ function html_operation_successful( $p_redirect_url, $p_message = '' ) {
* @return void
*/
function html_operation_warning( $p_redirect_url, $p_message = '' ) {
html_operation_successful_buttons(
html_operation_confirmation(
array( array( $p_redirect_url ) ),
$p_message,
CONFIRMATION_TYPE_WARNING
Expand All @@ -453,7 +453,7 @@ function html_operation_warning( $p_redirect_url, $p_message = '' ) {
* @return void
*/
function html_operation_failure( $p_redirect_url, $p_message = '' ) {
html_operation_successful_buttons(
html_operation_confirmation(
array( array( $p_redirect_url ) ),
$p_message,
CONFIRMATION_TYPE_FAILURE
Expand Down
2 changes: 1 addition & 1 deletion manage_user_create.php
Expand Up @@ -131,7 +131,7 @@
layout_page_header( null, $t_redirect_url );

layout_page_begin( 'manage_overview_page.php' );

$t_access_level = get_enum_element( 'access_levels', $f_access_level );
$t_message = lang_get( 'created_user_part1' )
. ' <span class="bold">' . $f_username . '</span> '
. lang_get( 'created_user_part2' )
Expand Down
3 changes: 1 addition & 2 deletions manage_user_reset.php
Expand Up @@ -82,8 +82,7 @@
if( $t_reset ) {
if( false == $t_result ) {
# PROTECTED
# @TODO this should be a failure message !
html_operation_successful( $t_redirect_url, lang_get( 'account_reset_protected_msg' ) );
html_operation_failure( $t_redirect_url, lang_get( 'account_reset_protected_msg' ) );
} else {
# SUCCESSFUL RESET
if( ( ON == config_get( 'send_reset_password' ) ) && ( ON == config_get( 'enable_email_notification' ) ) ) {
Expand Down
3 changes: 1 addition & 2 deletions manage_user_update.php
Expand Up @@ -228,8 +228,7 @@

if( $f_protected && $t_old_protected ) {
# PROTECTED
# @TODO this should actually be a warning message
html_operation_successful( $t_redirect_url, lang_get( 'manage_user_protected_msg' ) );
html_operation_warning( $t_redirect_url, lang_get( 'manage_user_protected_msg' ) );
} else if( $t_result ) {
# SUCCESS
html_operation_successful( $t_redirect_url );
Expand Down
2 changes: 1 addition & 1 deletion news_update.php
Expand Up @@ -69,7 +69,7 @@

echo '<div class="space-20"></div>';

html_operation_successful_buttons( array(
html_operation_confirmation( array(
array( 'news_menu_page.php' ),
array( 'news_edit_page.php?news_id=' . $f_news_id . '&action=edit', lang_get( 'edit_link' ) ),
) );
Expand Down

0 comments on commit 68bd874

Please sign in to comment.