summaryrefslogtreecommitdiff
path: root/lib/gitlab/visibility_level.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/visibility_level.rb')
-rw-r--r--lib/gitlab/visibility_level.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb
index a1ee1cba216..9462f3368e6 100644
--- a/lib/gitlab/visibility_level.rb
+++ b/lib/gitlab/visibility_level.rb
@@ -32,6 +32,13 @@ module Gitlab
}
end
+ def highest_allowed_level
+ restricted_levels = current_application_settings.restricted_visibility_levels
+
+ allowed_levels = self.values - restricted_levels
+ allowed_levels.max || PRIVATE
+ end
+
def allowed_for?(user, level)
user.is_admin? || allowed_level?(level.to_i)
end