Code reformattingand code layout beautying.

This commit is contained in:
Martin Edenhofer 2013-06-12 17:59:58 +02:00
parent b0ffaf1e5a
commit c2010124f5
102 changed files with 1014 additions and 811 deletions

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class ActivityController < ApplicationController
before_filter :authentication_check

View file

@ -1,5 +1,7 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class ApplicationController < ActionController::Base
# http_basic_authenticate_with :name => "test", :password => "ttt"
# http_basic_authenticate_with :name => "test", :password => "ttt"
helper_method :current_user,
:authentication_check,
@ -73,7 +75,7 @@ class ApplicationController < ActionController::Base
def authentication_check_only
puts 'authentication_check'
# puts params.inspect
# puts params.inspect
# check http basic auth
authenticate_with_http_basic do |username, password|

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class ChannelsController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class EmailAddressesController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class GettingStartedController < ApplicationController
=begin

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class GroupsController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class InitController < ApplicationController
# GET /init

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class LinksController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class LongPollingController < ApplicationController
# GET /api/message_send
@ -115,7 +117,7 @@ class LongPollingController < ApplicationController
count = count - 1
queue = Session.queue( client_id )
if queue && queue[0]
# puts "send " + queue.inspect + client_id.to_s
# puts "send " + queue.inspect + client_id.to_s
render :json => queue
return
end
@ -153,6 +155,6 @@ class LongPollingController < ApplicationController
return if level == 'debug'
end
puts "#{Time.now}:client(#{ client_id }) #{ data }"
# puts "#{Time.now}:#{ level }:client(#{ client_id }) #{ data }"
# puts "#{Time.now}:#{ level }:client(#{ client_id }) #{ data }"
end
end

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class NetworksController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class OrganizationsController < ApplicationController
before_filter :authentication_check
@ -140,7 +142,7 @@ Test:
=end
def destroy
def destroy
return if is_not_role('Agent')
model_destory_render(Organization, params)
end

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class OverviewsController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class PackagesController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class PostmasterFiltersController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class RecentViewedController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class RolesController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class RssController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class SearchController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
module ExtraCollection
def session( collections, user )

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
module ExtraCollection
def session( collections, user )

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
module ExtraCollection
def session( collections, user )

View file

@ -1,7 +1,9 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class SessionsController < ApplicationController
# def create
# render :text => request.env['rack.auth'].inspect
# end
# def create
# render :text => request.env['rack.auth'].inspect
# end
# "Create" a login, aka "log the user in"
def create

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class SettingsController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class SignaturesController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class SlasController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class TagsController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class TaskbarController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class TemplatesController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class TestsController < ApplicationController
# GET /test

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class TextModulesController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class TicketArticlesController < ApplicationController
before_filter :authentication_check
@ -66,7 +68,7 @@ class TicketArticlesController < ApplicationController
def attachment_new
# store file
# content_type = request.content_type
# content_type = request.content_type
content_type = request[:content_type]
puts 'content_type: ' + content_type.inspect
if !content_type || content_type == 'application/octet-stream'

View file

