Skip to content

Commit

Permalink
Merge pull request #7722 from Sesquipedalian/last_edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sesquipedalian authored Sep 24, 2023
2 parents 511ab57 + cc20b0f commit 3ec6008
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions Sources/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,9 +748,11 @@ function Post($post_errors = array())
// When was it last modified?
if (!empty($row['modified_time']))
{
$modified_reason = $row['modified_reason'];
$context['last_modified'] = timeformat($row['modified_time']);
$context['last_modified_reason'] = censorText($row['modified_reason']);
$context['last_modified_text'] = sprintf($txt['last_edit_by'], $context['last_modified'], $row['modified_name']) . empty($row['modified_reason']) ? '' : ' ' . $txt['last_edit_reason'] . ': ' . $row['modified_reason'];
$context['last_modified_name'] = $row['modified_name'];
$context['last_modified_text'] = sprintf($txt['last_edit_by'], $context['last_modified'], $row['modified_name']) . (empty($row['modified_reason']) ? '' : ' ' . sprintf($txt['last_edit_reason'], $row['modified_reason']));
}

// Get the stuff ready for the form.
Expand Down Expand Up @@ -1612,25 +1614,14 @@ function ($val) use ($smcFunc)
'attributes' => array(
'size' => 80,
'maxlength' => 80,
'value' => isset($context['last_modified_reason']) ? $context['last_modified_reason'] : '',
// If same user is editing again, keep the previous edit reason by default.
'value' => isset($modified_reason) && isset($context['last_modified_name']) && $context['last_modified_name'] === $user_info['name'] ? $modified_reason : '',
),
// If message has been edited before, show info about that.
'after' => empty($context['last_modified_text']) ? '' : '<div class="smalltext em">' . $context['last_modified_text'] . '</div>',
),
);

// If this message has been edited in the past - display when it was.
if (!empty($context['last_modified_text']))
{
$context['posting_fields']['modified_time'] = array(
'label' => array(
'text' => $txt['modified_time'],
),
'input' => array(
'type' => '',
'html' => !empty($context['last_modified_text']) ? ltrim(preg_replace('~<span[^>]*>[^<]*</span>~u', '', $context['last_modified_text']), ': ') : '',
),
);
}

// Prior to 2.1.4, the edit reason was not handled as a posting field,
// but instead using a hardcoded input in the template file. We've fixed
// that in the default theme, but to support any custom themes based on
Expand Down

0 comments on commit 3ec6008

Please sign in to comment.