Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Martin Edenhofer 2015-05-01 09:44:46 +02:00
commit 607911179b
50 changed files with 284 additions and 305 deletions

View file

@ -62,7 +62,7 @@ gem 'em-websocket'
# in production environments by default. # in production environments by default.
group :development, :test do group :development, :test do
gem 'test-unit' gem 'test-unit'
gem 'spring' gem 'spring'
gem 'sqlite3' gem 'sqlite3'

View file

@ -105,13 +105,13 @@ curl http://localhost/api/v1/online_notifications/mark_all_as_read -v -u #{login
=end =end
def mark_all_as_read def mark_all_as_read
notifications = OnlineNotification.list(current_user, 100) notifications = OnlineNotification.list(current_user, 100)
notifications.each do |notification| notifications.each do |notification|
if !notification['seen'] if !notification['seen']
OnlineNotification.seen( id: notification['id'] ) OnlineNotification.seen( id: notification['id'] )
end
end end
render json: {}, status: :ok end
render json: {}, status: :ok
end end
end end

View file

@ -98,13 +98,13 @@ return all activity entries of an user
return [] if role_ids.include?(customer_role.id) return [] if role_ids.include?(customer_role.id)
if group_ids.empty? if group_ids.empty?
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL)', role_ids ). stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL)', role_ids )
order( 'created_at DESC, id DESC' ). .order( 'created_at DESC, id DESC' )
limit( limit ) .limit( limit )
else else
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL) OR ( role_id IN (?) AND group_id IN (?) ) OR ( role_id is NULL AND group_id IN (?) )', role_ids, role_ids, group_ids, group_ids ). stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL) OR ( role_id IN (?) AND group_id IN (?) ) OR ( role_id is NULL AND group_id IN (?) )', role_ids, role_ids, group_ids, group_ids )
order( 'created_at DESC, id DESC' ). .order( 'created_at DESC, id DESC' )
limit( limit ) .limit( limit )
end end
list = [] list = []
stream.each do |item| stream.each do |item|

View file

@ -81,7 +81,7 @@ returns
# only use object attributes # only use object attributes
data = {} data = {}
self.new.attributes.each {|item| self.new.attributes.each {|item|
if params.has_key?(item[0]) if params.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
@ -109,7 +109,7 @@ returns
# set relations # set relations
self.class.reflect_on_all_associations.map { |assoc| self.class.reflect_on_all_associations.map { |assoc|
real_key = assoc.name.to_s[0, assoc.name.to_s.length - 1] + '_ids' real_key = assoc.name.to_s[0, assoc.name.to_s.length - 1] + '_ids'
if params.has_key?( real_key.to_sym ) if params.key?( real_key.to_sym )
list_of_items = params[ real_key.to_sym ] list_of_items = params[ real_key.to_sym ]
if params[ real_key.to_sym ].class != Array if params[ real_key.to_sym ].class != Array
list_of_items = [ params[ real_key.to_sym ] ] list_of_items = [ params[ real_key.to_sym ] ]
@ -246,14 +246,14 @@ returns
# delete old name / login caches # delete old name / login caches
if self.changed? if self.changed?
if self.changes.has_key?('name') if self.changes.key?('name')
name = self.changes['name'][0].to_s name = self.changes['name'][0].to_s
key = self.class.to_s + '::' + name key = self.class.to_s + '::' + name
Cache.delete( key.to_s ) Cache.delete( key.to_s )
key = self.class.to_s + ':f:' + name key = self.class.to_s + ':f:' + name
Cache.delete( key.to_s ) Cache.delete( key.to_s )
end end
if self.changes.has_key?('login') if self.changes.key?('login')
name = self.changes['login'][0].to_s name = self.changes['login'][0].to_s
key = self.class.to_s + '::' + name key = self.class.to_s + '::' + name
Cache.delete( key.to_s ) Cache.delete( key.to_s )
@ -844,7 +844,7 @@ log object update history with all updated attributes, if configured - will be e
changes = self.changes changes = self.changes
if self.history_changes_last_done if self.history_changes_last_done
self.history_changes_last_done.each {|key, value| self.history_changes_last_done.each {|key, value|
if changes.has_key?(key) && changes[key] == value if changes.key?(key) && changes[key] == value
changes.delete(key) changes.delete(key)
end end
} }

View file

@ -20,7 +20,7 @@ module Channel::EmailBuild
# set organization # set organization
organization = Setting.get('organization') organization = Setting.get('organization')
if organization then; if organization
mail['Organization'] = organization.to_s mail['Organization'] = organization.to_s
end end

View file

@ -491,7 +491,7 @@ class Channel::EmailParser
} }
# return new objects # return new objects
return ticket, article, user [ticket, article, user]
end end
def user_create(data) def user_create(data)
@ -526,7 +526,7 @@ class Channel::EmailParser
def set_attributes_by_x_headers( item_object, header_name, mail ) def set_attributes_by_x_headers( item_object, header_name, mail )
# loop all x-zammad-hedaer-* headers # loop all x-zammad-hedaer-* headers
item_object.attributes.each{|key, value| item_object.attributes.each {|key, value|
# ignore read only attributes # ignore read only attributes
next if key == 'updated_at' next if key == 'updated_at'

View file

@ -7,7 +7,7 @@ class Channel::IMAP < Channel::EmailParser
def fetch (channel, check_type = '', verify_string = '') def fetch (channel, check_type = '', verify_string = '')
ssl = true ssl = true
port = 993 port = 993
if channel[:options].has_key?(:ssl) && channel[:options][:ssl].to_s == 'false' if channel[:options].key?(:ssl) && channel[:options][:ssl].to_s == 'false'
ssl = false ssl = false
port = 143 port = 143
end end

View file

@ -7,7 +7,7 @@ class Channel::POP3 < Channel::EmailParser
def fetch (channel, check_type = '', verify_string = '') def fetch (channel, check_type = '', verify_string = '')
ssl = true ssl = true
port = 995 port = 995
if channel[:options].has_key?(:ssl) && channel[:options][:ssl].to_s == 'false' if channel[:options].key?(:ssl) && channel[:options][:ssl].to_s == 'false'
ssl = false ssl = false
port = 110 port = 110
end end

View file

@ -134,7 +134,7 @@ class Channel::TWITTER2
ticket = fetch_ticket_create(user, tweet, sender, channel, group) ticket = fetch_ticket_create(user, tweet, sender, channel, group)
end end
article = fetch_article_create(user, ticket, tweet, sender) article = fetch_article_create(user, ticket, tweet, sender)
return user, ticket, article [user, ticket, article]
end end
def fetch_user_create(tweet, sender) def fetch_user_create(tweet, sender)
@ -177,7 +177,7 @@ class Channel::TWITTER2
# set current user # set current user
UserInfo.current_user_id = user.id UserInfo.current_user_id = user.id
return user user
end end
def fetch_ticket_create(user, tweet, sender, channel, group) def fetch_ticket_create(user, tweet, sender, channel, group)
@ -298,6 +298,6 @@ class Channel::TWITTER2
} }
) )
# puts message.inspect # puts message.inspect
return message message
end end
end end

View file

