Code reformattingand code layout beautying.
This commit is contained in:
parent
b0ffaf1e5a
commit
c2010124f5
102 changed files with 1014 additions and 811 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class ActivityController < ApplicationController
|
class ActivityController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
# http_basic_authenticate_with :name => "test", :password => "ttt"
|
# http_basic_authenticate_with :name => "test", :password => "ttt"
|
||||||
|
|
||||||
helper_method :current_user,
|
helper_method :current_user,
|
||||||
:authentication_check,
|
:authentication_check,
|
||||||
:config_frontend,
|
:config_frontend,
|
||||||
:user_data_full,
|
:user_data_full,
|
||||||
:is_role,
|
:is_role,
|
||||||
:model_create_render,
|
:model_create_render,
|
||||||
:model_update_render,
|
:model_update_render,
|
||||||
:model_restory_render,
|
:model_restory_render,
|
||||||
:mode_show_rendeder,
|
:mode_show_rendeder,
|
||||||
:model_index_render
|
:model_index_render
|
||||||
|
|
||||||
before_filter :set_user
|
before_filter :set_user
|
||||||
before_filter :cors_preflight_check
|
before_filter :cors_preflight_check
|
||||||
|
@ -73,7 +75,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
def authentication_check_only
|
def authentication_check_only
|
||||||
puts 'authentication_check'
|
puts 'authentication_check'
|
||||||
# puts params.inspect
|
# puts params.inspect
|
||||||
|
|
||||||
# check http basic auth
|
# check http basic auth
|
||||||
authenticate_with_http_basic do |username, password|
|
authenticate_with_http_basic do |username, password|
|
||||||
|
@ -207,15 +209,15 @@ class ApplicationController < ActionController::Base
|
||||||
config['timezones'] = {}
|
config['timezones'] = {}
|
||||||
TZInfo::Timezone.all.each { |t|
|
TZInfo::Timezone.all.each { |t|
|
||||||
|
|
||||||
# ignore the following time zones
|
# ignore the following time zones
|
||||||
next if t.name =~ /^GMT/
|
next if t.name =~ /^GMT/
|
||||||
next if t.name =~ /^Etc/
|
next if t.name =~ /^Etc/
|
||||||
next if t.name =~ /^MET/
|
next if t.name =~ /^MET/
|
||||||
next if t.name =~ /^MST/
|
next if t.name =~ /^MST/
|
||||||
next if t.name =~ /^ROC/
|
next if t.name =~ /^ROC/
|
||||||
next if t.name =~ /^ROK/
|
next if t.name =~ /^ROK/
|
||||||
diff = t.current_period.utc_total_offset / 60 /60
|
diff = t.current_period.utc_total_offset / 60 /60
|
||||||
config['timezones'][ t.name ] = diff
|
config['timezones'][ t.name ] = diff
|
||||||
}
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class ChannelsController < ApplicationController
|
class ChannelsController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class EmailAddressesController < ApplicationController
|
class EmailAddressesController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class GettingStartedController < ApplicationController
|
class GettingStartedController < ApplicationController
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class GroupsController < ApplicationController
|
class GroupsController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class InitController < ApplicationController
|
class InitController < ApplicationController
|
||||||
|
|
||||||
# GET /init
|
# GET /init
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class LinksController < ApplicationController
|
class LinksController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class LongPollingController < ApplicationController
|
class LongPollingController < ApplicationController
|
||||||
|
|
||||||
# GET /api/message_send
|
# GET /api/message_send
|
||||||
|
@ -58,7 +60,7 @@ class LongPollingController < ApplicationController
|
||||||
log 'notice', "send auth login (user_id #{user_id})", client_id
|
log 'notice', "send auth login (user_id #{user_id})", client_id
|
||||||
Session.create( client_id, user, { :type => 'ajax' } )
|
Session.create( client_id, user, { :type => 'ajax' } )
|
||||||
|
|
||||||
# broadcast
|
# broadcast
|
||||||
elsif params['data']['action'] == 'broadcast'
|
elsif params['data']['action'] == 'broadcast'
|
||||||
|
|
||||||
# list all current clients
|
# list all current clients
|
||||||
|
@ -74,7 +76,7 @@ class LongPollingController < ApplicationController
|
||||||
Session.send( local_client_id, params['data'] )
|
Session.send( local_client_id, params['data'] )
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
# broadcast every client
|
# broadcast every client
|
||||||
else
|
else
|
||||||
log 'notice', "send broadcast from (#{client_id.to_s})", local_client_id
|
log 'notice', "send broadcast from (#{client_id.to_s})", local_client_id
|
||||||
Session.send( local_client_id, params['data'] )
|
Session.send( local_client_id, params['data'] )
|
||||||
|
@ -115,7 +117,7 @@ class LongPollingController < ApplicationController
|
||||||
count = count - 1
|
count = count - 1
|
||||||
queue = Session.queue( client_id )
|
queue = Session.queue( client_id )
|
||||||
if queue && queue[0]
|
if queue && queue[0]
|
||||||
# puts "send " + queue.inspect + client_id.to_s
|
# puts "send " + queue.inspect + client_id.to_s
|
||||||
render :json => queue
|
render :json => queue
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -134,25 +136,25 @@ class LongPollingController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def client_id_check
|
def client_id_check
|
||||||
return params[:client_id] if params[:client_id]
|
return params[:client_id] if params[:client_id]
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
def client_id_gen
|
def client_id_gen
|
||||||
rand(99999999)
|
rand(99999999)
|
||||||
end
|
end
|
||||||
def client_id_verify
|
def client_id_verify
|
||||||
return if !params[:client_id]
|
return if !params[:client_id]
|
||||||
sessions = Session.sessions
|
sessions = Session.sessions
|
||||||
return if !sessions.include?( params[:client_id].to_s )
|
return if !sessions.include?( params[:client_id].to_s )
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
def log( level, data, client_id = '-' )
|
def log( level, data, client_id = '-' )
|
||||||
if false
|
if false
|
||||||
return if level == 'debug'
|
return if level == 'debug'
|
||||||
end
|
|
||||||
puts "#{Time.now}:client(#{ client_id }) #{ data }"
|
|
||||||
# puts "#{Time.now}:#{ level }:client(#{ client_id }) #{ data }"
|
|
||||||
end
|
end
|
||||||
|
puts "#{Time.now}:client(#{ client_id }) #{ data }"
|
||||||
|
# puts "#{Time.now}:#{ level }:client(#{ client_id }) #{ data }"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class NetworksController < ApplicationController
|
class NetworksController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class OrganizationsController < ApplicationController
|
class OrganizationsController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
@ -140,7 +142,7 @@ Test:
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
return if is_not_role('Agent')
|
return if is_not_role('Agent')
|
||||||
model_destory_render(Organization, params)
|
model_destory_render(Organization, params)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class OverviewsController < ApplicationController
|
class OverviewsController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class PackagesController < ApplicationController
|
class PackagesController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class PostmasterFiltersController < ApplicationController
|
class PostmasterFiltersController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class RecentViewedController < ApplicationController
|
class RecentViewedController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class RolesController < ApplicationController
|
class RolesController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class RssController < ApplicationController
|
class RssController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class SearchController < ApplicationController
|
class SearchController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
module ExtraCollection
|
module ExtraCollection
|
||||||
def session( collections, user )
|
def session( collections, user )
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
module ExtraCollection
|
module ExtraCollection
|
||||||
def session( collections, user )
|
def session( collections, user )
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
module ExtraCollection
|
module ExtraCollection
|
||||||
def session( collections, user )
|
def session( collections, user )
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class SessionsController < ApplicationController
|
class SessionsController < ApplicationController
|
||||||
# def create
|
# def create
|
||||||
# render :text => request.env['rack.auth'].inspect
|
# render :text => request.env['rack.auth'].inspect
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# "Create" a login, aka "log the user in"
|
# "Create" a login, aka "log the user in"
|
||||||
def create
|
def create
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class SettingsController < ApplicationController
|
class SettingsController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class SignaturesController < ApplicationController
|
class SignaturesController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class SlasController < ApplicationController
|
class SlasController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class TagsController < ApplicationController
|
class TagsController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class TaskbarController < ApplicationController
|
class TaskbarController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
@ -38,11 +40,11 @@ class TaskbarController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def access(taskbar)
|
def access(taskbar)
|
||||||
if taskbar.user_id != current_user.id
|
if taskbar.user_id != current_user.id
|
||||||
render :json => { :error => 'Not allowed to access this task.' }, :status => :unprocessable_entity
|
render :json => { :error => 'Not allowed to access this task.' }, :status => :unprocessable_entity
|
||||||
return false
|
return false
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class TemplatesController < ApplicationController
|
class TemplatesController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class TestsController < ApplicationController
|
class TestsController < ApplicationController
|
||||||
|
|
||||||
# GET /test
|
# GET /test
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class TextModulesController < ApplicationController
|
class TextModulesController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class TicketArticlesController < ApplicationController
|
class TicketArticlesController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
@ -66,7 +68,7 @@ class TicketArticlesController < ApplicationController
|
||||||
def attachment_new
|
def attachment_new
|
||||||
|
|
||||||
# store file
|
# store file
|
||||||
# content_type = request.content_type
|
# content_type = request.content_type
|
||||||
content_type = request[:content_type]
|
content_type = request[:content_type]
|
||||||
puts 'content_type: ' + content_type.inspect
|
puts 'content_type: ' + content_type.inspect
|
||||||
if !content_type || content_type == 'application/octet-stream'
|
if !content_type || content_type == 'application/octet-stream'
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class TicketOverviewsController < ApplicationController
|
class TicketOverviewsController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
# GET /api/tickets
|
# GET /api/tickets
|
||||||
def show
|
def show
|
||||||
#sleep 2
|
|
||||||
|
|
||||||
# get navbar overview data
|
# get navbar overview data
|
||||||
if !params[:view]
|
if !params[:view]
|
||||||
|
@ -37,7 +38,7 @@ class TicketOverviewsController < ApplicationController
|
||||||
end
|
end
|
||||||
overview = Ticket.overview(
|
overview = Ticket.overview(
|
||||||
:view => params[:view],
|
:view => params[:view],
|
||||||
# :view_mode => params[:view_mode],
|
# :view_mode => params[:view_mode],
|
||||||
:current_user => User.find( current_user.id ),
|
:current_user => User.find( current_user.id ),
|
||||||
:array => true,
|
:array => true,
|
||||||
)
|
)
|
||||||
|
@ -74,14 +75,14 @@ class TicketOverviewsController < ApplicationController
|
||||||
}
|
}
|
||||||
groups_users = {}
|
groups_users = {}
|
||||||
group_ids.each {|group_id|
|
group_ids.each {|group_id|
|
||||||
groups_users[ group_id ] = []
|
groups_users[ group_id ] = []
|
||||||
Group.find(group_id).users.each {|user|
|
Group.find(group_id).users.each {|user|
|
||||||
next if !agents[ user.id ]
|
next if !agents[ user.id ]
|
||||||
groups_users[ group_id ].push user.id
|
groups_users[ group_id ].push user.id
|
||||||
if !users[user.id]
|
if !users[user.id]
|
||||||
users[user.id] = User.user_data_full(user.id)
|
users[user.id] = User.user_data_full(user.id)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return result
|
# return result
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class TicketPrioritiesController < ApplicationController
|
class TicketPrioritiesController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class TicketStatesController < ApplicationController
|
class TicketStatesController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class TicketsController < ApplicationController
|
class TicketsController < ApplicationController
|
||||||
before_filter :authentication_check
|
before_filter :authentication_check
|
||||||
|
|
||||||
|
@ -133,7 +135,7 @@ class TicketsController < ApplicationController
|
||||||
:open => tickets_open,
|
:open => tickets_open,
|
||||||
:closed => tickets_closed
|
:closed => tickets_closed
|
||||||
}
|
}
|
||||||
# :users => users,
|
# :users => users,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -187,9 +189,9 @@ class TicketsController < ApplicationController
|
||||||
)
|
)
|
||||||
ticket = Ticket.find( params[:ticket_id] )
|
ticket = Ticket.find( params[:ticket_id] )
|
||||||
ticket_list = Ticket.where( :customer_id => ticket.customer_id, :ticket_state_id => ticket_states )
|
ticket_list = Ticket.where( :customer_id => ticket.customer_id, :ticket_state_id => ticket_states )
|
||||||
.where( 'id != ?', [ ticket.id ] )
|
.where( 'id != ?', [ ticket.id ] )
|
||||||
.order('created_at DESC')
|
.order('created_at DESC')
|
||||||
.limit(6)
|
.limit(6)
|
||||||
|
|
||||||
# get related users
|
# get related users
|
||||||
users = {}
|
users = {}
|
||||||
|
@ -263,8 +265,8 @@ class TicketsController < ApplicationController
|
||||||
{
|
{
|
||||||
:ticket_id => ticket_master.id,
|
:ticket_id => ticket_master.id,
|
||||||
:created_by_id => current_user.id,
|
:created_by_id => current_user.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# return result
|
# return result
|
||||||
render :json => {
|
render :json => {
|
||||||
|
@ -375,8 +377,8 @@ class TicketsController < ApplicationController
|
||||||
# get attributes to update
|
# get attributes to update
|
||||||
attributes_to_change = Ticket.attributes_to_change(
|
attributes_to_change = Ticket.attributes_to_change(
|
||||||
:user => current_user,
|
:user => current_user,
|
||||||
# :ticket_id => params[:ticket_id],
|
# :ticket_id => params[:ticket_id],
|
||||||
# :article_id => params[:article_id]
|
# :article_id => params[:article_id]
|
||||||
)
|
)
|
||||||
|
|
||||||
users = {}
|
users = {}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class TranslationsController < ApplicationController
|
class TranslationsController < ApplicationController
|
||||||
before_filter :authentication_check, :except => [:load]
|
before_filter :authentication_check, :except => [:load]
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
before_filter :authentication_check, :except => [:create, :password_reset_send, :password_reset_verify]
|
before_filter :authentication_check, :except => [:create, :password_reset_send, :password_reset_verify]
|
||||||
|
|
||||||
|
@ -143,14 +145,14 @@ curl http://localhost/api/users.json -v -u #{login}:#{password} -H "Content-Type
|
||||||
group_ids.push group.id
|
group_ids.push group.id
|
||||||
}
|
}
|
||||||
|
|
||||||
# everybody else will go as customer per default
|
# everybody else will go as customer per default
|
||||||
else
|
else
|
||||||
role_ids.push Role.where( :name => 'Customer' ).first.id
|
role_ids.push Role.where( :name => 'Customer' ).first.id
|
||||||
end
|
end
|
||||||
user.role_ids = role_ids
|
user.role_ids = role_ids
|
||||||
user.group_ids = group_ids
|
user.group_ids = group_ids
|
||||||
|
|
||||||
# else do assignment as defined
|
# else do assignment as defined
|
||||||
else
|
else
|
||||||
if params[:role_ids]
|
if params[:role_ids]
|
||||||
user.role_ids = params[:role_ids]
|
user.role_ids = params[:role_ids]
|
||||||
|
@ -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[:subject] = 'Invitation to #{config.product_name} at #{config.fqdn}'
|
||||||
data[:body] = 'Hi #{user.firstname},
|
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}
|
#{current_user.firstname} #{current_user.lastname}
|
||||||
|
|
||||||
Your #{config.product_name} Team
|
Your #{config.product_name} Team
|
||||||
'
|
'
|
||||||
|
|
||||||
# prepare subject & body
|
# prepare subject & body
|
||||||
[:subject, :body].each { |key|
|
[:subject, :body].each { |key|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'cache'
|
require 'cache'
|
||||||
require 'user_info'
|
require 'user_info'
|
||||||
|
|
||||||
|
@ -26,7 +28,7 @@ class ApplicationModel < ActiveRecord::Base
|
||||||
data = {}
|
data = {}
|
||||||
self.new.attributes.each {|item|
|
self.new.attributes.each {|item|
|
||||||
if params.has_key?(item[0])
|
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]]
|
data[item[0].to_sym] = params[item[0]]
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -69,9 +71,9 @@ class ApplicationModel < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_update(o)
|
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
|
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
|
if o.respond_to?('cache_delete') then o.cache_delete end
|
||||||
end
|
end
|
||||||
def cache_delete_before
|
def cache_delete_before
|
||||||
|
@ -120,11 +122,11 @@ class ApplicationModel < ActiveRecord::Base
|
||||||
|
|
||||||
def self.lookup(data)
|
def self.lookup(data)
|
||||||
if data[:id]
|
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] )
|
cache = self.cache_get( data[:id] )
|
||||||
return cache if cache
|
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
|
record = self.where( :id => data[:id] ).first
|
||||||
self.cache_set( data[:id], record )
|
self.cache_set( data[:id], record )
|
||||||
return record
|
return record
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Authorization < ApplicationModel
|
class Authorization < ApplicationModel
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
after_create :delete_user_cache
|
after_create :delete_user_cache
|
||||||
|
@ -37,7 +39,7 @@ class Authorization < ApplicationModel
|
||||||
def self.create_from_hash(hash, user = nil)
|
def self.create_from_hash(hash, user = nil)
|
||||||
if user then
|
if user then
|
||||||
user.update_attributes(
|
user.update_attributes(
|
||||||
# :username => hash['username'],
|
# :username => hash['username'],
|
||||||
:image => hash['info']['image']
|
:image => hash['info']['image']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -60,8 +62,8 @@ class Authorization < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def delete_user_cache
|
def delete_user_cache
|
||||||
self.user.cache_delete
|
self.user.cache_delete
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Channel < ApplicationModel
|
class Channel < ApplicationModel
|
||||||
store :options
|
store :options
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'mail'
|
require 'mail'
|
||||||
|
|
||||||
class Channel::EmailBuild
|
class Channel::EmailBuild
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
require 'mail'
|
require 'mail'
|
||||||
|
@ -72,7 +74,7 @@ class Channel::EmailParser
|
||||||
data[:from_local] = Mail::Address.new( mail[:from].value ).local
|
data[:from_local] = Mail::Address.new( mail[:from].value ).local
|
||||||
data[:from_domain] = Mail::Address.new( mail[:from].value ).domain
|
data[:from_domain] = Mail::Address.new( mail[:from].value ).domain
|
||||||
data[:from_display_name] = Mail::Address.new( mail[:from].value ).display_name ||
|
data[:from_display_name] = Mail::Address.new( mail[:from].value ).display_name ||
|
||||||
( Mail::Address.new( mail[:from].value ).comments && Mail::Address.new( mail[:from].value ).comments[0] )
|
( Mail::Address.new( mail[:from].value ).comments && Mail::Address.new( mail[:from].value ).comments[0] )
|
||||||
|
|
||||||
# do extra decoding because we needed to use field.value
|
# do extra decoding because we needed to use field.value
|
||||||
data[:from_display_name] = Mail::Field.new( 'X-From', data[:from_display_name] ).to_s
|
data[:from_display_name] = Mail::Field.new( 'X-From', data[:from_display_name] ).to_s
|
||||||
|
@ -81,8 +83,8 @@ class Channel::EmailParser
|
||||||
data[:message_id] = data['message-id'.to_sym]
|
data[:message_id] = data['message-id'.to_sym]
|
||||||
|
|
||||||
# body
|
# body
|
||||||
# plain_part = mail.multipart? ? (mail.text_part ? mail.text_part.body.decoded : nil) : mail.body.decoded
|
# 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
|
# html_part = message.html_part ? message.html_part.body.decoded : nil
|
||||||
data[:attachments] = []
|
data[:attachments] = []
|
||||||
|
|
||||||
# multi part email
|
# multi part email
|
||||||
|
@ -93,7 +95,7 @@ class Channel::EmailParser
|
||||||
data[:body] = mail.text_part.body.decoded
|
data[:body] = mail.text_part.body.decoded
|
||||||
data[:body] = Encode.conv( mail.text_part.charset, data[:body] )
|
data[:body] = Encode.conv( mail.text_part.charset, data[:body] )
|
||||||
|
|
||||||
# html attachment/body may exists and will be converted to text
|
# html attachment/body may exists and will be converted to text
|
||||||
else
|
else
|
||||||
filename = '-no name-'
|
filename = '-no name-'
|
||||||
if mail.html_part.body
|
if mail.html_part.body
|
||||||
|
@ -102,7 +104,7 @@ class Channel::EmailParser
|
||||||
data[:body] = Encode.conv( mail.html_part.charset.to_s, data[:body] )
|
data[:body] = Encode.conv( mail.html_part.charset.to_s, data[:body] )
|
||||||
data[:body] = html2ascii( data[:body] )
|
data[:body] = html2ascii( data[:body] )
|
||||||
|
|
||||||
# any other attachments
|
# any other attachments
|
||||||
else
|
else
|
||||||
data[:body] = 'no visible content'
|
data[:body] = 'no visible content'
|
||||||
end
|
end
|
||||||
|
@ -144,7 +146,7 @@ class Channel::EmailParser
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
# not multipart email
|
# not multipart email
|
||||||
else
|
else
|
||||||
|
|
||||||
# text part
|
# text part
|
||||||
|
@ -152,7 +154,7 @@ class Channel::EmailParser
|
||||||
data[:body] = mail.body.decoded
|
data[:body] = mail.body.decoded
|
||||||
data[:body] = Encode.conv( mail.charset, data[:body] )
|
data[:body] = Encode.conv( mail.charset, data[:body] )
|
||||||
|
|
||||||
# html part
|
# html part
|
||||||
else
|
else
|
||||||
filename = '-no name-'
|
filename = '-no name-'
|
||||||
if mail.mime_type.to_s.downcase == 'text/html'
|
if mail.mime_type.to_s.downcase == 'text/html'
|
||||||
|
@ -161,7 +163,7 @@ class Channel::EmailParser
|
||||||
data[:body] = Encode.conv( mail.charset, data[:body] )
|
data[:body] = Encode.conv( mail.charset, data[:body] )
|
||||||
data[:body] = html2ascii( data[:body] )
|
data[:body] = html2ascii( data[:body] )
|
||||||
|
|
||||||
# any other attachments
|
# any other attachments
|
||||||
else
|
else
|
||||||
data[:body] = 'no visible content'
|
data[:body] = 'no visible content'
|
||||||
end
|
end
|
||||||
|
@ -425,7 +427,7 @@ class Channel::EmailParser
|
||||||
|
|
||||||
# run postmaster post filter
|
# run postmaster post filter
|
||||||
filters = {
|
filters = {
|
||||||
# '0010' => Channel::Filter::Trusted,
|
# '0010' => Channel::Filter::Trusted,
|
||||||
}
|
}
|
||||||
|
|
||||||
# filter( channel, mail )
|
# filter( channel, mail )
|
||||||
|
@ -525,14 +527,14 @@ module Mail
|
||||||
text
|
text
|
||||||
else
|
else
|
||||||
# Join QP encoded-words that are adjacent to avoid decoding partial chars
|
# 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
|
# Search for occurences of quoted strings or plain strings
|
||||||
text.scan(/( # Group around entire regex to include it in matches
|
text.scan(/( # Group around entire regex to include it in matches
|
||||||
\=\?[^?]+\?([QB])\?[^?]+?\?\= # Quoted String with subgroup for encoding method
|
\=\?[^?]+\?([QB])\?[^?]+?\?\= # Quoted String with subgroup for encoding method
|
||||||
| # or
|
| # or
|
||||||
.+?(?=\=\?|$) # Plain String
|
.+?(?=\=\?|$) # Plain String
|
||||||
)/xmi).map do |matches|
|
)/xmi).map do |matches|
|
||||||
string, method = *matches
|
string, method = *matches
|
||||||
if method == 'b' || method == 'B'
|
if method == 'b' || method == 'B'
|
||||||
b_value_decode(string)
|
b_value_decode(string)
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
#require 'rubygems'
|
#require 'rubygems'
|
||||||
#require 'twitter'
|
#require 'twitter'
|
||||||
|
|
||||||
class Channel::Facebook
|
class Channel::Facebook
|
||||||
# def fetch(:oauth_token, :oauth_token_secret)
|
# def fetch(:oauth_token, :oauth_token_secret)
|
||||||
def fetch
|
def fetch
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,10 +22,10 @@ class Channel::Facebook
|
||||||
:message => self.body
|
:message => self.body
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
# client.direct_message_create(
|
# client.direct_message_create(
|
||||||
# 'medenhofer',
|
# 'medenhofer',
|
||||||
# self.body,
|
# self.body,
|
||||||
# options = {}
|
# options = {}
|
||||||
# )
|
# )
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
# process all database filter
|
# process all database filter
|
||||||
module Channel::Filter::Database
|
module Channel::Filter::Database
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
# delete all X-Zammad header if channel is not trusted
|
# delete all X-Zammad header if channel is not trusted
|
||||||
module Channel::Filter::Trusted
|
module Channel::Filter::Trusted
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'net/imap'
|
require 'net/imap'
|
||||||
|
|
||||||
class Channel::IMAP < Channel::EmailParser
|
class Channel::IMAP < Channel::EmailParser
|
||||||
|
@ -34,7 +36,7 @@ class Channel::IMAP < Channel::EmailParser
|
||||||
count += 1
|
count += 1
|
||||||
puts " - message #{count.to_s}/#{count_all.to_s}"
|
puts " - message #{count.to_s}/#{count_all.to_s}"
|
||||||
msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
|
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
|
# delete email from server after article was created
|
||||||
if process(channel, msg)
|
if process(channel, msg)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Channel::MailStdin < Channel::EmailParser
|
class Channel::MailStdin < Channel::EmailParser
|
||||||
def initialize
|
def initialize
|
||||||
puts "read main from STDIN"
|
puts "read main from STDIN"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'net/pop'
|
require 'net/pop'
|
||||||
|
|
||||||
class Channel::POP3 < Channel::EmailParser
|
class Channel::POP3 < Channel::EmailParser
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Channel::Sendmail < Channel::EmailBuild
|
class Channel::Sendmail < Channel::EmailBuild
|
||||||
def send(attr, channel, notification = false)
|
def send(attr, channel, notification = false)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Channel::SMTP < Channel::EmailBuild
|
class Channel::SMTP < Channel::EmailBuild
|
||||||
def send(attr, channel, notification = false)
|
def send(attr, channel, notification = false)
|
||||||
|
|
||||||
|
@ -12,7 +14,7 @@ class Channel::SMTP < Channel::EmailBuild
|
||||||
:domain => channel[:options][:host],
|
:domain => channel[:options][:host],
|
||||||
:user_name => channel[:options][:user],
|
:user_name => channel[:options][:user],
|
||||||
:password => channel[:options][:password],
|
:password => channel[:options][:password],
|
||||||
# :authentication => 'plain',
|
# :authentication => 'plain',
|
||||||
:enable_starttls_auto => true
|
:enable_starttls_auto => true
|
||||||
}
|
}
|
||||||
mail.deliver
|
mail.deliver
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'twitter'
|
require 'twitter'
|
||||||
|
|
||||||
class Channel::Twitter2
|
class Channel::Twitter2
|
||||||
|
@ -49,13 +51,13 @@ class Channel::Twitter2
|
||||||
all_tweets = []
|
all_tweets = []
|
||||||
result_class = tweets.class
|
result_class = tweets.class
|
||||||
if result_class.to_s == 'Array'
|
if result_class.to_s == 'Array'
|
||||||
all_tweets = tweets
|
all_tweets = tweets
|
||||||
elsif result_class.to_s == 'Twitter::SearchResults'
|
elsif result_class.to_s == 'Twitter::SearchResults'
|
||||||
tweets.results.map do |tweet|
|
tweets.results.map do |tweet|
|
||||||
all_tweets.push tweet
|
all_tweets.push tweet
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
puts 'UNKNOWN: ' + result_class.to_s
|
puts 'UNKNOWN: ' + result_class.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
# find tweets
|
# find tweets
|
||||||
|
@ -91,16 +93,16 @@ class Channel::Twitter2
|
||||||
if tweet['user']
|
if tweet['user']
|
||||||
sender = tweet['user']
|
sender = tweet['user']
|
||||||
|
|
||||||
# direct message (full user data is included)
|
# direct message (full user data is included)
|
||||||
elsif tweet['sender']
|
elsif tweet['sender']
|
||||||
sender = tweet['sender']
|
sender = tweet['sender']
|
||||||
|
|
||||||
# search (no user data is included, do extra lookup)
|
# search (no user data is included, do extra lookup)
|
||||||
elsif tweet['from_user_id']
|
elsif tweet['from_user_id']
|
||||||
begin
|
begin
|
||||||
|
|
||||||
# reconnect for #<Twitter::Error::NotFound: Sorry, that page does not exist> workaround
|
# 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)
|
sender = @client.user(tweet.from_user_id)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
puts "Exception: twitter: " + e.inspect
|
puts "Exception: twitter: " + e.inspect
|
||||||
|
@ -113,7 +115,7 @@ class Channel::Twitter2
|
||||||
if tweet['in_reply_to_status_id']
|
if tweet['in_reply_to_status_id']
|
||||||
puts 'import in_reply_tweet ' + tweet.in_reply_to_status_id.to_s
|
puts 'import in_reply_tweet ' + tweet.in_reply_to_status_id.to_s
|
||||||
tweet_sub = @client.status(tweet.in_reply_to_status_id)
|
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)
|
(user, ticket, article) = fetch_import(tweet_sub, channel, group)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -129,8 +131,8 @@ class Channel::Twitter2
|
||||||
|
|
||||||
def fetch_user_create(tweet, sender)
|
def fetch_user_create(tweet, sender)
|
||||||
# create sender in db
|
# create sender in db
|
||||||
# puts tweet.inspect
|
# puts tweet.inspect
|
||||||
# user = User.where( :login => tweet.sender.screen_name ).first
|
# user = User.where( :login => tweet.sender.screen_name ).first
|
||||||
auth = Authorization.where( :uid => sender.id, :provider => 'twitter' ).first
|
auth = Authorization.where( :uid => sender.id, :provider => 'twitter' ).first
|
||||||
user = nil
|
user = nil
|
||||||
if auth
|
if auth
|
||||||
|
@ -172,7 +174,7 @@ class Channel::Twitter2
|
||||||
|
|
||||||
def fetch_ticket_create(user, tweet, sender, channel, group)
|
def fetch_ticket_create(user, tweet, sender, channel, group)
|
||||||
|
|
||||||
# puts '+++++++++++++++++++++++++++' + tweet.inspect
|
# puts '+++++++++++++++++++++++++++' + tweet.inspect
|
||||||
# check if ticket exists
|
# check if ticket exists
|
||||||
if tweet['in_reply_to_status_id']
|
if tweet['in_reply_to_status_id']
|
||||||
puts 'tweet.in_reply_to_status_id found: ' + 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
|
end
|
||||||
|
|
||||||
def send(attr, notification = false)
|
def send(attr, notification = false)
|
||||||
# logger.debug('tweeeeettttt!!!!!!')
|
# logger.debug('tweeeeettttt!!!!!!')
|
||||||
channel = Channel.where( :area => 'Twitter::Inbound', :active => true ).first
|
channel = Channel.where( :area => 'Twitter::Inbound', :active => true ).first
|
||||||
|
|
||||||
client = Twitter::Client.new(
|
client = Twitter::Client.new(
|
||||||
|
@ -276,7 +278,7 @@ class Channel::Twitter2
|
||||||
attr[:body].to_s,
|
attr[:body].to_s,
|
||||||
{}
|
{}
|
||||||
)
|
)
|
||||||
# puts dm.inspect
|
# puts dm.inspect
|
||||||
return dm
|
return dm
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -287,7 +289,7 @@ class Channel::Twitter2
|
||||||
:in_reply_to_status_id => attr[:in_reply_to]
|
:in_reply_to_status_id => attr[:in_reply_to]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
# puts message.inspect
|
# puts message.inspect
|
||||||
return message
|
return message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class EmailAddress < ApplicationModel
|
class EmailAddress < ApplicationModel
|
||||||
has_many :groups, :after_add => :cache_update, :after_remove => :cache_update
|
has_many :groups, :after_add => :cache_update, :after_remove => :cache_update
|
||||||
validates :realname, :presence => true
|
validates :realname, :presence => true
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Group < ApplicationModel
|
class Group < ApplicationModel
|
||||||
has_and_belongs_to_many :users, :after_add => :cache_update, :after_remove => :cache_update
|
has_and_belongs_to_many :users, :after_add => :cache_update, :after_remove => :cache_update
|
||||||
belongs_to :email_address
|
belongs_to :email_address
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class History < ApplicationModel
|
class History < ApplicationModel
|
||||||
self.table_name = 'histories'
|
self.table_name = 'histories'
|
||||||
belongs_to :history_type, :class_name => 'History::Type'
|
belongs_to :history_type, :class_name => 'History::Type'
|
||||||
belongs_to :history_object, :class_name => 'History::Object'
|
belongs_to :history_object, :class_name => 'History::Object'
|
||||||
belongs_to :history_attribute, :class_name => 'History::Attribute'
|
belongs_to :history_attribute, :class_name => 'History::Attribute'
|
||||||
# before_validation :check_type, :check_object
|
# before_validation :check_type, :check_object
|
||||||
# attr_writer :history_type, :history_object
|
# attr_writer :history_type, :history_object
|
||||||
|
|
||||||
@@cache_type = {}
|
@@cache_type = {}
|
||||||
@@cache_object = {}
|
@@cache_object = {}
|
||||||
|
@ -63,29 +65,29 @@ class History < ApplicationModel
|
||||||
|
|
||||||
def self.history_destroy( requested_object, requested_object_id )
|
def self.history_destroy( requested_object, requested_object_id )
|
||||||
History.where( :history_object_id => History::Object.where( :name => requested_object ) ).
|
History.where( :history_object_id => History::Object.where( :name => requested_object ) ).
|
||||||
where( :o_id => requested_object_id ).
|
where( :o_id => requested_object_id ).
|
||||||
destroy_all
|
destroy_all
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.history_list( requested_object, requested_object_id, related_history_object = nil )
|
def self.history_list( requested_object, requested_object_id, related_history_object = nil )
|
||||||
if !related_history_object
|
if !related_history_object
|
||||||
history_object = self.history_object_lookup( requested_object )
|
history_object = self.history_object_lookup( requested_object )
|
||||||
history = History.where( :history_object_id => history_object.id ).
|
history = History.where( :history_object_id => history_object.id ).
|
||||||
where( :o_id => requested_object_id ).
|
where( :o_id => requested_object_id ).
|
||||||
where( :history_type_id => History::Type.where( :name => ['created', 'updated', 'notification', 'email', 'added', 'removed'] ) ).
|
where( :history_type_id => History::Type.where( :name => ['created', 'updated', 'notification', 'email', 'added', 'removed'] ) ).
|
||||||
order('created_at ASC, id ASC')
|
order('created_at ASC, id ASC')
|
||||||
else
|
else
|
||||||
history_object_requested = self.history_object_lookup( requested_object )
|
history_object_requested = self.history_object_lookup( requested_object )
|
||||||
history_object_related = self.history_object_lookup( related_history_object )
|
history_object_related = self.history_object_lookup( related_history_object )
|
||||||
history = History.where(
|
history = History.where(
|
||||||
'((history_object_id = ? AND o_id = ?) OR (history_object_id = ? AND related_o_id = ? )) AND history_type_id IN (?)',
|
'((history_object_id = ? AND o_id = ?) OR (history_object_id = ? AND related_o_id = ? )) AND history_type_id IN (?)',
|
||||||
history_object_requested.id,
|
history_object_requested.id,
|
||||||
requested_object_id,
|
requested_object_id,
|
||||||
history_object_related.id,
|
history_object_related.id,
|
||||||
requested_object_id,
|
requested_object_id,
|
||||||
History::Type.where( :name => ['created', 'updated', 'notification', 'email', 'added', 'removed'] )
|
History::Type.where( :name => ['created', 'updated', 'notification', 'email', 'added', 'removed'] )
|
||||||
).
|
).
|
||||||
order('created_at ASC, id ASC')
|
order('created_at ASC, id ASC')
|
||||||
end
|
end
|
||||||
|
|
||||||
list = []
|
list = []
|
||||||
|
@ -94,7 +96,7 @@ class History < ApplicationModel
|
||||||
item_tmp['history_type'] = item.history_type.name
|
item_tmp['history_type'] = item.history_type.name
|
||||||
item_tmp['history_object'] = item.history_object.name
|
item_tmp['history_object'] = item.history_object.name
|
||||||
if item.history_attribute
|
if item.history_attribute
|
||||||
item_tmp['history_attribute'] = item.history_attribute.name
|
item_tmp['history_attribute'] = item.history_attribute.name
|
||||||
end
|
end
|
||||||
item_tmp.delete( 'history_attribute_id' )
|
item_tmp.delete( 'history_attribute_id' )
|
||||||
item_tmp.delete( 'history_object_id' )
|
item_tmp.delete( 'history_object_id' )
|
||||||
|
@ -121,14 +123,14 @@ class History < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.activity_stream( user, limit = 10 )
|
def self.activity_stream( user, limit = 10 )
|
||||||
# g = Group.where( :active => true ).joins(:users).where( 'users.id' => user.id )
|
# 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").
|
# 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']) ).
|
# 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").
|
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_object_id => History::Object.where( :name => [ 'Ticket', 'Ticket::Article' ] ) ).
|
||||||
where( :history_type_id => History::Type.where( :name => [ 'created', 'updated' ]) ).
|
where( :history_type_id => History::Type.where( :name => [ 'created', 'updated' ]) ).
|
||||||
order('created_at DESC, id DESC').
|
order('created_at DESC, id DESC').
|
||||||
limit(limit)
|
limit(limit)
|
||||||
datas = []
|
datas = []
|
||||||
stream.each do |item|
|
stream.each do |item|
|
||||||
data = item.attributes
|
data = item.attributes
|
||||||
|
@ -137,7 +139,7 @@ class History < ApplicationModel
|
||||||
data.delete('history_object_id')
|
data.delete('history_object_id')
|
||||||
data.delete('history_type_id')
|
data.delete('history_type_id')
|
||||||
datas.push data
|
datas.push data
|
||||||
# item['history_attribute'] = item.history_attribute
|
# item['history_attribute'] = item.history_attribute
|
||||||
end
|
end
|
||||||
return datas
|
return datas
|
||||||
end
|
end
|
||||||
|
@ -196,88 +198,88 @@ class History < ApplicationModel
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def self.history_type_lookup_id( id )
|
def self.history_type_lookup_id( id )
|
||||||
|
|
||||||
# use cache
|
# use cache
|
||||||
return @@cache_type[ id ] if @@cache_type[ id ]
|
return @@cache_type[ id ] if @@cache_type[ id ]
|
||||||
|
|
||||||
# lookup
|
# lookup
|
||||||
history_type = History::Type.find(id)
|
history_type = History::Type.find(id)
|
||||||
@@cache_type[ id ] = history_type
|
@@cache_type[ id ] = history_type
|
||||||
return history_type
|
return history_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.history_type_lookup( name )
|
def self.history_type_lookup( name )
|
||||||
|
|
||||||
# use cache
|
# use cache
|
||||||
return @@cache_type[ name ] if @@cache_type[ name ]
|
return @@cache_type[ name ] if @@cache_type[ name ]
|
||||||
|
|
||||||
# lookup
|
# lookup
|
||||||
history_type = History::Type.where( :name => name ).first
|
history_type = History::Type.where( :name => name ).first
|
||||||
if history_type
|
if history_type
|
||||||
@@cache_type[ name ] = history_type
|
|
||||||
return history_type
|
|
||||||
end
|
|
||||||
|
|
||||||
# create
|
|
||||||
history_type = History::Type.create(
|
|
||||||
:name => name
|
|
||||||
)
|
|
||||||
@@cache_type[ name ] = history_type
|
@@cache_type[ name ] = history_type
|
||||||
return history_type
|
return history_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.history_object_lookup_id( id )
|
# create
|
||||||
|
history_type = History::Type.create(
|
||||||
|
:name => name
|
||||||
|
)
|
||||||
|
@@cache_type[ name ] = history_type
|
||||||
|
return history_type
|
||||||
|
end
|
||||||
|
|
||||||
# use cache
|
def self.history_object_lookup_id( id )
|
||||||
return @@cache_object[ id ] if @@cache_object[ id ]
|
|
||||||
|
|
||||||
# lookup
|
# use cache
|
||||||
history_object = History::Object.find(id)
|
return @@cache_object[ id ] if @@cache_object[ id ]
|
||||||
@@cache_object[ id ] = history_object
|
|
||||||
return history_object
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.history_object_lookup( name )
|
# lookup
|
||||||
|
history_object = History::Object.find(id)
|
||||||
|
@@cache_object[ id ] = history_object
|
||||||
|
return history_object
|
||||||
|
end
|
||||||
|
|
||||||
# use cache
|
def self.history_object_lookup( name )
|
||||||
return @@cache_object[ name ] if @@cache_object[ name ]
|
|
||||||
|
|
||||||
# lookup
|
# use cache
|
||||||
history_object = History::Object.where( :name => name ).first
|
return @@cache_object[ name ] if @@cache_object[ name ]
|
||||||
if history_object
|
|
||||||
@@cache_object[ name ] = history_object
|
|
||||||
return history_object
|
|
||||||
end
|
|
||||||
|
|
||||||
# create
|
# lookup
|
||||||
history_object = History::Object.create(
|
history_object = History::Object.where( :name => name ).first
|
||||||
:name => name
|
if history_object
|
||||||
)
|
|
||||||
@@cache_object[ name ] = history_object
|
@@cache_object[ name ] = history_object
|
||||||
return history_object
|
return history_object
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.history_attribute_lookup( name )
|
# create
|
||||||
|
history_object = History::Object.create(
|
||||||
|
:name => name
|
||||||
|
)
|
||||||
|
@@cache_object[ name ] = history_object
|
||||||
|
return history_object
|
||||||
|
end
|
||||||
|
|
||||||
# use cache
|
def self.history_attribute_lookup( name )
|
||||||
return @@cache_attribute[ name ] if @@cache_attribute[ name ]
|
|
||||||
|
|
||||||
# lookup
|
# use cache
|
||||||
history_attribute = History::Attribute.where( :name => name ).first
|
return @@cache_attribute[ name ] if @@cache_attribute[ name ]
|
||||||
if history_attribute
|
|
||||||
@@cache_attribute[ name ] = history_attribute
|
|
||||||
return history_attribute
|
|
||||||
end
|
|
||||||
|
|
||||||
# create
|
# lookup
|
||||||
history_attribute = History::Attribute.create(
|
history_attribute = History::Attribute.where( :name => name ).first
|
||||||
:name => name
|
if history_attribute
|
||||||
)
|
|
||||||
@@cache_attribute[ name ] = history_attribute
|
@@cache_attribute[ name ] = history_attribute
|
||||||
return history_attribute
|
return history_attribute
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# create
|
||||||
|
history_attribute = History::Attribute.create(
|
||||||
|
:name => name
|
||||||
|
)
|
||||||
|
@@cache_attribute[ name ] = history_attribute
|
||||||
|
return history_attribute
|
||||||
|
end
|
||||||
|
|
||||||
class Object < ApplicationModel
|
class Object < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Link < ApplicationModel
|
class Link < ApplicationModel
|
||||||
belongs_to :link_type, :class_name => 'Link::Type'
|
belongs_to :link_type, :class_name => 'Link::Type'
|
||||||
belongs_to :link_object, :class_name => 'Link::Object'
|
belongs_to :link_object, :class_name => 'Link::Object'
|
||||||
|
@ -150,25 +152,25 @@ class Link < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def self.link_type_get(data)
|
def self.link_type_get(data)
|
||||||
linktype = Link::Type.where( :name => data[:name] ).first
|
linktype = Link::Type.where( :name => data[:name] ).first
|
||||||
if !linktype
|
if !linktype
|
||||||
linktype = Link::Type.create(
|
linktype = Link::Type.create(
|
||||||
:name => data[:name]
|
:name => data[:name]
|
||||||
)
|
)
|
||||||
end
|
|
||||||
return linktype
|
|
||||||
end
|
end
|
||||||
|
return linktype
|
||||||
|
end
|
||||||
|
|
||||||
def self.link_object_get(data)
|
def self.link_object_get(data)
|
||||||
linkobject = Link::Object.where( :name => data[:name] ).first
|
linkobject = Link::Object.where( :name => data[:name] ).first
|
||||||
if !linkobject
|
if !linkobject
|
||||||
linkobject = Link::Object.create(
|
linkobject = Link::Object.create(
|
||||||
:name => data[:name]
|
:name => data[:name]
|
||||||
)
|
)
|
||||||
end
|
|
||||||
return linkobject
|
|
||||||
end
|
end
|
||||||
|
return linkobject
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Network < ApplicationModel
|
class Network < ApplicationModel
|
||||||
# belongs_to :group
|
# belongs_to :group
|
||||||
# belongs_to :ticket_state, :class_name => 'Ticket::State'
|
# belongs_to :ticket_state, :class_name => 'Ticket::State'
|
||||||
# belongs_to :ticket_priority, :class_name => 'Ticket::Priority'
|
# belongs_to :ticket_priority, :class_name => 'Ticket::Priority'
|
||||||
|
|
||||||
class Category < ApplicationModel
|
class Category < ApplicationModel
|
||||||
self.table_name = 'network_categories'
|
self.table_name = 'network_categories'
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Notifications < ActiveRecord::Base
|
class Notifications < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'history'
|
require 'history'
|
||||||
|
|
||||||
class Observer::History < ActiveRecord::Observer
|
class Observer::History < ActiveRecord::Observer
|
||||||
|
@ -9,7 +11,7 @@ class Observer::History < ActiveRecord::Observer
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
|
|
||||||
puts "HISTORY OBSERVER, object created #{ record.class.name }.find(#{ record.id })"
|
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
|
# if Ticket::Article has changed, remember ticket to be able
|
||||||
# to show article changes in ticket history
|
# to show article changes in ticket history
|
||||||
|
@ -34,17 +36,17 @@ class Observer::History < ActiveRecord::Observer
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
|
|
||||||
# puts 'before_update'
|
# puts 'before_update'
|
||||||
current = record.class.find(record.id)
|
current = record.class.find(record.id)
|
||||||
|
|
||||||
# do not send anything if nothing has changed
|
# do not send anything if nothing has changed
|
||||||
return if current.attributes == record.attributes
|
return if current.attributes == record.attributes
|
||||||
|
|
||||||
puts "HISTORY OBSERVER, object will be updated #{ record.class.name.to_s}.find(#{ current.id.to_s })"
|
puts "HISTORY OBSERVER, object will be updated #{ record.class.name.to_s}.find(#{ current.id.to_s })"
|
||||||
# puts 'current'
|
# puts 'current'
|
||||||
# puts current.inspect
|
# puts current.inspect
|
||||||
# puts 'record'
|
# puts 'record'
|
||||||
# puts record.inspect
|
# puts record.inspect
|
||||||
|
|
||||||
diff = differences_from?(current, record)
|
diff = differences_from?(current, record)
|
||||||
puts ' DIFF'
|
puts ' DIFF'
|
||||||
|
@ -123,7 +125,7 @@ class Observer::History < ActiveRecord::Observer
|
||||||
value[1] = map[key.to_sym][:lookup_object].find( value_ids[1] ).send( map[key.to_sym][:lookup_method] )
|
value[1] = map[key.to_sym][:lookup_object].find( value_ids[1] ).send( map[key.to_sym][:lookup_method] )
|
||||||
end
|
end
|
||||||
|
|
||||||
# if not, fill diff data to value, empty value_ids
|
# if not, fill diff data to value, empty value_ids
|
||||||
else
|
else
|
||||||
value = value_ids
|
value = value_ids
|
||||||
value_ids = []
|
value_ids = []
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'history'
|
require 'history'
|
||||||
|
|
||||||
class Observer::Tag::TicketHistory < ActiveRecord::Observer
|
class Observer::Tag::TicketHistory < ActiveRecord::Observer
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer
|
class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer
|
||||||
observe 'ticket::_article'
|
observe 'ticket::_article'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Observer::Ticket::Article::CommunicateFacebook < ActiveRecord::Observer
|
class Observer::Ticket::Article::CommunicateFacebook < ActiveRecord::Observer
|
||||||
observe 'ticket::_article'
|
observe 'ticket::_article'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
|
class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
|
||||||
observe 'ticket::_article'
|
observe 'ticket::_article'
|
||||||
|
|
||||||
|
@ -23,7 +25,7 @@ class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
|
||||||
:body => record.body,
|
:body => record.body,
|
||||||
:in_reply_to => record.in_reply_to
|
:in_reply_to => record.in_reply_to
|
||||||
},
|
},
|
||||||
# Rails.application.config.channel_twitter
|
# Rails.application.config.channel_twitter
|
||||||
)
|
)
|
||||||
record.message_id = message.id
|
record.message_id = message.id
|
||||||
record.save
|
record.save
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer
|
class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer
|
||||||
observe 'ticket::_article'
|
observe 'ticket::_article'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Observer::Ticket::Article::FillupFromGeneral < ActiveRecord::Observer
|
class Observer::Ticket::Article::FillupFromGeneral < ActiveRecord::Observer
|
||||||
observe 'ticket::_article'
|
observe 'ticket::_article'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Observer::Ticket::ArticleCounter < ActiveRecord::Observer
|
class Observer::Ticket::ArticleCounter < ActiveRecord::Observer
|
||||||
observe 'ticket::_article'
|
observe 'ticket::_article'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Observer::Ticket::ArticleSenderType < ActiveRecord::Observer
|
class Observer::Ticket::ArticleSenderType < ActiveRecord::Observer
|
||||||
observe 'ticket::_article'
|
observe 'ticket::_article'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Observer::Ticket::CloseTime < ActiveRecord::Observer
|
class Observer::Ticket::CloseTime < ActiveRecord::Observer
|
||||||
observe 'ticket'
|
observe 'ticket'
|
||||||
|
|
||||||
|
@ -10,24 +12,24 @@ class Observer::Ticket::CloseTime < ActiveRecord::Observer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def _check(record)
|
def _check(record)
|
||||||
# puts 'check close time'
|
# puts 'check close time'
|
||||||
|
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
|
|
||||||
# check if close_time is already set
|
# check if close_time is already set
|
||||||
return true if record.close_time
|
return true if record.close_time
|
||||||
|
|
||||||
# check if ticket is closed now
|
# check if ticket is closed now
|
||||||
ticket_state = Ticket::State.lookup( :id => record.ticket_state_id )
|
ticket_state = Ticket::State.lookup( :id => record.ticket_state_id )
|
||||||
ticket_state_type = Ticket::StateType.lookup( :id => ticket_state.state_type_id )
|
ticket_state_type = Ticket::StateType.lookup( :id => ticket_state.state_type_id )
|
||||||
return true if ticket_state_type.name != 'closed'
|
return true if ticket_state_type.name != 'closed'
|
||||||
|
|
||||||
# set close_time
|
# set close_time
|
||||||
record.close_time = Time.now
|
record.close_time = Time.now
|
||||||
|
|
||||||
# save ticket
|
# save ticket
|
||||||
record.save
|
record.save
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Observer::Ticket::EscalationCalculation < ActiveRecord::Observer
|
class Observer::Ticket::EscalationCalculation < ActiveRecord::Observer
|
||||||
observe 'ticket', 'ticket::_article'
|
observe 'ticket', 'ticket::_article'
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Observer::Ticket::FirstResponse < ActiveRecord::Observer
|
class Observer::Ticket::FirstResponse < ActiveRecord::Observer
|
||||||
observe 'ticket::_article'
|
observe 'ticket::_article'
|
||||||
|
|
||||||
def after_create(record)
|
def after_create(record)
|
||||||
# puts 'check first response'
|
# puts 'check first response'
|
||||||
|
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Observer::Ticket::LastContact < ActiveRecord::Observer
|
class Observer::Ticket::LastContact < ActiveRecord::Observer
|
||||||
observe 'ticket::_article'
|
observe 'ticket::_article'
|
||||||
|
|
||||||
def after_create(record)
|
def after_create(record)
|
||||||
# puts 'check last contact'
|
# puts 'check last contact'
|
||||||
|
|
||||||
# if article in internal
|
# if article in internal
|
||||||
return true if record.internal
|
return true if record.internal
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'notification_factory'
|
require 'notification_factory'
|
||||||
|
|
||||||
class Observer::Ticket::Notification < ActiveRecord::Observer
|
class Observer::Ticket::Notification < ActiveRecord::Observer
|
||||||
|
@ -10,8 +12,8 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
|
|
||||||
# puts '@@event_buffer'
|
# puts '@@event_buffer'
|
||||||
# puts @@event_buffer.inspect
|
# puts @@event_buffer.inspect
|
||||||
@@event_buffer.each { |event|
|
@@event_buffer.each { |event|
|
||||||
|
|
||||||
# get current state of objects
|
# get current state of objects
|
||||||
|
@ -44,19 +46,19 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
|
||||||
:subject => 'New Ticket (#{ticket.title})',
|
:subject => 'New Ticket (#{ticket.title})',
|
||||||
:body => 'Hi #{recipient.firstname},
|
: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}
|
Group: #{ticket.group.name}
|
||||||
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
|
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
|
||||||
State: i18n(#{ticket.ticket_state.name})
|
State: i18n(#{ticket.ticket_state.name})
|
||||||
|
|
||||||
From: #{article.from}
|
From: #{article.from}
|
||||||
<snip>
|
<snip>
|
||||||
#{article.body}
|
#{article.body}
|
||||||
</snip>
|
</snip>
|
||||||
|
|
||||||
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
|
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
|
||||||
'
|
'
|
||||||
},
|
},
|
||||||
ticket,
|
ticket,
|
||||||
article
|
article
|
||||||
|
@ -77,17 +79,17 @@ From: #{article.from}
|
||||||
:subject => 'New Ticket has been created! (#{ticket.title})',
|
:subject => 'New Ticket has been created! (#{ticket.title})',
|
||||||
:body => 'Thanks for your email. A new ticket has been created.
|
:body => 'Thanks for your email. A new ticket has been created.
|
||||||
|
|
||||||
You wrote:
|
You wrote:
|
||||||
<snip>
|
<snip>
|
||||||
#{article.body}
|
#{article.body}
|
||||||
</snip>
|
</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,
|
ticket,
|
||||||
article
|
article
|
||||||
|
@ -110,19 +112,19 @@ Your Zammad Team
|
||||||
:subject => 'Follow Up (#{ticket.title})',
|
:subject => 'Follow Up (#{ticket.title})',
|
||||||
:body => 'Hi #{recipient.firstname},
|
: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}
|
Group: #{ticket.group.name}
|
||||||
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
|
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
|
||||||
State: i18n(#{ticket.ticket_state.name})
|
State: i18n(#{ticket.ticket_state.name})
|
||||||
|
|
||||||
From: #{article.from}
|
From: #{article.from}
|
||||||
<snip>
|
<snip>
|
||||||
#{article.body}
|
#{article.body}
|
||||||
</snip>
|
</snip>
|
||||||
|
|
||||||
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
|
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
|
||||||
'
|
'
|
||||||
},
|
},
|
||||||
ticket,
|
ticket,
|
||||||
article
|
article
|
||||||
|
@ -139,19 +141,19 @@ From: #{article.from}
|
||||||
:subject => 'Updated (#{ticket.title})',
|
:subject => 'Updated (#{ticket.title})',
|
||||||
:body => 'Hi #{recipient.firstname},
|
: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}
|
Group: #{ticket.group.name}
|
||||||
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
|
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
|
||||||
State: i18n(#{ticket.ticket_state.name})
|
State: i18n(#{ticket.ticket_state.name})
|
||||||
|
|
||||||
From: #{article.from}
|
From: #{article.from}
|
||||||
<snip>
|
<snip>
|
||||||
#{article.body}
|
#{article.body}
|
||||||
</snip>
|
</snip>
|
||||||
|
|
||||||
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
|
#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}/#{article.id}
|
||||||
'
|
'
|
||||||
},
|
},
|
||||||
ticket,
|
ticket,
|
||||||
article
|
article
|
||||||
|
@ -173,20 +175,20 @@ From: #{article.from}
|
||||||
if data[:recipient] == 'group'
|
if data[:recipient] == 'group'
|
||||||
recipients = ticket.agent_of_group()
|
recipients = ticket.agent_of_group()
|
||||||
|
|
||||||
# owner
|
# owner
|
||||||
elsif data[:recipient] == 'owner'
|
elsif data[:recipient] == 'owner'
|
||||||
if ticket.owner_id != 1
|
if ticket.owner_id != 1
|
||||||
recipients.push ticket.owner
|
recipients.push ticket.owner
|
||||||
end
|
end
|
||||||
|
|
||||||
# customer
|
# customer
|
||||||
elsif data[:recipient] == 'customer'
|
elsif data[:recipient] == 'customer'
|
||||||
if ticket.customer_id != 1
|
if ticket.customer_id != 1
|
||||||
# temporarily disabled
|
# temporarily disabled
|
||||||
# recipients.push ticket.customer
|
# recipients.push ticket.customer
|
||||||
end
|
end
|
||||||
|
|
||||||
# owner or group of agents to work on
|
# owner or group of agents to work on
|
||||||
elsif data[:recipient] == 'to_work_on'
|
elsif data[:recipient] == 'to_work_on'
|
||||||
if ticket.owner_id != 1
|
if ticket.owner_id != 1
|
||||||
recipients.push ticket.owner
|
recipients.push ticket.owner
|
||||||
|
@ -251,8 +253,8 @@ From: #{article.from}
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
|
|
||||||
# puts 'CREATED!!!!'
|
# puts 'CREATED!!!!'
|
||||||
# puts record.inspect
|
# puts record.inspect
|
||||||
e = {
|
e = {
|
||||||
:name => record.class.name,
|
:name => record.class.name,
|
||||||
:type => 'create',
|
:type => 'create',
|
||||||
|
@ -273,11 +275,11 @@ From: #{article.from}
|
||||||
# do not send anything if nothing has changed
|
# do not send anything if nothing has changed
|
||||||
return if current.attributes == record.attributes
|
return if current.attributes == record.attributes
|
||||||
|
|
||||||
# puts 'UPDATE!!!!!!!!'
|
# puts 'UPDATE!!!!!!!!'
|
||||||
# puts 'current'
|
# puts 'current'
|
||||||
# puts current.inspect
|
# puts current.inspect
|
||||||
# puts 'record'
|
# puts 'record'
|
||||||
# puts record.inspect
|
# puts record.inspect
|
||||||
|
|
||||||
e = {
|
e = {
|
||||||
:name => record.class.name,
|
:name => record.class.name,
|
||||||
|
@ -293,10 +295,10 @@ From: #{article.from}
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
|
|
||||||
# puts 'after_update'
|
# puts 'after_update'
|
||||||
# puts record.inspect
|
# puts record.inspect
|
||||||
# puts '-----'
|
# puts '-----'
|
||||||
# puts @a.inspect
|
# puts @a.inspect
|
||||||
# AuditTrail.new(record, "UPDATED")
|
# AuditTrail.new(record, "UPDATED")
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,8 +1,10 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Observer::Ticket::ResetNewState < ActiveRecord::Observer
|
class Observer::Ticket::ResetNewState < ActiveRecord::Observer
|
||||||
observe 'ticket::_article'
|
observe 'ticket::_article'
|
||||||
|
|
||||||
def after_create(record)
|
def after_create(record)
|
||||||
# puts 'check reset new state'
|
# puts 'check reset new state'
|
||||||
|
|
||||||
# return if we run import mode
|
# return if we run import mode
|
||||||
return if Setting.get('import_mode')
|
return if Setting.get('import_mode')
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Observer::Ticket::UserTicketCounter < ActiveRecord::Observer
|
class Observer::Ticket::UserTicketCounter < ActiveRecord::Observer
|
||||||
observe 'ticket'
|
observe 'ticket'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Organization < ApplicationModel
|
class Organization < ApplicationModel
|
||||||
has_and_belongs_to_many :users
|
has_and_belongs_to_many :users
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Overview < ApplicationModel
|
class Overview < ApplicationModel
|
||||||
store :condition
|
store :condition
|
||||||
store :order
|
store :order
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'rexml/document'
|
require 'rexml/document'
|
||||||
class Package < ApplicationModel
|
class Package < ApplicationModel
|
||||||
@@root = Rails.root.to_s
|
@@root = Rails.root.to_s
|
||||||
|
@ -322,14 +324,14 @@ class Package < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
def self._parse(xml)
|
def self._parse(xml)
|
||||||
# puts xml.inspect
|
# puts xml.inspect
|
||||||
begin
|
begin
|
||||||
package = REXML::Document.new( xml )
|
package = REXML::Document.new( xml )
|
||||||
rescue => e
|
rescue => e
|
||||||
puts 'ERROR: ' + e.inspect
|
puts 'ERROR: ' + e.inspect
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
# puts package.inspect
|
# puts package.inspect
|
||||||
return package
|
return package
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -481,7 +483,7 @@ class Package < ApplicationModel
|
||||||
record.destroy
|
record.destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
# up
|
# up
|
||||||
else
|
else
|
||||||
done = Package::Migration.where( :name => package.underscore, :version => version ).first
|
done = Package::Migration.where( :name => package.underscore, :version => version ).first
|
||||||
next if done
|
next if done
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class PostmasterFilter < ApplicationModel
|
class PostmasterFilter < ApplicationModel
|
||||||
store :perform
|
store :perform
|
||||||
store :match
|
store :match
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class RecentView < ApplicationModel
|
class RecentView < ApplicationModel
|
||||||
belongs_to :recent_view_object, :class_name => 'RecentView::Object'
|
belongs_to :recent_view_object, :class_name => 'RecentView::Object'
|
||||||
|
|
||||||
|
@ -19,14 +21,14 @@ class RecentView < ApplicationModel
|
||||||
|
|
||||||
def self.log_destroy( requested_object, requested_object_id )
|
def self.log_destroy( requested_object, requested_object_id )
|
||||||
RecentView.where( :recent_view_object_id => RecentView::Object.where( :name => requested_object ) ).
|
RecentView.where( :recent_view_object_id => RecentView::Object.where( :name => requested_object ) ).
|
||||||
where( :o_id => requested_object_id ).
|
where( :o_id => requested_object_id ).
|
||||||
destroy_all
|
destroy_all
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.list( user, limit = 10 )
|
def self.list( user, limit = 10 )
|
||||||
recent_views = RecentView.where( :created_by_id => user.id ).
|
recent_views = RecentView.where( :created_by_id => user.id ).
|
||||||
order('created_at DESC, id DESC').
|
order('created_at DESC, id DESC').
|
||||||
limit(limit)
|
limit(limit)
|
||||||
|
|
||||||
list = []
|
list = []
|
||||||
recent_views.each { |item|
|
recent_views.each { |item|
|
||||||
|
@ -47,16 +49,16 @@ class RecentView < ApplicationModel
|
||||||
recent_viewed.each {|item|
|
recent_viewed.each {|item|
|
||||||
|
|
||||||
# load article ids
|
# load article ids
|
||||||
# if item.recent_view_object == 'Ticket'
|
# if item.recent_view_object == 'Ticket'
|
||||||
ticket = Ticket.find( item['o_id'] ).attributes
|
ticket = Ticket.find( item['o_id'] ).attributes
|
||||||
tickets.push ticket
|
tickets.push ticket
|
||||||
# end
|
# end
|
||||||
# if item.recent_view_object 'Ticket::Article'
|
# if item.recent_view_object 'Ticket::Article'
|
||||||
# tickets.push Ticket::Article.find(item.o_id)
|
# tickets.push Ticket::Article.find(item.o_id)
|
||||||
# end
|
# end
|
||||||
# if item.recent_view_object 'User'
|
# if item.recent_view_object 'User'
|
||||||
# tickets.push User.find(item.o_id)
|
# tickets.push User.find(item.o_id)
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# load users
|
# load users
|
||||||
if !users[ ticket['owner_id'] ]
|
if !users[ ticket['owner_id'] ]
|
||||||
|
@ -78,37 +80,37 @@ class RecentView < ApplicationModel
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def self.recent_view_object_lookup_id( id )
|
def self.recent_view_object_lookup_id( id )
|
||||||
|
|
||||||
# use cache
|
# use cache
|
||||||
return @@cache_object[ id ] if @@cache_object[ id ]
|
return @@cache_object[ id ] if @@cache_object[ id ]
|
||||||
|
|
||||||
# lookup
|
# lookup
|
||||||
history_object = RecentView::Object.find(id)
|
history_object = RecentView::Object.find(id)
|
||||||
@@cache_object[ id ] = history_object
|
@@cache_object[ id ] = history_object
|
||||||
return history_object
|
return history_object
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.recent_view_object_lookup( name )
|
def self.recent_view_object_lookup( name )
|
||||||
|
|
||||||
# use cache
|
# use cache
|
||||||
return @@cache_object[ name ] if @@cache_object[ name ]
|
return @@cache_object[ name ] if @@cache_object[ name ]
|
||||||
|
|
||||||
# lookup
|
# lookup
|
||||||
recent_view_object = RecentView::Object.where( :name => name ).first
|
recent_view_object = RecentView::Object.where( :name => name ).first
|
||||||
if recent_view_object
|
if recent_view_object
|
||||||
@@cache_object[ name ] = recent_view_object
|
|
||||||
return recent_view_object
|
|
||||||
end
|
|
||||||
|
|
||||||
# create
|
|
||||||
recent_view_object = RecentView::Object.create(
|
|
||||||
:name => name
|
|
||||||
)
|
|
||||||
@@cache_object[ name ] = recent_view_object
|
@@cache_object[ name ] = recent_view_object
|
||||||
return recent_view_object
|
return recent_view_object
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# create
|
||||||
|
recent_view_object = RecentView::Object.create(
|
||||||
|
:name => name
|
||||||
|
)
|
||||||
|
@@cache_object[ name ] = recent_view_object
|
||||||
|
return recent_view_object
|
||||||
|
end
|
||||||
|
|
||||||
class Object < ApplicationModel
|
class Object < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Role < ApplicationModel
|
class Role < ApplicationModel
|
||||||
has_and_belongs_to_many :users, :after_add => :cache_update, :after_remove => :cache_update
|
has_and_belongs_to_many :users, :after_add => :cache_update, :after_remove => :cache_update
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Scheduler < ApplicationModel
|
class Scheduler < ApplicationModel
|
||||||
|
|
||||||
def self.run( worker, worker_count )
|
def self.run( worker, worker_count )
|
||||||
|
@ -44,7 +46,7 @@ class Scheduler < ApplicationModel
|
||||||
else
|
else
|
||||||
self._start_job( job, worker, worker_count )
|
self._start_job( job, worker, worker_count )
|
||||||
end
|
end
|
||||||
# raise "Exception from thread"
|
# raise "Exception from thread"
|
||||||
job.pid = ''
|
job.pid = ''
|
||||||
job.save
|
job.save
|
||||||
puts " ...stopped thread for '#{job.method}'"
|
puts " ...stopped thread for '#{job.method}'"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Setting < ApplicationModel
|
class Setting < ApplicationModel
|
||||||
store :options
|
store :options
|
||||||
store :state
|
store :state
|
||||||
|
@ -48,17 +50,17 @@ class Setting < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def delete_cache
|
def delete_cache
|
||||||
@@current[:settings_config] = nil
|
@@current[:settings_config] = nil
|
||||||
end
|
end
|
||||||
def set_initial
|
def set_initial
|
||||||
self.state_initial = self.state
|
self.state_initial = self.state
|
||||||
end
|
end
|
||||||
def state_check
|
def state_check
|
||||||
if self.state || self.state == false
|
if self.state || self.state == false
|
||||||
if !self.state.respond_to?('has_key?') || !self.state.has_key?(:value)
|
if !self.state.respond_to?('has_key?') || !self.state.has_key?(:value)
|
||||||
self.state = { :value => self.state }
|
self.state = { :value => self.state }
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Signature < ApplicationModel
|
class Signature < ApplicationModel
|
||||||
has_many :groups, :after_add => :cache_update, :after_remove => :cache_update
|
has_many :groups, :after_add => :cache_update, :after_remove => :cache_update
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'cache'
|
require 'cache'
|
||||||
|
|
||||||
class Sla < ApplicationModel
|
class Sla < ApplicationModel
|
||||||
|
@ -10,8 +12,8 @@ class Sla < ApplicationModel
|
||||||
after_destroy :escalation_calculation_rebuild
|
after_destroy :escalation_calculation_rebuild
|
||||||
|
|
||||||
private
|
private
|
||||||
def escalation_calculation_rebuild
|
def escalation_calculation_rebuild
|
||||||
Cache.delete( 'SLA::List::Active' )
|
Cache.delete( 'SLA::List::Active' )
|
||||||
Ticket.escalation_calculation_rebuild
|
Ticket.escalation_calculation_rebuild
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'digest/md5'
|
require 'digest/md5'
|
||||||
|
|
||||||
class Store < ApplicationModel
|
class Store < ApplicationModel
|
||||||
|
@ -14,10 +16,10 @@ class Store < ApplicationModel
|
||||||
data['store_object_id'] = store_object.id
|
data['store_object_id'] = store_object.id
|
||||||
|
|
||||||
# check if record already exists
|
# check if record already exists
|
||||||
# store = Store.where( :store_object_id => store_object.id, :o_id => data['o_id'], ).first
|
# store = Store.where( :store_object_id => store_object.id, :o_id => data['o_id'], ).first
|
||||||
# if store != nil
|
# if store != nil
|
||||||
# return store
|
# return store
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# check real store
|
# check real store
|
||||||
md5 = Digest::MD5.hexdigest( data['data'] )
|
md5 = Digest::MD5.hexdigest( data['data'] )
|
||||||
|
@ -49,7 +51,7 @@ class Store < ApplicationModel
|
||||||
# search
|
# search
|
||||||
store_object_id = Store::Object.lookup( :name => data[:object] )
|
store_object_id = Store::Object.lookup( :name => data[:object] )
|
||||||
stores = Store.where( :store_object_id => store_object_id, :o_id => data[:o_id].to_i ).
|
stores = Store.where( :store_object_id => store_object_id, :o_id => data[:o_id].to_i ).
|
||||||
order('created_at ASC, id ASC')
|
order('created_at ASC, id ASC')
|
||||||
return stores
|
return stores
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,8 +59,8 @@ class Store < ApplicationModel
|
||||||
# search
|
# search
|
||||||
store_object_id = Store::Object.lookup( :name => data[:object] )
|
store_object_id = Store::Object.lookup( :name => data[:object] )
|
||||||
stores = Store.where( :store_object_id => store_object_id ).
|
stores = Store.where( :store_object_id => store_object_id ).
|
||||||
where( :o_id => data[:o_id] ).
|
where( :o_id => data[:o_id] ).
|
||||||
order('created_at ASC, id ASC')
|
order('created_at ASC, id ASC')
|
||||||
stores.each do |store|
|
stores.each do |store|
|
||||||
store.destroy
|
store.destroy
|
||||||
end
|
end
|
||||||
|
@ -73,9 +75,9 @@ class Store < ApplicationModel
|
||||||
before_validation :add_md5
|
before_validation :add_md5
|
||||||
|
|
||||||
private
|
private
|
||||||
def add_md5
|
def add_md5
|
||||||
self.md5 = Digest::MD5.hexdigest( self.data )
|
self.md5 = Digest::MD5.hexdigest( self.data )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Tag < ApplicationModel
|
class Tag < ApplicationModel
|
||||||
belongs_to :tag_object, :class_name => 'Tag::Object'
|
belongs_to :tag_object, :class_name => 'Tag::Object'
|
||||||
belongs_to :tag_item, :class_name => 'Tag::Item'
|
belongs_to :tag_item, :class_name => 'Tag::Item'
|
||||||
|
@ -50,8 +52,8 @@ class Tag < ApplicationModel
|
||||||
def self.tag_list( data )
|
def self.tag_list( data )
|
||||||
tag_object_id_requested = self.tag_object_lookup( data[:object] )
|
tag_object_id_requested = self.tag_object_lookup( data[:object] )
|
||||||
tag_search = Tag.where(
|
tag_search = Tag.where(
|
||||||
:tag_object_id => tag_object_id_requested,
|
:tag_object_id => tag_object_id_requested,
|
||||||
:o_id => data[:o_id],
|
:o_id => data[:o_id],
|
||||||
)
|
)
|
||||||
tags = []
|
tags = []
|
||||||
tag_search.each {|tag|
|
tag_search.each {|tag|
|
||||||
|
@ -62,70 +64,70 @@ class Tag < ApplicationModel
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def self.tag_item_lookup_id( id )
|
def self.tag_item_lookup_id( id )
|
||||||
|
|
||||||
# use cache
|
# use cache
|
||||||
return @@cache_item[ id ] if @@cache_item[ id ]
|
return @@cache_item[ id ] if @@cache_item[ id ]
|
||||||
|
|
||||||
# lookup
|
# lookup
|
||||||
tag_item = Tag::Item.find(id)
|
tag_item = Tag::Item.find(id)
|
||||||
@@cache_item[ id ] = tag_item.name
|
@@cache_item[ id ] = tag_item.name
|
||||||
return tag_item.name
|
return tag_item.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.tag_item_lookup( name )
|
def self.tag_item_lookup( name )
|
||||||
|
|
||||||
name = name.downcase
|
name = name.downcase
|
||||||
|
|
||||||
# use cache
|
# use cache
|
||||||
return @@cache_item[ name ] if @@cache_item[ name ]
|
return @@cache_item[ name ] if @@cache_item[ name ]
|
||||||
|
|
||||||
# lookup
|
# lookup
|
||||||
tag_item = Tag::Item.where( :name => name ).first
|
tag_item = Tag::Item.where( :name => name ).first
|
||||||
if tag_item
|
if tag_item
|
||||||
@@cache_item[ name ] = tag_item.id
|
|
||||||
return tag_item.id
|
|
||||||
end
|
|
||||||
|
|
||||||
# create
|
|
||||||
tag_item = Tag::Item.create(
|
|
||||||
:name => name
|
|
||||||
)
|
|
||||||
@@cache_item[ name ] = tag_item.id
|
@@cache_item[ name ] = tag_item.id
|
||||||
return tag_item.id
|
return tag_item.id
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.tag_object_lookup_id( id )
|
# create
|
||||||
|
tag_item = Tag::Item.create(
|
||||||
|
:name => name
|
||||||
|
)
|
||||||
|
@@cache_item[ name ] = tag_item.id
|
||||||
|
return tag_item.id
|
||||||
|
end
|
||||||
|
|
||||||
# use cache
|
def self.tag_object_lookup_id( id )
|
||||||
return @@cache_object[ id ] if @@cache_object[ id ]
|
|
||||||
|
|
||||||
# lookup
|
# use cache
|
||||||
tag_object = Tag::Object.find(id)
|
return @@cache_object[ id ] if @@cache_object[ id ]
|
||||||
@@cache_object[ id ] = tag_object.name
|
|
||||||
return tag_object.name
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.tag_object_lookup( name )
|
# lookup
|
||||||
|
tag_object = Tag::Object.find(id)
|
||||||
|
@@cache_object[ id ] = tag_object.name
|
||||||
|
return tag_object.name
|
||||||
|
end
|
||||||
|
|
||||||
# use cache
|
def self.tag_object_lookup( name )
|
||||||
return @@cache_object[ name ] if @@cache_object[ name ]
|
|
||||||
|
|
||||||
# lookup
|
# use cache
|
||||||
tag_object = Tag::Object.where( :name => name ).first
|
return @@cache_object[ name ] if @@cache_object[ name ]
|
||||||
if tag_object
|
|
||||||
@@cache_object[ name ] = tag_object.id
|
|
||||||
return tag_object.id
|
|
||||||
end
|
|
||||||
|
|
||||||
# create
|
# lookup
|
||||||
tag_object = Tag::Object.create(
|
tag_object = Tag::Object.where( :name => name ).first
|
||||||
:name => name
|
if tag_object
|
||||||
)
|
|
||||||
@@cache_object[ name ] = tag_object.id
|
@@cache_object[ name ] = tag_object.id
|
||||||
return tag_object.id
|
return tag_object.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# create
|
||||||
|
tag_object = Tag::Object.create(
|
||||||
|
:name => name
|
||||||
|
)
|
||||||
|
@@cache_object[ name ] = tag_object.id
|
||||||
|
return tag_object.id
|
||||||
|
end
|
||||||
|
|
||||||
class Object < ActiveRecord::Base
|
class Object < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Taskbar < ApplicationModel
|
class Taskbar < ApplicationModel
|
||||||
store :state
|
store :state
|
||||||
store :params
|
store :params
|
||||||
|
@ -5,7 +7,7 @@ class Taskbar < ApplicationModel
|
||||||
before_update :update_last_contact
|
before_update :update_last_contact
|
||||||
|
|
||||||
private
|
private
|
||||||
def update_last_contact
|
def update_last_contact
|
||||||
self.last_contact = Time.now
|
self.last_contact = Time.now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Template < ApplicationModel
|
class Template < ApplicationModel
|
||||||
store :options
|
store :options
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class TextModule < ApplicationModel
|
class TextModule < ApplicationModel
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
validates :content, :presence => true
|
validates :content, :presence => true
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'time_calculation'
|
require 'time_calculation'
|
||||||
require 'sla'
|
require 'sla'
|
||||||
|
|
||||||
|
@ -78,11 +80,11 @@ class Ticket < ApplicationModel
|
||||||
}
|
}
|
||||||
groups_users = {}
|
groups_users = {}
|
||||||
group_ids.each {|group_id|
|
group_ids.each {|group_id|
|
||||||
groups_users[ group_id ] = []
|
groups_users[ group_id ] = []
|
||||||
Group.find( group_id ).users.each {|user|
|
Group.find( group_id ).users.each {|user|
|
||||||
next if !agents[ user.id ]
|
next if !agents[ user.id ]
|
||||||
groups_users[ group_id ].push user.id
|
groups_users[ group_id ].push user.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# get priorities
|
# get priorities
|
||||||
|
@ -152,9 +154,9 @@ class Ticket < ApplicationModel
|
||||||
self.save
|
self.save
|
||||||
end
|
end
|
||||||
|
|
||||||
# def self.agent
|
# def self.agent
|
||||||
# Role.where( :name => ['Agent'], :active => true ).first.users.where( :active => true ).uniq()
|
# Role.where( :name => ['Agent'], :active => true ).first.users.where( :active => true ).uniq()
|
||||||
# end
|
# end
|
||||||
|
|
||||||
def subject_build (subject)
|
def subject_build (subject)
|
||||||
|
|
||||||
|
@ -204,9 +206,9 @@ class Ticket < ApplicationModel
|
||||||
return subject
|
return subject
|
||||||
end
|
end
|
||||||
|
|
||||||
# ticket.permission(
|
# ticket.permission(
|
||||||
# :current_user => 123
|
# :current_user => 123
|
||||||
# )
|
# )
|
||||||
def permission (data)
|
def permission (data)
|
||||||
|
|
||||||
# check customer
|
# check customer
|
||||||
|
@ -236,11 +238,11 @@ class Ticket < ApplicationModel
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Ticket.search(
|
# Ticket.search(
|
||||||
# :current_user => 123,
|
# :current_user => 123,
|
||||||
# :query => 'search something',
|
# :query => 'search something',
|
||||||
# :limit => 15,
|
# :limit => 15,
|
||||||
# )
|
# )
|
||||||
def self.search (params)
|
def self.search (params)
|
||||||
|
|
||||||
# get params
|
# get params
|
||||||
|
@ -251,9 +253,9 @@ class Ticket < ApplicationModel
|
||||||
conditions = []
|
conditions = []
|
||||||
if current_user.is_role('Agent')
|
if current_user.is_role('Agent')
|
||||||
group_ids = Group.select( 'groups.id' ).joins(:users).
|
group_ids = Group.select( 'groups.id' ).joins(:users).
|
||||||
where( 'groups_users.user_id = ?', current_user.id ).
|
where( 'groups_users.user_id = ?', current_user.id ).
|
||||||
where( 'groups.active = ?', true ).
|
where( 'groups.active = ?', true ).
|
||||||
map( &:id )
|
map( &:id )
|
||||||
conditions = [ 'group_id IN (?)', group_ids ]
|
conditions = [ 'group_id IN (?)', group_ids ]
|
||||||
else
|
else
|
||||||
if !current_user.organization || ( !current_user.organization.shared || current_user.organization.shared == false )
|
if !current_user.organization || ( !current_user.organization.shared || current_user.organization.shared == false )
|
||||||
|
@ -265,11 +267,11 @@ class Ticket < ApplicationModel
|
||||||
|
|
||||||
# do query
|
# do query
|
||||||
tickets_all = Ticket.select('DISTINCT(tickets.id)').
|
tickets_all = Ticket.select('DISTINCT(tickets.id)').
|
||||||
where(conditions).
|
where(conditions).
|
||||||
where( '( `tickets`.`title` LIKE ? OR `tickets`.`number` LIKE ? OR `ticket_articles`.`body` LIKE ? OR `ticket_articles`.`from` LIKE ? OR `ticket_articles`.`to` LIKE ? OR `ticket_articles`.`subject` LIKE ?)', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" ).
|
where( '( `tickets`.`title` LIKE ? OR `tickets`.`number` LIKE ? OR `ticket_articles`.`body` LIKE ? OR `ticket_articles`.`from` LIKE ? OR `ticket_articles`.`to` LIKE ? OR `ticket_articles`.`subject` LIKE ?)', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" ).
|
||||||
joins(:articles).
|
joins(:articles).
|
||||||
limit(limit).
|
limit(limit).
|
||||||
order('`tickets`.`created_at` DESC')
|
order('`tickets`.`created_at` DESC')
|
||||||
|
|
||||||
# build result list
|
# build result list
|
||||||
tickets = []
|
tickets = []
|
||||||
|
@ -281,9 +283,9 @@ class Ticket < ApplicationModel
|
||||||
|
|
||||||
return tickets
|
return tickets
|
||||||
end
|
end
|
||||||
# Ticket.overview_list(
|
# Ticket.overview_list(
|
||||||
# :current_user => 123,
|
# :current_user => 123,
|
||||||
# )
|
# )
|
||||||
def self.overview_list (data)
|
def self.overview_list (data)
|
||||||
|
|
||||||
# get customer overviews
|
# get customer overviews
|
||||||
|
@ -303,10 +305,10 @@ class Ticket < ApplicationModel
|
||||||
return overviews
|
return overviews
|
||||||
end
|
end
|
||||||
|
|
||||||
# Ticket.overview(
|
# Ticket.overview(
|
||||||
# :view => 'some_view_url',
|
# :view => 'some_view_url',
|
||||||
# :current_user => OBJECT,
|
# :current_user => OBJECT,
|
||||||
# )
|
# )
|
||||||
def self.overview (data)
|
def self.overview (data)
|
||||||
|
|
||||||
overviews = self.overview_list(data)
|
overviews = self.overview_list(data)
|
||||||
|
@ -339,35 +341,35 @@ class Ticket < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
# sortby
|
# sortby
|
||||||
# prio
|
# prio
|
||||||
# state
|
# state
|
||||||
# group
|
# group
|
||||||
# customer
|
# customer
|
||||||
|
|
||||||
# order
|
# order
|
||||||
# asc
|
# asc
|
||||||
# desc
|
# desc
|
||||||
|
|
||||||
# groupby
|
# groupby
|
||||||
# prio
|
# prio
|
||||||
# state
|
# state
|
||||||
# group
|
# group
|
||||||
# customer
|
# customer
|
||||||
|
|
||||||
# all = attributes[:myopenassigned]
|
# all = attributes[:myopenassigned]
|
||||||
# all.merge( { :group_id => groups } )
|
# 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
|
# get only tickets with permissions
|
||||||
if data[:current_user].is_role('Customer')
|
if data[:current_user].is_role('Customer')
|
||||||
group_ids = Group.select( 'groups.id' ).
|
group_ids = Group.select( 'groups.id' ).
|
||||||
where( 'groups.active = ?', true ).
|
where( 'groups.active = ?', true ).
|
||||||
map( &:id )
|
map( &:id )
|
||||||
else
|
else
|
||||||
group_ids = Group.select( 'groups.id' ).joins(:users).
|
group_ids = Group.select( 'groups.id' ).joins(:users).
|
||||||
where( 'groups_users.user_id = ?', [ data[:current_user].id ] ).
|
where( 'groups_users.user_id = ?', [ data[:current_user].id ] ).
|
||||||
where( 'groups.active = ?', true ).
|
where( 'groups.active = ?', true ).
|
||||||
map( &:id )
|
map( &:id )
|
||||||
end
|
end
|
||||||
|
|
||||||
# overview meta for navbar
|
# overview meta for navbar
|
||||||
|
@ -400,10 +402,10 @@ class Ticket < ApplicationModel
|
||||||
order_by = overview_selected.group_by + '_id, ' + order_by
|
order_by = overview_selected.group_by + '_id, ' + order_by
|
||||||
end
|
end
|
||||||
tickets = Ticket.select( 'id' ).
|
tickets = Ticket.select( 'id' ).
|
||||||
where( :group_id => group_ids ).
|
where( :group_id => group_ids ).
|
||||||
where( self._condition( overview_selected.condition ) ).
|
where( self._condition( overview_selected.condition ) ).
|
||||||
order( order_by ).
|
order( order_by ).
|
||||||
limit( 500 )
|
limit( 500 )
|
||||||
|
|
||||||
ticket_ids = []
|
ticket_ids = []
|
||||||
tickets.each { |ticket|
|
tickets.each { |ticket|
|
||||||
|
@ -411,8 +413,8 @@ class Ticket < ApplicationModel
|
||||||
}
|
}
|
||||||
|
|
||||||
tickets_count = Ticket.where( :group_id => group_ids ).
|
tickets_count = Ticket.where( :group_id => group_ids ).
|
||||||
where( self._condition( overview_selected.condition ) ).
|
where( self._condition( overview_selected.condition ) ).
|
||||||
count()
|
count()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
:ticket_list => ticket_ids,
|
:ticket_list => ticket_ids,
|
||||||
|
@ -424,14 +426,14 @@ class Ticket < ApplicationModel
|
||||||
# get tickets for overview
|
# get tickets for overview
|
||||||
data[:start_page] ||= 1
|
data[:start_page] ||= 1
|
||||||
tickets = Ticket.where( :group_id => group_ids ).
|
tickets = Ticket.where( :group_id => group_ids ).
|
||||||
where( self._condition( overview_selected.condition ) ).
|
where( self._condition( overview_selected.condition ) ).
|
||||||
order( overview_selected[:order][:by].to_s + ' ' + overview_selected[:order][:direction].to_s )#.
|
order( overview_selected[:order][:by].to_s + ' ' + overview_selected[:order][:direction].to_s )#.
|
||||||
# limit( overview_selected.view[ data[:view_mode].to_sym ][:per_page] ).
|
# 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 ) )
|
# 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 ).
|
tickets_count = Ticket.where( :group_id => group_ids ).
|
||||||
where( self._condition( overview_selected.condition ) ).
|
where( self._condition( overview_selected.condition ) ).
|
||||||
count()
|
count()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
:tickets => tickets,
|
:tickets => tickets,
|
||||||
|
@ -580,8 +582,8 @@ class Ticket < ApplicationModel
|
||||||
ignore_escalation = ['removed', 'closed', 'merged', 'pending action']
|
ignore_escalation = ['removed', 'closed', 'merged', 'pending action']
|
||||||
if ignore_escalation.include?( ticket_state_type.name )
|
if ignore_escalation.include?( ticket_state_type.name )
|
||||||
self.escalation_time = nil
|
self.escalation_time = nil
|
||||||
# self.first_response_escal_date = nil
|
# self.first_response_escal_date = nil
|
||||||
# self.close_time_escal_date = nil
|
# self.close_time_escal_date = nil
|
||||||
self.callback_loop = true
|
self.callback_loop = true
|
||||||
self.save
|
self.save
|
||||||
return true
|
return true
|
||||||
|
@ -593,15 +595,15 @@ class Ticket < ApplicationModel
|
||||||
# reset escalation if no sla is set
|
# reset escalation if no sla is set
|
||||||
if !sla_selected
|
if !sla_selected
|
||||||
self.escalation_time = nil
|
self.escalation_time = nil
|
||||||
# self.first_response_escal_date = nil
|
# self.first_response_escal_date = nil
|
||||||
# self.close_time_escal_date = nil
|
# self.close_time_escal_date = nil
|
||||||
self.callback_loop = true
|
self.callback_loop = true
|
||||||
self.save
|
self.save
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
# puts sla_selected.inspect
|
# puts sla_selected.inspect
|
||||||
# puts days.inspect
|
# puts days.inspect
|
||||||
self.escalation_time = nil
|
self.escalation_time = nil
|
||||||
self.first_response_escal_date = nil
|
self.first_response_escal_date = nil
|
||||||
self.update_time_escal_date = nil
|
self.update_time_escal_date = nil
|
||||||
|
@ -664,43 +666,43 @@ class Ticket < ApplicationModel
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def number_generate
|
def number_generate
|
||||||
return if self.number
|
return if self.number
|
||||||
|
|
||||||
# generate number
|
# generate number
|
||||||
(1..25_000).each do |i|
|
(1..25_000).each do |i|
|
||||||
|
number = Ticket.number_adapter.number_generate_item()
|
||||||
|
ticket = Ticket.where( :number => number ).first
|
||||||
|
if ticket != nil
|
||||||
number = Ticket.number_adapter.number_generate_item()
|
number = Ticket.number_adapter.number_generate_item()
|
||||||
ticket = Ticket.where( :number => number ).first
|
else
|
||||||
if ticket != nil
|
self.number = number
|
||||||
number = Ticket.number_adapter.number_generate_item()
|
return number
|
||||||
else
|
|
||||||
self.number = number
|
|
||||||
return number
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def check_defaults
|
end
|
||||||
if !self.owner_id
|
def check_defaults
|
||||||
self.owner_id = 1
|
if !self.owner_id
|
||||||
end
|
self.owner_id = 1
|
||||||
# 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
|
|
||||||
self.organization_id = customer.organization_id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
def destroy_dependencies
|
# if self.customer_id && ( !self.organization_id || self.organization_id.empty? )
|
||||||
|
if self.customer_id
|
||||||
# delete history
|
customer = User.find( self.customer_id )
|
||||||
History.history_destroy( 'Ticket', self.id )
|
if self.organization_id != customer.organization_id
|
||||||
|
self.organization_id = customer.organization_id
|
||||||
# delete articles
|
end
|
||||||
self.articles.destroy_all
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
def destroy_dependencies
|
||||||
|
|
||||||
|
# delete history
|
||||||
|
History.history_destroy( 'Ticket', self.id )
|
||||||
|
|
||||||
|
# delete articles
|
||||||
|
self.articles.destroy_all
|
||||||
|
end
|
||||||
|
|
||||||
class Number
|
class Number
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Ticket::Article < ApplicationModel
|
class Ticket::Article < ApplicationModel
|
||||||
after_create :attachment_check
|
after_create :attachment_check
|
||||||
belongs_to :ticket
|
belongs_to :ticket
|
||||||
|
@ -9,25 +11,25 @@ class Ticket::Article < ApplicationModel
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def attachment_check
|
def attachment_check
|
||||||
|
|
||||||
# do nothing if no attachment exists
|
# do nothing if no attachment exists
|
||||||
return 1 if self.attachments == nil
|
return 1 if self.attachments == nil
|
||||||
|
|
||||||
# store attachments
|
# store attachments
|
||||||
article_store = []
|
article_store = []
|
||||||
self.attachments.each do |attachment|
|
self.attachments.each do |attachment|
|
||||||
article_store.push Store.add(
|
article_store.push Store.add(
|
||||||
:object => 'Ticket::Article',
|
:object => 'Ticket::Article',
|
||||||
:o_id => self.id,
|
:o_id => self.id,
|
||||||
:data => attachment.store_file.data,
|
:data => attachment.store_file.data,
|
||||||
:filename => attachment.filename,
|
:filename => attachment.filename,
|
||||||
:preferences => attachment.preferences,
|
:preferences => attachment.preferences,
|
||||||
:created_by_id => self.created_by_id,
|
:created_by_id => self.created_by_id,
|
||||||
)
|
)
|
||||||
end
|
|
||||||
self.attachments = article_store
|
|
||||||
end
|
end
|
||||||
|
self.attachments = article_store
|
||||||
|
end
|
||||||
|
|
||||||
class Flag < ApplicationModel
|
class Flag < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Ticket::Counter < ApplicationModel
|
class Ticket::Counter < ApplicationModel
|
||||||
end
|
end
|
|
@ -1,2 +1,4 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Ticket::Flag < ApplicationModel
|
class Ticket::Flag < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
module Ticket::Number::Date
|
module Ticket::Number::Date
|
||||||
extend self
|
extend self
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
module Ticket::Number::Increment
|
module Ticket::Number::Increment
|
||||||
extend self
|
extend self
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Ticket::Priority < ApplicationModel
|
class Ticket::Priority < ApplicationModel
|
||||||
self.table_name = 'ticket_priorities'
|
self.table_name = 'ticket_priorities'
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Ticket::State < ApplicationModel
|
class Ticket::State < ApplicationModel
|
||||||
belongs_to :state_type, :class_name => 'Ticket::StateType'
|
belongs_to :state_type, :class_name => 'Ticket::StateType'
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Ticket::StateType < ApplicationModel
|
class Ticket::StateType < ApplicationModel
|
||||||
has_many :states, :class_name => 'Ticket::State'
|
has_many :states, :class_name => 'Ticket::State'
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class TimeAccounting < ActiveRecord::Base
|
class TimeAccounting < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Token < ActiveRecord::Base
|
class Token < ActiveRecord::Base
|
||||||
before_create :generate_token
|
before_create :generate_token
|
||||||
|
|
||||||
|
@ -23,9 +25,9 @@ class Token < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_token
|
def generate_token
|
||||||
begin
|
begin
|
||||||
self.name = SecureRandom.hex(20)
|
self.name = SecureRandom.hex(20)
|
||||||
end while Token.exists?( :name => self.name )
|
end while Token.exists?( :name => self.name )
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,3 +1,5 @@
|
||||||
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Translation < ApplicationModel
|
class Translation < ApplicationModel
|
||||||
before_create :set_initial
|
before_create :set_initial
|
||||||
|
|
||||||
|
@ -19,7 +21,7 @@ class Translation < ApplicationModel
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def set_initial
|
def set_initial
|
||||||
self.target_initial = self.target
|
self.target_initial = self.target
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue