Commit 32af4b64 authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

changing redirects to return to the specific post on the topic page after...

changing redirects to return to the specific post on the topic page after creating/editing/deleting a post
parent f8c85792
......@@ -107,7 +107,7 @@ $form = pieform(array(
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('yes'), get_string('no')),
'goto' => get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $post->topic,
'goto' => get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $post->topic . '#post' . $postid
),
'post' => array(
'type' => 'hidden',
......@@ -116,6 +116,10 @@ $form = pieform(array(
'topic' => array(
'type' => 'hidden',
'value' => $post->topic
),
'parent' => array(
'type' => 'hidden',
'value' => $post->parent
)
)
));
......@@ -128,7 +132,7 @@ function deletepost_submit(Pieform $form, $values) {
array('id' => $values['post'])
);
$SESSION->add_ok_msg(get_string('deletepostsuccess', 'interaction.forum'));
redirect('/interaction/forum/topic.php?id=' . $values['topic']);
redirect('/interaction/forum/topic.php?id=' . $values['topic'] . '#post' . $values['parent']);
}
$smarty = smarty(array(), array(), array(), array('sideblocks' => array(interaction_sideblock($post->group))));
......
......@@ -164,8 +164,7 @@ $editform = pieform(array(
'title' => get_string('Subject', 'interaction.forum'),
'defaultvalue' => isset($post) ? $post->subject : null,
'rules' => array(
'maxlength' => 255,
'required' => isset($post) && !$post->parent ? true : false
'maxlength' => 255
)
),
'body' => array(
......@@ -182,7 +181,7 @@ $editform = pieform(array(
isset($post) ? get_string('edit') : get_string('Post','interaction.forum'),
get_string('cancel')
),
'goto' => get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $parent->topic
'goto' => get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $parent->topic . '#post' . (isset($postid) ? $postid : $parentid)
),
'topic' => array(
'type' => 'hidden',
......@@ -219,13 +218,13 @@ function editpost_submit(Pieform $form, $values) {
}
db_commit();
$SESSION->add_ok_msg(get_string('editpostsuccess', 'interaction.forum'));
redirect('/interaction/forum/topic.php?id=' . $values['topic']);
redirect('/interaction/forum/topic.php?id=' . $values['topic'] . '#post' . $postid);
}
function addpost_submit(Pieform $form, $values) {
global $USER, $SESSION;
$parentid = param_integer('parent');
insert_record(
$postid = insert_record(
'interaction_forum_post',
(object)array(
'topic' => $values['topic'],
......@@ -234,10 +233,11 @@ function addpost_submit(Pieform $form, $values) {
'subject' => $values['subject'],
'body' => $values['body'],
'ctime' => db_format_timestamp(time())
)
),
'id', true
);
$SESSION->add_ok_msg(get_string('addpostsuccess', 'interaction.forum'));
redirect('/interaction/forum/topic.php?id=' . $values['topic']);
redirect('/interaction/forum/topic.php?id=' . $values['topic'] . '#post' . $postid);
}
$smarty = smarty(array(), array(), array(), array('sideblocks' => array(interaction_sideblock($parent->group))));
......
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