@ -150,9 +150,9 @@ returns
def self.list( requested_object, requested_object_id, related_history_object = nil, assets = nil ) def self.list( requested_object, requested_object_id, related_history_object = nil, assets = nil )
if !related_history_object if !related_history_object
history_object = self.object_lookup( requested_object ) history_object = self.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 )
order('created_at ASC, id ASC') .order('created_at ASC, id ASC')
else else
history_object_requested = self.object_lookup( requested_object ) history_object_requested = self.object_lookup( requested_object )
history_object_related = self.object_lookup( related_history_object ) history_object_related = self.object_lookup( related_history_object )
@ -162,8 +162,8 @@ returns
requested_object_id, requested_object_id,
history_object_related.id, history_object_related.id,
requested_object_id, requested_object_id,
). )
order('created_at ASC, id ASC') .order('created_at ASC, id ASC')
end end
asset_list = {} asset_list = {}
list = [] list = []
@ -193,7 +193,7 @@ returns
data.delete( 'value_to' ) data.delete( 'value_to' )
data.delete( 'value_from' ) data.delete( 'value_from' )
end end
if data['related_history_object_id'] != nil if !data['related_history_object_id'].nil?
data['related_object'] = self.object_lookup_id( data['related_history_object_id'] ).name data['related_object'] = self.object_lookup_id( data['related_history_object_id'] ).name
end end
data.delete( 'related_history_object_id' ) data.delete( 'related_history_object_id' )
@ -223,7 +223,7 @@ returns
# lookup # lookup
history_type = History::Type.lookup( id: id ) history_type = History::Type.lookup( id: id )
@@cache_type[ id ] = history_type @@cache_type[ id ] = history_type
return history_type history_type
end end
def self.type_lookup( name ) def self.type_lookup( name )
@ -243,7 +243,7 @@ returns
name: name name: name
) )
@@cache_type[ name ] = history_type @@cache_type[ name ] = history_type
return history_type history_type
end end
def self.object_lookup_id( id ) def self.object_lookup_id( id )
@ -254,7 +254,7 @@ returns
# lookup # lookup
history_object = History::Object.lookup( id: id ) history_object = History::Object.lookup( id: id )
@@cache_object[ id ] = history_object @@cache_object[ id ] = history_object
return history_object history_object
end end
def self.object_lookup( name ) def self.object_lookup( name )
@ -274,7 +274,7 @@ returns
name: name name: name
) )
@@cache_object[ name ] = history_object @@cache_object[ name ] = history_object
return history_object history_object
end end
def self.attribute_lookup_id( id ) def self.attribute_lookup_id( id )
@ -285,7 +285,7 @@ returns
# lookup # lookup
history_attribute = History::Attribute.lookup( id: id ) history_attribute = History::Attribute.lookup( id: id )
@@cache_attribute[ id ] = history_attribute @@cache_attribute[ id ] = history_attribute
return history_attribute history_attribute
end end
def self.attribute_lookup( name ) def self.attribute_lookup( name )
@ -305,7 +305,7 @@ returns
name: name name: name
) )
@@cache_attribute[ name ] = history_attribute @@cache_attribute[ name ] = history_attribute
return history_attribute history_attribute
end end
private private

View file

@ -42,9 +42,9 @@ class Job < ApplicationModel
next if !job.timeplan['minutes'].include?( match_minutes(time.min.to_s) ) next if !job.timeplan['minutes'].include?( match_minutes(time.min.to_s) )
# find tickets to change # find tickets to change
tickets = Ticket.where( job.condition.permit! ). tickets = Ticket.where( job.condition.permit! )
order( '`tickets`.`created_at` DESC' ). .order( '`tickets`.`created_at` DESC' )
limit( 1_000 ) .limit( 1_000 )
job.processed = tickets.count job.processed = tickets.count
tickets.each do |ticket| tickets.each do |ticket|
#puts "CHANGE #{job.execute.inspect}" #puts "CHANGE #{job.execute.inspect}"

View file

@ -49,7 +49,7 @@ class Link < ApplicationModel
items.push link items.push link
} }
return items items
end end
=begin =begin
@ -74,19 +74,19 @@ class Link < ApplicationModel
def self.add(data) def self.add(data)
if data.has_key?(:link_type) if data.key?(:link_type)
linktype = self.link_type_get( name: data[:link_type] ) linktype = self.link_type_get( name: data[:link_type] )
data[:link_type_id] = linktype.id data[:link_type_id] = linktype.id
data.delete( :link_type ) data.delete( :link_type )
end end
if data.has_key?(:link_object_source) if data.key?(:link_object_source)
linkobject = self.link_object_get( name: data[:link_object_source] ) linkobject = self.link_object_get( name: data[:link_object_source] )
data[:link_object_source_id] = linkobject.id data[:link_object_source_id] = linkobject.id
data.delete( :link_object_source ) data.delete( :link_object_source )
end end
if data.has_key?(:link_object_target) if data.key?(:link_object_target)
linkobject = self.link_object_get( name: data[:link_object_target] ) linkobject = self.link_object_get( name: data[:link_object_target] )
data[:link_object_target_id] = linkobject.id data[:link_object_target_id] = linkobject.id
data.delete( :link_object_target ) data.delete( :link_object_target )
@ -108,18 +108,18 @@ class Link < ApplicationModel
=end =end
def self.remove(data) def self.remove(data)
if data.has_key?(:link_object_source) if data.key?(:link_object_source)
linkobject = self.link_object_get( name: data[:link_object_source] ) linkobject = self.link_object_get( name: data[:link_object_source] )
data[:link_object_source_id] = linkobject.id data[:link_object_source_id] = linkobject.id
end end
if data.has_key?(:link_object_target) if data.key?(:link_object_target)
linkobject = self.link_object_get( name: data[:link_object_target] ) linkobject = self.link_object_get( name: data[:link_object_target] )
data[:link_object_target_id] = linkobject.id data[:link_object_target_id] = linkobject.id
end end
# from one site # from one site
if data.has_key?(:link_type) if data.key?(:link_type)
linktype = self.link_type_get( name: data[:link_type] ) linktype = self.link_type_get( name: data[:link_type] )
data[:link_type_id] = linktype.id data[:link_type_id] = linktype.id
end end
@ -135,7 +135,7 @@ class Link < ApplicationModel
} }
# from the other site # from the other site
if data.has_key?(:link_type) if data.key?(:link_type)
linktype = self.link_type_get( name: @map[ data[:link_type] ] ) linktype = self.link_type_get( name: @map[ data[:link_type] ] )
data[:link_type_id] = linktype.id data[:link_type_id] = linktype.id
end end
@ -159,7 +159,7 @@ class Link < ApplicationModel
name: data[:name] name: data[:name]
) )
end end
return linktype linktype
end end
def self.link_object_get(data) def self.link_object_get(data)
@ -169,7 +169,7 @@ class Link < ApplicationModel
name: data[:name] name: data[:name]
) )
end end
return linkobject linkobject
end end
end end

View file

