wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[livejournal] r22723: iLJSUP-10041: Add ability to display sys...

Committer: wisest-owl
iLJSUP-10041: Add ability to display system message for non-logged users

U   trunk/cgi-bin/LJ/SiteMessages.pm
U   trunk/cgi-bin/LJ/Widget/SiteMessages.pm
Modified: trunk/cgi-bin/LJ/SiteMessages.pm
===================================================================
--- trunk/cgi-bin/LJ/SiteMessages.pm	2012-08-23 08:47:51 UTC (rev 22722)
+++ trunk/cgi-bin/LJ/SiteMessages.pm	2012-08-23 08:53:16 UTC (rev 22723)
@@ -10,7 +10,7 @@
                         validate    => sub {
                                             my ($u) = @_;
                                             
-                                            return $u->in_class('perm');
+                                            return $u && $u->in_class('perm');
                                        },
                     },
     
@@ -20,7 +20,7 @@
                         validate    => sub {
                                             my ($u) = @_;
                                             
-                                            return $u->in_class('sponsored');
+                                            return $u && $u->in_class('sponsored');
                                        },
                     },
                     
@@ -30,7 +30,7 @@
                         validate    => sub {
                                             my ($u) = @_;
                                             
-                                            return $u->get_cap('paid');
+                                            return $u && $u->get_cap('paid');
                                        },
                     },
     
@@ -40,7 +40,7 @@
                         validate    => sub {
                                             my ($u) = @_;
                                             
-                                            return $u->in_class('plus') && !$u->get_cap('paid');
+                                            return $u && $u->in_class('plus') && !$u->get_cap('paid');
                                        },
                     },
     
@@ -51,7 +51,7 @@
                         validate    => sub {
                                             my ($u) = @_;
 
-                                            return !($u->in_class('plus') || $u->get_cap('paid'));
+                                            return $u && !($u->in_class('plus') || $u->get_cap('paid'));
                                        }
                     },
     
@@ -98,7 +98,7 @@
                         validate    => sub {
                                             my ($u) = @_;
 
-                                            return $u->get_cap('trynbuy');      
+                                            return $u && $u->get_cap('trynbuy');      
                                        }
                     },
     
@@ -108,7 +108,7 @@
                         validate    => sub {
                                             my ($u) = @_;
 
-                                            return LJ::TryNBuy->already_used($u);
+                                            return $u && LJ::TryNBuy->already_used($u);
                                        }
                     },
     
@@ -118,7 +118,7 @@
                         validate    => sub {
                                             my ($u) = @_;
 
-                                            return !(LJ::TryNBuy->already_used($u) || $u->get_cap('trynbuy'));
+                                            return $u && !(LJ::TryNBuy->already_used($u) || $u->get_cap('trynbuy'));
                                        }
                     },
     
@@ -128,7 +128,7 @@
                         validate    => sub {
                                             my ($u) = @_;
                                             
-                                            return $u->prop('email_faulty');
+                                            return $u && $u->prop('email_faulty');
                                        }
                     },
    NewPhotohosting => {
@@ -136,9 +136,15 @@
                         group       => 5,
                         validate    => sub {
                                             my ($u) = @_;
-                                            return !(LJ::Pics::Migration->user_enabled_new_photohosting($u));
+                                            return $u && !(LJ::Pics::Migration->user_enabled_new_photohosting($u));
                                        }
                     },
+
+    Anonymous   => {
+                        value       => 8192,
+                        group       => 0,
+                        validate    => sub { LJ::get_remote() ? 0 : 1 },
+                    },
 };
 
 #
@@ -296,8 +302,6 @@
     # direct the questions at the given $u, or remote if no $u given
     my $u = $opts{user} && LJ::isu($opts{user}) ? $opts{user} : LJ::get_remote();
 
-    return unless $u; # there are no messages for logged out users
-
     my @messages = $class->load_messages;
     @messages = $class->filter_messages($u, @messages);
     @messages = $class->filter_by_country($u, @messages);
@@ -311,7 +315,7 @@
 sub filter_messages {
     my $class = shift;
     my $u = shift;
-   
+  
     my @messages;
     MESSAGE:
     foreach my $m (@_) {
@@ -466,15 +470,14 @@
     my $class = shift;
 
     my $remote = LJ::get_remote();
-    return unless $remote; # this feature only for logged in users
 
     ## tiny optimization
-    $remote->preload_props(qw/country closed_sm/);
+    $remote->preload_props(qw/country closed_sm/) if $remote;
 
     ##
     my @messages = $class->get_messages(user => $remote);
 
-    my $closed = $remote->prop('closed_sm');
+    my $closed = $remote ? $remote->prop('closed_sm') : undef;
     if ($closed) {
         my %closed = map { $_ => 1 } split(',', $closed);
         @messages = grep { not $closed{$_->{mid}} } @messages;

Modified: trunk/cgi-bin/LJ/Widget/SiteMessages.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/SiteMessages.pm	2012-08-23 08:47:51 UTC (rev 22722)
+++ trunk/cgi-bin/LJ/Widget/SiteMessages.pm	2012-08-23 08:53:16 UTC (rev 22723)
@@ -15,7 +15,7 @@
 
     my $lang;
     my $remote = LJ::get_remote();
-    return unless $remote;
+
     $lang = $remote->prop("browselang") if $remote; # exlude s2 context language from opportunities,
         # because S2 journal code executes BML::set_language($lang, \&LJ::Lang::get_text) with its own language
 
@@ -27,7 +27,7 @@
     LJ::CleanHTML::clean_event(\$text, { 'lj_sys_message_id' => $mid });
 
     my $is_office = LJ::SiteMessages->has_mask('OfficeOnly', $message->{accounts}) ? '<b>[Only for office]</b> ' : '';
-    if (LJ::SiteMessages->has_mask('NewPhotohosting', $message->{accounts}))  {
+    if ($remote && LJ::SiteMessages->has_mask('NewPhotohosting', $message->{accounts}))  {
         my $url = $remote->journal_base . "/pics/new_photo_service";
         $text = "<a href=$url>$text</a>"
     }

Tags: livejournal, pm, wisest-owl
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