Merge branch 'develop' of github.com:martini/zammad into develop
This commit is contained in:
commit
607911179b
50 changed files with 284 additions and 305 deletions
2
Gemfile
2
Gemfile
|
@ -62,7 +62,7 @@ gem 'em-websocket'
|
|||
# in production environments by default.
|
||||
group :development, :test do
|
||||
|
||||
gem 'test-unit'
|
||||
gem 'test-unit'
|
||||
gem 'spring'
|
||||
gem 'sqlite3'
|
||||
|
||||
|
|
|
@ -105,13 +105,13 @@ curl http://localhost/api/v1/online_notifications/mark_all_as_read -v -u #{login
|
|||
=end
|
||||
|
||||
def mark_all_as_read
|
||||
notifications = OnlineNotification.list(current_user, 100)
|
||||
notifications.each do |notification|
|
||||
if !notification['seen']
|
||||
OnlineNotification.seen( id: notification['id'] )
|
||||
end
|
||||
notifications = OnlineNotification.list(current_user, 100)
|
||||
notifications.each do |notification|
|
||||
if !notification['seen']
|
||||
OnlineNotification.seen( id: notification['id'] )
|
||||
end
|
||||
render json: {}, status: :ok
|
||||
end
|
||||
render json: {}, status: :ok
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -98,13 +98,13 @@ return all activity entries of an user
|
|||
|
||||
return [] if role_ids.include?(customer_role.id)
|
||||
if group_ids.empty?
|
||||
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL)', role_ids ).
|
||||
order( 'created_at DESC, id DESC' ).
|
||||
limit( limit )
|
||||
stream = ActivityStream.where('(role_id IN (?) AND group_id is NULL)', role_ids )
|
||||
.order( 'created_at DESC, id DESC' )
|
||||
.limit( limit )
|
||||
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 ).
|
||||
order( 'created_at DESC, id DESC' ).
|
||||
limit( limit )
|
||||
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' )
|
||||
.limit( limit )
|
||||
end
|
||||
list = []
|
||||
stream.each do |item|
|
||||
|
|
|
@ -81,7 +81,7 @@ returns
|
|||
# only use object attributes
|
||||
data = {}
|
||||
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
|
||||
data[item[0].to_sym] = params[item[0]]
|
||||
end
|
||||
|
@ -109,7 +109,7 @@ returns
|
|||
# set relations
|
||||
self.class.reflect_on_all_associations.map { |assoc|
|
||||
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 ]
|
||||
if params[ real_key.to_sym ].class != Array
|
||||
list_of_items = [ params[ real_key.to_sym ] ]
|
||||
|
@ -246,14 +246,14 @@ returns
|
|||
|
||||
# delete old name / login caches
|
||||
if self.changed?
|
||||
if self.changes.has_key?('name')
|
||||
if self.changes.key?('name')
|
||||
name = self.changes['name'][0].to_s
|
||||
key = self.class.to_s + '::' + name
|
||||
Cache.delete( key.to_s )
|
||||
key = self.class.to_s + ':f:' + name
|
||||
Cache.delete( key.to_s )
|
||||
end
|
||||
if self.changes.has_key?('login')
|
||||
if self.changes.key?('login')
|
||||
name = self.changes['login'][0].to_s
|
||||
key = self.class.to_s + '::' + name
|
||||
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
|
||||
if self.history_changes_last_done
|
||||
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)
|
||||
end
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ module Channel::EmailBuild
|
|||
|
||||
# set organization
|
||||
organization = Setting.get('organization')
|
||||
if organization then;
|
||||
if organization
|
||||
mail['Organization'] = organization.to_s
|
||||
end
|
||||
|
||||
|
|
|
@ -491,7 +491,7 @@ class Channel::EmailParser
|
|||
}
|
||||
|
||||
# return new objects
|
||||
return ticket, article, user
|
||||
[ticket, article, user]
|
||||
end
|
||||
|
||||
def user_create(data)
|
||||
|
@ -526,7 +526,7 @@ class Channel::EmailParser
|
|||
def set_attributes_by_x_headers( item_object, header_name, mail )
|
||||
|
||||
# loop all x-zammad-hedaer-* headers
|
||||
item_object.attributes.each{|key, value|
|
||||
item_object.attributes.each {|key, value|
|
||||
|
||||
# ignore read only attributes
|
||||
next if key == 'updated_at'
|
||||
|
|
|
@ -7,7 +7,7 @@ class Channel::IMAP < Channel::EmailParser
|
|||
def fetch (channel, check_type = '', verify_string = '')
|
||||
ssl = true
|
||||
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
|
||||
port = 143
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ class Channel::POP3 < Channel::EmailParser
|
|||
def fetch (channel, check_type = '', verify_string = '')
|
||||
ssl = true
|
||||
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
|
||||
port = 110
|
||||
end
|
||||
|
|
|
@ -134,7 +134,7 @@ class Channel::TWITTER2
|
|||
ticket = fetch_ticket_create(user, tweet, sender, channel, group)
|
||||
end
|
||||
article = fetch_article_create(user, ticket, tweet, sender)
|
||||
return user, ticket, article
|
||||
[user, ticket, article]
|
||||
end
|
||||
|
||||
def fetch_user_create(tweet, sender)
|
||||
|
@ -177,7 +177,7 @@ class Channel::TWITTER2
|
|||
# set current user
|
||||
UserInfo.current_user_id = user.id
|
||||
|
||||
return user
|
||||
user
|
||||
end
|
||||
|
||||
def fetch_ticket_create(user, tweet, sender, channel, group)
|
||||
|
@ -298,6 +298,6 @@ class Channel::TWITTER2
|
|||
}
|
||||
)
|
||||
# puts message.inspect
|
||||
return message
|
||||
message
|
||||
end
|
||||
end
|
||||
|
|
|
@ -150,9 +150,9 @@ returns
|
|||
def self.list( requested_object, requested_object_id, related_history_object = nil, assets = nil )
|
||||
if !related_history_object
|
||||
history_object = self.object_lookup( requested_object )
|
||||
history = History.where( history_object_id: history_object.id ).
|
||||
where( o_id: requested_object_id ).
|
||||
order('created_at ASC, id ASC')
|
||||
history = History.where( history_object_id: history_object.id )
|
||||
.where( o_id: requested_object_id )
|
||||
.order('created_at ASC, id ASC')
|
||||
else
|
||||
history_object_requested = self.object_lookup( requested_object )
|
||||
history_object_related = self.object_lookup( related_history_object )
|
||||
|
@ -162,8 +162,8 @@ returns
|
|||
requested_object_id,
|
||||
history_object_related.id,
|
||||
requested_object_id,
|
||||
).
|
||||
order('created_at ASC, id ASC')
|
||||
)
|
||||
.order('created_at ASC, id ASC')
|
||||
end
|
||||
asset_list = {}
|
||||
list = []
|
||||
|
@ -193,7 +193,7 @@ returns
|
|||
data.delete( 'value_to' )
|
||||
data.delete( 'value_from' )
|
||||
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
|
||||
end
|
||||
data.delete( 'related_history_object_id' )
|
||||
|
@ -223,7 +223,7 @@ returns
|
|||
# lookup
|
||||
history_type = History::Type.lookup( id: id )
|
||||
@@cache_type[ id ] = history_type
|
||||
return history_type
|
||||
history_type
|
||||
end
|
||||
|
||||
def self.type_lookup( name )
|
||||
|
@ -243,7 +243,7 @@ returns
|
|||
name: name
|
||||
)
|
||||
@@cache_type[ name ] = history_type
|
||||
return history_type
|
||||
history_type
|
||||
end
|
||||
|
||||
def self.object_lookup_id( id )
|
||||
|
@ -254,7 +254,7 @@ returns
|
|||
# lookup
|
||||
history_object = History::Object.lookup( id: id )
|
||||
@@cache_object[ id ] = history_object
|
||||
return history_object
|
||||
history_object
|
||||
end
|
||||
|
||||
def self.object_lookup( name )
|
||||
|
@ -274,7 +274,7 @@ returns
|
|||
name: name
|
||||
)
|
||||
@@cache_object[ name ] = history_object
|
||||
return history_object
|
||||
history_object
|
||||
end
|
||||
|
||||
def self.attribute_lookup_id( id )
|
||||
|
@ -285,7 +285,7 @@ returns
|
|||
# lookup
|
||||
history_attribute = History::Attribute.lookup( id: id )
|
||||
@@cache_attribute[ id ] = history_attribute
|
||||
return history_attribute
|
||||
history_attribute
|
||||
end
|
||||
|
||||
def self.attribute_lookup( name )
|
||||
|
@ -305,7 +305,7 @@ returns
|
|||
name: name
|
||||
)
|
||||
@@cache_attribute[ name ] = history_attribute
|
||||
return history_attribute
|
||||
history_attribute
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -42,9 +42,9 @@ class Job < ApplicationModel
|
|||
next if !job.timeplan['minutes'].include?( match_minutes(time.min.to_s) )
|
||||
|
||||
# find tickets to change
|
||||
tickets = Ticket.where( job.condition.permit! ).
|
||||
order( '`tickets`.`created_at` DESC' ).
|
||||
limit( 1_000 )
|
||||
tickets = Ticket.where( job.condition.permit! )
|
||||
.order( '`tickets`.`created_at` DESC' )
|
||||
.limit( 1_000 )
|
||||
job.processed = tickets.count
|
||||
tickets.each do |ticket|
|
||||
#puts "CHANGE #{job.execute.inspect}"
|
||||
|
|
|
@ -49,7 +49,7 @@ class Link < ApplicationModel
|
|||
items.push link
|
||||
}
|
||||
|
||||
return items
|
||||
items
|
||||
end
|
||||
|
||||
=begin
|
||||
|
@ -74,19 +74,19 @@ class Link < ApplicationModel
|
|||
|
||||
def self.add(data)
|
||||
|
||||
if data.has_key?(:link_type)
|
||||
if data.key?(:link_type)
|
||||
linktype = self.link_type_get( name: data[:link_type] )
|
||||
data[:link_type_id] = linktype.id
|
||||
data.delete( :link_type )
|
||||
end
|
||||
|
||||
if data.has_key?(:link_object_source)
|
||||
if data.key?(:link_object_source)
|
||||
linkobject = self.link_object_get( name: data[:link_object_source] )
|
||||
data[:link_object_source_id] = linkobject.id
|
||||
data.delete( :link_object_source )
|
||||
end
|
||||
|
||||
if data.has_key?(:link_object_target)
|
||||
if data.key?(:link_object_target)
|
||||
linkobject = self.link_object_get( name: data[:link_object_target] )
|
||||
data[:link_object_target_id] = linkobject.id
|
||||
data.delete( :link_object_target )
|
||||
|
@ -108,18 +108,18 @@ class Link < ApplicationModel
|
|||
=end
|
||||
|
||||
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] )
|
||||
data[:link_object_source_id] = linkobject.id
|
||||
end
|
||||
|
||||
if data.has_key?(:link_object_target)
|
||||
if data.key?(:link_object_target)
|
||||
linkobject = self.link_object_get( name: data[:link_object_target] )
|
||||
data[:link_object_target_id] = linkobject.id
|
||||
end
|
||||
|
||||
# from one site
|
||||
if data.has_key?(:link_type)
|
||||
if data.key?(:link_type)
|
||||
linktype = self.link_type_get( name: data[:link_type] )
|
||||
data[:link_type_id] = linktype.id
|
||||
end
|
||||
|
@ -135,7 +135,7 @@ class Link < ApplicationModel
|
|||
}
|
||||
|
||||
# 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] ] )
|
||||
data[:link_type_id] = linktype.id
|
||||
end
|
||||
|
@ -159,7 +159,7 @@ class Link < ApplicationModel
|
|||
name: data[:name]
|
||||
)
|
||||
end
|
||||
return linktype
|
||||
linktype
|
||||
end
|
||||
|
||||
def self.link_object_get(data)
|
||||
|
@ -169,7 +169,7 @@ class Link < ApplicationModel
|
|||
name: data[:name]
|
||||
)
|
||||
end
|
||||
return linkobject
|
||||
linkobject
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -187,7 +187,7 @@ returns:
|
|||
}
|
||||
if item.screens
|
||||
data[:screen] = {}
|
||||
item.screens.each {|screen, roles_options |
|
||||
item.screens.each {|screen, roles_options|
|
||||
data[:screen][screen] = {}
|
||||
roles_options.each {|role, options|
|
||||
if role == '-all-'
|
||||
|
|
|
@ -8,7 +8,7 @@ class Observer::Tag::TicketHistory < ActiveRecord::Observer
|
|||
def after_create(record)
|
||||
|
||||
# just process ticket object tags
|
||||
return true if record.tag_object.name != 'Ticket';
|
||||
return true if record.tag_object.name != 'Ticket'
|
||||
|
||||
# add ticket history
|
||||
History.add(
|
||||
|
@ -22,7 +22,7 @@ class Observer::Tag::TicketHistory < ActiveRecord::Observer
|
|||
def after_destroy(record)
|
||||
|
||||
# just process ticket object tags
|
||||
return true if record.tag_object.name != 'Ticket';
|
||||
return true if record.tag_object.name != 'Ticket'
|
||||
|
||||
# add ticket history
|
||||
History.add(
|
||||
|
|
|
@ -56,7 +56,7 @@ mark online notification as seen
|
|||
=end
|
||||
|
||||
def self.seen(data)
|
||||
notification = OnlineNotification.find(data[:id])
|
||||
notification = OnlineNotification.find(data[:id])
|
||||
notification.seen = true
|
||||
notification.save
|
||||
end
|
||||
|
@ -87,9 +87,9 @@ return all online notifications of an user
|
|||
|
||||
def self.list(user, limit)
|
||||
|
||||
notifications = OnlineNotification.where(user_id: user.id).
|
||||
order( 'created_at DESC, id DESC' ).
|
||||
limit( limit )
|
||||
notifications = OnlineNotification.where(user_id: user.id)
|
||||
.order( 'created_at DESC, id DESC' )
|
||||
.limit( limit )
|
||||
list = []
|
||||
notifications.each do |item|
|
||||
data = item.attributes
|
||||
|
@ -115,9 +115,9 @@ return all online notifications of an object
|
|||
notifications = OnlineNotification.where(
|
||||
object_lookup_id: object_id,
|
||||
o_id: o_id,
|
||||
).
|
||||
order( 'created_at DESC, id DESC' ).
|
||||
limit( 10_000 )
|
||||
)
|
||||
.order( 'created_at DESC, id DESC' )
|
||||
.limit( 10_000 )
|
||||
list = []
|
||||
notifications.each do |item|
|
||||
data = item.attributes
|
||||
|
@ -139,17 +139,17 @@ mark online notification as seen by object
|
|||
=end
|
||||
|
||||
def self.seen_by_object(object_name, o_id)
|
||||
object_id = ObjectLookup.by_name( object_name )
|
||||
notifications = OnlineNotification.where(
|
||||
object_lookup_id: object_id,
|
||||
o_id: o_id,
|
||||
seen: false,
|
||||
)
|
||||
notifications.each do |notification|
|
||||
notification.seen = true
|
||||
notification.save
|
||||
end
|
||||
true
|
||||
object_id = ObjectLookup.by_name( object_name )
|
||||
notifications = OnlineNotification.where(
|
||||
object_lookup_id: object_id,
|
||||
o_id: o_id,
|
||||
seen: false,
|
||||
)
|
||||
notifications.each do |notification|
|
||||
notification.seen = true
|
||||
notification.save
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
=begin
|
||||
|
@ -171,7 +171,7 @@ returns:
|
|||
|
||||
notifications = OnlineNotification.list(user, limit)
|
||||
assets = ApplicationModel.assets_of_object_list(notifications)
|
||||
return {
|
||||
{
|
||||
stream: notifications,
|
||||
assets: assets
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ class Package < ApplicationModel
|
|||
File.delete( entry )
|
||||
end
|
||||
backup_file = entry + '.link_backup'
|
||||
if File.exists?( backup_file )
|
||||
if File.exist?( backup_file )
|
||||
logger.info "Restore backup file of #{backup_file} -> #{entry}."
|
||||
File.rename( backup_file, entry )
|
||||
end
|
||||
|
@ -114,7 +114,7 @@ class Package < ApplicationModel
|
|||
end
|
||||
|
||||
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}."
|
||||
File.rename( backup_file, dest.to_s )
|
||||
end
|
||||
|
@ -145,7 +145,7 @@ class Package < ApplicationModel
|
|||
dest = @@root + '/' + file
|
||||
|
||||
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}"
|
||||
FileUtils.mkdir_p( dest.to_s )
|
||||
end
|
||||
|
@ -153,7 +153,7 @@ class Package < ApplicationModel
|
|||
|
||||
if File.file?( entry.to_s ) && ( File.file?( dest.to_s ) && !File.symlink?( dest.to_s ) )
|
||||
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!"
|
||||
else
|
||||
logger.info "Create backup file of #{dest.to_s} -> #{backup_file}."
|
||||
|
@ -441,7 +441,7 @@ class Package < ApplicationModel
|
|||
def self.migrate( package, direction = 'normal' )
|
||||
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 )
|
||||
|
||||
# get existing migrations
|
||||
|
|
|
@ -26,9 +26,9 @@ class RecentView < ApplicationModel
|
|||
|
||||
def self.log_destroy( requested_object, requested_object_id )
|
||||
return if requested_object == 'RecentView'
|
||||
RecentView.where( recent_view_object_id: ObjectLookup.by_name( requested_object ) ).
|
||||
where( o_id: requested_object_id ).
|
||||
destroy_all
|
||||
RecentView.where( recent_view_object_id: ObjectLookup.by_name( requested_object ) )
|
||||
.where( o_id: requested_object_id )
|
||||
.destroy_all
|
||||
end
|
||||
|
||||
def self.user_log_destroy( user )
|
||||
|
@ -37,13 +37,13 @@ class RecentView < ApplicationModel
|
|||
|
||||
def self.list( user, limit = 10, type = nil )
|
||||
if !type
|
||||
recent_views = RecentView.where( created_by_id: user.id ).
|
||||
order('created_at DESC, id DESC').
|
||||
limit(limit)
|
||||
recent_views = RecentView.where( created_by_id: user.id )
|
||||
.order('created_at DESC, id DESC')
|
||||
.limit(limit)
|
||||
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) ) .
|
||||
order('created_at DESC, id DESC').
|
||||
limit(limit)
|
||||
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')
|
||||
.limit(limit)
|
||||
end
|
||||
|
||||
list = []
|
||||
|
@ -67,7 +67,7 @@ class RecentView < ApplicationModel
|
|||
# get related object
|
||||
assets = ApplicationModel.assets_of_object_list(recent_viewed)
|
||||
|
||||
return {
|
||||
{
|
||||
stream: recent_viewed,
|
||||
assets: assets,
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class Setting < ApplicationModel
|
|||
|
||||
# store for class requests
|
||||
@@current[:settings_config] = config
|
||||
return config
|
||||
config
|
||||
end
|
||||
|
||||
def self.set(name, value)
|
||||
|
@ -47,7 +47,7 @@ class Setting < ApplicationModel
|
|||
|
||||
def self.get(name)
|
||||
self.load
|
||||
return @@current[:settings_config][name]
|
||||
@@current[:settings_config][name]
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -61,7 +61,7 @@ class Setting < ApplicationModel
|
|||
|
||||
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 }
|
||||
end
|
||||
|
|
|
@ -80,9 +80,9 @@ returns
|
|||
def self.list(data)
|
||||
# search
|
||||
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 ).
|
||||
order('created_at ASC, id ASC')
|
||||
return stores
|
||||
stores = Store.where( store_object_id: store_object_id, o_id: data[:o_id].to_i )
|
||||
.order('created_at ASC, id ASC')
|
||||
stores
|
||||
end
|
||||
|
||||
=begin
|
||||
|
@ -103,15 +103,15 @@ returns
|
|||
def self.remove(data)
|
||||
# search
|
||||
store_object_id = Store::Object.lookup( name: data[:object] )
|
||||
stores = Store.where( store_object_id: store_object_id ).
|
||||
where( o_id: data[:o_id] ).
|
||||
order('created_at ASC, id ASC')
|
||||
stores = Store.where( store_object_id: store_object_id )
|
||||
.where( o_id: data[:o_id] )
|
||||
.order('created_at ASC, id ASC')
|
||||
stores.each do |store|
|
||||
|
||||
# check backend for references
|
||||
Store.remove_item( store.id )
|
||||
end
|
||||
return true
|
||||
true
|
||||
end
|
||||
|
||||
=begin
|
||||
|
@ -136,7 +136,7 @@ returns
|
|||
end
|
||||
|
||||
store.destroy
|
||||
return true
|
||||
true
|
||||
end
|
||||
|
||||
def content
|
||||
|
|
|
@ -24,7 +24,7 @@ class Tag < ApplicationModel
|
|||
o_id: data[:o_id],
|
||||
created_by_id: data[:created_by_id],
|
||||
)
|
||||
return true
|
||||
true
|
||||
end
|
||||
|
||||
def self.tag_remove(data)
|
||||
|
@ -46,7 +46,7 @@ class Tag < ApplicationModel
|
|||
result.each { |item|
|
||||
item.destroy
|
||||
}
|
||||
return true
|
||||
true
|
||||
end
|
||||
|
||||
def self.tag_list( data )
|
||||
|
@ -59,7 +59,7 @@ class Tag < ApplicationModel
|
|||
tag_search.each {|tag|
|
||||
tags.push self.tag_item_lookup_id( tag.tag_item_id )
|
||||
}
|
||||
return tags
|
||||
tags
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -72,7 +72,7 @@ class Tag < ApplicationModel
|
|||
# lookup
|
||||
tag_item = Tag::Item.find(id)
|
||||
@@cache_item[ id ] = tag_item.name
|
||||
return tag_item.name
|
||||
tag_item.name
|
||||
end
|
||||
|
||||
def self.tag_item_lookup( name )
|
||||
|
@ -94,7 +94,7 @@ class Tag < ApplicationModel
|
|||
name: name
|
||||
)
|
||||
@@cache_item[ name ] = tag_item.id
|
||||
return tag_item.id
|
||||
tag_item.id
|
||||
end
|
||||
|
||||
def self.tag_object_lookup_id( id )
|
||||
|
@ -105,7 +105,7 @@ class Tag < ApplicationModel
|
|||
# lookup
|
||||
tag_object = Tag::Object.find(id)
|
||||
@@cache_object[ id ] = tag_object.name
|
||||
return tag_object.name
|
||||
tag_object.name
|
||||
end
|
||||
|
||||
def self.tag_object_lookup( name )
|
||||
|
@ -125,7 +125,7 @@ class Tag < ApplicationModel
|
|||
name: name
|
||||
)
|
||||
@@cache_object[ name ] = tag_object.id
|
||||
return tag_object.id
|
||||
tag_object.id
|
||||
end
|
||||
|
||||
class Object < ActiveRecord::Base
|
||||
|
|
|
@ -94,10 +94,10 @@ returns
|
|||
def self.access_condition(user)
|
||||
access_condition = []
|
||||
if user.is_role(Z_ROLENAME_AGENT)
|
||||
group_ids = Group.select( 'groups.id' ).joins(:users).
|
||||
where( 'groups_users.user_id = ?', user.id ).
|
||||
where( 'groups.active = ?', true ).
|
||||
map( &:id )
|
||||
group_ids = Group.select( 'groups.id' ).joins(:users)
|
||||
.where( 'groups_users.user_id = ?', user.id )
|
||||
.where( 'groups.active = ?', true )
|
||||
.map( &:id )
|
||||
access_condition = [ 'group_id IN (?)', group_ids ]
|
||||
else
|
||||
if !user.organization || ( !user.organization.shared || user.organization.shared == false )
|
||||
|
|
|
@ -262,7 +262,7 @@ returns
|
|||
if counted
|
||||
# puts "Diff count #{history_item['value_from']} -> #{history_item['value_to']} / #{last_state_change} -> #{history_item['created_at']}"
|
||||
total_time_without_pending = total_time_without_pending + diff
|
||||
else
|
||||
# else
|
||||
# puts "Diff not count #{history_item['value_from']} -> #{history_item['value_to']} / #{last_state_change} -> #{history_item['created_at']}"
|
||||
end
|
||||
total_time = total_time + diff
|
||||
|
|
|
@ -72,7 +72,7 @@ returns
|
|||
end
|
||||
|
||||
# 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'
|
||||
parts = value.split( '.', 2 )
|
||||
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])
|
||||
# get only tickets with permissions
|
||||
if data[:current_user].is_role('Customer')
|
||||
group_ids = Group.select( 'groups.id' ).
|
||||
where( 'groups.active = ?', true ).
|
||||
map( &:id )
|
||||
group_ids = Group.select( 'groups.id' )
|
||||
.where( 'groups.active = ?', true )
|
||||
.map( &:id )
|
||||
else
|
||||
group_ids = Group.select( 'groups.id' ).joins(:users).
|
||||
where( 'groups_users.user_id = ?', [ data[:current_user].id ] ).
|
||||
where( 'groups.active = ?', true ).
|
||||
map( &:id )
|
||||
group_ids = Group.select( 'groups.id' ).joins(:users)
|
||||
.where( 'groups_users.user_id = ?', [ data[:current_user].id ] )
|
||||
.where( 'groups.active = ?', true )
|
||||
.map( &:id )
|
||||
end
|
||||
|
||||
# overview meta for navbar
|
||||
|
@ -147,20 +147,20 @@ returns
|
|||
if overview_selected.group_by && !overview_selected.group_by.empty?
|
||||
order_by = overview_selected.group_by + '_id, ' + order_by
|
||||
end
|
||||
tickets = Ticket.select( 'id' ).
|
||||
where( group_id: group_ids ).
|
||||
where( _condition( overview_selected.condition ) ).
|
||||
order( order_by ).
|
||||
limit( 500 )
|
||||
tickets = Ticket.select( 'id' )
|
||||
.where( group_id: group_ids )
|
||||
.where( _condition( overview_selected.condition ) )
|
||||
.order( order_by )
|
||||
.limit( 500 )
|
||||
|
||||
ticket_ids = []
|
||||
tickets.each { |ticket|
|
||||
ticket_ids.push ticket.id
|
||||
}
|
||||
|
||||
tickets_count = Ticket.where( group_id: group_ids ).
|
||||
where( _condition( overview_selected.condition ) ).
|
||||
count()
|
||||
tickets_count = Ticket.where( group_id: group_ids )
|
||||
.where( _condition( overview_selected.condition ) )
|
||||
.count()
|
||||
|
||||
return {
|
||||
ticket_ids: ticket_ids,
|
||||
|
@ -171,15 +171,15 @@ returns
|
|||
|
||||
# get tickets for overview
|
||||
data[:start_page] ||= 1
|
||||
tickets = Ticket.where( group_id: group_ids ).
|
||||
where( _condition( overview_selected.condition ) ).
|
||||
order( overview_selected[:order][:by].to_s + ' ' + overview_selected[:order][:direction].to_s )#.
|
||||
tickets = Ticket.where( group_id: group_ids )
|
||||
.where( _condition( overview_selected.condition ) )
|
||||
.order( overview_selected[:order][:by].to_s + ' ' + overview_selected[:order][:direction].to_s )#.
|
||||
# limit( overview_selected.view[ data[:view_mode].to_sym ][:per_page] ).
|
||||
# offset( overview_selected.view[ data[:view_mode].to_sym ][:per_page].to_i * ( data[:start_page].to_i - 1 ) )
|
||||
|
||||
tickets_count = Ticket.where( group_id: group_ids ).
|
||||
where( _condition( overview_selected.condition ) ).
|
||||
count()
|
||||
tickets_count = Ticket.where( group_id: group_ids )
|
||||
.where( _condition( overview_selected.condition ) )
|
||||
.count()
|
||||
|
||||
{
|
||||
tickets: tickets,
|
||||
|
|
|
@ -34,7 +34,7 @@ returns
|
|||
end
|
||||
|
||||
# left position
|
||||
return "[#{ticket_hook}#{ticket_hook_divider}#{self.number}] " + subject
|
||||
"[#{ticket_hook}#{ticket_hook_divider}#{self.number}] " + subject
|
||||
end
|
||||
|
||||
=begin
|
||||
|
|
|
@ -22,7 +22,7 @@ class Token < ActiveRecord::Base
|
|||
end
|
||||
|
||||
# return token if valid
|
||||
return token.user
|
||||
token.user
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -136,7 +136,7 @@ get list of translations
|
|||
end
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
list: list,
|
||||
}
|
||||
end
|
||||
|
@ -163,7 +163,7 @@ translate strings in ruby context, e. g. for notifications
|
|||
return record.target if record.source == string
|
||||
}
|
||||
|
||||
return string
|
||||
string
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -159,7 +159,7 @@ returns
|
|||
# get related objects
|
||||
assets = ApplicationModel.assets_of_object_list(activity_stream)
|
||||
|
||||
return {
|
||||
{
|
||||
activity_stream: activity_stream,
|
||||
assets: assets,
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ returns
|
|||
|
||||
def self.create_from_hash!(hash)
|
||||
url = ''
|
||||
if hash['info']['urls'] then
|
||||
if hash['info']['urls']
|
||||
url = hash['info']['urls']['Website'] || hash['info']['urls']['Twitter'] || ''
|
||||
end
|
||||
roles = Role.where( name: 'Customer' )
|
||||
|
@ -415,10 +415,10 @@ returns
|
|||
scan = self.firstname.scan(/, /)
|
||||
if scan[0]
|
||||
name = self.firstname.split(', ', 2)
|
||||
if name[0] != nil
|
||||
if !name[0].nil?
|
||||
self.lastname = name[0]
|
||||
end
|
||||
if name[1] != nil
|
||||
if !name[1].nil?
|
||||
self.firstname = name[1]
|
||||
end
|
||||
return
|
||||
|
@ -426,10 +426,10 @@ returns
|
|||
|
||||
# Firstname Lastname
|
||||
name = self.firstname.split(' ', 2)
|
||||
if name[0] != nil
|
||||
if !name[0].nil?
|
||||
self.firstname = name[0]
|
||||
end
|
||||
if name[1] != nil
|
||||
if !name[1].nil?
|
||||
self.lastname = name[1]
|
||||
end
|
||||
return
|
||||
|
@ -438,10 +438,10 @@ returns
|
|||
elsif ( !self.firstname || self.firstname.empty? ) && ( !self.lastname || self.lastname.empty? ) && ( self.email && !self.email.empty? )
|
||||
scan = self.email.scan(/^(.+?)\.(.+?)\@.+?$/)
|
||||
if scan[0]
|
||||
if scan[0][0] != nil
|
||||
if !scan[0][0].nil?
|
||||
self.firstname = scan[0][0].capitalize
|
||||
end
|
||||
if scan[0][1] != nil
|
||||
if !scan[0][1].nil?
|
||||
self.lastname = scan[0][1].capitalize
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ returns
|
|||
# get linked accounts
|
||||
attributes['accounts'] = {}
|
||||
authorizations = self.authorizations()
|
||||
authorizations.each do | authorization |
|
||||
authorizations.each do |authorization|
|
||||
attributes['accounts'][authorization.provider] = {
|
||||
uid: authorization[:uid],
|
||||
username: authorization[:username]
|
||||
|
|
|
@ -3,4 +3,4 @@ require 'rubygems'
|
|||
# Set up gems listed in the Gemfile.
|
||||
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'])
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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',
|
||||
client_options: { authorize_path: '/oauth/authorize', site: 'https://api.twitter.com' }
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class CreateChannel < ActiveRecord::Migration
|
||||
def up
|
||||
|
||||
|
||||
create_table :channels do |t|
|
||||
t.references :group, null: true
|
||||
t.column :adapter, :string, limit: 100, null: false
|
||||
|
|
|
@ -8,14 +8,14 @@ class UpdateTicketNumber < ActiveRecord::Migration
|
|||
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.
|
||||
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).',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'ticket_number',
|
||||
name: 'ticket_number',
|
||||
tag: 'select',
|
||||
options: {
|
||||
'Ticket::Number::Increment' => 'Increment (SystemID.Counter)',
|
||||
|
|
|
@ -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).
|
||||
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).
|
||||
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).',
|
||||
options: {
|
||||
form: [
|
||||
|
|
|
@ -54,7 +54,5 @@ returns
|
|||
return user_auth
|
||||
end
|
||||
}
|
||||
return
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,6 +8,6 @@ module Auth::Developer
|
|||
return user if password == 'test'
|
||||
end
|
||||
|
||||
return false
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,6 @@ module Auth::Internal
|
|||
# plain auth check
|
||||
return user if user.password == password
|
||||
|
||||
return false
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -64,7 +64,7 @@ module Auth::Ldap
|
|||
source: 'ldap',
|
||||
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 ]
|
||||
user_attributes[ local_data.downcase.to_sym] = user_data[ ldap_data.downcase.to_sym ]
|
||||
end
|
||||
|
@ -76,7 +76,7 @@ module Auth::Ldap
|
|||
else
|
||||
user.update_attributes( user_attributes )
|
||||
puts "NOTICE: user updated '#{user.login}'"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# return if it was not possible to create user
|
||||
|
@ -119,6 +119,6 @@ module Auth::Ldap
|
|||
# take session down
|
||||
# - not needed, done by Net::LDAP -
|
||||
|
||||
return user
|
||||
user
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,6 +23,6 @@ module Auth::Otrs
|
|||
# sync / check permissions
|
||||
Import::OTRS.permission_sync( user, result, config )
|
||||
|
||||
return user
|
||||
user
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
class Class
|
||||
def to_app_model_url
|
||||
camel_cased_word = self.to_s
|
||||
camel_cased_word.gsub(/::/, '_').
|
||||
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
||||
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
||||
tr('-', '_').
|
||||
downcase
|
||||
camel_cased_word.gsub(/::/, '_')
|
||||
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
||||
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
||||
.tr('-', '_')
|
||||
.downcase
|
||||
end
|
||||
def to_app_model
|
||||
camel_cased_word = self.to_s
|
||||
|
|
|
@ -26,6 +26,6 @@ class GeoLocation::Gmaps
|
|||
result = JSON.parse( response.body )
|
||||
|
||||
address = result['results'].first['address_components'].first['long_name']
|
||||
return address
|
||||
address
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module Import::OTRS
|
|||
puts "ERROR: #{response.error}"
|
||||
return
|
||||
end
|
||||
return response
|
||||
response
|
||||
end
|
||||
def self.post(base, data)
|
||||
url = Setting.get('import_otrs_endpoint') + '/' + base
|
||||
|
@ -34,7 +34,7 @@ module Import::OTRS
|
|||
puts "ERROR: #{response.error}"
|
||||
return
|
||||
end
|
||||
return response
|
||||
response
|
||||
end
|
||||
|
||||
def self.json(response)
|
||||
|
@ -48,7 +48,7 @@ module Import::OTRS
|
|||
return if !response.success?
|
||||
|
||||
result = json(response)
|
||||
return result
|
||||
result
|
||||
end
|
||||
|
||||
def self.session(session_id)
|
||||
|
@ -57,7 +57,7 @@ module Import::OTRS
|
|||
return if !response.success?
|
||||
|
||||
result = json(response)
|
||||
return result
|
||||
result
|
||||
end
|
||||
|
||||
def self.permission_sync(user, result, config)
|
||||
|
@ -69,7 +69,7 @@ module Import::OTRS
|
|||
}
|
||||
types.each {|config_key, result_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
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ module Import::OTRS
|
|||
types.each {|config_key, result_key|
|
||||
next if !config[config_key]
|
||||
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 = Role.where( name: role ).first
|
||||
next if !role
|
||||
|
@ -117,7 +117,7 @@ module Import::OTRS
|
|||
|
||||
# check if system is in import mode
|
||||
if !Setting.get('import_mode')
|
||||
raise 'System is not in import mode!'
|
||||
raise 'System is not in import mode!'
|
||||
end
|
||||
|
||||
response = request('public.pl?Action=Export')
|
||||
|
@ -167,8 +167,7 @@ module Import::OTRS
|
|||
threads[thread].join
|
||||
}
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
def self.diff_worker
|
||||
return if !Setting.get('import_mode')
|
||||
|
@ -181,7 +180,7 @@ module Import::OTRS
|
|||
|
||||
# check if system is in import mode
|
||||
if !Setting.get('import_mode')
|
||||
raise 'System is not in import mode!'
|
||||
raise 'System is not in import mode!'
|
||||
end
|
||||
|
||||
# create states
|
||||
|
@ -198,7 +197,6 @@ module Import::OTRS
|
|||
|
||||
self.ticket_diff()
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
def self.ticket_diff()
|
||||
|
@ -557,7 +555,7 @@ module Import::OTRS
|
|||
ID: :id,
|
||||
ValidID: :active,
|
||||
Comment: :note,
|
||||
};
|
||||
}
|
||||
|
||||
Ticket::State.all.each {|state|
|
||||
state.name = state.name + '_tmp'
|
||||
|
@ -613,7 +611,7 @@ module Import::OTRS
|
|||
ID: :id,
|
||||
ValidID: :active,
|
||||
Comment: :note,
|
||||
};
|
||||
}
|
||||
|
||||
result.each { |priority|
|
||||
_set_valid(priority)
|
||||
|
@ -657,7 +655,7 @@ module Import::OTRS
|
|||
QueueID: :id,
|
||||
ValidID: :active,
|
||||
Comment: :note,
|
||||
};
|
||||
}
|
||||
|
||||
result.each { |group|
|
||||
_set_valid(group)
|
||||
|
@ -702,48 +700,44 @@ module Import::OTRS
|
|||
UserEmail: :email,
|
||||
UserFirstname: :firstname,
|
||||
UserLastname: :lastname,
|
||||
# :UserTitle =>
|
||||
UserLogin: :login,
|
||||
UserPw: :password,
|
||||
};
|
||||
}
|
||||
|
||||
result.each { |user|
|
||||
# puts 'USER: ' + user.inspect
|
||||
_set_valid(user)
|
||||
_set_valid(user)
|
||||
|
||||
role = Role.lookup( name: 'Agent' )
|
||||
# get new attributes
|
||||
user_new = {
|
||||
created_by_id: 1,
|
||||
updated_by_id: 1,
|
||||
source: 'OTRS Import',
|
||||
role_ids: [ role.id ],
|
||||
}
|
||||
map.each { |key, value|
|
||||
if user[key.to_s]
|
||||
user_new[value] = user[key.to_s]
|
||||
end
|
||||
}
|
||||
role = Role.lookup( name: 'Agent' )
|
||||
# get new attributes
|
||||
user_new = {
|
||||
created_by_id: 1,
|
||||
updated_by_id: 1,
|
||||
source: 'OTRS Import',
|
||||
role_ids: [ role.id ],
|
||||
}
|
||||
map.each { |key, value|
|
||||
if user[key.to_s]
|
||||
user_new[value] = user[key.to_s]
|
||||
end
|
||||
}
|
||||
|
||||
# check if state already exists
|
||||
# user_old = User.where( :login => user_new[:login] ).first
|
||||
user_old = User.where( id: user_new[:id] ).first
|
||||
# check if state already exists
|
||||
user_old = User.where( id: user_new[:id] ).first
|
||||
|
||||
# set state types
|
||||
if user_old
|
||||
puts "update User.find(#{user_new[:id]})"
|
||||
# puts 'Update User' + user_new.inspect
|
||||
user_new.delete( :role_ids )
|
||||
user_old.update_attributes(user_new)
|
||||
else
|
||||
puts "add User.find(#{user_new[:id]})"
|
||||
# puts 'Add User' + user_new.inspect
|
||||
user = User.new(user_new)
|
||||
user.id = user_new[:id]
|
||||
user.save
|
||||
end
|
||||
|
||||
# end
|
||||
if user_old
|
||||
puts "update User.find(#{user_new[:id]})"
|
||||
# puts 'Update User' + user_new.inspect
|
||||
user_new.delete( :role_ids )
|
||||
user_old.update_attributes(user_new)
|
||||
else
|
||||
puts "add User.find(#{user_new[:id]})"
|
||||
# puts 'Add User' + user_new.inspect
|
||||
user = User.new(user_new)
|
||||
user.id = user_new[:id]
|
||||
user.save
|
||||
end
|
||||
}
|
||||
end
|
||||
def self.customer
|
||||
|
@ -767,7 +761,6 @@ module Import::OTRS
|
|||
UserEmail: :email,
|
||||
UserFirstname: :firstname,
|
||||
UserLastname: :lastname,
|
||||
# :UserTitle =>
|
||||
UserLogin: :login,
|
||||
UserPassword: :password,
|
||||
UserPhone: :phone,
|
||||
|
@ -777,7 +770,7 @@ module Import::OTRS
|
|||
UserZip: :zip,
|
||||
UserCity: :city,
|
||||
UserCountry: :country,
|
||||
};
|
||||
}
|
||||
|
||||
done = true
|
||||
result.each { |user|
|
||||
|
@ -800,7 +793,7 @@ module Import::OTRS
|
|||
}
|
||||
|
||||
# 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
|
||||
|
||||
# set state types
|
||||
|
@ -819,17 +812,17 @@ module Import::OTRS
|
|||
end
|
||||
def self._set_valid(record)
|
||||
# map
|
||||
if record['ValidID'] == '3'
|
||||
record['ValidID'] = '2'
|
||||
end
|
||||
if record['ValidID'] == '2'
|
||||
record['ValidID'] = false
|
||||
end
|
||||
if record['ValidID'] == '1'
|
||||
record['ValidID'] = true
|
||||
end
|
||||
if record['ValidID'] == '0'
|
||||
record['ValidID'] = false
|
||||
end
|
||||
if record['ValidID'] == '3'
|
||||
record['ValidID'] = '2'
|
||||
end
|
||||
if record['ValidID'] == '2'
|
||||
record['ValidID'] = false
|
||||
end
|
||||
if record['ValidID'] == '1'
|
||||
record['ValidID'] = true
|
||||
end
|
||||
if record['ValidID'] == '0'
|
||||
record['ValidID'] = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -149,7 +149,7 @@ module Import::OTRS2
|
|||
return if !response.success?
|
||||
|
||||
result = json(response)
|
||||
return result
|
||||
result
|
||||
end
|
||||
|
||||
=begin
|
||||
|
@ -171,7 +171,7 @@ module Import::OTRS2
|
|||
return if !response
|
||||
return if !response.success?
|
||||
result = json(response)
|
||||
return result
|
||||
result
|
||||
end
|
||||
|
||||
=begin
|
||||
|
@ -207,7 +207,7 @@ module Import::OTRS2
|
|||
=end
|
||||
|
||||
def self.connection_test
|
||||
return self.request_json({})
|
||||
self.request_json({})
|
||||
end
|
||||
|
||||
=begin
|
||||
|
@ -352,14 +352,14 @@ module Import::OTRS2
|
|||
steps = 50
|
||||
run = true
|
||||
while run
|
||||
count += steps
|
||||
records = load('CustomerUser', steps, count - steps)
|
||||
if !records || !records[0]
|
||||
log 'all customers imported.'
|
||||
run = false
|
||||
next
|
||||
end
|
||||
customer(records, organizations)
|
||||
count += steps
|
||||
records = load('CustomerUser', steps, count - steps)
|
||||
if !records || !records[0]
|
||||
log 'all customers imported.'
|
||||
run = false
|
||||
next
|
||||
end
|
||||
customer(records, organizations)
|
||||
end
|
||||
|
||||
Thread.abort_on_exception = true
|
||||
|
@ -452,7 +452,6 @@ module Import::OTRS2
|
|||
# get changed tickets
|
||||
self.ticket_diff
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
def self.ticket_diff
|
||||
|
@ -820,7 +819,7 @@ module Import::OTRS2
|
|||
ID: :id,
|
||||
ValidID: :active,
|
||||
Comment: :note,
|
||||
};
|
||||
}
|
||||
|
||||
# rename states to handle not uniq issues
|
||||
Ticket::State.all.each {|state|
|
||||
|
@ -837,7 +836,7 @@ module Import::OTRS2
|
|||
updated_by_id: 1,
|
||||
}
|
||||
map.each { |key, value|
|
||||
if state.has_key?(key.to_s)
|
||||
if state.key?(key.to_s)
|
||||
state_new[value] = state[key.to_s]
|
||||
end
|
||||
}
|
||||
|
@ -875,7 +874,7 @@ module Import::OTRS2
|
|||
ID: :id,
|
||||
ValidID: :active,
|
||||
Comment: :note,
|
||||
};
|
||||
}
|
||||
|
||||
records.each { |priority|
|
||||
_set_valid(priority)
|
||||
|
@ -886,7 +885,7 @@ module Import::OTRS2
|
|||
updated_by_id: 1,
|
||||
}
|
||||
map.each { |key, value|
|
||||
if priority.has_key?(key.to_s)
|
||||
if priority.key?(key.to_s)
|
||||
priority_new[value] = priority[key.to_s]
|
||||
end
|
||||
}
|
||||
|
@ -916,7 +915,7 @@ module Import::OTRS2
|
|||
QueueID: :id,
|
||||
ValidID: :active,
|
||||
Comment: :note,
|
||||
};
|
||||
}
|
||||
|
||||
records.each { |group|
|
||||
_set_valid(group)
|
||||
|
@ -927,7 +926,7 @@ module Import::OTRS2
|
|||
updated_by_id: 1,
|
||||
}
|
||||
map.each { |key, value|
|
||||
if group.has_key?(key.to_s)
|
||||
if group.key?(key.to_s)
|
||||
group_new[value] = group[key.to_s]
|
||||
end
|
||||
}
|
||||
|
@ -960,10 +959,9 @@ module Import::OTRS2
|
|||
UserEmail: :email,
|
||||
UserFirstname: :firstname,
|
||||
UserLastname: :lastname,
|
||||
# :UserTitle =>
|
||||
UserLogin: :login,
|
||||
UserPw: :password,
|
||||
};
|
||||
}
|
||||
|
||||
records.each { |user|
|
||||
_set_valid(user)
|
||||
|
@ -983,7 +981,7 @@ module Import::OTRS2
|
|||
group_ids: group_ids,
|
||||
}
|
||||
map.each { |key, value|
|
||||
if user.has_key?(key.to_s)
|
||||
if user.key?(key.to_s)
|
||||
user_new[value] = user[key.to_s]
|
||||
end
|
||||
}
|
||||
|
@ -1081,7 +1079,6 @@ module Import::OTRS2
|
|||
UserEmail: :email,
|
||||
UserFirstname: :firstname,
|
||||
UserLastname: :lastname,
|
||||
# :UserTitle =>
|
||||
UserLogin: :login,
|
||||
UserPassword: :password,
|
||||
UserPhone: :phone,
|
||||
|
@ -1091,7 +1088,7 @@ module Import::OTRS2
|
|||
UserZip: :zip,
|
||||
UserCity: :city,
|
||||
UserCountry: :country,
|
||||
};
|
||||
}
|
||||
|
||||
role_agent = Role.lookup( name: 'Agent' )
|
||||
role_customer = Role.lookup( name: 'Customer' )
|
||||
|
@ -1108,7 +1105,7 @@ module Import::OTRS2
|
|||
role_ids: [ role_customer.id ],
|
||||
}
|
||||
map.each { |key, value|
|
||||
if user.has_key?(key.to_s)
|
||||
if user.key?(key.to_s)
|
||||
user_new[value] = user[key.to_s]
|
||||
end
|
||||
}
|
||||
|
@ -1161,7 +1158,7 @@ module Import::OTRS2
|
|||
CustomerCompanyName: :name,
|
||||
ValidID: :active,
|
||||
CustomerCompanyComment: :note,
|
||||
};
|
||||
}
|
||||
|
||||
records.each { |organization|
|
||||
_set_valid(organization)
|
||||
|
@ -1172,7 +1169,7 @@ module Import::OTRS2
|
|||
updated_by_id: 1,
|
||||
}
|
||||
map.each { |key, value|
|
||||
if organization.has_key?(key.to_s)
|
||||
if organization.key?(key.to_s)
|
||||
organization_new[value] = organization[key.to_s]
|
||||
end
|
||||
}
|
||||
|
@ -1252,20 +1249,20 @@ module Import::OTRS2
|
|||
|
||||
def self._set_valid(record)
|
||||
|
||||
# map
|
||||
if record['ValidID'].to_s == '3'
|
||||
record['ValidID'] = false
|
||||
elsif record['ValidID'].to_s == '2'
|
||||
record['ValidID'] = false
|
||||
elsif record['ValidID'].to_s == '1'
|
||||
record['ValidID'] = true
|
||||
elsif record['ValidID'].to_s == '0'
|
||||
record['ValidID'] = false
|
||||
# map
|
||||
if record['ValidID'].to_s == '3'
|
||||
record['ValidID'] = false
|
||||
elsif record['ValidID'].to_s == '2'
|
||||
record['ValidID'] = false
|
||||
elsif record['ValidID'].to_s == '1'
|
||||
record['ValidID'] = true
|
||||
elsif record['ValidID'].to_s == '0'
|
||||
record['ValidID'] = false
|
||||
|
||||
# fallback
|
||||
else
|
||||
record['ValidID'] = true
|
||||
end
|
||||
# fallback
|
||||
else
|
||||
record['ValidID'] = true
|
||||
end
|
||||
end
|
||||
|
||||
# cleanup invalid values
|
||||
|
|
|
@ -34,6 +34,6 @@ module Rss
|
|||
return
|
||||
end
|
||||
|
||||
return items
|
||||
items
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ module SessionHelper
|
|||
(default_collection, assets ) = ExtraCollection.session( default_collection, assets, user )
|
||||
end
|
||||
|
||||
return default_collection, assets
|
||||
[default_collection, assets]
|
||||
end
|
||||
|
||||
def self.models(user = nil)
|
||||
|
|
|
@ -68,7 +68,7 @@ returns
|
|||
path = @path + '/'
|
||||
|
||||
# just make sure that spool path exists
|
||||
if !File::exists?( path )
|
||||
if !File::exist?( path )
|
||||
FileUtils.mkpath path
|
||||
end
|
||||
|
||||
|
@ -270,7 +270,7 @@ returns
|
|||
check = true
|
||||
count = 0
|
||||
while check
|
||||
if File::exists?( path + filename )
|
||||
if File::exist?( path + filename )
|
||||
count += 1
|
||||
filename = filename + '-' + count
|
||||
else
|
||||
|
@ -284,7 +284,7 @@ returns
|
|||
file.flock( File::LOCK_UN )
|
||||
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 )
|
||||
true
|
||||
end
|
||||
|
@ -419,7 +419,7 @@ returns
|
|||
}
|
||||
files.sort.each {|entry|
|
||||
filename = path + '/' + entry
|
||||
next if !File::exists?( filename )
|
||||
next if !File::exist?( filename )
|
||||
File.open( filename, 'rb' ) { |file|
|
||||
all = file.read
|
||||
spool = JSON.parse( all )
|
||||
|
@ -468,13 +468,13 @@ returns
|
|||
to_delete.each {|file|
|
||||
File.delete(file)
|
||||
}
|
||||
return data
|
||||
data
|
||||
end
|
||||
|
||||
def self.jobs
|
||||
|
||||
# just make sure that spool path exists
|
||||
if !File::exists?( @path )
|
||||
if !File::exist?( @path )
|
||||
FileUtils.mkpath @path
|
||||
end
|
||||
|
||||
|
@ -576,7 +576,7 @@ returns
|
|||
end
|
||||
|
||||
def self.symbolize_keys(hash)
|
||||
hash.inject({}){|result, (key, value)|
|
||||
hash.inject({}) {|result, (key, value)|
|
||||
new_key = case key
|
||||
when String then key.to_sym
|
||||
else key
|
||||
|
|
|
@ -22,7 +22,7 @@ class Sessions::Backend::ActivityStream
|
|||
|
||||
# update last changed
|
||||
if activity_stream && activity_stream.first
|
||||
@last_change = activity_stream.first['created_at']
|
||||
@last_change = activity_stream.first['created_at']
|
||||
end
|
||||
|
||||
@user.activity_stream( 25, true )
|
||||
|
|
|
@ -65,7 +65,5 @@ returns
|
|||
return user_auth
|
||||
end
|
||||
}
|
||||
return
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,11 +22,11 @@ put working hours matrix and timezone in function, returns UTC working hours mat
|
|||
time_diff = 0
|
||||
if timezone
|
||||
begin
|
||||
time_diff = Time.parse(start_time.to_s).in_time_zone(timezone).utc_offset
|
||||
rescue Exception => e
|
||||
puts "ERROR: Can't fine tomezone #{timezone}"
|
||||
puts e.inspect
|
||||
puts e.backtrace
|
||||
time_diff = Time.parse(start_time.to_s).in_time_zone(timezone).utc_offset
|
||||
rescue Exception => e
|
||||
puts "ERROR: Can't fine tomezone #{timezone}"
|
||||
puts e.inspect
|
||||
puts e.backtrace
|
||||
end
|
||||
end
|
||||
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
|
||||
return working_hours
|
||||
working_hours
|
||||
end
|
||||
|
||||
=begin
|
||||
|
@ -169,7 +169,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat
|
|||
diff = end_time - start_time
|
||||
|
||||
if diff > 59 * 60
|
||||
diff = start_time - start_time.beginning_of_hour
|
||||
diff = start_time - start_time.beginning_of_hour
|
||||
end
|
||||
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
|
||||
end
|
||||
|
||||
return start_time
|
||||
start_time
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -386,6 +386,13 @@ returns
|
|||
end
|
||||
|
||||
class Result
|
||||
|
||||
attr_reader :error
|
||||
attr_reader :body
|
||||
attr_reader :data
|
||||
attr_reader :code
|
||||
attr_reader :content_type
|
||||
|
||||
def initialize(options)
|
||||
@success = options[:success]
|
||||
@body = options[:body]
|
||||
|
@ -394,23 +401,9 @@ returns
|
|||
@content_type = options[:content_type]
|
||||
@error = options[:error]
|
||||
end
|
||||
def error
|
||||
@error
|
||||
end
|
||||
|
||||
def success?
|
||||
@success
|
||||
end
|
||||
def body
|
||||
@body
|
||||
end
|
||||
def data
|
||||
@data
|
||||
end
|
||||
def code
|
||||
@code
|
||||
end
|
||||
def content_type
|
||||
@content_type
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -55,7 +55,7 @@ end.parse!
|
|||
|
||||
if ARGV[0] != 'start' && ARGV[0] != 'stop'
|
||||
puts "Usage: #{File.basename(__FILE__)} start|stop [options]"
|
||||
exit;
|
||||
exit
|
||||
end
|
||||
|
||||
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
|
||||
log 'error', "recipient attribute isn't a hash '#{ data['recipient'].inspect }'"
|
||||
else
|
||||
if !data['recipient'].has_key?('user_id')
|
||||
if !data['recipient'].key?('user_id')
|
||||
log 'error', "need recipient.user_id attribute '#{ data['recipient'].inspect }'"
|
||||
else
|
||||
if data['recipient']['user_id'].class != Array
|
||||
|
|
Loading…
Reference in a new issue