@ -187,7 +187,7 @@ returns:
} }
if item.screens if item.screens
data[:screen] = {} data[:screen] = {}
item.screens.each {|screen, roles_options | item.screens.each {|screen, roles_options|
data[:screen][screen] = {} data[:screen][screen] = {}
roles_options.each {|role, options| roles_options.each {|role, options|
if role == '-all-' if role == '-all-'

View file

@ -8,7 +8,7 @@ class Observer::Tag::TicketHistory < ActiveRecord::Observer
def after_create(record) def after_create(record)
# just process ticket object tags # just process ticket object tags
return true if record.tag_object.name != 'Ticket'; return true if record.tag_object.name != 'Ticket'
# add ticket history # add ticket history
History.add( History.add(
@ -22,7 +22,7 @@ class Observer::Tag::TicketHistory < ActiveRecord::Observer
def after_destroy(record) def after_destroy(record)
# just process ticket object tags # just process ticket object tags
return true if record.tag_object.name != 'Ticket'; return true if record.tag_object.name != 'Ticket'
# add ticket history # add ticket history
History.add( History.add(

View file

@ -56,7 +56,7 @@ mark online notification as seen
=end =end
def self.seen(data) def self.seen(data)
notification = OnlineNotification.find(data[:id]) notification = OnlineNotification.find(data[:id])
notification.seen = true notification.seen = true
notification.save notification.save
end end
@ -87,9 +87,9 @@ return all online notifications of an user
def self.list(user, limit) def self.list(user, limit)
notifications = OnlineNotification.where(user_id: user.id). notifications = OnlineNotification.where(user_id: user.id)
order( 'created_at DESC, id DESC' ). .order( 'created_at DESC, id DESC' )
limit( limit ) .limit( limit )
list = [] list = []
notifications.each do |item| notifications.each do |item|
data = item.attributes data = item.attributes
@ -115,9 +115,9 @@ return all online notifications of an object
notifications = OnlineNotification.where( notifications = OnlineNotification.where(
object_lookup_id: object_id, object_lookup_id: object_id,
o_id: o_id, o_id: o_id,
). )
order( 'created_at DESC, id DESC' ). .order( 'created_at DESC, id DESC' )
limit( 10_000 ) .limit( 10_000 )
list = [] list = []
notifications.each do |item| notifications.each do |item|
data = item.attributes data = item.attributes
@ -139,17 +139,17 @@ mark online notification as seen by object
=end =end
def self.seen_by_object(object_name, o_id) def self.seen_by_object(object_name, o_id)
object_id = ObjectLookup.by_name( object_name ) object_id = ObjectLookup.by_name( object_name )
notifications = OnlineNotification.where( notifications = OnlineNotification.where(
object_lookup_id: object_id, object_lookup_id: object_id,
o_id: o_id, o_id: o_id,
seen: false, seen: false,
) )
notifications.each do |notification| notifications.each do |notification|
notification.seen = true notification.seen = true
notification.save notification.save
end end
true true
end end
=begin =begin
@ -171,7 +171,7 @@ returns:
notifications = OnlineNotification.list(user, limit) notifications = OnlineNotification.list(user, limit)
assets = ApplicationModel.assets_of_object_list(notifications) assets = ApplicationModel.assets_of_object_list(notifications)
return { {
stream: notifications, stream: notifications,
assets: assets assets: assets
} }

View file

@ -71,7 +71,7 @@ class Package < ApplicationModel
File.delete( entry ) File.delete( entry )
end end
backup_file = entry + '.link_backup' backup_file = entry + '.link_backup'
if File.exists?( backup_file ) if File.exist?( backup_file )
logger.info "Restore backup file of #{backup_file} -> #{entry}." logger.info "Restore backup file of #{backup_file} -> #{entry}."
File.rename( backup_file, entry ) File.rename( backup_file, entry )
end end
@ -114,7 +114,7 @@ class Package < ApplicationModel
end end
backup_file = dest.to_s + '.link_backup' backup_file = dest.to_s + '.link_backup'
if File.exists?( backup_file ) if File.exist?( backup_file )
logger.info "Restore backup file of #{backup_file} -> #{dest.to_s}." logger.info "Restore backup file of #{backup_file} -> #{dest.to_s}."
File.rename( backup_file, dest.to_s ) File.rename( backup_file, dest.to_s )
end end
@ -145,7 +145,7 @@ class Package < ApplicationModel
dest = @@root + '/' + file dest = @@root + '/' + file
if File.directory?( entry.to_s ) if File.directory?( entry.to_s )
if !File.exists?( dest.to_s ) if !File.exist?( dest.to_s )
logger.info "Create dir: #{dest.to_s}" logger.info "Create dir: #{dest.to_s}"
FileUtils.mkdir_p( dest.to_s ) FileUtils.mkdir_p( dest.to_s )
end end
@ -153,7 +153,7 @@ class Package < ApplicationModel
if File.file?( entry.to_s ) && ( File.file?( dest.to_s ) && !File.symlink?( dest.to_s ) ) if File.file?( entry.to_s ) && ( File.file?( dest.to_s ) && !File.symlink?( dest.to_s ) )
backup_file = dest.to_s + '.link_backup' backup_file = dest.to_s + '.link_backup'
if File.exists?( backup_file ) if File.exist?( backup_file )
raise "Can't link #{entry.to_s} -> #{dest.to_s}, destination and .link_backup already exists!" raise "Can't link #{entry.to_s} -> #{dest.to_s}, destination and .link_backup already exists!"
else else
logger.info "Create backup file of #{dest.to_s} -> #{backup_file}." logger.info "Create backup file of #{dest.to_s} -> #{backup_file}."
@ -441,7 +441,7 @@ class Package < ApplicationModel
def self.migrate( package, direction = 'normal' ) def self.migrate( package, direction = 'normal' )
location = @@root + '/db/addon/' + package.underscore location = @@root + '/db/addon/' + package.underscore
return true if !File.exists?( location ) return true if !File.exist?( location )
migrations_done = Package::Migration.where( name: package.underscore ) migrations_done = Package::Migration.where( name: package.underscore )
# get existing migrations # get existing migrations

View file

@ -26,9 +26,9 @@ class RecentView < ApplicationModel
def self.log_destroy( requested_object, requested_object_id ) def self.log_destroy( requested_object, requested_object_id )
return if requested_object == 'RecentView' return if requested_object == 'RecentView'
RecentView.where( recent_view_object_id: ObjectLookup.by_name( requested_object ) ). RecentView.where( recent_view_object_id: ObjectLookup.by_name( requested_object ) )
where( o_id: requested_object_id ). .where( o_id: requested_object_id )
destroy_all .destroy_all
end end
def self.user_log_destroy( user ) def self.user_log_destroy( user )
@ -37,13 +37,13 @@ class RecentView < ApplicationModel
def self.list( user, limit = 10, type = nil ) def self.list( user, limit = 10, type = nil )
if !type if !type
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)
else else
recent_views = RecentView.select('DISTINCT(o_id), recent_view_object_id').where( created_by_id: user.id, recent_view_object_id: ObjectLookup.by_name(type) ) . recent_views = RecentView.select('DISTINCT(o_id), recent_view_object_id').where( created_by_id: user.id, recent_view_object_id: ObjectLookup.by_name(type) )
order('created_at DESC, id DESC'). .order('created_at DESC, id DESC')
limit(limit) .limit(limit)
end end
list = [] list = []
@ -67,7 +67,7 @@ class RecentView < ApplicationModel
# get related object # get related object
assets = ApplicationModel.assets_of_object_list(recent_viewed) assets = ApplicationModel.assets_of_object_list(recent_viewed)
return { {
stream: recent_viewed, stream: recent_viewed,
assets: assets, assets: assets,
} }

View file

@ -32,7 +32,7 @@ class Setting < ApplicationModel
# store for class requests # store for class requests
@@current[:settings_config] = config @@current[:settings_config] = config
return config config
end end
def self.set(name, value) def self.set(name, value)
@ -47,7 +47,7 @@ class Setting < ApplicationModel
def self.get(name) def self.get(name)
self.load self.load
return @@current[:settings_config][name] @@current[:settings_config][name]
end end
private private
@ -61,7 +61,7 @@ class Setting < ApplicationModel
return if !(self.state || self.state == false) return if !(self.state || self.state == false)
return if !( !self.state.respond_to?('has_key?') || !self.state.has_key?(:value) ) return if !( !self.state.respond_to?('has_key?') || !self.state.key?(:value) )
self.state = { value: self.state } self.state = { value: self.state }
end end

View file

@ -80,9 +80,9 @@ returns
def self.list(data) def self.list(data)
# 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 stores
end end
=begin =begin
@ -103,15 +103,15 @@ returns
def self.remove(data) def self.remove(data)
# 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|
# check backend for references # check backend for references
Store.remove_item( store.id ) Store.remove_item( store.id )
end end
return true true
end end
=begin =begin
@ -136,7 +136,7 @@ returns
end end
store.destroy store.destroy
return true true
end end
def content def content

View file

@ -24,7 +24,7 @@ class Tag < ApplicationModel
o_id: data[:o_id], o_id: data[:o_id],
created_by_id: data[:created_by_id], created_by_id: data[:created_by_id],
) )
return true true
end end
def self.tag_remove(data) def self.tag_remove(data)
@ -46,7 +46,7 @@ class Tag < ApplicationModel
result.each { |item| result.each { |item|
item.destroy item.destroy
} }
return true true
end end
def self.tag_list( data ) def self.tag_list( data )
@ -59,7 +59,7 @@ class Tag < ApplicationModel
tag_search.each {|tag| tag_search.each {|tag|
tags.push self.tag_item_lookup_id( tag.tag_item_id ) tags.push self.tag_item_lookup_id( tag.tag_item_id )
} }
return tags tags
end end
private private
@ -72,7 +72,7 @@ class Tag < ApplicationModel
# 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 tag_item.name
end end
def self.tag_item_lookup( name ) def self.tag_item_lookup( name )
@ -94,7 +94,7 @@ class Tag < ApplicationModel
name: name name: name
) )
@@cache_item[ name ] = tag_item.id @@cache_item[ name ] = tag_item.id
return tag_item.id tag_item.id
end end
def self.tag_object_lookup_id( id ) def self.tag_object_lookup_id( id )
@ -105,7 +105,7 @@ class Tag < ApplicationModel
# lookup # lookup
tag_object = Tag::Object.find(id) tag_object = Tag::Object.find(id)
@@cache_object[ id ] = tag_object.name @@cache_object[ id ] = tag_object.name
return tag_object.name tag_object.name
end end
def self.tag_object_lookup( name ) def self.tag_object_lookup( name )
@ -125,7 +125,7 @@ class Tag < ApplicationModel
name: name name: name
) )
@@cache_object[ name ] = tag_object.id @@cache_object[ name ] = tag_object.id
return tag_object.id tag_object.id
end end
class Object < ActiveRecord::Base class Object < ActiveRecord::Base

View file

@ -94,10 +94,10 @@ returns
def self.access_condition(user) def self.access_condition(user)
access_condition = [] access_condition = []
if user.is_role(Z_ROLENAME_AGENT) if user.is_role(Z_ROLENAME_AGENT)
group_ids = Group.select( 'groups.id' ).joins(:users). group_ids = Group.select( 'groups.id' ).joins(:users)
where( 'groups_users.user_id = ?', user.id ). .where( 'groups_users.user_id = ?', user.id )
where( 'groups.active = ?', true ). .where( 'groups.active = ?', true )
map( &:id ) .map( &:id )
access_condition = [ 'group_id IN (?)', group_ids ] access_condition = [ 'group_id IN (?)', group_ids ]
else else
if !user.organization || ( !user.organization.shared || user.organization.shared == false ) if !user.organization || ( !user.organization.shared || user.organization.shared == false )

View file

@ -262,7 +262,7 @@ returns
if counted if counted
# puts "Diff count #{history_item['value_from']} -> #{history_item['value_to']} / #{last_state_change} -> #{history_item['created_at']}" # puts "Diff count #{history_item['value_from']} -> #{history_item['value_to']} / #{last_state_change} -> #{history_item['created_at']}"
total_time_without_pending = total_time_without_pending + diff total_time_without_pending = total_time_without_pending + diff
else # else
# puts "Diff not count #{history_item['value_from']} -> #{history_item['value_to']} / #{last_state_change} -> #{history_item['created_at']}" # puts "Diff not count #{history_item['value_from']} -> #{history_item['value_to']} / #{last_state_change} -> #{history_item['created_at']}"
end end
total_time = total_time + diff total_time = total_time + diff

View file

@ -72,7 +72,7 @@ returns
end end
# replace e.g. 'current_user.id' with current_user.id # replace e.g. 'current_user.id' with current_user.id
overview.condition.each { |item, value | overview.condition.each { |item, value|
if value && value.class.to_s == 'String' if value && value.class.to_s == 'String'
parts = value.split( '.', 2 ) parts = value.split( '.', 2 )
if parts[0] && parts[1] && parts[0] == 'current_user' if parts[0] && parts[1] && parts[0] == 'current_user'
@ -108,14 +108,14 @@ returns
# @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
@ -147,20 +147,20 @@ returns
if overview_selected.group_by && !overview_selected.group_by.empty? if overview_selected.group_by && !overview_selected.group_by.empty?
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( _condition( overview_selected.condition ) ). .where( _condition( overview_selected.condition ) )
order( order_by ). .order( order_by )
limit( 500 ) .limit( 500 )
ticket_ids = [] ticket_ids = []
tickets.each { |ticket| tickets.each { |ticket|
ticket_ids.push ticket.id ticket_ids.push ticket.id
} }
tickets_count = Ticket.where( group_id: group_ids ). tickets_count = Ticket.where( group_id: group_ids )
where( _condition( overview_selected.condition ) ). .where( _condition( overview_selected.condition ) )
count() .count()
return { return {
ticket_ids: ticket_ids, ticket_ids: ticket_ids,
@ -171,15 +171,15 @@ returns
# 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( _condition( overview_selected.condition ) ). .where( _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( _condition( overview_selected.condition ) ). .where( _condition( overview_selected.condition ) )
count() .count()
{ {
tickets: tickets, tickets: tickets,

View file

@ -34,7 +34,7 @@ returns
end end
# left position # left position
return "[#{ticket_hook}#{ticket_hook_divider}#{self.number}] " + subject "[#{ticket_hook}#{ticket_hook_divider}#{self.number}] " + subject
end end
=begin =begin

View file

@ -22,7 +22,7 @@ class Token < ActiveRecord::Base
end end
# return token if valid # return token if valid
return token.user token.user
end end
private private

View file

@ -136,7 +136,7 @@ get list of translations
end end
end end
return { {
list: list, list: list,
} }
end end
@ -163,7 +163,7 @@ translate strings in ruby context, e. g. for notifications
return record.target if record.source == string return record.target if record.source == string
} }
return string string
end end
private private

View file

@ -159,7 +159,7 @@ returns
# get related objects # get related objects
assets = ApplicationModel.assets_of_object_list(activity_stream) assets = ApplicationModel.assets_of_object_list(activity_stream)
return { {
activity_stream: activity_stream, activity_stream: activity_stream,
assets: assets, assets: assets,
} }
@ -245,7 +245,7 @@ returns
def self.create_from_hash!(hash) def self.create_from_hash!(hash)
url = '' url = ''
if hash['info']['urls'] then if hash['info']['urls']
url = hash['info']['urls']['Website'] || hash['info']['urls']['Twitter'] || '' url = hash['info']['urls']['Website'] || hash['info']['urls']['Twitter'] || ''
end end
roles = Role.where( name: 'Customer' ) roles = Role.where( name: 'Customer' )
@ -415,10 +415,10 @@ returns
scan = self.firstname.scan(/, /) scan = self.firstname.scan(/, /)
if scan[0] if scan[0]
name = self.firstname.split(', ', 2) name = self.firstname.split(', ', 2)
if name[0] != nil if !name[0].nil?
self.lastname = name[0] self.lastname = name[0]
end end
if name[1] != nil if !name[1].nil?
self.firstname = name[1] self.firstname = name[1]
end end
return return
@ -426,10 +426,10 @@ returns
# Firstname Lastname # Firstname Lastname
name = self.firstname.split(' ', 2) name = self.firstname.split(' ', 2)
if name[0] != nil if !name[0].nil?
self.firstname = name[0] self.firstname = name[0]
end end
if name[1] != nil if !name[1].nil?
self.lastname = name[1] self.lastname = name[1]
end end
return return
@ -438,10 +438,10 @@ returns
elsif ( !self.firstname || self.firstname.empty? ) && ( !self.lastname || self.lastname.empty? ) && ( self.email && !self.email.empty? ) elsif ( !self.firstname || self.firstname.empty? ) && ( !self.lastname || self.lastname.empty? ) && ( self.email && !self.email.empty? )
scan = self.email.scan(/^(.+?)\.(.+?)\@.+?$/) scan = self.email.scan(/^(.+?)\.(.+?)\@.+?$/)
if scan[0] if scan[0]
if scan[0][0] != nil if !scan[0][0].nil?
self.firstname = scan[0][0].capitalize self.firstname = scan[0][0].capitalize
end end
if scan[0][1] != nil if !scan[0][1].nil?
self.lastname = scan[0][1].capitalize self.lastname = scan[0][1].capitalize
end end
end end

View file

@ -35,7 +35,7 @@ returns
# get linked accounts # get linked accounts
attributes['accounts'] = {} attributes['accounts'] = {}
authorizations = self.authorizations() authorizations = self.authorizations()
authorizations.each do | authorization | authorizations.each do |authorization|
attributes['accounts'][authorization.provider] = { attributes['accounts'][authorization.provider] = {
uid: authorization[:uid], uid: authorization[:uid],
username: authorization[:username] username: authorization[:username]

View file

@ -3,4 +3,4 @@ require 'rubygems'
# Set up gems listed in the Gemfile. # Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])

View file

@ -1,6 +1,6 @@
Rails.application.config.middleware.use OmniAuth::Builder do Rails.application.config.middleware.use OmniAuth::Builder do
# twitter database connect # twitter database connect
provider :twitter_database, 'not_change_will_be_set_by_databse', 'not_change_will_be_set_by_databse', provider :twitter_database, 'not_change_will_be_set_by_databse', 'not_change_will_be_set_by_databse',
client_options: { authorize_path: '/oauth/authorize', site: 'https://api.twitter.com' } client_options: { authorize_path: '/oauth/authorize', site: 'https://api.twitter.com' }

View file

@ -1,6 +1,6 @@
class CreateChannel < ActiveRecord::Migration class CreateChannel < ActiveRecord::Migration
def up def up
create_table :channels do |t| create_table :channels do |t|
t.references :group, null: true t.references :group, null: true
t.column :adapter, :string, limit: 100, null: false t.column :adapter, :string, limit: 100, null: false

View file

@ -8,14 +8,14 @@ class UpdateTicketNumber < ActiveRecord::Migration
number, the SystemID and the counter are used with SystemID.Counter format (e.g. 1010138, 1010139). number, the SystemID and the counter are used with SystemID.Counter format (e.g. 1010138, 1010139).
With "Date" the ticket numbers will be generated by the current date, the SystemID and the counter. With "Date" the ticket numbers will be generated by the current date, the SystemID and the counter.
The format looks like Year.Month.Day.SystemID.counter (e.g. 201206231010138, 201206231010139). The format looks like Year.Month.Day.SystemID.counter (e.g. 201206231010138, 201206231010139).
With param "Checksum => true" the counter will be appended as checksum to the string. The format With param "Checksum => true" the counter will be appended as checksum to the string. The format
looks like SystemID.Counter.CheckSum (e. g. 10101384, 10101392) or Year.Month.Day.SystemID.Counter.CheckSum (e.g. 2012070110101520, 2012070110101535).', looks like SystemID.Counter.CheckSum (e. g. 10101384, 10101392) or Year.Month.Day.SystemID.Counter.CheckSum (e.g. 2012070110101520, 2012070110101535).',
options: { options: {
form: [ form: [
{ {
display: '', display: '',
null: true, null: true,
name: 'ticket_number', name: 'ticket_number',
tag: 'select', tag: 'select',
options: { options: {
'Ticket::Number::Increment' => 'Increment (SystemID.Counter)', 'Ticket::Number::Increment' => 'Increment (SystemID.Counter)',

View file

@ -768,7 +768,7 @@ Setting.create_if_not_exists(
number, the SystemID and the counter are used with SystemID.Counter format (e.g. 1010138, 1010139). number, the SystemID and the counter are used with SystemID.Counter format (e.g. 1010138, 1010139).
With "Date" the ticket numbers will be generated by the current date, the SystemID and the counter. With "Date" the ticket numbers will be generated by the current date, the SystemID and the counter.
The format looks like Year.Month.Day.SystemID.counter (e.g. 201206231010138, 201206231010139). The format looks like Year.Month.Day.SystemID.counter (e.g. 201206231010138, 201206231010139).
With param "Checksum => true" the counter will be appended as checksum to the string. The format With param "Checksum => true" the counter will be appended as checksum to the string. The format
looks like SystemID.Counter.CheckSum (e. g. 10101384, 10101392) or Year.Month.Day.SystemID.Counter.CheckSum (e.g. 2012070110101520, 2012070110101535).', looks like SystemID.Counter.CheckSum (e. g. 10101384, 10101392) or Year.Month.Day.SystemID.Counter.CheckSum (e.g. 2012070110101520, 2012070110101535).',
options: { options: {
form: [ form: [

View file

@ -54,7 +54,5 @@ returns
return user_auth return user_auth
end end
} }
return end
end
end end

View file

@ -8,6 +8,6 @@ module Auth::Developer
return user if password == 'test' return user if password == 'test'
end end
return false false
end end
end end

View file

@ -15,6 +15,6 @@ module Auth::Internal
# plain auth check # plain auth check
return user if user.password == password return user if user.password == password
return false false
end end
end end

View file

@ -64,7 +64,7 @@ module Auth::Ldap
source: 'ldap', source: 'ldap',
updated_by_id: 1, updated_by_id: 1,
} }
config[:sync_params].each {| local_data, ldap_data | config[:sync_params].each {|local_data, ldap_data|
if user_data[ ldap_data.downcase.to_sym ] if user_data[ ldap_data.downcase.to_sym ]
user_attributes[ local_data.downcase.to_sym] = user_data[ ldap_data.downcase.to_sym ] user_attributes[ local_data.downcase.to_sym] = user_data[ ldap_data.downcase.to_sym ]
end end
@ -76,7 +76,7 @@ module Auth::Ldap
else else
user.update_attributes( user_attributes ) user.update_attributes( user_attributes )
puts "NOTICE: user updated '#{user.login}'" puts "NOTICE: user updated '#{user.login}'"
end end
end end
# return if it was not possible to create user # return if it was not possible to create user
@ -119,6 +119,6 @@ module Auth::Ldap
# take session down # take session down
# - not needed, done by Net::LDAP - # - not needed, done by Net::LDAP -
return user user
end end
end end

View file

@ -23,6 +23,6 @@ module Auth::Otrs
# sync / check permissions # sync / check permissions
Import::OTRS.permission_sync( user, result, config ) Import::OTRS.permission_sync( user, result, config )
return user user
end end
end end

View file

@ -1,11 +1,11 @@
class Class class Class
def to_app_model_url def to_app_model_url
camel_cased_word = self.to_s camel_cased_word = self.to_s
camel_cased_word.gsub(/::/, '_'). camel_cased_word.gsub(/::/, '_')
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
gsub(/([a-z\d])([A-Z])/, '\1_\2'). .gsub(/([a-z\d])([A-Z])/, '\1_\2')
tr('-', '_'). .tr('-', '_')
downcase .downcase
end end
def to_app_model def to_app_model
camel_cased_word = self.to_s camel_cased_word = self.to_s

View file

@ -26,6 +26,6 @@ class GeoLocation::Gmaps
result = JSON.parse( response.body ) result = JSON.parse( response.body )
address = result['results'].first['address_components'].first['long_name'] address = result['results'].first['address_components'].first['long_name']
return address address
end end
end end

View file

@ -15,7 +15,7 @@ module Import::OTRS
puts "ERROR: #{response.error}" puts "ERROR: #{response.error}"
return return
end end
return response response
end end
def self.post(base, data) def self.post(base, data)
url = Setting.get('import_otrs_endpoint') + '/' + base url = Setting.get('import_otrs_endpoint') + '/' + base
@ -34,7 +34,7 @@ module Import::OTRS
puts "ERROR: #{response.error}" puts "ERROR: #{response.error}"
return return
end end
return response response
end end
def self.json(response) def self.json(response)
@ -48,7 +48,7 @@ module Import::OTRS
return if !response.success? return if !response.success?
result = json(response) result = json(response)
return result result
end end
def self.session(session_id) def self.session(session_id)
@ -57,7 +57,7 @@ module Import::OTRS
return if !response.success? return if !response.success?
result = json(response) result = json(response)
return result result
end end
def self.permission_sync(user, result, config) def self.permission_sync(user, result, config)
@ -69,7 +69,7 @@ module Import::OTRS
} }
types.each {|config_key, result_key| types.each {|config_key, result_key|
if config[config_key] if config[config_key]
return false if !result[result_key].has_value?( config[config_key] ) return false if !result[result_key].value?( config[config_key] )
end end
} }
@ -85,7 +85,7 @@ module Import::OTRS
types.each {|config_key, result_key| types.each {|config_key, result_key|
next if !config[config_key] next if !config[config_key]
config[config_key].each {|otrs_group, role| config[config_key].each {|otrs_group, role|
next if !result[result_key].has_value?( otrs_group ) next if !result[result_key].value?( otrs_group )
role_ids = user.role_ids role_ids = user.role_ids
role = Role.where( name: role ).first role = Role.where( name: role ).first
next if !role next if !role
@ -117,7 +117,7 @@ module Import::OTRS
# check if system is in import mode # check if system is in import mode
if !Setting.get('import_mode') if !Setting.get('import_mode')
raise 'System is not in import mode!' raise 'System is not in import mode!'
end end
response = request('public.pl?Action=Export') response = request('public.pl?Action=Export')
@ -167,8 +167,7 @@ module Import::OTRS
threads[thread].join threads[thread].join
} }
return end
end
def self.diff_worker def self.diff_worker
return if !Setting.get('import_mode') return if !Setting.get('import_mode')
@ -181,7 +180,7 @@ module Import::OTRS
# check if system is in import mode # check if system is in import mode
if !Setting.get('import_mode') if !Setting.get('import_mode')
raise 'System is not in import mode!' raise 'System is not in import mode!'
end end
# create states # create states
@ -198,7 +197,6 @@ module Import::OTRS
self.ticket_diff() self.ticket_diff()
return
end end
def self.ticket_diff() def self.ticket_diff()
@ -557,7 +555,7 @@ module Import::OTRS
ID: :id, ID: :id,
ValidID: :active, ValidID: :active,
Comment: :note, Comment: :note,
}; }
Ticket::State.all.each {|state| Ticket::State.all.each {|state|
state.name = state.name + '_tmp' state.name = state.name + '_tmp'
@ -613,7 +611,7 @@ module Import::OTRS
ID: :id, ID: :id,
ValidID: :active, ValidID: :active,
Comment: :note, Comment: :note,
}; }
result.each { |priority| result.each { |priority|
_set_valid(priority) _set_valid(priority)
@ -657,7 +655,7 @@ module Import::OTRS
QueueID: :id, QueueID: :id,
ValidID: :active, ValidID: :active,
Comment: :note, Comment: :note,
}; }
result.each { |group| result.each { |group|
_set_valid(group) _set_valid(group)
@ -702,48 +700,44 @@ module Import::OTRS
UserEmail: :email, UserEmail: :email,
UserFirstname: :firstname, UserFirstname: :firstname,
UserLastname: :lastname, UserLastname: :lastname,
# :UserTitle =>
UserLogin: :login, UserLogin: :login,
UserPw: :password, UserPw: :password,
}; }
result.each { |user| result.each { |user|
# puts 'USER: ' + user.inspect # puts 'USER: ' + user.inspect
_set_valid(user) _set_valid(user)
role = Role.lookup( name: 'Agent' ) role = Role.lookup( name: 'Agent' )
# get new attributes # get new attributes
user_new = { user_new = {
created_by_id: 1, created_by_id: 1,
updated_by_id: 1, updated_by_id: 1,
source: 'OTRS Import', source: 'OTRS Import',
role_ids: [ role.id ], role_ids: [ role.id ],
} }
map.each { |key, value| map.each { |key, value|
if user[key.to_s] if user[key.to_s]
user_new[value] = user[key.to_s] user_new[value] = user[key.to_s]
end end
} }
# check if state already exists # check if state already exists
# user_old = User.where( :login => user_new[:login] ).first user_old = User.where( id: user_new[:id] ).first
user_old = User.where( id: user_new[:id] ).first
# set state types # set state types
if user_old if user_old
puts "update User.find(#{user_new[:id]})" puts "update User.find(#{user_new[:id]})"
# puts 'Update User' + user_new.inspect # puts 'Update User' + user_new.inspect
user_new.delete( :role_ids ) user_new.delete( :role_ids )
user_old.update_attributes(user_new) user_old.update_attributes(user_new)
else else
puts "add User.find(#{user_new[:id]})" puts "add User.find(#{user_new[:id]})"
# puts 'Add User' + user_new.inspect # puts 'Add User' + user_new.inspect
user = User.new(user_new) user = User.new(user_new)
user.id = user_new[:id] user.id = user_new[:id]
user.save user.save
end end
# end
} }
end end
def self.customer def self.customer
@ -767,7 +761,6 @@ module Import::OTRS
UserEmail: :email, UserEmail: :email,
UserFirstname: :firstname, UserFirstname: :firstname,
UserLastname: :lastname, UserLastname: :lastname,
# :UserTitle =>
UserLogin: :login, UserLogin: :login,
UserPassword: :password, UserPassword: :password,
UserPhone: :phone, UserPhone: :phone,
@ -777,7 +770,7 @@ module Import::OTRS
UserZip: :zip, UserZip: :zip,
UserCity: :city, UserCity: :city,
UserCountry: :country, UserCountry: :country,
}; }
done = true done = true
result.each { |user| result.each { |user|
@ -800,7 +793,7 @@ module Import::OTRS
} }
# check if state already exists # check if state already exists
# user_old = User.where( :login => user_new[:login] ).first # user_old = User.where( :login => user_new[:login] ).first
user_old = User.where( login: user_new[:login] ).first user_old = User.where( login: user_new[:login] ).first
# set state types # set state types
@ -819,17 +812,17 @@ module Import::OTRS
end end
def self._set_valid(record) def self._set_valid(record)
# map # map
if record['ValidID'] == '3' if record['ValidID'] == '3'
record['ValidID'] = '2' record['ValidID'] = '2'
end end
if record['ValidID'] == '2' if record['ValidID'] == '2'
record['ValidID'] = false record['ValidID'] = false
end end
if record['ValidID'] == '1' if record['ValidID'] == '1'
record['ValidID'] = true record['ValidID'] = true
end end
if record['ValidID'] == '0' if record['ValidID'] == '0'
record['ValidID'] = false record['ValidID'] = false
end end
end end
end end

View file

@ -149,7 +149,7 @@ module Import::OTRS2
return if !response.success? return if !response.success?
result = json(response) result = json(response)
return result result
end end
=begin =begin
@ -171,7 +171,7 @@ module Import::OTRS2
return if !response return if !response
return if !response.success? return if !response.success?
result = json(response) result = json(response)
return result result
end end
=begin =begin
@ -207,7 +207,7 @@ module Import::OTRS2
=end =end
def self.connection_test def self.connection_test
return self.request_json({}) self.request_json({})
end end
=begin =begin
@ -352,14 +352,14 @@ module Import::OTRS2
steps = 50 steps = 50
run = true run = true
while run while run
count += steps count += steps
records = load('CustomerUser', steps, count - steps) records = load('CustomerUser', steps, count - steps)
if !records || !records[0] if !records || !records[0]
log 'all customers imported.' log 'all customers imported.'
run = false run = false
next next
end end
customer(records, organizations) customer(records, organizations)
end end
Thread.abort_on_exception = true Thread.abort_on_exception = true
@ -452,7 +452,6 @@ module Import::OTRS2
# get changed tickets # get changed tickets
self.ticket_diff self.ticket_diff
return
end end
def self.ticket_diff def self.ticket_diff
@ -820,7 +819,7 @@ module Import::OTRS2
ID: :id, ID: :id,
ValidID: :active, ValidID: :active,
Comment: :note, Comment: :note,
}; }
# rename states to handle not uniq issues # rename states to handle not uniq issues
Ticket::State.all.each {|state| Ticket::State.all.each {|state|
@ -837,7 +836,7 @@ module Import::OTRS2
updated_by_id: 1, updated_by_id: 1,
} }
map.each { |key, value| map.each { |key, value|
if state.has_key?(key.to_s) if state.key?(key.to_s)
state_new[value] = state[key.to_s] state_new[value] = state[key.to_s]
end end
} }
@ -875,7 +874,7 @@ module Import::OTRS2
ID: :id, ID: :id,
ValidID: :active, ValidID: :active,
Comment: :note, Comment: :note,
}; }
records.each { |priority| records.each { |priority|
_set_valid(priority) _set_valid(priority)
@ -886,7 +885,7 @@ module Import::OTRS2
updated_by_id: 1, updated_by_id: 1,
} }
map.each { |key, value| map.each { |key, value|
if priority.has_key?(key.to_s) if priority.key?(key.to_s)
priority_new[value] = priority[key.to_s] priority_new[value] = priority[key.to_s]
end end
} }
@ -916,7 +915,7 @@ module Import::OTRS2
QueueID: :id, QueueID: :id,
ValidID: :active, ValidID: :active,
Comment: :note, Comment: :note,
}; }
records.each { |group| records.each { |group|
_set_valid(group) _set_valid(group)
@ -927,7 +926,7 @@ module Import::OTRS2
updated_by_id: 1, updated_by_id: 1,
} }
map.each { |key, value| map.each { |key, value|
if group.has_key?(key.to_s) if group.key?(key.to_s)
group_new[value] = group[key.to_s] group_new[value] = group[key.to_s]
end end
} }
@ -960,10 +959,9 @@ module Import::OTRS2
UserEmail: :email, UserEmail: :email,
UserFirstname: :firstname, UserFirstname: :firstname,
UserLastname: :lastname, UserLastname: :lastname,
# :UserTitle =>
UserLogin: :login, UserLogin: :login,
UserPw: :password, UserPw: :password,
}; }
records.each { |user| records.each { |user|
_set_valid(user) _set_valid(user)
@ -983,7 +981,7 @@ module Import::OTRS2
group_ids: group_ids, group_ids: group_ids,
} }
map.each { |key, value| map.each { |key, value|
if user.has_key?(key.to_s) if user.key?(key.to_s)
user_new[value] = user[key.to_s] user_new[value] = user[key.to_s]
end end
} }
@ -1081,7 +1079,6 @@ module Import::OTRS2
UserEmail: :email, UserEmail: :email,
UserFirstname: :firstname, UserFirstname: :firstname,
UserLastname: :lastname, UserLastname: :lastname,
# :UserTitle =>
UserLogin: :login, UserLogin: :login,
UserPassword: :password, UserPassword: :password,
UserPhone: :phone, UserPhone: :phone,
@ -1091,7 +1088,7 @@ module Import::OTRS2
UserZip: :zip, UserZip: :zip,
UserCity: :city, UserCity: :city,
UserCountry: :country, UserCountry: :country,
}; }
role_agent = Role.lookup( name: 'Agent' ) role_agent = Role.lookup( name: 'Agent' )
role_customer = Role.lookup( name: 'Customer' ) role_customer = Role.lookup( name: 'Customer' )
@ -1108,7 +1105,7 @@ module Import::OTRS2
role_ids: [ role_customer.id ], role_ids: [ role_customer.id ],
} }
map.each { |key, value| map.each { |key, value|
if user.has_key?(key.to_s) if user.key?(key.to_s)
user_new[value] = user[key.to_s] user_new[value] = user[key.to_s]
end end
} }
@ -1161,7 +1158,7 @@ module Import::OTRS2
CustomerCompanyName: :name, CustomerCompanyName: :name,
ValidID: :active, ValidID: :active,
CustomerCompanyComment: :note, CustomerCompanyComment: :note,
}; }
records.each { |organization| records.each { |organization|
_set_valid(organization) _set_valid(organization)
@ -1172,7 +1169,7 @@ module Import::OTRS2
updated_by_id: 1, updated_by_id: 1,
} }
map.each { |key, value| map.each { |key, value|
if organization.has_key?(key.to_s) if organization.key?(key.to_s)
organization_new[value] = organization[key.to_s] organization_new[value] = organization[key.to_s]
end end
} }
@ -1252,20 +1249,20 @@ module Import::OTRS2
def self._set_valid(record) def self._set_valid(record)
# map # map
if record['ValidID'].to_s == '3' if record['ValidID'].to_s == '3'
record['ValidID'] = false record['ValidID'] = false
elsif record['ValidID'].to_s == '2' elsif record['ValidID'].to_s == '2'
record['ValidID'] = false record['ValidID'] = false
elsif record['ValidID'].to_s == '1' elsif record['ValidID'].to_s == '1'
record['ValidID'] = true record['ValidID'] = true
elsif record['ValidID'].to_s == '0' elsif record['ValidID'].to_s == '0'
record['ValidID'] = false record['ValidID'] = false
# fallback # fallback
else else
record['ValidID'] = true record['ValidID'] = true
end end
end end
# cleanup invalid values # cleanup invalid values

