SimplePortal

Customization => Custom Coding => Topic started by: Manu on November 22, 2009, 05:36:01 AM

Title: Exclude banned members in "Top Poster" Block
Post by: Manu on November 22, 2009, 05:36:01 AM
Hi,

is there a way to exclude banned members in the top poster block?
I know I could use other options for the top poster block, like "This week" but we want to show "All Time", but our problem is, the member at position 1 is a banned member.

Is there a way not to show banned members in this block?
Title: Re: Exclude banned members in "Top Poster" Block
Post by: Manu on December 03, 2009, 03:17:31 PM
Any idea?  :-[
Title: Re: Exclude banned members in "Top Poster" Block
Post by: Nathaniel on December 10, 2009, 07:56:57 PM
Moved to the custom coding board.


This edit is for SMF1.1 only.

Code: ("Find (Sources/PortalBlocks.php)") [Select]
      $request = db_query("
         SELECT
            mem.ID_MEMBER, mem.realName, COUNT(*) as posts,
            mem.avatar, a.ID_ATTACH, a.attachmentType, a.filename
         FROM {$db_prefix}messages AS m
            LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
            LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = m.ID_MEMBER)
         WHERE m.posterTime > $start_time
            AND m.ID_MEMBER != 0
         GROUP BY mem.ID_MEMBER
         ORDER BY posts DESC
         LIMIT $limit", __FILE__, __LINE__);
   }
   else
   {
      $request = db_query("
         SELECT
            m.ID_MEMBER, m.realName, m.posts, m.avatar,
            a.ID_ATTACH, a.attachmentType, a.filename
         FROM {$db_prefix}members as m
            LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = m.ID_MEMBER)
         ORDER BY posts DESC
         LIMIT $limit", __FILE__, __LINE__);
   }

Code: ("Replace") [Select]
      $request = db_query("
         SELECT
            mem.ID_MEMBER, mem.realName, COUNT(*) as posts,
            mem.avatar, a.ID_ATTACH, a.attachmentType, a.filename
         FROM {$db_prefix}messages AS m
            LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
            LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = m.ID_MEMBER)
         WHERE m.posterTime > $start_time
            AND m.ID_MEMBER != 0
            AND mem.is_activated < 10
         GROUP BY mem.ID_MEMBER
         ORDER BY posts DESC
         LIMIT $limit", __FILE__, __LINE__);
   }
   else
   {
      $request = db_query("
         SELECT
            m.ID_MEMBER, m.realName, m.posts, m.avatar,
            a.ID_ATTACH, a.attachmentType, a.filename
         FROM {$db_prefix}members as m
            LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = m.ID_MEMBER)
         WHERE mem.is_activated < 10
         ORDER BY posts DESC
         LIMIT $limit", __FILE__, __LINE__);
   }
Title: Re: Exclude banned members in "Top Poster" Block
Post by: Manu on December 11, 2009, 06:51:07 PM
Thx for your help, but when I insert the code you posted, I get this error message when I try to set the block to "All Time"

Quote
Unknown column 'mem.is_activated' in 'where clause'
File: /is/htdocs/.../.../.../Sources/PortalBlocks.php
Line: 538

 :-[
Title: Re: Exclude banned members in "Top Poster" Block
Post by: Nathaniel on December 11, 2009, 06:54:19 PM
Whoops, the members table has a different prefix for the second query, try the replace code below.

Code: [Select]
      $request = db_query("
         SELECT
            mem.ID_MEMBER, mem.realName, COUNT(*) as posts,
            mem.avatar, a.ID_ATTACH, a.attachmentType, a.filename
         FROM {$db_prefix}messages AS m
            LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
            LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = m.ID_MEMBER)
         WHERE m.posterTime > $start_time
            AND m.ID_MEMBER != 0
            AND mem.is_activated < 10
         GROUP BY mem.ID_MEMBER
         ORDER BY posts DESC
         LIMIT $limit", __FILE__, __LINE__);
   }
   else
   {
      $request = db_query("
         SELECT
            m.ID_MEMBER, m.realName, m.posts, m.avatar,
            a.ID_ATTACH, a.attachmentType, a.filename
         FROM {$db_prefix}members as m
            LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = m.ID_MEMBER)
         WHERE m.is_activated < 10
         ORDER BY posts DESC
         LIMIT $limit", __FILE__, __LINE__);
   }
Title: Re: Exclude banned members in "Top Poster" Block
Post by: Manu on December 11, 2009, 07:02:09 PM
Oops  :-[

Now I get this message when I want to enter the Adminsection

Quote
Warning:  Unexpected character in input:  ''' (ASCII=39) state=1 in /is/htdocs/.../.../.../Sources/PortalBlocks.php on line 1264

Parse error:  syntax error, unexpected '/' in /is/htdocs/.../.../.../Sources/PortalBlocks.php on line 1264
Title: Re: Exclude banned members in "Top Poster" Block
Post by: Nathaniel on December 11, 2009, 07:08:27 PM
What exactly is located on line 1264 of your PortalBlocks.php file?
Title: Re: Exclude banned members in "Top Poster" Block
Post by: Manu on December 12, 2009, 04:33:46 AM
Line 1264

Code: [Select]
<form action="', $boardurl, '/SSI.php?ssi_function=pollVote" method="post" accept-charset="', $context['character_set'], '">
Title: Re: Exclude banned members in "Top Poster" Block
Post by: Nathaniel on December 12, 2009, 08:19:28 PM
Hmm, I'm not sure why that line would be causing that error, can you attach your entire PortalBlocks.php file?
Title: Re: Exclude banned members in "Top Poster" Block
Post by: Manu on October 28, 2011, 05:09:55 AM

Hmm, I'm not sure why that line would be causing that error, can you attach your entire PortalBlocks.php file?
Sorry, I made a mistake by adding the code  :-[

Is it possible to provide me with the code for SMF 2.0.1?
I'm working on the upgrade and need to exclude banned members on the Top-Poster Block :)
Title: Re: Exclude banned members in "Top Poster" Block
Post by: ccbtimewiz on October 28, 2011, 04:18:28 PM
Attach ./Sources/PortalBlocks.php
Title: Re: Exclude banned members in "Top Poster" Block
Post by: Manu on November 01, 2011, 02:59:08 PM
Attach ./Sources/PortalBlocks.php
The code Nathaniel showed here is only for installed portals on SMF 1.x.x :)
I need it for SMF 2.x.x :)
Title: Re: Exclude banned members in "Top Poster" Block
Post by: ccbtimewiz on November 01, 2011, 03:18:22 PM
Yes, I am aware of this. Please attach your file so I can make the edits for SMF 2.0
Title: Re: Exclude banned members in "Top Poster" Block
Post by: Manu on November 05, 2011, 08:02:10 AM
Yes, I am aware of this. Please attach your file so I can make the edits for SMF 2.0
Here's my actual PortalBlocks.php thanks for your help :)
Title: Re: Exclude banned members in "Top Poster" Block
Post by: ccbtimewiz on November 05, 2011, 02:35:26 PM
Find:
Code: [Select]
WHERE m.poster_time > {int:start_time}
AND m.id_member != 0

Replace with:
Code: [Select]
WHERE m.poster_time > {int:start_time}
AND m.id_member != 0
                                AND m.is_activated < 10
SimplePortal 2.3.8 © 2008-2024, SimplePortal