2016-10-19 03:11:36 +00:00
|
|
|
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
2016-08-12 16:39:09 +00:00
|
|
|
|
|
|
|
class Permission < ApplicationModel
|
|
|
|
has_and_belongs_to_many :roles
|
|
|
|
validates :name, presence: true
|
|
|
|
store :preferences
|
|
|
|
notify_clients_support
|
|
|
|
latest_change_support
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
permissions = Permission.with_parents('some_key.sub_key')
|
|
|
|
|
2016-12-13 13:58:13 +00:00
|
|
|
returns
|
2016-08-12 16:39:09 +00:00
|
|
|
|
|
|
|
['some_key.sub_key', 'some_key']
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def self.with_parents(key)
|
|
|
|
names = []
|
|
|
|
part = ''
|
|
|
|
key.split('.').each { |local_part|
|
|
|
|
if part != ''
|
|
|
|
part += '.'
|
|
|
|
end
|
|
|
|
part += local_part
|
|
|
|
names.push part
|
|
|
|
}
|
|
|
|
names
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|