mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-65469 mod_forum: Use the formchange checker initializer
This commit is contained in:
parent
dfd0021749
commit
9c3e3a904b
@ -35,6 +35,8 @@ $name = optional_param('name', '', PARAM_CLEAN);
|
||||
$confirm = optional_param('confirm', 0, PARAM_INT);
|
||||
$groupid = optional_param('groupid', null, PARAM_INT);
|
||||
$subject = optional_param('subject', '', PARAM_TEXT);
|
||||
|
||||
// Values posted via the inpage reply form.
|
||||
$prefilledpost = optional_param('post', '', PARAM_TEXT);
|
||||
$prefilledpostformat = optional_param('postformat', FORMAT_MOODLE, PARAM_INT);
|
||||
$prefilledprivatereply = optional_param('privatereply', false, PARAM_BOOL);
|
||||
@ -778,6 +780,25 @@ $mformpost->set_data(
|
||||
(isset($discussion->id) ? array('discussion' => $discussion->id) : array())
|
||||
);
|
||||
|
||||
// If we are being redirected via a no_submit_button press OR if the message is being prefilled.
|
||||
// then set the initial 'dirty' state.
|
||||
// - A prefilled post will exist when being redirected from the inpage reply form.
|
||||
// - A no_submit_button press occurs when being redirected from the inpage add new discussion post form.
|
||||
$dirty = $prefilledpost ? true : false;
|
||||
if ($mformpost->no_submit_button_pressed()) {
|
||||
$data = $mformpost->get_submitted_data();
|
||||
|
||||
// If a no submit button has been pressed but the default values haven't been then reset the form change.
|
||||
if (!$dirty && !empty(trim($data->message['text']))) {
|
||||
$dirty = true;
|
||||
}
|
||||
|
||||
if (!$dirty && !empty(trim($data->message['message']))) {
|
||||
$dirty = true;
|
||||
}
|
||||
}
|
||||
$mformpost->set_initial_dirty_state($dirty);
|
||||
|
||||
if ($mformpost->is_cancelled()) {
|
||||
if (!isset($discussion->id) || $forum->type === 'single') {
|
||||
// Single forums don't have a discussion page.
|
||||
|
Loading…
x
Reference in New Issue
Block a user