Mark edited posts as unread

Fix for forum_last_post_ not updating error. - Mark edited posts as unread

Fix for forum_last_post_ not updating error.

New postby pawelooss » Mon Jun 21, 2010 11:34 pm

Hi,

I'm very surprised nobody haven't observed that after send edited post, column of "forum last post" doesn't update.

I write this fix and I please author of mod to prepare an update to 1.0.2. ;]

Code: Select all
#
#-----[ OPEN ]------------------------------------------
#

posting.php


#
#-----[ FIND ]------------------------------------------
#

      $sql = 'SELECT f.*, t.*
         FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
         WHERE t.topic_id = $topic_id


#
#-----[ REPLACE WITH ]------------------------------------------
#

      $sql = 'SELECT f.*, t.*, u.user_colour
         FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f, " . USERS_TABLE . " u
         WHERE t.topic_id = $topic_id
            AND u.user_id = topic_last_poster_id


#
#-----[ FIND ]------------------------------------------
#

$sql = 'SELECT f.*, t.*, p.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield


#
#-----[ IN-LINE FIND ]------------------------------------------
#

$sql = 'SELECT f.*, t.*, p.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield


#
#-----[ IN-LINE AFTER ADD ]------------------------------------------
#

, u.user_colour


#
#-----[ FIND ]------------------------------------------
#

$post_data['icon_id']         = (!isset($post_data['icon_id']) || in_array($mode, array('quote', 'reply'))) ? 0 : (int) $post_data['icon_id'];


#
#-----[ BEFORE ADD ]------------------------------------------
#

$post_data['user_colour']         = (isset($post_data['user_colour'])) ? (string) $post_data['user_colour'] : '';


#
#-----[ FIND ]------------------------------------------
#

            'poster_id'            => (int) $post_data['poster_id'],


#
#-----[ AFTER ADD ]------------------------------------------
#

            'poster_colour'            => (string) $post_data['user_colour'],



#
#-----[ OPEN ]------------------------------------------
#

includes/functions_posting.php


#
#-----[ FIND ]------------------------------------------
#

      update_post_information('forum', $data['forum_id']);
      markread('post', $data['forum_id'], $data['topic_id'], $data['post_time']);


#
#-----[ AFTER ADD ]------------------------------------------
#

      $sql_update_forums = 'UPDATE ' . FORUMS_TABLE . '
            SET forum_last_post_time = ' . $current_time . ',
                  forum_last_post_id = ' . $data['post_id'] . ',
                  forum_last_post_subject = "' . $subject . '",
                  forum_last_poster_id = ' . $data['poster_id'] . ',
                  forum_last_poster_name = "' . $username . '",
                  forum_last_poster_colour = "' . $data['poster_colour'] . '"
            WHERE forum_id = ' . $data['forum_id'];
      $db->sql_query($sql_update_forums);



#
#-----[ EOM ]------------------------------------------
#


Best regards,
pawelooss
phpBB3 fan! ;)
pawelooss
Registered User
 
Posts: 48
Joined: Wed Nov 04, 2009 8:26 pm

Re: Fix for forum_last_post_ not updating error.

New postby KillerEST1 » Fri Oct 29, 2010 2:05 pm

This mod doesn't work in 3.0.7-PL1 version.

// Sorry, wrong topic.
KillerEST1
Registered User
 
Posts: 25
Joined: Thu Oct 21, 2010 5:21 pm

Re: Fix for forum_last_post_ not updating error.

New postby ALIENQuake » Sat Feb 19, 2011 9:51 pm

Many thanks fot this fix !!
ALIENQuake
Registered User
 
Posts: 85
Joined: Tue Dec 28, 2010 4:06 pm

Re: Fix for forum_last_post_ not updating error.

New postby WileCoyote » Wed Mar 16, 2011 6:18 pm

There must be an error in your code. I've reparsed BBCodes with Support Toolkit 1.0.3 and got an error message that in includes/functions_posting.php on the line forum_last_poster_colour = "' . $data['poster_colour'] . '" poster_colour is an unindexed field
rgds
Regards
WileCoyote
____________________________________________________________
wu-systems.at - [ MODs ] || [ Addons ] || [ Snippets ] || [ Translations ]
User avatar
WileCoyote
Registered User
 
Posts: 362
Joined: Sun Jan 15, 2006 7:37 am
Location: Austria
Name: Wolfgang

Re: Fix for forum_last_post_ not updating error.

New postby Leinad4Mind » Tue Jul 26, 2011 4:43 pm

"I'm very surprised nobody haven't observed that after send edited post, column of "forum last post" doesn't update."

In my side, it's all fine. The time is changed to the last edit time. I can't see the problem you're talking about...
Wanna help on phpBB? I can do for you:
- Forum installations
- MOD installations
- Updates installations, Some Tweaks and Bug Fix's
If you're interested on my services PM or email me!
User avatar
Leinad4Mind
Registered User
 
Posts: 534
Joined: Sun Jun 01, 2008 11:08 pm

Re: Fix for forum_last_post_ not updating error.

New postby WileCoyote » Thu Sep 08, 2011 2:57 am

Turn on debug mode go to Support Toolkit and reparse BBCodes then you should see the error i'm talking about
Regards
WileCoyote
____________________________________________________________
wu-systems.at - [ MODs ] || [ Addons ] || [ Snippets ] || [ Translations ]
User avatar
WileCoyote
Registered User
 
