aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/Result/User.pm
diff options
context:
space:
mode:
authorZarino Zappia <mail@zarino.co.uk>2016-08-03 16:15:19 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-08-10 09:33:39 +0100
commite0308e6af55a95f8c6e26e331434ea61259b18b9 (patch)
tree86d97dd8a4f9a87557db7f518fb291aac30ae652 /perllib/FixMyStreet/DB/Result/User.pm
parent0c31945416238d7eb06543c107214adfd4b83734 (diff)
Feature to create report as body/other user.
This allows users who have the correct permissions to add reports on behalf of the body or another user. We enable editing of the email box by default, so that if JavaScript isn't available, someone can still change the email for the 'another user' option. For mysociety/fixmystreetforcouncils#10 and mysociety/fixmystreetforcouncils#11
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/User.pm')
-rw-r--r--perllib/FixMyStreet/DB/Result/User.pm8
1 files changed, 8 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm
index 65dd1dab1..7d1785c4b 100644
--- a/perllib/FixMyStreet/DB/Result/User.pm
+++ b/perllib/FixMyStreet/DB/Result/User.pm
@@ -243,6 +243,14 @@ sub has_permission_to {
return $permission ? 1 : undef;
}
+sub contributing_as {
+ my ($self, $other, $c, $bodies) = @_;
+ $bodies = join(',', keys %$bodies) if ref $bodies eq 'HASH';
+ $c->log->error("Bad data $bodies passed to contributing_as") if ref $bodies;
+ my $form_as = $c->get_param('form_as') || '';
+ return 1 if $form_as eq $other && $self->has_permission_to("contribute_as_$other", $bodies);
+}
+
sub adopt {
my ($self, $other) = @_;