"Edited by" message

Post Reply
User avatar
kinerity
Administrator
Administrator
Posts: 4
Joined: Fri Jul 26, 2019 7:47 pm
Name: Kailey Truscott

"Edited by" message

Post by kinerity » Tue Aug 13, 2019 7:12 pm

The default behavior of edits, even with the setting on in the ACP, is not to display an edit time if the edit is to the most recent post or if it was an admin/mod edit without an edit reason being given. I wasn't happy with not knowing (or showing) all edits, so I made the following changes to /includes/functions_posting.php to log and display all edits - regardless of whether replies had been made or if it was an admin/mod editing the post.

OPEN: /includes/functions_posting.php

FIND:

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']
				));
			}

			if (!isset($sql_data[POSTS_TABLE]['sql']))
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']
				));

			if (!isset($sql_data[POSTS_TABLE]['sql']))

Post Reply