FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » Insert a message into a thread (Can we add a message to the middle of a thread?)
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Insert a message into a thread [message #169259] Sat, 14 September 2013 18:37 Go to next message
Parrot
Messages: 32
Registered: July 2013
Location: US
Karma: 1
Member
Can we insert a message to the middle of an existing thread (topic)?

Or can we change the sequence of individual messages?

Or can we change the date on a message so FF will sort it into the wanted order? (My guess is that this is the most likely solution.)


(This is needed where a thread has messages with dated reports, and we find one that should be inserted before some of the existing messages.)

I looked at the message date field in phpMyAdmin, but the date encoding is not obvious. I'd also be concerned about such a change breaking unknown FF functions.

So, can this be done? And if so, how.

Thanks.
Re: Insert a message into a thread [message #169261 is a reply to message #169259] Sun, 15 September 2013 07:26 Go to previous messageGo to next message
naudefj is currently offline  naudefj   
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
This is an unusual request, but it should be quite easy to do if you update the DB directly.

Possible solution:
* Edit src/msg.php.t
* Change 'ORDER BY id' to 'ORDER BY post_stamp';
* Change 'ORDER BY m.id' to 'ORDER BY m.post_stamp';
* Go the the Theme Manager ACP and recompile your themes.

To change the date of a message:
* UPDATE fud30_msg set post_stamp = ... where id = ....

Date conversion:
SQL> SELECT post_stamp, FROM_UNIXTIME(post_stamp), UNIX_TIMESTAMP('2013-09-15 03:26:41') from fud30_msg where id = 169261;
1379230001	2013-09-15 03:26:41	1379230001

Re: Insert a message into a thread [message #169263 is a reply to message #169261] Sun, 15 September 2013 12:27 Go to previous messageGo to next message
Parrot
Messages: 32
Registered: July 2013
Location: US
Karma: 1
Member
Thanks. I'll try it as soon as I get back tomorrow. Can't wait.

Curious: Why not just change the message ID and leave everything else alone?

Example:
    The entire board has message IDs up to 500.
    The last three messages in the particular thread (topic) are 444, 445, and 499.
    A new message must be inserted between 444 and 445.

Can we:
    Add the new message to the end of the thread, which creates new message 501.
    Assign a new ID to 445, creating 502.
    Assign a new ID to 499, creating 503.
Would that put them in the correct order?

If it's not easy or safe to mess with message IDs, can we:
    Use the Reply button to post the contents of the new message to the end of the thread, creating 501.
    Use the Reply button to add a new message, which will become 502.
    Copy and paste the contents of 445 into the new 502, and post it.
    Delete 445.
    Use the Reply button to add a new message, which will become 503.
    Copy and paste the contents of 449 into the new 503, and post it.
    Delete 449.
Would that low-tech method work?
.
Re: Insert a message into a thread [message #169270 is a reply to message #169263] Mon, 16 September 2013 17:08 Go to previous messageGo to next message
naudefj is currently offline  naudefj   
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Not all databases will allow you to update the primary key. If yours do, create a test message, record its ID and delete it. You can now use this ID to perform the swap operation between messages X and Y:

UPDATE fud30_msg set id = [TEST_MSG_ID] where id = [X];
UPDATE fud30_msg set id = [X] where id = [Y];
UPDATE fud30_msg set id = [Y] where id = [TEST_MSG_ID];

Let us know if it works.
Re: Insert a message into a thread [message #169273 is a reply to message #169270] Mon, 16 September 2013 18:15 Go to previous messageGo to next message
Parrot
Messages: 32
Registered: July 2013
Location: US
Karma: 1
Member

Thanks. I get the idea and can try that, but first...

There may be a way that (a) is suitable for frequent use, and (b) can be used by a moderator/administrator who will not have server access to edit the database.


Possible solution:

. . Example: A topic has two messages. Let's insert a new message between them.
    1. Move the first message to a new topic, creating the new topic in the move process.

    2. Post a Reply in the new topic, which is the content to be inserted. That becomes the second message in the new topic.

    3. Post a another Reply in the new topic, copying and pasting the contents of the old topic's last message. That's the new topic's third message.

    4. Delete the old topic.

    5. Smile.

Comment: Step three does not Move the last message of the old topic into the new topic. Instead, it copies-and-pastes the text into a new-topc Reply. That's because Moving a message into an existing topic does not add it to the end but replaces all existing messages in the target topic. Er, don't ask how I found out :)


Re: Insert a message into a thread [message #169291 is a reply to message #169273] Thu, 19 September 2013 03:22 Go to previous messageGo to next message
Parrot
Messages: 32
Registered: July 2013
Location: US
Karma: 1
Member
The above approach works.
Re: Insert a message into a thread [message #169301 is a reply to message #169291] Fri, 20 September 2013 16:07 Go to previous message
naudefj is currently offline  naudefj   
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Great, thanks for sharing with us!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to Delete ALL Unconfirmed Users?
Next Topic: Reset admin password from database
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 12 21:05:02 GMT 2024

Total time taken to generate the page: 0.04360 seconds