sunnyman's (sunnyman) wrote in changelog,
sunnyman's
sunnyman
changelog

[livejournal] r20095: LJSUP-9733: Extra attributes added to lj...

Committer: vtroitsky
LJSUP-9733: Extra attributes added to lj-poll tags returned from LJ.XMLRPC.getevents / LJ.XMLRPC.getfriendspage in case of get_polls=1 parameter specified.
U   trunk/cgi-bin/LJ/Poll.pm
U   trunk/cgi-bin/ljprotocol.pl
Modified: trunk/cgi-bin/LJ/Poll.pm
===================================================================
--- trunk/cgi-bin/LJ/Poll.pm	2011-09-21 03:28:02 UTC (rev 20094)
+++ trunk/cgi-bin/LJ/Poll.pm	2011-09-21 04:11:37 UTC (rev 20095)
@@ -1012,7 +1012,7 @@
 
 # get poll description as a xml
 sub get_poll_xml {
-    my $self = shift;
+    my ($self, %opts) = @_;
     my $ret = '';
 
     my $attrs = ' id="'.$self->pollid.'"';
@@ -1023,6 +1023,8 @@
     }
 
     $attrs .= ' whovote="'.$self->whovote.'" whoview="'.$self->whoview.'"';
+    $attrs .= ' can_view="'.$self->can_view($opts{viewer}).'" can_vote="'.$self->can_vote($opts{viewer}).'" is_owner="'.$self->is_owner($opts{viewer}).'" status="'.($self->is_closed ? 'close' : 'open').'"' if ($opts{viewer});
+
     $ret .= "<lj-poll$attrs>";
     my @questions = $self->questions;
     map { $ret .= $_->get_question_xml() } @questions;
@@ -1748,7 +1750,7 @@
         my $poll = LJ::Poll->new($pollid);
         return "[Error: Invalid poll ID $pollid]" unless $poll && $poll->valid;
 
-        return ($viewpoll ? $poll->get_poll_xml : $poll->render);
+        return ($viewpoll ? $poll->get_poll_xml(viewer => $opts{viewer}) : $poll->render);
     };
 
     $$entryref =~ s/<lj-poll-(\d+)>/$expand->($1, $getpolls)/eg;

Modified: trunk/cgi-bin/ljprotocol.pl
===================================================================
--- trunk/cgi-bin/ljprotocol.pl	2011-09-21 03:28:02 UTC (rev 20094)
+++ trunk/cgi-bin/ljprotocol.pl	2011-09-21 04:11:37 UTC (rev 20095)
@@ -1004,7 +1004,7 @@
         ) if $req->{trim_widgets};
 
         LJ::EmbedModule->expand_entry($entry->poster, \$h{event_raw}, get_video_id => 1) if $req->{get_video_ids};
-        LJ::Poll->expand_entry(\$h{event_raw}, getpolls => 1) if $req->{get_polls};
+        LJ::Poll->expand_entry(\$h{event_raw}, getpolls => 1, viewer => $u ) if $req->{get_polls};
 
         if ($req->{view}) {
             LJ::EmbedModule->expand_entry($entry->poster, \$h{event_raw}, edit => 1) if $req->{view} eq 'stored';
@@ -3385,7 +3385,7 @@
         ) if $req->{trim_widgets};
 
         LJ::EmbedModule->expand_entry($uowner, \$t->[1], get_video_id => 1) if($req->{get_video_ids});
-        LJ::Poll->expand_entry(\$t->[1], getpolls => 1) if $req->{get_polls};
+        LJ::Poll->expand_entry(\$t->[1], getpolls => 1, viewer => $u) if $req->{get_polls};
 
         if ($req->{view}) {
             LJ::EmbedModule->expand_entry($uowner, \$t->[1], edit => 1) if $req->{view} eq 'stored';

Tags: livejournal, pl, pm, sunnyman
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