HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Nice Module!

R_JR_J Ex-FanboyMunich Admin

I like the idea very much and - don't ask me why - have taken a look at the code (always eager to learn).

At first I didn't understood what's happening at Gdn::Set and Gdn:Get but then I understood that you are using the cache to store todays birthdays, which is a great idea, so that the db doesn't need to be queried all the time. Hopefully I can use that in one of my plugins B)

I was surprised you've not used the query builder. I would have filtered out the system user already in the sql like that (and inserted a Today var)

    protected function GetBirthdays() {
        $Birthdays = json_decode(Gdn::Get('BirthdayModule.Birthdays'));
        $Today = date('Y-m-d');
        if ($Birthdays && $Birthdays[0] == $Today) {
            return $Birthdays[1];
        $Birthdays = Gdn::SQL()
            ->Where('UserID <>', Gdn::UserModel()->GetSystemUserID())
            ->Where('DateOfBirth', $Today)
        $Birthdays = ConsolidateArrayValuesByKey($Birthdays, 'UserID');
        Gdn::Set('BirthdayModule.Birthdays', json_encode(array($Today, $Birthdays)));
        return $Birthdays;

Actually, that's lie: I would have forgotten the system user ;)


  • Options
    R_JR_J Ex-Fanboy Munich Admin

    By the way: if you really think another plugin is needed (ProfileExtender in this case) you can add 'RequiredPlugins' => array('ProfileExtender' => '3.0'), to your PluginInfo array. But I guess you already knew that and I think it is better to not use it in this context, because DateOfBirth is a standard column and ProfileExtender is only one way to fill that column.

    And another "By the way": since I'm hanging around here, I've been wondering why there are no new developers/active community members/plugin contributors joining this community. Glad you are here at last :D

  • Options

    Thanks for the suggestions!

    I used a "raw" query as I needed DATE_FORMAT to filter out the year (otherwise it will only work on the actual date of birth ;) )
    But I could use Where() with the third and fourth parameter to prevent escaping, so it was probably just lazyness.
    Will use the query builder in the next revision.

    Another thing I would like to incorporate is birthdays on the 29.2.

    Right now it shows the birthdays in GMT, which is not really a problem for my community, as the users are all based in GMT+1, but in other timezones it can be up to 12 hours off.

    I thought about using Garden.GuestTimeZone, but that might not be set on every vanilla installation.
    It would be ideal to use the Houroffset to calculate the birthday for every user individually, but that would make the query overly complex :/

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    @Bleistivt said:
    I used a "raw" query as I needed DATE_FORMAT to filter out the year (otherwise it will only work on the actual date of birth ;) )

    Doh! And I thought my solution was elegant :lol:

    I also spent a few moments on thinking about different time zones, but you would have to cache each query by timezone which might simply be to much work for a simple module.

  • Options
    hgtonighthgtonight ∞ · New Moderator

    I am wondering why you put the birthday cache on the controller rather than in the module itself.

    Setting it in the data portion of the controller makes it visible in the json/xml view. Something to consider. That is my only concern.

    Nice idea and implemented pretty cleanly. :)

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    Would be nice to have something like that here... no one said happy b day to me last time.. :(

  • Options
    whu606whu606 I'm not a SuperHero; I just like wearing tights... MVP


    Are you Yaya Toure in disguise? ;)

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    Well, if I was I would not be a midfielder... >:)

Sign In or Register to comment.