Committer: bradfitzreverting r4059. it was supposed to go into a branch for review.
U trunk/cgi-bin/ljcom.pl
Modified: trunk/cgi-bin/ljcom.pl
===================================================================
--- trunk/cgi-bin/ljcom.pl 2006-12-22 16:54:47 UTC (rev 4059)
+++ trunk/cgi-bin/ljcom.pl 2006-12-22 17:04:39 UTC (rev 4060)
@@ -3671,88 +3671,26 @@
my $u = LJ::load_user($username);
my $remote = LJ::get_remote();
- # it's much eaiser to define when we SHOULD not show SUP advs
- # there are 4 cases (out of 12):
- # 1. user - defined, non-SUP
- # remote - defined, non-SUP
- # ip address - any
- # 2. user - defined, non-SUP
- # remote - undefined
- # ip address - non ex-USSR
- # 3. user - undefined (app pages)
- # remote - defined, non-SUP
- # ip address - any
- # 4. user - undefined (app pages)
- # remote - undefined
- # ip address - non ex-USSR
-
+ my $sup_u;
- my $is_sup_user;
- my $is_sup_remote;
-
- $is_sup_user = $u->get_cap("sup_user") if ($u); # whether user is SUP or not
- $is_sup_remote = $remote->get_cap("sup_user") if ($remote); # whether remote is SUP or not
+ if ($u && $u->get_cap("sup_user")) {
+ # If we're viewing a journal page of a sup_user, then use that userid for the ip class check.
+ $sup_u = $u;
+ } elsif ($remote && $remote->get_cap("sup_user")) {
+ # Otherwise see if the remote is a sup_user, using that if they are.
+ $sup_u = $remote;
+ } else {
+ # Otherwise bail out, we're not dealing with sup users at all.
+ return;
+ }
my $ip = LJ::get_remote_ip();
my $ip_class = ip_class($ip);
- my $exUSSR_ip = $ip_class eq 'sup' || $ip_class eq 'russia';
- if ($u) {
- unless ($is_sup_user) {
- if ($remote) {
- # case 1:
- # user - defined, non-SUP
- # remote - defined, non-SUP
- # ip address - any
- return unless $is_sup_remote;
- }
- else {
- # case 2:
- # user - defined, non-SUP
- # remote - undefined
- # ip address - non ex-USSR
- return unless $exUSSR_ip;
- }
- }
- }
- else {
- if ($remote) {
- # case 3:
- # user - undefined (app pages)
- # remote - defined, non-SUP
- # ip address - any
- return unless $is_sup_remote;
- }
- else {
- # case 4
- # user - undefined (app pages)
- # remote - undefined
- # ip address - non ex-USSR
- return unless $exUSSR_ip;
- }
- }
+ my $sup_userid = $sup_u->id;
- # if we got here we SHOULD TRY to show SUP adv
- # trying depends on value of percentage (from 0 to 100%)
-
- my $trying_userid;
- if ($is_sup_user) {
- $trying_userid = $u->id;
- }
- elsif ($is_sup_remote) {
- $trying_userid = $remote->id;
- } elsif ($u) {
- $trying_userid = $u->id;
- } elsif ($remote) {
- $trying_userid = $remote->id;
- } else {
- # anonymous user => let's use ip address as $trying_userid
-
- $trying_userid = $ip;
- }
-
- my $match_all = LJ::Knob->instance("adv-sup-all")->check($trying_userid);
- my $match_class = $ip_class && LJ::Knob->instance("adv-sup-$ip_class")->check($trying_userid);
+ my $match_all = LJ::Knob->instance("adv-sup-all")->check($sup_userid);
+ my $match_class = $ip_class && LJ::Knob->instance("adv-sup-$ip_class")->check($sup_userid);
return unless $match_all || $match_class;