Icy Phoenix

     
 


This forum is locked: you cannot post, reply or edit topics.  This topic is locked: you cannot edit posts or make replies. 
Page 1 of 1
 
 
Reply with quote Download Post 
Post Exclude banned Calendar Bdays? 
 
Hey all,

I picked up an old project again and I don't really see how I can exclude birthdays of banned users from showing up.

The function file content I'm looking at is this part:
Code: [Download] [Hide] [Select]
/* Generates the list of birthdays for the given date
*/
function generate_birthday_list( $day, $month, $year )
{
    global $db, $user, $config;

    $birthday_list = "";
    if ($config['load_birthdays'] && $config['allow_birthdays'])
    {
        $sql = 'SELECT user_id, username, user_colour, user_birthday
                FROM ' . USERS_TABLE . "
                WHERE user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $day, $month)) . "%'
                AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result))
        {
            // TBD TRANSLATION ISSUE HERE!!!
            $birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
            if ($age = (int) substr($row['user_birthday'], -4))
            {
                // TBD TRANSLATION ISSUE HERE!!!
                $birthday_list .= ' (' . ($year - $age) . ')';
            }
        }
        if( $birthday_list != "" )
        {
            // TBD TRANSLATION ISSUE HERE!!!
            $birthday_list = $user->lang['BIRTHDAYS'].": ". $birthday_list;
        }
        $db->sql_freeresult($result);
    }

    return $birthday_list;
}


I did manage to exclude them from showing in my portals but the code used there is quite different

If anyone has any idea it would make me very happy because this calendar mod has been abandoned a long time ago.
 




____________
www.DutchaGoGo.com (development/under construction ...Forever?¿?)
 
Joshua203Send private messageVisit poster's website  
Back to topPage bottom
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.

Support us
 
Reply with quote Download Post 
Post Re: Exclude banned Calendar Bdays? 
 
Well, I am not the best with php but can you play with this

Code: [Download] [Hide] [Select]
AND user_active = 1


Because banned users should have 0 , I guess
 




____________
TheSteffen
Often SEARCH is the quickest way to get support.
IcyPhoenix German Support
 
TheSteffenSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Exclude banned Calendar Bdays? 
 
Thanks for the suggestion Steffen but this won't work on phpbb .. as far as I know this does not exist in my DB
 




____________
www.DutchaGoGo.com (development/under construction ...Forever?¿?)
 
Joshua203Send private messageVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Exclude banned Calendar Bdays? 
 
Hehehe, on phpBB3 you should have a look into phpbb_banlist => ban_userid

But I dont know how to change your code  

EDIT: Maybe you can combine with this mod

Hide Banned Members From Memberlist on phpBB

OPEN memberlist.php
FIND
Code: [Download] [Hide] [Select]
// Get us some users :D

Add before
Code: [Download] [Hide] [Select]
//Begin: banned users hidden in memberlist_body
$sql = 'SELECT ban_userid
        FROM ' . BANLIST_TABLE . '
        WHERE ban_userid <> 0
        AND (ban_end >= ' . time() . ' OR ban_end = 0)';
$result = $db->sql_query($sql);      

$ban_list[] = array(0);    
while ($row = $db->sql_fetchrow($result))
{
    $ban_list[] = $row['ban_userid'];
}  
$db->sql_freeresult($result);
//End: banned users hidden in memberlist_body


FIND
Code: [Download] [Hide] [Select]
                    $user_list[] = (int) $row['user_id'];

REPLACE WITH
Code: [Download] [Hide] [Select]
                if (!in_array((int) $row['user_id'], $ban_list))//ban_list test line
                {
                    $user_list[] = (int) $row['user_id'];
                }  

 




____________
TheSteffen
Often SEARCH is the quickest way to get support.
IcyPhoenix German Support
 
TheSteffenSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Exclude banned Calendar Bdays? 
 
Thanks for the suggestion Steffen, however after looking at your suggestion I took another look at what I did to the portal in the past and maybe I got it fixed now ... the calendar looks a lot cleaner now but not completely missing birthdays.

