aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/Cobrand.pm15
-rw-r--r--perllib/Problems.pm6
-rwxr-xr-xt/Cobrand.t8
3 files changed, 14 insertions, 15 deletions
diff --git a/perllib/Cobrand.pm b/perllib/Cobrand.pm
index 13ba644a9..d0f15947a 100644
--- a/perllib/Cobrand.pm
+++ b/perllib/Cobrand.pm
@@ -7,7 +7,7 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: Cobrand.pm,v 1.40 2009-11-17 13:58:47 louise Exp $
+# $Id: Cobrand.pm,v 1.41 2009-11-19 09:56:11 louise Exp $
package Cobrand;
use strict;
@@ -61,21 +61,20 @@ sub cobrand_page {
return $handle->page($q);
}
-=item set_site_restriction Q
+=item site_restriction COBRAND COBRAND_DATA
Return a site restriction clause and a site key if the cobrand uses a subset of the FixMyStreet
-data. Q is the query object. Returns an empty string and site key 0 if the cobrand uses all the
-data.
+data. COBRAND_DATA is any extra data the cobrand needs. Returns an empty string and site key 0
+if the cobrand uses all the data.
=cut
-sub set_site_restriction {
- my $q = shift;
+sub site_restriction {
+ my ($cobrand, $cobrand_data) = @_;
my $site_restriction = '';
my $site_id = 0;
- my $cobrand = Page::get_cobrand($q);
my $handle = cobrand_handle($cobrand);
return ($site_restriction, $site_id) unless $handle;
- return $handle->site_restriction($q);
+ return $handle->site_restriction($cobrand_data);
}
=item contact_restriction COBRAND
diff --git a/perllib/Problems.pm b/perllib/Problems.pm
index 685c0db0b..4d5a32fbd 100644
--- a/perllib/Problems.pm
+++ b/perllib/Problems.pm
@@ -6,7 +6,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Problems.pm,v 1.29 2009-11-18 16:43:42 louise Exp $
+# $Id: Problems.pm,v 1.30 2009-11-19 09:56:12 louise Exp $
#
package Problems;
@@ -25,7 +25,9 @@ sub set_site_restriction {
my $q = shift;
my $site = $q->{site};
if ($site ne 'fixmystreet'){
- ($site_restriction, $site_key) = Cobrand::set_site_restriction($q);
+ my $cobrand = Page::get_cobrand($q);
+ my $cobrand_data = Cobrand::extra_data($cobrand, $q);
+ ($site_restriction, $site_key) = Cobrand::site_restriction($cobrand, $cobrand_data);
} else {
$site_restriction = '';
$site_key = 0;
diff --git a/t/Cobrand.t b/t/Cobrand.t
index b5559381c..f63e3455b 100755
--- a/t/Cobrand.t
+++ b/t/Cobrand.t
@@ -6,7 +6,7 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Cobrand.t,v 1.22 2009-10-21 15:58:25 louise Exp $
+# $Id: Cobrand.t,v 1.23 2009-11-19 09:56:12 louise Exp $
#
use strict;
@@ -23,13 +23,11 @@ use Cobrand;
use mySociety::MockQuery;
sub test_site_restriction {
- my $q = new MockQuery('mysite');
- my ($site_restriction, $site_id) = Cobrand::set_site_restriction($q);
+ my ($site_restriction, $site_id) = Cobrand::site_restriction('mysite', 'test');
like($site_restriction, qr/ and council = 1 /, 'should return result of cobrand module site_restriction function');
ok($site_id == 99, 'should return result of cobrand module site_restriction function');
- $q = new MockQuery('nosite');
- ($site_restriction, $site_id) = Cobrand::set_site_restriction($q);
+ ($site_restriction, $site_id) = Cobrand::site_restriction('nosite', 'test');
ok($site_restriction eq '', 'should return "" and zero if no module exists' );
ok($site_id == 0, 'should return "" and zero if no module exists');
}