[dw-free] allow different interest counts based on account level
[commit: http://hg.dwscoalition.org/dw-free/rev/9e8abb4a632f]
http://bugs.dwscoalition.org/show_bug.cgi?id=1037
Make interest limit a tunable, and increase limit on number of interests for
paid accounts.
Patch by
denise.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=1037
Make interest limit a tunable, and increase limit on number of interests for
paid accounts.
Patch by
![[staff profile]](https://www.dreamwidth.org/img/silk/identity/user_staff.png)
Files modified:
- bin/upgrading/en.dat
- cgi-bin/LJ/Setting/Interests.pm
- cgi-bin/LJ/Widget/CreateAccountProfile.pm
- cgi-bin/LJ/Widget/FriendInterests.pm
- etc/config.pl
- htdocs/interests.bml
- htdocs/manage/profile/index.bml
-------------------------------------------------------------------------------- diff -r e297eaa982ef -r 9e8abb4a632f bin/upgrading/en.dat --- a/bin/upgrading/en.dat Sun Jun 14 20:52:55 2009 +0000 +++ b/bin/upgrading/en.dat Mon Jun 15 04:09:00 2009 +0000 @@ -1276,7 +1276,7 @@ error.interest.bytes.chars=Sorry, you ha error.interest.chars=Sorry, you have listed an interest with [[chars]] characters. Each interest has a limit of [[chars_max]] characters. Any changes you made to your interests were not saved. Go back and remove, or modify "[[int]]". -error.interest.excessive=Sorry, you have listed too many interests. The limit is 150, but you have listed [[intcount]]. Any changes you made to your interests were not saved. Go back and remove some interests. +error.interest.excessive2=Sorry, you have listed too many interests. The limit for your account type is [[maxinterests]], but you have listed [[intcount]]. Any changes you made to your interests were not saved. Go back and remove some interests. error.interest.invalid=Sorry, you have listed an interest with invalid characters. Any changes you made to your interests were not saved. Go back and remove, or modify "[[int]]". diff -r e297eaa982ef -r 9e8abb4a632f cgi-bin/LJ/Setting/Interests.pm --- a/cgi-bin/LJ/Setting/Interests.pm Sun Jun 14 20:52:55 2009 +0000 +++ b/cgi-bin/LJ/Setting/Interests.pm Mon Jun 15 04:09:00 2009 +0000 @@ -36,8 +36,10 @@ sub error_check { my @interrors = (); # Don't bother validating the interests if there are already too many - if ($intcount > 150) { - $class->errors("interests" => LJ::Lang::ml('error.interest.excessive', { intcount => $intcount })); + my $maxinterests = $u->get_cap( 'interests' ); + + if ($intcount > $maxinterests) { + $class->errors("interests" => LJ::Lang::ml('error.interest.excessive2', { intcount => $intcount, maxinterests => $maxinterests })); return 1; } diff -r e297eaa982ef -r 9e8abb4a632f cgi-bin/LJ/Widget/CreateAccountProfile.pm --- a/cgi-bin/LJ/Widget/CreateAccountProfile.pm Sun Jun 14 20:52:55 2009 +0000 +++ b/cgi-bin/LJ/Widget/CreateAccountProfile.pm Mon Jun 15 04:09:00 2009 +0000 @@ -192,7 +192,10 @@ sub handle_post { # count interests my $intcount = scalar @ints; - $from_post{errors}->{interests} = LJ::Lang::ml('error.interest.excessive', { intcount => $intcount }) if $intcount > 150; + my $maxinterests = $u->get_cap( 'interests' ); + + $from_post{errors}->{interests} = LJ::Lang::ml('error.interest.excessive2', { intcount => $intcount, maxinterests => $maxinterests }) + if $intcount > $maxinterests; # clean interests, and make sure they're valid my @interrors; diff -r e297eaa982ef -r 9e8abb4a632f cgi-bin/LJ/Widget/FriendInterests.pm --- a/cgi-bin/LJ/Widget/FriendInterests.pm Sun Jun 14 20:52:55 2009 +0000 +++ b/cgi-bin/LJ/Widget/FriendInterests.pm Mon Jun 15 04:09:00 2009 +0000 @@ -46,11 +46,13 @@ sub handle_post { $deleted = 1; } if (@toadd) { - if ($intcount + scalar @toadd > 150) { + my $maxinterests = $u->get_cap( 'interests' ); + + if ($intcount + scalar @toadd > $maxinterests) { if ($deleted) { - die BML::ml('/interests.bml.results.del_and_toomany', {'intcount' => 150}); + die BML::ml('/interests.bml.results.del_and_toomany', {'intcount' => $maxinterests}); } else { - die BML::ml('/interests.bml.results.toomany', {'intcount' => 150}); + die BML::ml('/interests.bml.results.toomany', {'intcount' => $maxinterests}); } } else { my $dbh = LJ::get_db_writer(); diff -r e297eaa982ef -r 9e8abb4a632f etc/config.pl --- a/etc/config.pl Sun Jun 14 20:52:55 2009 +0000 +++ b/etc/config.pl Mon Jun 15 04:09:00 2009 +0000 @@ -300,6 +300,7 @@ 'checkfriends' => 0, 'checkfriends_interval' => 300, 'friendsviewupdate' => 30, + 'interests' => 150, 'makepoll' => 0, 'maxfriends' => 500, 'moodthemecreate' => 0, @@ -370,6 +371,7 @@ 'getselfemail' => 0, google_analytics => 0, 'inbox_max' => 2000, + 'interests' => 150, 'makepoll' => 0, 'mass_privacy' => 0, 'maxfriends' => 1000, @@ -425,6 +427,7 @@ 'getselfemail' => 1, google_analytics => 1, 'inbox_max' => 4000, + 'interests' => 200, 'makepoll' => 1, 'mass_privacy' => 1, 'maxfriends' => 1500, @@ -478,6 +481,7 @@ 'getselfemail' => 1, google_analytics => 1, 'inbox_max' => 6000, + 'interests' => 250, 'makepoll' => 1, 'mass_privacy' => 1, 'maxfriends' => 2000, @@ -538,6 +542,7 @@ 'getselfemail' => 1, google_analytics => 1, 'inbox_max' => 6000, + 'interests' => 250, 'makepoll' => 1, 'mass_privacy' => 1, 'maxfriends' => 2000, @@ -589,6 +594,7 @@ 'getselfemail' => 1, google_analytics => 1, 'inbox_max' => 6000, + 'interests' => 250, 'makepoll' => 1, 'mass_privacy' => 1, 'maxfriends' => 2000, diff -r e297eaa982ef -r 9e8abb4a632f htdocs/interests.bml --- a/htdocs/interests.bml Sun Jun 14 20:52:55 2009 +0000 +++ b/htdocs/interests.bml Mon Jun 15 04:09:00 2009 +0000 @@ -25,6 +25,8 @@ body<= my $did_post = LJ::did_post(); my $remote = LJ::get_remote(); + + my $maxinterests = $remote->get_cap( 'interests' ); my $table = sub { $_[0]->{'journaltype'} eq 'C' ? 'comminterests' : 'userinterests' }; @@ -103,8 +105,8 @@ body<= # account for the case where we bypass the POST due to the referer return $ML{'error.invalidform'} unless !$did_post || LJ::check_form_auth(); - if ($count >= 150) { - $ret .= "<?h1 $ML{'.add.toomany.head'} h1?><?p " .BML::ml(".add.toomany.text", {'maxinterests' => "150"}) ." p?>"; + if ($count >= $maxinterests) { + $ret .= "<?h1 $ML{'.add.toomany.head'} h1?><?p " .BML::ml(".add.toomany.text", {'maxinterests' => $maxinterests}) ." p?>"; return $ret; } @@ -171,7 +173,7 @@ body<= } my @matches = sort { $magic{$b} <=> $magic{$a} } keys %magic; - if (@matches > 150) { @matches = @matches[0..149]; } + if (@matches > $maxinterests) { @matches = @matches[0..( $maxinterests - 1 )]; } my $sth = $dbr->prepare("SELECT userid, user FROM useridmap WHERE userid IN (" . join(",",@matches) . ")"); $sth->execute; my %username; @@ -323,7 +325,7 @@ body<= $deleted = 1; } if (@toadd) { - if ($intcount + scalar @toadd > 150) { + if ($intcount + scalar @toadd > $maxinterests) { $toomany = 1; } else { my $dbh = LJ::get_db_writer(); @@ -346,11 +348,11 @@ body<= my $ret = "<?h1 $ML{'.results.header'} h1?><?p "; if ($deleted) { $ret .= $added ? $ML{'.results.both'} - : $toomany ? BML::ml('.results.del_and_toomany', {'intcount' => 150}) + : $toomany ? BML::ml('.results.del_and_toomany', {'intcount' => $maxinterests}) : $ML{'.results.deleted'}; } else { $ret .= $added ? $ML{'.results.added'} - : $toomany ? BML::ml('.results.toomany', {'intcount' => 150}) + : $toomany ? BML::ml('.results.toomany', {'intcount' => $maxinterests}) : $ML{'.results.nothing'}; } diff -r e297eaa982ef -r 9e8abb4a632f htdocs/manage/profile/index.bml --- a/htdocs/manage/profile/index.bml Sun Jun 14 20:52:55 2009 +0000 +++ b/htdocs/manage/profile/index.bml Mon Jun 15 04:09:00 2009 +0000 @@ -743,12 +743,14 @@ body<= # update interests unless ($POST{'interests_absent'}) { + my $maxinterests = $u->get_cap( 'interests' ); + my @ints = LJ::interest_string_to_list($POST{'interests'}); my $intcount = scalar(@ints); my @interrors = (); # Don't bother validating the interests if there are already too many - return LJ::bad_input( BML::ml('error.interest.excessive', { intcount => $intcount }) ) if $intcount > 150; + return LJ::bad_input( BML::ml('error.interest.excessive2', { intcount => $intcount, maxinterests => $maxinterests } ) ) if $intcount > $maxinterests; # Clean interests, and make sure they're valid my @valid_ints = LJ::validate_interest_list(\@interrors, @ints); --------------------------------------------------------------------------------