@ -1,9 +1,10 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class TicketOverviewsController < ApplicationController
before_filter :authentication_check
# GET /api/tickets
def show
#sleep 2
# get navbar overview data
if !params[:view]
@ -37,7 +38,7 @@ class TicketOverviewsController < ApplicationController
end
overview = Ticket.overview(
:view => params[:view],
# :view_mode => params[:view_mode],
# :view_mode => params[:view_mode],
:current_user => User.find( current_user.id ),
:array => true,
)

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class TicketPrioritiesController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class TicketStatesController < ApplicationController
before_filter :authentication_check

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class TicketsController < ApplicationController
before_filter :authentication_check
@ -133,7 +135,7 @@ class TicketsController < ApplicationController
:open => tickets_open,
:closed => tickets_closed
}
# :users => users,
# :users => users,
}
end
@ -375,8 +377,8 @@ class TicketsController < ApplicationController
# get attributes to update
attributes_to_change = Ticket.attributes_to_change(
:user => current_user,
# :ticket_id => params[:ticket_id],
# :article_id => params[:article_id]
# :ticket_id => params[:ticket_id],
# :article_id => params[:article_id]
)
users = {}

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class TranslationsController < ApplicationController
before_filter :authentication_check, :except => [:load]

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class UsersController < ApplicationController
before_filter :authentication_check, :except => [:create, :password_reset_send, :password_reset_verify]
@ -195,18 +197,18 @@ curl http://localhost/api/users.json -v -u #{login}:#{password} -H "Content-Type
data[:subject] = 'Invitation to #{config.product_name} at #{config.fqdn}'
data[:body] = 'Hi #{user.firstname},
I (#{current_user.firstname} #{current_user.lastname}) invite you to #{config.product_name} - a customer support / ticket system platform.
I (#{current_user.firstname} #{current_user.lastname}) invite you to #{config.product_name} - a customer support / ticket system platform.
Click on the following link and set your password:
Click on the following link and set your password:
#{config.http_type}://#{config.fqdn}/#password_reset_verify/#{token.name}
#{config.http_type}://#{config.fqdn}/#password_reset_verify/#{token.name}
Enjoy,
Enjoy,
#{current_user.firstname} #{current_user.lastname}
Your #{config.product_name} Team
'
'
# prepare subject & body
[:subject, :body].each { |key|

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'cache'
require 'user_info'
@ -26,7 +28,7 @@ class ApplicationModel < ActiveRecord::Base
data = {}
self.new.attributes.each {|item|
if params.has_key?(item[0])
# puts 'use ' + item[0].to_s + '-' + params[item[0]].to_s
# puts 'use ' + item[0].to_s + '-' + params[item[0]].to_s
data[item[0].to_sym] = params[item[0]]
end
}
@ -69,9 +71,9 @@ class ApplicationModel < ActiveRecord::Base
end
def cache_update(o)
# puts 'u ' + self.class.to_s
# puts 'u ' + self.class.to_s
if self.respond_to?('cache_delete') then self.cache_delete end
# puts 'g ' + group.class.to_s
# puts 'g ' + group.class.to_s
if o.respond_to?('cache_delete') then o.cache_delete end
end
def cache_delete_before
@ -120,11 +122,11 @@ class ApplicationModel < ActiveRecord::Base
def self.lookup(data)
if data[:id]
# puts "GET- + #{self.to_s}.#{data[:id].to_s}"
# puts "GET- + #{self.to_s}.#{data[:id].to_s}"
cache = self.cache_get( data[:id] )
return cache if cache
# puts "Fillup- + #{self.to_s}.#{data[:id].to_s}"
# puts "Fillup- + #{self.to_s}.#{data[:id].to_s}"
record = self.where( :id => data[:id] ).first
self.cache_set( data[:id], record )
return record

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Authorization < ApplicationModel
belongs_to :user
after_create :delete_user_cache
@ -37,7 +39,7 @@ class Authorization < ApplicationModel
def self.create_from_hash(hash, user = nil)
if user then
user.update_attributes(
# :username => hash['username'],
# :username => hash['username'],
:image => hash['info']['image']
)

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Channel < ApplicationModel
store :options

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'mail'
class Channel::EmailBuild

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
# encoding: utf-8
require 'mail'
@ -81,8 +83,8 @@ class Channel::EmailParser
data[:message_id] = data['message-id'.to_sym]
# body
# plain_part = mail.multipart? ? (mail.text_part ? mail.text_part.body.decoded : nil) : mail.body.decoded
# html_part = message.html_part ? message.html_part.body.decoded : nil
# plain_part = mail.multipart? ? (mail.text_part ? mail.text_part.body.decoded : nil) : mail.body.decoded
# html_part = message.html_part ? message.html_part.body.decoded : nil
data[:attachments] = []
# multi part email
@ -425,7 +427,7 @@ class Channel::EmailParser
# run postmaster post filter
filters = {
# '0010' => Channel::Filter::Trusted,
# '0010' => Channel::Filter::Trusted,
}
# filter( channel, mail )
@ -525,7 +527,7 @@ module Mail
text
else
# Join QP encoded-words that are adjacent to avoid decoding partial chars
# text.gsub!(/\?\=\=\?.+?\?[Qq]\?/m, '') if text =~ /\?==\?/
# text.gsub!(/\?\=\=\?.+?\?[Qq]\?/m, '') if text =~ /\?==\?/
# Search for occurences of quoted strings or plain strings
text.scan(/( # Group around entire regex to include it in matches

View file

@ -1,8 +1,10 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
#require 'rubygems'
#require 'twitter'
class Channel::Facebook
# def fetch(:oauth_token, :oauth_token_secret)
# def fetch(:oauth_token, :oauth_token_secret)
def fetch
@ -20,10 +22,10 @@ class Channel::Facebook
:message => self.body
}
)
# client.direct_message_create(
# 'medenhofer',
# self.body,
# options = {}
# )
# client.direct_message_create(
# 'medenhofer',
# self.body,
# options = {}
# )
end
end

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
# process all database filter
module Channel::Filter::Database

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
# delete all X-Zammad header if channel is not trusted
module Channel::Filter::Trusted

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'net/imap'
class Channel::IMAP < Channel::EmailParser
@ -34,7 +36,7 @@ class Channel::IMAP < Channel::EmailParser
count += 1
puts " - message #{count.to_s}/#{count_all.to_s}"
msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
# puts msg.to_s
# puts msg.to_s
# delete email from server after article was created
if process(channel, msg)

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Channel::MailStdin < Channel::EmailParser
def initialize
puts "read main from STDIN"

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'net/pop'
class Channel::POP3 < Channel::EmailParser

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Channel::Sendmail < Channel::EmailBuild
def send(attr, channel, notification = false)

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Channel::SMTP < Channel::EmailBuild
def send(attr, channel, notification = false)

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'twitter'
class Channel::Twitter2
@ -100,7 +102,7 @@ class Channel::Twitter2
begin
# reconnect for #<Twitter::Error::NotFound: Sorry, that page does not exist> workaround
# @client = connect(channel)
# @client = connect(channel)
sender = @client.user(tweet.from_user_id)
rescue Exception => e
puts "Exception: twitter: " + e.inspect
@ -113,7 +115,7 @@ class Channel::Twitter2
if tweet['in_reply_to_status_id']
puts 'import in_reply_tweet ' + tweet.in_reply_to_status_id.to_s
tweet_sub = @client.status(tweet.in_reply_to_status_id)
# puts tweet_sub.inspect
# puts tweet_sub.inspect
(user, ticket, article) = fetch_import(tweet_sub, channel, group)
end
@ -129,8 +131,8 @@ class Channel::Twitter2
def fetch_user_create(tweet, sender)
# create sender in db
# puts tweet.inspect
# user = User.where( :login => tweet.sender.screen_name ).first
# puts tweet.inspect
# user = User.where( :login => tweet.sender.screen_name ).first
auth = Authorization.where( :uid => sender.id, :provider => 'twitter' ).first
user = nil
if auth
@ -172,7 +174,7 @@ class Channel::Twitter2
def fetch_ticket_create(user, tweet, sender, channel, group)
# puts '+++++++++++++++++++++++++++' + tweet.inspect
# puts '+++++++++++++++++++++++++++' + tweet.inspect
# check if ticket exists
if tweet['in_reply_to_status_id']
puts 'tweet.in_reply_to_status_id found: ' + tweet.in_reply_to_status_id
@ -260,7 +262,7 @@ class Channel::Twitter2
end
def send(attr, notification = false)
# logger.debug('tweeeeettttt!!!!!!')
# logger.debug('tweeeeettttt!!!!!!')
channel = Channel.where( :area => 'Twitter::Inbound', :active => true ).first
client = Twitter::Client.new(
@ -276,7 +278,7 @@ class Channel::Twitter2
attr[:body].to_s,
{}
)
# puts dm.inspect
# puts dm.inspect
return dm
end
@ -287,7 +289,7 @@ class Channel::Twitter2
:in_reply_to_status_id => attr[:in_reply_to]
}
)
# puts message.inspect
# puts message.inspect
return message
end

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class EmailAddress < ApplicationModel
has_many :groups, :after_add => :cache_update, :after_remove => :cache_update
validates :realname, :presence => true

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Group < ApplicationModel
has_and_belongs_to_many :users, :after_add => :cache_update, :after_remove => :cache_update
belongs_to :email_address

View file

@ -1,10 +1,12 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class History < ApplicationModel
self.table_name = 'histories'
belongs_to :history_type, :class_name => 'History::Type'
belongs_to :history_object, :class_name => 'History::Object'
belongs_to :history_attribute, :class_name => 'History::Attribute'
# before_validation :check_type, :check_object
# attr_writer :history_type, :history_object
# before_validation :check_type, :check_object
# attr_writer :history_type, :history_object
@@cache_type = {}
@@cache_object = {}
@ -121,9 +123,9 @@ class History < ApplicationModel
end
def self.activity_stream( user, limit = 10 )
# g = Group.where( :active => true ).joins(:users).where( 'users.id' => user.id )
# stream = History.select("distinct(histories.o_id), created_by_id, history_attribute_id, history_type_id, history_object_id, value_from, value_to").
# where( :history_type_id => History::Type.where( :name => ['created', 'updated']) ).
# g = Group.where( :active => true ).joins(:users).where( 'users.id' => user.id )
# stream = History.select("distinct(histories.o_id), created_by_id, history_attribute_id, history_type_id, history_object_id, value_from, value_to").
# where( :history_type_id => History::Type.where( :name => ['created', 'updated']) ).
stream = History.select("distinct(histories.o_id), created_by_id, history_type_id, history_object_id").
where( :history_object_id => History::Object.where( :name => [ 'Ticket', 'Ticket::Article' ] ) ).
where( :history_type_id => History::Type.where( :name => [ 'created', 'updated' ]) ).
@ -137,7 +139,7 @@ class History < ApplicationModel
data.delete('history_object_id')
data.delete('history_type_id')
datas.push data
# item['history_attribute'] = item.history_attribute
# item['history_attribute'] = item.history_attribute
end
return datas
end

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Link < ApplicationModel
belongs_to :link_type, :class_name => 'Link::Type'
belongs_to :link_object, :class_name => 'Link::Object'

View file

@ -1,7 +1,9 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Network < ApplicationModel
# belongs_to :group
# belongs_to :ticket_state, :class_name => 'Ticket::State'
# belongs_to :ticket_priority, :class_name => 'Ticket::Priority'
# belongs_to :group
# belongs_to :ticket_state, :class_name => 'Ticket::State'
# belongs_to :ticket_priority, :class_name => 'Ticket::Priority'
class Category < ApplicationModel
self.table_name = 'network_categories'

View file

@ -1,2 +1,4 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Notifications < ActiveRecord::Base
end

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'history'
class Observer::History < ActiveRecord::Observer
@ -9,7 +11,7 @@ class Observer::History < ActiveRecord::Observer
return if Setting.get('import_mode')
puts "HISTORY OBSERVER, object created #{ record.class.name }.find(#{ record.id })"
# puts record.inspect
# puts record.inspect
# if Ticket::Article has changed, remember ticket to be able
# to show article changes in ticket history
@ -34,17 +36,17 @@ class Observer::History < ActiveRecord::Observer
# return if we run import mode
return if Setting.get('import_mode')
# puts 'before_update'
# puts 'before_update'
current = record.class.find(record.id)
# do not send anything if nothing has changed
return if current.attributes == record.attributes
puts "HISTORY OBSERVER, object will be updated #{ record.class.name.to_s}.find(#{ current.id.to_s })"
# puts 'current'
# puts current.inspect
# puts 'record'
# puts record.inspect
# puts 'current'
# puts current.inspect
# puts 'record'
# puts record.inspect
diff = differences_from?(current, record)
puts ' DIFF'

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'history'
class Observer::Tag::TicketHistory < ActiveRecord::Observer

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer
observe 'ticket::_article'

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::Article::CommunicateFacebook < ActiveRecord::Observer
observe 'ticket::_article'

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
observe 'ticket::_article'
@ -23,7 +25,7 @@ class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
:body => record.body,
:in_reply_to => record.in_reply_to
},
# Rails.application.config.channel_twitter
# Rails.application.config.channel_twitter
)
record.message_id = message.id
record.save

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer
observe 'ticket::_article'

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::Article::FillupFromGeneral < ActiveRecord::Observer
observe 'ticket::_article'

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::ArticleCounter < ActiveRecord::Observer
observe 'ticket::_article'

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::ArticleSenderType < ActiveRecord::Observer
observe 'ticket::_article'

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::CloseTime < ActiveRecord::Observer
observe 'ticket'
@ -11,7 +13,7 @@ class Observer::Ticket::CloseTime < ActiveRecord::Observer
private
def _check(record)
# puts 'check close time'
# puts 'check close time'
# return if we run import mode
return if Setting.get('import_mode')

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::EscalationCalculation < ActiveRecord::Observer
observe 'ticket', 'ticket::_article'

