Commit dcd579a2 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Redirect back to blog page after submitting a post

parent 6d4ea4f5
......@@ -124,8 +124,6 @@ $form = pieform(array(
'filebrowser' => array(
'type' => 'filebrowser',
'title' => get_string('attachments', 'artefact.blog'),
'group' => null,
'institution' => null,
'folder' => $folder,
'highlight' => $highlight,
'browse' => $browse,
......@@ -381,6 +379,14 @@ function editpost_submit(Pieform $form, $values) {
'message' => get_string('blogpostsaved', 'artefact.blog'),
'goto' => get_config('wwwroot') . 'artefact/blog/view/index.php?id=' . $blog,
);
if ($form->submitted_by_js()) {
global $SESSION;
// Redirect back to the blog page from within the iframe
$url = json_encode($result['goto']);
$SESSION->add_ok_msg($result['message']);
echo "<html><head></head><body onload='parent.location.href={$url};'></body></html>";
exit;
}
$form->reply(PIEFORM_OK, $result);
}
......
......@@ -204,12 +204,12 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
this.browse_init = function () {
if (self.config.edit) {
forEach(getElementsByTagAndClassName('button', null, 'filelist'), function (elem) {
var name = getNodeAttribute(elem, 'name');
if (name.match(/^edit\[\d+\]$/)) {
var name = getNodeAttribute(elem, 'name').match(/^([a-z]+)\[(\d+)\]$/);
if (name[1] == 'edit') {
connect(elem, 'onclick', self.edit_form);
}
else if (name.match(/^delete\[\d+\]$/)) {
var id = name.replace(/^delete\[(\d+)\]$/, '$1');
else if (name[1] == 'delete') {
var id = name[2];
if (self.filedata[id].attachcount > 0) {
connect(elem, 'onclick', function (e) {
if (!confirm(get_string('detachfilewarning', self.filedata[id].attachcount))) {
......
Supports Markdown
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