[dw-free] /birthdays.bml still calling friends
[commit: http://hg.dwscoalition.org/dw-free/rev/62a5a71da77a]
http://bugs.dwscoalition.org/show_bug.cgi?id=851
Update /birthdays to work in our post-WTF world.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=851
Update /birthdays to work in our post-WTF world.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- htdocs/birthdays.bml
- htdocs/birthdays.bml.text
-------------------------------------------------------------------------------- diff -r dc38b4979caa -r 62a5a71da77a htdocs/birthdays.bml --- a/htdocs/birthdays.bml Mon May 18 00:58:43 2009 +0000 +++ b/htdocs/birthdays.bml Mon May 18 01:01:58 2009 +0000 @@ -21,13 +21,13 @@ body<= } my $body; - my $lastmon = 0; $body .= '<?p '; if ($u) { $body .= BML::ml('.description.others', { user => LJ::ljuser($u) }); } else { $body .= $ML{'.description'}; + $u = $remote; # work with the logged in user } $body .= ' p?>'; @@ -37,30 +37,42 @@ body<= $body .= LJ::html_submit(undef, $ML{'.view'}); $body .= "</form>"; - my @bdays; + # merge watched_userids & trusted_userids + my %friends; # using a hash avoids duplicate elements + map { $friends{$_}++ } ($u->watched_userids, $u->trusted_userids); + my $nb = LJ::User->next_birthdays( keys %friends ); + # returns ref to hash of form (userid => date) + my $uids = LJ::load_userids( keys %$nb ); + # returns ref to hash of form (userid => user object) - if (defined $u) { - @bdays = $u->get_friends_birthdays(full => 1); - } else { - @bdays = $remote->get_friends_birthdays(full => 1); + my %timedata; + while ( my ($id, $u) = each %$uids ) { + next unless $u->is_personal && $u->can_show_bday; + my $date = $nb->{$id} or next; + # need numeric month and day + my @lt = localtime( $date ); + my $month = $lt[4] + 1; + my $day = $lt[3]; + $timedata{"$date.$id"} = [$month, $day, $u]; } + # hash slice for array sorted by date + my @bdays = @timedata{ sort keys %timedata }; + my $lastmon = 0; + foreach my $bday (@bdays) { - LJ::text_out(\$bday->[2]); + my ($mymon, $myday, $u) = @$bday; + my $name = $u->name_html; - if ($bday->[0] != $lastmon) { - if ($lastmon) { $body .= "</ul>\n"; } - $lastmon = $bday->[0]; - $body .= "<?h1 " . LJ::Lang::month_long($lastmon) . " h1?><ul>\n"; - } + if ( $mymon != $lastmon ) { + $body .= "</ul>\n" if $lastmon; + $lastmon = $mymon; + $body .= "<?h1 " . LJ::Lang::month_long_ml( $mymon ) . " h1?><ul>\n"; + } - my $day = sprintf("%2s", $bday->[1]); - $day =~ s/ / /; - - my $friendu = LJ::load_user($bday->[2]); - my $name = LJ::ehtml($friendu->{'name'}); - $body .= "<b><tt>$day</tt></b>: " . LJ::ljuser($friendu) . " - $name<br />\n"; - } + $body .= sprintf( "<b><tt>%02d</tt></b>: ", $myday ); + $body .= LJ::ljuser( $u ) . " - $name<br />\n"; + } if (@bdays) { $body .= "</ul>\n"; diff -r dc38b4979caa -r 62a5a71da77a htdocs/birthdays.bml.text --- a/htdocs/birthdays.bml.text Mon May 18 00:58:43 2009 +0000 +++ b/htdocs/birthdays.bml.text Mon May 18 01:01:58 2009 +0000 @@ -1,7 +1,7 @@ ;; -*- coding: utf-8 -*- -.description=Below are the birthdays for everyone that you list as a friend. +.description=Below are the birthdays for everyone that is in your circle. -.description.others=Below are the birthdays for everyone that [[user]] lists as a friend. +.description.others=Below are the birthdays for everyone that is in [[user]]'s circle. .error.badstatus=[[user]] is not a currently active account. @@ -9,7 +9,7 @@ .findothers=If you would like to see the birthdays of the friends of another user, or of the members of a community, enter a username below: -.nobirthdays=There are no birthdays to display. This happens when a user doesn't have anyone added to their Friends list, or if none of the user's friends list their birthday publically. +.nobirthdays=<b>There are no birthdays to display.</b> This happens when a user doesn't have anyone added to their access or subscription lists, or if no one in the user's circle has made their birthday public. .title=Birthdays --------------------------------------------------------------------------------