diff options
author | Byron Jones <glob@mozilla.com> | 2015-07-15 09:02:19 +0200 |
---|---|---|
committer | Byron Jones <glob@mozilla.com> | 2015-07-15 09:02:19 +0200 |
commit | e2635d9f405ec8b6f22b58d2ec1ec72c22d91df2 (patch) | |
tree | c502cfb9479ee53c811d0e0cb5dd0e590ea7ce94 /extensions/Review | |
parent | 7a87266845224adb56547f775ddbb01914a73d7f (diff) | |
download | bugzilla-e2635d9f405ec8b6f22b58d2ec1ec72c22d91df2.tar.gz bugzilla-e2635d9f405ec8b6f22b58d2ec1ec72c22d91df2.tar.xz |
Bug 1183975 - limit the number of accounts a new user can add to any multi-user field
Diffstat (limited to 'extensions/Review')
-rw-r--r-- | extensions/Review/Extension.pm | 6 | ||||
-rw-r--r-- | extensions/Review/template/en/default/hook/global/user-error-errors.html.tmpl | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/extensions/Review/Extension.pm b/extensions/Review/Extension.pm index e97269272..ef83b61b4 100644 --- a/extensions/Review/Extension.pm +++ b/extensions/Review/Extension.pm @@ -25,6 +25,7 @@ use Bugzilla::User::Setting; use Bugzilla::Util qw(clean_text datetime_from diff_arrays); use constant UNAVAILABLE_RE => qr/\b(?:unavailable|pto|away)\b/i; +use constant MENTOR_LIMIT => 10; # # monkey-patched methods @@ -171,11 +172,14 @@ sub object_validators { sub _bug_check_bug_mentors { my ($self, $value) = @_; my %seen; - return [ + my $mentors = [ grep { !$seen{$_->id}++ } map { Bugzilla::User->check({ name => $_, cache => 1 }) } ref($value) ? @$value : ($value) ]; + if (scalar(@$mentors) > MENTOR_LIMIT) { + ThrowUserError('mentor_limit_exceeded', { limit => MENTOR_LIMIT }); + } } sub bug_user_match_fields { diff --git a/extensions/Review/template/en/default/hook/global/user-error-errors.html.tmpl b/extensions/Review/template/en/default/hook/global/user-error-errors.html.tmpl index aafdb5445..4b8b7dcbf 100644 --- a/extensions/Review/template/en/default/hook/global/user-error-errors.html.tmpl +++ b/extensions/Review/template/en/default/hook/global/user-error-errors.html.tmpl @@ -34,4 +34,8 @@ [% requestee.identity FILTER html %] is not currently accepting '[% flagtype FILTER html %]' requests. +[% ELSIF error == "mentor_limit_exceeded" %] + [% title = "Too Many Mentors" %] + You cannot add more than [% limit FILTER html %] mentors to a [% terms.bug %]. + [% END %] |