Author Topic: Modify button for messages in topic search results  (Read 15116 times)

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 490
  • Gender: Female
Modify button for messages in topic search results
« on: October 06, 2017, 01:55:28 AM »
As an Admin I sometimes need to modify multiple messages in a single topic and while I can find the relevant messages using the search function I cannot modify them directly as the only button options available in each message are Reply, Quote and Notify.

Adding the Modify button to each displayed message only requires two minor code changes:

In ./Sources/Search.php
Code: [Select]
'can_mark_notify' => in_array($message['id_board'], $boards_can['mark_any_notify']) || in_array(0, $boards_can['mark_any_notify']) && !$context['user']['is_guest'],
Add After:
Code: [Select]
// Added 'can_modify' for use in search results.
'can_modify' => (!empty($message['is_locked']) || allowedTo('moderate_board')) && (allowedTo('modify_any') || (allowedTo('modify_replies') && $context['user']['started']) || (allowedTo('modify_own') && $message['id_member'] == $user_info['id'] && (empty($modSettings['edit_disable_time']) || !$message['approved'] || $message['poster_time'] + $modSettings['edit_disable_time'] * 60 > time()))),

In ./Themes/default/Search.template.php
Code: [Select]
if ($topic['can_reply'] || $topic['can_mark_notify'])
echo '
<div class="quickbuttons_wrap">
<ul class="reset smalltext quickbuttons">';

Add After:
Code: [Select]
// Added 'can_modify' to search results options.
// If they *can* modify?
if ($topic['can_modify'])
echo '
<li class="modify_button"><a href="', $scripturl, '?action=post;topic=', $topic['id'], ';msg=', $message['id'], '">', $txt['modify'], '</a></li>';

Life doesn't have to be perfect to be wonderful ...