Committer: vad
LJSUP-13023: Save settings of ratingU trunk/cgi-bin/LJ/Widget/HomepageRU.pm
Modified: trunk/cgi-bin/LJ/Widget/HomepageRU.pm =================================================================== --- trunk/cgi-bin/LJ/Widget/HomepageRU.pm 2012-07-25 09:06:02 UTC (rev 12343) +++ trunk/cgi-bin/LJ/Widget/HomepageRU.pm 2012-07-25 09:19:52 UTC (rev 12344) @@ -128,13 +128,14 @@ my $rating_top_journals_sort = LJ::Request->cookie('rating_top_journals_sort'); $rating_top_journals_sort = 'visitors' unless defined $rating_top_journals_sort; - my $rating_show_custom = LJ::Request->cookie('rating_show_custom'); + my $rating_show_custom = ! LJ::Request->cookie('rating_full'); $rating_show_custom = 1 unless defined $rating_show_custom; $rating_show_custom = ( $rating_show_custom ? 1 : 0 ); - ## rating_top_journals_sort cookie specifies ratings sort order and usually is set or changed by JavaScript, - ## in case JS is disabled in browser or it does not support JS, set the cookie by Set-Cookie response header. - my $set_sort_cookie = 0; + ## 'rating_full' and 'rating_top_journals_sort' cookie specify ratings sort order and usually are set or changed by JavaScript, + ## in case JS is disabled in browser or it does not support JS, set them by Set-Cookie response header. + my $set_sort_cookie = 0; + my $set_rating_cookie = 0; if (defined $GET->{'rating'}) { my %get_rating = map { lc($_) => 1 } split /\s+/, $GET->{'rating'}; @@ -148,18 +149,20 @@ if ($get_rating{'custom'}) { $rating_show_custom = 1; - $set_sort_cookie = 1; + $set_rating_cookie = 1; } elsif ($get_rating{'all'}) { $rating_show_custom = 0; - $set_sort_cookie = 1; + $set_rating_cookie = 1; } if ($get_rating{'authority'}) { $rating_top_journals_sort = 'authority'; + $set_sort_cookie = 1; } elsif ($get_rating{'visitors'}) { $rating_top_journals_sort = 'visitors'; + $set_sort_cookie = 1; } } @@ -199,7 +202,7 @@ 'output' => $output, ); - LJ::Request->set_cookie('rating_show_custom' => $rating_show_custom, 'expires' => time + 60*60*24*180); + LJ::Request->set_cookie('rating_full' => !$rating_show_custom, 'expires' => time + 60*60*24*180) if $set_rating_cookie; LJ::Request->set_cookie('rating_top_journals_sort' => $output->{'sort'}, 'expires' => time + 60*60*24*180) if $set_sort_cookie; }