Advertisement:

Author Topic: Ignored users: hiding posts on Recent.template.php  (Read 298 times)

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,746
  • Master of BBC Abuse
Ignored users: hiding posts on Recent.template.php
« on: September 16, 2019, 09:27:40 PM »
Just wondering how difficult it would be to transfer the logic/conditionals from Display.template.php to Recent.template.php, so that posts by really irritating mongrels that you are trying to ignore would have their content hidden on both templates. I'm thinking of action=recent, not the unread and/or new replies functions.

I know I can swap the javascript over and add the required id's to whatever post elements on Recent. That should be straightforward. I'm just wondering if Recent can access the ignored logic that Display uses:

Code: [Select]
// Are we ignoring this message?
if (!empty($message['is_ignored']))
{
$ignoring = true;
$ignoredMsgs[] = $message['id'];
}

Can this be done just in the template? Or is it going to need a Sources hack as well?

Online Sesquipedalian

  • The Mad Doctor
  • Lead Developer
  • Sr. Member
  • *
  • Posts: 969
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: Ignored users: hiding posts on Recent.template.php
« Reply #1 on: September 18, 2019, 10:20:21 AM »
I'm on my phone at the moment, so I can't verify, but I'm sure you would need to make changes to the query in Sources if you want that to work out properly.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Offline Suki

  • Kaizoku Jotei
  • Developer
  • SMF Super Hero
  • *
  • Posts: 15,548
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: Ignored users: hiding posts on Recent.template.php
« Reply #2 on: September 18, 2019, 10:32:54 AM »
For 2.1?

$context['posts'] holds the following user info:

Code: (php) [Select]
'first_poster' => array(
'id' => $row['id_first_member'],
'name' => $row['first_poster_name'],
'href' => empty($row['id_first_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_first_member'],
'link' => empty($row['id_first_member']) ? $row['first_poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_first_member'] . '">' . $row['first_poster_name'] . '</a>'
),
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'
),

When that var gets iterated you can use an in_array on $user_info['ignoreusers'] to skip printing that message.

Code: (php) [Select]
if (in_array($post['poster']['id'], $user_info['ignoreusers']))
continue;

Should be pretty similar for 2.0.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,746
  • Master of BBC Abuse
Re: Ignored users: hiding posts on Recent.template.php
« Reply #3 on: September 18, 2019, 04:39:46 PM »
Cool. I'll mess around with it once I knock off a few other things. I was thinking of 2.0.x, but as you say it shouldn't be much different. Might be a good mod for both versions.