diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 45c5a89fc..264e6b405 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module ApplicationHelper end diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index 6833fa8a0..b8a3288db 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module PostsHelper end diff --git a/app/models/activity_stream.rb b/app/models/activity_stream.rb index 13f8d67ef..b1ebeb87d 100644 --- a/app/models/activity_stream.rb +++ b/app/models/activity_stream.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class ActivityStream < ApplicationModel self.table_name = 'activity_streams' @@ -45,10 +45,10 @@ add a new activity entry for an object # check if entry is needed result = ActivityStream.where( :o_id => data[:o_id], - # :activity_stream_type_id => type.id, + # :activity_stream_type_id => type.id, :role_id => role_id, :activity_stream_object_id => object.id, - :created_by_id => data[:created_by_id] + :created_by_id => data[:created_by_id] ).last # resturn if old entry is really freash diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 41f1b8358..5fbcf2090 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class ApplicationModel < ActiveRecord::Base include ApplicationModel::Assets diff --git a/app/models/application_model/activity_stream_base.rb b/app/models/application_model/activity_stream_base.rb index 6f40308e2..34eaefc02 100644 --- a/app/models/application_model/activity_stream_base.rb +++ b/app/models/application_model/activity_stream_base.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module ApplicationModel::ActivityStreamBase @@ -35,4 +35,4 @@ returns ) end -end \ No newline at end of file +end diff --git a/app/models/application_model/assets.rb b/app/models/application_model/assets.rb index 7c8289584..1ad686537 100644 --- a/app/models/application_model/assets.rb +++ b/app/models/application_model/assets.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module ApplicationModel::Assets diff --git a/app/models/application_model/history_log_base.rb b/app/models/application_model/history_log_base.rb index cacdab982..743d155b5 100644 --- a/app/models/application_model/history_log_base.rb +++ b/app/models/application_model/history_log_base.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module ApplicationModel::HistoryLogBase @@ -97,4 +97,4 @@ returns } end -end \ No newline at end of file +end diff --git a/app/models/application_model/search_index_base.rb b/app/models/application_model/search_index_base.rb index fd7f4b76e..3865023ef 100644 --- a/app/models/application_model/search_index_base.rb +++ b/app/models/application_model/search_index_base.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module ApplicationModel::SearchIndexBase @@ -138,4 +138,4 @@ returns attributes_new.merge(attributes) end -end \ No newline at end of file +end diff --git a/app/models/authorization.rb b/app/models/authorization.rb index b0ae22971..332bfd71b 100644 --- a/app/models/authorization.rb +++ b/app/models/authorization.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Authorization < ApplicationModel belongs_to :user diff --git a/app/models/channel.rb b/app/models/channel.rb index b7d23bde9..cf2ed60fa 100644 --- a/app/models/channel.rb +++ b/app/models/channel.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Channel < ApplicationModel store :options diff --git a/app/models/channel/email_build.rb b/app/models/channel/email_build.rb index 9c74a9b3f..d3c77754c 100644 --- a/app/models/channel/email_build.rb +++ b/app/models/channel/email_build.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ require 'mail' diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index 315545d9f..64381d3f0 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ # encoding: utf-8 diff --git a/app/models/channel/facebook.rb b/app/models/channel/facebook.rb index 2dcbb9d03..7fdddca9d 100644 --- a/app/models/channel/facebook.rb +++ b/app/models/channel/facebook.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ #require 'rubygems' #require 'twitter' diff --git a/app/models/channel/filter/database.rb b/app/models/channel/filter/database.rb index 3334900af..a0ed78e75 100644 --- a/app/models/channel/filter/database.rb +++ b/app/models/channel/filter/database.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ # process all database filter module Channel::Filter::Database diff --git a/app/models/channel/filter/trusted.rb b/app/models/channel/filter/trusted.rb index ced56b611..e37cb12bb 100644 --- a/app/models/channel/filter/trusted.rb +++ b/app/models/channel/filter/trusted.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ # delete all X-Zammad header if channel is not trusted module Channel::Filter::Trusted diff --git a/app/models/channel/imap.rb b/app/models/channel/imap.rb index 62c3f6cc0..30816d504 100644 --- a/app/models/channel/imap.rb +++ b/app/models/channel/imap.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ require 'net/imap' diff --git a/app/models/channel/mail_stdin.rb b/app/models/channel/mail_stdin.rb index 20e722f2d..eaf9368fa 100644 --- a/app/models/channel/mail_stdin.rb +++ b/app/models/channel/mail_stdin.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Channel::MailStdin < Channel::EmailParser def initialize diff --git a/app/models/channel/pop3.rb b/app/models/channel/pop3.rb index 6648381fc..0a71e6358 100644 --- a/app/models/channel/pop3.rb +++ b/app/models/channel/pop3.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ require 'net/pop' diff --git a/app/models/channel/sendmail.rb b/app/models/channel/sendmail.rb index 808e72d51..b32d46ce1 100644 --- a/app/models/channel/sendmail.rb +++ b/app/models/channel/sendmail.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Channel::Sendmail < Channel::EmailBuild def send(attr, channel, notification = false) diff --git a/app/models/channel/smtp.rb b/app/models/channel/smtp.rb index d4952613f..3447a4127 100644 --- a/app/models/channel/smtp.rb +++ b/app/models/channel/smtp.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Channel::SMTP < Channel::EmailBuild def send(attr, channel, notification = false) diff --git a/app/models/channel/twitter2.rb b/app/models/channel/twitter2.rb index 0fa6b01e1..4401df826 100644 --- a/app/models/channel/twitter2.rb +++ b/app/models/channel/twitter2.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ require 'twitter' diff --git a/app/models/email_address.rb b/app/models/email_address.rb index de59f72a8..fcb01a689 100644 --- a/app/models/email_address.rb +++ b/app/models/email_address.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class EmailAddress < ApplicationModel has_many :groups, :after_add => :cache_update, :after_remove => :cache_update diff --git a/app/models/group.rb b/app/models/group.rb index b1813e6c9..3bde3ca40 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Group < ApplicationModel has_and_belongs_to_many :users, :after_add => :cache_update, :after_remove => :cache_update diff --git a/app/models/history.rb b/app/models/history.rb index 2a474a497..e1eb22b8c 100644 --- a/app/models/history.rb +++ b/app/models/history.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class History < ApplicationModel include History::Assets @@ -313,7 +313,7 @@ returns =begin -nothing to do on destroying history entries +nothing to do on destroying history entries =end diff --git a/app/models/history/assets.rb b/app/models/history/assets.rb index ba49440f4..c61dc1c3d 100644 --- a/app/models/history/assets.rb +++ b/app/models/history/assets.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module History::Assets @@ -32,4 +32,4 @@ returns data end -end \ No newline at end of file +end diff --git a/app/models/link.rb b/app/models/link.rb index adf9cc3ab..5a3001146 100644 --- a/app/models/link.rb +++ b/app/models/link.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Link < ApplicationModel belongs_to :link_type, :class_name => 'Link::Type' diff --git a/app/models/network.rb b/app/models/network.rb index 2940ac975..00c759148 100644 --- a/app/models/network.rb +++ b/app/models/network.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Network < ApplicationModel # belongs_to :group diff --git a/app/models/notification.rb b/app/models/notification.rb index 564b970ea..a95a8e6ca 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Notification < ActiveRecord::Base end diff --git a/app/models/observer/session.rb b/app/models/observer/session.rb index fdd96c2f8..d2e7f7f02 100644 --- a/app/models/observer/session.rb +++ b/app/models/observer/session.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ require 'history' diff --git a/app/models/observer/tag/ticket_history.rb b/app/models/observer/tag/ticket_history.rb index a127449a7..b38d7f6e9 100644 --- a/app/models/observer/tag/ticket_history.rb +++ b/app/models/observer/tag/ticket_history.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ require 'history' diff --git a/app/models/observer/ticket/article/communicate_email.rb b/app/models/observer/ticket/article/communicate_email.rb index bcecb0acd..94ee39aa5 100644 --- a/app/models/observer/ticket/article/communicate_email.rb +++ b/app/models/observer/ticket/article/communicate_email.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer observe 'ticket::_article' @@ -79,4 +79,4 @@ class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer end end -end \ No newline at end of file +end diff --git a/app/models/observer/ticket/article/communicate_facebook.rb b/app/models/observer/ticket/article/communicate_facebook.rb index c9c5ea893..eb523e8fa 100644 --- a/app/models/observer/ticket/article/communicate_facebook.rb +++ b/app/models/observer/ticket/article/communicate_facebook.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::Ticket::Article::CommunicateFacebook < ActiveRecord::Observer observe 'ticket::_article' diff --git a/app/models/observer/ticket/article/communicate_twitter.rb b/app/models/observer/ticket/article/communicate_twitter.rb index b30d61da6..8f4ff2261 100644 --- a/app/models/observer/ticket/article/communicate_twitter.rb +++ b/app/models/observer/ticket/article/communicate_twitter.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer observe 'ticket::_article' diff --git a/app/models/observer/ticket/article/fillup_from_email.rb b/app/models/observer/ticket/article/fillup_from_email.rb index 3273120df..b37c495fd 100644 --- a/app/models/observer/ticket/article/fillup_from_email.rb +++ b/app/models/observer/ticket/article/fillup_from_email.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer observe 'ticket::_article' diff --git a/app/models/observer/ticket/article/fillup_from_general.rb b/app/models/observer/ticket/article/fillup_from_general.rb index 06e590e1e..b87023aea 100644 --- a/app/models/observer/ticket/article/fillup_from_general.rb +++ b/app/models/observer/ticket/article/fillup_from_general.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::Ticket::Article::FillupFromGeneral < ActiveRecord::Observer observe 'ticket::_article' diff --git a/app/models/observer/ticket/article_counter.rb b/app/models/observer/ticket/article_counter.rb index f21420eff..839dae22b 100644 --- a/app/models/observer/ticket/article_counter.rb +++ b/app/models/observer/ticket/article_counter.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::Ticket::ArticleCounter < ActiveRecord::Observer observe 'ticket::_article' diff --git a/app/models/observer/ticket/article_sender_type.rb b/app/models/observer/ticket/article_sender_type.rb index adea94459..a7f547661 100644 --- a/app/models/observer/ticket/article_sender_type.rb +++ b/app/models/observer/ticket/article_sender_type.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::Ticket::ArticleSenderType < ActiveRecord::Observer observe 'ticket::_article' diff --git a/app/models/observer/ticket/close_time.rb b/app/models/observer/ticket/close_time.rb index eaf2182e5..19683b2c9 100644 --- a/app/models/observer/ticket/close_time.rb +++ b/app/models/observer/ticket/close_time.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::Ticket::CloseTime < ActiveRecord::Observer observe 'ticket' diff --git a/app/models/observer/ticket/escalation_calculation.rb b/app/models/observer/ticket/escalation_calculation.rb index 62fc167a8..5431d2b1f 100644 --- a/app/models/observer/ticket/escalation_calculation.rb +++ b/app/models/observer/ticket/escalation_calculation.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::Ticket::EscalationCalculation < ActiveRecord::Observer observe 'ticket', 'ticket::_article' diff --git a/app/models/observer/ticket/first_response.rb b/app/models/observer/ticket/first_response.rb index 220158797..5c7d6362c 100644 --- a/app/models/observer/ticket/first_response.rb +++ b/app/models/observer/ticket/first_response.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::Ticket::FirstResponse < ActiveRecord::Observer observe 'ticket::_article' diff --git a/app/models/observer/ticket/last_contact.rb b/app/models/observer/ticket/last_contact.rb index 596b94794..91b83b861 100644 --- a/app/models/observer/ticket/last_contact.rb +++ b/app/models/observer/ticket/last_contact.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::Ticket::LastContact < ActiveRecord::Observer observe 'ticket::_article' diff --git a/app/models/observer/ticket/notification.rb b/app/models/observer/ticket/notification.rb index 69ded6f6d..f372e9111 100644 --- a/app/models/observer/ticket/notification.rb +++ b/app/models/observer/ticket/notification.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ require 'event_buffer' require 'notification_factory' diff --git a/app/models/observer/ticket/reset_new_state.rb b/app/models/observer/ticket/reset_new_state.rb index fe9c1bf25..98c95dbde 100644 --- a/app/models/observer/ticket/reset_new_state.rb +++ b/app/models/observer/ticket/reset_new_state.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::Ticket::ResetNewState < ActiveRecord::Observer observe 'ticket::_article' diff --git a/app/models/observer/ticket/user_ticket_counter.rb b/app/models/observer/ticket/user_ticket_counter.rb index e3accb90d..60c613893 100644 --- a/app/models/observer/ticket/user_ticket_counter.rb +++ b/app/models/observer/ticket/user_ticket_counter.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::Ticket::UserTicketCounter < ActiveRecord::Observer observe 'ticket' diff --git a/app/models/observer/user/geo.rb b/app/models/observer/user/geo.rb index bf4d6ca65..51d82364e 100644 --- a/app/models/observer/user/geo.rb +++ b/app/models/observer/user/geo.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Observer::User::Geo < ActiveRecord::Observer observe 'user' @@ -18,7 +18,7 @@ class Observer::User::Geo < ActiveRecord::Observer # check if geo update is needed based on old/new location if record.id current = User.where( :id => record.id ).first - return if !current + return if !current current_location = {} location.each { |item| @@ -61,4 +61,4 @@ class Observer::User::Geo < ActiveRecord::Observer record.preferences['lat'] = latlng[0] record.preferences['lng'] = latlng[1] end -end \ No newline at end of file +end diff --git a/app/models/organization.rb b/app/models/organization.rb index 186c1da50..dc155b89b 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Organization < ApplicationModel include Organization::Assets @@ -13,4 +13,4 @@ class Organization < ApplicationModel history_support search_index_support -end \ No newline at end of file +end diff --git a/app/models/organization/assets.rb b/app/models/organization/assets.rb index 9bb88d15f..86fbc239d 100644 --- a/app/models/organization/assets.rb +++ b/app/models/organization/assets.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Organization::Assets @@ -40,4 +40,4 @@ returns data end -end \ No newline at end of file +end diff --git a/app/models/organization/search.rb b/app/models/organization/search.rb index 8607e44b6..2e82326e2 100644 --- a/app/models/organization/search.rb +++ b/app/models/organization/search.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Organization::Search @@ -71,4 +71,4 @@ returns end organizations end -end \ No newline at end of file +end diff --git a/app/models/organization/search_index.rb b/app/models/organization/search_index.rb index d5a93a053..a7aa0eb2b 100644 --- a/app/models/organization/search_index.rb +++ b/app/models/organization/search_index.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Organization::SearchIndex @@ -57,4 +57,4 @@ returns attributes_new.merge(attributes) end -end \ No newline at end of file +end diff --git a/app/models/overview.rb b/app/models/overview.rb index fc0911954..4696f14cb 100644 --- a/app/models/overview.rb +++ b/app/models/overview.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Overview < ApplicationModel store :condition diff --git a/app/models/package.rb b/app/models/package.rb index 1100912d5..7b23138eb 100644 --- a/app/models/package.rb +++ b/app/models/package.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ require 'rexml/document' class Package < ApplicationModel diff --git a/app/models/postmaster_filter.rb b/app/models/postmaster_filter.rb index 62ea286e2..9f8c2f917 100644 --- a/app/models/postmaster_filter.rb +++ b/app/models/postmaster_filter.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class PostmasterFilter < ApplicationModel store :perform diff --git a/app/models/recent_view.rb b/app/models/recent_view.rb index 63f4e1dbd..fc0f07204 100644 --- a/app/models/recent_view.rb +++ b/app/models/recent_view.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class RecentView < ApplicationModel belongs_to :recent_view_object, :class_name => 'RecentView::Object' diff --git a/app/models/role.rb b/app/models/role.rb index d0a22bfed..c07030299 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Role < ApplicationModel diff --git a/app/models/scheduler.rb b/app/models/scheduler.rb index 1b3e5f7d3..9e1078c40 100644 --- a/app/models/scheduler.rb +++ b/app/models/scheduler.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Scheduler < ApplicationModel @@ -62,27 +62,27 @@ class Scheduler < ApplicationModel end def self.worker - wait = 10 - puts "*** Starting worker #{Delayed::Job.to_s}" + wait = 10 + puts "*** Starting worker #{Delayed::Job.to_s}" - loop do - result = nil + loop do + result = nil - realtime = Benchmark.realtime do - result = Delayed::Worker.new.work_off - end - - count = result.sum - - break if $exit - - if count.zero? - sleep(wait) - puts "*** worker loop" - else - printf "*** #{count} jobs processed at %.4f j/s, %d failed ...\n" % [count / realtime, result.last] - end + realtime = Benchmark.realtime do + result = Delayed::Worker.new.work_off end + + count = result.sum + + break if $exit + + if count.zero? + sleep(wait) + puts "*** worker loop" + else + printf "*** #{count} jobs processed at %.4f j/s, %d failed ...\n" % [count / realtime, result.last] + end + end end def self.check( name, time_warning = 10, time_critical = 20 ) @@ -93,7 +93,7 @@ class Scheduler < ApplicationModel puts "CRITICAL - no such scheduler jobs '#{name}'" return true end -#puts "S " + scheduler.inspect + #puts "S " + scheduler.inspect if !scheduler.last_run puts "CRITICAL - scheduler jobs never started '#{name}'" exit 2 diff --git a/app/models/setting.rb b/app/models/setting.rb index 2a0db2f8e..a24e97881 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Setting < ApplicationModel store :options diff --git a/app/models/signature.rb b/app/models/signature.rb index 1abb91d86..d1cdc6c10 100644 --- a/app/models/signature.rb +++ b/app/models/signature.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Signature < ApplicationModel has_many :groups, :after_add => :cache_update, :after_remove => :cache_update diff --git a/app/models/sla.rb b/app/models/sla.rb index 455589f78..be1458777 100644 --- a/app/models/sla.rb +++ b/app/models/sla.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Sla < ApplicationModel store :condition diff --git a/app/models/store.rb b/app/models/store.rb index e127163c4..d887d1bad 100644 --- a/app/models/store.rb +++ b/app/models/store.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ require 'digest/md5' diff --git a/app/models/tag.rb b/app/models/tag.rb index 03079e402..2a5031e48 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Tag < ApplicationModel belongs_to :tag_object, :class_name => 'Tag::Object' diff --git a/app/models/taskbar.rb b/app/models/taskbar.rb index fd4636739..3d707221d 100644 --- a/app/models/taskbar.rb +++ b/app/models/taskbar.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Taskbar < ApplicationModel store :state diff --git a/app/models/template.rb b/app/models/template.rb index d18bb3ec3..001cdbcf4 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Template < ApplicationModel store :options diff --git a/app/models/text_module.rb b/app/models/text_module.rb index 77e55f0ac..8f019b879 100644 --- a/app/models/text_module.rb +++ b/app/models/text_module.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class TextModule < ApplicationModel validates :name, :presence => true diff --git a/app/models/ticket.rb b/app/models/ticket.rb index 5da4c773f..62ee4c9b1 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Ticket < ApplicationModel include Ticket::Escalation diff --git a/app/models/ticket/activity_stream_log.rb b/app/models/ticket/activity_stream_log.rb index b47483a7d..6273f1fd0 100644 --- a/app/models/ticket/activity_stream_log.rb +++ b/app/models/ticket/activity_stream_log.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::ActivityStreamLog @@ -29,4 +29,4 @@ returns ) end -end \ No newline at end of file +end diff --git a/app/models/ticket/article.rb b/app/models/ticket/article.rb index 61810d884..cb464add4 100644 --- a/app/models/ticket/article.rb +++ b/app/models/ticket/article.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Ticket::Article < ApplicationModel require 'ticket/article/assets' diff --git a/app/models/ticket/article/activity_stream_log.rb b/app/models/ticket/article/activity_stream_log.rb index c9b10da9d..46a280cd8 100644 --- a/app/models/ticket/article/activity_stream_log.rb +++ b/app/models/ticket/article/activity_stream_log.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::Article::ActivityStreamLog @@ -30,4 +30,4 @@ returns ) end -end \ No newline at end of file +end diff --git a/app/models/ticket/article/assets.rb b/app/models/ticket/article/assets.rb index c46df3ee6..5b65a7084 100644 --- a/app/models/ticket/article/assets.rb +++ b/app/models/ticket/article/assets.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::Article::Assets @@ -53,4 +53,4 @@ returns data end -end \ No newline at end of file +end diff --git a/app/models/ticket/article/history_log.rb b/app/models/ticket/article/history_log.rb index a47c50283..1a53c6591 100644 --- a/app/models/ticket/article/history_log.rb +++ b/app/models/ticket/article/history_log.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, httpdata[://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::Article::HistoryLog @@ -28,4 +28,4 @@ returns History.add(data) end -end \ No newline at end of file +end diff --git a/app/models/ticket/assets.rb b/app/models/ticket/assets.rb index e70ebf73b..53aa439f6 100644 --- a/app/models/ticket/assets.rb +++ b/app/models/ticket/assets.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::Assets @@ -48,4 +48,4 @@ returns data end -end \ No newline at end of file +end diff --git a/app/models/ticket/counter.rb b/app/models/ticket/counter.rb index 922a5b2e7..bcd1ed5bc 100644 --- a/app/models/ticket/counter.rb +++ b/app/models/ticket/counter.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Ticket::Counter < ApplicationModel end diff --git a/app/models/ticket/escalation.rb b/app/models/ticket/escalation.rb index 43f529b43..705daf675 100644 --- a/app/models/ticket/escalation.rb +++ b/app/models/ticket/escalation.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::Escalation @@ -163,7 +163,7 @@ returns =end -def escalation_calculation_get_sla + def escalation_calculation_get_sla sla_selected = nil sla_list = Cache.get( 'SLA::List::Active' ) if sla_list == nil @@ -201,115 +201,115 @@ def escalation_calculation_get_sla private - #type could be: - # real - time without supsend state - # relative - only suspend time + #type could be: + # real - time without supsend state + # relative - only suspend time - def escalation_suspend (start_time, end_time, type, sla_selected, sla_time = 0) - if type == 'relative' - end_time += sla_time * 60 + def escalation_suspend (start_time, end_time, type, sla_selected, sla_time = 0) + if type == 'relative' + end_time += sla_time * 60 + end + total_time_without_pending = 0 + total_time = 0 + #get history for ticket + history_list = self.history_get + + #loop through hist. changes and get time + last_state = nil + last_state_change = nil + last_state_is_pending = false + history_list.each { |history_item| + + # ignore if it isn't a state change + next if !history_item['attribute'] + next if history_item['attribute'] != 'ticket_state' + + # ignore all newer state before start_time + next if history_item['created_at'] < start_time + + # ignore all older state changes after end_time + next if last_state_change && last_state_change > end_time + + # if created_at is later then end_time, use end_time as last time + if history_item['created_at'] > end_time + history_item['created_at'] = end_time end - total_time_without_pending = 0 - total_time = 0 - #get history for ticket - history_list = self.history_get - #loop through hist. changes and get time - last_state = nil - last_state_change = nil - last_state_is_pending = false - history_list.each { |history_item| + # get initial state and time + if !last_state + last_state = history_item['value_from'] + last_state_change = start_time + end - # ignore if it isn't a state change - next if !history_item['attribute'] - next if history_item['attribute'] != 'ticket_state' + # check if time need to be counted + counted = true + if history_item['value_from'] == 'pending' + counted = false + elsif history_item['value_from'] == 'close' + counted = false + end - # ignore all newer state before start_time - next if history_item['created_at'] < start_time - - # ignore all older state changes after end_time - next if last_state_change && last_state_change > end_time - - # if created_at is later then end_time, use end_time as last time - if history_item['created_at'] > end_time - history_item['created_at'] = end_time - end - - # get initial state and time - if !last_state - last_state = history_item['value_from'] - last_state_change = start_time - end - - # check if time need to be counted - counted = true - if history_item['value_from'] == 'pending' - counted = false - elsif history_item['value_from'] == 'close' - counted = false - end - - diff = escalation_time_diff( last_state_change, history_item['created_at'], sla_selected ) - if counted - puts "Diff count #{history_item['value_from']} -> #{history_item['value_to']} / #{last_state_change} -> #{history_item['created_at']}" - total_time_without_pending = total_time_without_pending + diff - else - puts "Diff not count #{history_item['value_from']} -> #{history_item['value_to']} / #{last_state_change} -> #{history_item['created_at']}" - end - total_time = total_time + diff - - if history_item['value_to'] == 'pending' - last_state_is_pending = true - else - last_state_is_pending = false - end - - # remember for next loop last state - last_state = history_item['value_to'] - last_state_change = history_item['created_at'] - } - - # if last state isnt pending, count rest - if !last_state_is_pending && last_state_change && last_state_change < end_time - diff = escalation_time_diff( last_state_change, end_time, sla_selected ) - puts "Diff count last state was not pending #{diff.to_s} - #{last_state_change} - #{end_time}" + diff = escalation_time_diff( last_state_change, history_item['created_at'], sla_selected ) + if counted + puts "Diff count #{history_item['value_from']} -> #{history_item['value_to']} / #{last_state_change} -> #{history_item['created_at']}" total_time_without_pending = total_time_without_pending + diff - total_time = total_time + diff - end - - # if we have not had any state change - if !last_state_change - diff = escalation_time_diff( start_time, end_time, sla_selected ) - puts 'Diff state has not changed ' + diff.to_s - total_time_without_pending = total_time_without_pending + diff - total_time = total_time + diff - end - - #return sum - if type == 'real' - return total_time_without_pending - elsif type == 'relative' - relative = total_time - total_time_without_pending - return relative else - raise "ERROR: Unknown type #{type}" + puts "Diff not count #{history_item['value_from']} -> #{history_item['value_to']} / #{last_state_change} -> #{history_item['created_at']}" end - end + total_time = total_time + diff - def escalation_time_diff( start_time, end_time, sla_selected ) - if sla_selected - diff = TimeCalculation.business_time_diff( start_time, end_time, sla_selected.data, sla_selected.timezone) + if history_item['value_to'] == 'pending' + last_state_is_pending = true else - diff = TimeCalculation.business_time_diff( start_time, end_time ) + last_state_is_pending = false end - diff + + # remember for next loop last state + last_state = history_item['value_to'] + last_state_change = history_item['created_at'] + } + + # if last state isnt pending, count rest + if !last_state_is_pending && last_state_change && last_state_change < end_time + diff = escalation_time_diff( last_state_change, end_time, sla_selected ) + puts "Diff count last state was not pending #{diff.to_s} - #{last_state_change} - #{end_time}" + total_time_without_pending = total_time_without_pending + diff + total_time = total_time + diff end - def calculation_higher_time(escalation_time, check_time, done_time) - return escalation_time if done_time - return check_time if !escalation_time - return escalation_time if !check_time - return check_time if escalation_time > check_time - return escalation_time + # if we have not had any state change + if !last_state_change + diff = escalation_time_diff( start_time, end_time, sla_selected ) + puts 'Diff state has not changed ' + diff.to_s + total_time_without_pending = total_time_without_pending + diff + total_time = total_time + diff end -end \ No newline at end of file + + #return sum + if type == 'real' + return total_time_without_pending + elsif type == 'relative' + relative = total_time - total_time_without_pending + return relative + else + raise "ERROR: Unknown type #{type}" + end + end + + def escalation_time_diff( start_time, end_time, sla_selected ) + if sla_selected + diff = TimeCalculation.business_time_diff( start_time, end_time, sla_selected.data, sla_selected.timezone) + else + diff = TimeCalculation.business_time_diff( start_time, end_time ) + end + diff + end + + def calculation_higher_time(escalation_time, check_time, done_time) + return escalation_time if done_time + return check_time if !escalation_time + return escalation_time if !check_time + return check_time if escalation_time > check_time + return escalation_time + end +end diff --git a/app/models/ticket/flag.rb b/app/models/ticket/flag.rb index a3e6df147..d50fe5814 100644 --- a/app/models/ticket/flag.rb +++ b/app/models/ticket/flag.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Ticket::Flag < ApplicationModel end diff --git a/app/models/ticket/history_log.rb b/app/models/ticket/history_log.rb index 5e65833dc..dc9e45b3a 100644 --- a/app/models/ticket/history_log.rb +++ b/app/models/ticket/history_log.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::HistoryLog @@ -79,4 +79,4 @@ returns } end -end \ No newline at end of file +end diff --git a/app/models/ticket/number.rb b/app/models/ticket/number.rb index 1bcfd6403..05c50c1f6 100644 --- a/app/models/ticket/number.rb +++ b/app/models/ticket/number.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Ticket::Number < ApplicationLib @@ -15,7 +15,7 @@ returns =end def self.generate - + # generate number (1..50_000).each { |i| number = adapter.generate diff --git a/app/models/ticket/number/date.rb b/app/models/ticket/number/date.rb index f0e2be455..1105d7c1f 100644 --- a/app/models/ticket/number/date.rb +++ b/app/models/ticket/number/date.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::Number::Date extend self diff --git a/app/models/ticket/number/increment.rb b/app/models/ticket/number/increment.rb index d530785b8..5defeef37 100644 --- a/app/models/ticket/number/increment.rb +++ b/app/models/ticket/number/increment.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::Number::Increment extend self diff --git a/app/models/ticket/overviews.rb b/app/models/ticket/overviews.rb index d08bee701..ebe538e1c 100644 --- a/app/models/ticket/overviews.rb +++ b/app/models/ticket/overviews.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::Overviews @@ -187,62 +187,62 @@ returns end private - def self._condition(condition) - sql = '' - bind = [nil] - condition.each {|key, value| - if sql != '' - sql += ' AND ' - end - if value.class == Array - sql += " #{key} IN (?)" - bind.push value - elsif value.class == Hash || value.class == ActiveSupport::HashWithIndifferentAccess - time = Time.now - if value['area'] == 'minute' - if value['direction'] == 'last' - time -= value['count'].to_i * 60 - else - time += value['count'].to_i * 60 - end - elsif value['area'] == 'hour' - if value['direction'] == 'last' - time -= value['count'].to_i * 60 * 60 - else - time += value['count'].to_i * 60 * 60 - end - elsif value['area'] == 'day' - if value['direction'] == 'last' - time -= value['count'].to_i * 60 * 60 * 24 - else - time += value['count'].to_i * 60 * 60 * 24 - end - elsif value['area'] == 'month' - if value['direction'] == 'last' - time -= value['count'].to_i * 60 * 60 * 24 * 31 - else - time += value['count'].to_i * 60 * 60 * 24 * 31 - end - elsif value['area'] == 'year' - if value['direction'] == 'last' - time -= value['count'].to_i * 60 * 60 * 24 * 365 - else - time += value['count'].to_i * 60 * 60 * 24 * 365 - end - end + def self._condition(condition) + sql = '' + bind = [nil] + condition.each {|key, value| + if sql != '' + sql += ' AND ' + end + if value.class == Array + sql += " #{key} IN (?)" + bind.push value + elsif value.class == Hash || value.class == ActiveSupport::HashWithIndifferentAccess + time = Time.now + if value['area'] == 'minute' if value['direction'] == 'last' - sql += " #{key} > ?" - bind.push time + time -= value['count'].to_i * 60 else - sql += " #{key} < ?" - bind.push time + time += value['count'].to_i * 60 + end + elsif value['area'] == 'hour' + if value['direction'] == 'last' + time -= value['count'].to_i * 60 * 60 + else + time += value['count'].to_i * 60 * 60 + end + elsif value['area'] == 'day' + if value['direction'] == 'last' + time -= value['count'].to_i * 60 * 60 * 24 + else + time += value['count'].to_i * 60 * 60 * 24 + end + elsif value['area'] == 'month' + if value['direction'] == 'last' + time -= value['count'].to_i * 60 * 60 * 24 * 31 + else + time += value['count'].to_i * 60 * 60 * 24 * 31 + end + elsif value['area'] == 'year' + if value['direction'] == 'last' + time -= value['count'].to_i * 60 * 60 * 24 * 365 + else + time += value['count'].to_i * 60 * 60 * 24 * 365 end - else - sql += " #{key} = ?" - bind.push value end - } - bind[0] = sql - return bind - end -end \ No newline at end of file + if value['direction'] == 'last' + sql += " #{key} > ?" + bind.push time + else + sql += " #{key} < ?" + bind.push time + end + else + sql += " #{key} = ?" + bind.push value + end + } + bind[0] = sql + return bind + end +end diff --git a/app/models/ticket/permission.rb b/app/models/ticket/permission.rb index 5f7b3caf6..6a81de573 100644 --- a/app/models/ticket/permission.rb +++ b/app/models/ticket/permission.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::Permission @@ -44,4 +44,4 @@ returns return false end -end \ No newline at end of file +end diff --git a/app/models/ticket/priority.rb b/app/models/ticket/priority.rb index ded6210dc..384e4a68e 100644 --- a/app/models/ticket/priority.rb +++ b/app/models/ticket/priority.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Ticket::Priority < ApplicationModel self.table_name = 'ticket_priorities' diff --git a/app/models/ticket/screen_options.rb b/app/models/ticket/screen_options.rb index d91bf2620..bfb7f3b43 100644 --- a/app/models/ticket/screen_options.rb +++ b/app/models/ticket/screen_options.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::ScreenOptions @@ -167,4 +167,4 @@ returns } end -end \ No newline at end of file +end diff --git a/app/models/ticket/search.rb b/app/models/ticket/search.rb index c5268cabd..c67f7f6d0 100644 --- a/app/models/ticket/search.rb +++ b/app/models/ticket/search.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::Search @@ -33,29 +33,29 @@ returns if current_user.is_role('Agent') groups = Group.joins(:users). - where( 'groups_users.user_id = ?', current_user.id ). - where( 'groups.active = ?', true ) - group_condition = [] - groups.each {|group| - group_condition.push group.name - } + where( 'groups_users.user_id = ?', current_user.id ). + where( 'groups.active = ?', true ) + group_condition = [] + groups.each {|group| + group_condition.push group.name + } condition = { - 'query_string' => { 'default_field' => 'Ticket.group.name', 'query' => "\"#{group_condition.join('" OR "')}\"" } + 'query_string' => { 'default_field' => 'Ticket.group.name', 'query' => "\"#{group_condition.join('" OR "')}\"" } } query_extention['bool']['must'].push condition else if !current_user.organization || ( !current_user.organization.shared || current_user.organization.shared == false ) condition = { - 'query_string' => { 'default_field' => 'Ticket.customer_id', 'query' => current_user.id } + 'query_string' => { 'default_field' => 'Ticket.customer_id', 'query' => current_user.id } } - # customer_id: XXX -# conditions = [ 'customer_id = ?', current_user.id ] + # customer_id: XXX + # conditions = [ 'customer_id = ?', current_user.id ] else condition = { - 'query_string' => { 'query' => "Ticket.customer_id:#{current_user.id} OR Ticket.organization_id:#{current_user.organization.id}" } + 'query_string' => { 'query' => "Ticket.customer_id:#{current_user.id} OR Ticket.organization_id:#{current_user.organization.id}" } } - # customer_id: XXX OR organization_id: XXX -# conditions = [ '( customer_id = ? OR organization_id = ? )', current_user.id, current_user.organization.id ] + # customer_id: XXX OR organization_id: XXX + # conditions = [ '( customer_id = ? OR organization_id = ? )', current_user.id, current_user.organization.id ] end query_extention['bool']['must'].push condition end @@ -101,4 +101,4 @@ returns tickets end -end \ No newline at end of file +end diff --git a/app/models/ticket/search_index.rb b/app/models/ticket/search_index.rb index 6e7267651..27b22a7a3 100644 --- a/app/models/ticket/search_index.rb +++ b/app/models/ticket/search_index.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::SearchIndex @@ -61,8 +61,8 @@ returns end file = Store.find( attachment.id ) data = { - "_name" => file.filename, - "content" => Base64.encode64( file.store_file.data ) + "_name" => file.filename, + "content" => Base64.encode64( file.store_file.data ) } article_attributes['attachments'].push data } @@ -76,4 +76,4 @@ returns SearchIndexBackend.add(self.class.to_s, attributes) end -end \ No newline at end of file +end diff --git a/app/models/ticket/state.rb b/app/models/ticket/state.rb index 258ef5150..ecf12e39b 100644 --- a/app/models/ticket/state.rb +++ b/app/models/ticket/state.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Ticket::State < ApplicationModel belongs_to :state_type, :class_name => 'Ticket::StateType' @@ -22,10 +22,10 @@ returns: :state_type_id => Ticket::StateType.where( :name => ['new', 'open', 'pending reminder', 'pending action'] ) ) elsif category == 'closed' - return Ticket::State.where( + return Ticket::State.where( :state_type_id => Ticket::StateType.where( :name => ['closed'] ) ) - end + end raise "Unknown category '#{category}'" end @@ -44,7 +44,7 @@ returns: =end def ignore_escalation? - ignore_escalation = ['removed', 'closed', 'merged'] + ignore_escalation = ['removed', 'closed', 'merged'] return true if ignore_escalation.include?( self.name ) return false end diff --git a/app/models/ticket/state_type.rb b/app/models/ticket/state_type.rb index 5b3a2830b..178046c95 100644 --- a/app/models/ticket/state_type.rb +++ b/app/models/ticket/state_type.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Ticket::StateType < ApplicationModel has_many :states, :class_name => 'Ticket::State' diff --git a/app/models/ticket/subject.rb b/app/models/ticket/subject.rb index ff3c491b1..2343efabb 100644 --- a/app/models/ticket/subject.rb +++ b/app/models/ticket/subject.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module Ticket::Subject @@ -75,4 +75,4 @@ returns return subject end -end \ No newline at end of file +end diff --git a/app/models/time_accounting.rb b/app/models/time_accounting.rb index a78c3090f..e40d4fa57 100644 --- a/app/models/time_accounting.rb +++ b/app/models/time_accounting.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class TimeAccounting < ActiveRecord::Base end diff --git a/app/models/token.rb b/app/models/token.rb index fd2e39189..698b96a4a 100644 --- a/app/models/token.rb +++ b/app/models/token.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Token < ActiveRecord::Base before_create :generate_token diff --git a/app/models/translation.rb b/app/models/translation.rb index baa553e5a..08901ed5e 100644 --- a/app/models/translation.rb +++ b/app/models/translation.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Translation < ApplicationModel before_create :set_initial diff --git a/app/models/trigger.rb b/app/models/trigger.rb index 2871065fd..4d5c948a3 100644 --- a/app/models/trigger.rb +++ b/app/models/trigger.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Trigger < ActiveRecord::Base end diff --git a/app/models/user.rb b/app/models/user.rb index b7c8e5ce9..d3a955612 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ require 'digest/md5' diff --git a/app/models/user/assets.rb b/app/models/user/assets.rb index b66069003..49d0e2779 100644 --- a/app/models/user/assets.rb +++ b/app/models/user/assets.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module User::Assets @@ -37,4 +37,4 @@ returns data end -end \ No newline at end of file +end diff --git a/app/models/user/search.rb b/app/models/user/search.rb index a706d4c1e..b2d63a127 100644 --- a/app/models/user/search.rb +++ b/app/models/user/search.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module User::Search @@ -65,4 +65,4 @@ returns return users end -end \ No newline at end of file +end diff --git a/app/models/user/search_index.rb b/app/models/user/search_index.rb index b37356836..0d6b4df04 100644 --- a/app/models/user/search_index.rb +++ b/app/models/user/search_index.rb @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ +# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ module User::SearchIndex @@ -25,4 +25,4 @@ returns return if attributes.empty? attributes end -end \ No newline at end of file +end