diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 1190dcff3..551fe482b 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -1,23 +1,22 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class ApplicationModel < ActiveRecord::Base - include ApplicationModel::ActivityStreamLoggable - include ApplicationModel::Cacheable + include ApplicationModel::CanActivityStreamLog + include ApplicationModel::HasCache include ApplicationModel::CanLookup include ApplicationModel::CanLookupSearchIndexAttributes include ApplicationModel::ChecksAttributeLength - include ApplicationModel::CleansParam - include ApplicationModel::CleansRecentView - include ApplicationModel::FillsByUserColumns - include ApplicationModel::HandlesCreatesAndUpdates - include ApplicationModel::HasAssets - include ApplicationModel::HasAssociations + include ApplicationModel::CanCleanupParam + include ApplicationModel::HasRecentViews + include ApplicationModel::ChecksUserColumnsFillup + include ApplicationModel::CanCreatesAndUpdates + include ApplicationModel::CanAssets + include ApplicationModel::CanAssociations include ApplicationModel::HasAttachments - include ApplicationModel::HasLatestChangeTimestamp + include ApplicationModel::CanLatestChange include ApplicationModel::HasExternalSync - include ApplicationModel::Importable - include ApplicationModel::HistoryLoggable - include ApplicationModel::TouchesReferences + include ApplicationModel::ChecksImport + include ApplicationModel::CanTouchReferences self.abstract_class = true end diff --git a/app/models/application_model/activity_stream_loggable.rb b/app/models/application_model/can_activity_stream_log.rb similarity index 96% rename from app/models/application_model/activity_stream_loggable.rb rename to app/models/application_model/can_activity_stream_log.rb index 8a884d23f..b1498b6da 100644 --- a/app/models/application_model/activity_stream_loggable.rb +++ b/app/models/application_model/can_activity_stream_log.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module ApplicationModel::ActivityStreamLoggable +module ApplicationModel::CanActivityStreamLog extend ActiveSupport::Concern =begin diff --git a/app/models/application_model/has_assets.rb b/app/models/application_model/can_assets.rb similarity index 99% rename from app/models/application_model/has_assets.rb rename to app/models/application_model/can_assets.rb index a7dff804a..838670092 100644 --- a/app/models/application_model/has_assets.rb +++ b/app/models/application_model/can_assets.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module ApplicationModel::HasAssets +module ApplicationModel::CanAssets extend ActiveSupport::Concern =begin diff --git a/app/models/application_model/has_associations.rb b/app/models/application_model/can_associations.rb similarity index 99% rename from app/models/application_model/has_associations.rb rename to app/models/application_model/can_associations.rb index 0718aac30..812217b26 100644 --- a/app/models/application_model/has_associations.rb +++ b/app/models/application_model/can_associations.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module ApplicationModel::HasAssociations +module ApplicationModel::CanAssociations extend ActiveSupport::Concern =begin diff --git a/app/models/application_model/cleans_param.rb b/app/models/application_model/can_cleanup_param.rb similarity index 98% rename from app/models/application_model/cleans_param.rb rename to app/models/application_model/can_cleanup_param.rb index e0b092f38..7823ca0e7 100644 --- a/app/models/application_model/cleans_param.rb +++ b/app/models/application_model/can_cleanup_param.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module ApplicationModel::CleansParam +module ApplicationModel::CanCleanupParam extend ActiveSupport::Concern # methods defined here are going to extend the class, not the instance of it diff --git a/app/models/application_model/handles_creates_and_updates.rb b/app/models/application_model/can_creates_and_updates.rb similarity index 99% rename from app/models/application_model/handles_creates_and_updates.rb rename to app/models/application_model/can_creates_and_updates.rb index ab368ecff..45fabaa1b 100644 --- a/app/models/application_model/handles_creates_and_updates.rb +++ b/app/models/application_model/can_creates_and_updates.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module ApplicationModel::HandlesCreatesAndUpdates +module ApplicationModel::CanCreatesAndUpdates extend ActiveSupport::Concern # methods defined here are going to extend the class, not the instance of it diff --git a/app/models/application_model/has_latest_change_timestamp.rb b/app/models/application_model/can_latest_change.rb similarity index 95% rename from app/models/application_model/has_latest_change_timestamp.rb rename to app/models/application_model/can_latest_change.rb index 2d4b8e610..ad69dcc48 100644 --- a/app/models/application_model/has_latest_change_timestamp.rb +++ b/app/models/application_model/can_latest_change.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module ApplicationModel::HasLatestChangeTimestamp +module ApplicationModel::CanLatestChange extend ActiveSupport::Concern # methods defined here are going to extend the class, not the instance of it diff --git a/app/models/application_model/touches_references.rb b/app/models/application_model/can_touch_references.rb similarity index 92% rename from app/models/application_model/touches_references.rb rename to app/models/application_model/can_touch_references.rb index 84fad3692..b73eeac6b 100644 --- a/app/models/application_model/touches_references.rb +++ b/app/models/application_model/can_touch_references.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module ApplicationModel::TouchesReferences +module ApplicationModel::CanTouchReferences extend ActiveSupport::Concern # methods defined here are going to extend the class, not the instance of it diff --git a/app/models/application_model/importable.rb b/app/models/application_model/checks_import.rb similarity index 93% rename from app/models/application_model/importable.rb rename to app/models/application_model/checks_import.rb index f919b64d4..2e5e65868 100644 --- a/app/models/application_model/importable.rb +++ b/app/models/application_model/checks_import.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module ApplicationModel::Importable +module ApplicationModel::ChecksImport extend ActiveSupport::Concern included do diff --git a/app/models/application_model/fills_by_user_columns.rb b/app/models/application_model/checks_user_columns_fillup.rb similarity index 97% rename from app/models/application_model/fills_by_user_columns.rb rename to app/models/application_model/checks_user_columns_fillup.rb index df2075441..b70bf8060 100644 --- a/app/models/application_model/fills_by_user_columns.rb +++ b/app/models/application_model/checks_user_columns_fillup.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module ApplicationModel::FillsByUserColumns +module ApplicationModel::ChecksUserColumnsFillup extend ActiveSupport::Concern included do diff --git a/app/models/application_model/cacheable.rb b/app/models/application_model/has_cache.rb similarity index 97% rename from app/models/application_model/cacheable.rb rename to app/models/application_model/has_cache.rb index a07b7decf..9446cfe29 100644 --- a/app/models/application_model/cacheable.rb +++ b/app/models/application_model/has_cache.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module ApplicationModel::Cacheable +module ApplicationModel::HasCache extend ActiveSupport::Concern included do diff --git a/app/models/application_model/cleans_recent_view.rb b/app/models/application_model/has_recent_views.rb similarity index 90% rename from app/models/application_model/cleans_recent_view.rb rename to app/models/application_model/has_recent_views.rb index bd0c5e24a..b8f493e86 100644 --- a/app/models/application_model/cleans_recent_view.rb +++ b/app/models/application_model/has_recent_views.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module ApplicationModel::CleansRecentView +module ApplicationModel::HasRecentViews extend ActiveSupport::Concern included do diff --git a/app/models/application_model/history_loggable.rb b/app/models/application_model/history_loggable.rb deleted file mode 100644 index fcd28d08f..000000000 --- a/app/models/application_model/history_loggable.rb +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module ApplicationModel::HistoryLoggable - extend ActiveSupport::Concern - -=begin - -create history entry for this object - - organization = Organization.find(123) - result = organization.history_log('created', user_id) - -returns - - result = true # false - -=end - - def history_log(type, user_id, attributes = {}) - - attributes.merge!( - o_id: self['id'], - history_type: type, - history_object: self.class.name, - related_o_id: nil, - related_history_object: nil, - created_by_id: user_id, - updated_at: updated_at, - created_at: updated_at, - ).merge!(history_log_attributes) - - History.add(attributes) - end - - # callback function to overwrite - # default history log attributes - # gets called from history_log - def history_log_attributes - {} - end - -=begin - -get history log for this object - - organization = Organization.find(123) - result = organization.history_get() - -returns - - result = [ - { - :type => 'created', - :object => 'Organization', - :created_by_id => 3, - :created_at => "2013-08-19 20:41:33", - }, - { - :type => 'updated', - :object => 'Organization', - :attribute => 'note', - :o_id => 1, - :id_to => nil, - :id_from => nil, - :value_from => "some note", - :value_to => "some other note", - :created_by_id => 3, - :created_at => "2013-08-19 20:41:33", - }, - ] - -to get history log for this object with all assets - - organization = Organization.find(123) - result = organization.history_get(true) - -returns - - result = { - :history => [ - { ... }, - { ... }, - ], - :assets => { - ... - } - } - -=end - - def history_get(fulldata = false) - if !fulldata - return History.list(self.class.name, self['id']) - end - - # get related objects - history = History.list(self.class.name, self['id'], nil, true) - history[:list].each { |item| - record = Kernel.const_get(item['object']).find(item['o_id']) - - history[:assets] = record.assets(history[:assets]) - - if item['related_object'] - record = Kernel.const_get(item['related_object']).find(item['related_o_id']) - history[:assets] = record.assets(history[:assets]) - end - } - { - history: history[:list], - assets: history[:assets], - } - end -end diff --git a/app/models/calendar.rb b/app/models/calendar.rb index 9bd526ec1..882e19a6b 100644 --- a/app/models/calendar.rb +++ b/app/models/calendar.rb @@ -1,8 +1,8 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Calendar < ApplicationModel - include NotifiesClients - include UniqNamed + include ChecksClientNotification + include CanUniqName store :business_hours store :public_holidays diff --git a/app/models/chat/message.rb b/app/models/chat/message.rb index a86b0bba1..a343cf418 100644 --- a/app/models/chat/message.rb +++ b/app/models/chat/message.rb @@ -1,5 +1,5 @@ class Chat::Message < ApplicationModel - include HtmlSanitized + include ChecksHtmlSanitized sanitized_html :content end diff --git a/app/models/concerns/seedable.rb b/app/models/concerns/can_seed.rb similarity index 96% rename from app/models/concerns/seedable.rb rename to app/models/concerns/can_seed.rb index 8f5e79ff4..13d6d91bd 100644 --- a/app/models/concerns/seedable.rb +++ b/app/models/concerns/can_seed.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module Seedable +module CanSeed extend ActiveSupport::Concern # methods defined here are going to extend the class, not the instance of it diff --git a/app/models/concerns/uniq_named.rb b/app/models/concerns/can_uniq_name.rb similarity index 97% rename from app/models/concerns/uniq_named.rb rename to app/models/concerns/can_uniq_name.rb index 4ee4f465f..e00baf348 100644 --- a/app/models/concerns/uniq_named.rb +++ b/app/models/concerns/can_uniq_name.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module UniqNamed +module CanUniqName extend ActiveSupport::Concern # methods defined here are going to extend the class, not the instance of it diff --git a/app/models/concerns/notifies_clients.rb b/app/models/concerns/checks_client_notification.rb similarity index 99% rename from app/models/concerns/notifies_clients.rb rename to app/models/concerns/checks_client_notification.rb index e3997c694..dea69363b 100644 --- a/app/models/concerns/notifies_clients.rb +++ b/app/models/concerns/checks_client_notification.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module NotifiesClients +module ChecksClientNotification extend ActiveSupport::Concern included do diff --git a/app/models/concerns/validates_condition.rb b/app/models/concerns/checks_condition_validation.rb similarity index 96% rename from app/models/concerns/validates_condition.rb rename to app/models/concerns/checks_condition_validation.rb index 77f5beca5..945f978c0 100644 --- a/app/models/concerns/validates_condition.rb +++ b/app/models/concerns/checks_condition_validation.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module ValidatesCondition +module ChecksConditionValidation extend ActiveSupport::Concern included do diff --git a/app/models/concerns/html_sanitized.rb b/app/models/concerns/checks_html_sanitized.rb similarity index 97% rename from app/models/concerns/html_sanitized.rb rename to app/models/concerns/checks_html_sanitized.rb index 116967e7e..f3db21a9a 100644 --- a/app/models/concerns/html_sanitized.rb +++ b/app/models/concerns/checks_html_sanitized.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module HtmlSanitized +module ChecksHtmlSanitized extend ActiveSupport::Concern included do diff --git a/app/models/concerns/latest_change_observed.rb b/app/models/concerns/checks_latest_change_observed.rb similarity index 93% rename from app/models/concerns/latest_change_observed.rb rename to app/models/concerns/checks_latest_change_observed.rb index 3e390158c..97b8a37ca 100644 --- a/app/models/concerns/latest_change_observed.rb +++ b/app/models/concerns/checks_latest_change_observed.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module LatestChangeObserved +module ChecksLatestChangeObserved extend ActiveSupport::Concern included do diff --git a/app/models/concerns/logs_activity_stream.rb b/app/models/concerns/has_activity_stream_log.rb similarity index 97% rename from app/models/concerns/logs_activity_stream.rb rename to app/models/concerns/has_activity_stream_log.rb index 6c9ac12e9..8af68e63a 100644 --- a/app/models/concerns/logs_activity_stream.rb +++ b/app/models/concerns/has_activity_stream_log.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module LogsActivityStream +module HasActivityStreamLog extend ActiveSupport::Concern included do @@ -69,7 +69,7 @@ delete object activity stream, will be executed automatically serve methode to ignore model attributes in activity stream and/or limit activity stream permission class Model < ApplicationModel - include LogsActivityStream + include HasActivityStreamLog activity_stream_permission 'admin.user' activity_stream_attributes_ignored :create_article_type_id, :preferences end diff --git a/app/models/concerns/historisable.rb b/app/models/concerns/has_history.rb similarity index 60% rename from app/models/concerns/historisable.rb rename to app/models/concerns/has_history.rb index a95623d5f..10eeb1128 100644 --- a/app/models/concerns/historisable.rb +++ b/app/models/concerns/has_history.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module Historisable +module HasHistory extend ActiveSupport::Concern included do @@ -120,6 +120,114 @@ delete object history, will be executed automatically History.remove(self.class.to_s, id) end +=begin + +create history entry for this object + + organization = Organization.find(123) + result = organization.history_log('created', user_id) + +returns + + result = true # false + +=end + + def history_log(type, user_id, attributes = {}) + + attributes.merge!( + o_id: self['id'], + history_type: type, + history_object: self.class.name, + related_o_id: nil, + related_history_object: nil, + created_by_id: user_id, + updated_at: updated_at, + created_at: updated_at, + ).merge!(history_log_attributes) + + History.add(attributes) + end + + # callback function to overwrite + # default history log attributes + # gets called from history_log + def history_log_attributes + {} + end + +=begin + +get history log for this object + + organization = Organization.find(123) + result = organization.history_get() + +returns + + result = [ + { + :type => 'created', + :object => 'Organization', + :created_by_id => 3, + :created_at => "2013-08-19 20:41:33", + }, + { + :type => 'updated', + :object => 'Organization', + :attribute => 'note', + :o_id => 1, + :id_to => nil, + :id_from => nil, + :value_from => "some note", + :value_to => "some other note", + :created_by_id => 3, + :created_at => "2013-08-19 20:41:33", + }, + ] + +to get history log for this object with all assets + + organization = Organization.find(123) + result = organization.history_get(true) + +returns + + result = { + :history => [ + { ... }, + { ... }, + ], + :assets => { + ... + } + } + +=end + + def history_get(fulldata = false) + if !fulldata + return History.list(self.class.name, self['id']) + end + + # get related objects + history = History.list(self.class.name, self['id'], nil, true) + history[:list].each { |item| + record = Kernel.const_get(item['object']).find(item['o_id']) + + history[:assets] = record.assets(history[:assets]) + + if item['related_object'] + record = Kernel.const_get(item['related_object']).find(item['related_o_id']) + history[:assets] = record.assets(history[:assets]) + end + } + { + history: history[:list], + assets: history[:assets], + } + end + # methods defined here are going to extend the class, not the instance of it class_methods do =begin @@ -127,7 +235,7 @@ delete object history, will be executed automatically serve methode to ignore model attributes in historization class Model < ApplicationModel - include Historisable + include HasHistory history_attributes_ignored :create_article_type_id, :preferences end diff --git a/app/models/concerns/search_indexed.rb b/app/models/concerns/has_search_index_backend.rb similarity index 97% rename from app/models/concerns/search_indexed.rb rename to app/models/concerns/has_search_index_backend.rb index febbf6e5e..4ab81a4ab 100644 --- a/app/models/concerns/search_indexed.rb +++ b/app/models/concerns/has_search_index_backend.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module SearchIndexed +module HasSearchIndexBackend extend ActiveSupport::Concern included do @@ -102,7 +102,7 @@ returns serve methode to ignore model attributes in search index class Model < ApplicationModel - include SearchIndexed + include HasSearchIndexBackend search_index_attributes_ignored :password, :image end diff --git a/app/models/concerns/taggable.rb b/app/models/concerns/has_tags.rb similarity index 98% rename from app/models/concerns/taggable.rb rename to app/models/concerns/has_tags.rb index fcbee9d27..5dbbd5fae 100644 --- a/app/models/concerns/taggable.rb +++ b/app/models/concerns/has_tags.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ -module Taggable +module HasTags extend ActiveSupport::Concern included do diff --git a/app/models/email_address.rb b/app/models/email_address.rb index adc1e1089..b2918ebbc 100644 --- a/app/models/email_address.rb +++ b/app/models/email_address.rb @@ -1,7 +1,7 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class EmailAddress < ApplicationModel - include LatestChangeObserved + include ChecksLatestChangeObserved has_many :groups, after_add: :cache_update, after_remove: :cache_update belongs_to :channel diff --git a/app/models/group.rb b/app/models/group.rb index be8e5c99f..96a563e56 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,10 +1,10 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Group < ApplicationModel - include LogsActivityStream - include NotifiesClients - include LatestChangeObserved - include Historisable + include HasActivityStreamLog + include ChecksClientNotification + include ChecksLatestChangeObserved + include HasHistory has_and_belongs_to_many :users, after_add: :cache_update, after_remove: :cache_update belongs_to :email_address diff --git a/app/models/job.rb b/app/models/job.rb index e954008f8..332a58944 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -1,8 +1,8 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Job < ApplicationModel - include NotifiesClients - include ValidatesCondition + include ChecksClientNotification + include ChecksConditionValidation load 'job/assets.rb' include Job::Assets diff --git a/app/models/macro.rb b/app/models/macro.rb index af860f659..4d0a0b771 100644 --- a/app/models/macro.rb +++ b/app/models/macro.rb @@ -1,8 +1,8 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Macro < ApplicationModel - include NotifiesClients - include LatestChangeObserved + include ChecksClientNotification + include ChecksLatestChangeObserved store :perform validates :name, presence: true diff --git a/app/models/object_manager/attribute.rb b/app/models/object_manager/attribute.rb index ca7a83e1d..d49035ffd 100644 --- a/app/models/object_manager/attribute.rb +++ b/app/models/object_manager/attribute.rb @@ -1,5 +1,5 @@ class ObjectManager::Attribute < ApplicationModel - include NotifiesClients + include ChecksClientNotification self.table_name = 'object_manager_attributes' diff --git a/app/models/organization.rb b/app/models/organization.rb index e3fa9869b..18cb20eba 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -1,11 +1,11 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Organization < ApplicationModel - include LogsActivityStream - include NotifiesClients - include LatestChangeObserved - include Historisable - include SearchIndexed + include HasActivityStreamLog + include ChecksClientNotification + include ChecksLatestChangeObserved + include HasHistory + include HasSearchIndexBackend load 'organization/permission.rb' include Organization::Permission diff --git a/app/models/overview.rb b/app/models/overview.rb index 118d99345..aa1213b4b 100644 --- a/app/models/overview.rb +++ b/app/models/overview.rb @@ -1,10 +1,10 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Overview < ApplicationModel - include NotifiesClients - include LatestChangeObserved - include ValidatesCondition - include Seedable + include ChecksClientNotification + include ChecksLatestChangeObserved + include ChecksConditionValidation + include CanSeed load 'overview/assets.rb' include Overview::Assets diff --git a/app/models/permission.rb b/app/models/permission.rb index c926fe632..b43b1e35a 100644 --- a/app/models/permission.rb +++ b/app/models/permission.rb @@ -1,8 +1,8 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Permission < ApplicationModel - include NotifiesClients - include LatestChangeObserved + include ChecksClientNotification + include ChecksLatestChangeObserved has_and_belongs_to_many :roles validates :name, presence: true diff --git a/app/models/role.rb b/app/models/role.rb index 3c5ca4bbb..0ff38b23b 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,9 +1,9 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Role < ApplicationModel - include LogsActivityStream - include NotifiesClients - include LatestChangeObserved + include HasActivityStreamLog + include ChecksClientNotification + include ChecksLatestChangeObserved has_and_belongs_to_many :users, after_add: :cache_update, after_remove: :cache_update has_and_belongs_to_many :permissions, after_add: :cache_update, after_remove: :cache_update, before_add: :validate_agent_limit diff --git a/app/models/signature.rb b/app/models/signature.rb index 07be9f281..0435e0fff 100644 --- a/app/models/signature.rb +++ b/app/models/signature.rb @@ -1,7 +1,7 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Signature < ApplicationModel - include LatestChangeObserved + include ChecksLatestChangeObserved has_many :groups, after_add: :cache_update, after_remove: :cache_update validates :name, presence: true diff --git a/app/models/sla.rb b/app/models/sla.rb index 29fe06c5a..11aed5e6f 100644 --- a/app/models/sla.rb +++ b/app/models/sla.rb @@ -1,8 +1,8 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Sla < ApplicationModel - include NotifiesClients - include ValidatesCondition + include ChecksClientNotification + include ChecksConditionValidation load 'sla/assets.rb' include Sla::Assets diff --git a/app/models/template.rb b/app/models/template.rb index 70227e0a9..470b86239 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -1,7 +1,7 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Template < ApplicationModel - include NotifiesClients + include ChecksClientNotification store :options validates :name, presence: true diff --git a/app/models/text_module.rb b/app/models/text_module.rb index e95c8689c..357f0c78b 100644 --- a/app/models/text_module.rb +++ b/app/models/text_module.rb @@ -1,7 +1,7 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class TextModule < ApplicationModel - include NotifiesClients + include ChecksClientNotification validates :name, presence: true validates :content, presence: true diff --git a/app/models/ticket.rb b/app/models/ticket.rb index c29bae12f..a95f5467d 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -1,12 +1,12 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Ticket < ApplicationModel - include LogsActivityStream - include NotifiesClients - include LatestChangeObserved - include Historisable - include Taggable - include SearchIndexed + include HasActivityStreamLog + include ChecksClientNotification + include ChecksLatestChangeObserved + include HasHistory + include HasTags + include HasSearchIndexBackend include Ticket::Escalation include Ticket::Subject diff --git a/app/models/ticket/article.rb b/app/models/ticket/article.rb index 69e400263..738cf112f 100644 --- a/app/models/ticket/article.rb +++ b/app/models/ticket/article.rb @@ -1,9 +1,9 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Ticket::Article < ApplicationModel - include LogsActivityStream - include NotifiesClients - include Historisable - include HtmlSanitized + include HasActivityStreamLog + include ChecksClientNotification + include HasHistory + include ChecksHtmlSanitized load 'ticket/article/assets.rb' include Ticket::Article::Assets @@ -305,12 +305,12 @@ returns end class Sender < ApplicationModel - include LatestChangeObserved + include ChecksLatestChangeObserved validates :name, presence: true end class Type < ApplicationModel - include LatestChangeObserved + include ChecksLatestChangeObserved validates :name, presence: true end end diff --git a/app/models/ticket/state.rb b/app/models/ticket/state.rb index 37561d4c9..285a65eae 100644 --- a/app/models/ticket/state.rb +++ b/app/models/ticket/state.rb @@ -1,6 +1,6 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Ticket::State < ApplicationModel - include LatestChangeObserved + include ChecksLatestChangeObserved after_create :ensure_defaults after_update :ensure_defaults diff --git a/app/models/ticket/state_type.rb b/app/models/ticket/state_type.rb index 94278ace3..454b2727e 100644 --- a/app/models/ticket/state_type.rb +++ b/app/models/ticket/state_type.rb @@ -1,6 +1,6 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Ticket::StateType < ApplicationModel - include LatestChangeObserved + include ChecksLatestChangeObserved has_many :states, class_name: 'Ticket::State' validates :name, presence: true diff --git a/app/models/trigger.rb b/app/models/trigger.rb index 8fee22905..23b71280d 100644 --- a/app/models/trigger.rb +++ b/app/models/trigger.rb @@ -1,7 +1,7 @@ # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ class Trigger < ApplicationModel - include ValidatesCondition + include ChecksConditionValidation store :condition store :perform diff --git a/app/models/user.rb b/app/models/user.rb index 70f772f2c..cbf763f2a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -24,10 +24,10 @@ require 'digest/md5' # @property active [Boolean] The flag that shows the active state of the User. # @property note [String] The note or comment stored to the User. class User < ApplicationModel - include LogsActivityStream - include NotifiesClients - include Historisable - include SearchIndexed + include HasActivityStreamLog + include ChecksClientNotification + include HasHistory + include HasSearchIndexBackend load 'user/permission.rb' include User::Permission