mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-30811 core: Replace use of continue_button with redirect
This commit is contained in:
parent
d954b54f9e
commit
372d6b923b
@ -87,13 +87,9 @@ if ($mform && ($mform->is_cancelled() || !empty($CFG->preventscheduledtaskchange
|
||||
|
||||
try {
|
||||
\core\task\manager::configure_scheduled_task($task);
|
||||
$url = $PAGE->url;
|
||||
$url->params(array('success'=>get_string('changessaved')));
|
||||
redirect($url);
|
||||
redirect($PAGE->url, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
|
||||
} catch (Exception $e) {
|
||||
$url = $PAGE->url;
|
||||
$url->params(array('error'=>$e->getMessage()));
|
||||
redirect($url);
|
||||
redirect($PAGE->url, $e->getMessage(), null, \core\output\notification::NOTIFY_ERROR);
|
||||
}
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
@ -104,19 +100,7 @@ if ($mform && ($mform->is_cancelled() || !empty($CFG->preventscheduledtaskchange
|
||||
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
$error = optional_param('error', '', PARAM_NOTAGS);
|
||||
if ($error) {
|
||||
echo $OUTPUT->notification($error, 'notifyerror');
|
||||
}
|
||||
$success = optional_param('success', '', PARAM_NOTAGS);
|
||||
if ($success) {
|
||||
echo $OUTPUT->notification($success, 'notifysuccess');
|
||||
}
|
||||
$tasks = core\task\manager::get_all_scheduled_tasks();
|
||||
echo $renderer->scheduled_tasks_table($tasks);
|
||||
echo $OUTPUT->footer();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -60,12 +60,7 @@ foreach ($allcohorts as $c) {
|
||||
unset($allcohorts);
|
||||
|
||||
if (count($cohorts) < 2) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('bulkadd', 'core_cohort'));
|
||||
echo $OUTPUT->notification(get_string('bulknocohort', 'core_cohort'));
|
||||
echo $OUTPUT->continue_button(new moodle_url('/admin/user/user_bulk.php'));
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
redirect(new moodle_url('/admin/user/user_bulk.php'), get_string('bulknocohort', 'core_cohort'));
|
||||
}
|
||||
|
||||
$countries = get_string_manager()->get_list_of_countries(true);
|
||||
|
@ -115,8 +115,7 @@ if ($activate) {
|
||||
$url = new moodle_url('/badges/action.php', $params);
|
||||
|
||||
if (!$badge->has_criteria()) {
|
||||
echo $OUTPUT->notification(get_string('error:cannotact', 'badges') . get_string('nocriteria', 'badges'));
|
||||
echo $OUTPUT->continue_button($returnurl);
|
||||
redirect($returnurl, get_string('error:cannotact', 'badges') . get_string('nocriteria', 'badges'), null, \core\output\notification::NOTIFY_ERROR);
|
||||
} else {
|
||||
$message = get_string('reviewconfirm', 'badges', $badge->name);
|
||||
echo $OUTPUT->confirm($message, $url, $returnurl);
|
||||
|
@ -2599,7 +2599,7 @@ function notice ($message, $link='', $course=null) {
|
||||
* @param string $messagetype The type of notification to show the message in. See constants on \core\output\notification.
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
function redirect($url, $message='', $delay=-1, $messagetype = \core\output\notification::NOTIFY_INFO) {
|
||||
function redirect($url, $message='', $delay=null, $messagetype = \core\output\notification::NOTIFY_INFO) {
|
||||
global $OUTPUT, $PAGE, $CFG;
|
||||
|
||||
if (CLI_SCRIPT or AJAX_SCRIPT) {
|
||||
@ -2607,6 +2607,10 @@ function redirect($url, $message='', $delay=-1, $messagetype = \core\output\noti
|
||||
throw new moodle_exception('redirecterrordetected', 'error');
|
||||
}
|
||||
|
||||
if ($delay === null) {
|
||||
$delay = -1;
|
||||
}
|
||||
|
||||
// Prevent debug errors - make sure context is properly initialised.
|
||||
if ($PAGE) {
|
||||
$PAGE->set_context(null);
|
||||
|
@ -62,17 +62,15 @@ $PAGE->requires->string_for_js('show', 'moodle');
|
||||
$PAGE->set_title($course->shortname.': '.$imscp->name);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_activity_record($imscp);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(format_string($imscp->name));
|
||||
|
||||
// Verify imsmanifest was parsed properly.
|
||||
if (!$imscp->structure) {
|
||||
echo $OUTPUT->notification(get_string('deploymenterror', 'imscp'), 'notifyproblem');
|
||||
echo $OUTPUT->continue_button(course_get_url($course->id, $cm->section));
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
redirect(course_get_url($course->id, $cm->section), get_string('deploymenterror', 'imscp'));
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(format_string($imscp->name));
|
||||
|
||||
imscp_print_content($imscp, $cm, $course);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -302,11 +302,7 @@ class quiz_overview_report extends quiz_attempts_report {
|
||||
* @uses exit. This method never returns.
|
||||
*/
|
||||
protected function finish_regrade($nexturl) {
|
||||
global $OUTPUT, $PAGE;
|
||||
echo $OUTPUT->heading(get_string('regradecomplete', 'quiz_overview'), 3);
|
||||
echo $OUTPUT->continue_button($nexturl);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
redirect($nexturl, get_string('regradecomplete', 'quiz_overview'), null, \core\output\notification::NOTIFY_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,16 +45,15 @@ $stremailupdate = get_string('emailupdate', 'auth', $a);
|
||||
$PAGE->set_title(format_string($SITE->fullname) . ": $stremailupdate");
|
||||
$PAGE->set_heading(format_string($SITE->fullname) . ": $stremailupdate");
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (empty($preferences['newemailattemptsleft'])) {
|
||||
redirect("$CFG->wwwroot/user/view.php?id=$user->id");
|
||||
|
||||
} else if ($preferences['newemailattemptsleft'] < 1) {
|
||||
cancel_email_update($user->id);
|
||||
$stroutofattempts = get_string('auth_outofnewemailupdateattempts', 'auth');
|
||||
echo $OUTPUT->box($stroutofattempts, 'center');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->box(get_string('auth_outofnewemailupdateattempts', 'auth'), 'center');
|
||||
echo $OUTPUT->footer();
|
||||
} else if ($key == $preferences['newemailkey']) {
|
||||
$olduser = clone($user);
|
||||
cancel_email_update($user->id);
|
||||
@ -62,25 +61,25 @@ if (empty($preferences['newemailattemptsleft'])) {
|
||||
|
||||
// Detect duplicate before saving.
|
||||
if ($DB->get_record('user', array('email' => $user->email))) {
|
||||
$stremailnowexists = get_string('emailnowexists', 'auth');
|
||||
echo $OUTPUT->box($stremailnowexists, 'center');
|
||||
echo $OUTPUT->continue_button("$CFG->wwwroot/user/view.php?id=$user->id");
|
||||
redirect(new moodle_url('/user/view.php', ['id' => $user->id]), get_string('emailnowexists', 'auth'));
|
||||
} else {
|
||||
// Update user email.
|
||||
$authplugin = get_auth_plugin($user->auth);
|
||||
$authplugin->user_update($olduser, $user);
|
||||
user_update_user($user, false);
|
||||
$a->email = $user->email;
|
||||
$stremailupdatesuccess = get_string('emailupdatesuccess', 'auth', $a);
|
||||
echo $OUTPUT->box($stremailupdatesuccess, 'center');
|
||||
echo $OUTPUT->continue_button("$CFG->wwwroot/user/view.php?id=$user->id");
|
||||
redirect(
|
||||
new moodle_url('/user/view.php', ['id' => $user->id]),
|
||||
get_string('emailupdatesuccess', 'auth', $a),
|
||||
null,
|
||||
\core\output\notification::NOTIFY_SUCCESS
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
$preferences['newemailattemptsleft']--;
|
||||
set_user_preference('newemailattemptsleft', $preferences['newemailattemptsleft'], $user->id);
|
||||
$strinvalidkey = get_string('auth_invalidnewemailkey', 'auth');
|
||||
echo $OUTPUT->box($strinvalidkey, 'center');
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->box(get_string('auth_invalidnewemailkey', 'auth'), 'center');
|
||||
echo $OUTPUT->footer();
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -110,12 +110,12 @@ $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $coursec
|
||||
if ($currentuser) {
|
||||
if (!is_viewing($coursecontext) && !is_enrolled($coursecontext)) {
|
||||
// Need to have full access to a course to see the rest of own info.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('notenrolled', '', $fullname));
|
||||
$referer = get_local_referer(false);
|
||||
if (!empty($referer)) {
|
||||
echo $OUTPUT->continue_button($referer);
|
||||
redirect($referer, get_string('notenrolled', '', $fullname));
|
||||
}
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('notenrolled', '', $fullname));
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
@ -136,17 +136,17 @@ if ($currentuser) {
|
||||
// or test for course:inspect capability.
|
||||
if (has_capability('moodle/role:assign', $coursecontext)) {
|
||||
$PAGE->navbar->add($fullname);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('notenrolled', '', $fullname));
|
||||
$notice = get_string('notenrolled', '', $fullname);
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
$PAGE->navbar->add($struser);
|
||||
echo $OUTPUT->heading(get_string('notenrolledprofile'));
|
||||
$notice = get_string('notenrolledprofile', '', $fullname);
|
||||
}
|
||||
$referer = get_local_referer(false);
|
||||
if (!empty($referer)) {
|
||||
echo $OUTPUT->continue_button($referer);
|
||||
redirect($referer, $notice);
|
||||
}
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($notice);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user