How to see when a post was edited

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
User avatar
kamaleon
Registered User
Posts: 540
Joined: Tue Sep 09, 2014 9:47 am
Location: Barcelona

How to see when a post was edited

Post by kamaleon »

Hello,

I have enabled in Post settings the option to Display last edited time information, but when a user edits his post, it is not shown.

What am I doing wrong?

Thanks
This is a test signature. I hope you love it :D
User avatar
KaileyT
Community Team Member
Community Team Member
Posts: 2900
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: How to see when a post was edited

Post by KaileyT »

Code: Select all

// If edit reason is given always display edit info

// If editing last post then display no edit info
// If m_edit permission then display no edit info
// If normal edit display edit info

// Display edit info if edit reason given or user is editing his post, which is not the last within the topic.
Basically, the edit information is only shown if an edit reason is given or the post that is edited is not the last post in a topic. You can, however, change this with the code edit below.

In includes/functions_posting.php, around line 1627

Code: Select all

		case 'edit_topic':

			// If edit reason is given always display edit info

			// If editing last post then display no edit info
			// If m_edit permission then display no edit info
			// If normal edit display edit info

			// Display edit info if edit reason given or user is editing his post, which is not the last within the topic.
			if ($data_ary['post_edit_reason'] || (!$auth->acl_get('m_edit', $data_ary['forum_id']) && ($post_mode == 'edit' || $post_mode == 'edit_first_post')))
			{
				$data_ary['post_edit_reason']		= truncate_string($data_ary['post_edit_reason'], 255, 255, false);

				$sql_data[POSTS_TABLE]['sql']	= array(
					'post_edit_time'	=> $current_time,
					'post_edit_reason'	=> $data_ary['post_edit_reason'],
					'post_edit_user'	=> (int) $data_ary['post_edit_user'],
				);

				$sql_data[POSTS_TABLE]['stat'][] = 'post_edit_count = post_edit_count + 1';
			}
			else if (!$data_ary['post_edit_reason'] && $mode == 'edit' && $auth->acl_get('m_edit', $data_ary['forum_id']))
			{
				$sql_data[POSTS_TABLE]['sql'] = array(
					'post_edit_reason'	=> '',
				);
			}

			// If the person editing this post is different to the one having posted then we will add a log entry stating the edit
			// Could be simplified by only adding to the log if the edit is not tracked - but this may confuse admins/mods
			if ($user->data['user_id'] != $poster_id)
			{
				$log_subject = ($subject) ? $subject : $data_ary['topic_title'];
				$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_POST_EDITED', false, array(
					'forum_id' => $data_ary['forum_id'],
					'topic_id' => $data_ary['topic_id'],
					'post_id'  => $data_ary['post_id'],
					$log_subject,
					(!empty($username)) ? $username : $user->lang['GUEST'],
					$data_ary['post_edit_reason']
				));
			}
Replace with

Code: Select all

		case 'edit_topic':

			// If edit reason is given always display edit info

			// If editing last post then display no edit info
			// If m_edit permission then display no edit info
			// If normal edit display edit info

			// Display edit info if edit reason given or user is editing his post, which is not the last within the topic.
			$data_ary['post_edit_reason']		= truncate_string($data_ary['post_edit_reason'], 255, 255, false);

			$sql_data[POSTS_TABLE]['sql']	= array(
				'post_edit_time'	=> $current_time,
				'post_edit_reason'	=> $data_ary['post_edit_reason'],
				'post_edit_user'	=> (int) $data_ary['post_edit_user'],
			);

			$sql_data[POSTS_TABLE]['stat'][] = 'post_edit_count = post_edit_count + 1';

			// If the person editing this post is different to the one having posted then we will add a log entry stating the edit
			// Could be simplified by only adding to the log if the edit is not tracked - but this may confuse admins/mods
			$log_subject = ($subject) ? $subject : $data_ary['topic_title'];
			$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_POST_EDITED', false, array(
				'forum_id' => $data_ary['forum_id'],
				'topic_id' => $data_ary['topic_id'],
				'post_id'  => $data_ary['post_id'],
				$log_subject,
				(!empty($username)) ? $username : $user->lang['GUEST'],
				$data_ary['post_edit_reason']
			));
Kailey Truscott - Community Team
User avatar
kamaleon
Registered User
Posts: 540
Joined: Tue Sep 09, 2014 9:47 am
Location: Barcelona

Re: How to see when a post was edited

Post by kamaleon »

What does that code do? It always displays the time it was edited?

And if there is an update to phpBB, I will lose all that code, right?
This is a test signature. I hope you love it :D
User avatar
Mick
Support Team Member
Support Team Member
Posts: 22958
Joined: Fri Aug 29, 2008 9:49 am
Location: Watching cricket probably.

Re: How to see when a post was edited

Post by Mick »

kamaleon wrote:
Sat Sep 01, 2018 9:20 am
And if there is an update to phpBB, I will lose all that code, right?
Correct. If the snippet above doesn’t do what you want try making an extension request.
"The more connected we get the more alone we become" - Kyle Broflovski©
User avatar
david63
Registered User
Posts: 18851
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: How to see when a post was edited

Post by david63 »

You might like to try this extension - https://www.phpbb.com/customise/db/exte ... dit_log_2/
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: How to see when a post was edited

Post by 2600 »

I use that extension and it does a great job showing edits.
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
kamaleon
Registered User
Posts: 540
Joined: Tue Sep 09, 2014 9:47 am
Location: Barcelona

Re: How to see when a post was edited

Post by kamaleon »

Thanks guys, this is what I needed.
This is a test signature. I hope you love it :D
Post Reply

Return to “phpBB Custom Coding”