aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/Bodies.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/Users.pm5
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm18
3 files changed, 24 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm
index bfa74ad4e..07d058872 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm
@@ -267,7 +267,7 @@ sub update_contact : Private {
$contact->send_method( $c->get_param('send_method') );
# Set flags in extra to the appropriate values
- foreach (qw(photo_required open311_protect updates_disallowed reopening_disallowed)) {
+ foreach (qw(photo_required open311_protect updates_disallowed reopening_disallowed assigned_users_only)) {
if ( $c->get_param($_) ) {
$contact->set_extra_metadata( $_ => 1 );
} else {
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Users.pm b/perllib/FixMyStreet/App/Controller/Admin/Users.pm
index 046e19126..f4b9bd7dc 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/Users.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/Users.pm
@@ -373,6 +373,11 @@ sub edit : Chained('user') : PathPart('') : Args(0) {
my @live_contact_ids = map { $_->id } @live_contacts;
my @new_contact_ids = grep { $c->get_param("contacts[$_]") } @live_contact_ids;
$user->set_extra_metadata('categories', \@new_contact_ids);
+ if ($c->get_param('assigned_categories_only')) {
+ $user->set_extra_metadata(assigned_categories_only => 1);
+ } else {
+ $user->unset_extra_metadata('assigned_categories_only');
+ }
} else {
$user->unset_extra_metadata('categories');
}
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 82e8b107f..3052b1015 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -87,6 +87,24 @@ sub display :PathPart('') :Chained('id') :Args(0) {
my $permissions = $c->stash->{permissions} ||= $c->forward('fetch_permissions');
+ my $staff_user = $c->user_exists && ($c->user->is_superuser || $c->user->belongs_to_body($c->stash->{problem}->bodies_str));
+
+ if ($staff_user) {
+ # Check assigned categories feature
+ my $okay = 1;
+ my $contact = $c->stash->{problem}->contact;
+ if ($contact && ($c->user->get_extra_metadata('assigned_categories_only') || $contact->get_extra_metadata('assigned_users_only'))) {
+ my $user_cats = $c->user->get_extra_metadata('categories') || [];
+ $okay = any { $contact->id eq $_ } @$user_cats;
+ }
+ if ($okay) {
+ $c->stash->{relevant_staff_user} = 1;
+ } else {
+ # Remove all staff permissions
+ $permissions = $c->stash->{permissions} = {};
+ }
+ }
+
if (grep { $permissions->{$_} } qw/report_inspect report_edit_category report_edit_priority report_mark_private triage/) {
$c->stash->{template} = 'report/inspect.html';
$c->forward('inspect');