I still have to test and investigate but I was so excited that I wanted to reply  

It would be great if anyone could tell me "yeah correct" or "no stupid!" so below is what I the changed code....

Code: [Download] [Hide]
  1. /* Generates the list of birthdays for the given date 
  2. */ 
  3. function generate_birthday_list( $day, $month, $year ) 
  4.     global $db, $user, $config; 
  5.  
  6.     $birthday_list = ""; 
  7.     if ($config['load_birthdays'] && $config['allow_birthdays']) 
  8.     { 
  9.         $sql = 'SELECT user_id, username, user_colour, user_birthday 
  10.                 FROM ' . USERS_TABLE . ' 
  11.                 LEFT JOIN ' . BANLIST_TABLE . " b ON (user_id = b.ban_userid) 
  12.                 WHERE (b.ban_id IS NULL 
  13.                 OR b.ban_exclude = 1) 
  14.                 AND user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $day, $month)) . "%' 
  15.                 AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; 
  16.         $result = $db->sql_query($sql); 
  17.         while ($row = $db->sql_fetchrow($result)) 
  18.         { 
  19.             // TBD TRANSLATION ISSUE HERE!!! 
  20.             $birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); 
  21.             if ($age = (int) substr($row['user_birthday'], -4)) 
  22.             { 
  23.                 // TBD TRANSLATION ISSUE HERE!!! 
  24.                 $birthday_list .= ' (' . ($year - $age) . ')'; 
  25.             } 
  26.         } 
  27.         if( $birthday_list != "" ) 
  28.         { 
  29.             // TBD TRANSLATION ISSUE HERE!!! 
  30.             $birthday_list = $user->lang['BIRTHDAYS'].": ". $birthday_list; 
  31.         } 
  32.         $db->sql_freeresult($result); 
  33.     } 
  34.  
  35.     return $birthday_list; 


changes:
- in line 5 I replaced the " by a '
- line 6, 7 and 8 are newly added
- in line 9 I replaced the WHERE into an AND

I truly can't believe I didn't goof anything up so please anyone judge it  
 




____________
www.DutchaGoGo.com (development/under construction ...Forever?¿?)
 
Joshua203Send private messageVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Exclude Banned Calendar Bdays? 
 
$sql = 'SELECT user_id, username, user_colour, user_birthday
                FROM ' . USERS_TABLE . '
                LEFT JOIN ' . BANLIST_TABLE . " b ON (user_id = b.ban_userid)
                WHERE (b.ban_id IS NULL
                OR b.ban_exclude = 1)
                AND user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $day, $month)) . "%'
                AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';

maybe just
AND user_id NOT in (SELECT ban_userid FROM " . BANLIST_TABLE . ")
I don't have mysql here, so I can't "explain" queries but I think your one is better.
 



 
InformproSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Exclude banned Calendar Bdays? 
 
Thanks for another suggestion Informpro, yours does look alittle more "straight to the point"

If my own try starts showing flaws I will certainly try your idea!

Stuff I mostly doubt are in the use of the quotes and double quotes, I know almost nothing about all this stuff .. it's all just copy, paste, try to adjust and wait for errors to pop up for me TBH  
 




____________
www.DutchaGoGo.com (development/under construction ...Forever?¿?)
 
Joshua203Send private messageVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Exclude Banned Calendar Bdays? 
 
There's actually too many way to achieve that. If you can run EXPLAIN on these queries, you'll have a better idea of the performance impact. You could also select in before (=> (SELECT bla FROM ...) as B), etc, etc.
 



 
InformproSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Exclude banned Calendar Bdays? 
 
I'll mark this solved before I get even more confused  

Thanks for all your replies guys
 




____________
www.DutchaGoGo.com (development/under construction ...Forever?¿?)
 
Joshua203Send private messageVisit poster's website  
Back to topPage bottom
This forum is locked: you cannot post, reply or edit topics.  This topic is locked: you cannot edit posts or make replies.  Page 1 of 1
 


Display posts from previous:    

HideWas this topic useful?

Link this topic
URL
BBCode
HTML




 
Permissions List
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events


  

 

  cron