Skip to content

Commit

Permalink
Redirect to originating page
Browse files Browse the repository at this point in the history
When editing a global profile from the Manage User Profile page,
Mantis redirects to the Manage Global Profile page, which is confusing.

We now return to the page from which the user submitted the Edit.

Fixes #27260
  • Loading branch information
dregad committed Sep 18, 2020
1 parent 29992f8 commit 6c6251c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 2 additions & 0 deletions account_prof_edit_page.php
Expand Up @@ -59,6 +59,7 @@
current_user_ensure_unprotected();

$f_profile_id = gpc_get_int( 'profile_id' );
$f_redirect_page = gpc_get_string( 'redirect', 'account_prof_menu_page.php' );

if( profile_is_global( $f_profile_id ) ) {
access_ensure_global_level( config_get( 'manage_global_profile_threshold' ) );
Expand Down Expand Up @@ -97,6 +98,7 @@
<?php echo form_security_field( 'account_prof_update' )?>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="profile_id" value="<?php echo $v_id ?>" />
<input type="hidden" name="redirect" value="<?php echo $f_redirect_page ?>" />
<tr>
<th class="category" width="25%">
<span class="required">*</span><?php echo lang_get( 'platform' ) ?>
Expand Down
1 change: 1 addition & 0 deletions account_prof_menu_page.php
Expand Up @@ -224,6 +224,7 @@
# Common POST parameters for action buttons
$t_param = array(
'profile_id' => $v_id,
'redirect' => basename( $_SERVER["SCRIPT_FILENAME"] ),
);

# Print the Edit and Delete buttons for local profiles, or
Expand Down
14 changes: 5 additions & 9 deletions account_prof_update.php
Expand Up @@ -58,6 +58,7 @@
current_user_ensure_unprotected();

$f_action = gpc_get_string( 'action' );
$f_redirect_page = gpc_get_string( 'redirect', 'account_prof_menu_page.php' );

if( $f_action != 'add' ) {
$f_profile_id = gpc_get_int( 'profile_id' );
Expand All @@ -71,7 +72,7 @@

switch( $f_action ) {
case 'edit':
$t_redirect_page = 'account_prof_edit_page.php?profile_id=' . $f_profile_id;
$f_redirect_page = 'account_prof_edit_page.php?profile_id=' . $f_profile_id;
break;

case 'add':
Expand All @@ -94,9 +95,9 @@
profile_create( $t_user_id, $f_platform, $f_os, $f_os_build, $f_description );

if( ALL_USERS == $t_user_id ) {
$t_redirect_page = 'manage_prof_menu_page.php';
$f_redirect_page = 'manage_prof_menu_page.php';
} else {
$t_redirect_page = 'account_prof_menu_page.php';
$f_redirect_page = 'account_prof_menu_page.php';
}
break;

Expand All @@ -110,10 +111,8 @@
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 );
$t_redirect_page = '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 );
$t_redirect_page = 'account_prof_menu_page.php';
}
break;

Expand All @@ -122,18 +121,15 @@
access_ensure_global_level( config_get( 'manage_global_profile_threshold' ) );

profile_delete( ALL_USERS, $f_profile_id );
$t_redirect_page = 'manage_prof_menu_page.php';
} else {
profile_delete( auth_get_current_user_id(), $f_profile_id );
$t_redirect_page = 'account_prof_menu_page.php';
}
break;

case 'make_default':
current_user_set_pref( 'default_profile', $f_profile_id );
$t_redirect_page = 'account_prof_menu_page.php';
break;
}

form_security_purge( $t_form_name );
print_header_redirect( $t_redirect_page );
print_header_redirect( $f_redirect_page );

0 comments on commit 6c6251c

Please sign in to comment.