Applied rubocop.

This commit is contained in:
Martin Edenhofer 2016-06-30 22:04:48 +02:00
parent c52ee90747
commit 30fe8aef36
158 changed files with 557 additions and 548 deletions

View file

@ -119,7 +119,7 @@ class ApplicationController < ActionController::Base
content_encoding: request.headers['Content-Encoding'], content_encoding: request.headers['Content-Encoding'],
source: request.headers['User-Agent'] || request.headers['Server'], source: request.headers['User-Agent'] || request.headers['Server'],
} }
request.headers.each {|key, value| request.headers.each { |key, value|
next if key[0, 5] != 'HTTP_' next if key[0, 5] != 'HTTP_'
request_data[:content] += if key == 'HTTP_COOKIE' request_data[:content] += if key == 'HTTP_COOKIE'
"#{key}: xxxxx\n" "#{key}: xxxxx\n"
@ -141,7 +141,7 @@ class ApplicationController < ActionController::Base
content_encoding: nil, content_encoding: nil,
source: nil, source: nil,
} }
response.headers.each {|key, value| response.headers.each { |key, value|
response_data[:content] += "#{key}: #{value}\n" response_data[:content] += "#{key}: #{value}\n"
} }
body = response.body body = response.body
@ -473,7 +473,7 @@ class ApplicationController < ActionController::Base
if params[:expand] if params[:expand]
list = [] list = []
generic_objects.each {|generic_object| generic_objects.each { |generic_object|
list.push generic_object.attributes_with_relation_names list.push generic_object.attributes_with_relation_names
} }
render json: list, status: :ok render json: list, status: :ok
@ -483,7 +483,7 @@ class ApplicationController < ActionController::Base
if params[:full] if params[:full]
assets = {} assets = {}
item_ids = [] item_ids = []
generic_objects.each {|item| generic_objects.each { |item|
item_ids.push item.id item_ids.push item.id
assets = item.assets(assets) assets = item.assets(assets)
} }
@ -495,7 +495,7 @@ class ApplicationController < ActionController::Base
end end
generic_objects_with_associations = [] generic_objects_with_associations = []
generic_objects.each {|item| generic_objects.each { |item|
generic_objects_with_associations.push item.attributes_with_associations generic_objects_with_associations.push item.attributes_with_associations
} }
model_index_render_result(generic_objects_with_associations) model_index_render_result(generic_objects_with_associations)

View file

@ -9,7 +9,7 @@ class CalendarsController < ApplicationController
# calendars # calendars
assets = {} assets = {}
calendar_ids = [] calendar_ids = []
Calendar.all.order(:name, :created_at).each {|calendar| Calendar.all.order(:name, :created_at).each { |calendar|
calendar_ids.push calendar.id calendar_ids.push calendar.id
assets = calendar.assets(assets) assets = calendar.assets(assets)
} }

View file

