2016-10-19 03:11:36 +00:00
|
|
|
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
class Organization < ApplicationModel
|
2016-08-12 16:39:09 +00:00
|
|
|
load 'organization/permission.rb'
|
2014-12-31 13:56:37 +00:00
|
|
|
include Organization::Permission
|
2014-10-17 12:15:54 +00:00
|
|
|
load 'organization/assets.rb'
|
2013-08-19 06:29:49 +00:00
|
|
|
include Organization::Assets
|
|
|
|
extend Organization::Search
|
2016-07-06 06:13:44 +00:00
|
|
|
load 'organization/search_index.rb'
|
2014-01-29 23:54:34 +00:00
|
|
|
include Organization::SearchIndex
|
2013-08-19 06:29:49 +00:00
|
|
|
|
2014-08-12 19:40:56 +00:00
|
|
|
has_and_belongs_to_many :users
|
2015-04-27 13:42:53 +00:00
|
|
|
has_many :members, class_name: 'User'
|
|
|
|
validates :name, presence: true
|
2014-08-12 19:40:56 +00:00
|
|
|
|
2016-11-13 22:59:39 +00:00
|
|
|
before_create :domain_cleanup
|
|
|
|
before_update :domain_cleanup
|
|
|
|
|
2016-08-12 16:39:09 +00:00
|
|
|
activity_stream_support permission: 'admin.role'
|
2013-09-29 16:40:42 +00:00
|
|
|
history_support
|
2014-01-27 22:59:41 +00:00
|
|
|
search_index_support
|
2015-02-01 12:08:11 +00:00
|
|
|
notify_clients_support
|
2015-02-25 20:52:14 +00:00
|
|
|
latest_change_support
|
2015-06-18 22:39:34 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-11-13 22:59:39 +00:00
|
|
|
def domain_cleanup
|
2016-12-02 11:24:00 +00:00
|
|
|
return if domain.blank?
|
2016-11-13 22:59:39 +00:00
|
|
|
domain.gsub!(/@/, '')
|
|
|
|
domain.gsub!(/\s*/, '')
|
|
|
|
domain.strip!
|
|
|
|
domain.downcase!
|
|
|
|
end
|
|
|
|
|
2015-06-18 22:39:34 +00:00
|
|
|
def cache_delete
|
|
|
|
super
|
|
|
|
|
|
|
|
# delete asset caches
|
|
|
|
key = "Organization::member_ids::#{id}"
|
|
|
|
Cache.delete(key)
|
|
|
|
end
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|