Первый фоллен на хелле (wildkin) wrote in changelog,
Первый фоллен на хелле
wildkin
changelog

[ljcom] r12318: LJSUP-11266: Users should be able to adj...

Committer: dnikolaev
LJSUP-11266: Users should be able to adjust rating (disable users and entries)

U   trunk/cgi-bin/LJ/Widget/HomepageRU.pm
Modified: trunk/cgi-bin/LJ/Widget/HomepageRU.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/HomepageRU.pm	2012-07-19 11:52:50 UTC (rev 12317)
+++ trunk/cgi-bin/LJ/Widget/HomepageRU.pm	2012-07-19 12:43:05 UTC (rev 12318)
@@ -77,29 +77,6 @@
     ## Realtime SMS
     $result{real_time_sms} = LJ::Widget::ExtBlock->render(id=>'realtime.sms');
 
-    ## Ratings
-    if (LJ::is_enabled('personal_stats_ratings')) {
-
-        if (defined $GET->{rating}) {
-            LJ::PersonalStats::Ratings->set_view_ua_ratings( lc($GET->{rating}) eq 'ua' );
-        }
-
-        my $entries_top = LJ::PersonalStats::Ratings::Posts::Top->new( {
-            # 'country'         => STRING (cyr | noncyr | ua)
-            'sort'             => 'visitors',
-            'length'           => 25,
-            'filter_commpromo' => 1,
-            'filter_selfpromo' => 1,
-            'filter_featured'  => 0,
-            'filter_blacklist' => 0,
-        } );
-
-        $result{personalstats} = $entries_top->template_output( {
-            'homepage'         => 1,
-            'widget'           => 1,
-        } );
-    }
-
     ## Widget SUP1MillionPromo
     $result{widget_sup1millionpromo} = LJ::Widget::SUP1MillionPromo->render;
 
@@ -146,30 +123,73 @@
     ## Widget UpdatesForUser
     $result{widget_updatesforuser} = LJ::Widget::UpdatesForUser->render;
 
-    ## Widget RatingTop10
-    # $result{widget_ratingtop10} = LJ::Widget::RatingTop10->render;
+    ## Ratings
+    {
+        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_top_journals_sort = $GET->{'sort'};
-        unless (defined $rating_top_journals_sort) {
-            $rating_top_journals_sort =  LJ::Request->cookie('rating_top_journals_sort');
+        my $rating_use_custom = LJ::Request->cookie('rating_use_custom');
+        $rating_use_custom = 1 unless defined $rating_use_custom;
+        $rating_use_custom = ( $rating_use_custom ? 1 : 0 );
+
+        if (defined $GET->{'rating'}) {
+            my %get_rating = map { lc($_) => 1 } split /\s+/, $GET->{'rating'};
+
+            if ($get_rating{'ua'}) {
+                LJ::PersonalStats::Ratings->set_view_ua_ratings(1);
+            }
+            elsif ($get_rating{'cyr'}) {
+                LJ::PersonalStats::Ratings->set_view_ua_ratings(0);
+            }
+
+            if ($get_rating{'custom'}) {
+                $rating_use_custom = 1;
+            }
+            elsif ($get_rating{'all'}) {
+                $rating_use_custom = 0;
+            }
+
+            if ($get_rating{'authority'}) {
+                $rating_top_journals_sort = 'authority';
+            }
+            elsif ($get_rating{'visitors'}) {
+                $rating_top_journals_sort = 'visitors';
+            }
         }
 
+        my $entries_top = LJ::PersonalStats::Ratings::Posts::Top->new( {
+            # 'country'         => STRING (cyr | noncyr | ua)
+            'sort'             => 'visitors',
+            'length'           => 25,
+            'filter_commpromo' => 1,
+            'filter_selfpromo' => 1,
+            'filter_featured'  => 0,
+            'filter_blacklist' => $rating_use_custom,
+        } );
+
+        $result{personalstats} = $entries_top->template_output( {
+            'homepage'         => 1,
+            'widget'           => 1,
+        } );
+
         my $output = {};
 
         $result{widget_ratingtop10_users} = LJ::Widget::RatingTopJournals->render(
-            'what'    => 'users',
-            'sort'    => $rating_top_journals_sort,
-            # 'country' => ???, # do not define 'country', use default value
-            'output'  => $output,
+            'what'             => 'users',
+            'sort'             => $rating_top_journals_sort,
+            # 'country'          => ???, # do not define 'country', use default value
+            'filter_blacklist' => $rating_use_custom,
+            'output'           => $output,
         );
 
         $result{widget_ratingtop10_comms} = LJ::Widget::RatingTopJournals->render(
-            'what'    => 'communities',
-            'sort'    => $rating_top_journals_sort,
-            'output'  => $output,
+            'what'             => 'communities',
+            'sort'             => $rating_top_journals_sort,
+            'filter_blacklist' => $rating_use_custom,
+            'output'           => $output,
         );
 
+        LJ::Request->set_cookie('rating_use_custom' => $rating_use_custom, 'expires' => time + 60*60*24*180);
         LJ::Request->set_cookie('rating_top_journals_sort' => $output->{'sort'}, 'expires' => time + 60*60*24*180);
     }
 

Tags: dnikolaev, ljcom, pm, wildkin
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