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( ...@@ -124,8 +124,6 @@ $form = pieform(array(
'filebrowser' => array( 'filebrowser' => array(
'type' => 'filebrowser', 'type' => 'filebrowser',
'title' => get_string('attachments', 'artefact.blog'), 'title' => get_string('attachments', 'artefact.blog'),
'group' => null,
'institution' => null,
'folder' => $folder, 'folder' => $folder,
'highlight' => $highlight, 'highlight' => $highlight,
'browse' => $browse, 'browse' => $browse,
...@@ -381,6 +379,14 @@ function editpost_submit(Pieform $form, $values) { ...@@ -381,6 +379,14 @@ function editpost_submit(Pieform $form, $values) {
'message' => get_string('blogpostsaved', 'artefact.blog'), 'message' => get_string('blogpostsaved', 'artefact.blog'),
'goto' => get_config('wwwroot') . 'artefact/blog/view/index.php?id=' . $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); $form->reply(PIEFORM_OK, $result);
} }
......
...@@ -204,12 +204,12 @@ function FileBrowser(idprefix, folderid, config, globalconfig) { ...@@ -204,12 +204,12 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
this.browse_init = function () { this.browse_init = function () {
if (self.config.edit) { if (self.config.edit) {
forEach(getElementsByTagAndClassName('button', null, 'filelist'), function (elem) { forEach(getElementsByTagAndClassName('button', null, 'filelist'), function (elem) {
var name = getNodeAttribute(elem, 'name'); var name = getNodeAttribute(elem, 'name').match(/^([a-z]+)\[(\d+)\]$/);
if (name.match(/^edit\[\d+\]$/)) { if (name[1] == 'edit') {
connect(elem, 'onclick', self.edit_form); connect(elem, 'onclick', self.edit_form);
} }
else if (name.match(/^delete\[\d+\]$/)) { else if (name[1] == 'delete') {
var id = name.replace(/^delete\[(\d+)\]$/, '$1'); var id = name[2];
if (self.filedata[id].attachcount > 0) { if (self.filedata[id].attachcount > 0) {
connect(elem, 'onclick', function (e) { connect(elem, 'onclick', function (e) {
if (!confirm(get_string('detachfilewarning', self.filedata[id].attachcount))) { 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