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

View file

@ -9,7 +9,7 @@ class CalendarsController < ApplicationController
# calendars
assets = {}
calendar_ids = []
Calendar.all.order(:name, :created_at).each {|calendar|
Calendar.all.order(:name, :created_at).each { |calendar|
calendar_ids.push calendar.id
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
assets = {}
ExternalCredential.where(name: 'twitter').each {|external_credential|
ExternalCredential.where(name: 'twitter').each { |external_credential|
assets = external_credential.assets(assets)
}
channel_ids = []
Channel.order(:id).each {|channel|
Channel.order(:id).each { |channel|
next if channel.area != 'Twitter::Account'
assets = channel.assets(assets)
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
assets = {}
ExternalCredential.where(name: 'facebook').each {|external_credential|
ExternalCredential.where(name: 'facebook').each { |external_credential|
assets = external_credential.assets(assets)
}
channel_ids = []
Channel.order(:id).each {|channel|
Channel.order(:id).each { |channel|
next if channel.area != 'Facebook::Account'
assets = channel.assets(assets)
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 = []
accounts_fixed = []
assets = {}
Channel.order(:id).each {|channel|
Channel.order(:id).each { |channel|
if system_online_service && channel.preferences && channel.preferences['online_service_disable']
email_addresses = EmailAddress.where(channel_id: channel.id)
email_addresses.each {|email_address|
email_addresses.each { |email_address|
accounts_fixed.push email_address
}
next
@ -116,7 +116,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
assets = channel.assets(assets)
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']
email_address_ids.push email_address.id
assets = email_address.assets(assets)
@ -299,7 +299,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
# save settings
if result[:result] == 'ok'
Channel.where(area: 'Email::Notification').each {|channel|
Channel.where(area: 'Email::Notification').each { |channel|
active = false
if adapter =~ /^#{channel.options[:outbound][:adapter]}$/i
active = true
@ -322,7 +322,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
private
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[:inbound]
next if !channel.options[:inbound][:adapter]

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -6,7 +6,7 @@ class UserDevicesController < ApplicationController
def index
devices = UserDevice.where(user_id: current_user.id).order('updated_at DESC, name ASC')
devices_full = []
devices.each {|device|
devices.each { |device|
attributes = device.attributes
if device.location_details['city_name'] && !device.location_details['city_name'].empty?
attributes['location'] += ", #{device.location_details['city_name']}"
@ -30,7 +30,7 @@ class UserDevicesController < ApplicationController
# delete device and session's
if user_device
SessionHelper.list.each {|session|
SessionHelper.list.each { |session|
next if !session.data['user_id']
next if !session.data['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]
list = []
users.each {|user|
users.each { |user|
list.push user.attributes_with_relation_names
}
render json: list, status: :ok
@ -39,7 +39,7 @@ class UsersController < ApplicationController
if params[:full]
assets = {}
item_ids = []
users.each {|item|
users.each { |item|
item_ids.push item.id
assets = item.assets(assets)
}
@ -51,7 +51,7 @@ class UsersController < ApplicationController
end
users_all = []
users.each {|user|
users.each { |user|
users_all.push User.lookup(id: user.id).attributes_with_associations
}
render json: users_all, status: :ok
@ -341,7 +341,7 @@ class UsersController < ApplicationController
if params[:expand]
list = []
user_all.each {|user|
user_all.each { |user|
list.push user.attributes_with_relation_names
}
render json: list, status: :ok
@ -753,7 +753,7 @@ curl http://localhost/api/v1/users/preferences.json -v -u #{login}:#{password} -
if params[:user]
user = User.find(current_user.id)
params[:user].each {|key, value|
params[:user].each { |key, value|
user.preferences[key.to_sym] = value
}
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
params[:role_ids] = [params[:role_ids]]
end
params[:role_ids].each {|role_id|
params[:role_ids].each { |role_id|
role_local = Role.lookup(id: role_id)
if !role_local
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
data = {}
params.each {|key, value|
params.each { |key, value|
data[key.to_sym] = value
}
@ -91,7 +91,7 @@ returns
# only use object attributes
clean_params = {}
new.attributes.each {|attribute, _value|
new.attributes.each { |attribute, _value|
next if !data.key?(attribute.to_sym)
clean_params[attribute.to_sym] = data[attribute.to_sym]
}
@ -125,7 +125,7 @@ returns
list_of_items = [ params[real_ids] ]
end
list = []
list_of_items.each {|item_id|
list_of_items.each { |item_id|
next if !item_id
lookup = assoc.klass.lookup(id: item_id)
@ -150,7 +150,7 @@ returns
next if params[real_values].class != Array
list = []
class_object = assoc.klass
params[real_values].each {|value|
params[real_values].each { |value|
lookup = nil
if class_object == User
if !lookup
@ -222,7 +222,7 @@ returns
next if !ref
if ref.respond_to?(:first)
attributes[assoc.name.to_s] = []
ref.each {|item|
ref.each { |item|
if item[:login]
attributes[assoc.name.to_s].push item[:login]
next
@ -247,7 +247,7 @@ returns
{
'created_by_id' => 'created_by',
'updated_by_id' => 'updated_by',
}.each {|source, destination|
}.each { |source, destination|
next if !attributes[source]
user = User.lookup(id: attributes[source])
next if !user
@ -255,7 +255,7 @@ returns
}
# remove forbitten attributes
%w(password token tokens token_ids).each {|item|
%w(password token tokens token_ids).each { |item|
attributes.delete(item)
}
@ -277,7 +277,7 @@ returns
def self.param_validation(data)
# 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)
}
@ -317,7 +317,7 @@ returns
def self.param_association_lookup(params)
data = {}
params.each {|key, value|
params.each { |key, value|
data[key.to_sym] = value
}
@ -376,7 +376,7 @@ returns
# get association class and do lookup
class_object = assoc.klass
lookup_ids = []
value.each {|item|
value.each { |item|
lookup = nil
if class_object == User
if item.class == String
@ -528,7 +528,7 @@ returns
def self.genrate_uniq_name(name)
return name if !find_by(name: name)
(1..100).each {|counter|
(1..100).each { |counter|
name = "#{name}_#{counter}"
exists = find_by(name: name)
next if exists
@ -570,7 +570,7 @@ returns
else
where(name: data[:name])
end
records.each {|loop_record|
records.each { |loop_record|
if loop_record.name == data[:name]
cache_set(data[:name], loop_record)
return loop_record
@ -587,7 +587,7 @@ returns
else
where(login: data[:login])
end
records.each {|loop_record|
records.each { |loop_record|
if loop_record.login == data[:login]
cache_set(data[:login], loop_record)
return loop_record
@ -604,7 +604,7 @@ returns
else
where(email: data[:email])
end
records.each {|loop_record|
records.each { |loop_record|
if loop_record.email == data[:email]
cache_set(data[:email], loop_record)
return loop_record
@ -640,7 +640,7 @@ returns
else
where(name: data[:name])
end
records.each {|loop_record|
records.each { |loop_record|
return loop_record if loop_record.name == data[:name]
}
elsif data[:login]
@ -651,7 +651,7 @@ returns
else
where(login: data[:login])
end
records.each {|loop_record|
records.each { |loop_record|
return loop_record if loop_record.login == data[:login]
}
elsif data[:email]
@ -662,7 +662,7 @@ returns
else
where(email: data[:email])
end
records.each {|loop_record|
records.each { |loop_record|
return loop_record if loop_record.email == data[:email]
}
elsif data[:locale] && data[:source]
@ -673,7 +673,7 @@ returns
else
where(locale: data[:locale], source: data[:source])
end
records.each {|loop_record|
records.each { |loop_record|
return loop_record if loop_record.source == data[:source]
}
end
@ -727,7 +727,7 @@ returns
else
where(name: data[:name])
end
records.each {|loop_record|
records.each { |loop_record|
if loop_record.name == data[:name]
loop_record.update_attributes(data)
return loop_record
@ -744,7 +744,7 @@ returns
else
where(login: data[:login])
end
records.each {|loop_record|
records.each { |loop_record|
if loop_record.login.casecmp(data[:login]).zero?
loop_record.update_attributes(data)
return loop_record
@ -761,7 +761,7 @@ returns
else
where(email: data[:email])
end
records.each {|loop_record|
records.each { |loop_record|
if loop_record.email.casecmp(data[:email]).zero?
loop_record.update_attributes(data)
return loop_record
@ -778,7 +778,7 @@ returns
else
where(locale: data[:locale])
end
records.each {|loop_record|
records.each { |loop_record|
if loop_record.locale.casecmp(data[:locale]).zero?
loop_record.update_attributes(data)
return loop_record
@ -1130,13 +1130,13 @@ log object update activity stream, if configured - will be executed automaticall
updated_by_id: true,
}
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
}
end
log = false
changes.each {|key, _value|
changes.each { |key, _value|
# do not log created_at and updated_at attributes
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
changes = self.changes
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
changes.delete(key)
end
@ -1236,12 +1236,12 @@ log object update history with all updated attributes, if configured - will be e
updated_by_id: true,
}
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
}
end
changes.each {|key, value|
changes.each { |key, value|
# do not log created_at and updated_at attributes
next if ignore_attributes[key.to_sym] == true
@ -1384,7 +1384,7 @@ get assets of object list
=end
def self.assets_of_object_list(list, assets = {})
list.each {|item|
list.each { |item|
require item['object'].to_filename
record = Kernel.const_get(item['object']).find(item['o_id'])
assets = record.assets(assets)
@ -1414,7 +1414,7 @@ get assets and record_ids of selector
# get assets of condition
models = Models.all
send(selector).each {|item, content|
send(selector).each { |item, content|
attribute = item.split(/\./)
next if !attribute[1]
begin
@ -1431,7 +1431,7 @@ get assets and record_ids of selector
next if !models[attribute_class][:reflections][reflection].klass
attribute_ref_class = models[attribute_class][:reflections][reflection].klass
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)
if attribute_object
assets = attribute_object.assets(assets)
@ -1520,7 +1520,7 @@ check string/varchar size and cut them if needed
=end
def check_limits
attributes.each {|attribute|
attributes.each { |attribute|
next if !self[ attribute[0] ]
next if self[ attribute[0] ].class != String
next if self[ attribute[0] ].empty?

View file

@ -29,7 +29,7 @@ returns
end
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 data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ])

View file

@ -82,7 +82,7 @@ returns
# get related objects
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'])
history[:assets] = record.assets(history[:assets])

View file

@ -20,7 +20,7 @@ returns
# default ignored attributes
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
}
end
@ -31,7 +31,7 @@ returns
# remove ignored attributes
attributes = data.attributes
ignore_attributes.each {|key, value|
ignore_attributes.each { |key, value|
next if value != true
attributes.delete(key.to_s)
}
@ -86,7 +86,7 @@ returns
def search_index_attribute_lookup(attributes, ref_object)
attributes_new = {}
attributes.each {|key, value|
attributes.each { |key, value|
next if !value
# get attribute name

View file

@ -157,7 +157,7 @@ returns
'Venezuela' => 'en.ve',
}
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
@ -232,14 +232,14 @@ returns
end
# 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 meta['feed'] == Digest::MD5.hexdigest(ical_url)
public_holidays.delete(day)
}
# sync new ical feed dates
events.each {|day, summary|
events.each { |day, summary|
if !public_holidays[day]
public_holidays[day] = {}
end
@ -280,7 +280,7 @@ returns
cals = Icalendar.parse(cal_file)
cal = cals.first
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 + 3.years
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
def sync_default
return if !default
Calendar.all.each {|calendar|
Calendar.all.each { |calendar|
next if calendar.id == id
next if !calendar.default
calendar.default = false
@ -312,7 +312,7 @@ returns
# check if min one is set to default true
def min_one_check
Calendar.all.each {|calendar|
Calendar.all.each { |calendar|
return true if calendar.default
}
first = Calendar.order(:created_at, :id).limit(1).first
@ -320,7 +320,7 @@ returns
first.save
# check if sla's are refer to an existing calendar
Sla.all.each {|sla|
Sla.all.each { |sla|
if !sla.calendar_id
sla.calendar_id = first.id
sla.save
@ -342,7 +342,7 @@ returns
def validate_public_holidays
# 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']
meta['feed'] = public_holidays_was[day]['feed']
end

View file

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

View file

@ -38,7 +38,7 @@ returns
end
end
if !access
%w(inbound outbound).each {|key|
%w(inbound outbound).each { |key|
if attributes['options'] && attributes['options'][key] && attributes['options'][key]['options']
attributes['options'][key]['options'].delete('password')
end
@ -49,7 +49,7 @@ returns
end
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 data[ User.to_app_model ] && data[ User.to_app_model ][ 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)
access_token = nil
options['pages'].each {|page|
options['pages'].each { |page|
next if page['id'].to_s != fb_object_id.to_s
access_token = page['access_token']
}
@ -52,7 +52,7 @@ class Channel::Driver::Facebook
private
def get_page(page_id)
@pages.each {|page|
@pages.each { |page|
return page if page['id'].to_s == page_id.to_s
}
nil
@ -62,7 +62,7 @@ class Channel::Driver::Facebook
return if !@sync
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)
next if !page
next if !page_to_sync_params['group_id']
@ -70,7 +70,7 @@ class Channel::Driver::Facebook
page_client = Facebook.new(page['access_token'])
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)
}
}

View file

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

View file

@ -280,7 +280,7 @@ class Channel::EmailParser
# check if sub parts are available
if !file.parts.empty?
a = []
file.parts.each {|p|
file.parts.each { |p|
attachment = _get_attachment(p, attachments, mail)
a.concat(attachment)
}
@ -324,10 +324,10 @@ class Channel::EmailParser
# generate file name
if !filename || filename.empty?
attachment_count = 0
(1..1000).each {|count|
(1..1000).each { |count|
filename_exists = false
filename = 'file-' + count.to_s
attachments.each {|attachment|
attachments.each { |attachment|
if attachment[:filename] == filename
filename_exists = true
end
@ -394,10 +394,10 @@ retrns
# run postmaster pre filter
UserInfo.current_user_id = 1
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.each {|_prio, backend|
filters.each { |_prio, backend|
Rails.logger.debug "run postmaster pre filter #{backend}"
begin
backend.run(channel, mail)
@ -550,10 +550,10 @@ retrns
# run postmaster post filter
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.each {|_prio, backend|
filters.each { |_prio, backend|
Rails.logger.debug "run postmaster post filter #{backend}"
begin
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)
# loop all x-zammad-hedaer-* headers
item_object.attributes.each {|key, _value|
item_object.attributes.each { |key, _value|
# ignore read only attributes
next if key == 'updated_by_id'

View file

@ -9,7 +9,7 @@ module Channel::Filter::BounceCheck
return if !mail[:attachments]
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]['Mime-Type'] != 'message/rfc822'
next if !attachment[:data]

View file

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

View file

@ -28,7 +28,7 @@ module Channel::Filter::FollowUpCheck
# get ticket# from attachment
if setting.include?('attachment') && mail[:attachments]
mail[:attachments].each {|attachment|
mail[:attachments].each { |attachment|
next if !attachment[:data]
ticket = Ticket::Number.check(attachment[:data])
next if !ticket
@ -54,7 +54,7 @@ module Channel::Filter::FollowUpCheck
end
if references != ''
message_ids = references.split(/\s+/)
message_ids.each {|message_id|
message_ids.each { |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
next if !article

View file

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

View file

@ -47,7 +47,7 @@ class Channel::Filter::MonitoringBase
# follow up detection by meta data
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['integration']
next if ticket.preferences['integration'] != integration
@ -77,7 +77,7 @@ class Channel::Filter::MonitoringBase
preferences = {}
preferences['integration'] = integration
preferences[integration] = result
preferences.each {|key, value|
preferences.each { |key, value|
mail[ 'x-zammad-ticket-preferences'.to_sym ][key] = value
}
end

View file

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

View file

@ -65,16 +65,16 @@ class Chat < ApplicationModel
def self.agent_state(user_id)
return { state: 'chat_disabled' } if !Setting.get('chat')
assets = {}
Chat.where(active: true).each {|chat|
Chat.where(active: true).each { |chat|
assets = chat.assets(assets)
}
active_agent_ids = []
active_agents.each {|user|
active_agents.each { |user|
active_agent_ids.push user.id
assets = user.assets(assets)
}
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']
user = User.lookup(id: session['user_id'])
next if !user
@ -107,7 +107,7 @@ class Chat < ApplicationModel
def self.waiting_chat_session_list
sessions = []
Chat::Session.where(state: ['waiting']).each {|session|
Chat::Session.where(state: ['waiting']).each { |session|
sessions.push session.attributes
}
sessions
@ -119,7 +119,7 @@ class Chat < ApplicationModel
def self.running_chat_session_list
sessions = []
Chat::Session.where(state: ['running']).each {|session|
Chat::Session.where(state: ['running']).each { |session|
sessions.push session.attributes
}
sessions
@ -131,7 +131,7 @@ class Chat < ApplicationModel
def self.available_agents(diff = 2.minutes)
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
@ -143,7 +143,7 @@ class Chat < ApplicationModel
def self.active_agents(diff = 2.minutes)
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)
next if !user
users.push user
@ -153,7 +153,7 @@ class Chat < ApplicationModel
def self.seads_total(diff = 2.minutes)
total = 0
available_agents(diff).each {|_user_id, concurrent|
available_agents(diff).each { |_user_id, concurrent|
total += concurrent
}
total
@ -178,7 +178,7 @@ optional you can ignore it for dedecated user
def self.broadcast_agent_state_update(ignore_user_id = nil)
# 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
data = {
event: 'chat_status_agent',
@ -200,7 +200,7 @@ broadcast new customer queue position to all waiting customers
# send position update to other waiting sessions
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
data = {
event: 'chat_session_queue',
@ -227,7 +227,7 @@ optional you can parse the max oldest chat entries
=end
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_session.destroy
}
@ -248,7 +248,7 @@ optional you can parse the max oldest chat sessions
=end
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?
chat_session.state = 'closed'
chat_session.save

View file

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

View file

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

View file

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

View file

@ -23,7 +23,7 @@ check and if channel not exists reset configured channels for email addresses
=end
def self.channel_cleanup
EmailAddress.all.each {|email_address|
EmailAddress.all.each { |email_address|
# set to active if channel exists
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('perform', data)
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 data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ])

View file

@ -140,7 +140,7 @@ class Link < ApplicationModel
)
# touch references
links.each {|link|
links.each { |link|
link.destroy
touch_reference_by_params(
object: Link::Object.lookup(id: link.link_object_source_id).name,
@ -166,7 +166,7 @@ class Link < ApplicationModel
)
# touch references
links.each {|link|
links.each { |link|
link.destroy
touch_reference_by_params(
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?
ActiveRecord::Base.transaction do
result.data.each {|locale|
result.data.each { |locale|
exists = Locale.find_by(locale: locale['locale'])
if exists
exists.update(locale.symbolize_keys!)

View file

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

View file

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

View file

@ -31,7 +31,7 @@ class Observer::Sla::TicketRebuildEscalation < ActiveRecord::Observer
# check if condition has changed
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][0] == record.changes[item][1]
changed = true

View file

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

View file

@ -9,7 +9,7 @@ class Observer::Ticket::OnlineNotificationSeen::BackgroundJob
# set all online notifications to seen
ActiveRecord::Base.transaction do
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
seen = ticket.online_notification_seen_state(notification.user_id)
next if !seen

View file

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

View file

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

View file

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

View file

@ -218,7 +218,7 @@ returns:
def self.all_seen?(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']
}
true
@ -240,7 +240,7 @@ returns:
def self.exists?(user, object, o_id, type, created_by_user, seen)
# rubocop:enable Metrics/ParameterLists
notifications = OnlineNotification.list(user, 10)
notifications.each {|notification|
notifications.each { |notification|
next if notification['o_id'] != o_id
next if notification['object'] != object
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)
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
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
User.of_role('Agent').each {|user|
User.of_role('Agent').each { |user|
Sessions.send_to(
user.id,
{

View file

@ -45,7 +45,7 @@ returns
end
local_attributes['member_ids'] = 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 ]
user = User.lookup(id: local_user_id)
next if !user
@ -55,7 +55,7 @@ returns
data[ Organization.to_app_model ][ id ] = local_attributes
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 data[ User.to_app_model ][ 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(
'users.firstname LIKE ? or users.lastname LIKE ? or users.email LIKE ?', "%#{query}%", "%#{query}%", "%#{query}%"
).order('organizations.name').limit(limit)
organizations_by_user.each {|organization_by_user|
organizations_by_user.each { |organization_by_user|
organization_exists = false
organizations.each {|organization|
organizations.each { |organization|
if organization.id == organization_by_user.id
organization_exists = true
end

View file

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

View file

@ -32,7 +32,7 @@ returns
if !data[ Overview.to_app_model ][ id ]
data[ Overview.to_app_model ][ id ] = attributes_with_associations
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 ]
user = User.lookup(id: local_user_id)
next if !user
@ -43,7 +43,7 @@ returns
data = assets_of_selector('condition', data)
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 data[ User.to_app_model ][ 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
end
end
data.each {|file|
data.each { |file|
install(file: "#{path}/#{file}")
}
data
@ -370,7 +370,7 @@ execute all pending package migrations at once
=end
def self.migration_execute
Package.all.each {|package|
Package.all.each { |package|
json_file = Package._get_bin(package.name, package.version)
package = JSON.parse(json_file)
Package::Migration.migrate(package['name'])
@ -435,16 +435,16 @@ execute all pending package migrations at once
# check if directories need to be created
directories = location.split '/'
(0..(directories.length - 2) ).each {|position|
(0..(directories.length - 2) ).each { |position|
tmp_path = ''
(1..position).each {|count|
(1..position).each { |count|
tmp_path = "#{tmp_path}/#{directories[count]}"
}
next if tmp_path == ''
next if File.exist?(tmp_path)
Dir.mkdir(tmp_path, 0755)
Dir.mkdir(tmp_path, 0o755)
}
# install file
@ -490,7 +490,7 @@ execute all pending package migrations at once
# get existing migrations
migrations_existing = []
Dir.foreach(location) {|entry|
Dir.foreach(location) { |entry|
next if entry == '.'
next if entry == '..'
migrations_existing.push entry
@ -504,7 +504,7 @@ execute all pending package migrations at once
migrations_existing = migrations_existing.reverse
end
migrations_existing.each {|migration|
migrations_existing.each { |migration|
next if migration !~ /\.rb$/
version = nil
name = nil

View file

@ -302,8 +302,8 @@ class Report
]
config[:metric][:communication][:backend] = backend
config[:metric].each {|metric_key, metric_value|
metric_value[:backend].each {|metric_backend|
config[:metric].each { |metric_key, metric_value|
metric_value[:backend].each { |metric_backend|
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
jobs = Scheduler.where('active = ?', true).order('prio ASC')
jobs.each {|job|
jobs.each { |job|
# ignore job is still running
next if @@jobs_started[ job.id ]

View file

@ -39,7 +39,7 @@ returns
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 data[ User.to_app_model ][ 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)
success = true
Store::File.all.each {|item|
Store::File.all.each { |item|
content = item.content
sha = Digest::SHA256.hexdigest(content)
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_target = load_adapter("Store::Provider::#{target}")
Store::File.all.each {|item|
Store::File.all.each { |item|
next if item.provider == target
content = item.content

View file

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

View file

@ -116,7 +116,7 @@ returns
o_id: data[:o_id],
)
tags = []
tag_search.each {|tag|
tag_search.each { |tag|
tag_item = Tag::Item.lookup(id: tag.tag_item_id)
next if !tag_item
tags.push tag_item.name
@ -189,7 +189,7 @@ rename tag items
if 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
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
# 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.touch_reference_by_params(
object: tag_object.name,
@ -246,7 +246,7 @@ remove tag item (destroy with reverences)
def self.remove(id)
# 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.destroy
Tag.touch_reference_by_params(

View file

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

View file

@ -48,7 +48,7 @@ class Ticket::Article < ApplicationModel
replace = item
# look for attachment
attachments.each {|file|
attachments.each { |file|
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}"
inline_attachments[file.id] = true
@ -57,7 +57,7 @@ class Ticket::Article < ApplicationModel
replace
}
new_attachments = []
attachments.each {|file|
attachments.each { |file|
next if inline_attachments[file.id]
new_attachments.push file
}

View file

@ -55,7 +55,7 @@ returns
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 data[ User.to_app_model ] && data[ User.to_app_model ][ 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 ]
data[ Ticket.to_app_model ][ id ] = attributes_with_associations
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 data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ])

View file

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

View file

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

View file

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

View file

@ -31,7 +31,7 @@ module Ticket::Number::Increment
min_digs = min_digs.to_i - 1
end
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

View file

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

View file

@ -37,7 +37,7 @@ returns
return true if owner_id == data[:current_user].id
# 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
}
false

View file

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

View file

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

View file

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

View file

@ -22,7 +22,7 @@ class Transaction::BackgroundJob
end
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))
Observer::Transaction.execute_singel_backend(backend, @item, @params)
}

View file

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

View file

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

View file

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

View file

@ -40,7 +40,7 @@ class Transaction::Trigger
original_user_id = UserInfo.current_user_id
UserInfo.current_user_id = 1
triggers.each {|trigger|
triggers.each { |trigger|
condition = trigger.condition
# check action
@ -49,7 +49,28 @@ class Transaction::Trigger
next if condition['ticket.action']['operator'] != 'is' && condition['ticket.action']['value'] == @item[:type]
condition.delete('ticket.action')
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
condition['ticket.id'] = {
operator: 'is',

View file

@ -24,13 +24,13 @@ dedicated:
locales_list = []
if !dedicated_locale
locales = Locale.to_sync
locales.each {|locale|
locales.each { |locale|
locales_list.push locale.locale
}
else
locales_list = [dedicated_locale]
end
locales_list.each {|locale|
locales_list.each { |locale|
url = "https://i18n.zammad.com/api/v1/translations/#{locale}"
if !UserInfo.current_user_id
UserInfo.current_user_id = 1
@ -48,11 +48,11 @@ dedicated:
translations = Translation.where(locale: locale).all
ActiveRecord::Base.transaction do
result.data.each {|translation_raw|
result.data.each { |translation_raw|
# handle case insensitive sql
translation = nil
translations.each {|item|
translations.each { |item|
next if item.format != translation_raw['format']
next if item.source != translation_raw['source']
translation = item
@ -62,7 +62,7 @@ dedicated:
# verify if update is needed
update_needed = false
translation_raw.each {|key, _value|
translation_raw.each { |key, _value|
if translation_raw[key] != translation[key]
update_needed = true
break
@ -94,7 +94,7 @@ push translations to online
# only push changed translations
translations = Translation.where(locale: locale)
translations_to_push = []
translations.each {|translation|
translations.each { |translation|
if translation.target != translation.target_initial
translations_to_push.push translation
end
@ -142,7 +142,7 @@ reset translations to origin
# only push changed translations
translations = Translation.where(locale: locale)
translations.each {|translation|
translations.each { |translation|
if !translation.target_initial || translation.target_initial.empty?
translation.destroy
elsif translation.target != translation.target_initial
@ -203,8 +203,8 @@ get list of translations
# add presorted on top
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|
list.each {|item|
%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|
next if item[1] != presort
presorted_list.push item
list.delete item
@ -233,13 +233,13 @@ translate strings in ruby context, e. g. for notifications
# translate string
records = Translation.where(locale: locale, source: string)
records.each {|record|
records.each { |record|
return record.target if record.source == string
}
# fallback lookup in en
records = Translation.where(locale: 'en', source: string)
records.each {|record|
records.each { |record|
return record.target if record.source == string
}

View file

@ -290,7 +290,7 @@ returns
roles = Role.where(name: 'Customer')
url = ''
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.empty?
url = local_url
@ -539,7 +539,7 @@ returns
def self.update_default_preferences(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_preferences_default
user.save
@ -555,7 +555,7 @@ returns
if !@preferences_default
@preferences_default = {}
end
default[o.name].each {|key, value|
default[o.name].each { |key, value|
next if @preferences_default[key]
@preferences_default[key] = value
}

View file

@ -62,7 +62,7 @@ returns
end
local_attributes['role_ids'] = 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)
data = role.assets(data)
}
@ -77,7 +77,7 @@ returns
end
local_attributes['group_ids'] = 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)
next if !group
data = group.assets(data)
@ -93,7 +93,7 @@ returns
end
local_attributes['organization_ids'] = 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)
next if !organization
data = organization.assets(data)
@ -112,7 +112,7 @@ returns
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 data[ User.to_app_model ][ 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,
fingerprint: fingerprint,
)
user_devices.each {|local_user_device|
user_devices.each { |local_user_device|
device_exists_by_fingerprint = true
next if local_user_device.location != location
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_agent: user_agent,
)
user_devices.each {|local_user_device|
user_devices.each { |local_user_device|
device_exists_by_user_agent = true
next if local_user_device.location != location
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.
# 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( print.css )
Rails.application.config.assets.precompile += %w(application-print.css)
Rails.application.config.assets.precompile += %w(print.css)

View file

@ -1,5 +1,5 @@
# 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)
require file
end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -64,7 +64,7 @@ module Auth::Ldap
source: 'ldap',
updated_by_id: 1,
}
config[:sync_params].each {|local_data, ldap_data|
config[:sync_params].each { |local_data, ldap_data|
if user_data[ ldap_data.downcase.to_sym ]
user_attributes[ local_data.downcase.to_sym] = user_data[ ldap_data.downcase.to_sym ]
end
@ -91,7 +91,7 @@ module Auth::Ldap
# set always roles
if config[:always_roles]
role_ids = user.role_ids
config[:always_roles].each {|role_name|
config[:always_roles].each { |role_name|
role = Role.where( name: role_name ).first
next if !role
if !role_ids.include?( role.id )
@ -105,7 +105,7 @@ module Auth::Ldap
# set always groups
if config[:always_groups]
group_ids = user.group_ids
config[:always_groups].each {|group_name|
config[:always_groups].each { |group_name|
group = Group.where( name: group_name ).first
next if !group
if !group_ids.include?( group.id )

View file

@ -81,9 +81,9 @@ returns
model_map = {
'Organizations' => 'Organization',
}
model_map.each {|map_name, model|
model_map.each { |map_name, model|
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)
data.symbolize_keys!
generic_object.create_or_update_with_ref(data)
@ -126,9 +126,9 @@ returns
'Signatures' => 'Signature',
'Groups' => 'Group',
}
model_map.each {|map_name, model|
model_map.each { |map_name, model|
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)
data.symbolize_keys!
generic_object.create_or_update_with_ref(data)

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