vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[ljcom] r9844: LJSUP-7604: allow to view friends page o...

Committer: vsukhanov
LJSUP-7604: allow to view friends page of any journal
U   trunk/cgi-bin/LJ/SUP/RPC/Command/get_friends_page.pm
Modified: trunk/cgi-bin/LJ/SUP/RPC/Command/get_friends_page.pm
===================================================================
--- trunk/cgi-bin/LJ/SUP/RPC/Command/get_friends_page.pm	2010-12-14 10:18:53 UTC (rev 9843)
+++ trunk/cgi-bin/LJ/SUP/RPC/Command/get_friends_page.pm	2010-12-14 11:14:15 UTC (rev 9844)
@@ -3,9 +3,9 @@
 use base qw/LJ::SUP::RPC::Command::get_entries/;
 use LJ::TimeUtil;
 
-sub need_user           { 'any' }
+sub need_user           { 0 }
 sub need_journal        { 0 }
-sub need_active_session { 1 }
+sub need_active_session { 0 }
 sub need_post           { 1 }
 
 sub process {
@@ -20,6 +20,8 @@
     #   skip   = how many entries to skip
     #
     # Optional params:
+    #   journal     = get friends page of this journal, if omited used remote user.
+    #
     #   filter      = list of group names. 
     #       The first group with non-empty result will be returned.
     #       Empty string may be used for unfiltered result.
@@ -38,24 +40,29 @@
 
     my @filter = (defined $params->{filter}) ? split("\0", $params->{filter}, -1) : ('');
     
-    my $u = $self->u;
+    my $journalu = ($params->{journal}) ? LJ::load_user($params->{journal}) : $self->u;
+    return { status => "ERROR", message => "no user" }
+        unless $journalu;
+
+    my $remote = $self->u;
+
     my @entries = ();
     my $used_filter;
     for my $filter (@filter) {
         my $filter_bit;
         if ($filter ne '') {
-            my $group = LJ::get_friend_group($u, { 'name' => $filter });
+            my $group = LJ::get_friend_group($journalu, { 'name' => $filter });
             next unless $group; # try other group 
-            $filter_bit = 1 << $group->{'groupnum'};
+            $filter_bit = 1 << $group->{'group0num'};
         }
         $used_filter = $filter;
         @entries = LJ::get_friend_items({
-            'remoteid'          => $u->userid,
+            'remoteid'          => ($remote) ? $remote->userid : undef,
             'itemshow'          => $limit,
             'skip'              => $skip,
             'showtypes'         => $params->{show_types}, ## may be undef, journal types string
-            'u'                 => $u,
-            'userid'            => $u->userid,
+            'u'                 => $journalu,
+            'userid'            => $journalu->userid,
             'filter'            => $filter_bit,
             'dateformat'        => 'S2',
             ## 'common_filter' really not used inside
@@ -71,7 +78,7 @@
         next unless $ei;
         my $entry = LJ::Entry->new_from_item_hash($ei);
         next unless $entry;
-        next unless $entry->visible_to($u);
+        next unless $entry->visible_to($remote);
 
         # event result data structure
         my %h = ();

Tags: ljcom, pm, vadvs
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments