Commit e95ea062 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "(Bug #1158086) Error when deleting the child of a deleted post"

parents 2e1aec83 20caffed
......@@ -115,7 +115,18 @@ function deletepost_submit(Pieform $form, $values) {
array('id' => $values['post'])
);
$SESSION->add_ok_msg(get_string('deletepostsuccess', 'interaction.forum'));
redirect(get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $values['topic'] . '&post=' . $values['parent']);
// Figure out which parent record to redirect us to. If the parent record is deleted,
// keep moving up the chain until you find one that's not deleted.
$postrec = new stdClass();
$postrec->parent = $values['parent'];
do {
$postrec = get_record('interaction_forum_post', 'id', $postrec->parent, '', '', '', '', 'id, deleted, parent');
} while ($postrec && $postrec->deleted && $postrec->parent);
$redirecturl = get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $values['topic'];
if ($postrec && $postrec->parent) {
$redirecturl .= '&post=' . $postrec->id;
}
redirect($redirecturl);
}
$smarty = smarty();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment