\n"; $body .= LJ::make_authas_select($remote, { 'authas' => $authasu->{user} }) . "\n"; $body .= LJ::html_hidden(keyword => $GET{keyword}) if $GET{keyword}; $body .= "\n\n"; $user ||= $authasu->{user}; $authasarg = "&authas=$authasu->{user}"; $authasarge = "&authas=$authasu->{user}"; } else { $authasu = $remote; } } # Now, whose memories page do we actually want to see? # - if 'user' is specified, we want to see theirs # (in this case, $user has already been set to that) # - if no 'user', but 'authas' is specified, we want to see authas's # (in this case, $user has been set to $authasu->{user} above # - if neither is specified, we want to see remote's: if ($user eq "" && defined $remote) { $user = $remote->{'user'}; } my $u = LJ::load_user($user); unless ($u) { # There is no 'authas' OR $remote. # If there's a 'user', that user doesn't exist. # Otherwise, complain about the absence of 'user' / suggest logging in. $title = $ML{'Error'}; $body = $user eq "" ? BML::ml('.login', { 'aopts' => 'href="/login.bml?ret=1"' }) : $ML{'error.username_notfound'}; return; } # owner if you've authed as them or you administrate them my $is_owner = $authasu && $user eq $authasu->{user} || LJ::can_manage_other($remote, $u); my $userid = $u->{'userid'}; if ($u->{'journaltype'} eq "R") { LJ::load_user_props($u, "renamedto"); return BML::redirect("/tools/memories.bml?user=$u->{'renamedto'}$authasarg"); } LJ::load_user_props($u, "opt_blockrobots") if $u->{'statusvis'} eq 'V'; unless ($u->{'statusvis'} eq 'V' && ! $u->{'opt_blockrobots'}) { $head = LJ::robot_meta_tags(); } if ($u->{'statusvis'} eq "S") { $title = $ML{'error.suspended.title'}; $body = "$LJ::SITENAME,'user'=>$user}) . " p?>"; return; } if ($u->{'statusvis'} eq "D") { $title = $ML{'error.deleted.title'}; $body = "$user}) . " p?>"; return; } if ($u->{'statusvis'} eq "X") { $title = $ML{'error.purged.title'}; $body = ""; return; } if (LJ::did_post()) { unless ($is_owner) { $title = $ML{'Error'}; $body = "\n"; return; } my @to_delete = (); foreach (keys %POST) { push @to_delete, $1 if /^select_mem_(\d+)$/; } unless (@to_delete) { $title = $ML{'Error'}; $body = ""; return; } # delete them! LJ::Memories::delete_by_id($authasu, \@to_delete); $title = $ML{'.delete.deleted.title'}; $body = " "href='./memories.bml?user=$authasu->{user}'" }) . " p?>"; return; } my %filters = ("all" => $ML{'.filter.all'}, "own" => BML::ml(".filter.own", { 'user' => $user }), "other" => $ML{'.filter.other'}); my $filter = $GET{'filter'} || "all"; unless (defined $filters{$filter}) { $filter = "all"; } my %sorts = ('memid' => $ML{'.sort.orderadded'}, 'des' => $ML{'.sort.description'}, 'user' => $ML{'.sort.journal'}); my $sort = ($GET{'sortby'} || 'memid'); unless (defined $sorts{$sort}) { $sort = 'memid'; } # keys must be the same as those of %sorts my %sortfunc = ('memid' => sub { sort { $a->{'memid'} <=> $b->{'memid'} } @_; }, 'des' => sub { sort { $a->{'des'} cmp $b->{'des'} } @_; }, 'user' => sub { sort { $a->{'user'} cmp $b->{'user'} || $a->{'des'} cmp $b->{'des'} } @_; }); my $securities = ['public']; if ($authasu) { if ($is_owner) { $securities = []; } elsif ($authasu->{'journaltype'} eq 'P' and LJ::is_friend($userid, $authasu->{'userid'})) { $securities = ['public', 'friends']; } } my $kwmap = LJ::Memories::get_keywords($u); return $dberr->() unless defined $kwmap; if ($GET{'keyword'}) { if ($GET{'keyword'} eq "*") { $title = $ML{'.title.memorable'}; $body .= " $user }) . " p?>"; } else { my $ekw = LJ::ehtml($GET{'keyword'}); $title = BML::ml(".title.keyword", { 'keyword' => $ekw, 'user' => $user }); $body .= BML::ml(".body.keyword", { 'keyword' => $ekw, 'user' => $user }); } $body .= "
\n"; $body .= "<< $ML{'.back'}"; my $key_id; foreach (keys %$kwmap) { $key_id = $_ if $kwmap->{$_} eq $GET{keyword}; } my $memoryhash = LJ::Memories::get_by_keyword($u, $key_id, { security => $securities, filter => $filter }); return $dberr->() unless defined $memoryhash; my @jids = map { $_->{journalid} } values %$memoryhash; my $us = LJ::load_userids(@jids); my @memories = $sortfunc{$sort}->( values %$memoryhash ); $body .= "\n"; } return; } $title = $ML{'.title.memorable'}; $body .= BML::ml(".body.list_categories", { 'user' => $user }); my $rows = LJ::Memories::get_keyword_counts($u, { security => $securities, filter => $filter }); return $dberr->() unless defined $rows; my @sortedrows; push @sortedrows, { keyword => $kwmap->{$_}, count => $rows->{$_} } foreach keys %{$rows || {}}; @sortedrows = sort { $a->{'keyword'} cmp $b->{'keyword'} } @sortedrows; $body .= ""; unless (@sortedrows) { $body .= ""; } else { $body .= "