Should fix bug when editing thread see #4271

skala
Julio Montoya 12 years ago
parent 20a774a647
commit 1ebebb731b
  1. 21
      main/forum/forumfunction.inc.php
  2. 9
      main/forum/reply.php

@ -2162,9 +2162,10 @@ function show_add_post_form($action = '', $id = '', $form_values = '')
// If we are quoting a message we have to retrieve the information of the post we are quoting so that
// we can add this as default to the textarea.
if (($action == 'quote' || $action == 'replymessage') && isset($my_post)) {
// We also need to put the parent_id of the post in a hidden form when we are quoting or replying to a message (<> reply to a thread !!!)
$form->addElement('hidden', 'post_parent_id', strval(intval($my_post))); // Note: This has to be cleaned first.
$form->addElement('hidden', 'post_parent_id', intval($my_post)); // Note: This has to be cleaned first.
// If we are replying or are quoting then we display a default title.
$values = get_post_information($my_post); // Note: This has to be cleaned first.
$defaults['post_title'] = get_lang('ReplyShort').api_html_entity_decode($values['post_title'], ENT_QUOTES);
@ -2527,7 +2528,7 @@ function show_edit_post_form($current_post, $current_thread, $current_forum, $fo
$form->addElement('hidden', 'post_id', $current_post['post_id']);
$form->addElement('hidden', 'thread_id', $current_thread['thread_id']);
$form->addElement('hidden', 'id_attach', $id_attach);
var_dump($current_post);
if ($current_post['post_parent_id'] == 0) {
$form->addElement('hidden', 'is_first_post_of_thread', '1');
}
@ -2665,11 +2666,17 @@ function store_edit_post($values)
$course_id = api_get_course_int_id();
//check if this post is the first of the thread
// First we check if the change affects the thread and if so we commit the changes (sticky and post_title=thread_title are relevant).
var_dump($values);
exit;
if (array_key_exists('is_first_post_of_thread', $values) AND $values['is_first_post_of_thread'] == '1') {
$posts = get_posts($values['thread_id']);
$first_post = null;
if (!empty($posts)) {
$first_post = $posts[0];
}
if (!empty($first_post) && $first_post['post_id'] == $values['post_id']) {
//if (array_key_exists('is_first_post_of_thread', $values) AND $values['is_first_post_of_thread'] == '1') {
$sql = "UPDATE $table_threads SET
thread_title ='".Database::escape_string($values['post_title'])."',
thread_sticky ='".Database::escape_string(isset($values['thread_sticky']) ? $values['thread_sticky'] : null)."',".
@ -2686,7 +2693,7 @@ function store_edit_post($values)
post_title ='".Database::escape_string($values['post_title'])."',
post_text ='".Database::escape_string($values['post_text'])."',
post_notification ='".Database::escape_string(isset($values['post_notification']) ? $values['post_notification'] : null)."'
WHERE c_id = $course_id AND post_id='".intval($values['post_id'])."'";
WHERE c_id = $course_id AND post_id = '".intval($values['post_id'])."'";
Database::query($sql);

@ -133,7 +133,7 @@ if (isset($_POST['add_resources']) AND $_POST['add_resources'] == get_lang('Reso
/* Header */
if ($origin == 'learnpath') {
if ($origin == 'learnpath') {
Display :: display_reduced_header('');
} else {
// The last element of the breadcrumb navigation is already set in interbreadcrumb, so give an empty string.
@ -161,13 +161,12 @@ $values = show_add_post_form($my_action, $my_post, $my_elements); // Note:
if (!empty($values) AND isset($_POST['SubmitPost'])) {
$result = store_reply($values);
//@todo split the show_add_post_form function
$url = 'viewthread.php?forum='.$current_thread['forum_id'].'&gradebook='.$gradebook.'&thread='.intval($_GET['thread']).'&gidReq='.api_get_group_id().'&origin='.$origin.'&msg='.$result['msg'].'&type='.$result['type'];
echo '
<script type="text/javascript">
<script>
window.location = "'.$url.'";
</script>';
//header('Location: );
</script>';
}
if ($origin != 'learnpath') {

Loading…
Cancel
Save