2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-07-23 13:07:16 +00:00
|
|
|
|
|
|
|
class KnowledgeBasePolicy < ApplicationPolicy
|
2022-02-24 11:15:19 +00:00
|
|
|
def show?
|
|
|
|
access_editor? || access_reader?
|
|
|
|
end
|
|
|
|
|
|
|
|
def update?
|
|
|
|
access_editor?
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def access
|
|
|
|
@access ||= KnowledgeBase::EffectivePermission.new(user, record).access_effective
|
|
|
|
end
|
|
|
|
|
|
|
|
def access_editor?
|
|
|
|
access == 'editor'
|
|
|
|
end
|
|
|
|
|
|
|
|
def access_reader?
|
|
|
|
access == 'reader'
|
2021-07-23 13:07:16 +00:00
|
|
|
end
|
|
|
|
end
|