View file

@ -34,6 +34,6 @@ module Rss
return return
end end
return items items
end end
end end

View file

@ -13,7 +13,7 @@ module SessionHelper
(default_collection, assets ) = ExtraCollection.session( default_collection, assets, user ) (default_collection, assets ) = ExtraCollection.session( default_collection, assets, user )
end end
return default_collection, assets [default_collection, assets]
end end
def self.models(user = nil) def self.models(user = nil)

View file

@ -68,7 +68,7 @@ returns
path = @path + '/' path = @path + '/'
# just make sure that spool path exists # just make sure that spool path exists
if !File::exists?( path ) if !File::exist?( path )
FileUtils.mkpath path FileUtils.mkpath path
end end
@ -270,7 +270,7 @@ returns
check = true check = true
count = 0 count = 0
while check while check
if File::exists?( path + filename ) if File::exist?( path + filename )
count += 1 count += 1
filename = filename + '-' + count filename = filename + '-' + count
else else
@ -284,7 +284,7 @@ returns
file.flock( File::LOCK_UN ) file.flock( File::LOCK_UN )
file.close file.close
} }
return false if !File.exists?( path + 'a-' + filename ) return false if !File.exist?( path + 'a-' + filename )
FileUtils.mv( path + 'a-' + filename, path + filename ) FileUtils.mv( path + 'a-' + filename, path + filename )
true true
end end
@ -419,7 +419,7 @@ returns
} }
files.sort.each {|entry| files.sort.each {|entry|
filename = path + '/' + entry filename = path + '/' + entry
next if !File::exists?( filename ) next if !File::exist?( filename )
File.open( filename, 'rb' ) { |file| File.open( filename, 'rb' ) { |file|
all = file.read all = file.read
spool = JSON.parse( all ) spool = JSON.parse( all )
@ -468,13 +468,13 @@ returns
to_delete.each {|file| to_delete.each {|file|
File.delete(file) File.delete(file)
} }
return data data
end end
def self.jobs def self.jobs
# just make sure that spool path exists # just make sure that spool path exists
if !File::exists?( @path ) if !File::exist?( @path )
FileUtils.mkpath @path FileUtils.mkpath @path
end end
@ -576,7 +576,7 @@ returns
end end
def self.symbolize_keys(hash) def self.symbolize_keys(hash)
hash.inject({}){|result, (key, value)| hash.inject({}) {|result, (key, value)|
new_key = case key new_key = case key
when String then key.to_sym when String then key.to_sym
else key else key

View file

@ -22,7 +22,7 @@ class Sessions::Backend::ActivityStream
# update last changed # update last changed
if activity_stream && activity_stream.first if activity_stream && activity_stream.first
@last_change = activity_stream.first['created_at'] @last_change = activity_stream.first['created_at']
end end
@user.activity_stream( 25, true ) @user.activity_stream( 25, true )

View file

@ -65,7 +65,5 @@ returns
return user_auth return user_auth
end end
} }
return
end end
end end

View file

@ -22,11 +22,11 @@ put working hours matrix and timezone in function, returns UTC working hours mat
time_diff = 0 time_diff = 0
if timezone if timezone
begin begin
time_diff = Time.parse(start_time.to_s).in_time_zone(timezone).utc_offset time_diff = Time.parse(start_time.to_s).in_time_zone(timezone).utc_offset
rescue Exception => e rescue Exception => e
puts "ERROR: Can't fine tomezone #{timezone}" puts "ERROR: Can't fine tomezone #{timezone}"
puts e.inspect puts e.inspect
puts e.backtrace puts e.backtrace
end end
end end
beginning_of_workday = Time.parse("1977-10-27 #{config['beginning_of_workday']}") beginning_of_workday = Time.parse("1977-10-27 #{config['beginning_of_workday']}")
@ -93,7 +93,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat
} }
} }
end end
return working_hours working_hours
end end
=begin =begin
@ -169,7 +169,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat
diff = end_time - start_time diff = end_time - start_time
if diff > 59 * 60 if diff > 59 * 60
diff = start_time - start_time.beginning_of_hour diff = start_time - start_time.beginning_of_hour
end end
start_time += diff start_time += diff
@ -350,7 +350,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat
start_time = start_time.beginning_of_day + 86_400 start_time = start_time.beginning_of_day + 86_400
end end
return start_time start_time
end end
end end

