diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-07-06 12:10:46 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-07-06 12:10:46 +0100 |
commit | 842ff2b00f4924f8580710c977ccce7bef33b0c2 (patch) | |
tree | e2ab4fda5a811b214fb4f501208f98f07a2c3c41 /perllib/FixMyStreet/App | |
parent | deb369669b540f607e435390f4606b927569dded (diff) |
Factor out the SQL restriction from site_restriction, as it's only used in one place.
Diffstat (limited to 'perllib/FixMyStreet/App')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 11 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Rss.pm | 6 |
2 files changed, 8 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 871da737f..3bcadd758 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -50,7 +50,7 @@ sub index : Path : Args(0) { $c->forward('check_page_allowed'); - my ( $sql_restriction, $id, $site_restriction ) = $c->cobrand->site_restriction(); + my ( $id, $site_restriction ) = $c->cobrand->site_restriction(); my $problems = $c->cobrand->problems->summary_count; @@ -122,7 +122,7 @@ sub timeline : Path( 'timeline' ) : Args(0) { $c->forward('check_page_allowed'); - my ( $sql_restriction, $id, $site_restriction ) = $c->cobrand->site_restriction(); + my ( $id, $site_restriction ) = $c->cobrand->site_restriction(); my %time; $c->model('DB')->schema->storage->sql_maker->quote_char( '"' ); @@ -472,7 +472,7 @@ sub search_reports : Path('search_reports') { if (my $search = $c->req->param('search')) { $c->stash->{searched} = 1; - my ( $site_res_sql, $site_key, $site_restriction ) = $c->cobrand->site_restriction; + my ( $site_key, $site_restriction ) = $c->cobrand->site_restriction; my $search_n = 0; $search_n = int($search) if $search =~ /^\d+$/; @@ -574,7 +574,7 @@ sub search_reports : Path('search_reports') { sub report_edit : Path('report_edit') : Args(1) { my ( $self, $c, $id ) = @_; - my ( $site_res_sql, $site_key, $site_restriction ) = $c->cobrand->site_restriction; + my ( $site_key, $site_restriction ) = $c->cobrand->site_restriction; my $problem = $c->cobrand->problems->search( { @@ -735,8 +735,7 @@ sub search_users: Path('search_users') : Args(0) { sub update_edit : Path('update_edit') : Args(1) { my ( $self, $c, $id ) = @_; - my ( $site_res_sql, $site_key, $site_restriction ) = - $c->cobrand->site_restriction; + my ( $site_key, $site_restriction ) = $c->cobrand->site_restriction; my $update = $c->model('DB::Comment')->search( { id => $id, diff --git a/perllib/FixMyStreet/App/Controller/Rss.pm b/perllib/FixMyStreet/App/Controller/Rss.pm index 4d0b6cb93..f898d06a0 100755 --- a/perllib/FixMyStreet/App/Controller/Rss.pm +++ b/perllib/FixMyStreet/App/Controller/Rss.pm @@ -205,14 +205,14 @@ sub query_main : Private { my ( $self, $c ) = @_; my $alert_type = $c->stash->{alert_type}; - my ( $site_restriction, $site_id ) = $c->cobrand->site_restriction( $c->cobrand->extra_data ); + my ( $sql_restriction ) = $c->cobrand->sql_restriction( $c->cobrand->extra_data ); # Only apply a site restriction if the alert uses the problem table - $site_restriction = '' unless $alert_type->item_table eq 'problem'; + $sql_restriction = '' unless $alert_type->item_table eq 'problem'; # FIXME Do this in a nicer way at some point in the future... my $query = 'select * from ' . $alert_type->item_table . ' where ' . ($alert_type->head_table ? $alert_type->head_table . '_id=? and ' : '') - . $alert_type->item_where . $site_restriction . ' order by ' + . $alert_type->item_where . $sql_restriction . ' order by ' . $alert_type->item_order; my $rss_limit = mySociety::Config::get('RSS_LIMIT'); $query .= " limit $rss_limit" unless $c->stash->{type} =~ /^all/; |