Posts: 362
Joined: Sun Jan 15, 2006 7:37 am
Location: Austria
Name: Wolfgang

Re: Fix for forum_last_post_ not updating error.

New postby Leinad4Mind » Tue Sep 27, 2011 2:49 pm

You're right. It has a bug! After reparse it change the forum last post time. Like someone post something...

For reparse I need to disable it... always ^^
Wanna help on phpBB? I can do for you:
- Forum installations
- MOD installations
- Updates installations, Some Tweaks and Bug Fix's
If you're interested on my services PM or email me!
User avatar
Leinad4Mind
Registered User
 
Posts: 534
Joined: Sun Jun 01, 2008 11:08 pm

Re: Fix for forum_last_post_ not updating error.

New postby pawelooss » Tue Sep 27, 2011 5:44 pm

Maybe adding this somewhere before will help?
Code: Select all
   $data['poster_colour'] = (isset($data['poster_colour'])) ? $data['poster_colour'] : '';

Unless a modification has been running well without my "fix". That would be good. :D
phpBB3 fan! ;)
pawelooss
Registered User
 
Posts: 48
Joined: Wed Nov 04, 2009 8:26 pm

Re: Fix for forum_last_post_ not updating error.

New postby WileCoyote » Tue Sep 27, 2011 6:03 pm

I'll give it a try. But not today ^^
Regards
WileCoyote
____________________________________________________________
wu-systems.at - [ MODs ] || [ Addons ] || [ Snippets ] || [ Translations ]
User avatar
WileCoyote
Registered User
 
Posts: 362
Joined: Sun Jan 15, 2006 7:37 am
Location: Austria
Name: Wolfgang

Re: Fix for forum_last_post_ not updating error.

New postby WileCoyote » Wed Sep 28, 2011 3:35 pm

The error message when reparsing is gone. But there is another issue with reparsing. After reparsing every last posting in every topic on every forum is set to the time when reparsing occurs. To fix this we must also add to the edit in includes/function_posting.php

Code: Select all
        If (defined('IN_STK'))
        {
            return;
        }

After adding the lines mentioned above and the fix from pawelooss the edit for includes/function_posting.php should look like

Code: Select all
    // Start : Mark edited posts as unread MOD   
   if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic')
   {
        If (defined('IN_STK'))
        {
            return;
        }

        $data['poster_colour'] = (isset($data['poster_colour'])) ? $data['poster_colour'] : '';

      $sql_update_posts = 'UPDATE ' . POSTS_TABLE . '
            SET post_time = ' . $current_time . '
            WHERE post_id = ' . $data['post_id'] . '
               AND topic_id = ' . $data['topic_id'];
      $db->sql_query($sql_update_posts);

      $sql_update_topics = 'UPDATE ' . TOPICS_TABLE . '
            SET topic_last_post_time = ' . $current_time . '
            WHERE topic_id = ' . $data['topic_id'];
      $db->sql_query($sql_update_topics);           
   
      update_post_information('forum', $data['forum_id']);
      markread('post', $data['forum_id'], $data['topic_id'], $data['post_time']);

        $sql_update_forums = 'UPDATE ' . FORUMS_TABLE . '
                SET forum_last_post_time = ' . $current_time . ',
                    forum_last_post_id = ' . $data['post_id'] . ',
                    forum_last_post_subject = "' . $subject . '",
                    forum_last_poster_id = ' . $data['poster_id'] . ',
                    forum_last_poster_name = "' . $username . '",
                    forum_last_poster_colour = "' . $data['poster_colour'] . '"
                WHERE forum_id = ' . $data['forum_id'];
        $db->sql_query($sql_update_forums);
   }
    // End : Mark edited posts as unread MOD

To get everything working fine together it is also required to fix a problem in the reparsing function itself. For further details read the topic All message are by guest and the possible fix for the problem in the stk bugtracker reparse bbcode changes topic poster to guest.

I've tested the above code for includes/function_posting.php and the fix for the stk from the bugtracker on my local testing enviroment and it seems that all problems are solved now.
Regards
WileCoyote
____________________________________________________________
wu-systems.at - [ MODs ] || [ Addons ] || [ Snippets ] || [ Translations ]
User avatar
WileCoyote
Registered User
 
Posts: 362
Joined: Sun Jan 15, 2006 7:37 am
Location: Austria
Name: Wolfgang

Re: Fix for forum_last_post_ not updating error.

New postby kevinaf » Wed Nov 30, 2011 8:36 am

Hello i had the same problem when parsing bbcode.

All topic auteur titel are set to guest but that can be solved by : http://www.phpbb.com/customise/db/offic ... 65#p226665
And all the posting times are seem to be reset :roll:

i have de-install this mod, run the bbcode parser from stk again, execute the sql query but stil the time stamps of the posts are not correct.

Can someone please help me out with this please.
kevinaf
Registered User
 
Posts: 112
Joined: Tue Aug 12, 2008 9:45 am

Re: Fix for forum_last_post_ not updating error.

New postby kevinaf » Fri Dec 02, 2011 9:22 pm

Can undo the date settings that where done to the posts? Ore are the change for good in my database.
kevinaf
Registered User
 
Posts: 112
Joined: Tue Aug 12, 2008 9:45 am