View file

@ -386,6 +386,13 @@ returns
end end
class Result class Result
attr_reader :error
attr_reader :body
attr_reader :data
attr_reader :code
attr_reader :content_type
def initialize(options) def initialize(options)
@success = options[:success] @success = options[:success]
@body = options[:body] @body = options[:body]
@ -394,23 +401,9 @@ returns
@content_type = options[:content_type] @content_type = options[:content_type]
@error = options[:error] @error = options[:error]
end end
def error
@error
end
def success? def success?
@success @success
end end
def body
@body
end
def data
@data
end
def code
@code
end
def content_type
@content_type
end
end end
end end

View file

@ -55,7 +55,7 @@ end.parse!
if ARGV[0] != 'start' && ARGV[0] != 'stop' if ARGV[0] != 'start' && ARGV[0] != 'stop'
puts "Usage: #{File.basename(__FILE__)} start|stop [options]" puts "Usage: #{File.basename(__FILE__)} start|stop [options]"
exit; exit
end end
puts "Starting websocket server on #{ @options[:b] }:#{ @options[:p] } (secure:#{ @options[:s].to_s },pid:#{@options[:i].to_s})" puts "Starting websocket server on #{ @options[:b] }:#{ @options[:p] } (secure:#{ @options[:s].to_s },pid:#{@options[:i].to_s})"
@ -191,7 +191,7 @@ EventMachine.run {
if data['recipient'].class != Hash if data['recipient'].class != Hash
log 'error', "recipient attribute isn't a hash '#{ data['recipient'].inspect }'" log 'error', "recipient attribute isn't a hash '#{ data['recipient'].inspect }'"
else else
if !data['recipient'].has_key?('user_id') if !data['recipient'].key?('user_id')
log 'error', "need recipient.user_id attribute '#{ data['recipient'].inspect }'" log 'error', "need recipient.user_id attribute '#{ data['recipient'].inspect }'"
else else
if data['recipient']['user_id'].class != Array if data['recipient']['user_id'].class != Array