Skip to content

Commit

Permalink
MDL-53357 admin: Don't break urls after saving admin settings
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanheywood committed Mar 17, 2016
1 parent e8952c5 commit 9c489db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion admin/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
// now we'll deal with the case that the admin has submitted the form with changed settings
if ($data = data_submitted() and confirm_sesskey()) {
if (admin_write_settings($data)) {
$statusmsg = get_string('changessaved');
redirect($PAGE->url, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
}

if (!empty($adminroot->errors)) {
$errormsg = get_string('errorwithsettings', 'admin');
$firsterror = reset($adminroot->errors);
$focus = $firsterror->id;
} else {
redirect($PAGE->url);
}
}

Expand Down
7 changes: 4 additions & 3 deletions admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@

if ($data = data_submitted() and confirm_sesskey()) {
if (admin_write_settings($data)) {
$statusmsg = get_string('changessaved');
redirect($PAGE->url, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
}

if (empty($adminroot->errors)) {
switch ($return) {
case 'site': redirect("$CFG->wwwroot/");
case 'admin': redirect("$CFG->wwwroot/$CFG->admin/");
}
redirect($PAGE->url);
} else {
$errormsg = get_string('errorwithsettings', 'admin');
$firsterror = reset($adminroot->errors);
Expand Down Expand Up @@ -72,7 +73,7 @@

// ---------------------------------------------------------------------------------------------------------------

echo '<form action="settings.php" method="post" id="adminsettings">';
echo '<form action="' . $PAGE->url . '" method="post" id="adminsettings">';
echo '<div class="settingsform clearfix">';
echo html_writer::input_hidden_params($PAGE->url);
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
Expand Down Expand Up @@ -116,7 +117,7 @@

// ---------------------------------------------------------------------------------------------------------------

echo '<form action="settings.php" method="post" id="adminsettings">';
echo '<form action="' . $PAGE->url . '" method="post" id="adminsettings">';
echo '<div class="settingsform clearfix">';
echo html_writer::input_hidden_params($PAGE->url);
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
Expand Down

0 comments on commit 9c489db

Please sign in to comment.