diff options
author | matthew <matthew> | 2008-02-07 17:53:52 +0000 |
---|---|---|
committer | matthew <matthew> | 2008-02-07 17:53:52 +0000 |
commit | a11c2bf3033e4aa5010054749ceca6773cb59fc0 (patch) | |
tree | c30281fb6fe1a8ebf1d180198cece57bc0372ec6 /perllib/CrossSell.pm | |
parent | 9930a756f73e4b6413a6b8f5a5fd660235f2ac80 (diff) |
Don't use rand,as makes it hard to add new adverts in future.
Diffstat (limited to 'perllib/CrossSell.pm')
-rw-r--r-- | perllib/CrossSell.pm | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/perllib/CrossSell.pm b/perllib/CrossSell.pm index 229cd73ee..7b5aab03b 100644 --- a/perllib/CrossSell.pm +++ b/perllib/CrossSell.pm @@ -9,7 +9,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: CrossSell.pm,v 1.9 2008-02-06 15:28:23 matthew Exp $ +# $Id: CrossSell.pm,v 1.10 2008-02-07 17:53:52 matthew Exp $ # Config parameters site needs set to call these functions: # OPTION_AUTH_SHARED_SECRET @@ -124,27 +124,29 @@ sub display_advert ($$;$%) { } my @adverts = ( - [ 'gny', '<h2>Are you a member of a local group…</h2> …which uses the internet to coordinate itself, such as a neighbourhood watch? If so, please help the charity that runs FixMyStreet by <a href="http://www.groupsnearyou.com/add/about/">adding some information about it</a> to our new site, GroupsNearYou.' ], + [ 'gny0', '<h2>Are you a member of a local group…</h2> …which uses the internet to coordinate itself, such as a neighbourhood watch? If so, please help the charity that runs FixMyStreet by <a href="http://www.groupsnearyou.com/add/about/">adding some information about it</a> to our new site, GroupsNearYou.' ], # Since you're interested in your local area, why not # start a long term relationship with your MP? - [ 'hfymp', '<h2 style="margin-bottom:0">Get email from your MP in the future</h2> <p style="font-size:120%;margin-top:0;">and have a chance to discuss what they say in a public forum [form]Sign up to HearFromYourMP[/form]' ], - [ 'twfy_alerts', '<h2>Get emailed every time your MP says something in Parliament</h2> [button]Keep an eye on them for free![/button]' ], + [ 'hfymp0', '<h2 style="margin-bottom:0">Get email from your MP in the future</h2> <p style="font-size:120%;margin-top:0;">and have a chance to discuss what they say in a public forum [form]Sign up to HearFromYourMP[/form]' ], + [ 'twfy_alerts0', '<h2>Get emailed every time your MP says something in Parliament</h2> [button]Keep an eye on them for free![/button]' ], ); while (@adverts) { my $rand = int(rand(scalar @adverts)); next unless $adverts[$rand]; - my ($advert_site, $advert_text) = @{$adverts[$rand]}; + my ($advert_id, $advert_text) = @{$adverts[$rand]}; + (my $advert_site = $advert_id) =~ s/\d+$//; my $func = "display_random_${advert_site}_advert"; no strict 'refs'; my $out = &$func($email, $name, $advert_text); use strict 'refs'; if ($out) { - $q->{scratch} = "advert=$advert_site$rand"; + $q->{scratch} = "advert=$advert_id"; return $out; } for (my $i=0; $i<@adverts; $i++) { - delete $adverts[$i] if $advert_site eq $adverts[$i][0]; + (my $a = $adverts[$i][0]) =~ s/\d+$//; + delete $adverts[$i] if $advert_site eq $a; } } |