Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[livejournal] r18784: LJSUP-8475: RemoteUser in S2

Committer: gariev
LJSUP-8475: RemoteUser in S2

U   trunk/bin/upgrading/s2layers/core1.s2
U   trunk/cgi-bin/LJ/S2.pm
Modified: trunk/bin/upgrading/s2layers/core1.s2
===================================================================
--- trunk/bin/upgrading/s2layers/core1.s2	2011-04-04 08:18:09 UTC (rev 18783)
+++ trunk/bin/upgrading/s2layers/core1.s2	2011-04-04 08:31:00 UTC (rev 18784)
@@ -824,6 +824,9 @@
 function builtin pageview_unique_string () : string
 "Returns a unique string for the remote user.";
 
+function builtin get_remote () : User
+"Returns an object of remote user in trusted styles only. See also: viewer_logged_in(), viewer_is_owner() etc.";
+
 function builtin alternate (string a, string b) : string
 "With each call, this function will alternate between the two values and return one of them.
 Useful for making tables whose rows alternate in background color.";

Modified: trunk/cgi-bin/LJ/S2.pm
===================================================================
--- trunk/cgi-bin/LJ/S2.pm	2011-04-04 08:18:09 UTC (rev 18783)
+++ trunk/cgi-bin/LJ/S2.pm	2011-04-04 08:31:00 UTC (rev 18784)
@@ -2490,6 +2490,17 @@
     return LJ::pageview_unique_string();
 }
 
+sub get_remote {
+    my ($ctx) = @_;
+
+    return unless $LJ::S2_TRUSTED{ $LJ::S2::CURR_PAGE->{'_u'}->{'userid'} };
+
+    my $remote = LJ::get_remote();
+    return unless $remote;
+    
+    return LJ::S2::User($remote);
+}
+
 sub viewer_logged_in
 {
     my ($ctx) = @_;

Tags: gariev, livejournal, pm, s2
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