@ -47,11 +47,11 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
def twitter_index def twitter_index
assets = {} assets = {}
ExternalCredential.where(name: 'twitter').each {|external_credential| ExternalCredential.where(name: 'twitter').each { |external_credential|
assets = external_credential.assets(assets) assets = external_credential.assets(assets)
} }
channel_ids = [] channel_ids = []
Channel.order(:id).each {|channel| Channel.order(:id).each { |channel|
next if channel.area != 'Twitter::Account' next if channel.area != 'Twitter::Account'
assets = channel.assets(assets) assets = channel.assets(assets)
channel_ids.push channel.id channel_ids.push channel.id
@ -70,11 +70,11 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
def facebook_index def facebook_index
assets = {} assets = {}
ExternalCredential.where(name: 'facebook').each {|external_credential| ExternalCredential.where(name: 'facebook').each { |external_credential|
assets = external_credential.assets(assets) assets = external_credential.assets(assets)
} }
channel_ids = [] channel_ids = []
Channel.order(:id).each {|channel| Channel.order(:id).each { |channel|
next if channel.area != 'Facebook::Account' next if channel.area != 'Facebook::Account'
assets = channel.assets(assets) assets = channel.assets(assets)
channel_ids.push channel.id channel_ids.push channel.id
@ -100,10 +100,10 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
not_used_email_address_ids = [] not_used_email_address_ids = []
accounts_fixed = [] accounts_fixed = []
assets = {} assets = {}
Channel.order(:id).each {|channel| Channel.order(:id).each { |channel|
if system_online_service && channel.preferences && channel.preferences['online_service_disable'] if system_online_service && channel.preferences && channel.preferences['online_service_disable']
email_addresses = EmailAddress.where(channel_id: channel.id) email_addresses = EmailAddress.where(channel_id: channel.id)
email_addresses.each {|email_address| email_addresses.each { |email_address|
accounts_fixed.push email_address accounts_fixed.push email_address
} }
next next
@ -116,7 +116,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
assets = channel.assets(assets) assets = channel.assets(assets)
end end
} }
EmailAddress.all.each {|email_address| EmailAddress.all.each { |email_address|
next if system_online_service && email_address.preferences && email_address.preferences['online_service_disable'] next if system_online_service && email_address.preferences && email_address.preferences['online_service_disable']
email_address_ids.push email_address.id email_address_ids.push email_address.id
assets = email_address.assets(assets) assets = email_address.assets(assets)
@ -299,7 +299,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
# save settings # save settings
if result[:result] == 'ok' if result[:result] == 'ok'
Channel.where(area: 'Email::Notification').each {|channel| Channel.where(area: 'Email::Notification').each { |channel|
active = false active = false
if adapter =~ /^#{channel.options[:outbound][:adapter]}$/i if adapter =~ /^#{channel.options[:outbound][:adapter]}$/i
active = true active = true
@ -322,7 +322,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
private private
def email_account_duplicate?(result, channel_id = nil) def email_account_duplicate?(result, channel_id = nil)
Channel.where(area: 'Email::Account').each {|channel| Channel.where(area: 'Email::Account').each { |channel|
next if !channel.options next if !channel.options
next if !channel.options[:inbound] next if !channel.options[:inbound]
next if !channel.options[:inbound][:adapter] next if !channel.options[:inbound][:adapter]

View file

@ -7,7 +7,7 @@ class ChatsController < ApplicationController
deny_if_not_role(Z_ROLENAME_ADMIN) deny_if_not_role(Z_ROLENAME_ADMIN)
chat_ids = [] chat_ids = []
assets = {} assets = {}
Chat.order(:id).each {|chat| Chat.order(:id).each { |chat|
chat_ids.push chat.id chat_ids.push chat.id
assets = chat.assets(assets) assets = chat.assets(assets)
} }

View file

@ -246,9 +246,9 @@ class FirstStepsController < ApplicationController
test_ticket_active = false test_ticket_active = false
end end
return result if test_ticket_active return result if test_ticket_active
result.each {|item| result.each { |item|
items = [] items = []
item[:items].each {|local_item| item[:items].each { |local_item|
next if local_item[:name] == 'Create a Test Ticket' next if local_item[:name] == 'Create a Test Ticket'
items.push local_item items.push local_item
} }

View file

@ -179,7 +179,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end end
# set changed settings # set changed settings
settings.each {|key, value| settings.each { |key, value|
Setting.set(key, value) Setting.set(key, value)
} }

View file

@ -26,7 +26,7 @@ class ImportOtrsController < ApplicationController
if !response.success? && response.code.to_s !~ /^40.$/ if !response.success? && response.code.to_s !~ /^40.$/
message_human = '' message_human = ''
translation_map.each {|key, message| translation_map.each { |key, message|
if response.error.to_s =~ /#{Regexp.escape(key)}/i if response.error.to_s =~ /#{Regexp.escape(key)}/i
message_human = message message_human = message
end end

View file

@ -27,7 +27,7 @@ class ImportZendeskController < ApplicationController
if !response.success? if !response.success?
message_human = '' message_human = ''
translation_map.each {|key, message| translation_map.each { |key, message|
if response.error.to_s =~ /#{Regexp.escape(key)}/i if response.error.to_s =~ /#{Regexp.escape(key)}/i
message_human = message message_human = message
end end

View file

@ -16,7 +16,7 @@ class Integration::SipgateController < ApplicationController
block_caller_ids = config_inbound[:block_caller_ids] || [] block_caller_ids = config_inbound[:block_caller_ids] || []
# check if call need to be blocked # check if call need to be blocked
block_caller_ids.each {|item| block_caller_ids.each { |item|
next unless item[:caller_id] == params['from'] next unless item[:caller_id] == params['from']
xml = Builder::XmlMarkup.new(indent: 2) xml = Builder::XmlMarkup.new(indent: 2)
xml.instruct! xml.instruct!
@ -61,7 +61,7 @@ class Integration::SipgateController < ApplicationController
to = params[:to] to = params[:to]
from = nil from = nil
if to if to
config_outbound.each {|row| config_outbound.each { |row|
dest = row[:dest].gsub(/\*/, '.+?') dest = row[:dest].gsub(/\*/, '.+?')
next if to !~ /^#{dest}$/ next if to !~ /^#{dest}$/
from = row[:caller_id] from = row[:caller_id]
@ -173,7 +173,7 @@ class Integration::SipgateController < ApplicationController
preferences_maybe = {} preferences_maybe = {}
preferences_maybe[direction] = [] preferences_maybe[direction] = []
caller_ids = Cti::CallerId.lookup(params[direction]) caller_ids = Cti::CallerId.lookup(params[direction])
caller_ids.each {|record| caller_ids.each { |record|
if record.level == 'known' if record.level == 'known'
preferences_known[direction].push record preferences_known[direction].push record
else else

View file

@ -67,7 +67,7 @@ curl http://localhost/api/v1/organizations -v -u #{login}:#{password}
if params[:expand] if params[:expand]
list = [] list = []
organizations.each {|organization| organizations.each { |organization|
list.push organization.attributes_with_relation_names list.push organization.attributes_with_relation_names
} }
render json: list, status: :ok render json: list, status: :ok
@ -77,7 +77,7 @@ curl http://localhost/api/v1/organizations -v -u #{login}:#{password}
if params[:full] if params[:full]
assets = {} assets = {}
item_ids = [] item_ids = []
organizations.each {|item| organizations.each { |item|
item_ids.push item.id item_ids.push item.id
assets = item.assets(assets) assets = item.assets(assets)
} }
@ -246,7 +246,7 @@ curl http://localhost/api/v1/organization/{id} -v -u #{login}:#{password} -H "Co
if params[:expand] if params[:expand]
list = [] list = []
organization_all.each {|organization| organization_all.each { |organization|
list.push organization.attributes_with_relation_names list.push organization.attributes_with_relation_names
} }
render json: list, status: :ok render json: list, status: :ok

View file

@ -22,7 +22,7 @@ class ReportsController < ApplicationController
return if !get_params return if !get_params
result = {} result = {}
get_params[:metric][:backend].each {|backend| get_params[:metric][:backend].each { |backend|
condition = get_params[:profile].condition condition = get_params[:profile].condition
if backend[:condition] if backend[:condition]
backend[:condition].merge(condition) backend[:condition].merge(condition)
@ -75,7 +75,7 @@ class ReportsController < ApplicationController
# get data # get data
result = {} result = {}
get_params[:metric][:backend].each {|backend| get_params[:metric][:backend].each { |backend|
next if params[:downloadBackendSelected] != backend[:name] next if params[:downloadBackendSelected] != backend[:name]
condition = get_params[:profile].condition condition = get_params[:profile].condition
if backend[:condition] if backend[:condition]
@ -116,7 +116,7 @@ class ReportsController < ApplicationController
if params[:profile_id] if params[:profile_id]
profile = Report::Profile.find(params[:profile_id]) profile = Report::Profile.find(params[:profile_id])
else else
params[:profiles].each {|profile_id, active| params[:profiles].each { |profile_id, active|
next if !active next if !active
profile = Report::Profile.find(profile_id) profile = Report::Profile.find(profile_id)
} }
@ -203,7 +203,7 @@ class ReportsController < ApplicationController
worksheet.write(2, 7, 'Closed at', format_header ) worksheet.write(2, 7, 'Closed at', format_header )
row = 2 row = 2
result[:ticket_ids].each {|ticket_id| result[:ticket_ids].each { |ticket_id|
ticket = Ticket.lookup(id: ticket_id) ticket = Ticket.lookup(id: ticket_id)
row += 1 row += 1
worksheet.write(row, 0, ticket.number ) worksheet.write(row, 0, ticket.number )

View file

@ -34,7 +34,7 @@ class SearchController < ApplicationController
next if !preferences next if !preferences
objects_in_order_hash[preferences[:prio]] = object objects_in_order_hash[preferences[:prio]] = object
} }
objects_in_order_hash.keys.sort.reverse_each {|prio| objects_in_order_hash.keys.sort.reverse_each { |prio|
objects_in_order.push objects_in_order_hash[prio] objects_in_order.push objects_in_order_hash[prio]
} }
@ -78,7 +78,7 @@ class SearchController < ApplicationController
# sort order by object priority # sort order by object priority
result_in_order = [] result_in_order = []
objects_in_order.each { |object| objects_in_order.each { |object|
result.each {|item| result.each { |item|
next if item[:type] != object next if item[:type] != object
item[:id] = item[:id].to_i item[:id] = item[:id].to_i
result_in_order.push item result_in_order.push item

View file

@ -7,7 +7,7 @@ module ExtraCollection
collections[ Locale.to_app_model ] = Locale.where(active: true) collections[ Locale.to_app_model ] = Locale.where(active: true)
collections[ Taskbar.to_app_model ] = Taskbar.where(user_id: user.id) collections[ Taskbar.to_app_model ] = Taskbar.where(user_id: user.id)
collections[ Taskbar.to_app_model ].each {|item| collections[ Taskbar.to_app_model ].each { |item|
assets = item.assets(assets) assets = item.assets(assets)
} }
@ -18,18 +18,18 @@ module ExtraCollection
assets = RecentView.assets_of_object_list(collections[ RecentView.to_app_model ], assets) assets = RecentView.assets_of_object_list(collections[ RecentView.to_app_model ], assets)
collections[ Role.to_app_model ] = [] collections[ Role.to_app_model ] = []
Role.all.each {|item| Role.all.each { |item|
assets = item.assets(assets) assets = item.assets(assets)
} }
collections[ Group.to_app_model ] = [] collections[ Group.to_app_model ] = []
Group.all.each {|item| Group.all.each { |item|
assets = item.assets(assets) assets = item.assets(assets)
} }
collections[ Organization.to_app_model ] = [] collections[ Organization.to_app_model ] = []
if user.organization_id if user.organization_id
Organization.where(id: user.organization_id).each {|item| Organization.where(id: user.organization_id).each { |item|
assets = item.assets(assets) assets = item.assets(assets)
} }
end end

View file

@ -5,40 +5,40 @@ module ExtraCollection
# all ticket stuff # all ticket stuff
collections[ Macro.to_app_model ] = [] collections[ Macro.to_app_model ] = []
Macro.all.each {|item| Macro.all.each { |item|
assets = item.assets(assets) assets = item.assets(assets)
} }
collections[ Ticket::StateType.to_app_model ] = [] collections[ Ticket::StateType.to_app_model ] = []
Ticket::StateType.all.each {|item| Ticket::StateType.all.each { |item|
assets = item.assets(assets) assets = item.assets(assets)
} }
collections[ Ticket::State.to_app_model ] = [] collections[ Ticket::State.to_app_model ] = []
Ticket::State.all.each {|item| Ticket::State.all.each { |item|
assets = item.assets(assets) assets = item.assets(assets)
} }
collections[ Ticket::Priority.to_app_model ] = [] collections[ Ticket::Priority.to_app_model ] = []
Ticket::Priority.all.each {|item| Ticket::Priority.all.each { |item|
assets = item.assets(assets) assets = item.assets(assets)
} }
collections[ Ticket::Article::Type.to_app_model ] = [] collections[ Ticket::Article::Type.to_app_model ] = []
Ticket::Article::Type.all.each {|item| Ticket::Article::Type.all.each { |item|
assets = item.assets(assets) assets = item.assets(assets)
} }
collections[ Ticket::Article::Sender.to_app_model ] = [] collections[ Ticket::Article::Sender.to_app_model ] = []
Ticket::Article::Sender.all.each {|item| Ticket::Article::Sender.all.each { |item|
assets = item.assets(assets) assets = item.assets(assets)
} }
if !user.role?(Z_ROLENAME_CUSTOMER) if !user.role?(Z_ROLENAME_CUSTOMER)
# all signatures # all signatures
collections[ Signature.to_app_model ] = [] collections[ Signature.to_app_model ] = []
Signature.all.each {|item| Signature.all.each { |item|
assets = item.assets(assets) assets = item.assets(assets)
} }
# all email addresses # all email addresses
collections[ EmailAddress.to_app_model ] = [] collections[ EmailAddress.to_app_model ] = []
EmailAddress.all.each {|item| EmailAddress.all.each { |item|
assets = item.assets(assets) assets = item.assets(assets)
} }
end end

View file

@ -280,7 +280,7 @@ class SessionsController < ApplicationController
deny_if_not_role(Z_ROLENAME_ADMIN) deny_if_not_role(Z_ROLENAME_ADMIN)
assets = {} assets = {}
sessions_clean = [] sessions_clean = []
SessionHelper.list.each {|session| SessionHelper.list.each { |session|
next if !session.data['user_id'] next if !session.data['user_id']
sessions_clean.push session sessions_clean.push session
if session.data['user_id'] if session.data['user_id']

View file

@ -54,13 +54,13 @@ curl http://localhost/api/v1/slas.json -v -u #{login}:#{password}
# calendars # calendars
assets = {} assets = {}
calendar_ids = [] calendar_ids = []
Calendar.all.each {|calendar| Calendar.all.each { |calendar|
assets = calendar.assets(assets) assets = calendar.assets(assets)
} }
# slas # slas
sla_ids = [] sla_ids = []
Sla.all.each {|item| Sla.all.each { |item|
sla_ids.push item.id sla_ids.push item.id
assets = item.assets(assets) assets = item.assets(assets)
} }

View file

@ -7,7 +7,7 @@ class TagsController < ApplicationController
def search def search
list = Tag::Item.where('name_downcase LIKE ?', "#{params[:term].strip.downcase}%").order('name ASC').limit(params[:limit] || 10) list = Tag::Item.where('name_downcase LIKE ?', "#{params[:term].strip.downcase}%").order('name ASC').limit(params[:limit] || 10)
results = [] results = []
list.each {|item| list.each { |item|
result = { result = {
id: item.id, id: item.id,
value: item.name, value: item.name,
@ -62,7 +62,7 @@ class TagsController < ApplicationController
def admin_list def admin_list
list = Tag::Item.order('name ASC').limit(params[:limit] || 1000) list = Tag::Item.order('name ASC').limit(params[:limit] || 1000)
results = [] results = []
list.each {|item| list.each { |item|
result = { result = {
id: item.id, id: item.id,
name: item.name, name: item.name,

View file

@ -45,7 +45,7 @@ class TicketArticlesController < ApplicationController
articles = [] articles = []
if params[:expand] if params[:expand]
ticket.articles.each {|article| ticket.articles.each { |article|
# ignore internal article if customer is requesting # ignore internal article if customer is requesting
next if article.internal == true && role?(Z_ROLENAME_CUSTOMER) next if article.internal == true && role?(Z_ROLENAME_CUSTOMER)
@ -64,7 +64,7 @@ class TicketArticlesController < ApplicationController
if params[:full] if params[:full]
assets = {} assets = {}
record_ids = [] record_ids = []
ticket.articles.each {|article| ticket.articles.each { |article|
# ignore internal article if customer is requesting # ignore internal article if customer is requesting
next if article.internal == true && role?(Z_ROLENAME_CUSTOMER) next if article.internal == true && role?(Z_ROLENAME_CUSTOMER)
@ -79,7 +79,7 @@ class TicketArticlesController < ApplicationController
return return
end end
ticket.articles.each {|article| ticket.articles.each { |article|
# ignore internal article if customer is requesting # ignore internal article if customer is requesting
next if article.internal == true && role?(Z_ROLENAME_CUSTOMER) next if article.internal == true && role?(Z_ROLENAME_CUSTOMER)
@ -220,7 +220,7 @@ class TicketArticlesController < ApplicationController
list = article.attachments || [] list = article.attachments || []
access = false access = false
list.each {|item| list.each { |item|
if item.id.to_i == params[:id].to_i if item.id.to_i == params[:id].to_i
access = true access = true
end end

View file

@ -36,7 +36,7 @@ class TicketOverviewsController < ApplicationController
overview = Overview.lookup(id: index[:overview][:id]) overview = Overview.lookup(id: index[:overview][:id])
assets = overview.assets(assets) assets = overview.assets(assets)
index[:tickets].each {|ticket_meta| index[:tickets].each { |ticket_meta|
ticket = Ticket.lookup(id: ticket_meta[:id]) ticket = Ticket.lookup(id: ticket_meta[:id])
assets = ticket.assets(assets) assets = ticket.assets(assets)
} }

View file

@ -18,7 +18,7 @@ class TicketsController < ApplicationController
if params[:expand] if params[:expand]
list = [] list = []
tickets.each {|ticket| tickets.each { |ticket|
list.push ticket.attributes_with_relation_names list.push ticket.attributes_with_relation_names
} }
render json: list, status: :ok render json: list, status: :ok
@ -28,7 +28,7 @@ class TicketsController < ApplicationController
if params[:full] if params[:full]
assets = {} assets = {}
item_ids = [] item_ids = []
tickets.each {|item| tickets.each { |item|
item_ids.push item.id item_ids.push item.id
assets = item.assets(assets) assets = item.assets(assets)
} }
@ -90,7 +90,7 @@ class TicketsController < ApplicationController
# create tags if given # create tags if given
if params[:tags] && !params[:tags].empty? if params[:tags] && !params[:tags].empty?
tags = params[:tags].split(/,/) tags = params[:tags].split(/,/)
tags.each {|tag| tags.each { |tag|
Tag.tag_add( Tag.tag_add(
object: 'Ticket', object: 'Ticket',
o_id: ticket.id, o_id: ticket.id,
@ -215,14 +215,14 @@ class TicketsController < ApplicationController
# get related assets # get related assets
ticket_ids_by_customer = [] ticket_ids_by_customer = []
ticket_lists.each {|ticket_list| ticket_lists.each { |ticket_list|
ticket_ids_by_customer.push ticket_list.id ticket_ids_by_customer.push ticket_list.id
assets = ticket_list.assets(assets) assets = ticket_list.assets(assets)
} }
ticket_ids_recent_viewed = [] ticket_ids_recent_viewed = []
recent_views = RecentView.list(current_user, 8, 'Ticket') recent_views = RecentView.list(current_user, 8, 'Ticket')
recent_views.each {|recent_view| recent_views.each { |recent_view|
next if recent_view['object'] != 'Ticket' next if recent_view['object'] != 'Ticket'
ticket_ids_recent_viewed.push recent_view['o_id'] ticket_ids_recent_viewed.push recent_view['o_id']
recent_view_ticket = Ticket.find(recent_view['o_id']) recent_view_ticket = Ticket.find(recent_view['o_id'])
@ -332,7 +332,7 @@ class TicketsController < ApplicationController
if params[:expand] if params[:expand]
list = [] list = []
tickets.each {|ticket| tickets.each { |ticket|
list.push ticket.attributes_with_relation_names list.push ticket.attributes_with_relation_names
} }
render json: list, status: :ok render json: list, status: :ok
@ -433,7 +433,7 @@ class TicketsController < ApplicationController
user_tickets_closed_ids = assets_of_tickets(user_tickets_closed, assets) user_tickets_closed_ids = assets_of_tickets(user_tickets_closed, assets)
# generate stats by user # generate stats by user
(0..11).each {|month_back| (0..11).each { |month_back|
date_to_check = now - month_back.month date_to_check = now - month_back.month
date_start = "#{date_to_check.year}-#{date_to_check.month}-01 00:00:00" date_start = "#{date_to_check.year}-#{date_to_check.month}-01 00:00:00"
date_end = "#{date_to_check.year}-#{date_to_check.month}-#{date_to_check.end_of_month.day} 00:00:00" date_end = "#{date_to_check.year}-#{date_to_check.month}-#{date_to_check.end_of_month.day} 00:00:00"
@ -507,7 +507,7 @@ class TicketsController < ApplicationController
org_tickets_closed_ids = assets_of_tickets(org_tickets_closed, assets) org_tickets_closed_ids = assets_of_tickets(org_tickets_closed, assets)
# generate stats by org # generate stats by org
(0..11).each {|month_back| (0..11).each { |month_back|
date_to_check = now - month_back.month date_to_check = now - month_back.month
date_start = "#{date_to_check.year}-#{date_to_check.month}-01 00:00:00" date_start = "#{date_to_check.year}-#{date_to_check.month}-01 00:00:00"
date_end = "#{date_to_check.year}-#{date_to_check.month}-#{date_to_check.end_of_month.day} 00:00:00" date_end = "#{date_to_check.year}-#{date_to_check.month}-#{date_to_check.end_of_month.day} 00:00:00"
@ -624,7 +624,7 @@ class TicketsController < ApplicationController
# get related users # get related users
article_ids = [] article_ids = []
articles.each {|article| articles.each { |article|
# ignore internal article if customer is requesting # ignore internal article if customer is requesting
next if article.internal == true && role?(Z_ROLENAME_CUSTOMER) next if article.internal == true && role?(Z_ROLENAME_CUSTOMER)

View file

@ -6,7 +6,7 @@ class UserDevicesController < ApplicationController
def index def index
devices = UserDevice.where(user_id: current_user.id).order('updated_at DESC, name ASC') devices = UserDevice.where(user_id: current_user.id).order('updated_at DESC, name ASC')
devices_full = [] devices_full = []
devices.each {|device| devices.each { |device|
attributes = device.attributes attributes = device.attributes
if device.location_details['city_name'] && !device.location_details['city_name'].empty? if device.location_details['city_name'] && !device.location_details['city_name'].empty?
attributes['location'] += ", #{device.location_details['city_name']}" attributes['location'] += ", #{device.location_details['city_name']}"
@ -30,7 +30,7 @@ class UserDevicesController < ApplicationController
# delete device and session's # delete device and session's
if user_device if user_device
SessionHelper.list.each {|session| SessionHelper.list.each { |session|
next if !session.data['user_id'] next if !session.data['user_id']
next if !session.data['user_device_id'] next if !session.data['user_device_id']
next if session.data['user_device_id'] != user_device.id next if session.data['user_device_id'] != user_device.id

View file

@ -29,7 +29,7 @@ class UsersController < ApplicationController
if params[:expand] if params[:expand]
list = [] list = []
users.each {|user| users.each { |user|
list.push user.attributes_with_relation_names list.push user.attributes_with_relation_names
} }
render json: list, status: :ok render json: list, status: :ok
@ -39,7 +39,7 @@ class UsersController < ApplicationController
if params[:full] if params[:full]
assets = {} assets = {}
item_ids = [] item_ids = []
users.each {|item| users.each { |item|
item_ids.push item.id item_ids.push item.id
assets = item.assets(assets) assets = item.assets(assets)
} }
@ -51,7 +51,7 @@ class UsersController < ApplicationController
end end
users_all = [] users_all = []
users.each {|user| users.each { |user|
users_all.push User.lookup(id: user.id).attributes_with_associations users_all.push User.lookup(id: user.id).attributes_with_associations
} }
render json: users_all, status: :ok render json: users_all, status: :ok
@ -341,7 +341,7 @@ class UsersController < ApplicationController
if params[:expand] if params[:expand]
list = [] list = []
user_all.each {|user| user_all.each { |user|
list.push user.attributes_with_relation_names list.push user.attributes_with_relation_names
} }
render json: list, status: :ok render json: list, status: :ok
@ -753,7 +753,7 @@ curl http://localhost/api/v1/users/preferences.json -v -u #{login}:#{password} -
if params[:user] if params[:user]
user = User.find(current_user.id) user = User.find(current_user.id)
params[:user].each {|key, value| params[:user].each { |key, value|
user.preferences[key.to_sym] = value user.preferences[key.to_sym] = value
} }
user.save user.save
@ -954,7 +954,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
if params[:role_ids].class != Array if params[:role_ids].class != Array
params[:role_ids] = [params[:role_ids]] params[:role_ids] = [params[:role_ids]]
end end
params[:role_ids].each {|role_id| params[:role_ids].each { |role_id|
role_local = Role.lookup(id: role_id) role_local = Role.lookup(id: role_id)
if !role_local if !role_local
logger.info "Invalid role_ids for current_user_id: #{current_user.id} role_ids #{role_id}" logger.info "Invalid role_ids for current_user_id: #{current_user.id} role_ids #{role_id}"

View file

@ -1,9 +0,0 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module ApplicationHelper
def inline_svg(path)
File.open("public/assets/images/#{path}", 'rb') do |file|
raw file.read
end
end
end

View file

@ -1,4 +0,0 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module PostsHelper
end

View file

@ -80,7 +80,7 @@ returns
end end
data = {} data = {}
params.each {|key, value| params.each { |key, value|
data[key.to_sym] = value data[key.to_sym] = value
} }
@ -91,7 +91,7 @@ returns
# only use object attributes # only use object attributes
clean_params = {} clean_params = {}
new.attributes.each {|attribute, _value| new.attributes.each { |attribute, _value|
next if !data.key?(attribute.to_sym) next if !data.key?(attribute.to_sym)
clean_params[attribute.to_sym] = data[attribute.to_sym] clean_params[attribute.to_sym] = data[attribute.to_sym]
} }
@ -125,7 +125,7 @@ returns
list_of_items = [ params[real_ids] ] list_of_items = [ params[real_ids] ]
end end
list = [] list = []
list_of_items.each {|item_id| list_of_items.each { |item_id|
next if !item_id next if !item_id
lookup = assoc.klass.lookup(id: item_id) lookup = assoc.klass.lookup(id: item_id)
@ -150,7 +150,7 @@ returns
next if params[real_values].class != Array next if params[real_values].class != Array
list = [] list = []
class_object = assoc.klass class_object = assoc.klass
params[real_values].each {|value| params[real_values].each { |value|
lookup = nil lookup = nil
if class_object == User if class_object == User
if !lookup if !lookup
@ -222,7 +222,7 @@ returns
next if !ref next if !ref
if ref.respond_to?(:first) if ref.respond_to?(:first)
attributes[assoc.name.to_s] = [] attributes[assoc.name.to_s] = []
ref.each {|item| ref.each { |item|
if item[:login] if item[:login]
attributes[assoc.name.to_s].push item[:login] attributes[assoc.name.to_s].push item[:login]
next next
@ -247,7 +247,7 @@ returns
{ {
'created_by_id' => 'created_by', 'created_by_id' => 'created_by',
'updated_by_id' => 'updated_by', 'updated_by_id' => 'updated_by',
}.each {|source, destination| }.each { |source, destination|
next if !attributes[source] next if !attributes[source]
user = User.lookup(id: attributes[source]) user = User.lookup(id: attributes[source])
next if !user next if !user
@ -255,7 +255,7 @@ returns
} }
# remove forbitten attributes # remove forbitten attributes
%w(password token tokens token_ids).each {|item| %w(password token tokens token_ids).each { |item|
attributes.delete(item) attributes.delete(item)
} }
@ -277,7 +277,7 @@ returns
def self.param_validation(data) def self.param_validation(data)
# we do want to set this via database # we do want to set this via database
[:action, :controller, :updated_at, :created_at, :updated_by_id, :created_by_id, :updated_by, :created_by].each {|key| [:action, :controller, :updated_at, :created_at, :updated_by_id, :created_by_id, :updated_by, :created_by].each { |key|
data.delete(key) data.delete(key)
} }
@ -317,7 +317,7 @@ returns
def self.param_association_lookup(params) def self.param_association_lookup(params)
data = {} data = {}
params.each {|key, value| params.each { |key, value|
data[key.to_sym] = value data[key.to_sym] = value
} }
@ -376,7 +376,7 @@ returns
# get association class and do lookup # get association class and do lookup
class_object = assoc.klass class_object = assoc.klass
lookup_ids = [] lookup_ids = []
value.each {|item| value.each { |item|
lookup = nil lookup = nil
if class_object == User if class_object == User
if item.class == String if item.class == String
@ -528,7 +528,7 @@ returns
def self.genrate_uniq_name(name) def self.genrate_uniq_name(name)
return name if !find_by(name: name) return name if !find_by(name: name)
(1..100).each {|counter| (1..100).each { |counter|
name = "#{name}_#{counter}" name = "#{name}_#{counter}"
exists = find_by(name: name) exists = find_by(name: name)
next if exists next if exists
@ -570,7 +570,7 @@ returns
else else
where(name: data[:name]) where(name: data[:name])
end end
records.each {|loop_record| records.each { |loop_record|
if loop_record.name == data[:name] if loop_record.name == data[:name]
cache_set(data[:name], loop_record) cache_set(data[:name], loop_record)
return loop_record return loop_record
@ -587,7 +587,7 @@ returns
else else
where(login: data[:login]) where(login: data[:login])
end end
records.each {|loop_record| records.each { |loop_record|
if loop_record.login == data[:login] if loop_record.login == data[:login]
cache_set(data[:login], loop_record) cache_set(data[:login], loop_record)
return loop_record return loop_record
@ -604,7 +604,7 @@ returns
else else
where(email: data[:email]) where(email: data[:email])
end end
records.each {|loop_record| records.each { |loop_record|
if loop_record.email == data[:email] if loop_record.email == data[:email]
cache_set(data[:email], loop_record) cache_set(data[:email], loop_record)
return loop_record return loop_record
@ -640,7 +640,7 @@ returns
else else
where(name: data[:name]) where(name: data[:name])
end end
records.each {|loop_record| records.each { |loop_record|
return loop_record if loop_record.name == data[:name] return loop_record if loop_record.name == data[:name]
} }
elsif data[:login] elsif data[:login]
@ -651,7 +651,7 @@ returns
else else
where(login: data[:login]) where(login: data[:login])
end end
records.each {|loop_record| records.each { |loop_record|
return loop_record if loop_record.login == data[:login] return loop_record if loop_record.login == data[:login]
} }
elsif data[:email] elsif data[:email]
@ -662,7 +662,7 @@ returns
else else
where(email: data[:email]) where(email: data[:email])
end end
records.each {|loop_record| records.each { |loop_record|
return loop_record if loop_record.email == data[:email] return loop_record if loop_record.email == data[:email]
} }
elsif data[:locale] && data[:source] elsif data[:locale] && data[:source]
@ -673,7 +673,7 @@ returns
else else
where(locale: data[:locale], source: data[:source]) where(locale: data[:locale], source: data[:source])
end end
records.each {|loop_record| records.each { |loop_record|
return loop_record if loop_record.source == data[:source] return loop_record if loop_record.source == data[:source]
} }
end end
@ -727,7 +727,7 @@ returns
else else
where(name: data[:name]) where(name: data[:name])
end end
records.each {|loop_record| records.each { |loop_record|
if loop_record.name == data[:name] if loop_record.name == data[:name]
loop_record.update_attributes(data) loop_record.update_attributes(data)
return loop_record return loop_record
@ -744,7 +744,7 @@ returns
else else
where(login: data[:login]) where(login: data[:login])
end end
records.each {|loop_record| records.each { |loop_record|
if loop_record.login.casecmp(data[:login]).zero? if loop_record.login.casecmp(data[:login]).zero?
loop_record.update_attributes(data) loop_record.update_attributes(data)
return loop_record return loop_record
@ -761,7 +761,7 @@ returns
else else
where(email: data[:email]) where(email: data[:email])
end end
records.each {|loop_record| records.each { |loop_record|
if loop_record.email.casecmp(data[:email]).zero? if loop_record.email.casecmp(data[:email]).zero?
loop_record.update_attributes(data) loop_record.update_attributes(data)
return loop_record return loop_record
@ -778,7 +778,7 @@ returns
else else
where(locale: data[:locale]) where(locale: data[:locale])
end end
records.each {|loop_record| records.each { |loop_record|
if loop_record.locale.casecmp(data[:locale]).zero? if loop_record.locale.casecmp(data[:locale]).zero?
loop_record.update_attributes(data) loop_record.update_attributes(data)
return loop_record return loop_record
@ -1130,13 +1130,13 @@ log object update activity stream, if configured - will be executed automaticall
updated_by_id: true, updated_by_id: true,
} }
if self.class.activity_stream_support_config[:ignore_attributes] if self.class.activity_stream_support_config[:ignore_attributes]
self.class.activity_stream_support_config[:ignore_attributes].each {|key, value| self.class.activity_stream_support_config[:ignore_attributes].each { |key, value|
ignore_attributes[key] = value ignore_attributes[key] = value
} }
end end
log = false log = false
changes.each {|key, _value| changes.each { |key, _value|
# do not log created_at and updated_at attributes # do not log created_at and updated_at attributes
next if ignore_attributes[key.to_sym] == true next if ignore_attributes[key.to_sym] == true
@ -1217,7 +1217,7 @@ log object update history with all updated attributes, if configured - will be e
# new record also triggers update, so ignore new records # new record also triggers update, so ignore new records
changes = self.changes changes = self.changes
if history_changes_last_done if history_changes_last_done
history_changes_last_done.each {|key, value| history_changes_last_done.each { |key, value|
if changes.key?(key) && changes[key] == value if changes.key?(key) && changes[key] == value
changes.delete(key) changes.delete(key)
end end
@ -1236,12 +1236,12 @@ log object update history with all updated attributes, if configured - will be e
updated_by_id: true, updated_by_id: true,
} }
if self.class.history_support_config[:ignore_attributes] if self.class.history_support_config[:ignore_attributes]
self.class.history_support_config[:ignore_attributes].each {|key, value| self.class.history_support_config[:ignore_attributes].each { |key, value|
ignore_attributes[key] = value ignore_attributes[key] = value
} }
end end
changes.each {|key, value| changes.each { |key, value|
# do not log created_at and updated_at attributes # do not log created_at and updated_at attributes
next if ignore_attributes[key.to_sym] == true next if ignore_attributes[key.to_sym] == true
@ -1384,7 +1384,7 @@ get assets of object list
=end =end
def self.assets_of_object_list(list, assets = {}) def self.assets_of_object_list(list, assets = {})
list.each {|item| list.each { |item|
require item['object'].to_filename require item['object'].to_filename
record = Kernel.const_get(item['object']).find(item['o_id']) record = Kernel.const_get(item['object']).find(item['o_id'])
assets = record.assets(assets) assets = record.assets(assets)
@ -1414,7 +1414,7 @@ get assets and record_ids of selector
# get assets of condition # get assets of condition
models = Models.all models = Models.all
send(selector).each {|item, content| send(selector).each { |item, content|
attribute = item.split(/\./) attribute = item.split(/\./)
next if !attribute[1] next if !attribute[1]
begin begin
@ -1431,7 +1431,7 @@ get assets and record_ids of selector
next if !models[attribute_class][:reflections][reflection].klass next if !models[attribute_class][:reflections][reflection].klass
attribute_ref_class = models[attribute_class][:reflections][reflection].klass attribute_ref_class = models[attribute_class][:reflections][reflection].klass
if content['value'].class == Array if content['value'].class == Array
content['value'].each {|item_id| content['value'].each { |item_id|
attribute_object = attribute_ref_class.find_by(id: item_id) attribute_object = attribute_ref_class.find_by(id: item_id)
if attribute_object if attribute_object
assets = attribute_object.assets(assets) assets = attribute_object.assets(assets)
@ -1520,7 +1520,7 @@ check string/varchar size and cut them if needed
=end =end
def check_limits def check_limits
attributes.each {|attribute| attributes.each { |attribute|
next if !self[ attribute[0] ] next if !self[ attribute[0] ]
next if self[ attribute[0] ].class != String next if self[ attribute[0] ].class != String
next if self[ attribute[0] ].empty? next if self[ attribute[0] ].empty?

View file

@ -29,7 +29,7 @@ returns
end end
return data if !self['created_by_id'] && !self['updated_by_id'] return data if !self['created_by_id'] && !self['updated_by_id']
%w(created_by_id updated_by_id).each {|local_user_id| %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ] next if !self[ local_user_id ]
next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ] next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ]) user = User.lookup(id: self[ local_user_id ])

View file

@ -82,7 +82,7 @@ returns
# get related objects # get related objects
history = History.list(self.class.name, self['id'], nil, true) history = History.list(self.class.name, self['id'], nil, true)
history[:list].each {|item| history[:list].each { |item|
record = Kernel.const_get(item['object']).find(item['o_id']) record = Kernel.const_get(item['object']).find(item['o_id'])
history[:assets] = record.assets(history[:assets]) history[:assets] = record.assets(history[:assets])

View file

@ -20,7 +20,7 @@ returns
# default ignored attributes # default ignored attributes
ignore_attributes = {} ignore_attributes = {}
if self.class.search_index_support_config[:ignore_attributes] if self.class.search_index_support_config[:ignore_attributes]
self.class.search_index_support_config[:ignore_attributes].each {|key, value| self.class.search_index_support_config[:ignore_attributes].each { |key, value|
ignore_attributes[key] = value ignore_attributes[key] = value
} }
end end
@ -31,7 +31,7 @@ returns
# remove ignored attributes # remove ignored attributes
attributes = data.attributes attributes = data.attributes
ignore_attributes.each {|key, value| ignore_attributes.each { |key, value|
next if value != true next if value != true
attributes.delete(key.to_s) attributes.delete(key.to_s)
} }
@ -86,7 +86,7 @@ returns
def search_index_attribute_lookup(attributes, ref_object) def search_index_attribute_lookup(attributes, ref_object)
attributes_new = {} attributes_new = {}
attributes.each {|key, value| attributes.each { |key, value|
next if !value next if !value
# get attribute name # get attribute name

View file

@ -157,7 +157,7 @@ returns
'Venezuela' => 'en.ve', 'Venezuela' => 'en.ve',
} }
all_feeds = {} all_feeds = {}
gfeeds.each {|key, name| gfeeds.each { |key, name|
all_feeds["http://www.google.com/calendar/ical/#{name}%23holiday%40group.v.calendar.google.com/public/basic.ics"] = key all_feeds["http://www.google.com/calendar/ical/#{name}%23holiday%40group.v.calendar.google.com/public/basic.ics"] = key
} }
all_feeds all_feeds
@ -232,14 +232,14 @@ returns
end end
# remove old ical entries if feed has changed # remove old ical entries if feed has changed
public_holidays.each {|day, meta| public_holidays.each { |day, meta|
next if !public_holidays[day]['feed'] next if !public_holidays[day]['feed']
next if meta['feed'] == Digest::MD5.hexdigest(ical_url) next if meta['feed'] == Digest::MD5.hexdigest(ical_url)
public_holidays.delete(day) public_holidays.delete(day)
} }
# sync new ical feed dates # sync new ical feed dates
events.each {|day, summary| events.each { |day, summary|
if !public_holidays[day] if !public_holidays[day]
public_holidays[day] = {} public_holidays[day] = {}
end end
@ -280,7 +280,7 @@ returns
cals = Icalendar.parse(cal_file) cals = Icalendar.parse(cal_file)
cal = cals.first cal = cals.first
events = {} events = {}
cal.events.each {|event| cal.events.each { |event|
next if event.dtstart < Time.zone.now - 1.year next if event.dtstart < Time.zone.now - 1.year
next if event.dtstart > Time.zone.now + 3.years next if event.dtstart > Time.zone.now + 3.years
day = "#{event.dtstart.year}-#{format('%02d', event.dtstart.month)}-#{format('%02d', event.dtstart.day)}" day = "#{event.dtstart.year}-#{format('%02d', event.dtstart.month)}-#{format('%02d', event.dtstart.day)}"
@ -302,7 +302,7 @@ returns
# if changed calendar is default, set all others default to false # if changed calendar is default, set all others default to false
def sync_default def sync_default
return if !default return if !default
Calendar.all.each {|calendar| Calendar.all.each { |calendar|
next if calendar.id == id next if calendar.id == id
next if !calendar.default next if !calendar.default
calendar.default = false calendar.default = false
@ -312,7 +312,7 @@ returns
# check if min one is set to default true # check if min one is set to default true
def min_one_check def min_one_check
Calendar.all.each {|calendar| Calendar.all.each { |calendar|
return true if calendar.default return true if calendar.default
} }
first = Calendar.order(:created_at, :id).limit(1).first first = Calendar.order(:created_at, :id).limit(1).first
@ -320,7 +320,7 @@ returns
first.save first.save
# check if sla's are refer to an existing calendar # check if sla's are refer to an existing calendar
Sla.all.each {|sla| Sla.all.each { |sla|
if !sla.calendar_id if !sla.calendar_id
sla.calendar_id = first.id sla.calendar_id = first.id
sla.save sla.save
@ -342,7 +342,7 @@ returns
def validate_public_holidays def validate_public_holidays
# fillup feed info # fillup feed info
public_holidays.each {|day, meta| public_holidays.each { |day, meta|
if public_holidays_was && public_holidays_was[day] && public_holidays_was[day]['feed'] if public_holidays_was && public_holidays_was[day] && public_holidays_was[day]['feed']
meta['feed'] = public_holidays_was[day]['feed'] meta['feed'] = public_holidays_was[day]['feed']
end end

View file

@ -138,7 +138,7 @@ stream all accounts
logger.debug 'stream controll loop' logger.debug 'stream controll loop'
current_channels = [] current_channels = []
channels = Channel.where('active = ? AND area LIKE ?', true, '%::Account') channels = Channel.where('active = ? AND area LIKE ?', true, '%::Account')
channels.each {|channel| channels.each { |channel|
next if channel.options[:adapter] != 'twitter' next if channel.options[:adapter] != 'twitter'
current_channels.push channel.id current_channels.push channel.id
@ -181,7 +181,7 @@ stream all accounts
} }
# cleanup deleted channels # cleanup deleted channels
last_channels.each {|channel_id| last_channels.each { |channel_id|
next if !@@channel_stream[channel_id] next if !@@channel_stream[channel_id]
next if current_channels.include?(channel_id) next if current_channels.include?(channel_id)
logger.debug "channel (#{channel_id}) not longer active, stop thread" logger.debug "channel (#{channel_id}) not longer active, stop thread"

View file

@ -38,7 +38,7 @@ returns
end end
end end
if !access if !access
%w(inbound outbound).each {|key| %w(inbound outbound).each { |key|
if attributes['options'] && attributes['options'][key] && attributes['options'][key]['options'] if attributes['options'] && attributes['options'][key] && attributes['options'][key]['options']
attributes['options'][key]['options'].delete('password') attributes['options'][key]['options'].delete('password')
end end
@ -49,7 +49,7 @@ returns
end end
return data if !self['created_by_id'] && !self['updated_by_id'] return data if !self['created_by_id'] && !self['updated_by_id']
%w(created_by_id updated_by_id).each {|local_user_id| %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ] next if !self[ local_user_id ]
next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ] next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ]) user = User.lookup(id: self[ local_user_id ])

View file

@ -24,7 +24,7 @@ class Channel::Driver::Facebook
def send(options, fb_object_id, article, _notification = false) def send(options, fb_object_id, article, _notification = false)
access_token = nil access_token = nil
options['pages'].each {|page| options['pages'].each { |page|
next if page['id'].to_s != fb_object_id.to_s next if page['id'].to_s != fb_object_id.to_s
access_token = page['access_token'] access_token = page['access_token']
} }
@ -52,7 +52,7 @@ class Channel::Driver::Facebook
private private
def get_page(page_id) def get_page(page_id)
@pages.each {|page| @pages.each { |page|
return page if page['id'].to_s == page_id.to_s return page if page['id'].to_s == page_id.to_s
} }
nil nil
@ -62,7 +62,7 @@ class Channel::Driver::Facebook
return if !@sync return if !@sync
return if !@sync['pages'] return if !@sync['pages']
@sync['pages'].each {|page_to_sync_id, page_to_sync_params| @sync['pages'].each { |page_to_sync_id, page_to_sync_params|
page = get_page(page_to_sync_id) page = get_page(page_to_sync_id)
next if !page next if !page
next if !page_to_sync_params['group_id'] next if !page_to_sync_params['group_id']
@ -70,7 +70,7 @@ class Channel::Driver::Facebook
page_client = Facebook.new(page['access_token']) page_client = Facebook.new(page['access_token'])
posts = page_client.client.get_connection('me', 'feed', fields: 'id,from,to,message,created_time,comments') posts = page_client.client.get_connection('me', 'feed', fields: 'id,from,to,message,created_time,comments')
posts.each {|post| posts.each { |post|
page_client.to_group(post, page_to_sync_params['group_id'], @channel, page) page_client.to_group(post, page_to_sync_params['group_id'], @channel, page)
} }
} }

View file

@ -189,7 +189,7 @@ returns
filter = {} filter = {}
if sync['search'] if sync['search']
hashtags = [] hashtags = []
sync['search'].each {|item| sync['search'].each { |item|
hashtags.push item['term'] hashtags.push item['term']
} }
filter[:track] = hashtags.join(',') filter[:track] = hashtags.join(',')
@ -219,7 +219,7 @@ returns
if sync['mentions'] && sync['mentions']['group_id'] != '' if sync['mentions'] && sync['mentions']['group_id'] != ''
hit = false hit = false
if tweet.user_mentions if tweet.user_mentions
tweet.user_mentions.each {|user| tweet.user_mentions.each { |user|
if user.id.to_s == @channel.options['user']['id'].to_s if user.id.to_s == @channel.options['user']['id'].to_s
hit = true hit = true
end end
@ -234,8 +234,8 @@ returns
# check hashtags # check hashtags
if sync['search'] && tweet.hashtags if sync['search'] && tweet.hashtags
hit = false hit = false
sync['search'].each {|item| sync['search'].each { |item|
tweet.hashtags.each {|hashtag| tweet.hashtags.each { |hashtag|
next if item['term'] !~ /^#/ next if item['term'] !~ /^#/
if item['term'].sub(/^#/, '') == hashtag.text if item['term'].sub(/^#/, '') == hashtag.text
hit = item hit = item
@ -252,7 +252,7 @@ returns
if sync['search'] if sync['search']
hit = false hit = false
body = tweet.text body = tweet.text
sync['search'].each {|item| sync['search'].each { |item|
next if item['term'] =~ /^#/ next if item['term'] =~ /^#/
if body =~ /#{item['term']}/ if body =~ /#{item['term']}/
hit = item hit = item

View file

@ -280,7 +280,7 @@ class Channel::EmailParser
# check if sub parts are available # check if sub parts are available
if !file.parts.empty? if !file.parts.empty?
a = [] a = []
file.parts.each {|p| file.parts.each { |p|
attachment = _get_attachment(p, attachments, mail) attachment = _get_attachment(p, attachments, mail)
a.concat(attachment) a.concat(attachment)
} }
@ -324,10 +324,10 @@ class Channel::EmailParser
# generate file name # generate file name
if !filename || filename.empty? if !filename || filename.empty?
attachment_count = 0 attachment_count = 0
(1..1000).each {|count| (1..1000).each { |count|
filename_exists = false filename_exists = false
filename = 'file-' + count.to_s filename = 'file-' + count.to_s
attachments.each {|attachment| attachments.each { |attachment|
if attachment[:filename] == filename if attachment[:filename] == filename
filename_exists = true filename_exists = true
end end
@ -394,10 +394,10 @@ retrns
# run postmaster pre filter # run postmaster pre filter
UserInfo.current_user_id = 1 UserInfo.current_user_id = 1
filters = {} filters = {}
Setting.where(area: 'Postmaster::PreFilter').order(:name).each {|setting| Setting.where(area: 'Postmaster::PreFilter').order(:name).each { |setting|
filters[setting.name] = Kernel.const_get(Setting.get(setting.name)) filters[setting.name] = Kernel.const_get(Setting.get(setting.name))
} }
filters.each {|_prio, backend| filters.each { |_prio, backend|
Rails.logger.debug "run postmaster pre filter #{backend}" Rails.logger.debug "run postmaster pre filter #{backend}"
begin begin
backend.run(channel, mail) backend.run(channel, mail)
@ -550,10 +550,10 @@ retrns
# run postmaster post filter # run postmaster post filter
filters = {} filters = {}
Setting.where(area: 'Postmaster::PostFilter').order(:name).each {|setting| Setting.where(area: 'Postmaster::PostFilter').order(:name).each { |setting|
filters[setting.name] = Kernel.const_get(Setting.get(setting.name)) filters[setting.name] = Kernel.const_get(Setting.get(setting.name))
} }
filters.each {|_prio, backend| filters.each { |_prio, backend|
Rails.logger.debug "run postmaster post filter #{backend}" Rails.logger.debug "run postmaster post filter #{backend}"
begin begin
backend.run(channel, mail, ticket, article, user) backend.run(channel, mail, ticket, article, user)
@ -570,7 +570,7 @@ retrns
def set_attributes_by_x_headers(item_object, header_name, mail, suffix = false) def set_attributes_by_x_headers(item_object, header_name, mail, suffix = false)
# 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_by_id' next if key == 'updated_by_id'

View file

@ -9,7 +9,7 @@ module Channel::Filter::BounceCheck
return if !mail[:attachments] return if !mail[:attachments]
return if mail[ 'x-zammad-ticket-id'.to_sym ] return if mail[ 'x-zammad-ticket-id'.to_sym ]
mail[:attachments].each {|attachment| mail[:attachments].each { |attachment|
next if !attachment[:preferences] next if !attachment[:preferences]
next if attachment[:preferences]['Mime-Type'] != 'message/rfc822' next if attachment[:preferences]['Mime-Type'] != 'message/rfc822'
next if !attachment[:data] next if !attachment[:data]

View file

@ -7,11 +7,11 @@ module Channel::Filter::Database
# process postmaster filter # process postmaster filter
filters = PostmasterFilter.where( active: true, channel: 'email' ).order(:name, :created_at) filters = PostmasterFilter.where( active: true, channel: 'email' ).order(:name, :created_at)
filters.each {|filter| filters.each { |filter|
Rails.logger.info " proccess filter #{filter.name} ..." Rails.logger.info " proccess filter #{filter.name} ..."
all_matches_ok = true all_matches_ok = true
min_one_rule_exists = false min_one_rule_exists = false
filter[:match].each {|key, meta| filter[:match].each { |key, meta|
begin begin
next if !meta || !meta['value'] || meta['value'].empty? next if !meta || !meta['value'] || meta['value'].empty?
min_one_rule_exists = true min_one_rule_exists = true
@ -41,7 +41,7 @@ module Channel::Filter::Database
next if !min_one_rule_exists next if !min_one_rule_exists
next if !all_matches_ok next if !all_matches_ok
filter[:perform].each {|key, meta| filter[:perform].each { |key, meta|
Rails.logger.info " perform '#{key.downcase}' = '#{meta.inspect}'" Rails.logger.info " perform '#{key.downcase}' = '#{meta.inspect}'"
mail[ key.downcase.to_sym ] = meta['value'] mail[ key.downcase.to_sym ] = meta['value']
} }

View file

@ -28,7 +28,7 @@ module Channel::Filter::FollowUpCheck
# get ticket# from attachment # get ticket# from attachment
if setting.include?('attachment') && mail[:attachments] if setting.include?('attachment') && mail[:attachments]
mail[:attachments].each {|attachment| mail[:attachments].each { |attachment|
next if !attachment[:data] next if !attachment[:data]
ticket = Ticket::Number.check(attachment[:data]) ticket = Ticket::Number.check(attachment[:data])
next if !ticket next if !ticket
@ -54,7 +54,7 @@ module Channel::Filter::FollowUpCheck
end end
if references != '' if references != ''
message_ids = references.split(/\s+/) message_ids = references.split(/\s+/)
message_ids.each {|message_id| message_ids.each { |message_id|
message_id_md5 = Digest::MD5.hexdigest(message_id) message_id_md5 = Digest::MD5.hexdigest(message_id)
article = Ticket::Article.where(message_id_md5: message_id_md5).order('created_at DESC, id DESC').limit(1).first article = Ticket::Article.where(message_id_md5: message_id_md5).order('created_at DESC, id DESC').limit(1).first
next if !article next if !article

View file

@ -47,7 +47,7 @@ module Channel::Filter::IdentifySender
begin begin
next if !mail[item.to_sym].addrs next if !mail[item.to_sym].addrs
items = mail[item.to_sym].addrs items = mail[item.to_sym].addrs
items.each {|address_data| items.each { |address_data|
user_create( user_create(
firstname: address_data.display_name, firstname: address_data.display_name,
lastname: '', lastname: '',
@ -60,7 +60,7 @@ module Channel::Filter::IdentifySender
Rails.logger.error 'ERROR: ' + e.inspect Rails.logger.error 'ERROR: ' + e.inspect
Rails.logger.error 'ERROR: try it by my self' Rails.logger.error 'ERROR: try it by my self'
recipients = mail[item.to_sym].to_s.split(',') recipients = mail[item.to_sym].to_s.split(',')
recipients.each {|recipient| recipients.each { |recipient|
address = nil address = nil
display_name = nil display_name = nil
if recipient =~ /<(.+?)>/ if recipient =~ /<(.+?)>/

View file

@ -47,7 +47,7 @@ class Channel::Filter::MonitoringBase
# follow up detection by meta data # follow up detection by meta data
open_states = Ticket::State.by_category('open') open_states = Ticket::State.by_category('open')
Ticket.where(state: open_states).each {|ticket| Ticket.where(state: open_states).each { |ticket|
next if !ticket.preferences next if !ticket.preferences
next if !ticket.preferences['integration'] next if !ticket.preferences['integration']
next if ticket.preferences['integration'] != integration next if ticket.preferences['integration'] != integration
@ -77,7 +77,7 @@ class Channel::Filter::MonitoringBase
preferences = {} preferences = {}
preferences['integration'] = integration preferences['integration'] = integration
preferences[integration] = result preferences[integration] = result
preferences.each {|key, value| preferences.each { |key, value|
mail[ 'x-zammad-ticket-preferences'.to_sym ][key] = value mail[ 'x-zammad-ticket-preferences'.to_sym ][key] = value
} }
end end

View file

@ -7,7 +7,7 @@ module Channel::Filter::Trusted
# check if trust x-headers # check if trust x-headers
if !channel[:trusted] if !channel[:trusted]
mail.each {|key, _value| mail.each { |key, _value|
next if key !~ /^x-zammad/i next if key !~ /^x-zammad/i
mail.delete(key) mail.delete(key)
} }

View file

@ -65,16 +65,16 @@ class Chat < ApplicationModel
def self.agent_state(user_id) def self.agent_state(user_id)
return { state: 'chat_disabled' } if !Setting.get('chat') return { state: 'chat_disabled' } if !Setting.get('chat')
assets = {} assets = {}
Chat.where(active: true).each {|chat| Chat.where(active: true).each { |chat|
assets = chat.assets(assets) assets = chat.assets(assets)
} }
active_agent_ids = [] active_agent_ids = []
active_agents.each {|user| active_agents.each { |user|
active_agent_ids.push user.id active_agent_ids.push user.id
assets = user.assets(assets) assets = user.assets(assets)
} }
runningchat_session_list_local = running_chat_session_list runningchat_session_list_local = running_chat_session_list
runningchat_session_list_local.each {|session| runningchat_session_list_local.each { |session|
next if !session['user_id'] next if !session['user_id']
user = User.lookup(id: session['user_id']) user = User.lookup(id: session['user_id'])
next if !user next if !user
@ -107,7 +107,7 @@ class Chat < ApplicationModel
def self.waiting_chat_session_list def self.waiting_chat_session_list
sessions = [] sessions = []
Chat::Session.where(state: ['waiting']).each {|session| Chat::Session.where(state: ['waiting']).each { |session|
sessions.push session.attributes sessions.push session.attributes
} }
sessions sessions
@ -119,7 +119,7 @@ class Chat < ApplicationModel
def self.running_chat_session_list def self.running_chat_session_list
sessions = [] sessions = []
Chat::Session.where(state: ['running']).each {|session| Chat::Session.where(state: ['running']).each { |session|
sessions.push session.attributes sessions.push session.attributes
} }
sessions sessions
@ -131,7 +131,7 @@ class Chat < ApplicationModel
def self.available_agents(diff = 2.minutes) def self.available_agents(diff = 2.minutes)
agents = {} agents = {}
Chat::Agent.where(active: true).where('updated_at > ?', Time.zone.now - diff).each {|record| Chat::Agent.where(active: true).where('updated_at > ?', Time.zone.now - diff).each { |record|
agents[record.updated_by_id] = record.concurrent agents[record.updated_by_id] = record.concurrent
} }
agents agents
@ -143,7 +143,7 @@ class Chat < ApplicationModel
def self.active_agents(diff = 2.minutes) def self.active_agents(diff = 2.minutes)
users = [] users = []
Chat::Agent.where(active: true).where('updated_at > ?', Time.zone.now - diff).each {|record| Chat::Agent.where(active: true).where('updated_at > ?', Time.zone.now - diff).each { |record|
user = User.lookup(id: record.updated_by_id) user = User.lookup(id: record.updated_by_id)
next if !user next if !user
users.push user users.push user
@ -153,7 +153,7 @@ class Chat < ApplicationModel
def self.seads_total(diff = 2.minutes) def self.seads_total(diff = 2.minutes)
total = 0 total = 0
available_agents(diff).each {|_user_id, concurrent| available_agents(diff).each { |_user_id, concurrent|
total += concurrent total += concurrent
} }
total total
@ -178,7 +178,7 @@ optional you can ignore it for dedecated user
def self.broadcast_agent_state_update(ignore_user_id = nil) def self.broadcast_agent_state_update(ignore_user_id = nil)
# send broadcast to agents # send broadcast to agents
Chat::Agent.where('active = ? OR updated_at > ?', true, Time.zone.now - 8.hours).each {|item| Chat::Agent.where('active = ? OR updated_at > ?', true, Time.zone.now - 8.hours).each { |item|
next if item.updated_by_id == ignore_user_id next if item.updated_by_id == ignore_user_id
data = { data = {
event: 'chat_status_agent', event: 'chat_status_agent',
@ -200,7 +200,7 @@ broadcast new customer queue position to all waiting customers
# send position update to other waiting sessions # send position update to other waiting sessions
position = 0 position = 0
Chat::Session.where(state: 'waiting').order('created_at ASC').each {|local_chat_session| Chat::Session.where(state: 'waiting').order('created_at ASC').each { |local_chat_session|
position += 1 position += 1
data = { data = {
event: 'chat_session_queue', event: 'chat_session_queue',
@ -227,7 +227,7 @@ optional you can parse the max oldest chat entries
=end =end
def self.cleanup(diff = 3.months) def self.cleanup(diff = 3.months)
Chat::Session.where(state: 'closed').where('updated_at < ?', Time.zone.now - diff).each {|chat_session| Chat::Session.where(state: 'closed').where('updated_at < ?', Time.zone.now - diff).each { |chat_session|
Chat::Message.where(chat_session_id: chat_session.id).delete_all Chat::Message.where(chat_session_id: chat_session.id).delete_all
chat_session.destroy chat_session.destroy
} }
@ -248,7 +248,7 @@ optional you can parse the max oldest chat sessions
=end =end
def self.cleanup_close(diff = 5.minutes) def self.cleanup_close(diff = 5.minutes)
Chat::Session.where.not(state: 'closed').where('updated_at < ?', Time.zone.now - diff).each {|chat_session| Chat::Session.where.not(state: 'closed').where('updated_at < ?', Time.zone.now - diff).each { |chat_session|
next if chat_session.recipients_active? next if chat_session.recipients_active?
chat_session.state = 'closed' chat_session.state = 'closed'
chat_session.save chat_session.save

View file

@ -22,7 +22,7 @@ class Chat::Session < ApplicationModel
return true if !preferences return true if !preferences
return true if !preferences[:participants] return true if !preferences[:participants]
count = 0 count = 0
preferences[:participants].each {|client_id| preferences[:participants].each { |client_id|
next if !Sessions.session_exists?(client_id) next if !Sessions.session_exists?(client_id)
count += 1 count += 1
} }
@ -31,7 +31,7 @@ class Chat::Session < ApplicationModel
end end
def send_to_recipients(message, ignore_client_id = nil) def send_to_recipients(message, ignore_client_id = nil)
preferences[:participants].each {|local_client_id| preferences[:participants].each { |local_client_id|
next if local_client_id == ignore_client_id next if local_client_id == ignore_client_id
Sessions.send(local_client_id, message) Sessions.send(local_client_id, message)
} }
@ -41,7 +41,7 @@ class Chat::Session < ApplicationModel
def position def position
return if state != 'waiting' return if state != 'waiting'
position = 0 position = 0
Chat::Session.where(state: 'waiting').order('created_at ASC').each {|chat_session| Chat::Session.where(state: 'waiting').order('created_at ASC').each { |chat_session|
position += 1 position += 1
break if chat_session.id == id break if chat_session.id == id
} }
@ -60,7 +60,7 @@ class Chat::Session < ApplicationModel
def self.active_chats_by_user_id(user_id) def self.active_chats_by_user_id(user_id)
actice_sessions = [] actice_sessions = []
Chat::Session.where(state: 'running', user_id: user_id).order('created_at ASC').each {|session| Chat::Session.where(state: 'running', user_id: user_id).order('created_at ASC').each { |session|
session_attributes = session.attributes session_attributes = session.attributes
session_attributes['messages'] = [] session_attributes['messages'] = []
Chat::Message.where(chat_session_id: session.id).each { |message| Chat::Message.where(chat_session_id: session.id).each { |message|

View file

@ -79,7 +79,7 @@ returns
map = config map = config
level = nil level = nil
model = nil model = nil
map.each {|item| map.each { |item|
next if item[:model] != record.class next if item[:model] != record.class
level = item[:level] level = item[:level]
model = item[:model] model = item[:model]
@ -114,7 +114,7 @@ returns
# get caller ids # get caller ids
caller_ids = [] caller_ids = []
attributes = record.attributes attributes = record.attributes
attributes.each {|_attribute, value| attributes.each { |_attribute, value|
next if value.class != String next if value.class != String
next if value.empty? next if value.empty?
local_caller_ids = Cti::CallerId.parse_text(value) local_caller_ids = Cti::CallerId.parse_text(value)
@ -124,7 +124,7 @@ returns
# store caller ids # store caller ids
Cti::CallerId.where(object: model.to_s, o_id: record.id).destroy_all Cti::CallerId.where(object: model.to_s, o_id: record.id).destroy_all
caller_ids.each {|caller_id| caller_ids.each { |caller_id|
Cti::CallerId.maybe_add( Cti::CallerId.maybe_add(
caller_id: caller_id, caller_id: caller_id,
level: level, level: level,
@ -145,7 +145,7 @@ returns
def self.rebuild def self.rebuild
Cti::CallerId.delete_all Cti::CallerId.delete_all
map = config map = config
map.each {|item| map.each { |item|
level = item[:level] level = item[:level]
model = item[:model] model = item[:model]
item[:model].find_each(batch_size: 500) do |record| item[:model].find_each(batch_size: 500) do |record|

View file

@ -235,11 +235,11 @@ returns
# add assets # add assets
assets = {} assets = {}
list.each {|item| list.each { |item|
next if !item.preferences next if !item.preferences
%w(from to).each {|direction| %w(from to).each { |direction|
next if !item.preferences[direction] next if !item.preferences[direction]
item.preferences[direction].each {|caller_id| item.preferences[direction].each { |caller_id|
next if !caller_id['user_id'] next if !caller_id['user_id']
user = User.lookup(id: caller_id['user_id']) user = User.lookup(id: caller_id['user_id'])
next if !user next if !user
@ -256,7 +256,7 @@ returns
def push_event def push_event
users = User.of_role('CTI') users = User.of_role('CTI')
users.each {|user| users.each { |user|
# send notify about event # send notify about event
Sessions.send_to( Sessions.send_to(
@ -273,7 +273,7 @@ returns
list = Cti::Log.log list = Cti::Log.log
users = User.of_role('CTI') users = User.of_role('CTI')
users.each {|user| users.each { |user|
# send notify on create/update/delete # send notify on create/update/delete
Sessions.send_to( Sessions.send_to(

View file

@ -23,7 +23,7 @@ check and if channel not exists reset configured channels for email addresses
=end =end
def self.channel_cleanup def self.channel_cleanup
EmailAddress.all.each {|email_address| EmailAddress.all.each { |email_address|
# set to active if channel exists # set to active if channel exists
if email_address.channel_id && Channel.find_by(id: email_address.channel_id) if email_address.channel_id && Channel.find_by(id: email_address.channel_id)

View file

@ -34,7 +34,7 @@ returns
data = assets_of_selector('condition', data) data = assets_of_selector('condition', data)
data = assets_of_selector('perform', data) data = assets_of_selector('perform', data)
end end
%w(created_by_id updated_by_id).each {|local_user_id| %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ] next if !self[ local_user_id ]
next if data[ User.to_app_model ][ self[ local_user_id ] ] next if data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ]) user = User.lookup(id: self[ local_user_id ])

View file

@ -140,7 +140,7 @@ class Link < ApplicationModel
) )
# touch references # touch references
links.each {|link| links.each { |link|
link.destroy link.destroy
touch_reference_by_params( touch_reference_by_params(
object: Link::Object.lookup(id: link.link_object_source_id).name, object: Link::Object.lookup(id: link.link_object_source_id).name,
@ -166,7 +166,7 @@ class Link < ApplicationModel
) )
# touch references # touch references
links.each {|link| links.each { |link|
link.destroy link.destroy
touch_reference_by_params( touch_reference_by_params(
object: Link::Object.lookup(id: link.link_object_source_id).name, object: Link::Object.lookup(id: link.link_object_source_id).name,

View file

@ -30,7 +30,7 @@ class Locale < ApplicationModel
raise "Can't load locales from #{url}: #{result.error}" if !result.success? raise "Can't load locales from #{url}: #{result.error}" if !result.success?
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
result.data.each {|locale| result.data.each { |locale|
exists = Locale.find_by(locale: locale['locale']) exists = Locale.find_by(locale: locale['locale'])
if exists if exists
exists.update(locale.symbolize_keys!) exists.update(locale.symbolize_keys!)

View file

@ -27,7 +27,7 @@ list of all attributes
result = ObjectManager::Attribute.all.order('position ASC, name ASC') result = ObjectManager::Attribute.all.order('position ASC, name ASC')
attributes = [] attributes = []
assets = {} assets = {}
result.each {|item| result.each { |item|
attribute = item.attributes attribute = item.attributes
attribute[:object] = ObjectLookup.by_id(item.object_lookup_id) attribute[:object] = ObjectLookup.by_id(item.object_lookup_id)
attribute.delete('object_lookup_id') attribute.delete('object_lookup_id')
@ -240,7 +240,7 @@ possible types
end end
# update attributes # update attributes
data.each {|key, value| data.each { |key, value|
record[key.to_sym] = value record[key.to_sym] = value
} }
@ -376,7 +376,7 @@ returns:
to_delete: false, to_delete: false,
).order('position ASC, name ASC') ).order('position ASC, name ASC')
attributes = [] attributes = []
result.each {|item| result.each { |item|
data = { data = {
name: item.name, name: item.name,
display: item.display, display: item.display,
@ -385,9 +385,9 @@ 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-'
data[:screen][screen] = options data[:screen][screen] = options
elsif user && user.role?(role) elsif user && user.role?(role)
@ -423,7 +423,7 @@ returns:
def self.by_object_as_hash(object, user) def self.by_object_as_hash(object, user)
list = by_object(object, user) list = by_object(object, user)
hash = {} hash = {}
list.each {|item| list.each { |item|
hash[ item[:name] ] = item hash[ item[:name] ] = item
} }
hash hash
@ -443,7 +443,7 @@ returns
def self.discard_changes def self.discard_changes
ObjectManager::Attribute.where('to_create = ?', true).each(&:destroy) ObjectManager::Attribute.where('to_create = ?', true).each(&:destroy)
ObjectManager::Attribute.where('to_delete = ? OR to_config = ?', true, true).each {|attribute| ObjectManager::Attribute.where('to_delete = ? OR to_config = ?', true, true).each { |attribute|
attribute.to_migrate = false attribute.to_migrate = false
attribute.to_delete = false attribute.to_delete = false
attribute.to_config = false attribute.to_config = false
@ -507,7 +507,7 @@ to send no browser reload event, pass false
# check if field already exists # check if field already exists
execute_db_count = 0 execute_db_count = 0
execute_config_count = 0 execute_config_count = 0
migrations.each {|attribute| migrations.each { |attribute|
model = Kernel.const_get(attribute.object_lookup.name) model = Kernel.const_get(attribute.object_lookup.name)
# remove field # remove field
@ -701,7 +701,7 @@ to send no browser reload event, pass false
end end
if data_type == 'integer' if data_type == 'integer'
[:min, :max].each {|item| [:min, :max].each { |item|
raise "Need data_option[#{item.inspect}] param" if !data_option[item] raise "Need data_option[#{item.inspect}] param" if !data_option[item]
raise "Invalid data_option[#{item.inspect}] param #{data_option[item]}" if data_option[item].to_s !~ /^\d+?$/ raise "Invalid data_option[#{item.inspect}] param #{data_option[item]}" if data_option[item].to_s !~ /^\d+?$/
} }

View file

@ -24,7 +24,7 @@ class Observer::Organization::RefObjectTouch < ActiveRecord::Observer
Ticket.select('id').where( organization_id: record.id ).each(&:touch) Ticket.select('id').where( organization_id: record.id ).each(&:touch)
# touch current members # touch current members
record.member_ids.uniq.each {|user_id| record.member_ids.uniq.each { |user_id|
User.find(user_id).touch User.find(user_id).touch
} }
end end

View file

@ -31,7 +31,7 @@ class Observer::Sla::TicketRebuildEscalation < ActiveRecord::Observer
# check if condition has changed # check if condition has changed
changed = false changed = false
%w(condition calendar_id first_response_time update_time solution_time).each {|item| %w(condition calendar_id first_response_time update_time solution_time).each { |item|
next if !record.changes[item] next if !record.changes[item]
next if record.changes[item][0] == record.changes[item][1] next if record.changes[item][0] == record.changes[item][1]
changed = true changed = true

View file

@ -48,7 +48,7 @@ class Observer::Ticket::Article::CommunicateTwitter::BackgroundJob
if tweet.user_mentions if tweet.user_mentions
to = '' to = ''
twitter_mention_ids = [] twitter_mention_ids = []
tweet.user_mentions.each {|user| tweet.user_mentions.each { |user|
if to != '' if to != ''
to += ' ' to += ' '
end end

View file

@ -9,7 +9,7 @@ class Observer::Ticket::OnlineNotificationSeen::BackgroundJob
# set all online notifications to seen # set all online notifications to seen
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
ticket = Ticket.lookup(id: @ticket_id) ticket = Ticket.lookup(id: @ticket_id)
OnlineNotification.list_by_object('Ticket', @ticket_id).each {|notification| OnlineNotification.list_by_object('Ticket', @ticket_id).each { |notification|
next if notification.seen next if notification.seen
seen = ticket.online_notification_seen_state(notification.user_id) seen = ticket.online_notification_seen_state(notification.user_id)
next if !seen next if !seen

View file

@ -28,18 +28,18 @@ class Observer::Transaction < ActiveRecord::Observer
# get asyn backends # get asyn backends
sync_backends = [] sync_backends = []
Setting.where(area: 'Transaction::Backend::Sync').order(:name).each {|setting| Setting.where(area: 'Transaction::Backend::Sync').order(:name).each { |setting|
backend = Setting.get(setting.name) backend = Setting.get(setting.name)
sync_backends.push Kernel.const_get(backend) sync_backends.push Kernel.const_get(backend)
} }
# get uniq objects # get uniq objects
list_objects = get_uniq_changes(list) list_objects = get_uniq_changes(list)
list_objects.each {|_object, objects| list_objects.each { |_object, objects|
objects.each {|_id, item| objects.each { |_id, item|
# execute sync backends # execute sync backends
sync_backends.each {|backend| sync_backends.each { |backend|
execute_singel_backend(backend, item, params) execute_singel_backend(backend, item, params)
} }
@ -150,7 +150,7 @@ class Observer::Transaction < ActiveRecord::Observer
if !store[:changes] if !store[:changes]
store[:changes] = event[:changes] store[:changes] = event[:changes]
else else
event[:changes].each {|key, value| event[:changes].each { |key, value|
if !store[:changes][key] if !store[:changes][key]
store[:changes][key] = value store[:changes][key] = value
else else
@ -190,7 +190,7 @@ class Observer::Transaction < ActiveRecord::Observer
# ignore certain attributes # ignore certain attributes
real_changes = {} real_changes = {}
record.changes.each {|key, value| record.changes.each { |key, value|
next if key == 'updated_at' next if key == 'updated_at'
next if key == 'first_response' next if key == 'first_response'
next if key == 'close_time' next if key == 'close_time'

View file

@ -38,7 +38,7 @@ class Observer::User::RefObjectTouch < ActiveRecord::Observer
end end
# touch old/current customer # touch old/current customer
member_ids.uniq.each {|user_id| member_ids.uniq.each { |user_id|
if user_id != record.id if user_id != record.id
User.find(user_id).touch User.find(user_id).touch
end end

View file

@ -19,7 +19,7 @@ class Observer::User::TicketOrganization < ActiveRecord::Observer
# update last 100 tickets of user # update last 100 tickets of user
tickets = Ticket.where(customer_id: record.id).limit(100) tickets = Ticket.where(customer_id: record.id).limit(100)
tickets.each {|ticket| tickets.each { |ticket|
if ticket.organization_id != record.organization_id if ticket.organization_id != record.organization_id
ticket.organization_id = record.organization_id ticket.organization_id = record.organization_id
ticket.save ticket.save

View file

@ -218,7 +218,7 @@ returns:
def self.all_seen?(object, o_id) def self.all_seen?(object, o_id)
notifications = OnlineNotification.list_by_object(object, o_id) notifications = OnlineNotification.list_by_object(object, o_id)
notifications.each {|onine_notification| notifications.each { |onine_notification|
return false if !onine_notification['seen'] return false if !onine_notification['seen']
} }
true true
@ -240,7 +240,7 @@ returns:
def self.exists?(user, object, o_id, type, created_by_user, seen) def self.exists?(user, object, o_id, type, created_by_user, seen)
# rubocop:enable Metrics/ParameterLists # rubocop:enable Metrics/ParameterLists
notifications = OnlineNotification.list(user, 10) notifications = OnlineNotification.list(user, 10)
notifications.each {|notification| notifications.each { |notification|
next if notification['o_id'] != o_id next if notification['o_id'] != o_id
next if notification['object'] != object next if notification['object'] != object
next if notification['type'] != type next if notification['type'] != type
@ -269,7 +269,7 @@ with dedicated times
def self.cleanup(max_age = Time.zone.now - 9.months, max_own_seen = Time.zone.now - 10.minutes, max_auto_seen = Time.zone.now - 8.hours) def self.cleanup(max_age = Time.zone.now - 9.months, max_own_seen = Time.zone.now - 10.minutes, max_auto_seen = Time.zone.now - 8.hours)
OnlineNotification.where('created_at < ?', max_age).delete_all OnlineNotification.where('created_at < ?', max_age).delete_all
OnlineNotification.where('seen = ? AND updated_at < ?', true, max_own_seen).each {|notification| OnlineNotification.where('seen = ? AND updated_at < ?', true, max_own_seen).each { |notification|
# delete own "seen" notificatons after 1 hour # delete own "seen" notificatons after 1 hour
next if notification.user_id == notification.updated_by_id && notification.updated_at > max_own_seen next if notification.user_id == notification.updated_by_id && notification.updated_at > max_own_seen
@ -281,7 +281,7 @@ with dedicated times
} }
# notify all agents # notify all agents
User.of_role('Agent').each {|user| User.of_role('Agent').each { |user|
Sessions.send_to( Sessions.send_to(
user.id, user.id,
{ {

View file

@ -45,7 +45,7 @@ returns
end end
local_attributes['member_ids'] = local_member_ids local_attributes['member_ids'] = local_member_ids
if local_member_ids if local_member_ids
local_member_ids.each {|local_user_id| local_member_ids.each { |local_user_id|
next if data[ User.to_app_model ][ local_user_id ] next if data[ User.to_app_model ][ local_user_id ]
user = User.lookup(id: local_user_id) user = User.lookup(id: local_user_id)
next if !user next if !user
@ -55,7 +55,7 @@ returns
data[ Organization.to_app_model ][ id ] = local_attributes data[ Organization.to_app_model ][ id ] = local_attributes
end end
%w(created_by_id updated_by_id).each {|local_user_id| %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ] next if !self[ local_user_id ]
next if data[ User.to_app_model ][ self[ local_user_id ] ] next if data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ]) user = User.lookup(id: self[ local_user_id ])

View file

@ -78,9 +78,9 @@ returns
organizations_by_user = Organization.select('DISTINCT(organizations.id), organizations.name').joins('LEFT OUTER JOIN users ON users.organization_id = organizations.id').where( organizations_by_user = Organization.select('DISTINCT(organizations.id), organizations.name').joins('LEFT OUTER JOIN users ON users.organization_id = organizations.id').where(
'users.firstname LIKE ? or users.lastname LIKE ? or users.email LIKE ?', "%#{query}%", "%#{query}%", "%#{query}%" 'users.firstname LIKE ? or users.lastname LIKE ? or users.email LIKE ?', "%#{query}%", "%#{query}%", "%#{query}%"
).order('organizations.name').limit(limit) ).order('organizations.name').limit(limit)
organizations_by_user.each {|organization_by_user| organizations_by_user.each { |organization_by_user|
organization_exists = false organization_exists = false
organizations.each {|organization| organizations.each { |organization|
if organization.id == organization_by_user.id if organization.id == organization_by_user.id
organization_exists = true organization_exists = true
end end

View file

@ -18,7 +18,7 @@ returns
def search_index_attribute_lookup(attributes, ref_object) def search_index_attribute_lookup(attributes, ref_object)
attributes_new = {} attributes_new = {}
attributes.each {|key, value| attributes.each { |key, value|
next if !value next if !value
# get attribute name # get attribute name

View file

@ -32,7 +32,7 @@ returns
if !data[ Overview.to_app_model ][ id ] if !data[ Overview.to_app_model ][ id ]
data[ Overview.to_app_model ][ id ] = attributes_with_associations data[ Overview.to_app_model ][ id ] = attributes_with_associations
if user_ids if user_ids
user_ids.each {|local_user_id| user_ids.each { |local_user_id|
next if data[ User.to_app_model ][ local_user_id ] next if data[ User.to_app_model ][ local_user_id ]
user = User.lookup(id: local_user_id) user = User.lookup(id: local_user_id)
next if !user next if !user
@ -43,7 +43,7 @@ returns
data = assets_of_selector('condition', data) data = assets_of_selector('condition', data)
end end
%w(created_by_id updated_by_id).each {|local_user_id| %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ] next if !self[ local_user_id ]
next if data[ User.to_app_model ][ self[ local_user_id ] ] next if data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ]) user = User.lookup(id: self[ local_user_id ])

View file

@ -65,7 +65,7 @@ install all packages located under auto_install/*.zpm
data.push entry data.push entry
end end
end end
data.each {|file| data.each { |file|
install(file: "#{path}/#{file}") install(file: "#{path}/#{file}")
} }
data data
@ -370,7 +370,7 @@ execute all pending package migrations at once
=end =end
def self.migration_execute def self.migration_execute
Package.all.each {|package| Package.all.each { |package|
json_file = Package._get_bin(package.name, package.version) json_file = Package._get_bin(package.name, package.version)
package = JSON.parse(json_file) package = JSON.parse(json_file)
Package::Migration.migrate(package['name']) Package::Migration.migrate(package['name'])
@ -435,16 +435,16 @@ execute all pending package migrations at once
# check if directories need to be created # check if directories need to be created
directories = location.split '/' directories = location.split '/'
(0..(directories.length - 2) ).each {|position| (0..(directories.length - 2) ).each { |position|
tmp_path = '' tmp_path = ''
(1..position).each {|count| (1..position).each { |count|
tmp_path = "#{tmp_path}/#{directories[count]}" tmp_path = "#{tmp_path}/#{directories[count]}"
} }
next if tmp_path == '' next if tmp_path == ''
next if File.exist?(tmp_path) next if File.exist?(tmp_path)
Dir.mkdir(tmp_path, 0755) Dir.mkdir(tmp_path, 0o755)
} }
# install file # install file
@ -490,7 +490,7 @@ execute all pending package migrations at once
# get existing migrations # get existing migrations
migrations_existing = [] migrations_existing = []
Dir.foreach(location) {|entry| Dir.foreach(location) { |entry|
next if entry == '.' next if entry == '.'
next if entry == '..' next if entry == '..'
migrations_existing.push entry migrations_existing.push entry
@ -504,7 +504,7 @@ execute all pending package migrations at once
migrations_existing = migrations_existing.reverse migrations_existing = migrations_existing.reverse
end end
migrations_existing.each {|migration| migrations_existing.each { |migration|
next if migration !~ /\.rb$/ next if migration !~ /\.rb$/
version = nil version = nil
name = nil name = nil

View file

@ -302,8 +302,8 @@ class Report
] ]
config[:metric][:communication][:backend] = backend config[:metric][:communication][:backend] = backend
config[:metric].each {|metric_key, metric_value| config[:metric].each { |metric_key, metric_value|
metric_value[:backend].each {|metric_backend| metric_value[:backend].each { |metric_backend|
metric_backend[:name] = "#{metric_key}::#{metric_backend[:name]}" metric_backend[:name] = "#{metric_key}::#{metric_backend[:name]}"
} }
} }

View file

@ -27,7 +27,7 @@ class Scheduler < ApplicationModel
# read/load jobs and check if it is alredy started # read/load jobs and check if it is alredy started
jobs = Scheduler.where('active = ?', true).order('prio ASC') jobs = Scheduler.where('active = ?', true).order('prio ASC')
jobs.each {|job| jobs.each { |job|
# ignore job is still running # ignore job is still running
next if @@jobs_started[ job.id ] next if @@jobs_started[ job.id ]

View file

@ -39,7 +39,7 @@ returns
end end
end end
end end
%w(created_by_id updated_by_id).each {|local_user_id| %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ] next if !self[ local_user_id ]
next if data[ User.to_app_model ][ self[ local_user_id ] ] next if data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ]) user = User.lookup(id: self[ local_user_id ])

View file

@ -78,7 +78,7 @@ in case of fixing sha hash use:
def self.verify(fix_it = nil) def self.verify(fix_it = nil)
success = true success = true
Store::File.all.each {|item| Store::File.all.each { |item|
content = item.content content = item.content
sha = Digest::SHA256.hexdigest(content) sha = Digest::SHA256.hexdigest(content)
logger.info "CHECK: Store::File.find(#{item.id})" logger.info "CHECK: Store::File.find(#{item.id})"
@ -112,7 +112,7 @@ move files from db backend to fs
adapter_source = load_adapter("Store::Provider::#{source}") adapter_source = load_adapter("Store::Provider::#{source}")
adapter_target = load_adapter("Store::Provider::#{target}") adapter_target = load_adapter("Store::Provider::#{target}")
Store::File.all.each {|item| Store::File.all.each { |item|
next if item.provider == target next if item.provider == target
content = item.content content = item.content

View file

@ -53,7 +53,7 @@ class Store::Provider::File
# check if dir need to be removed # check if dir need to be removed
base = "#{Rails.root}/storage/fs" base = "#{Rails.root}/storage/fs"
locations = location.split('/') locations = location.split('/')
(0..locations.count).reverse_each {|count| (0..locations.count).reverse_each { |count|
local_location = locations[0, count].join('/') local_location = locations[0, count].join('/')
break if local_location =~ %r{storage/fs/{0,4}$} break if local_location =~ %r{storage/fs/{0,4}$}
break if !Dir["#{local_location}/*"].empty? break if !Dir["#{local_location}/*"].empty?
@ -71,17 +71,17 @@ class Store::Provider::File
length2 = 5 length2 = 5
length3 = 7 length3 = 7
last_position = 0 last_position = 0
(0..1).each {|_count| (0..1).each { |_count|
end_position = last_position + length1 end_position = last_position + length1
parts.push sha[last_position, length1] parts.push sha[last_position, length1]
last_position = end_position last_position = end_position
} }
(0..1).each {|_count| (0..1).each { |_count|
end_position = last_position + length2 end_position = last_position + length2
parts.push sha[last_position, length2] parts.push sha[last_position, length2]
last_position = end_position last_position = end_position
} }
(0..1).each {|_count| (0..1).each { |_count|
end_position = last_position + length3 end_position = last_position + length3
parts.push sha[last_position, length3] parts.push sha[last_position, length3]
last_position = end_position last_position = end_position

View file

@ -116,7 +116,7 @@ returns
o_id: data[:o_id], o_id: data[:o_id],
) )
tags = [] tags = []
tag_search.each {|tag| tag_search.each { |tag|
tag_item = Tag::Item.lookup(id: tag.tag_item_id) tag_item = Tag::Item.lookup(id: tag.tag_item_id)
next if !tag_item next if !tag_item
tags.push tag_item.name tags.push tag_item.name
@ -189,7 +189,7 @@ rename tag items
if already_existing_tag if already_existing_tag
# re-assign old tag to already existing tag # re-assign old tag to already existing tag
Tag.where(tag_item_id: old_tag_item.id).each {|tag| Tag.where(tag_item_id: old_tag_item.id).each { |tag|
# check if tag already exists on object # check if tag already exists on object
if Tag.find_by(tag_object_id: tag.tag_object_id, o_id: tag.o_id, tag_item_id: already_existing_tag.id) if Tag.find_by(tag_object_id: tag.tag_object_id, o_id: tag.o_id, tag_item_id: already_existing_tag.id)
@ -223,7 +223,7 @@ rename tag items
old_tag_item.save old_tag_item.save
# touch reference objects # touch reference objects
Tag.where(tag_item_id: old_tag_item.id).each {|tag| Tag.where(tag_item_id: old_tag_item.id).each { |tag|
tag_object = Tag::Object.lookup(id: tag.tag_object_id) tag_object = Tag::Object.lookup(id: tag.tag_object_id)
Tag.touch_reference_by_params( Tag.touch_reference_by_params(
object: tag_object.name, object: tag_object.name,
@ -246,7 +246,7 @@ remove tag item (destroy with reverences)
def self.remove(id) def self.remove(id)
# search for references, destroy and touch # search for references, destroy and touch
Tag.where(tag_item_id: id).each {|tag| Tag.where(tag_item_id: id).each { |tag|
tag_object = Tag::Object.lookup(id: tag.tag_object_id) tag_object = Tag::Object.lookup(id: tag.tag_object_id)
tag.destroy tag.destroy
Tag.touch_reference_by_params( Tag.touch_reference_by_params(

View file

@ -221,7 +221,7 @@ returns
tickets = where('escalation_time <= ?', Time.zone.now + 15.minutes) tickets = where('escalation_time <= ?', Time.zone.now + 15.minutes)
tickets.each {|ticket| tickets.each { |ticket|
# get sla # get sla
sla = ticket.escalation_calculation_get_sla sla = ticket.escalation_calculation_get_sla
@ -452,7 +452,7 @@ condition example
# get tables to join # get tables to join
tables = '' tables = ''
selectors.each {|attribute, selector| selectors.each { |attribute, selector|
selector = attribute.split(/\./) selector = attribute.split(/\./)
next if !selector[1] next if !selector[1]
next if selector[0] == 'ticket' next if selector[0] == 'ticket'
@ -478,7 +478,7 @@ condition example
} }
# add conditions # add conditions
selectors.each {|attribute, selector_raw| selectors.each { |attribute, selector_raw|
# validation # validation
raise "Invalid selector #{selector_raw.inspect}" if !selector_raw raise "Invalid selector #{selector_raw.inspect}" if !selector_raw
@ -673,7 +673,7 @@ perform changes on ticket
end end
recipient_string = '' recipient_string = ''
recipient_already = {} recipient_already = {}
recipients.each {|user| recipients.each { |user|
# send notifications only to email adresses # send notifications only to email adresses
next if !user.email next if !user.email
@ -784,7 +784,7 @@ perform changes on ticket
next if value['value'].empty? next if value['value'].empty?
tags = value['value'].split(/,/) tags = value['value'].split(/,/)
if value['operator'] == 'add' if value['operator'] == 'add'
tags.each {|tag| tags.each { |tag|
Tag.tag_add( Tag.tag_add(
object: 'Ticket', object: 'Ticket',
o_id: id, o_id: id,
@ -792,7 +792,7 @@ perform changes on ticket
) )
} }
elsif value['operator'] == 'remove' elsif value['operator'] == 'remove'
tags.each {|tag| tags.each { |tag|
Tag.tag_remove( Tag.tag_remove(
object: 'Ticket', object: 'Ticket',
o_id: id, o_id: id,
@ -838,7 +838,7 @@ result
def get_references(ignore = []) def get_references(ignore = [])
references = [] references = []
Ticket::Article.select('in_reply_to, message_id').where(ticket_id: id).each {|article| Ticket::Article.select('in_reply_to, message_id').where(ticket_id: id).each { |article|
if !article.in_reply_to.empty? if !article.in_reply_to.empty?
references.push article.in_reply_to references.push article.in_reply_to
end end
@ -846,7 +846,7 @@ result
next if article.message_id.empty? next if article.message_id.empty?
references.push article.message_id references.push article.message_id
} }
ignore.each {|item| ignore.each { |item|
references.delete(item) references.delete(item)
} }
references references

View file

@ -48,7 +48,7 @@ class Ticket::Article < ApplicationModel
replace = item replace = item
# look for attachment # look for attachment
attachments.each {|file| attachments.each { |file|
next if !file.preferences['Content-ID'] || file.preferences['Content-ID'] != $3 next if !file.preferences['Content-ID'] || file.preferences['Content-ID'] != $3
replace = "#{$1}/api/v1/ticket_attachment/#{article['ticket_id']}/#{article['id']}/#{file.id}#{$4}" replace = "#{$1}/api/v1/ticket_attachment/#{article['ticket_id']}/#{article['id']}/#{file.id}#{$4}"
inline_attachments[file.id] = true inline_attachments[file.id] = true
@ -57,7 +57,7 @@ class Ticket::Article < ApplicationModel
replace replace
} }
new_attachments = [] new_attachments = []
attachments.each {|file| attachments.each { |file|
next if inline_attachments[file.id] next if inline_attachments[file.id]
new_attachments.push file new_attachments.push file
} }

View file

@ -55,7 +55,7 @@ returns
end end
end end
%w(created_by_id updated_by_id).each {|local_user_id| %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ] next if !self[ local_user_id ]
next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ] next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ]) user = User.lookup(id: self[ local_user_id ])

View file

@ -28,7 +28,7 @@ returns
if !data[ Ticket.to_app_model ][ id ] if !data[ Ticket.to_app_model ][ id ]
data[ Ticket.to_app_model ][ id ] = attributes_with_associations data[ Ticket.to_app_model ][ id ] = attributes_with_associations
end end
%w(created_by_id updated_by_id owner_id customer_id).each {|local_user_id| %w(created_by_id updated_by_id owner_id customer_id).each { |local_user_id|
next if !self[ local_user_id ] next if !self[ local_user_id ]
next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ] next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ]) user = User.lookup(id: self[ local_user_id ])

View file

@ -72,11 +72,11 @@ returns
# get business hours # get business hours
hours = {} hours = {}
calendar.business_hours.each {|day, meta| calendar.business_hours.each { |day, meta|
next if !meta[:active] next if !meta[:active]
next if !meta[:timeframes] next if !meta[:timeframes]
hours[day.to_sym] = {} hours[day.to_sym] = {}
meta[:timeframes].each {|frame| meta[:timeframes].each { |frame|
next if !frame[0] next if !frame[0]
next if !frame[1] next if !frame[1]
hours[day.to_sym][frame[0]] = frame[1] hours[day.to_sym][frame[0]] = frame[1]
@ -90,7 +90,7 @@ returns
# get holidays # get holidays
holidays = [] holidays = []
if calendar.public_holidays if calendar.public_holidays
calendar.public_holidays.each {|day, meta| calendar.public_holidays.each { |day, meta|
next if !meta next if !meta
next if !meta['active'] next if !meta['active']
next if meta['removed'] next if meta['removed']
@ -212,7 +212,7 @@ returns
sla_list = Sla.all.order(:name, :created_at) sla_list = Sla.all.order(:name, :created_at)
Cache.write('SLA::List::Active', sla_list, { expires_in: 1.hour }) Cache.write('SLA::List::Active', sla_list, { expires_in: 1.hour })
end end
sla_list.each {|sla| sla_list.each { |sla|
if !sla.condition || sla.condition.empty? if !sla.condition || sla.condition.empty?
sla_selected = sla sla_selected = sla
elsif sla.condition elsif sla.condition

View file

@ -64,7 +64,7 @@ returns
# get related objects # get related objects
assets = {} assets = {}
list.each {|item| list.each { |item|
record = Kernel.const_get(item['object']).find(item['o_id']) record = Kernel.const_get(item['object']).find(item['o_id'])
assets = record.assets(assets) assets = record.assets(assets)

View file

@ -18,7 +18,7 @@ returns
def self.generate def self.generate
# generate number # generate number
(1..50_000).each { 49_999.times {
number = adapter.generate number = adapter.generate
ticket = Ticket.find_by( number: number ) ticket = Ticket.find_by( number: number )
return number if !ticket return number if !ticket

View file

@ -31,7 +31,7 @@ module Ticket::Number::Increment
min_digs = min_digs.to_i - 1 min_digs = min_digs.to_i - 1
end end
fillup = Setting.get('system_id').to_s || '1' fillup = Setting.get('system_id').to_s || '1'
(1..100).each { 99.times {
next if (fillup.length.to_i + counter_increment.to_s.length.to_i) >= min_digs.to_i next if (fillup.length.to_i + counter_increment.to_s.length.to_i) >= min_digs.to_i

View file

@ -26,7 +26,7 @@ returns
Overview.where(role_id: role.id, organization_shared: false, active: true).order(:prio) Overview.where(role_id: role.id, organization_shared: false, active: true).order(:prio)
end end
overviews_list = [] overviews_list = []
overviews.each {|overview| overviews.each { |overview|
user_ids = overview.user_ids user_ids = overview.user_ids
next if !user_ids.empty? && !user_ids.include?(data[:current_user].id) next if !user_ids.empty? && !user_ids.include?(data[:current_user].id)
overviews_list.push overview overviews_list.push overview
@ -39,7 +39,7 @@ returns
role = Role.find_by(name: 'Agent') role = Role.find_by(name: 'Agent')
overviews = Overview.where(role_id: role.id, active: true).order(:prio) overviews = Overview.where(role_id: role.id, active: true).order(:prio)
overviews_list = [] overviews_list = []
overviews.each {|overview| overviews.each { |overview|
user_ids = overview.user_ids user_ids = overview.user_ids
next if !user_ids.empty? && !user_ids.include?(data[:current_user].id) next if !user_ids.empty? && !user_ids.include?(data[:current_user].id)
overviews_list.push overview overviews_list.push overview
@ -91,7 +91,7 @@ returns
access_condition = Ticket.access_condition(user) access_condition = Ticket.access_condition(user)
list = [] list = []
overviews.each {|overview| overviews.each { |overview|
query_condition, bind_condition = Ticket.selector2sql(overview.condition, user) query_condition, bind_condition = Ticket.selector2sql(overview.condition, user)
order_by = "#{overview.order[:by]} #{overview.order[:direction]}" order_by = "#{overview.order[:by]} #{overview.order[:direction]}"

View file

@ -37,7 +37,7 @@ returns
return true if owner_id == data[:current_user].id return true if owner_id == data[:current_user].id
# access if requestor is in group # access if requestor is in group
data[:current_user].groups.each {|group| data[:current_user].groups.each { |group|
return true if self.group.id == group.id return true if self.group.id == group.id
} }
false false

View file

@ -45,10 +45,10 @@ returns
if state_type && !state_types.include?(state_type.name) if state_type && !state_types.include?(state_type.name)
state_ids.push params[:ticket].state.id state_ids.push params[:ticket].state.id
end end
state_types.each {|type| state_types.each { |type|
state_type = Ticket::StateType.find_by(name: type) state_type = Ticket::StateType.find_by(name: type)
next if !state_type next if !state_type
state_type.states.each {|state| state_type.states.each { |state|
assets = state.assets(assets) assets = state.assets(assets)
state_ids.push state.id state_ids.push state.id
} }
@ -69,7 +69,7 @@ returns
if params[:ticket].group.email_address_id if params[:ticket].group.email_address_id
types.push 'email' types.push 'email'
end end
types.each {|type_name| types.each { |type_name|
type = Ticket::Article::Type.lookup( name: type_name ) type = Ticket::Article::Type.lookup( name: type_name )
if type if type
type_ids.push type.id type_ids.push type.id
@ -88,7 +88,7 @@ returns
Group.where(active: true).each { |group| Group.where(active: true).each { |group|
assets = group.assets(assets) assets = group.assets(assets)
dependencies[:group_id][group.id] = { owner_id: [] } dependencies[:group_id][group.id] = { owner_id: [] }
group.users.each {|user| group.users.each { |user|
next if !agents[ user.id ] next if !agents[ user.id ]
assets = user.assets(assets) assets = user.assets(assets)
dependencies[:group_id][ group.id ][ :owner_id ].push user.id dependencies[:group_id][ group.id ][ :owner_id ].push user.id
@ -136,7 +136,7 @@ returns
).limit( data[:limit] || 15 ).order('created_at DESC') ).limit( data[:limit] || 15 ).order('created_at DESC')
assets = {} assets = {}
ticket_ids_open = [] ticket_ids_open = []
tickets_open.each {|ticket| tickets_open.each { |ticket|
ticket_ids_open.push ticket.id ticket_ids_open.push ticket.id
assets = ticket.assets(assets) assets = ticket.assets(assets)
} }
@ -146,7 +146,7 @@ returns
state_id: state_list_closed state_id: state_list_closed
).limit( data[:limit] || 15 ).order('created_at DESC') ).limit( data[:limit] || 15 ).order('created_at DESC')
ticket_ids_closed = [] ticket_ids_closed = []
tickets_closed.each {|ticket| tickets_closed.each { |ticket|
ticket_ids_closed.push ticket.id ticket_ids_closed.push ticket.id
assets = ticket.assets(assets) assets = ticket.assets(assets)
} }

View file

@ -107,7 +107,7 @@ returns
.where('groups_users.user_id = ?', current_user.id) .where('groups_users.user_id = ?', current_user.id)
.where('groups.active = ?', true) .where('groups.active = ?', true)
group_condition = [] group_condition = []
groups.each {|group| groups.each { |group|
group_condition.push group.name group_condition.push group.name
} }
access_condition = { access_condition = {
@ -134,7 +134,7 @@ returns
items = SearchIndexBackend.search(query, limit, 'Ticket', query_extention) items = SearchIndexBackend.search(query, limit, 'Ticket', query_extention)
if !full if !full
ids = [] ids = []
items.each {|item| items.each { |item|
ids.push item[:id] ids.push item[:id]
} }
return ids return ids

View file

@ -20,7 +20,7 @@ returns
# default ignored attributes # default ignored attributes
ignore_attributes = {} ignore_attributes = {}
if self.class.search_index_support_config[:ignore_attributes] if self.class.search_index_support_config[:ignore_attributes]
self.class.search_index_support_config[:ignore_attributes].each {|key, value| self.class.search_index_support_config[:ignore_attributes].each { |key, value|
ignore_attributes[key] = value ignore_attributes[key] = value
} }
end end
@ -31,7 +31,7 @@ returns
# remove ignored attributes # remove ignored attributes
attributes = ticket.attributes attributes = ticket.attributes
ignore_attributes.each {|key, value| ignore_attributes.each { |key, value|
next if value != true next if value != true
attributes.delete( key.to_s ) attributes.delete( key.to_s )
} }
@ -54,12 +54,12 @@ returns
# collect article data # collect article data
articles = Ticket::Article.where( ticket_id: id ) articles = Ticket::Article.where( ticket_id: id )
attributes['articles'] = [] attributes['articles'] = []
articles.each {|article| articles.each { |article|
article_attributes = article.attributes article_attributes = article.attributes
# remove note needed attributes # remove note needed attributes
ignore = %w(message_id_md5) ignore = %w(message_id_md5)
ignore.each {|attribute| ignore.each { |attribute|
article_attributes.delete( attribute ) article_attributes.delete( attribute )
} }
@ -72,7 +72,7 @@ returns
end end
# lookup attachments # lookup attachments
article.attachments.each {|attachment| article.attachments.each { |attachment|
if !article_attributes['attachments'] if !article_attributes['attachments']
article_attributes['attachments'] = [] article_attributes['attachments'] = []
end end

View file

@ -22,7 +22,7 @@ class Transaction::BackgroundJob
end end
def perform def perform
Setting.where(area: 'Transaction::Backend::Async').order(:name).each {|setting| Setting.where(area: 'Transaction::Backend::Async').order(:name).each { |setting|
backend = Kernel.const_get(Setting.get(setting.name)) backend = Kernel.const_get(Setting.get(setting.name))
Observer::Transaction.execute_singel_backend(backend, @item, @params) Observer::Transaction.execute_singel_backend(backend, @item, @params)
} }

View file

@ -50,7 +50,7 @@ sync all users against clearbit
def self.sync def self.sync
users = User.of_role('Customer') users = User.of_role('Customer')
users.each {|user| users.each { |user|
sync_user(user) sync_user(user)
} }
end end
@ -84,7 +84,7 @@ users = [...]
user_sync = config['user_sync'] user_sync = config['user_sync']
user_sync_values = {} user_sync_values = {}
if user_sync if user_sync
user_sync.each {|callback, destination| user_sync.each { |callback, destination|
next if !user_sync_values[destination].empty? next if !user_sync_values[destination].empty?
value = _replace(callback, data) value = _replace(callback, data)
next if !value next if !value
@ -96,7 +96,7 @@ users = [...]
organization_sync = config['organization_sync'] organization_sync = config['organization_sync']
organization_sync_values = {} organization_sync_values = {}
if organization_sync if organization_sync
organization_sync.each {|callback, destination| organization_sync.each { |callback, destination|
next if !organization_sync_values[destination].empty? next if !organization_sync_values[destination].empty?
value = _replace(callback, data) value = _replace(callback, data)
next if !value next if !value
@ -115,7 +115,7 @@ users = [...]
o_id: user.id, o_id: user.id,
) )
if external_syn_user && external_syn_user.last_payload if external_syn_user && external_syn_user.last_payload
user_sync.each {|callback, destination| user_sync.each { |callback, destination|
next if !user_sync_values_last_time[destination].empty? next if !user_sync_values_last_time[destination].empty?
value = _replace(callback, external_syn_user.last_payload) value = _replace(callback, external_syn_user.last_payload)
next if !value next if !value
@ -126,7 +126,7 @@ users = [...]
# if person record exists # if person record exists
user_has_changed = false user_has_changed = false
user_sync_values.each {|destination, value| user_sync_values.each { |destination, value|
attribute = destination.sub(/^user\./, '') attribute = destination.sub(/^user\./, '')
next if user[attribute] == value next if user[attribute] == value
next if !user[attribute].empty? && user_sync_values_last_time[destination] != user[attribute] next if !user[attribute].empty? && user_sync_values_last_time[destination] != user[attribute]
@ -196,7 +196,7 @@ users = [...]
organization = Organization.new( organization = Organization.new(
shared: config['organization_shared'], shared: config['organization_shared'],
) )
organization_sync_values.each {|destination, value| organization_sync_values.each { |destination, value|
attribute = destination.sub(/^organization\./, '') attribute = destination.sub(/^organization\./, '')
next if !organization[attribute].empty? next if !organization[attribute].empty?
begin begin
@ -227,7 +227,7 @@ users = [...]
# get latest organization synced attributes # get latest organization synced attributes
organization_sync_values_last_time = {} organization_sync_values_last_time = {}
if external_syn_organization && external_syn_organization.last_payload if external_syn_organization && external_syn_organization.last_payload
organization_sync.each {|callback, destination| organization_sync.each { |callback, destination|
next if !organization_sync_values_last_time[destination].empty? next if !organization_sync_values_last_time[destination].empty?
value = _replace(callback, external_syn_organization.last_payload) value = _replace(callback, external_syn_organization.last_payload)
next if !value next if !value
@ -238,7 +238,7 @@ users = [...]
# update existing organization # update existing organization
organization = Organization.find(external_syn_organization[:o_id]) organization = Organization.find(external_syn_organization[:o_id])
organization_has_changed = false organization_has_changed = false
organization_sync_values.each {|destination, value| organization_sync_values.each { |destination, value|
attribute = destination.sub(/^organization\./, '') attribute = destination.sub(/^organization\./, '')
next if organization[attribute] == value next if organization[attribute] == value
next if !organization[attribute].empty? && organization_sync_values_last_time[destination] != organization[attribute] next if !organization[attribute].empty? && organization_sync_values_last_time[destination] != organization[attribute]
@ -292,7 +292,7 @@ users = [...]
object_refs = data[object_name] object_refs = data[object_name]
object_methods = object_method.split('.') object_methods = object_method.split('.')
object_methods_s = '' object_methods_s = ''
object_methods.each {|method| object_methods.each { |method|
if object_methods_s != '' if object_methods_s != ''
object_methods_s += '.' object_methods_s += '.'
end end

View file

@ -79,7 +79,7 @@ class Transaction::Notification
possible_recipients.push ticket.owner possible_recipients.push ticket.owner
end end
already_checked_recipient_ids = {} already_checked_recipient_ids = {}
possible_recipients.each {|user| possible_recipients.each { |user|
result = NotificationFactory::Mailer.notification_settings(user, ticket, @item[:type]) result = NotificationFactory::Mailer.notification_settings(user, ticket, @item[:type])
next if !result next if !result
next if already_checked_recipient_ids[result[:user].id] next if already_checked_recipient_ids[result[:user].id]
@ -113,7 +113,7 @@ class Transaction::Notification
identifier = user.login identifier = user.login
end end
already_notified = false already_notified = false
History.list('Ticket', ticket.id).each {|history| History.list('Ticket', ticket.id).each { |history|
next if history['type'] != 'notification' next if history['type'] != 'notification'
next if history['value_to'] !~ /\(#{Regexp.escape(@item[:type])}:/ next if history['value_to'] !~ /\(#{Regexp.escape(@item[:type])}:/
next if history['value_to'] !~ /#{Regexp.escape(identifier)}\(/ next if history['value_to'] !~ /#{Regexp.escape(identifier)}\(/
@ -234,7 +234,7 @@ class Transaction::Notification
attribute_list = ObjectManager::Attribute.by_object_as_hash('Ticket', user) attribute_list = ObjectManager::Attribute.by_object_as_hash('Ticket', user)
#puts "AL #{attribute_list.inspect}" #puts "AL #{attribute_list.inspect}"
user_related_changes = {} user_related_changes = {}
@item[:changes].each {|key, value| @item[:changes].each { |key, value|
# if no config exists, use all attributes # if no config exists, use all attributes
if !attribute_list || attribute_list.empty? if !attribute_list || attribute_list.empty?
@ -247,7 +247,7 @@ class Transaction::Notification
} }
changes = {} changes = {}
user_related_changes.each {|key, value| user_related_changes.each { |key, value|
# get attribute name # get attribute name
attribute_name = key.to_s attribute_name = key.to_s

View file

@ -110,7 +110,7 @@ backend.perform
color = '#38ad69' color = '#38ad69'
end end
config['items'].each {|local_config| config['items'].each { |local_config|
next if local_config['webhook'].empty? next if local_config['webhook'].empty?
# check if reminder_reached/escalation/escalation_warning is already sent today # check if reminder_reached/escalation/escalation_warning is already sent today
@ -134,7 +134,7 @@ backend.perform
# check action # check action
if local_config['types'].class == Array if local_config['types'].class == Array
hit = false hit = false
local_config['types'].each {|type| local_config['types'].each { |type|
next if type.to_s != @item[:type].to_s next if type.to_s != @item[:type].to_s
hit = true hit = true
break break
@ -147,7 +147,7 @@ backend.perform
# check group # check group
if local_config['group_ids'].class == Array if local_config['group_ids'].class == Array
hit = false hit = false
local_config['group_ids'].each {|group_id| local_config['group_ids'].each { |group_id|
next if group_id.to_s != ticket.group_id.to_s next if group_id.to_s != ticket.group_id.to_s
hit = true hit = true
break break
@ -206,7 +206,7 @@ backend.perform
attribute_list = ObjectManager::Attribute.by_object_as_hash('Ticket', user) attribute_list = ObjectManager::Attribute.by_object_as_hash('Ticket', user)
#puts "AL #{attribute_list.inspect}" #puts "AL #{attribute_list.inspect}"
user_related_changes = {} user_related_changes = {}
@item[:changes].each {|key, value| @item[:changes].each { |key, value|
# if no config exists, use all attributes # if no config exists, use all attributes
if !attribute_list || attribute_list.empty? if !attribute_list || attribute_list.empty?
@ -219,7 +219,7 @@ backend.perform
} }
changes = {} changes = {}
user_related_changes.each {|key, value| user_related_changes.each { |key, value|
# get attribute name # get attribute name
attribute_name = key.to_s attribute_name = key.to_s

View file

@ -40,7 +40,7 @@ class Transaction::Trigger
original_user_id = UserInfo.current_user_id original_user_id = UserInfo.current_user_id
UserInfo.current_user_id = 1 UserInfo.current_user_id = 1
triggers.each {|trigger| triggers.each { |trigger|
condition = trigger.condition condition = trigger.condition
# check action # check action
@ -49,7 +49,28 @@ class Transaction::Trigger
next if condition['ticket.action']['operator'] != 'is' && condition['ticket.action']['value'] == @item[:type] next if condition['ticket.action']['operator'] != 'is' && condition['ticket.action']['value'] == @item[:type]
condition.delete('ticket.action') condition.delete('ticket.action')
end end
=begin
# check "has changed" options
has_changed = true
trigger.condition.each do |key, value|
next if !value
next if !value['operator']
next if !value['operator']['has changed']
# next if has changed? && !@item[:changes][attribute]
(object_name, attribute) = key.split('.', 2)
# remove condition item, because it has changed
if @item[:changes][attribute]
#condition.delete(key)
next
end
has_changed = false
break
#{"ticket.state_id"=>{"operator"=>"has changed"
end
next if !has_changed
=end
# check if selector is matching # check if selector is matching
condition['ticket.id'] = { condition['ticket.id'] = {
operator: 'is', operator: 'is',

View file

@ -24,13 +24,13 @@ dedicated:
locales_list = [] locales_list = []
if !dedicated_locale if !dedicated_locale
locales = Locale.to_sync locales = Locale.to_sync
locales.each {|locale| locales.each { |locale|
locales_list.push locale.locale locales_list.push locale.locale
} }
else else
locales_list = [dedicated_locale] locales_list = [dedicated_locale]
end end
locales_list.each {|locale| locales_list.each { |locale|
url = "https://i18n.zammad.com/api/v1/translations/#{locale}" url = "https://i18n.zammad.com/api/v1/translations/#{locale}"
if !UserInfo.current_user_id if !UserInfo.current_user_id
UserInfo.current_user_id = 1 UserInfo.current_user_id = 1
@ -48,11 +48,11 @@ dedicated:
translations = Translation.where(locale: locale).all translations = Translation.where(locale: locale).all
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
result.data.each {|translation_raw| result.data.each { |translation_raw|
# handle case insensitive sql # handle case insensitive sql
translation = nil translation = nil
translations.each {|item| translations.each { |item|
next if item.format != translation_raw['format'] next if item.format != translation_raw['format']
next if item.source != translation_raw['source'] next if item.source != translation_raw['source']
translation = item translation = item
@ -62,7 +62,7 @@ dedicated:
# verify if update is needed # verify if update is needed
update_needed = false update_needed = false
translation_raw.each {|key, _value| translation_raw.each { |key, _value|
if translation_raw[key] != translation[key] if translation_raw[key] != translation[key]
update_needed = true update_needed = true
break break
@ -94,7 +94,7 @@ push translations to online
# only push changed translations # only push changed translations
translations = Translation.where(locale: locale) translations = Translation.where(locale: locale)
translations_to_push = [] translations_to_push = []
translations.each {|translation| translations.each { |translation|
if translation.target != translation.target_initial if translation.target != translation.target_initial
translations_to_push.push translation translations_to_push.push translation
end end
@ -142,7 +142,7 @@ reset translations to origin
# only push changed translations # only push changed translations
translations = Translation.where(locale: locale) translations = Translation.where(locale: locale)
translations.each {|translation| translations.each { |translation|
if !translation.target_initial || translation.target_initial.empty? if !translation.target_initial || translation.target_initial.empty?
translation.destroy translation.destroy
elsif translation.target != translation.target_initial elsif translation.target != translation.target_initial
@ -203,8 +203,8 @@ get list of translations
# add presorted on top # add presorted on top
presorted_list = [] presorted_list = []
%w(yes no or Year Years Month Months Day Days Hour Hours Minute Minutes Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec January February March April May June July August September October November December Mon Tue Wed Thu Fri Sat Sun Monday Tuesday Wednesday Thursday Friday Saturday Sunday).each {|presort| %w(yes no or Year Years Month Months Day Days Hour Hours Minute Minutes Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec January February March April May June July August September October November December Mon Tue Wed Thu Fri Sat Sun Monday Tuesday Wednesday Thursday Friday Saturday Sunday).each { |presort|
list.each {|item| list.each { |item|
next if item[1] != presort next if item[1] != presort
presorted_list.push item presorted_list.push item
list.delete item list.delete item
@ -233,13 +233,13 @@ translate strings in ruby context, e. g. for notifications
# translate string # translate string
records = Translation.where(locale: locale, source: string) records = Translation.where(locale: locale, source: string)
records.each {|record| records.each { |record|
return record.target if record.source == string return record.target if record.source == string
} }
# fallback lookup in en # fallback lookup in en
records = Translation.where(locale: 'en', source: string) records = Translation.where(locale: 'en', source: string)
records.each {|record| records.each { |record|
return record.target if record.source == string return record.target if record.source == string
} }

View file

@ -290,7 +290,7 @@ returns
roles = Role.where(name: 'Customer') roles = Role.where(name: 'Customer')
url = '' url = ''
if hash['info']['urls'] if hash['info']['urls']
hash['info']['urls'].each {|_name, local_url| hash['info']['urls'].each { |_name, local_url|
next if !local_url next if !local_url
next if local_url.empty? next if local_url.empty?
url = local_url url = local_url
@ -539,7 +539,7 @@ returns
def self.update_default_preferences(role_name) def self.update_default_preferences(role_name)
role = Role.lookup(name: role_name) role = Role.lookup(name: role_name)
User.of_role(role_name).each {|user| User.of_role(role_name).each { |user|
user.check_notifications(role) user.check_notifications(role)
user.check_preferences_default user.check_preferences_default
user.save user.save
@ -555,7 +555,7 @@ returns
if !@preferences_default if !@preferences_default
@preferences_default = {} @preferences_default = {}
end end
default[o.name].each {|key, value| default[o.name].each { |key, value|
next if @preferences_default[key] next if @preferences_default[key]
@preferences_default[key] = value @preferences_default[key] = value
} }

View file

@ -62,7 +62,7 @@ returns
end end
local_attributes['role_ids'] = local_role_ids local_attributes['role_ids'] = local_role_ids
if local_role_ids if local_role_ids
local_role_ids.each {|role_id| local_role_ids.each { |role_id|
role = Role.lookup(id: role_id) role = Role.lookup(id: role_id)
data = role.assets(data) data = role.assets(data)
} }
@ -77,7 +77,7 @@ returns
end end
local_attributes['group_ids'] = local_group_ids local_attributes['group_ids'] = local_group_ids
if local_group_ids if local_group_ids
local_group_ids.each {|group_id| local_group_ids.each { |group_id|
group = Group.lookup(id: group_id) group = Group.lookup(id: group_id)
next if !group next if !group
data = group.assets(data) data = group.assets(data)
@ -93,7 +93,7 @@ returns
end end
local_attributes['organization_ids'] = local_organization_ids local_attributes['organization_ids'] = local_organization_ids
if local_organization_ids if local_organization_ids
local_organization_ids.each {|organization_id| local_organization_ids.each { |organization_id|
organization = Organization.lookup(id: organization_id) organization = Organization.lookup(id: organization_id)
next if !organization next if !organization
data = organization.assets(data) data = organization.assets(data)
@ -112,7 +112,7 @@ returns
end end
end end
end end
%w(created_by_id updated_by_id).each {|local_user_id| %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ] next if !self[ local_user_id ]
next if data[ User.to_app_model ][ self[ local_user_id ] ] next if data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ]) user = User.lookup(id: self[ local_user_id ])

View file

@ -40,7 +40,7 @@ store new device for user if device not already known
user_id: user_id, user_id: user_id,
fingerprint: fingerprint, fingerprint: fingerprint,
) )
user_devices.each {|local_user_device| user_devices.each { |local_user_device|
device_exists_by_fingerprint = true device_exists_by_fingerprint = true
next if local_user_device.location != location next if local_user_device.location != location
return action(local_user_device.id, user_agent, ip, user_id, type) if local_user_device return action(local_user_device.id, user_agent, ip, user_id, type) if local_user_device
@ -54,7 +54,7 @@ store new device for user if device not already known
user_id: user_id, user_id: user_id,
user_agent: user_agent, user_agent: user_agent,
) )
user_devices.each {|local_user_device| user_devices.each { |local_user_device|
device_exists_by_user_agent = true device_exists_by_user_agent = true
next if local_user_device.location != location next if local_user_device.location != location
return action(local_user_device.id, user_agent, ip, user_id, type) if local_user_device return action(local_user_device.id, user_agent, ip, user_id, type) if local_user_device

View file

@ -8,5 +8,5 @@ Rails.application.config.assets.version = '1.0'
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.application.config.assets.precompile += %w( application-print.css ) Rails.application.config.assets.precompile += %w(application-print.css)
Rails.application.config.assets.precompile += %w( print.css ) Rails.application.config.assets.precompile += %w(print.css)

View file

@ -1,5 +1,5 @@
# load all core_ext extentions # load all core_ext extentions
Dir.glob("#{Rails.root}/lib/core_ext/**/*").each {|file| Dir.glob("#{Rails.root}/lib/core_ext/**/*").each { |file|
if File.file?(file) if File.file?(file)
require file require file
end end

View file

@ -1,5 +1,5 @@
# load all vendor/lib extentions # load all vendor/lib extentions
Dir["#{Rails.root}/vendor/lib/*"].each {|file| Dir["#{Rails.root}/vendor/lib/*"].each { |file|
if File.file?(file) if File.file?(file)
require file require file
end end

View file

@ -1,7 +1,7 @@
class UpdateTimestamps < ActiveRecord::Migration class UpdateTimestamps < ActiveRecord::Migration
def up def up
# get all models # get all models
Models.all.each {|_model, value| Models.all.each { |_model, value|
next if !value next if !value
next if !value[:attributes] next if !value[:attributes]
if value[:attributes].include?('changed_at') if value[:attributes].include?('changed_at')

View file

@ -188,7 +188,7 @@ class OnlyOneGroup < ActiveRecord::Migration
) )
list = [] list = []
User.all {|user| User.all { |user|
next if !user.zip.empty? && !user.city.empty? && !user.street.empty? next if !user.zip.empty? && !user.city.empty? && !user.street.empty?
#next if !user.address.empty? #next if !user.address.empty?
list.push user list.push user

View file

@ -11,7 +11,7 @@ class UpdateSettingPlaceholder < ActiveRecord::Migration
http_type http_type
ticket_hook ticket_hook
) )
names.each {|name| names.each { |name|
setting = Setting.find_by(name: name) setting = Setting.find_by(name: name)
next if !setting next if !setting
setting.preferences[:placeholder] = true setting.preferences[:placeholder] = true

View file

@ -134,7 +134,7 @@ Setting.create_if_not_exists(
frontend: true frontend: true
) )
options = {} options = {}
(10..99).each {|item| (10..99).each { |item|
options[item] = item options[item] = item
} }
system_id = rand(10..99) system_id = rand(10..99)

View file

@ -28,7 +28,7 @@ returns
] ]
# added configured backends # added configured backends
Setting.where(area: 'Security::Authentication').each {|setting| Setting.where(area: 'Security::Authentication').each { |setting|
if setting.state_current[:value] if setting.state_current[:value]
config.push setting.state_current[:value] config.push setting.state_current[:value]
end end
@ -36,7 +36,7 @@ returns
# try to login against configure auth backends # try to login against configure auth backends
user_auth = nil user_auth = nil
config.each {|config_item| config.each { |config_item|
next if !config_item[:adapter] next if !config_item[:adapter]
# load backend # load backend

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
@ -91,7 +91,7 @@ module Auth::Ldap
# set always roles # set always roles
if config[:always_roles] if config[:always_roles]
role_ids = user.role_ids role_ids = user.role_ids
config[:always_roles].each {|role_name| config[:always_roles].each { |role_name|
role = Role.where( name: role_name ).first role = Role.where( name: role_name ).first
next if !role next if !role
if !role_ids.include?( role.id ) if !role_ids.include?( role.id )
@ -105,7 +105,7 @@ module Auth::Ldap
# set always groups # set always groups
if config[:always_groups] if config[:always_groups]
group_ids = user.group_ids group_ids = user.group_ids
config[:always_groups].each {|group_name| config[:always_groups].each { |group_name|
group = Group.where( name: group_name ).first group = Group.where( name: group_name ).first
next if !group next if !group
if !group_ids.include?( group.id ) if !group_ids.include?( group.id )

View file

@ -81,9 +81,9 @@ returns
model_map = { model_map = {
'Organizations' => 'Organization', 'Organizations' => 'Organization',
} }
model_map.each {|map_name, model| model_map.each { |map_name, model|
next if !auto_wizard_hash[map_name] next if !auto_wizard_hash[map_name]
auto_wizard_hash[map_name].each {|data| auto_wizard_hash[map_name].each { |data|
generic_object = Kernel.const_get(model) generic_object = Kernel.const_get(model)
data.symbolize_keys! data.symbolize_keys!
generic_object.create_or_update_with_ref(data) generic_object.create_or_update_with_ref(data)
@ -126,9 +126,9 @@ returns
'Signatures' => 'Signature', 'Signatures' => 'Signature',
'Groups' => 'Group', 'Groups' => 'Group',
} }
model_map.each {|map_name, model| model_map.each { |map_name, model|
next if !auto_wizard_hash[map_name] next if !auto_wizard_hash[map_name]
auto_wizard_hash[map_name].each {|data| auto_wizard_hash[map_name].each { |data|
generic_object = Kernel.const_get(model) generic_object = Kernel.const_get(model)
data.symbolize_keys! data.symbolize_keys!
generic_object.create_or_update_with_ref(data) generic_object.create_or_update_with_ref(data)

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