View file

@ -1,8 +1,10 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::FirstResponse < ActiveRecord::Observer
observe 'ticket::_article'
def after_create(record)
# puts 'check first response'
# puts 'check first response'
# return if we run import mode
return if Setting.get('import_mode')

View file

@ -1,8 +1,10 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::LastContact < ActiveRecord::Observer
observe 'ticket::_article'
def after_create(record)
# puts 'check last contact'
# puts 'check last contact'
# if article in internal
return true if record.internal

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'notification_factory'
class Observer::Ticket::Notification < ActiveRecord::Observer
@ -10,8 +12,8 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
# return if we run import mode
return if Setting.get('import_mode')
# puts '@@event_buffer'
# puts @@event_buffer.inspect
# puts '@@event_buffer'
# puts @@event_buffer.inspect
@@event_buffer.each { |event|
# get current state of objects
@ -44,19 +46,19 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
:subject => 'New Ticket (#{ticket.title})',
:body => 'Hi #{recipient.firstname},
a new Ticket (#{ticket.title}) via i18n(#{article.ticket_article_type.name}).
a new Ticket (#{ticket.title}) via i18n(#{article.ticket_article_type.name}).
Group: #{ticket.group.name}
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
State: i18n(#{ticket.ticket_state.name})
Group: #{ticket.group.name}
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
State: i18n(#{ticket.ticket_state.name})
From: #{article.from}
<snip>
#{article.body}
</snip>
From: #{article.from}
<snip>
#{article.body}
</snip>
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
'
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
'
},
ticket,
article
@ -77,17 +79,17 @@ From: #{article.from}
:subject => 'New Ticket has been created! (#{ticket.title})',
:body => 'Thanks for your email. A new ticket has been created.
You wrote:
<snip>
#{article.body}
</snip>
You wrote:
<snip>
#{article.body}
</snip>
Your email will be answered by a human ASAP
Your email will be answered by a human ASAP
Have fun with Zammad! :-)
Have fun with Zammad! :-)
Your Zammad Team
'
Your Zammad Team
'
},
ticket,
article
@ -110,19 +112,19 @@ Your Zammad Team
:subject => 'Follow Up (#{ticket.title})',
:body => 'Hi #{recipient.firstname},
a follow Up (#{ticket.title}) via i18n(#{article.ticket_article_type.name}).
a follow Up (#{ticket.title}) via i18n(#{article.ticket_article_type.name}).
Group: #{ticket.group.name}
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
State: i18n(#{ticket.ticket_state.name})
Group: #{ticket.group.name}
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
State: i18n(#{ticket.ticket_state.name})
From: #{article.from}
<snip>
#{article.body}
</snip>
From: #{article.from}
<snip>
#{article.body}
</snip>
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
'
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
'
},
ticket,
article
@ -139,19 +141,19 @@ From: #{article.from}
:subject => 'Updated (#{ticket.title})',
:body => 'Hi #{recipient.firstname},
updated (#{ticket.title}) via i18n(#{article.ticket_article_type.name}).
updated (#{ticket.title}) via i18n(#{article.ticket_article_type.name}).
Group: #{ticket.group.name}
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
State: i18n(#{ticket.ticket_state.name})
Group: #{ticket.group.name}
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
State: i18n(#{ticket.ticket_state.name})
From: #{article.from}
<snip>
#{article.body}
</snip>
From: #{article.from}
<snip>
#{article.body}
</snip>
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
'
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
'
},
ticket,
article
@ -182,8 +184,8 @@ From: #{article.from}
# customer
elsif data[:recipient] == 'customer'
if ticket.customer_id != 1
# temporarily disabled
# recipients.push ticket.customer
# temporarily disabled
# recipients.push ticket.customer
end
# owner or group of agents to work on
@ -251,8 +253,8 @@ From: #{article.from}
# return if we run import mode
return if Setting.get('import_mode')
# puts 'CREATED!!!!'
# puts record.inspect
# puts 'CREATED!!!!'
# puts record.inspect
e = {
:name => record.class.name,
:type => 'create',
@ -273,11 +275,11 @@ From: #{article.from}
# do not send anything if nothing has changed
return if current.attributes == record.attributes
# puts 'UPDATE!!!!!!!!'
# puts 'current'
# puts current.inspect
# puts 'record'
# puts record.inspect
# puts 'UPDATE!!!!!!!!'
# puts 'current'
# puts current.inspect
# puts 'record'
# puts record.inspect
e = {
:name => record.class.name,
@ -293,10 +295,10 @@ From: #{article.from}
# return if we run import mode
return if Setting.get('import_mode')
# puts 'after_update'
# puts record.inspect
# puts '-----'
# puts @a.inspect
# AuditTrail.new(record, "UPDATED")
# puts 'after_update'
# puts record.inspect
# puts '-----'
# puts @a.inspect
# AuditTrail.new(record, "UPDATED")
end
end

View file

@ -1,8 +1,10 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::ResetNewState < ActiveRecord::Observer
observe 'ticket::_article'
def after_create(record)
# puts 'check reset new state'
# puts 'check reset new state'
# return if we run import mode
return if Setting.get('import_mode')

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Observer::Ticket::UserTicketCounter < ActiveRecord::Observer
observe 'ticket'

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Organization < ApplicationModel
has_and_belongs_to_many :users
validates :name, :presence => true

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Overview < ApplicationModel
store :condition
store :order

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'rexml/document'
class Package < ApplicationModel
@@root = Rails.root.to_s
@ -322,14 +324,14 @@ class Package < ApplicationModel
end
def self._parse(xml)
# puts xml.inspect
# puts xml.inspect
begin
package = REXML::Document.new( xml )
rescue => e
puts 'ERROR: ' + e.inspect
return
end
# puts package.inspect
# puts package.inspect
return package
end

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class PostmasterFilter < ApplicationModel
store :perform
store :match

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class RecentView < ApplicationModel
belongs_to :recent_view_object, :class_name => 'RecentView::Object'
@ -47,16 +49,16 @@ class RecentView < ApplicationModel
recent_viewed.each {|item|
# load article ids
# if item.recent_view_object == 'Ticket'
# if item.recent_view_object == 'Ticket'
ticket = Ticket.find( item['o_id'] ).attributes
tickets.push ticket
# end
# if item.recent_view_object 'Ticket::Article'
# tickets.push Ticket::Article.find(item.o_id)
# end
# if item.recent_view_object 'User'
# tickets.push User.find(item.o_id)
# end
# end
# if item.recent_view_object 'Ticket::Article'
# tickets.push Ticket::Article.find(item.o_id)
# end
# if item.recent_view_object 'User'
# tickets.push User.find(item.o_id)
# end
# load users
if !users[ ticket['owner_id'] ]

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Role < ApplicationModel
has_and_belongs_to_many :users, :after_add => :cache_update, :after_remove => :cache_update
validates :name, :presence => true

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Scheduler < ApplicationModel
def self.run( worker, worker_count )
@ -44,7 +46,7 @@ class Scheduler < ApplicationModel
else
self._start_job( job, worker, worker_count )
end
# raise "Exception from thread"
# raise "Exception from thread"
job.pid = ''
job.save
puts " ...stopped thread for '#{job.method}'"

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Setting < ApplicationModel
store :options
store :state

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Signature < ApplicationModel
has_many :groups, :after_add => :cache_update, :after_remove => :cache_update
validates :name, :presence => true

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'cache'
class Sla < ApplicationModel

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'digest/md5'
class Store < ApplicationModel
@ -14,10 +16,10 @@ class Store < ApplicationModel
data['store_object_id'] = store_object.id
# check if record already exists
# store = Store.where( :store_object_id => store_object.id, :o_id => data['o_id'], ).first
# if store != nil
# return store
# end
# store = Store.where( :store_object_id => store_object.id, :o_id => data['o_id'], ).first
# if store != nil
# return store
# end
# check real store
md5 = Digest::MD5.hexdigest( data['data'] )

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Tag < ApplicationModel
belongs_to :tag_object, :class_name => 'Tag::Object'
belongs_to :tag_item, :class_name => 'Tag::Item'

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Taskbar < ApplicationModel
store :state
store :params

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Template < ApplicationModel
store :options
validates :name, :presence => true

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class TextModule < ApplicationModel
validates :name, :presence => true
validates :content, :presence => true

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'time_calculation'
require 'sla'
@ -152,9 +154,9 @@ class Ticket < ApplicationModel
self.save
end
# def self.agent
# Role.where( :name => ['Agent'], :active => true ).first.users.where( :active => true ).uniq()
# end
# def self.agent
# Role.where( :name => ['Agent'], :active => true ).first.users.where( :active => true ).uniq()
# end
def subject_build (subject)
@ -204,9 +206,9 @@ class Ticket < ApplicationModel
return subject
end
# ticket.permission(
# :current_user => 123
# )
# ticket.permission(
# :current_user => 123
# )
def permission (data)
# check customer
@ -236,11 +238,11 @@ class Ticket < ApplicationModel
return false
end
# Ticket.search(
# :current_user => 123,
# :query => 'search something',
# :limit => 15,
# )
# Ticket.search(
# :current_user => 123,
# :query => 'search something',
# :limit => 15,
# )
def self.search (params)
# get params
@ -281,9 +283,9 @@ class Ticket < ApplicationModel
return tickets
end
# Ticket.overview_list(
# :current_user => 123,
# )
# Ticket.overview_list(
# :current_user => 123,
# )
def self.overview_list (data)
# get customer overviews
@ -303,10 +305,10 @@ class Ticket < ApplicationModel
return overviews
end
# Ticket.overview(
# :view => 'some_view_url',
# :current_user => OBJECT,
# )
# Ticket.overview(
# :view => 'some_view_url',
# :current_user => OBJECT,
# )
def self.overview (data)
overviews = self.overview_list(data)
@ -354,10 +356,10 @@ class Ticket < ApplicationModel
# group
# customer
# all = attributes[:myopenassigned]
# all.merge( { :group_id => groups } )
# all = attributes[:myopenassigned]
# all.merge( { :group_id => groups } )
# @tickets = Ticket.where(:group_id => groups, attributes[:myopenassigned] ).limit(params[:limit])
# @tickets = Ticket.where(:group_id => groups, attributes[:myopenassigned] ).limit(params[:limit])
# get only tickets with permissions
if data[:current_user].is_role('Customer')
group_ids = Group.select( 'groups.id' ).
@ -426,8 +428,8 @@ class Ticket < ApplicationModel
tickets = Ticket.where( :group_id => group_ids ).
where( self._condition( overview_selected.condition ) ).
order( overview_selected[:order][:by].to_s + ' ' + overview_selected[:order][:direction].to_s )#.
# limit( overview_selected.view[ data[:view_mode].to_sym ][:per_page] ).
# offset( overview_selected.view[ data[:view_mode].to_sym ][:per_page].to_i * ( data[:start_page].to_i - 1 ) )
# limit( overview_selected.view[ data[:view_mode].to_sym ][:per_page] ).
# offset( overview_selected.view[ data[:view_mode].to_sym ][:per_page].to_i * ( data[:start_page].to_i - 1 ) )
tickets_count = Ticket.where( :group_id => group_ids ).
where( self._condition( overview_selected.condition ) ).
@ -580,8 +582,8 @@ class Ticket < ApplicationModel
ignore_escalation = ['removed', 'closed', 'merged', 'pending action']
if ignore_escalation.include?( ticket_state_type.name )
self.escalation_time = nil
# self.first_response_escal_date = nil
# self.close_time_escal_date = nil
# self.first_response_escal_date = nil
# self.close_time_escal_date = nil
self.callback_loop = true
self.save
return true
@ -593,15 +595,15 @@ class Ticket < ApplicationModel
# reset escalation if no sla is set
if !sla_selected
self.escalation_time = nil
# self.first_response_escal_date = nil
# self.close_time_escal_date = nil
# self.first_response_escal_date = nil
# self.close_time_escal_date = nil
self.callback_loop = true
self.save
return true
end
# puts sla_selected.inspect
# puts days.inspect
# puts sla_selected.inspect
# puts days.inspect
self.escalation_time = nil
self.first_response_escal_date = nil
self.update_time_escal_date = nil
@ -683,7 +685,7 @@ class Ticket < ApplicationModel
if !self.owner_id
self.owner_id = 1
end
# if self.customer_id && ( !self.organization_id || self.organization_id.empty? )
# if self.customer_id && ( !self.organization_id || self.organization_id.empty? )
if self.customer_id
customer = User.find( self.customer_id )
if self.organization_id != customer.organization_id

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Ticket::Article < ApplicationModel
after_create :attachment_check
belongs_to :ticket

View file

@ -1,2 +1,4 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Ticket::Counter < ApplicationModel
end

View file

@ -1,2 +1,4 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Ticket::Flag < ApplicationModel
end

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
module Ticket::Number::Date
extend self

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
module Ticket::Number::Increment
extend self

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Ticket::Priority < ApplicationModel
self.table_name = 'ticket_priorities'
validates :name, :presence => true

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Ticket::State < ApplicationModel
belongs_to :state_type, :class_name => 'Ticket::StateType'
validates :name, :presence => true

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Ticket::StateType < ApplicationModel
has_many :states, :class_name => 'Ticket::State'
validates :name, :presence => true

View file

@ -1,2 +1,4 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class TimeAccounting < ActiveRecord::Base
end

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Token < ActiveRecord::Base
before_create :generate_token

View file

@ -1,3 +1,5 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
class Translation < ApplicationModel
before_create :set_initial

Some files were not shown because too many files have changed in this diff Show more