Corrected with rubocop cop 'Style/HashSyntax'.

This commit is contained in:
Thorsten Eckel 2015-04-27 15:42:53 +02:00
parent 540c99fcaf
commit ce58d465c0
284 changed files with 10121 additions and 10128 deletions

View file

@ -167,13 +167,6 @@ Style/SymbolProc:
Description: 'Use symbols as procs instead of blocks when possible.'
Enabled: false
Style/HashSyntax:
Description: >-
Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
{ :a => 1, :b => 2 }.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-literals'
Enabled: false
Style/RedundantBegin:
Description: "Don't use begin blocks when they are not needed."
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#begin-implicit'

View file

@ -74,10 +74,10 @@ group :development, :test do
gem 'selenium-webdriver'
# livereload on template changes (html, js, css)
gem 'guard', '>= 2.2.2', :require => false
gem 'guard-livereload', :require => false
gem 'guard', '>= 2.2.2', require: false
gem 'guard-livereload', require: false
gem 'rack-livereload'
gem 'rb-fsevent', :require => false
gem 'rb-fsevent', require: false
# code QA
gem 'rubocop'

View file

@ -1,7 +1,7 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'livereload', :port => '35738' do
guard 'livereload', port: '35738' do
watch(%r{app/views/.+\.(erb|haml|slim)$})
watch(%r{app/helpers/.+\.rb})
watch(%r{public/.+\.(css|js|html)})

View file

@ -8,7 +8,7 @@ class ActivityStreamController < ApplicationController
activity_stream = current_user.activity_stream( params[:limit], true )
# return result
render :json => activity_stream
render json: activity_stream
end
end

View file

@ -41,7 +41,7 @@ class ApplicationController < ActionController::Base
headers['Access-Control-Allow-Headers'] = 'Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control, Accept-Language'
headers['Access-Control-Max-Age'] = '1728000'
headers['Access-Control-Allow-Credentials'] = 'true'
render :text => '', :content_type => 'text/plain'
render text: '', content_type: 'text/plain'
return false
end
end
@ -123,20 +123,20 @@ class ApplicationController < ActionController::Base
# set basic auth user to current user
current_user_set(userdata)
return {
:auth => true
auth: true
}
end
# return auth not ok
return {
:auth => false,
:message => message,
auth: false,
message: message,
}
end
# check logon session
if params['logon_session']
logon_session = ActiveRecord::SessionStore::Session.where( :session_id => params['logon_session'] ).first
logon_session = ActiveRecord::SessionStore::Session.where( session_id: params['logon_session'] ).first
if logon_session
userdata = User.find( logon_session.data[:user_id] )
end
@ -146,7 +146,7 @@ class ApplicationController < ActionController::Base
# set logon session user to current user
current_user_set(userdata)
return {
:auth => true
auth: true
}
end
@ -166,13 +166,13 @@ class ApplicationController < ActionController::Base
puts 'no valid session, user_id'
message = 'no valid session, user_id'
return {
:auth => false,
:message => message,
auth: false,
message: message,
}
end
return {
:auth => true
auth: true
}
end
@ -182,10 +182,10 @@ class ApplicationController < ActionController::Base
# return auth not ok
if result[:auth] == false
render(
:json => {
:error => result[:message],
json: {
error: result[:message],
},
:status => :unauthorized
status: :unauthorized
)
return false
end
@ -197,8 +197,8 @@ class ApplicationController < ActionController::Base
def authentication_check_action_token(action)
user = Token.check(
:action => action,
:name => params[:action_token],
action: action,
name: params[:action_token],
)
if !user
@ -219,7 +219,7 @@ class ApplicationController < ActionController::Base
end
def ticket_permission(ticket)
return true if ticket.permission( :current_user => current_user )
return true if ticket.permission( current_user: current_user )
response_access_deny
false
end
@ -236,14 +236,14 @@ class ApplicationController < ActionController::Base
def valid_session_with_user
return true if current_user
render :json => { :message => 'No session user!' }, :status => :unprocessable_entity
render json: { message: 'No session user!' }, status: :unprocessable_entity
false
end
def response_access_deny
render(
:json => {},
:status => :unauthorized
json: {},
status: :unauthorized
)
false
end
@ -252,7 +252,7 @@ class ApplicationController < ActionController::Base
# config
config = {}
Setting.select('name').where( :frontend => true ).each { |setting|
Setting.select('name').where( frontend: true ).each { |setting|
config[setting.name] = Setting.get(setting.name)
}
@ -296,11 +296,11 @@ class ApplicationController < ActionController::Base
puts e.message.inspect
logger.error e.message
logger.error e.backtrace.inspect
render :json => { :error => e.message }, :status => :unprocessable_entity
render json: { error: e.message }, status: :unprocessable_entity
end
end
def model_create_render_item (generic_object)
render :json => generic_object.attributes_with_associations, :status => :created
render json: generic_object.attributes_with_associations, status: :created
end
def model_update_render (object, params)
@ -319,11 +319,11 @@ class ApplicationController < ActionController::Base
rescue Exception => e
logger.error e.message
logger.error e.backtrace.inspect
render :json => { :error => e.message }, :status => :unprocessable_entity
render json: { error: e.message }, status: :unprocessable_entity
end
end
def model_update_render_item (generic_object)
render :json => generic_object.attributes_with_associations, :status => :ok
render json: generic_object.attributes_with_associations, status: :ok
end
def model_destory_render (object, params)
@ -334,11 +334,11 @@ class ApplicationController < ActionController::Base
rescue Exception => e
logger.error e.message
logger.error e.backtrace.inspect
render :json => { :error => e.message }, :status => :unprocessable_entity
render json: { error: e.message }, status: :unprocessable_entity
end
end
def model_destory_render_item ()
render :json => {}, :status => :ok
render json: {}, status: :ok
end
def model_show_render (object, params)
@ -346,7 +346,7 @@ class ApplicationController < ActionController::Base
if params[:full]
generic_object_full = object.full( params[:id] )
render :json => generic_object_full, :status => :ok
render json: generic_object_full, status: :ok
return
end
@ -355,11 +355,11 @@ class ApplicationController < ActionController::Base
rescue Exception => e
logger.error e.message
logger.error e.backtrace.inspect
render :json => { :error => e.message }, :status => :unprocessable_entity
render json: { error: e.message }, status: :unprocessable_entity
end
end
def model_show_render_item (generic_object)
render :json => generic_object.attributes_with_associations, :status => :ok
render json: generic_object.attributes_with_associations, status: :ok
end
def model_index_render (object, params)
@ -369,11 +369,11 @@ class ApplicationController < ActionController::Base
rescue Exception => e
logger.error e.message
logger.error e.backtrace.inspect
render :json => { :error => e.message }, :status => :unprocessable_entity
render json: { error: e.message }, status: :unprocessable_entity
end
end
def model_index_render_result (generic_objects)
render :json => generic_objects, :status => :ok
render json: generic_objects, status: :ok
end
end

View file

@ -44,12 +44,12 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# set system init to done
Setting.set( 'system_init_done', true )
render :json => {
:auto_wizard => true,
:setup_done => setup_done,
:import_mode => Setting.get('import_mode'),
:import_backend => Setting.get('import_backend'),
:system_online_service => Setting.get('system_online_service'),
render json: {
auto_wizard: true,
setup_done: setup_done,
import_mode: Setting.get('import_mode'),
import_backend: Setting.get('import_backend'),
system_online_service: Setting.get('system_online_service'),
}
return
end
@ -60,11 +60,11 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
# return result
render :json => {
:setup_done => setup_done,
:import_mode => Setting.get('import_mode'),
:import_backend => Setting.get('import_backend'),
:system_online_service => Setting.get('system_online_service'),
render json: {
setup_done: setup_done,
import_mode: Setting.get('import_mode'),
import_backend: Setting.get('import_backend'),
system_online_service: Setting.get('system_online_service'),
}
end
@ -97,9 +97,9 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
if !messages.empty?
render :json => {
:result => 'invalid',
:messages => messages,
render json: {
result: 'invalid',
messages: messages,
}
return
end
@ -143,9 +143,9 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
Setting.set(key, value)
}
render :json => {
:result => 'ok',
:settings => settings,
render json: {
result: 'ok',
settings: settings,
}
end
@ -163,10 +163,10 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
if !user || !domain
render :json => {
:result => 'invalid',
:messages => {
:email => 'Invalid email.'
render json: {
result: 'invalid',
messages: {
email: 'Invalid email.'
},
}
return
@ -174,49 +174,49 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# check domain based attributes
providerMap = {
:google => {
:domain => 'gmail.com|googlemail.com|gmail.de',
:inbound => {
:adapter => 'imap',
:options => {
:host => 'imap.gmail.com',
:port => '993',
:ssl => true,
:user => params[:email],
:password => params[:password],
google: {
domain: 'gmail.com|googlemail.com|gmail.de',
inbound: {
adapter: 'imap',
options: {
host: 'imap.gmail.com',
port: '993',
ssl: true,
user: params[:email],
password: params[:password],
},
},
:outbound => {
:adapter => 'smtp',
:options => {
:host => 'smtp.gmail.com',
:port => '25',
:start_tls => true,
:user => params[:email],
:password => params[:password],
outbound: {
adapter: 'smtp',
options: {
host: 'smtp.gmail.com',
port: '25',
start_tls: true,
user: params[:email],
password: params[:password],
}
},
},
:microsoft => {
:domain => 'outlook.com|hotmail.com',
:inbound => {
:adapter => 'imap',
:options => {
:host => 'imap-mail.outlook.com',
:port => '993',
:ssl => true,
:user => params[:email],
:password => params[:password],
microsoft: {
domain: 'outlook.com|hotmail.com',
inbound: {
adapter: 'imap',
options: {
host: 'imap-mail.outlook.com',
port: '993',
ssl: true,
user: params[:email],
password: params[:password],
},
},
:outbound => {
:adapter => 'smtp',
:options => {
:host => 'smtp-mail.outlook.com',
:port => 25,
:start_tls => true,
:user => params[:email],
:password => params[:password],
outbound: {
adapter: 'smtp',
options: {
host: 'smtp-mail.outlook.com',
port: 25,
start_tls: true,
user: params[:email],
password: params[:password],
}
},
},
@ -238,20 +238,20 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# probe inbound
result = email_probe_inbound( settings[:inbound] )
if result[:result] != 'ok'
render :json => result
render json: result
return
end
# probe outbound
result = email_probe_outbound( settings[:outbound], params[:email] )
if result[:result] != 'ok'
render :json => result
render json: result
return
end
render :json => {
:result => 'ok',
:setting => settings,
render json: {
result: 'ok',
setting: settings,
}
return
end
@ -263,23 +263,23 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
inboundMx = [
{
:adapter => 'imap',
:options => {
:host => mail_exchangers[0][0],
:port => 993,
:ssl => true,
:user => user,
:password => params[:password],
adapter: 'imap',
options: {
host: mail_exchangers[0][0],
port: 993,
ssl: true,
user: user,
password: params[:password],
},
},
{
:adapter => 'imap',
:options => {
:host => mail_exchangers[0][0],
:port => 993,
:ssl => true,
:user => params[:email],
:password => params[:password],
adapter: 'imap',
options: {
host: mail_exchangers[0][0],
port: 993,
ssl: true,
user: params[:email],
password: params[:password],
},
},
]
@ -287,103 +287,103 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
inboundAuto = [
{
:adapter => 'imap',
:options => {
:host => "mail.#{domain}",
:port => 993,
:ssl => true,
:user => user,
:password => params[:password],
adapter: 'imap',
options: {
host: "mail.#{domain}",
port: 993,
ssl: true,
user: user,
password: params[:password],
},
},
{
:adapter => 'imap',
:options => {
:host => "mail.#{domain}",
:port => 993,
:ssl => true,
:user => params[:email],
:password => params[:password],
adapter: 'imap',
options: {
host: "mail.#{domain}",
port: 993,
ssl: true,
user: params[:email],
password: params[:password],
},
},
{
:adapter => 'imap',
:options => {
:host => "imap.#{domain}",
:port => 993,
:ssl => true,
:user => user,
:password => params[:password],
adapter: 'imap',
options: {
host: "imap.#{domain}",
port: 993,
ssl: true,
user: user,
password: params[:password],
},
},
{
:adapter => 'imap',
:options => {
:host => "imap.#{domain}",
:port => 993,
:ssl => true,
:user => params[:email],
:password => params[:password],
adapter: 'imap',
options: {
host: "imap.#{domain}",
port: 993,
ssl: true,
user: params[:email],
password: params[:password],
},
},
{
:adapter => 'pop3',
:options => {
:host => "mail.#{domain}",
:port => 995,
:ssl => true,
:user => user,
:password => params[:password],
adapter: 'pop3',
options: {
host: "mail.#{domain}",
port: 995,
ssl: true,
user: user,
password: params[:password],
},
},
{
:adapter => 'pop3',
:options => {
:host => "mail.#{domain}",
:port => 995,
:ssl => true,
:user => params[:email],
:password => params[:password],
adapter: 'pop3',
options: {
host: "mail.#{domain}",
port: 995,
ssl: true,
user: params[:email],
password: params[:password],
},
},
{
:adapter => 'pop3',
:options => {
:host => "pop.#{domain}",
:port => 995,
:ssl => true,
:user => user,
:password => params[:password],
adapter: 'pop3',
options: {
host: "pop.#{domain}",
port: 995,
ssl: true,
user: user,
password: params[:password],
},
},
{
:adapter => 'pop3',
:options => {
:host => "pop.#{domain}",
:port => 995,
:ssl => true,
:user => params[:email],
:password => params[:password],
adapter: 'pop3',
options: {
host: "pop.#{domain}",
port: 995,
ssl: true,
user: params[:email],
password: params[:password],
},
},
{
:adapter => 'pop3',
:options => {
:host => "pop3.#{domain}",
:port => 995,
:ssl => true,
:user => user,
:password => params[:password],
adapter: 'pop3',
options: {
host: "pop3.#{domain}",
port: 995,
ssl: true,
user: user,
password: params[:password],
},
},
{
:adapter => 'pop3',
:options => {
:host => "pop3.#{domain}",
:port => 995,
:ssl => true,
:user => params[:email],
:password => params[:password],
adapter: 'pop3',
options: {
host: "pop3.#{domain}",
port: 995,
ssl: true,
user: params[:email],
password: params[:password],
},
},
]
@ -402,8 +402,8 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
}
if !success
render :json => {
:result => 'failed',
render json: {
result: 'failed',
}
return
end
@ -413,43 +413,43 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
outboundMx = [
{
:adapter => 'smtp',
:options => {
:host => mail_exchangers[0][0],
:port => 25,
:start_tls => true,
:user => user,
:password => params[:password],
adapter: 'smtp',
options: {
host: mail_exchangers[0][0],
port: 25,
start_tls: true,
user: user,
password: params[:password],
},
},
{
:adapter => 'smtp',
:options => {
:host => mail_exchangers[0][0],
:port => 25,
:start_tls => true,
:user => params[:email],
:password => params[:password],
adapter: 'smtp',
options: {
host: mail_exchangers[0][0],
port: 25,
start_tls: true,
user: params[:email],
password: params[:password],
},
},
{
:adapter => 'smtp',
:options => {
:host => mail_exchangers[0][0],
:port => 465,
:start_tls => true,
:user => user,
:password => params[:password],
adapter: 'smtp',
options: {
host: mail_exchangers[0][0],
port: 465,
start_tls: true,
user: user,
password: params[:password],
},
},
{
:adapter => 'smtp',
:options => {
:host => mail_exchangers[0][0],
:port => 465,
:start_tls => true,
:user => params[:email],
:password => params[:password],
adapter: 'smtp',
options: {
host: mail_exchangers[0][0],
port: 465,
start_tls: true,
user: params[:email],
password: params[:password],
},
},
]
@ -457,83 +457,83 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
outboundAuto = [
{
:adapter => 'smtp',
:options => {
:host => "mail.#{domain}",
:port => 25,
:start_tls => true,
:user => user,
:password => params[:password],
adapter: 'smtp',
options: {
host: "mail.#{domain}",
port: 25,
start_tls: true,
user: user,
password: params[:password],
},
},
{
:adapter => 'smtp',
:options => {
:host => "mail.#{domain}",
:port => 25,
:start_tls => true,
:user => params[:email],
:password => params[:password],
adapter: 'smtp',
options: {
host: "mail.#{domain}",
port: 25,
start_tls: true,
user: params[:email],
password: params[:password],
},
},
{
:adapter => 'smtp',
:options => {
:host => "mail.#{domain}",
:port => 465,
:start_tls => true,
:user => user,
:password => params[:password],
adapter: 'smtp',
options: {
host: "mail.#{domain}",
port: 465,
start_tls: true,
user: user,
password: params[:password],
},
},
{
:adapter => 'smtp',
:options => {
:host => "mail.#{domain}",
:port => 465,
:start_tls => true,
:user => params[:email],
:password => params[:password],
adapter: 'smtp',
options: {
host: "mail.#{domain}",
port: 465,
start_tls: true,
user: params[:email],
password: params[:password],
},
},
{
:adapter => 'smtp',
:options => {
:host => "smtp.#{domain}",
:port => 25,
:start_tls => true,
:user => user,
:password => params[:password],
adapter: 'smtp',
options: {
host: "smtp.#{domain}",
port: 25,
start_tls: true,
user: user,
password: params[:password],
},
},
{
:adapter => 'smtp',
:options => {
:host => "smtp.#{domain}",
:port => 25,
:start_tls => true,
:user => params[:email],
:password => params[:password],
adapter: 'smtp',
options: {
host: "smtp.#{domain}",
port: 25,
start_tls: true,
user: params[:email],
password: params[:password],
},
},
{
:adapter => 'smtp',
:options => {
:host => "smtp.#{domain}",
:port => 465,
:start_tls => true,
:user => user,
:password => params[:password],
adapter: 'smtp',
options: {
host: "smtp.#{domain}",
port: 465,
start_tls: true,
user: user,
password: params[:password],
},
},
{
:adapter => 'smtp',
:options => {
:host => "smtp.#{domain}",
:port => 465,
:start_tls => true,
:user => params[:email],
:password => params[:password],
adapter: 'smtp',
options: {
host: "smtp.#{domain}",
port: 465,
start_tls: true,
user: params[:email],
password: params[:password],
},
},
]
@ -551,15 +551,15 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
}
if !success
render :json => {
:result => 'failed',
render json: {
result: 'failed',
}
return
end
render :json => {
:result => 'ok',
:setting => settings,
render json: {
result: 'ok',
setting: settings,
}
end
@ -570,8 +570,8 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# validate params
if !params[:adapter]
render :json => {
:result => 'invalid',
render json: {
result: 'invalid',
}
return
end
@ -579,7 +579,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# connection test
result = email_probe_outbound( params, params[:email] )
render :json => result
render json: result
end
def email_inbound
@ -589,8 +589,8 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# validate params
if !params[:adapter]
render :json => {
:result => 'invalid',
render json: {
result: 'invalid',
}
return
end
@ -598,7 +598,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# connection test
result = email_probe_inbound( params )
render :json => result
render json: result
return
end
@ -623,15 +623,15 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
begin
if params[:inbound][:adapter] =~ /^imap$/i
found = Channel::IMAP.new.fetch( { :options => params[:inbound][:options] }, 'verify', subject )
found = Channel::IMAP.new.fetch( { options: params[:inbound][:options] }, 'verify', subject )
else
found = Channel::POP3.new.fetch( { :options => params[:inbound][:options] }, 'verify', subject )
found = Channel::POP3.new.fetch( { options: params[:inbound][:options] }, 'verify', subject )
end
rescue Exception => e
render :json => {
:result => 'invalid',
:message => e.to_s,
:subject => subject,
render json: {
result: 'invalid',
message: e.to_s,
subject: subject,
}
return
end
@ -639,70 +639,70 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
if found && found == 'verify ok'
# remember address
address = EmailAddress.where( :email => params[:meta][:email] ).first
address = EmailAddress.where( email: params[:meta][:email] ).first
if !address
address = EmailAddress.first
end
if address
address.update_attributes(
:realname => params[:meta][:realname],
:email => params[:meta][:email],
:active => 1,
:updated_by_id => 1,
:created_by_id => 1,
realname: params[:meta][:realname],
email: params[:meta][:email],
active: 1,
updated_by_id: 1,
created_by_id: 1,
)
else
EmailAddress.create(
:realname => params[:meta][:realname],
:email => params[:meta][:email],
:active => 1,
:updated_by_id => 1,
:created_by_id => 1,
realname: params[:meta][:realname],
email: params[:meta][:email],
active: 1,
updated_by_id: 1,
created_by_id: 1,
)
end
# store mailbox
Channel.create(
:area => 'Email::Inbound',
:adapter => params[:inbound][:adapter],
:options => params[:inbound][:options],
:group_id => 1,
:active => 1,
:updated_by_id => 1,
:created_by_id => 1,
area: 'Email::Inbound',
adapter: params[:inbound][:adapter],
options: params[:inbound][:options],
group_id: 1,
active: 1,
updated_by_id: 1,
created_by_id: 1,
)
# save settings
if params[:outbound][:adapter] =~ /^smtp$/i
smtp = Channel.where( :adapter => 'SMTP', :area => 'Email::Outbound' ).first
smtp = Channel.where( adapter: 'SMTP', area: 'Email::Outbound' ).first
smtp.options = params[:outbound][:options]
smtp.active = true
smtp.save!
sendmail = Channel.where( :adapter => 'Sendmail' ).first
sendmail = Channel.where( adapter: 'Sendmail' ).first
sendmail.active = false
sendmail.save!
else
sendmail = Channel.where( :adapter => 'Sendmail', :area => 'Email::Outbound' ).first
sendmail = Channel.where( adapter: 'Sendmail', area: 'Email::Outbound' ).first
sendmail.options = {}
sendmail.active = true
sendmail.save!
smtp = Channel.where( :adapter => 'SMTP' ).first
smtp = Channel.where( adapter: 'SMTP' ).first
smtp.active = false
smtp.save
end
render :json => {
:result => 'ok',
render json: {
result: 'ok',
}
return
end
}
# check delivery for 30 sek.
render :json => {
:result => 'invalid',
:message => 'Verification Email not found in mailbox.',
:subject => subject,
render json: {
result: 'invalid',
message: 'Verification Email not found in mailbox.',
subject: subject,
}
end
@ -713,8 +713,8 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# validate params
if !params[:adapter]
result = {
:result => 'invalid',
:message => 'Invalid, need adapter!',
result: 'invalid',
message: 'Invalid, need adapter!',
}
return result
end
@ -729,10 +729,10 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
}
else
mail = {
:from => email,
:to => 'emailtrytest@znuny.com',
:subject => 'test',
:body => 'test',
from: email,
to: 'emailtrytest@znuny.com',
subject: 'test',
body: 'test',
}
end
@ -758,7 +758,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
Channel::SMTP.new.send(
mail,
{
:options => params[:options]
options: params[:options]
}
)
rescue Exception => e
@ -771,9 +771,9 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
whiteMap.each {|key, message|
if e.message =~ /#{Regexp.escape(key)}/i
result = {
:result => 'ok',
:settings => params,
:notice => e.message,
result: 'ok',
settings: params,
notice: e.message,
}
return result
end
@ -786,15 +786,15 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
}
result = {
:result => 'invalid',
:settings => params,
:message => e.message,
:message_human => message_human,
result: 'invalid',
settings: params,
message: e.message,
message_human: message_human,
}
return result
end
result = {
:result => 'ok',
result: 'ok',
}
return result
end
@ -812,15 +812,15 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
}
result = {
:result => 'invalid',
:settings => params,
:message => e.message,
:message_human => message_human,
result: 'invalid',
settings: params,
message: e.message,
message_human: message_human,
}
return result
end
result = {
:result => 'ok',
result: 'ok',
}
return result
end
@ -843,7 +843,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
if params[:adapter] =~ /^imap$/i
begin
Channel::IMAP.new.fetch( { :options => params[:options] }, 'check' )
Channel::IMAP.new.fetch( { options: params[:options] }, 'check' )
rescue Exception => e
message_human = ''
translationMap.each {|key, message|
@ -852,21 +852,21 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
}
result = {
:result => 'invalid',
:settings => params,
:message => e.message,
:message_human => message_human,
result: 'invalid',
settings: params,
message: e.message,
message_human: message_human,
}
return result
end
result = {
:result => 'ok',
result: 'ok',
}
return result
end
begin
Channel::POP3.new.fetch( { :options => params[:options] }, 'check' )
Channel::POP3.new.fetch( { options: params[:options] }, 'check' )
rescue Exception => e
message_human = ''
translationMap.each {|key, message|
@ -875,15 +875,15 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
}
result = {
:result => 'invalid',
:settings => params,
:message => e.message,
:message_human => message_human,
result: 'invalid',
settings: params,
message: e.message,
message_human: message_human,
}
return result
end
result = {
:result => 'ok',
result: 'ok',
}
return result
end
@ -917,18 +917,18 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
# get all groups
groups = Group.where( :active => true )
groups = Group.where( active: true )
# get email addresses
addresses = EmailAddress.where( :active => true )
addresses = EmailAddress.where( active: true )
render :json => {
:setup_done => true,
:import_mode => Setting.get('import_mode'),
:import_backend => Setting.get('import_backend'),
:system_online_service => Setting.get('system_online_service'),
:addresses => addresses,
:groups => groups,
render json: {
setup_done: true,
import_mode: Setting.get('import_mode'),
import_backend: Setting.get('import_backend'),
system_online_service: Setting.get('system_online_service'),
addresses: addresses,
groups: groups,
}
true
end

View file

@ -74,8 +74,8 @@ class IcalTicketsController < ApplicationController
condition = {
'tickets.owner_id' => current_user.id,
'tickets.state_id' => Ticket::State.where(
:state_type_id => Ticket::StateType.where(
:name => [
state_type_id: Ticket::StateType.where(
name: [
'new',
'open',
],
@ -84,8 +84,8 @@ class IcalTicketsController < ApplicationController
}
tickets = Ticket.search(
:current_user => current_user,
:condition => condition,
current_user: current_user,
condition: condition,
)
events_data = []
@ -109,8 +109,8 @@ class IcalTicketsController < ApplicationController
condition = {
'tickets.owner_id' => current_user.id,
'tickets.state_id' => Ticket::State.where(
:state_type_id => Ticket::StateType.where(
:name => [
state_type_id: Ticket::StateType.where(
name: [
'pending reminder',
'pending action',
],
@ -119,8 +119,8 @@ class IcalTicketsController < ApplicationController
}
tickets = Ticket.search(
:current_user => current_user,
:condition => condition,
current_user: current_user,
condition: condition,
)
events_data = []
@ -148,8 +148,8 @@ class IcalTicketsController < ApplicationController
]
tickets = Ticket.search(
:current_user => current_user,
:condition => condition,
current_user: current_user,
condition: condition,
)
events_data = []
@ -186,9 +186,9 @@ class IcalTicketsController < ApplicationController
send_data(
cal.to_ical,
:filename => 'zammad.ical',
:type => 'text/plain',
:disposition => 'inline'
filename: 'zammad.ical',
type: 'text/plain',
disposition: 'inline'
)
end

View file

@ -8,9 +8,9 @@ class ImportOtrsController < ApplicationController
# validate
if !params[:url] ||params[:url] !~ /^(http|https):\/\/.+?$/
render :json => {
:result => 'invalid',
:message => 'Invalid!',
render json: {
result: 'invalid',
message: 'Invalid!',
}
return
end
@ -32,10 +32,10 @@ class ImportOtrsController < ApplicationController
message_human = message
end
}
render :json => {
:result => 'invalid',
:message_human => message_human,
:message => response.error.to_s,
render json: {
result: 'invalid',
message_human: message_human,
message: response.error.to_s,
}
return
end
@ -53,9 +53,9 @@ class ImportOtrsController < ApplicationController
Setting.set('import_otrs_endpoint', url)
Setting.set('import_otrs_endpoint_key', '01234567899876543210')
if response.body =~ /zammad migrator/
render :json => {
:url => url,
:result => 'ok',
render json: {
url: url,
result: 'ok',
}
return
elsif response.body =~ /(otrs\sag|otrs.com|otrs.org)/i
@ -65,9 +65,9 @@ class ImportOtrsController < ApplicationController
# return result
render :json => {
:result => 'invalid',
:message_human => message_human,
render json: {
result: 'invalid',
message_human: message_human,
}
end
@ -77,9 +77,9 @@ class ImportOtrsController < ApplicationController
Setting.set('import_mode', true)
welcome = Import::OTRS2.connection_test
if !welcome
render :json => {
:message => 'Migrator can\'t read OTRS output!',
:result => 'invalid',
render json: {
message: 'Migrator can\'t read OTRS output!',
result: 'invalid',
}
return
end
@ -87,8 +87,8 @@ class ImportOtrsController < ApplicationController
# start migration
Import::OTRS2.delay.start
render :json => {
:result => 'ok',
render json: {
result: 'ok',
}
end
@ -97,9 +97,9 @@ class ImportOtrsController < ApplicationController
state = Import::OTRS2.get_current_state
render :json => {
:data => state,
:result => 'in_progress',
render json: {
data: state,
result: 'in_progress',
}
end
@ -119,8 +119,8 @@ class ImportOtrsController < ApplicationController
if !setup_done
return false
end
render :json => {
:setup_done => true,
render json: {
setup_done: true,
}
true
end

View file

@ -6,8 +6,8 @@ class LinksController < ApplicationController
# GET /api/v1/links
def index
links = Link.list(
:link_object => params[:link_object],
:link_object_value => params[:link_object_value],
link_object: params[:link_object],
link_object_value: params[:link_object_value],
)
assets = {}
@ -15,15 +15,15 @@ class LinksController < ApplicationController
links.each { |item|
link_list.push item
if item['link_object'] == 'Ticket'
ticket = Ticket.lookup( :id => item['link_object_value'] )
ticket = Ticket.lookup( id: item['link_object_value'] )
assets = ticket.assets(assets)
end
}
# return result
render :json => {
:links => link_list,
:assets => assets,
render json: {
links: link_list,
assets: assets,
}
end
@ -31,19 +31,19 @@ class LinksController < ApplicationController
def add
# lookup object id
object_id = Ticket.where( :number => params[:link_object_source_number] ).first.id
object_id = Ticket.where( number: params[:link_object_source_number] ).first.id
link = Link.add(
:link_type => params[:link_type],
:link_object_target => params[:link_object_target],
:link_object_target_value => params[:link_object_target_value],
:link_object_source => params[:link_object_source],
:link_object_source_value => object_id
link_type: params[:link_type],
link_object_target: params[:link_object_target],
link_object_target_value: params[:link_object_target_value],
link_object_source: params[:link_object_source],
link_object_source_value: object_id
)
if link
render :json => link, :status => :created
render json: link, status: :created
else
render :json => link.errors, :status => :unprocessable_entity
render json: link.errors, status: :unprocessable_entity
end
end
@ -52,9 +52,9 @@ class LinksController < ApplicationController
link = Link.remove(params)
if link
render :json => link, :status => :created
render json: link, status: :created
else
render :json => link.errors, :status => :unprocessable_entity
render json: link.errors, status: :unprocessable_entity
end
end

View file

@ -50,7 +50,7 @@ class LongPollingController < ApplicationController
# send spool:sent event to client
sleep 0.2
log 'notice', 'send spool:sent event', client_id
Sessions.send( client_id, { :event => 'spool:sent', :data => { :timestamp => Time.now.utc.to_i } } )
Sessions.send( client_id, { event: 'spool:sent', data: { timestamp: Time.now.utc.to_i } } )
end
@ -62,7 +62,7 @@ class LongPollingController < ApplicationController
user = User.find( user_id ).attributes
end
log 'notice', "send auth login (user_id #{user_id})", client_id
Sessions.create( client_id, user, { :type => 'ajax' } )
Sessions.create( client_id, user, { type: 'ajax' } )
# broadcast
elsif params['data']['action'] == 'broadcast'
@ -92,10 +92,10 @@ class LongPollingController < ApplicationController
end
if new_connection
result = { :client_id => client_id }
render :json => result
result = { client_id: client_id }
render json: result
else
render :json => {}
render json: {}
end
end
@ -105,7 +105,7 @@ class LongPollingController < ApplicationController
# check client id
client_id = client_id_verify
if !client_id
render :json => { :error => 'Invalid client_id receive!' }, :status => :unprocessable_entity
render json: { error: 'Invalid client_id receive!' }, status: :unprocessable_entity
return
end
@ -126,7 +126,7 @@ class LongPollingController < ApplicationController
queue = Sessions.queue( client_id )
if queue && queue[0]
# puts "send " + queue.inspect + client_id.to_s
render :json => queue
render json: queue
return
end
8.times {|loop|
@ -134,14 +134,14 @@ class LongPollingController < ApplicationController
}
#sleep 2
if count == 0
render :json => { :action => 'pong' }
render json: { action: 'pong' }
return
end
end
rescue Exception => e
puts e.inspect
puts e.backtrace
render :json => { :error => 'Invalid client_id in receive loop!' }, :status => :unprocessable_entity
render json: { error: 'Invalid client_id in receive loop!' }, status: :unprocessable_entity
return
end
end

View file

@ -10,7 +10,7 @@ class NetworksController < ApplicationController
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @networks }
format.json { render json: @networks }
end
end
@ -21,7 +21,7 @@ class NetworksController < ApplicationController
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @network }
format.json { render json: @network }
end
end
@ -32,7 +32,7 @@ class NetworksController < ApplicationController
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @network }
format.json { render json: @network }
end
end
@ -48,11 +48,11 @@ class NetworksController < ApplicationController
respond_to do |format|
if @network.save
format.html { redirect_to @network, :notice => 'Network was successfully created.' }
format.json { render :json => @network, :status => :created }
format.html { redirect_to @network, notice: 'Network was successfully created.' }
format.json { render json: @network, status: :created }
else
format.html { render :action => 'new' }
format.json { render :json => @network.errors, :status => :unprocessable_entity }
format.html { render action: 'new' }
format.json { render json: @network.errors, status: :unprocessable_entity }
end
end
end
@ -64,11 +64,11 @@ class NetworksController < ApplicationController
respond_to do |format|
if @network.update_attributes(params[:network])
format.html { redirect_to @network, :notice => 'Network was successfully updated.' }
format.json { render :json => @network, :status => :ok }
format.html { redirect_to @network, notice: 'Network was successfully updated.' }
format.json { render json: @network, status: :ok }
else
format.html { render :action => 'edit' }
format.json { render :json => @network.errors, :status => :unprocessable_entity }
format.html { render action: 'edit' }
format.json { render json: @network.errors, status: :unprocessable_entity }
end
end
end

View file

@ -7,8 +7,8 @@ class ObjectManagerAttributesController < ApplicationController
# GET /object_manager_attributes_list
def list
return if deny_if_not_role(Z_ROLENAME_ADMIN)
render :json => {
:objects => ObjectManager.listFrontendObjects,
render json: {
objects: ObjectManager.listFrontendObjects,
}
#model_index_render(ObjectManager::Attribute, params)
end
@ -16,7 +16,7 @@ class ObjectManagerAttributesController < ApplicationController
# GET /object_manager_attributes
def index
return if deny_if_not_role(Z_ROLENAME_ADMIN)
render :json => ObjectManager::Attribute.list_full
render json: ObjectManager::Attribute.list_full
#model_index_render(ObjectManager::Attribute, params)
end

View file

@ -48,7 +48,7 @@ curl http://localhost/api/v1/online_notifications.json -v -u #{login}:#{password
def index
if params[:full]
render :json => OnlineNotification.list_full(current_user, 50)
render json: OnlineNotification.list_full(current_user, 50)
return
end
@ -108,10 +108,10 @@ curl http://localhost/api/v1/online_notifications/mark_all_as_read -v -u #{login
notifications = OnlineNotification.list(current_user,100)
notifications.each do |notification|
if !notification['seen']
OnlineNotification.seen( :id => notification['id'] )
OnlineNotification.seen( id: notification['id'] )
end
end
render :json => {}, :status => :ok
render json: {}, status: :ok
end
end

View file

@ -52,12 +52,12 @@ curl http://localhost/api/v1/organizations.json -v -u #{login}:#{password}
organizations = []
if is_role(Z_ROLENAME_CUSTOMER) && !is_role(Z_ROLENAME_ADMIN) && !is_role(Z_ROLENAME_AGENT)
if current_user.organization_id
organizations = Organization.where( :id => current_user.organization_id )
organizations = Organization.where( id: current_user.organization_id )
end
else
organizations = Organization.all
end
render :json => organizations
render json: organizations
end
=begin
@ -82,7 +82,7 @@ curl http://localhost/api/v1/organizations/#{id}.json -v -u #{login}:#{password}
# only allow customer to fetch his own organization
if is_role(Z_ROLENAME_CUSTOMER) && !is_role(Z_ROLENAME_ADMIN) && !is_role(Z_ROLENAME_AGENT)
if !current_user.organization_id
render :json => {}
render json: {}
return
end
if params[:id].to_i != current_user.organization_id
@ -92,7 +92,7 @@ curl http://localhost/api/v1/organizations/#{id}.json -v -u #{login}:#{password}
end
if params[:full]
full = Organization.full( params[:id] )
render :json => full
render json: full
return
end
model_show_render(Organization, params)
@ -190,7 +190,7 @@ Test:
history = organization.history_get(true)
# return result
render :json => history
render json: history
end
end

View file

@ -7,8 +7,8 @@ class PackagesController < ApplicationController
def index
return if deny_if_not_role(Z_ROLENAME_ADMIN)
packages = Package.all().order('name')
render :json => {
:packages => packages
render json: {
packages: packages
}
end
@ -16,7 +16,7 @@ class PackagesController < ApplicationController
def install
return if deny_if_not_role(Z_ROLENAME_ADMIN)
Package.install( :string => params[:file_upload].read )
Package.install( string: params[:file_upload].read )
redirect_to '/#system/package'
end
@ -27,10 +27,10 @@ class PackagesController < ApplicationController
package = Package.find( params[:id] )
Package.uninstall( :name => package.name, :version => package.version )
Package.uninstall( name: package.name, version: package.version )
render :json => {
:success => true
render json: {
success: true
}
end

View file

@ -22,7 +22,7 @@ curl http://localhost/api/v1/recent_view -v -u #{login}:#{password} -H "Content-
recent_viewed = RecentView.list_full( current_user, 10 )
# return result
render :json => recent_viewed
render json: recent_viewed
end
=begin
@ -49,7 +49,7 @@ curl http://localhost/api/v1/recent_view -v -u #{login}:#{password} -H "Content-
RecentView.log( params[:object], params[:o_id], current_user )
# return result
render :json => { :message => 'ok' }
render json: { message: 'ok' }
end
end

View file

@ -21,10 +21,10 @@ curl http://localhost/api/v1/rss_fetch.json -v -u #{login}:#{password} -H "Conte
def fetch
items = Rss.fetch(params[:url], params[:limit])
if items == nil
render :json => { :message => "failed to fetch #{ params[:url] }", :status => :unprocessable_entity }
render json: { message: "failed to fetch #{ params[:url] }", status: :unprocessable_entity }
return
end
render :json => { :items => items }
render json: { items: items }
end
end

View file

@ -30,40 +30,40 @@ class SearchController < ApplicationController
else
# do query
users = User.search(
:query => query,
:limit => limit,
:current_user => current_user,
query: query,
limit: limit,
current_user: current_user,
)
user_result = []
users.each do |user|
item = {
:id => user.id,
:type => user.class.to_s
id: user.id,
type: user.class.to_s
}
result.push item
assets = user.assets(assets)
end
organizations = Organization.search(
:query => query,
:limit => limit,
:current_user => current_user,
query: query,
limit: limit,
current_user: current_user,
)
organization_result = []
organizations.each do |organization|
item = {
:id => organization.id,
:type => organization.class.to_s
id: organization.id,
type: organization.class.to_s
}
result.push item
assets = organization.assets(assets)
end
end
render :json => {
:assets => assets,
:result => result,
render json: {
assets: assets,
result: result,
}
end
@ -72,9 +72,9 @@ class SearchController < ApplicationController
# build result list
tickets = Ticket.search(
:limit => params[:limit],
:query => params[:term],
:current_user => current_user,
limit: params[:limit],
query: params[:term],
current_user: current_user,
)
assets = {}
ticket_result = []
@ -85,9 +85,9 @@ class SearchController < ApplicationController
# do query
users = User.search(
:query => params[:term],
:limit => params[:limit],
:current_user => current_user,
query: params[:term],
limit: params[:limit],
current_user: current_user,
)
user_result = []
users.each do |user|
@ -96,9 +96,9 @@ class SearchController < ApplicationController
end
organizations = Organization.search(
:query => params[:term],
:limit => params[:limit],
:current_user => current_user,
query: params[:term],
limit: params[:limit],
current_user: current_user,
)
organization_result = []
@ -110,30 +110,30 @@ class SearchController < ApplicationController
result = []
if ticket_result[0]
data = {
:name => 'Ticket',
:ids => ticket_result,
name: 'Ticket',
ids: ticket_result,
}
result.push data
end
if user_result[0]
data = {
:name => 'User',
:ids => user_result,
name: 'User',
ids: user_result,
}
result.push data
end
if organization_result[0]
data = {
:name => 'Organization',
:ids => organization_result,
name: 'Organization',
ids: organization_result,
}
result.push data
end
# return result
render :json => {
:assets => assets,
:result => result,
render json: {
assets: assets,
result: result,
}
end

View file

@ -4,9 +4,9 @@ module ExtraCollection
def session( collections, assets, user )
# all base stuff
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|
assets = item.assets(assets)
}
@ -34,7 +34,7 @@ module ExtraCollection
else
if user.organization_id
collections[ Organization.to_app_model ] = []
Organization.where( :id => user.organization_id ).each {|item|
Organization.where( id: user.organization_id ).each {|item|
assets = item.assets(assets)
}
end

View file

@ -13,7 +13,7 @@ class SessionsController < ApplicationController
# auth failed
if !user
render :json => { :error => 'login failed' }, :status => :unauthorized
render json: { error: 'login failed' }, status: :unauthorized
return
end
@ -55,14 +55,14 @@ class SessionsController < ApplicationController
end
# return new session data
render :json => {
:session => user,
:models => models,
:collections => collections,
:assets => assets,
:logon_session => logon_session_key,
render json: {
session: user,
models: models,
collections: collections,
assets: assets,
logon_session: logon_session_key,
},
:status => :created
status: :created
end
def show
@ -86,10 +86,10 @@ class SessionsController < ApplicationController
# get models
models = SessionHelper::models()
render :json => {
:error => 'no valid session',
:config => config_frontend,
:models => models,
render json: {
error: 'no valid session',
config: config_frontend,
models: models,
}
return
end
@ -108,12 +108,12 @@ class SessionsController < ApplicationController
models = SessionHelper::models(user)
# return current session
render :json => {
:session => user,
:models => models,
:collections => collections,
:assets => assets,
:config => config_frontend,
render json: {
session: user,
models: models,
collections: collections,
assets: assets,
config: config_frontend,
}
end
@ -127,7 +127,7 @@ class SessionsController < ApplicationController
request.env['rack.session.options'][:expire_after] = -1.year
request.env['rack.session.options'][:renew] = true
render :json => { }
render json: { }
end
def create_omniauth
@ -195,17 +195,17 @@ class SessionsController < ApplicationController
# check user
if !params[:id]
render(
:json => { :message => 'no user given' },
:status => :not_found
json: { message: 'no user given' },
status: :not_found
)
return false
end
user = User.lookup( :id => params[:id] )
user = User.lookup( id: params[:id] )
if !user
render(
:json => {},
:status => :not_found
json: {},
status: :not_found
)
return false
end
@ -231,11 +231,11 @@ class SessionsController < ApplicationController
return false
end
user = User.lookup( :id => session[:switched_from_user_id] )
user = User.lookup( id: session[:switched_from_user_id] )
if !user
render(
:json => {},
:status => :not_found
json: {},
status: :not_found
)
return false
end
@ -263,20 +263,20 @@ class SessionsController < ApplicationController
next if !session.data['user_id']
sessions_clean.push session
if session.data['user_id']
user = User.lookup( :id => session.data['user_id'] )
user = User.lookup( id: session.data['user_id'] )
assets = user.assets( assets )
end
}
render :json => {
:sessions => sessions_clean,
:assets => assets,
render json: {
sessions: sessions_clean,
assets: assets,
}
end
def delete
return if deny_if_not_role(Z_ROLENAME_ADMIN)
SessionHelper::destroy( params[:id] )
render :json => {}
render json: {}
end
end

View file

@ -8,49 +8,49 @@ class TagsController < ApplicationController
list = Tag.list()
# return result
render :json => {
:tags => list,
render json: {
tags: list,
}
end
# GET /api/v1/tags
def list
list = Tag.tag_list(
:object => params[:object],
:o_id => params[:o_id],
object: params[:object],
o_id: params[:o_id],
)
# return result
render :json => {
:tags => list,
render json: {
tags: list,
}
end
# POST /api/v1/tag/add
def add
success = Tag.tag_add(
:object => params[:object],
:o_id => params[:o_id],
:item => params[:item],
object: params[:object],
o_id: params[:o_id],
item: params[:item],
);
if success
render :json => success, :status => :created
render json: success, status: :created
else
render :json => success.errors, :status => :unprocessable_entity
render json: success.errors, status: :unprocessable_entity
end
end
# DELETE /api/v1/tag/remove
def remove
success = Tag.tag_remove(
:object => params[:object],
:o_id => params[:o_id],
:item => params[:item],
object: params[:object],
o_id: params[:o_id],
item: params[:item],
);
if success
render :json => success, :status => :created
render json: success, status: :created
else
render :json => success.errors, :status => :unprocessable_entity
render json: success.errors, status: :unprocessable_entity
end
end

View file

@ -5,7 +5,7 @@ class TaskbarController < ApplicationController
def index
current_user_tasks = Taskbar.where( :user_id => current_user.id )
current_user_tasks = Taskbar.where( user_id: current_user.id )
model_index_render_result(current_user_tasks)
end
@ -40,7 +40,7 @@ class TaskbarController < ApplicationController
private
def access(taskbar)
if taskbar.user_id != current_user.id
render :json => { :error => 'Not allowed to access this task.' }, :status => :unprocessable_entity
render json: { error: 'Not allowed to access this task.' }, status: :unprocessable_entity
return false
end
return true

View file

@ -5,8 +5,8 @@ class TestsController < ApplicationController
# GET /test/wait
def wait
sleep params[:sec].to_i
result = { :success => true }
render :json => result
result = { success: true }
render json: result
end
end

View file

@ -7,14 +7,14 @@ class TicketArticlesController < ApplicationController
def index
@articles = Ticket::Article.all
render :json => @articles
render json: @articles
end
# GET /articles/1
def show
@article = Ticket::Article.find( params[:id] )
render :json => @article
render json: @article
end
# POST /articles
@ -26,8 +26,8 @@ class TicketArticlesController < ApplicationController
# find attachments in upload cache
if form_id
@article.attachments = Store.list(
:object => 'UploadCache',
:o_id => form_id,
object: 'UploadCache',
o_id: form_id,
)
end
@ -35,13 +35,13 @@ class TicketArticlesController < ApplicationController
# remove attachments from upload cache
Store.remove(
:object => 'UploadCache',
:o_id => form_id,
object: 'UploadCache',
o_id: form_id,
)
render :json => @article, :status => :created
render json: @article, status: :created
else
render :json => @article.errors, :status => :unprocessable_entity
render json: @article.errors, status: :unprocessable_entity
end
end
@ -50,9 +50,9 @@ class TicketArticlesController < ApplicationController
@article = Ticket::Article.find( params[:id] )
if @article.update_attributes( Ticket::Article.param_validation( params[:ticket_article] ) )
render :json => @article, :status => :ok
render json: @article, status: :ok
else
render :json => @article.errors, :status => :unprocessable_entity
render json: @article.errors, status: :unprocessable_entity
end
end
@ -69,8 +69,8 @@ class TicketArticlesController < ApplicationController
Store.remove_item( params[:store_id] )
# return result
render :json => {
:success => true,
render json: {
success: true,
}
end
@ -91,20 +91,20 @@ class TicketArticlesController < ApplicationController
'Content-Type' => content_type
}
store = Store.add(
:object => 'UploadCache',
:o_id => params[:form_id],
:data => file.read,
:filename => file.original_filename,
:preferences => headers_store
object: 'UploadCache',
o_id: params[:form_id],
data: file.read,
filename: file.original_filename,
preferences: headers_store
)
# return result
render :json => {
:success => true,
:data => {
:store_id => store.id,
:filename => file.original_filename,
:size => store.size,
render json: {
success: true,
data: {
store_id: store.id,
filename: file.original_filename,
size: store.size,
}
}
end
@ -115,12 +115,12 @@ class TicketArticlesController < ApplicationController
# permissin check
ticket = Ticket.find( params[:ticket_id] )
if !ticket_permission(ticket)
render( :json => 'No such ticket.', :status => :unauthorized )
render( json: 'No such ticket.', status: :unauthorized )
return
end
article = Ticket::Article.find( params[:article_id] )
if ticket.id != article.ticket_id
render( :json => 'No access, article_id/ticket_id is not matching.', :status => :unauthorized )
render( json: 'No access, article_id/ticket_id is not matching.', status: :unauthorized )
return
end
@ -132,7 +132,7 @@ class TicketArticlesController < ApplicationController
end
}
if !access
render( :json => 'Requested file id is not linked with article_id.', :status => :unauthorized )
render( json: 'Requested file id is not linked with article_id.', status: :unauthorized )
return
end
@ -140,9 +140,9 @@ class TicketArticlesController < ApplicationController
file = Store.find(params[:id])
send_data(
file.content,
:filename => file.filename,
:type => file.preferences['Content-Type'] || file.preferences['Mime-Type'],
:disposition => 'inline'
filename: file.filename,
type: file.preferences['Content-Type'] || file.preferences['Mime-Type'],
disposition: 'inline'
)
end
@ -154,8 +154,8 @@ class TicketArticlesController < ApplicationController
return if !ticket_permission( article.ticket )
list = Store.list(
:object => 'Ticket::Article::Mail',
:o_id => params[:id],
object: 'Ticket::Article::Mail',
o_id: params[:id],
)
# find file
@ -163,9 +163,9 @@ class TicketArticlesController < ApplicationController
file = Store.find(list.first)
send_data(
file.content,
:filename => file.filename,
:type => 'message/rfc822',
:disposition => 'inline'
filename: file.filename,
type: 'message/rfc822',
disposition: 'inline'
)
end
end

View file

@ -11,53 +11,53 @@ class TicketOverviewsController < ApplicationController
# get navbar overview data
if !params[:view]
result = Ticket::Overviews.list(
:current_user => current_user,
current_user: current_user,
)
render :json => result
render json: result
return
end
# get real overview data
if params[:array]
overview = Ticket::Overviews.list(
:view => params[:view],
:current_user => current_user,
:array => true,
view: params[:view],
current_user: current_user,
array: true,
)
tickets = []
overview[:tickets].each {|ticket_id|
data = { :id => ticket_id }
data = { id: ticket_id }
tickets.push data
}
# return result
render :json => {
:overview => overview[:overview],
:tickets => tickets,
:tickets_count => overview[:tickets_count],
render json: {
overview: overview[:overview],
tickets: tickets,
tickets_count: overview[:tickets_count],
}
return
end
overview = Ticket::Overviews.list(
:view => params[:view],
:current_user => current_user,
:array => true,
view: params[:view],
current_user: current_user,
array: true,
)
if !overview
render :json => { :error => "No such view #{ params[:view] }!" }, :status => :unprocessable_entity
render json: { error: "No such view #{ params[:view] }!" }, status: :unprocessable_entity
return
end
# get related users
assets = {}
overview[:ticket_ids].each {|ticket_id|
ticket = Ticket.lookup( :id => ticket_id )
ticket = Ticket.lookup( id: ticket_id )
assets = ticket.assets(assets)
}
# get groups
group_ids = []
Group.where( :active => true ).each { |group|
Group.where( active: true ).each { |group|
group_ids.push group.id
}
agents = {}
@ -75,15 +75,15 @@ class TicketOverviewsController < ApplicationController
}
# return result
render :json => {
:view => params[:view],
:overview => overview[:overview],
:ticket_ids => overview[:ticket_ids],
:tickets_count => overview[:tickets_count],
:bulk => {
:group_id__owner_id => groups_users,
render json: {
view: params[:view],
overview: overview[:overview],
ticket_ids: overview[:ticket_ids],
tickets_count: overview[:tickets_count],
bulk: {
group_id__owner_id: groups_users,
},
:assets => assets,
assets: assets,
}
end

View file

@ -7,7 +7,7 @@ class TicketsController < ApplicationController
def index
@tickets = Ticket.all
render :json => @tickets
render json: @tickets
end
# GET /api/v1/tickets/1
@ -17,7 +17,7 @@ class TicketsController < ApplicationController
# permissin check
return if !ticket_permission(@ticket)
render :json => @ticket
render json: @ticket
end
# POST /api/v1/tickets
@ -26,13 +26,13 @@ class TicketsController < ApplicationController
# check if article is given
if !params[:article]
render :json => 'article hash is missing', :status => :unprocessable_entity
render json: 'article hash is missing', status: :unprocessable_entity
return
end
# create ticket
if !ticket.save
render :json => ticket.errors, :status => :unprocessable_entity
render json: ticket.errors, status: :unprocessable_entity
return
end
@ -41,10 +41,10 @@ class TicketsController < ApplicationController
tags = params[:tags].split /,/
tags.each {|tag|
Tag.tag_add(
:object => 'Ticket',
:o_id => ticket.id,
:item => tag,
:created_by_id => current_user.id,
object: 'Ticket',
o_id: ticket.id,
item: tag,
created_by_id: current_user.id,
)
}
end
@ -54,7 +54,7 @@ class TicketsController < ApplicationController
article_create( ticket, params[:article] )
end
render :json => ticket, :status => :created
render json: ticket, status: :created
end
# PUT /api/v1/tickets/1
@ -70,9 +70,9 @@ class TicketsController < ApplicationController
article_create( ticket, params[:article] )
end
render :json => ticket, :status => :ok
render json: ticket, status: :ok
else
render :json => ticket.errors, :status => :unprocessable_entity
render json: ticket.errors, status: :unprocessable_entity
end
end
@ -94,10 +94,10 @@ class TicketsController < ApplicationController
# return result
result = Ticket::ScreenOptions.list_by_customer(
:customer_id => params[:customer_id],
:limit => 15,
customer_id: params[:customer_id],
limit: 15,
)
render :json => result
render json: result
end
# GET /api/v1/ticket_history/1
@ -114,7 +114,7 @@ class TicketsController < ApplicationController
# return result
render :json => history
render json: history
end
# GET /api/v1/ticket_related/1
@ -130,8 +130,8 @@ class TicketsController < ApplicationController
map( &:id )
access_condition = [ 'group_id IN (?)', group_ids ]
ticket_list = Ticket.where(
:customer_id => ticket.customer_id,
:state_id => Ticket::State.by_category( 'open' )
customer_id: ticket.customer_id,
state_id: Ticket::State.by_category( 'open' )
)
.where(access_condition)
@ -158,10 +158,10 @@ class TicketsController < ApplicationController
}
# return result
render :json => {
:assets => assets,
:ticket_ids_by_customer => ticket_ids_by_customer,
:ticket_ids_recent_viewed => ticket_ids_recent_viewed,
render json: {
assets: assets,
ticket_ids_by_customer: ticket_ids_by_customer,
ticket_ids_recent_viewed: ticket_ids_recent_viewed,
}
end
@ -169,11 +169,11 @@ class TicketsController < ApplicationController
def ticket_merge
# check master ticket
ticket_master = Ticket.where( :number => params[:master_ticket_number] ).first
ticket_master = Ticket.where( number: params[:master_ticket_number] ).first
if !ticket_master
render :json => {
:result => 'faild',
:message => 'No such master ticket number!',
render json: {
result: 'faild',
message: 'No such master ticket number!',
}
return
end
@ -182,11 +182,11 @@ class TicketsController < ApplicationController
return if !ticket_permission(ticket_master)
# check slave ticket
ticket_slave = Ticket.where( :id => params[:slave_ticket_id] ).first
ticket_slave = Ticket.where( id: params[:slave_ticket_id] ).first
if !ticket_slave
render :json => {
:result => 'faild',
:message => 'No such slave ticket!',
render json: {
result: 'faild',
message: 'No such slave ticket!',
}
return
end
@ -196,9 +196,9 @@ class TicketsController < ApplicationController
# check diffetent ticket ids
if ticket_slave.id == ticket_master.id
render :json => {
:result => 'faild',
:message => 'Can\'t merge ticket with it self!',
render json: {
result: 'faild',
message: 'Can\'t merge ticket with it self!',
}
return
end
@ -206,16 +206,16 @@ class TicketsController < ApplicationController
# merge ticket
success = ticket_slave.merge_to(
{
:ticket_id => ticket_master.id,
:created_by_id => current_user.id,
ticket_id: ticket_master.id,
created_by_id: current_user.id,
}
)
# return result
render :json => {
:result => 'success',
:master_ticket => ticket_master.attributes,
:slave_ticket => ticket_slave.attributes,
render json: {
result: 'success',
master_ticket: ticket_master.attributes,
slave_ticket: ticket_slave.attributes,
}
end
@ -227,14 +227,14 @@ class TicketsController < ApplicationController
return if !ticket_permission( ticket )
# get attributes to update
attributes_to_change = Ticket::ScreenOptions.attributes_to_change( :user => current_user, :ticket => ticket )
attributes_to_change = Ticket::ScreenOptions.attributes_to_change( user: current_user, ticket: ticket )
# get related users
assets = attributes_to_change[:assets]
assets = ticket.assets(assets)
# get related articles
articles = Ticket::Article.where( :ticket_id => params[:id] )
articles = Ticket::Article.where( ticket_id: params[:id] )
# get related users
article_ids = []
@ -252,34 +252,34 @@ class TicketsController < ApplicationController
# get links
links = Link.list(
:link_object => 'Ticket',
:link_object_value => ticket.id,
link_object: 'Ticket',
link_object_value: ticket.id,
)
link_list = []
links.each { |item|
link_list.push item
if item['link_object'] == 'Ticket'
linked_ticket = Ticket.lookup( :id => item['link_object_value'] )
linked_ticket = Ticket.lookup( id: item['link_object_value'] )
assets = linked_ticket.assets(assets)
end
}
# get tags
tags = Tag.tag_list(
:object => 'Ticket',
:o_id => ticket.id,
object: 'Ticket',
o_id: ticket.id,
)
# return result
render :json => {
:ticket_id => ticket.id,
:ticket_article_ids => article_ids,
:assets => assets,
:links => link_list,
:tags => tags,
:form_meta => {
:filter => attributes_to_change[:filter],
:dependencies => attributes_to_change[:dependencies],
render json: {
ticket_id: ticket.id,
ticket_article_ids: article_ids,
assets: assets,
links: link_list,
tags: tags,
form_meta: {
filter: attributes_to_change[:filter],
dependencies: attributes_to_change[:dependencies],
}
}
end
@ -289,9 +289,9 @@ class TicketsController < ApplicationController
# get attributes to update
attributes_to_change = Ticket::ScreenOptions.attributes_to_change(
:user => current_user,
:ticket_id => params[:ticket_id],
:article_id => params[:article_id]
user: current_user,
ticket_id: params[:ticket_id],
article_id: params[:article_id]
)
assets = attributes_to_change[:assets]
@ -309,12 +309,12 @@ class TicketsController < ApplicationController
end
# return result
render :json => {
:split => split,
:assets => assets,
:form_meta => {
:filter => attributes_to_change[:filter],
:dependencies => attributes_to_change[:dependencies],
render json: {
split: split,
assets: assets,
form_meta: {
filter: attributes_to_change[:filter],
dependencies: attributes_to_change[:dependencies],
}
}
end
@ -327,11 +327,11 @@ class TicketsController < ApplicationController
# build result list
tickets = Ticket.search(
:limit => params[:limit],
:query => params[:term],
:condition => params[:condition],
:current_user => current_user,
:detail => params[:detail]
limit: params[:limit],
query: params[:term],
condition: params[:condition],
current_user: current_user,
detail: params[:detail]
)
assets = {}
ticket_result = []
@ -341,10 +341,10 @@ class TicketsController < ApplicationController
end
# return result
render :json => {
:tickets => ticket_result,
:tickets_count => tickets.count,
:assets => assets,
render json: {
tickets: ticket_result,
tickets_count: tickets.count,
assets: assets,
}
end
@ -373,11 +373,11 @@ class TicketsController < ApplicationController
'tickets.customer_id' => user.id,
}
user_tickets_open = Ticket.search(
:limit => limit,
limit: limit,
#:query => params[:term],
:condition => condition,
:current_user => current_user,
:detail => true,
condition: condition,
current_user: current_user,
detail: true,
)
user_tickets_open_ids = assets_of_tickets(user_tickets_open, assets)
@ -387,11 +387,11 @@ class TicketsController < ApplicationController
'tickets.customer_id' => user.id,
}
user_tickets_closed = Ticket.search(
:limit => limit,
limit: limit,
#:query => params[:term],
:condition => condition,
:current_user => current_user,
:detail => true,
condition: condition,
current_user: current_user,
detail: true,
)
user_tickets_closed_ids = assets_of_tickets(user_tickets_closed, assets)
@ -418,11 +418,11 @@ class TicketsController < ApplicationController
count
data = {
:month => date_to_check.month,
:year => date_to_check.year,
:text => Date::MONTHNAMES[date_to_check.month],
:created => created,
:closed => closed,
month: date_to_check.month,
year: date_to_check.year,
text: Date::MONTHNAMES[date_to_check.month],
created: created,
closed: closed,
}
user_ticket_volume_by_year.push data
}
@ -440,11 +440,11 @@ class TicketsController < ApplicationController
'tickets.organization_id' => params[:organization_id],
}
org_tickets_open = Ticket.search(
:limit => limit,
limit: limit,
#:query => params[:term],
:condition => condition,
:current_user => current_user,
:detail => true,
condition: condition,
current_user: current_user,
detail: true,
)
org_tickets_open_ids = assets_of_tickets(org_tickets_open, assets)
@ -454,11 +454,11 @@ class TicketsController < ApplicationController
'tickets.organization_id' => params[:organization_id],
}
org_tickets_closed = Ticket.search(
:limit => limit,
limit: limit,
#:query => params[:term],
:condition => condition,
:current_user => current_user,
:detail => true,
condition: condition,
current_user: current_user,
detail: true,
)
org_tickets_closed_ids = assets_of_tickets(org_tickets_closed, assets)
@ -479,25 +479,25 @@ class TicketsController < ApplicationController
closed = Ticket.where('close_time > ? AND close_time < ?', date_start, date_end ).where(condition).count
data = {
:month => date_to_check.month,
:year => date_to_check.year,
:text => Date::MONTHNAMES[date_to_check.month],
:created => created,
:closed => closed,
month: date_to_check.month,
year: date_to_check.year,
text: Date::MONTHNAMES[date_to_check.month],
created: created,
closed: closed,
}
org_ticket_volume_by_year.push data
}
end
# return result
render :json => {
:user_tickets_open_ids => user_tickets_open_ids,
:user_tickets_closed_ids => user_tickets_closed_ids,
:org_tickets_open_ids => org_tickets_open_ids,
:org_tickets_closed_ids => org_tickets_closed_ids,
:user_ticket_volume_by_year => user_ticket_volume_by_year,
:org_ticket_volume_by_year => org_ticket_volume_by_year,
:assets => assets,
render json: {
user_tickets_open_ids: user_tickets_open_ids,
user_tickets_closed_ids: user_tickets_closed_ids,
org_tickets_open_ids: org_tickets_open_ids,
org_tickets_closed_ids: org_tickets_closed_ids,
user_ticket_volume_by_year: user_ticket_volume_by_year,
org_ticket_volume_by_year: org_ticket_volume_by_year,
assets: assets,
}
end
@ -523,20 +523,20 @@ class TicketsController < ApplicationController
# find attachments in upload cache
if form_id
article.attachments = Store.list(
:object => 'UploadCache',
:o_id => form_id,
object: 'UploadCache',
o_id: form_id,
)
end
if !article.save
render :json => article.errors, :status => :unprocessable_entity
render json: article.errors, status: :unprocessable_entity
return
end
# remove attachments from upload cache
if form_id
Store.remove(
:object => 'UploadCache',
:o_id => form_id,
object: 'UploadCache',
o_id: form_id,
)
end
end

View file

@ -1,17 +1,17 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class TranslationsController < ApplicationController
before_filter :authentication_check, :except => [:load]
before_filter :authentication_check, except: [:load]
# GET /translations/lang/:locale
def load
render :json => Translation.list( params[:locale] )
render json: Translation.list( params[:locale] )
end
# GET /translations/admin/lang/:locale
def admin
return if deny_if_not_role(Z_ROLENAME_ADMIN)
render :json => Translation.list( params[:locale], true )
render json: Translation.list( params[:locale], true )
end
# GET /translations

View file

@ -1,7 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class UsersController < ApplicationController
before_filter :authentication_check, :except => [:create, :password_reset_send, :password_reset_verify]
before_filter :authentication_check, except: [:create, :password_reset_send, :password_reset_verify]
# @path [GET] /users
#
@ -16,15 +16,15 @@ class UsersController < ApplicationController
# only allow customer to fetch him self
if is_role(Z_ROLENAME_CUSTOMER) && !is_role(Z_ROLENAME_ADMIN) && !is_role('Agent')
users = User.where( :id => current_user.id )
users = User.where( id: current_user.id )
else
users = User.all
end
users_all = []
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
end
# @path [GET] /users/{id}
@ -46,12 +46,12 @@ class UsersController < ApplicationController
if params[:full]
full = User.full( params[:id] )
render :json => full
render json: full
return
end
user = User.find( params[:id] )
render :json => user
render json: user
end
# @path [POST] /users
@ -77,7 +77,7 @@ class UsersController < ApplicationController
# check if feature is enabled
if !Setting.get('user_create_account')
render :json => { :error => 'Feature not enabled!' }, :status => :unprocessable_entity
render json: { error: 'Feature not enabled!' }, status: :unprocessable_entity
return
end
@ -85,7 +85,7 @@ class UsersController < ApplicationController
group_ids = []
role_ids = []
if count <= 2
Role.where( :name => [ Z_ROLENAME_ADMIN, 'Agent'] ).each { |role|
Role.where( name: [ Z_ROLENAME_ADMIN, 'Agent'] ).each { |role|
role_ids.push role.id
}
Group.all().each { |group|
@ -94,7 +94,7 @@ class UsersController < ApplicationController
# everybody else will go as customer per default
else
role_ids.push Role.where( :name => Z_ROLENAME_CUSTOMER ).first.id
role_ids.push Role.where( name: Z_ROLENAME_CUSTOMER ).first.id
end
user.role_ids = role_ids
user.group_ids = group_ids
@ -115,9 +115,9 @@ class UsersController < ApplicationController
# check if user already exists
if user.email
exists = User.where( :email => user.email ).first
exists = User.where( email: user.email ).first
if exists
render :json => { :error => 'User already exists!' }, :status => :unprocessable_entity
render json: { error: 'User already exists!' }, status: :unprocessable_entity
return
end
end
@ -133,7 +133,7 @@ class UsersController < ApplicationController
if params[:invite] && current_user
# generate token
token = Token.create( :action => 'PasswordReset', :user_id => user.id )
token = Token.create( action: 'PasswordReset', user_id: user.id )
# send mail
data = {}
@ -156,28 +156,28 @@ class UsersController < ApplicationController
# prepare subject & body
[:subject, :body].each { |key|
data[key.to_sym] = NotificationFactory.build(
:locale => user.preferences[:locale],
:string => data[key.to_sym],
:objects => {
:token => token,
:user => user,
:current_user => current_user,
locale: user.preferences[:locale],
string: data[key.to_sym],
objects: {
token: token,
user: user,
current_user: current_user,
}
)
}
# send notification
NotificationFactory.send(
:recipient => user,
:subject => data[:subject],
:body => data[:body]
recipient: user,
subject: data[:subject],
body: data[:body]
)
end
user_new = User.find( user.id )
render :json => user_new, :status => :created
render json: user_new, status: :created
rescue Exception => e
render :json => { :error => e.message }, :status => :unprocessable_entity
render json: { error: e.message }, status: :unprocessable_entity
end
end
@ -219,9 +219,9 @@ class UsersController < ApplicationController
# get new data
user_new = User.find( params[:id] )
render :json => user_new, :status => :ok
render json: user_new, status: :ok
rescue Exception => e
render :json => { :error => e.message }, :status => :unprocessable_entity
render json: { error: e.message }, status: :unprocessable_entity
end
end
@ -266,9 +266,9 @@ class UsersController < ApplicationController
end
query_params = {
:query => params[:term],
:limit => params[:limit],
:current_user => current_user,
query: params[:term],
limit: params[:limit],
current_user: current_user,
}
if params[:role_ids] && !params[:role_ids].empty?
query_params[:role_ids] = params[:role_ids]
@ -285,12 +285,12 @@ class UsersController < ApplicationController
if user.email && user.email.to_s != ''
realname = realname + ' <' + user.email.to_s + '>'
end
a = { :id => user.id, :label => realname, :value => realname }
a = { id: user.id, label: realname, value: realname }
users.push a
}
# return result
render :json => users
render json: users
return
end
@ -302,9 +302,9 @@ class UsersController < ApplicationController
}
# return result
render :json => {
:assets => assets,
:user_ids => user_ids.uniq,
render json: {
assets: assets,
user_ids: user_ids.uniq,
}
end
@ -336,7 +336,7 @@ class UsersController < ApplicationController
history = user.history_get(true)
# return result
render :json => history
render json: history
end
=begin
@ -363,7 +363,7 @@ curl http://localhost/api/v1/users/password_reset.json -v -u #{login}:#{password
# check if feature is enabled
if !Setting.get('user_lost_password')
render :json => { :error => 'Feature not enabled!' }, :status => :unprocessable_entity
render json: { error: 'Feature not enabled!' }, status: :unprocessable_entity
return
end
@ -372,17 +372,17 @@ curl http://localhost/api/v1/users/password_reset.json -v -u #{login}:#{password
# only if system is in develop mode, send token back to browser for browser tests
if Setting.get('developer_mode') == true
render :json => { :message => 'ok', :token => token.name }, :status => :ok
render json: { message: 'ok', token: token.name }, status: :ok
return
end
# token sent to user, send ok to browser
render :json => { :message => 'ok' }, :status => :ok
render json: { message: 'ok' }, status: :ok
return
end
# unable to generate token
render :json => { :message => 'failed' }, :status => :ok
render json: { message: 'failed' }, status: :ok
end
=begin
@ -412,7 +412,7 @@ curl http://localhost/api/v1/users/password_reset_verify.json -v -u #{login}:#{p
# check password policy
result = password_policy(params[:password])
if result != true
render :json => { :message => 'failed', :notice => result }, :status => :ok
render json: { message: 'failed', notice: result }, status: :ok
return
end
@ -422,9 +422,9 @@ curl http://localhost/api/v1/users/password_reset_verify.json -v -u #{login}:#{p
user = User.password_reset_check( params[:token] )
end
if user
render :json => { :message => 'ok', :user_login => user.login }, :status => :ok
render json: { message: 'ok', user_login: user.login }, status: :ok
else
render :json => { :message => 'failed' }, :status => :ok
render json: { message: 'failed' }, status: :ok
end
end
@ -453,30 +453,30 @@ curl http://localhost/api/v1/users/password_change.json -v -u #{login}:#{passwor
# check old password
if !params[:password_old]
render :json => { :message => 'failed', :notice => ['Current password needed!'] }, :status => :ok
render json: { message: 'failed', notice: ['Current password needed!'] }, status: :ok
return
end
user = User.authenticate( current_user.login, params[:password_old] )
if !user
render :json => { :message => 'failed', :notice => ['Current password is wrong!'] }, :status => :ok
render json: { message: 'failed', notice: ['Current password is wrong!'] }, status: :ok
return
end
# set new password
if !params[:password_new]
render :json => { :message => 'failed', :notice => ['Please supply your new password!'] }, :status => :ok
render json: { message: 'failed', notice: ['Please supply your new password!'] }, status: :ok
return
end
# check password policy
result = password_policy(params[:password_new])
if result != true
render :json => { :message => 'failed', :notice => result }, :status => :ok
render json: { message: 'failed', notice: result }, status: :ok
return
end
user.update_attributes( :password => params[:password_new] )
render :json => { :message => 'ok', :user_login => user.login }, :status => :ok
user.update_attributes( password: params[:password_new] )
render json: { message: 'ok', user_login: user.login }, status: :ok
end
=begin
@ -502,7 +502,7 @@ curl http://localhost/api/v1/users/preferences.json -v -u #{login}:#{password} -
def preferences
if !current_user
render :json => { :message => 'No current user!' }, :status => :unprocessable_entity
render json: { message: 'No current user!' }, status: :unprocessable_entity
return
end
if params[:user]
@ -511,7 +511,7 @@ curl http://localhost/api/v1/users/preferences.json -v -u #{login}:#{password} -
}
current_user.save
end
render :json => { :message => 'ok' }, :status => :ok
render json: { message: 'ok' }, status: :ok
end
=begin
@ -537,32 +537,32 @@ curl http://localhost/api/v1/users/account.json -v -u #{login}:#{password} -H "C
def account_remove
if !current_user
render :json => { :message => 'No current user!' }, :status => :unprocessable_entity
render json: { message: 'No current user!' }, status: :unprocessable_entity
return
end
# provider + uid to remove
if !params[:provider]
render :json => { :message => 'provider needed!' }, :status => :unprocessable_entity
render json: { message: 'provider needed!' }, status: :unprocessable_entity
return
end
if !params[:uid]
render :json => { :message => 'uid needed!' }, :status => :unprocessable_entity
render json: { message: 'uid needed!' }, status: :unprocessable_entity
return
end
# remove from database
record = Authorization.where(
:user_id => current_user.id,
:provider => params[:provider],
:uid => params[:uid],
user_id: current_user.id,
provider: params[:provider],
uid: params[:uid],
)
if !record.first
render :json => { :message => 'No record found!' }, :status => :unprocessable_entity
render json: { message: 'No record found!' }, status: :unprocessable_entity
return
end
record.destroy_all
render :json => { :message => 'ok' }, :status => :ok
render json: { message: 'ok' }, status: :ok
end
=begin
@ -589,9 +589,9 @@ curl http://localhost/api/v1/users/image/8d6cca1c6bdc226cf2ba131e264ca2c7 -v -u
if file
send_data(
file.content,
:filename => file.filename,
:type => file.preferences['Content-Type'] || file.preferences['Mime-Type'],
:disposition => 'inline'
filename: file.filename,
type: file.preferences['Content-Type'] || file.preferences['Mime-Type'],
disposition: 'inline'
)
return
end
@ -600,9 +600,9 @@ curl http://localhost/api/v1/users/image/8d6cca1c6bdc226cf2ba131e264ca2c7 -v -u
image = 'R0lGODdhMAAwAOMAAMzMzJaWlr6+vqqqqqOjo8XFxbe3t7GxsZycnAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAMAAwAAAEcxDISau9OOvNu/9gKI5kaZ5oqq5s675wLM90bd94ru98TwuAA+KQAQqJK8EAgBAgMEqmkzUgBIeSwWGZtR5XhSqAULACCoGCJGwlm1MGQrq9RqgB8fm4ZTUgDBIEcRR9fz6HiImKi4yNjo+QkZKTlJWWkBEAOw=='
send_data(
Base64.decode64(image),
:filename => 'image.gif',
:type => 'image/gif',
:disposition => 'inline'
filename: 'image.gif',
type: 'image/gif',
disposition: 'inline'
)
end
@ -634,24 +634,24 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
file_resize = StaticAssets.data_url_attributes( params[:avatar_resize] )
avatar = Avatar.add(
:object => 'User',
:o_id => current_user.id,
:full => {
:content => file_full[:content],
:mime_type => file_full[:mime_type],
object: 'User',
o_id: current_user.id,
full: {
content: file_full[:content],
mime_type: file_full[:mime_type],
},
:resize => {
:content => file_resize[:content],
:mime_type => file_resize[:mime_type],
resize: {
content: file_resize[:content],
mime_type: file_resize[:mime_type],
},
:source => 'upload ' + Time.now.to_s,
:deletable => true,
source: 'upload ' + Time.now.to_s,
deletable: true,
)
# update user link
current_user.update_attributes( :image => avatar.store_hash )
current_user.update_attributes( image: avatar.store_hash )
render :json => { :avatar => avatar }, :status => :ok
render json: { avatar: avatar }, status: :ok
end
def avatar_set_default
@ -659,7 +659,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
# get & validate image
if !params[:id]
render :json => { :message => 'No id of avatar!' }, :status => :unprocessable_entity
render json: { message: 'No id of avatar!' }, status: :unprocessable_entity
return
end
@ -667,9 +667,9 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
avatar = Avatar.set_default( 'User', current_user.id, params[:id] )
# update user link
current_user.update_attributes( :image => avatar.store_hash )
current_user.update_attributes( image: avatar.store_hash )
render :json => {}, :status => :ok
render json: {}, status: :ok
end
def avatar_destroy
@ -677,7 +677,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
# get & validate image
if !params[:id]
render :json => { :message => 'No id of avatar!' }, :status => :unprocessable_entity
render json: { message: 'No id of avatar!' }, status: :unprocessable_entity
return
end
@ -686,9 +686,9 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
# update user link
avatar = Avatar.get_default( 'User', current_user.id )
current_user.update_attributes( :image => avatar.store_hash )
current_user.update_attributes( image: avatar.store_hash )
render :json => {}, :status => :ok
render json: {}, status: :ok
end
def avatar_list
@ -696,7 +696,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
# list of avatars
result = Avatar.list( 'User', current_user.id )
render :json => { :avatars => result }, :status => :ok
render json: { avatars: result }, status: :ok
end
private

View file

@ -2,8 +2,8 @@
class ActivityStream < ApplicationModel
self.table_name = 'activity_streams'
belongs_to :activity_stream_type, :class_name => 'TypeLookup'
belongs_to :activity_stream_object, :class_name => 'ObjectLookup'
belongs_to :activity_stream_type, class_name: 'TypeLookup'
belongs_to :activity_stream_object, class_name: 'ObjectLookup'
=begin
@ -32,7 +32,7 @@ add a new activity entry for an object
role_id = nil
if data[:role]
role = Role.lookup( :name => data[:role] )
role = Role.lookup( name: data[:role] )
if !role
raise "No such Role #{data[:role]}"
end
@ -41,11 +41,11 @@ add a new activity entry for an object
# check newest entry - is needed
result = ActivityStream.where(
:o_id => data[:o_id],
o_id: data[:o_id],
#:activity_stream_type_id => type_id,
:role_id => role_id,
:activity_stream_object_id => object_id,
:created_by_id => data[:created_by_id]
role_id: role_id,
activity_stream_object_id: object_id,
created_by_id: data[:created_by_id]
).order('created_at DESC, id DESC').first
# resturn if old entry is really fresh
@ -53,13 +53,13 @@ add a new activity entry for an object
# create history
record = {
:o_id => data[:o_id],
:activity_stream_type_id => type_id,
:activity_stream_object_id => object_id,
:role_id => role_id,
:group_id => data[:group_id],
:created_at => data[:created_at],
:created_by_id => data[:created_by_id]
o_id: data[:o_id],
activity_stream_type_id: type_id,
activity_stream_object_id: object_id,
role_id: role_id,
group_id: data[:group_id],
created_at: data[:created_at],
created_by_id: data[:created_by_id]
}
ActivityStream.create(record)
@ -76,8 +76,8 @@ remove whole activity entries of an object
def self.remove( object_name, o_id )
object_id = ObjectLookup.by_name( object_name )
ActivityStream.where(
:activity_stream_object_id => object_id,
:o_id => o_id,
activity_stream_object_id: object_id,
o_id: o_id,
).destroy_all
end
@ -94,7 +94,7 @@ return all activity entries of an user
group_ids = user.group_ids
# do not return an activity stream for custoers
customer_role = Role.lookup( :name => 'Customer' )
customer_role = Role.lookup( name: 'Customer' )
return [] if role_ids.include?(customer_role.id)
if group_ids.empty?

View file

@ -316,14 +316,14 @@ returns
return cache if cache
# puts "Fillup- + #{self.to_s}.#{data[:id].to_s}"
record = self.where( :id => data[:id] ).first
record = self.where( id: data[:id] ).first
self.cache_set( data[:id], record )
return record
elsif data[:name]
cache = self.cache_get( data[:name] )
return cache if cache
records = self.where( :name => data[:name] )
records = self.where( name: data[:name] )
records.each {|record|
if record.name == data[:name]
self.cache_set( data[:name], record )
@ -335,7 +335,7 @@ returns
cache = self.cache_get( data[:login] )
return cache if cache
records = self.where( :login => data[:login] )
records = self.where( login: data[:login] )
records.each {|record|
if record.login == data[:login]
self.cache_set( data[:login], record )
@ -362,20 +362,20 @@ returns
def self.create_if_not_exists(data)
if data[:id]
record = self.where( :id => data[:id] ).first
record = self.where( id: data[:id] ).first
return record if record
elsif data[:name]
records = self.where( :name => data[:name] )
records = self.where( name: data[:name] )
records.each {|record|
return record if record.name == data[:name]
}
elsif data[:login]
records = self.where( :login => data[:login] )
records = self.where( login: data[:login] )
records.each {|record|
return record if record.login == data[:login]
}
elsif data[:locale] && data[:source]
records = self.where( :locale => data[:locale], :source => data[:source] )
records = self.where( locale: data[:locale], source: data[:source] )
records.each {|record|
return record if record.source == data[:source]
}
@ -397,7 +397,7 @@ returns
def self.create_or_update(data)
if data[:id]
records = self.where( :id => data[:id] )
records = self.where( id: data[:id] )
records.each {|record|
record.update_attributes( data )
return record
@ -406,7 +406,7 @@ returns
record.save
return record
elsif data[:name]
records = self.where( :name => data[:name] )
records = self.where( name: data[:name] )
records.each {|record|
if record.name == data[:name]
record.update_attributes( data )
@ -417,7 +417,7 @@ returns
record.save
return record
elsif data[:login]
records = self.where( :login => data[:login] )
records = self.where( login: data[:login] )
records.each {|record|
if record.login.downcase == data[:login].downcase
record.update_attributes( data )
@ -428,7 +428,7 @@ returns
record.save
return record
elsif data[:locale]
records = self.where( :locale => data[:locale] )
records = self.where( locale: data[:locale] )
records.each {|record|
if record.locale.downcase == data[:locale].downcase
record.update_attributes( data )
@ -474,7 +474,7 @@ end
if updated_at == nil
Cache.delete( key )
else
Cache.write( key, updated_at, { :expires_in => expires_in } )
Cache.write( key, updated_at, { expires_in: expires_in } )
end
end
@ -545,8 +545,8 @@ class OwnModel < ApplicationModel
class_name = self.class.name
class_name.gsub!(/::/, '')
Sessions.broadcast(
:event => class_name + ':create',
:data => { :id => self.id, :updated_at => self.updated_at }
event: class_name + ':create',
data: { id: self.id, updated_at: self.updated_at }
)
end
@ -573,8 +573,8 @@ class OwnModel < ApplicationModel
class_name = self.class.name
class_name.gsub!(/::/, '')
Sessions.broadcast(
:event => class_name + ':update',
:data => { :id => self.id, :updated_at => self.updated_at }
event: class_name + ':update',
data: { id: self.id, updated_at: self.updated_at }
)
end
@ -600,8 +600,8 @@ class OwnModel < ApplicationModel
class_name = self.class.name
class_name.gsub!(/::/, '')
Sessions.broadcast(
:event => class_name + ':destroy',
:data => { :id => self.id, :updated_at => self.updated_at }
event: class_name + ':destroy',
data: { id: self.id, updated_at: self.updated_at }
)
end
@ -716,10 +716,10 @@ log object update activity stream, if configured - will be executed automaticall
# default ignored attributes
ignore_attributes = {
:created_at => true,
:updated_at => true,
:created_by_id => true,
:updated_by_id => true,
created_at: true,
updated_at: true,
created_by_id: true,
updated_by_id: true,
}
if self.class.activity_stream_support_config[:ignore_attributes]
self.class.activity_stream_support_config[:ignore_attributes].each {|key, value|
@ -823,10 +823,10 @@ log object update history with all updated attributes, if configured - will be e
# default ignored attributes
ignore_attributes = {
:created_at => true,
:updated_at => true,
:created_by_id => true,
:updated_by_id => true,
created_at: true,
updated_at: true,
created_by_id: true,
updated_by_id: true,
}
if self.class.history_support_config[:ignore_attributes]
self.class.history_support_config[:ignore_attributes].each {|key, value|
@ -854,7 +854,7 @@ log object update history with all updated attributes, if configured - will be e
if self.respond_to?( attribute_name ) && self.send(attribute_name)
relation_class = self.send(attribute_name).class
if relation_class && value_id[0]
relation_model = relation_class.lookup( :id => value_id[0] )
relation_model = relation_class.lookup( id: value_id[0] )
if relation_model
if relation_model['name']
value_str[0] = relation_model['name']
@ -864,7 +864,7 @@ log object update history with all updated attributes, if configured - will be e
end
end
if relation_class && value_id[1]
relation_model = relation_class.lookup( :id => value_id[1] )
relation_model = relation_class.lookup( id: value_id[1] )
if relation_model
if relation_model['name']
value_str[1] = relation_model['name']
@ -876,11 +876,11 @@ log object update history with all updated attributes, if configured - will be e
end
end
data = {
:history_attribute => attribute_name,
:value_from => value_str[0].to_s,
:value_to => value_str[1].to_s,
:id_from => value_id[0],
:id_to => value_id[1],
history_attribute: attribute_name,
value_from: value_str[0].to_s,
value_to: value_str[1].to_s,
id_from: value_id[0],
id_to: value_id[1],
}
#puts "HIST NEW #{self.class.to_s}.find(#{self.id}) #{data.inspect}"
self.history_log( 'updated', self.updated_by_id, data )
@ -915,7 +915,7 @@ returns
=end
def attachments
Store.list( :object => self.class.to_s, :o_id => self.id )
Store.list( object: self.class.to_s, o_id: self.id )
end
=begin
@ -952,8 +952,8 @@ return object and assets
object = self.find(id)
assets = object.assets({})
{
:id => id,
:assets => assets,
id: id,
assets: assets,
}
end
@ -1011,12 +1011,12 @@ get assets of object list
article_store = []
attachments_buffer.each do |attachment|
article_store.push Store.add(
:object => self.class.to_s,
:o_id => self.id,
:data => attachment.content,
:filename => attachment.filename,
:preferences => attachment.preferences,
:created_by_id => self.created_by_id,
object: self.class.to_s,
o_id: self.id,
data: attachment.content,
filename: attachment.filename,
preferences: attachment.preferences,
created_by_id: self.created_by_id,
)
end
attachments_buffer = nil

View file

@ -32,13 +32,13 @@ returns
updated_at = Time.new
end
ActivityStream.add(
:o_id => self['id'],
:type => type,
:object => self.class.name,
:group_id => self['group_id'],
:role => role,
:created_at => updated_at,
:created_by_id => user_id,
o_id: self['id'],
type: type,
object: self.class.name,
group_id: self['group_id'],
role: role,
created_at: updated_at,
created_by_id: user_id,
)
end

View file

@ -33,7 +33,7 @@ returns
['created_by_id', 'updated_by_id'].each {|item|
if self[ item ]
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
user = User.lookup( :id => self[ item ] )
user = User.lookup( id: self[ item ] )
data = user.assets( data )
end
end

View file

@ -92,8 +92,8 @@ returns
end
}
return {
:history => history[:list],
:assets => history[:assets],
history: history[:list],
assets: history[:assets],
}
end

View file

@ -20,9 +20,9 @@ returns
# default ignored attributes
ignore_attributes = {
:created_by_id => true,
:updated_by_id => true,
:active => true,
created_by_id: true,
updated_by_id: true,
active: true,
}
if self.class.search_index_support_config[:ignore_attributes]
self.class.search_index_support_config[:ignore_attributes].each {|key, value|
@ -123,7 +123,7 @@ returns
next if !relation_class
# lookup ref object
relation_model = relation_class.lookup( :id => value )
relation_model = relation_class.lookup( id: value )
next if !relation_model
# get name of ref object

View file

@ -6,22 +6,22 @@ class Authorization < ApplicationModel
after_update :delete_user_cache
after_destroy :delete_user_cache
validates_presence_of :user_id, :uid, :provider
validates_uniqueness_of :uid, :scope => :provider
validates_uniqueness_of :uid, scope: :provider
def self.find_from_hash(hash)
auth = Authorization.where( :provider => hash['provider'], :uid => hash['uid'] ).first
auth = Authorization.where( provider: hash['provider'], uid: hash['uid'] ).first
if auth
# update auth tokens
auth.update_attributes(
:token => hash['credentials']['token'],
:secret => hash['credentials']['secret']
token: hash['credentials']['token'],
secret: hash['credentials']['secret']
)
# update username of auth entry if empty
if !auth.username && hash['info']['nickname']
auth.update_attributes(
:username => hash['info']['nickname'],
username: hash['info']['nickname'],
)
end
@ -31,13 +31,13 @@ class Authorization < ApplicationModel
# save/update avatar
avatar = Avatar.add(
:object => 'User',
:o_id => user.id,
:url => hash['info']['image'],
:source => hash['provider'],
:deletable => true,
:updated_by_id => user.id,
:created_by_id => user.id,
object: 'User',
o_id: user.id,
url: hash['info']['image'],
source: hash['provider'],
deletable: true,
updated_by_id: user.id,
created_by_id: user.id,
)
# update user link
@ -54,13 +54,13 @@ class Authorization < ApplicationModel
# save/update avatar
avatar = Avatar.add(
:object => 'User',
:o_id => user.id,
:url => hash['info']['image'],
:source => hash['provider'],
:deletable => true,
:updated_by_id => user.id,
:created_by_id => user.id,
object: 'User',
o_id: user.id,
url: hash['info']['image'],
source: hash['provider'],
deletable: true,
updated_by_id: user.id,
created_by_id: user.id,
)
# update user link
@ -76,12 +76,12 @@ class Authorization < ApplicationModel
end
Authorization.create(
:user => user,
:uid => hash['uid'],
:username => hash['info']['nickname'] || hash['username'],
:provider => hash['provider'],
:token => hash['credentials']['token'],
:secret => hash['credentials']['secret']
user: user,
uid: hash['uid'],
username: hash['info']['nickname'] || hash['username'],
provider: hash['provider'],
token: hash['credentials']['token'],
secret: hash['credentials']['secret']
)
end

View file

@ -1,7 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Avatar < ApplicationModel
belongs_to :object_lookup, :class_name => 'ObjectLookup'
belongs_to :object_lookup, class_name: 'ObjectLookup'
=begin
@ -31,13 +31,13 @@ add an avatar based on auto detection (email address)
puts "#{data[:url]}: #{url}"
Avatar.add(
:object => data[:object],
:o_id => data[:o_id],
:url => url,
:source => 'gravatar.com',
:deletable => false,
:updated_by_id => 1,
:created_by_id => 1,
object: data[:object],
o_id: data[:o_id],
url: url,
source: 'gravatar.com',
deletable: false,
updated_by_id: 1,
created_by_id: 1,
)
end
@ -75,24 +75,24 @@ add a avatar
add_init_avatar(object_id, data[:o_id])
record = {
:o_id => data[:o_id],
:object_lookup_id => object_id,
:default => true,
:deletable => data[:deletable],
:initial => false,
:source => data[:source],
:source_url => data[:url],
:updated_by_id => data[:updated_by_id],
:created_by_id => data[:created_by_id],
o_id: data[:o_id],
object_lookup_id: object_id,
default: true,
deletable: data[:deletable],
initial: false,
source: data[:source],
source_url: data[:url],
updated_by_id: data[:updated_by_id],
created_by_id: data[:created_by_id],
}
# check if avatar with url already exists
avatar_already_exists = nil
if data[:source] && !data[:source].empty?
avatar_already_exists = Avatar.where(
:object_lookup_id => object_id,
:o_id => data[:o_id],
:source => data[:source],
object_lookup_id: object_id,
o_id: data[:o_id],
source: data[:source],
).first
end
@ -119,8 +119,8 @@ add a avatar
data[:url],
{},
{
:open_timeout => 4,
:read_timeout => 6,
open_timeout: 4,
read_timeout: 6,
},
)
if !response.success?
@ -159,28 +159,28 @@ add a avatar
object_name = "Avatar::#{data[:object]}"
if data[:full]
store_full = Store.add(
:object => "#{object_name}::Full",
:o_id => data[:o_id],
:data => data[:full][:content],
:filename => 'avatar_full',
:preferences => {
object: "#{object_name}::Full",
o_id: data[:o_id],
data: data[:full][:content],
filename: 'avatar_full',
preferences: {
'Mime-Type' => data[:full][:mime_type]
},
:created_by_id => data[:created_by_id],
created_by_id: data[:created_by_id],
)
record[:store_full_id] = store_full.id
record[:store_hash] = Digest::MD5.hexdigest( data[:full][:content] )
end
if data[:resize]
store_resize = Store.add(
:object => "#{object_name}::Resize",
:o_id => data[:o_id],
:data => data[:resize][:content],
:filename => 'avatar',
:preferences => {
object: "#{object_name}::Resize",
o_id: data[:o_id],
data: data[:resize][:content],
filename: 'avatar',
preferences: {
'Mime-Type' => data[:resize][:mime_type]
},
:created_by_id => data[:created_by_id],
created_by_id: data[:created_by_id],
)
record[:store_resize_id] = store_resize.id
record[:store_hash] = Digest::MD5.hexdigest( data[:resize][:content] )
@ -211,9 +211,9 @@ set avatars as default
def self.set_default( object_name, o_id, avatar_id )
object_id = ObjectLookup.by_name( object_name )
avatar = Avatar.where(
:object_lookup_id => object_id,
:o_id => o_id,
:id => avatar_id,
object_lookup_id: object_id,
o_id: o_id,
id: avatar_id,
).first
avatar.default = true
avatar.save!
@ -235,18 +235,18 @@ remove all avatars of an object
def self.remove( object_name, o_id )
object_id = ObjectLookup.by_name( object_name )
Avatar.where(
:object_lookup_id => object_id,
:o_id => o_id,
object_lookup_id: object_id,
o_id: o_id,
).destroy_all
object_name_store = "Avatar::#{object_name}"
Store.remove(
:object => "#{object_name_store}::Full",
:o_id => o_id,
object: "#{object_name_store}::Full",
o_id: o_id,
)
Store.remove(
:object => "#{object_name_store}::Resize",
:o_id => o_id,
object: "#{object_name_store}::Resize",
o_id: o_id,
)
end
@ -261,9 +261,9 @@ remove one avatars of an object
def self.remove_one( object_name, o_id, avatar_id )
object_id = ObjectLookup.by_name( object_name )
Avatar.where(
:object_lookup_id => object_id,
:o_id => o_id,
:id => avatar_id,
object_lookup_id: object_id,
o_id: o_id,
id: avatar_id,
).destroy_all
end
@ -278,8 +278,8 @@ return all avatars of an user
def self.list(object_name, o_id)
object_id = ObjectLookup.by_name( object_name )
avatars = Avatar.where(
:object_lookup_id => object_id,
:o_id => o_id,
object_lookup_id: object_id,
o_id: o_id,
).order( 'initial DESC, deletable ASC, created_at ASC, id DESC' )
# add initial avatar
@ -311,7 +311,7 @@ returns:
def self.get_by_hash(hash)
avatar = Avatar.where(
:store_hash => hash,
store_hash: hash,
).first
return if !avatar
file = Store.find(avatar.store_resize_id)
@ -332,9 +332,9 @@ returns:
def self.get_default(object_name, o_id)
object_id = ObjectLookup.by_name( object_name )
Avatar.where(
:object_lookup_id => object_id,
:o_id => o_id,
:default => true,
object_lookup_id: object_id,
o_id: o_id,
default: true,
).first
end
@ -342,8 +342,8 @@ returns:
def self.set_default_items(object_id, o_id, avatar_id)
avatars = Avatar.where(
:object_lookup_id => object_id,
:o_id => o_id,
object_lookup_id: object_id,
o_id: o_id,
).order( 'created_at ASC, id DESC' )
avatars.each do |avatar|
next if avatar.id == avatar_id
@ -355,20 +355,20 @@ returns:
def self.add_init_avatar(object_id, o_id)
count = Avatar.where(
:object_lookup_id => object_id,
:o_id => o_id,
object_lookup_id: object_id,
o_id: o_id,
).count
return if count > 0
Avatar.create(
:o_id => o_id,
:object_lookup_id => object_id,
:default => true,
:source => 'init',
:initial => true,
:deletable => false,
:updated_by_id => 1,
:created_by_id => 1,
o_id: o_id,
object_lookup_id: object_id,
default: true,
source: 'init',
initial: true,
deletable: false,
updated_by_id: 1,
created_by_id: 1,
)
end
end

View file

@ -130,7 +130,7 @@ class Channel::EmailParser
data[:body] = Encode.conv( mail.text_part.charset, data[:body] )
if !data[:body].valid_encoding?
data[:body] = data[:body].encode('utf-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')
data[:body] = data[:body].encode('utf-8', 'binary', invalid: :replace, undef: :replace, replace: '?')
end
# html attachment/body may exists and will be converted to text
@ -143,7 +143,7 @@ class Channel::EmailParser
data[:body] = data[:body].html2text.to_s.force_encoding('utf-8')
if !data[:body].force_encoding('UTF-8').valid_encoding?
data[:body] = data[:body].encode('utf-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')
data[:body] = data[:body].encode('utf-8', 'binary', invalid: :replace, undef: :replace, replace: '?')
end
# any other attachments
@ -165,9 +165,9 @@ class Channel::EmailParser
headers_store['Charset'] = mail.html_part.charset
end
attachment = {
:data => mail.html_part.body.to_s,
:filename => mail.html_part.filename || filename,
:preferences => headers_store
data: mail.html_part.body.to_s,
filename: mail.html_part.filename || filename,
preferences: headers_store
}
data[:attachments].push attachment
end
@ -196,7 +196,7 @@ class Channel::EmailParser
data[:body] = Encode.conv( mail.charset, data[:body] )
if !data[:body].force_encoding('UTF-8').valid_encoding?
data[:body] = data[:body].encode('utf-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')
data[:body] = data[:body].encode('utf-8', 'binary', invalid: :replace, undef: :replace, replace: '?')
end
# html part only, convert ot text and add it as attachment
@ -209,7 +209,7 @@ class Channel::EmailParser
data[:body] = data[:body].html2text.to_s.force_encoding('utf-8')
if !data[:body].valid_encoding?
data[:body] = data[:body].encode('utf-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')
data[:body] = data[:body].encode('utf-8', 'binary', invalid: :replace, undef: :replace, replace: '?')
end
# any other attachments
@ -228,9 +228,9 @@ class Channel::EmailParser
headers_store['Charset'] = mail.charset
end
attachment = {
:data => mail.body.decoded,
:filename => mail.filename || filename,
:preferences => headers_store
data: mail.body.decoded,
filename: mail.filename || filename,
preferences: headers_store
}
data[:attachments].push attachment
end
@ -316,9 +316,9 @@ class Channel::EmailParser
headers_store.delete('Content-Disposition')
attach = {
:data => file.body.to_s,
:filename => filename,
:preferences => headers_store,
data: file.body.to_s,
filename: filename,
preferences: headers_store,
}
[attach]
end
@ -358,18 +358,18 @@ class Channel::EmailParser
# create sender
if mail[ 'x-zammad-customer-login'.to_sym ]
user = User.where( :login => mail[ 'x-zammad-customer-login'.to_sym ] ).first
user = User.where( login: mail[ 'x-zammad-customer-login'.to_sym ] ).first
end
if !user
user = User.where( :email => mail[ 'x-zammad-customer-email'.to_sym ] || mail[:from_email] ).first
user = User.where( email: mail[ 'x-zammad-customer-email'.to_sym ] || mail[:from_email] ).first
end
if !user
puts 'create user...'
user = user_create(
:login => mail[ 'x-zammad-customer-login'.to_sym ] || mail[ 'x-zammad-customer-email'.to_sym ] || mail[:from_email],
:firstname => mail[ 'x-zammad-customer-firstname'.to_sym ] || mail[:from_display_name],
:lastname => mail[ 'x-zammad-customer-lastname'.to_sym ],
:email => mail[ 'x-zammad-customer-email'.to_sym ] || mail[:from_email],
login: mail[ 'x-zammad-customer-login'.to_sym ] || mail[ 'x-zammad-customer-email'.to_sym ] || mail[:from_email],
firstname: mail[ 'x-zammad-customer-firstname'.to_sym ] || mail[:from_display_name],
lastname: mail[ 'x-zammad-customer-lastname'.to_sym ],
email: mail[ 'x-zammad-customer-email'.to_sym ] || mail[:from_email],
)
end
@ -379,9 +379,9 @@ class Channel::EmailParser
items = mail[item.to_sym].tree
items.addresses.each {|item|
user_create(
:firstname => item.display_name,
:lastname => '',
:email => item.address,
firstname: item.display_name,
lastname: '',
email: item.address,
)
}
end
@ -404,7 +404,7 @@ class Channel::EmailParser
end
if state_type.name != 'new'
ticket.state = Ticket::State.where( :name => 'open' ).first
ticket.state = Ticket::State.where( name: 'open' ).first
ticket.save
end
end
@ -414,11 +414,11 @@ class Channel::EmailParser
# set attributes
ticket = Ticket.new(
:group_id => channel[:group_id] || 1,
:customer_id => user.id,
:title => mail[:subject] || '',
:state_id => Ticket::State.where( :name => 'new' ).first.id,
:priority_id => Ticket::Priority.where( :name => '2 normal' ).first.id,
group_id: channel[:group_id] || 1,
customer_id: user.id,
title: mail[:subject] || '',
state_id: Ticket::State.where( name: 'new' ).first.id,
priority_id: Ticket::Priority.where( name: '2 normal' ).first.id,
)
set_attributes_by_x_headers( ticket, 'ticket', mail )
@ -431,16 +431,16 @@ class Channel::EmailParser
# set attributes
article = Ticket::Article.new(
:ticket_id => ticket.id,
:type_id => Ticket::Article::Type.where( :name => 'email' ).first.id,
:sender_id => Ticket::Article::Sender.where( :name => 'Customer' ).first.id,
:body => mail[:body],
:from => mail[:from],
:to => mail[:to],
:cc => mail[:cc],
:subject => mail[:subject],
:message_id => mail[:message_id],
:internal => false,
ticket_id: ticket.id,
type_id: Ticket::Article::Type.where( name: 'email' ).first.id,
sender_id: Ticket::Article::Sender.where( name: 'Customer' ).first.id,
body: mail[:body],
from: mail[:from],
to: mail[:to],
cc: mail[:cc],
subject: mail[:subject],
message_id: mail[:message_id],
internal: false,
)
# x-headers lookup
@ -451,22 +451,22 @@ class Channel::EmailParser
# store mail plain
Store.add(
:object => 'Ticket::Article::Mail',
:o_id => article.id,
:data => msg,
:filename => "ticket-#{ticket.number}-#{article.id}.eml",
:preferences => {}
object: 'Ticket::Article::Mail',
o_id: article.id,
data: msg,
filename: "ticket-#{ticket.number}-#{article.id}.eml",
preferences: {}
)
# store attachments
if mail[:attachments]
mail[:attachments].each do |attachment|
Store.add(
:object => 'Ticket::Article',
:o_id => article.id,
:data => attachment[:data],
:filename => attachment[:filename],
:preferences => attachment[:preferences]
object: 'Ticket::Article',
o_id: article.id,
data: attachment[:data],
filename: attachment[:filename],
preferences: attachment[:preferences]
)
end
end
@ -497,11 +497,11 @@ class Channel::EmailParser
def user_create(data)
# return existing
user = User.where( :login => data[:email].downcase ).first
user = User.where( login: data[:email].downcase ).first
return user if user
# create new user
roles = Role.where( :name => 'Customer' )
roles = Role.where( name: 'Customer' )
# fillup
['firstname', 'lastname'].each { |item|
@ -517,8 +517,8 @@ class Channel::EmailParser
user = User.create(data)
user.update_attributes(
:updated_by_id => user.id,
:created_by_id => user.id,
updated_by_id: user.id,
created_by_id: user.id,
)
user
end
@ -547,12 +547,12 @@ class Channel::EmailParser
item = assoc.class_name.constantize
if item.respond_to?(:name)
if item.lookup( :name => mail[ header.to_sym ] )
item_object[key] = item.lookup( :name => mail[ header.to_sym ] ).id
if item.lookup( name: mail[ header.to_sym ] )
item_object[key] = item.lookup( name: mail[ header.to_sym ] ).id
end
elsif item.respond_to?(:login)
if item.lookup( :login => mail[ header.to_sym ] )
item_object[key] = item.lookup( :login => mail[ header.to_sym ] ).id
if item.lookup( login: mail[ header.to_sym ] )
item_object[key] = item.lookup( login: mail[ header.to_sym ] ).id
end
end
end

View file

@ -4,7 +4,7 @@ require 'net/imap'
module Channel::EmailSend
def self.send(attr, notification = false)
channel = Channel.where( :area => 'Email::Outbound', :active => true ).first
channel = Channel.where( area: 'Email::Outbound', active: true ).first
begin
c = eval 'Channel::' + channel[:adapter] + '.new'
c.send(attr, channel, notification)

View file

@ -25,7 +25,7 @@ class Channel::Facebook
'id',
'comments',
{
:message => self.body
message: self.body
}
)
# client.direct_message_create(

View file

@ -6,7 +6,7 @@ module Channel::Filter::Database
def self.run( channel, mail )
# process postmaster filter
filters = PostmasterFilter.where( :active => true, :channel => 'email' )
filters = PostmasterFilter.where( active: true, channel: 'email' )
filters.each {|filter|
puts " proccess filter #{filter.name} ..."
match = true

View file

@ -8,13 +8,13 @@ class Channel::SMTP
mail = Channel::EmailBuild.build(attr, notification)
mail.delivery_method :smtp, {
:openssl_verify_mode => 'none',
:address => channel[:options][:host],
:port => channel[:options][:port] || 25,
:domain => channel[:options][:host],
:user_name => channel[:options][:user],
:password => channel[:options][:password],
:enable_starttls_auto => true,
openssl_verify_mode: 'none',
address: channel[:options][:host],
port: channel[:options][:port] || 25,
domain: channel[:options][:host],
user_name: channel[:options][:user],
password: channel[:options][:password],
enable_starttls_auto: true,
}
mail.deliver
end

View file

@ -28,7 +28,7 @@ class Channel::TWITTER2
channel[:options][:search].each { |search|
puts " - searching for #{search[:item]}"
tweets = []
@client.search( search[:item], :count => 50, :result_type => 'recent' ).collect do |tweet|
@client.search( search[:item], count: 50, result_type: 'recent' ).collect do |tweet|
tweets.push tweet
end
@article_type = 'twitter status'
@ -74,7 +74,7 @@ class Channel::TWITTER2
all_tweets.each do |tweet|
# check if tweet is already imported
article = Ticket::Article.where( :message_id => tweet.id.to_s ).first
article = Ticket::Article.where( message_id: tweet.id.to_s ).first
# check if sender already exists
next if article
@ -140,34 +140,34 @@ class Channel::TWITTER2
# create sender in db
# puts tweet.inspect
# user = User.where( :login => tweet.sender.screen_name ).first
auth = Authorization.where( :uid => sender.id, :provider => 'twitter' ).first
auth = Authorization.where( uid: sender.id, provider: 'twitter' ).first
user = nil
if auth
puts 'user_id', auth.user_id
user = User.where( :id => auth.user_id ).first
user = User.where( id: auth.user_id ).first
end
if !user
puts 'create user...'
roles = Role.where( :name => 'Customer' )
roles = Role.where( name: 'Customer' )
user = User.create(
:login => sender.screen_name,
:firstname => sender.name,
:lastname => '',
:email => '',
:password => '',
:image_source => sender.profile_image_url.to_s,
:note => sender.description,
:active => true,
:roles => roles,
:updated_by_id => 1,
:created_by_id => 1
login: sender.screen_name,
firstname: sender.name,
lastname: '',
email: '',
password: '',
image_source: sender.profile_image_url.to_s,
note: sender.description,
active: true,
roles: roles,
updated_by_id: 1,
created_by_id: 1
)
puts 'autentication create...'
authentication = Authorization.create(
:uid => sender.id,
:username => sender.screen_name,
:user_id => user.id,
:provider => 'twitter'
uid: sender.id,
username: sender.screen_name,
user_id: user.id,
provider: 'twitter'
)
else
puts 'user exists'#, user.inspect
@ -185,7 +185,7 @@ class Channel::TWITTER2
# check if ticket exists
if tweet.respond_to?('in_reply_to_status_id') && tweet.in_reply_to_status_id && tweet.in_reply_to_status_id.to_s != ''
puts 'tweet.in_reply_to_status_id found: ' + tweet.in_reply_to_status_id.to_s
article = Ticket::Article.where( :message_id => tweet.in_reply_to_status_id.to_s ).first
article = Ticket::Article.where( message_id: tweet.in_reply_to_status_id.to_s ).first
if article
puts 'article with id found tweet.in_reply_to_status_id found: ' + tweet.in_reply_to_status_id.to_s
return article.ticket
@ -193,14 +193,14 @@ class Channel::TWITTER2
end
# find if record already exists
article = Ticket::Article.where( :message_id => tweet.id.to_s ).first
article = Ticket::Article.where( message_id: tweet.id.to_s ).first
if article
return article.ticket
end
ticket = nil
if @article_type == 'twitter direct-message'
ticket = Ticket.where( :customer_id => user.id ).first
ticket = Ticket.where( customer_id: user.id ).first
if ticket
state_type = Ticket::StateType.where( ticket.state.state_type_id )
if state_type.name == 'closed' || state_type.name == 'closed'
@ -209,27 +209,27 @@ class Channel::TWITTER2
end
end
if !ticket
group = Group.where( :name => group ).first
group = Group.where( name: group ).first
group_id = 1
if group
group_id = group.id
end
state = Ticket::State.where( :name => 'new' ).first
state = Ticket::State.where( name: 'new' ).first
state_id = 1
if state
state_id = state.id
end
priority = Ticket::Priority.where( :name => '2 normal' ).first
priority = Ticket::Priority.where( name: '2 normal' ).first
priority_id = 1
if priority
priority_id = priority.id
end
ticket = Ticket.create(
:group_id => group_id,
:customer_id => user.id,
:title => tweet.text[0,40],
:state_id => state_id,
:priority_id => priority_id,
group_id: group_id,
customer_id: user.id,
title: tweet.text[0,40],
state_id: state_id,
priority_id: priority_id,
)
end
@ -239,12 +239,12 @@ class Channel::TWITTER2
def fetch_article_create( user, ticket, tweet, sender )
# find if record already exists
article = Ticket::Article.where( :message_id => tweet.id.to_s ).first
article = Ticket::Article.where( message_id: tweet.id.to_s ).first
return article if article
# set ticket state to open if not new
if ticket.state.name != 'new'
ticket.state = Ticket::State.where( :name => 'open' ).first
ticket.state = Ticket::State.where( name: 'open' ).first
ticket.save
end
@ -255,21 +255,21 @@ class Channel::TWITTER2
end
article = Ticket::Article.create(
:ticket_id => ticket.id,
:type_id => Ticket::Article::Type.where( :name => @article_type ).first.id,
:sender_id => Ticket::Article::Sender.where( :name => 'Customer' ).first.id,
:body => tweet.text,
:from => sender.name,
:to => to,
:message_id => tweet.id,
:internal => false,
ticket_id: ticket.id,
type_id: Ticket::Article::Type.where( name: @article_type ).first.id,
sender_id: Ticket::Article::Sender.where( name: 'Customer' ).first.id,
body: tweet.text,
from: sender.name,
to: to,
message_id: tweet.id,
internal: false,
)
end
def send(attr, notification = false)
# logger.debug('tweeeeettttt!!!!!!')
channel = Channel.where( :area => 'Twitter::Inbound', :active => true ).first
channel = Channel.where( area: 'Twitter::Inbound', active: true ).first
client = Twitter::REST::Client.new do |config|
config.consumer_key = channel[:options][:consumer_key]
@ -292,7 +292,7 @@ class Channel::TWITTER2
message = client.update(
attr[:body].to_s,
{
:in_reply_to_status_id => attr[:in_reply_to]
in_reply_to_status_id: attr[:in_reply_to]
}
)
# puts message.inspect

View file

@ -1,9 +1,9 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class EmailAddress < ApplicationModel
has_many :groups, :after_add => :cache_update, :after_remove => :cache_update
validates :realname, :presence => true
validates :email, :presence => true
has_many :groups, after_add: :cache_update, after_remove: :cache_update
validates :realname, presence: true
validates :email, presence: true
latest_change_support

View file

@ -1,12 +1,12 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Group < ApplicationModel
has_and_belongs_to_many :users, :after_add => :cache_update, :after_remove => :cache_update
has_and_belongs_to_many :users, after_add: :cache_update, after_remove: :cache_update
belongs_to :email_address
belongs_to :signature
validates :name, :presence => true
validates :name, presence: true
activity_stream_support :role => Z_ROLENAME_ADMIN
activity_stream_support role: Z_ROLENAME_ADMIN
history_support
latest_change_support
end

View file

@ -5,9 +5,9 @@ class History < ApplicationModel
include History::Assets
self.table_name = 'histories'
belongs_to :history_type, :class_name => 'History::Type'
belongs_to :history_object, :class_name => 'History::Object'
belongs_to :history_attribute, :class_name => 'History::Attribute'
belongs_to :history_type, class_name: 'History::Type'
belongs_to :history_object, class_name: 'History::Object'
belongs_to :history_attribute, class_name: 'History::Attribute'
# before_validation :check_type, :check_object
# attr_writer :history_type, :history_object
@ -60,23 +60,23 @@ add a new history entry for an object
# create history
record = {
:id => data[:id],
:o_id => data[:o_id],
:history_type_id => history_type.id,
:history_object_id => history_object.id,
:history_attribute_id => history_attribute_id,
:related_history_object_id => related_history_object_id,
:related_o_id => data[:related_o_id],
:value_from => data[:value_from],
:value_to => data[:value_to],
:id_from => data[:id_from],
:id_to => data[:id_to],
:created_at => data[:created_at],
:created_by_id => data[:created_by_id]
id: data[:id],
o_id: data[:o_id],
history_type_id: history_type.id,
history_object_id: history_object.id,
history_attribute_id: history_attribute_id,
related_history_object_id: related_history_object_id,
related_o_id: data[:related_o_id],
value_from: data[:value_from],
value_to: data[:value_to],
id_from: data[:id_from],
id_to: data[:id_to],
created_at: data[:created_at],
created_by_id: data[:created_by_id]
}
history_record = nil
if data[:id]
history_record = History.where( :id => data[:id] ).first
history_record = History.where( id: data[:id] ).first
end
if history_record
history_record.update_attributes(record)
@ -98,11 +98,11 @@ remove whole history entries of an object
=end
def self.remove( requested_object, requested_object_id )
history_object = History::Object.where( :name => requested_object ).first
history_object = History::Object.where( name: requested_object ).first
return if !history_object
History.where(
:history_object_id => history_object.id,
:o_id => requested_object_id,
history_object_id: history_object.id,
o_id: requested_object_id,
).destroy_all
end
@ -152,8 +152,8 @@ returns
def self.list( requested_object, requested_object_id, related_history_object = nil, assets = nil )
if !related_history_object
history_object = self.object_lookup( requested_object )
history = History.where( :history_object_id => history_object.id ).
where( :o_id => requested_object_id ).
history = History.where( history_object_id: history_object.id ).
where( o_id: requested_object_id ).
order('created_at ASC, id ASC')
else
history_object_requested = self.object_lookup( requested_object )
@ -208,8 +208,8 @@ returns
end
if assets
return {
:list => list,
:assets => asset_list,
list: list,
assets: asset_list,
}
end
list
@ -223,7 +223,7 @@ returns
return @@cache_type[ id ] if @@cache_type[ id ]
# lookup
history_type = History::Type.lookup( :id => id )
history_type = History::Type.lookup( id: id )
@@cache_type[ id ] = history_type
return history_type
end
@ -234,7 +234,7 @@ returns
return @@cache_type[ name ] if @@cache_type[ name ]
# lookup
history_type = History::Type.lookup( :name => name )
history_type = History::Type.lookup( name: name )
if history_type
@@cache_type[ name ] = history_type
return history_type
@ -242,7 +242,7 @@ returns
# create
history_type = History::Type.create(
:name => name
name: name
)
@@cache_type[ name ] = history_type
return history_type
@ -254,7 +254,7 @@ returns
return @@cache_object[ id ] if @@cache_object[ id ]
# lookup
history_object = History::Object.lookup( :id => id )
history_object = History::Object.lookup( id: id )
@@cache_object[ id ] = history_object
return history_object
end
@ -265,7 +265,7 @@ returns
return @@cache_object[ name ] if @@cache_object[ name ]
# lookup
history_object = History::Object.lookup( :name => name )
history_object = History::Object.lookup( name: name )
if history_object
@@cache_object[ name ] = history_object
return history_object
@ -273,7 +273,7 @@ returns
# create
history_object = History::Object.create(
:name => name
name: name
)
@@cache_object[ name ] = history_object
return history_object
@ -285,7 +285,7 @@ returns
return @@cache_attribute[ id ] if @@cache_attribute[ id ]
# lookup
history_attribute = History::Attribute.lookup( :id => id )
history_attribute = History::Attribute.lookup( id: id )
@@cache_attribute[ id ] = history_attribute
return history_attribute
end
@ -296,7 +296,7 @@ returns
return @@cache_attribute[ name ] if @@cache_attribute[ name ]
# lookup
history_attribute = History::Attribute.lookup( :name => name )
history_attribute = History::Attribute.lookup( name: name )
if history_attribute
@@cache_attribute[ name ] = history_attribute
return history_attribute
@ -304,7 +304,7 @@ returns
# create
history_attribute = History::Attribute.create(
:name => name
name: name
)
@@cache_attribute[ name ] = history_attribute
return history_attribute

View file

@ -23,7 +23,7 @@ returns
def assets (data)
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self['created_by_id'] ]
user = User.lookup( :id => self['created_by_id'] )
user = User.lookup( id: self['created_by_id'] )
data = user.assets( data )
end

View file

@ -4,7 +4,7 @@ class Job < ApplicationModel
store :timeplan
store :condition
store :execute
validates :name, :presence => true
validates :name, presence: true
before_create :updated_matching
before_update :updated_matching
@ -22,7 +22,7 @@ class Job < ApplicationModel
5 => 'fri',
6 => 'sat',
}
jobs = Job.where( :active => true )
jobs = Job.where( active: true )
jobs.each do |job|
# only execute jobs, older then 1 min, to give admin posibility to change

View file

@ -1,8 +1,8 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Link < ApplicationModel
belongs_to :link_type, :class_name => 'Link::Type'
belongs_to :link_object, :class_name => 'Link::Object'
belongs_to :link_type, class_name: 'Link::Type'
belongs_to :link_object, class_name: 'Link::Object'
@map = {
'normal' => 'normal',
@ -20,7 +20,7 @@ class Link < ApplicationModel
=end
def self.list(data)
linkobject = self.link_object_get( :name => data[:link_object] )
linkobject = self.link_object_get( name: data[:link_object] )
return if !linkobject
items = []
@ -75,19 +75,19 @@ class Link < ApplicationModel
def self.add(data)
if data.has_key?(:link_type)
linktype = self.link_type_get( :name => data[:link_type] )
linktype = self.link_type_get( name: data[:link_type] )
data[:link_type_id] = linktype.id
data.delete( :link_type )
end
if data.has_key?(:link_object_source)
linkobject = self.link_object_get( :name => data[:link_object_source] )
linkobject = self.link_object_get( name: data[:link_object_source] )
data[:link_object_source_id] = linkobject.id
data.delete( :link_object_source )
end
if data.has_key?(:link_object_target)
linkobject = self.link_object_get( :name => data[:link_object_target] )
linkobject = self.link_object_get( name: data[:link_object_target] )
data[:link_object_target_id] = linkobject.id
data.delete( :link_object_target )
end
@ -109,26 +109,26 @@ class Link < ApplicationModel
def self.remove(data)
if data.has_key?(:link_object_source)
linkobject = self.link_object_get( :name => data[:link_object_source] )
linkobject = self.link_object_get( name: data[:link_object_source] )
data[:link_object_source_id] = linkobject.id
end
if data.has_key?(:link_object_target)
linkobject = self.link_object_get( :name => data[:link_object_target] )
linkobject = self.link_object_get( name: data[:link_object_target] )
data[:link_object_target_id] = linkobject.id
end
# from one site
if data.has_key?(:link_type)
linktype = self.link_type_get( :name => data[:link_type] )
linktype = self.link_type_get( name: data[:link_type] )
data[:link_type_id] = linktype.id
end
links = Link.where(
:link_type_id => data[:link_type_id],
:link_object_source_id => data[:link_object_source_id],
:link_object_source_value => data[:link_object_source_value],
:link_object_target_id => data[:link_object_target_id],
:link_object_target_value => data[:link_object_target_value]
link_type_id: data[:link_type_id],
link_object_source_id: data[:link_object_source_id],
link_object_source_value: data[:link_object_source_value],
link_object_target_id: data[:link_object_target_id],
link_object_target_value: data[:link_object_target_value]
)
links.each { |link|
link.destroy
@ -136,15 +136,15 @@ class Link < ApplicationModel
# from the other site
if data.has_key?(:link_type)
linktype = self.link_type_get( :name => @map[ data[:link_type] ] )
linktype = self.link_type_get( name: @map[ data[:link_type] ] )
data[:link_type_id] = linktype.id
end
links = Link.where(
:link_type_id => data[:link_type_id],
:link_object_target_id => data[:link_object_source_id],
:link_object_target_value => data[:link_object_source_value],
:link_object_source_id => data[:link_object_target_id],
:link_object_source_value => data[:link_object_target_value]
link_type_id: data[:link_type_id],
link_object_target_id: data[:link_object_source_id],
link_object_target_value: data[:link_object_source_value],
link_object_source_id: data[:link_object_target_id],
link_object_source_value: data[:link_object_target_value]
)
links.each { |link|
link.destroy
@ -153,20 +153,20 @@ class Link < ApplicationModel
private
def self.link_type_get(data)
linktype = Link::Type.where( :name => data[:name] ).first
linktype = Link::Type.where( name: data[:name] ).first
if !linktype
linktype = Link::Type.create(
:name => data[:name]
name: data[:name]
)
end
return linktype
end
def self.link_object_get(data)
linkobject = Link::Object.where( :name => data[:name] ).first
linkobject = Link::Object.where( name: data[:name] ).first
if !linkobject
linkobject = Link::Object.create(
:name => data[:name]
name: data[:name]
)
end
return linkobject
@ -175,9 +175,9 @@ class Link < ApplicationModel
end
class Link::Type < ApplicationModel
validates :name, :presence => true
validates :name, presence: true
end
class Link::Object < ApplicationModel
validates :name, :presence => true
validates :name, presence: true
end

View file

@ -9,7 +9,7 @@ class Locale < ApplicationModel
url,
{},
{
:json => true,
json: true,
}
)
@ -17,7 +17,7 @@ class Locale < ApplicationModel
result.data.each {|locale|
puts locale.inspect
exists = Locale.where(:locale => locale['locale']).first
exists = Locale.where(locale: locale['locale']).first
if exists
exists.update(locale.symbolize_keys!)
else

View file

@ -9,7 +9,7 @@ class ObjectLookup < ApplicationModel
return @@cache_object[ id ] if @@cache_object[ id ]
# lookup
lookup = self.lookup( :id => id )
lookup = self.lookup( id: id )
return if !lookup
@@cache_object[ id ] = lookup.name
lookup.name
@ -21,7 +21,7 @@ class ObjectLookup < ApplicationModel
return @@cache_object[ name ] if @@cache_object[ name ]
# lookup
lookup = self.lookup( :name => name )
lookup = self.lookup( name: name )
if lookup
@@cache_object[ name ] = lookup.id
return lookup.id
@ -29,7 +29,7 @@ class ObjectLookup < ApplicationModel
# create
lookup = self.create(
:name => name
name: name
)
@@cache_object[ name ] = lookup.id
lookup.id

View file

@ -30,8 +30,8 @@ end
class ObjectManager::Attribute < ApplicationModel
self.table_name = 'object_manager_attributes'
belongs_to :object_lookup, :class_name => 'ObjectLookup'
validates :name, :presence => true
belongs_to :object_lookup, class_name: 'ObjectLookup'
validates :name, presence: true
store :screens
store :data_option
@ -113,8 +113,8 @@ add a new attribute entry for an object
# check newest entry - is needed
result = ObjectManager::Attribute.where(
:object_lookup_id => data[:object_lookup_id],
:name => data[:name],
object_lookup_id: data[:object_lookup_id],
name: data[:name],
).first
if result
# raise "ERROR: attribute #{data[:name]} for #{data[:object]} already exists"
@ -145,8 +145,8 @@ get the attribute model based on object and name
end
ObjectManager::Attribute.where(
:object_lookup_id => data[:object_lookup_id],
:name => data[:name],
object_lookup_id: data[:object_lookup_id],
name: data[:name],
).first
end
@ -175,15 +175,15 @@ returns:
# get attributes in right order
result = ObjectManager::Attribute.where(
:object_lookup_id => object_lookup_id,
:active => true,
object_lookup_id: object_lookup_id,
active: true,
).order('position ASC')
attributes = []
result.each {|item|
data = {
:name => item.name,
:display => item.display,
:tag => item.data_type,
name: item.name,
display: item.display,
tag: item.data_type,
#:null => item.null,
}
if item.screens

View file

@ -19,7 +19,7 @@ class Observer::Organization::RefObjectTouch < ActiveRecord::Observer
return if Setting.get('import_mode')
# touch organizations tickets
Ticket.select('id').where( :organization_id => record.id ).each {|ticket|
Ticket.select('id').where( organization_id: record.id ).each {|ticket|
ticket.touch
}

View file

@ -12,11 +12,11 @@ class Observer::Tag::TicketHistory < ActiveRecord::Observer
# add ticket history
History.add(
:o_id => record.o_id,
:history_type => 'added',
:history_object => 'Ticket',
:history_attribute => 'tag',
:value_to => record.tag_item.name,
o_id: record.o_id,
history_type: 'added',
history_object: 'Ticket',
history_attribute: 'tag',
value_to: record.tag_item.name,
)
end
def after_destroy(record)
@ -26,11 +26,11 @@ class Observer::Tag::TicketHistory < ActiveRecord::Observer
# add ticket history
History.add(
:o_id => record.o_id,
:history_type => 'removed',
:history_object => 'Ticket',
:history_attribute => 'tag',
:value_to => record.tag_item.name,
o_id: record.o_id,
history_type: 'removed',
history_object: 'Ticket',
history_attribute: 'tag',
value_to: record.tag_item.name,
)
end
end

View file

@ -9,12 +9,12 @@ class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer
return if Setting.get('import_mode')
# if sender is customer, do not communication
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
return 1 if sender == nil
return 1 if sender['name'] == 'Customer'
# only apply on emails
type = Ticket::Article::Type.lookup( :id => record.type_id )
type = Ticket::Article::Type.lookup( id: record.type_id )
return if type['name'] != 'email'
# send background job

View file

@ -6,32 +6,32 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob
record = Ticket::Article.find( @article_id )
# build subject
ticket = Ticket.lookup( :id => record.ticket_id )
ticket = Ticket.lookup( id: record.ticket_id )
subject = ticket.subject_build( record.subject )
# send email
message = Channel::EmailSend.send(
{
:message_id => record.message_id,
:in_reply_to => record.in_reply_to,
:from => record.from,
:to => record.to,
:cc => record.cc,
:subject => subject,
:content_type => record.content_type,
:body => record.body,
:attachments => record.attachments
message_id: record.message_id,
in_reply_to: record.in_reply_to,
from: record.from,
to: record.to,
cc: record.cc,
subject: subject,
content_type: record.content_type,
body: record.body,
attachments: record.attachments
}
)
# store mail plain
Store.add(
:object => 'Ticket::Article::Mail',
:o_id => record.id,
:data => message.to_s,
:filename => "ticket-#{ticket.number}-#{record.id}.eml",
:preferences => {},
:created_by_id => record.created_by_id,
object: 'Ticket::Article::Mail',
o_id: record.id,
data: message.to_s,
filename: "ticket-#{ticket.number}-#{record.id}.eml",
preferences: {},
created_by_id: record.created_by_id,
)
# add history record
@ -46,14 +46,14 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob
}
if recipient_list != ''
History.add(
:o_id => record.id,
:history_type => 'email',
:history_object => 'Ticket::Article',
:related_o_id => ticket.id,
:related_history_object => 'Ticket',
:value_from => record.subject,
:value_to => recipient_list,
:created_by_id => record.created_by_id,
o_id: record.id,
history_type: 'email',
history_object: 'Ticket::Article',
related_o_id: ticket.id,
related_history_object: 'Ticket',
value_from: record.subject,
value_to: recipient_list,
created_by_id: record.created_by_id,
)
end
end

View file

@ -9,20 +9,20 @@ class Observer::Ticket::Article::CommunicateFacebook < ActiveRecord::Observer
return if Setting.get('import_mode')
# if sender is customer, do not communication
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
return 1 if sender == nil
return 1 if sender['name'] == 'Customer'
# only apply on emails
type = Ticket::Article::Type.lookup( :id => record.type_id )
type = Ticket::Article::Type.lookup( id: record.type_id )
return if type['name'] != 'facebook'
a = Channel::Facebook.new
a.send(
{
:from => 'me@znuny.com',
:to => 'medenhofer',
:body => record.body
from: 'me@znuny.com',
to: 'medenhofer',
body: record.body
}
)
end

View file

@ -9,21 +9,21 @@ class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
return if Setting.get('import_mode')
# if sender is customer, do not communication
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
return 1 if sender == nil
return 1 if sender['name'] == 'Customer'
# only apply on tweets
type = Ticket::Article::Type.lookup( :id => record.type_id )
type = Ticket::Article::Type.lookup( id: record.type_id )
return if type['name'] != 'twitter direct-message' && type['name'] != 'twitter status'
a = Channel::TWITTER2.new
message = a.send(
{
:type => type['name'],
:to => record.to,
:body => record.body,
:in_reply_to => record.in_reply_to
type: type['name'],
to: record.to,
body: record.body,
in_reply_to: record.in_reply_to
},
# Rails.application.config.channel_twitter
)

View file

@ -9,16 +9,16 @@ class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer
return if Setting.get('import_mode')
# if sender is customer, do not change anything
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
return if sender == nil
return if sender['name'] == 'Customer'
# set email attributes
type = Ticket::Article::Type.lookup( :id => record.type_id )
type = Ticket::Article::Type.lookup( id: record.type_id )
return if type['name'] != 'email'
# set subject if empty
ticket = Ticket.lookup( :id => record.ticket_id )
ticket = Ticket.lookup( id: record.ticket_id )
if !record.subject || record.subject == ''
record.subject = ticket.title
end

View file

@ -9,7 +9,7 @@ class Observer::Ticket::Article::FillupFromGeneral < ActiveRecord::Observer
return if Setting.get('import_mode')
# if sender is customer, do not change anything
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
return if sender == nil
return if sender['name'] == 'Customer'

View file

@ -6,7 +6,7 @@ class Observer::Ticket::ArticleSenderType < ActiveRecord::Observer
def after_create(record)
# get article count
count = Ticket::Article.where( :ticket_id => record.ticket_id ).count
count = Ticket::Article.where( ticket_id: record.ticket_id ).count
return if count > 1
record.ticket.create_article_type_id = record.type_id

View file

@ -22,8 +22,8 @@ class Observer::Ticket::CloseTime < ActiveRecord::Observer
return true if record.close_time
# check if ticket is closed now
state = Ticket::State.lookup( :id => record.state_id )
state_type = Ticket::StateType.lookup( :id => state.state_type_id )
state = Ticket::State.lookup( id: record.state_id )
state_type = Ticket::StateType.lookup( id: state.state_type_id )
return true if state_type.name != 'closed'
# set close_time

View file

@ -13,8 +13,8 @@ class Observer::Ticket::FirstResponse < ActiveRecord::Observer
return true if record.internal
# if sender is not agent
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
type = Ticket::Article::Type.lookup( :id => record.type_id )
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
type = Ticket::Article::Type.lookup( id: record.type_id )
if sender.name != 'Agent' && type.name !~ /^phone/
return true
end

View file

@ -10,10 +10,10 @@ class Observer::Ticket::LastContact < ActiveRecord::Observer
return true if record.internal
# if article is a message to customer
return true if !Ticket::Article::Type.lookup( :id => record.type_id ).communication
return true if !Ticket::Article::Type.lookup( id: record.type_id ).communication
# if sender is not customer
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
if sender.name == 'Customer'
# check if last communication is done by agent, else do not set last_contact_customer

View file

@ -54,7 +54,7 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
# get current state of objects
if event[:name] == 'Ticket::Article'
article = Ticket::Article.lookup( :id => event[:id] )
article = Ticket::Article.lookup( id: event[:id] )
# next if article is already deleted
next if !article
@ -71,7 +71,7 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
end
elsif event[:name] == 'Ticket'
ticket = Ticket.lookup( :id => event[:id] )
ticket = Ticket.lookup( id: event[:id] )
# next if ticket is already deleted
next if !ticket
@ -115,10 +115,10 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
# puts 'CREATED!!!!'
# puts record.inspect
e = {
:name => record.class.name,
:type => 'create',
:data => record,
:id => record.id,
name: record.class.name,
type: 'create',
data: record,
id: record.id,
}
EventBuffer.add(e)
end
@ -150,11 +150,11 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
return if real_changes.empty?
e = {
:name => record.class.name,
:type => 'update',
:data => record,
:changes => real_changes,
:id => record.id,
name: record.class.name,
type: 'update',
data: record,
changes: real_changes,
id: record.id,
}
EventBuffer.add(e)
end

View file

@ -66,12 +66,12 @@ class Observer::Ticket::Notification::BackgroundJob
# create online notification
seen = ticket.online_notification_seen_state
OnlineNotification.add(
:type => @p[:type],
:object => 'Ticket',
:o_id => ticket.id,
:seen => seen,
:created_by_id => ticket.updated_by_id || 1,
:user_id => user.id,
type: @p[:type],
object: 'Ticket',
o_id: ticket.id,
seen: seen,
created_by_id: ticket.updated_by_id || 1,
user_id: user.id,
)
# create email notification
@ -103,12 +103,12 @@ class Observer::Ticket::Notification::BackgroundJob
notification = {}
[:subject, :body].each { |key|
notification[key.to_sym] = NotificationFactory.build(
:locale => user.preferences[:locale],
:string => template[key],
:objects => {
:ticket => ticket,
:article => article,
:recipient => user,
locale: user.preferences[:locale],
string: template[key],
objects: {
ticket: ticket,
article: article,
recipient: user,
}
)
}
@ -120,21 +120,21 @@ class Observer::Ticket::Notification::BackgroundJob
puts "send ticket notifiaction to agent (#{@p[:type]}/#{ticket.id}/#{user.email})"
NotificationFactory.send(
:recipient => user,
:subject => notification[:subject],
:body => notification[:body],
:content_type => 'text/html',
recipient: user,
subject: notification[:subject],
body: notification[:body],
content_type: 'text/html',
)
end
# add history record
if recipient_list != ''
History.add(
:o_id => ticket.id,
:history_type => 'notification',
:history_object => 'Ticket',
:value_to => recipient_list,
:created_by_id => ticket.updated_by_id || 1
o_id: ticket.id,
history_type: 'notification',
history_object: 'Ticket',
value_to: recipient_list,
created_by_id: ticket.updated_by_id || 1
)
end
end
@ -184,7 +184,7 @@ class Observer::Ticket::Notification::BackgroundJob
if record.respond_to?( attribute_name ) && record.send(attribute_name)
relation_class = record.send(attribute_name).class
if relation_class && value_id[0]
relation_model = relation_class.lookup( :id => value_id[0] )
relation_model = relation_class.lookup( id: value_id[0] )
if relation_model
if relation_model['name']
value_str[0] = relation_model['name']
@ -194,7 +194,7 @@ class Observer::Ticket::Notification::BackgroundJob
end
end
if relation_class && value_id[1]
relation_model = relation_class.lookup( :id => value_id[1] )
relation_model = relation_class.lookup( id: value_id[1] )
if relation_model
if relation_model['name']
value_str[1] = relation_model['name']
@ -281,8 +281,8 @@ State: i18n(#{ticket.state.name.text2html})<br>
body += template_footer(user, ticket, article)
template = {
:subject => subject,
:body => body,
subject: subject,
body: body,
}
template
end
@ -342,8 +342,8 @@ Changes:<br>
body += template_footer(user,ticket, article)
template = {
:subject => subject,
:body => body,
subject: subject,
body: body,
}
template
end

View file

@ -13,17 +13,17 @@ class Observer::Ticket::ResetNewState < ActiveRecord::Observer
return true if record.internal
# if sender is agent
return true if Ticket::Article::Sender.lookup( :id => record.sender_id ).name != 'Agent'
return true if Ticket::Article::Sender.lookup( id: record.sender_id ).name != 'Agent'
# if article is a message to customer
return true if !Ticket::Article::Type.lookup( :id => record.type_id ).communication
return true if !Ticket::Article::Type.lookup( id: record.type_id ).communication
# if current ticket state is still new
ticket = Ticket.lookup( :id => record.ticket_id )
ticket = Ticket.lookup( id: record.ticket_id )
return true if ticket.state.state_type.name != 'new'
# TODO: add config option to state managment in UI
state = Ticket::State.lookup( :name => 'open' )
state = Ticket::State.lookup( name: 'open' )
return if !state
# set ticket to open

View file

@ -20,19 +20,19 @@ class Observer::Ticket::UserTicketCounter < ActiveRecord::Observer
# open ticket count
state_open = Ticket::State.by_category( 'open' )
tickets_open = Ticket.where(
:customer_id => record.customer_id,
:state_id => state_open,
customer_id: record.customer_id,
state_id: state_open,
).count()
# closed ticket count
state_closed = Ticket::State.by_category( 'closed' )
tickets_closed = Ticket.where(
:customer_id => record.customer_id,
:state_id => state_closed,
customer_id: record.customer_id,
state_id: state_closed,
).count()
# check if update is needed
customer = User.lookup( :id => record.customer_id )
customer = User.lookup( id: record.customer_id )
need_update = false
if customer[:preferences][:tickets_open] != tickets_open
need_update = true

View file

@ -17,7 +17,7 @@ class Observer::User::Geo < ActiveRecord::Observer
# check if geo update is needed based on old/new location
if record.id
current = User.where( :id => record.id ).first
current = User.where( id: record.id ).first
return if !current
current_location = {}

View file

@ -17,7 +17,7 @@ class Observer::User::TicketOrganization < ActiveRecord::Observer
return if !record.changes['organization_id']
# 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|
if ticket.organization_id != record.organization_id
ticket.organization_id = record.organization_id

View file

@ -1,8 +1,8 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class OnlineNotification < ApplicationModel
belongs_to :type_lookup, :class_name => 'TypeLookup'
belongs_to :object_lookup, :class_name => 'ObjectLookup'
belongs_to :type_lookup, class_name: 'TypeLookup'
belongs_to :object_lookup, class_name: 'ObjectLookup'
after_create :notify_clients_after_change
after_update :notify_clients_after_change
@ -34,12 +34,12 @@ add a new online notification for this user
end
record = {
:o_id => data[:o_id],
:object_lookup_id => object_id,
:type_lookup_id => type_id,
:seen => data[:seen],
:user_id => data[:user_id],
:created_by_id => data[:created_by_id]
o_id: data[:o_id],
object_lookup_id: object_id,
type_lookup_id: type_id,
seen: data[:seen],
user_id: data[:user_id],
created_by_id: data[:created_by_id]
}
OnlineNotification.create(record)
@ -72,8 +72,8 @@ remove whole online notifications of an object
def self.remove( object_name, o_id )
object_id = ObjectLookup.by_name( object_name )
OnlineNotification.where(
:object_lookup_id => object_id,
:o_id => o_id,
object_lookup_id: object_id,
o_id: o_id,
).destroy_all
end
@ -87,7 +87,7 @@ return all online notifications of an user
def self.list(user,limit)
notifications = OnlineNotification.where(:user_id => user.id).
notifications = OnlineNotification.where(user_id: user.id).
order( 'created_at DESC, id DESC' ).
limit( limit )
list = []
@ -113,8 +113,8 @@ return all online notifications of an object
def self.list_by_object( object_name, o_id)
object_id = ObjectLookup.by_name( object_name )
notifications = OnlineNotification.where(
:object_lookup_id => object_id,
:o_id => o_id,
object_lookup_id: object_id,
o_id: o_id,
).
order( 'created_at DESC, id DESC' ).
limit( 10_000 )
@ -141,9 +141,9 @@ mark online notification as seen by object
def self.seen_by_object(object_name, o_id)
object_id = ObjectLookup.by_name( object_name )
notifications = OnlineNotification.where(
:object_lookup_id => object_id,
:o_id => o_id,
:seen => false,
object_lookup_id: object_id,
o_id: o_id,
seen: false,
)
notifications.each do |notification|
notification.seen = true
@ -172,8 +172,8 @@ returns:
notifications = OnlineNotification.list(user, limit)
assets = ApplicationModel.assets_of_object_list(notifications)
return {
:stream => notifications,
:assets => assets
stream: notifications,
assets: assets
}
end
@ -181,8 +181,8 @@ returns:
Sessions.send_to(
self.user_id,
{
:event => 'OnlineNotification::changed',
:data => {}
event: 'OnlineNotification::changed',
data: {}
}
)
end

View file

@ -8,10 +8,10 @@ class Organization < ApplicationModel
include Organization::SearchIndex
has_and_belongs_to_many :users
has_many :members, :class_name => 'User'
validates :name, :presence => true
has_many :members, class_name: 'User'
validates :name, presence: true
activity_stream_support :role => Z_ROLENAME_ADMIN
activity_stream_support role: Z_ROLENAME_ADMIN
history_support
search_index_support
notify_clients_support

View file

@ -33,7 +33,7 @@ returns
if data[ Organization.to_app_model ][ self.id ]['member_ids']
data[ Organization.to_app_model ][ self.id ]['member_ids'].each {|user_id|
if !data[ User.to_app_model ][ user_id ]
user = User.lookup( :id => user_id )
user = User.lookup( id: user_id )
data = user.assets( data )
end
}
@ -42,7 +42,7 @@ returns
['created_by_id', 'updated_by_id'].each {|item|
if self[ item ]
if !data[ User.to_app_model ][ self[ item ] ]
user = User.lookup( :id => self[ item ] )
user = User.lookup( id: self[ item ] )
data = user.assets( data )
end
end

View file

@ -33,7 +33,7 @@ returns
items = SearchIndexBackend.search( query, limit, 'Organization' )
organizations = []
items.each { |item|
organizations.push Organization.lookup( :id => item[:id] )
organizations.push Organization.lookup( id: item[:id] )
}
return organizations
end

View file

@ -32,7 +32,7 @@ returns
next if !relation_class
# lookup ref object
relation_model = relation_class.lookup( :id => value )
relation_model = relation_class.lookup( id: value )
next if !relation_model
# get name of ref object
@ -49,7 +49,7 @@ returns
# add org member for search index data
attributes['member'] = []
users = User.where( :organization_id => self.id )
users = User.where( organization_id: self.id )
users.each { |user|
attributes['member'].push user.search_index_data
}

View file

@ -4,7 +4,7 @@ class Overview < ApplicationModel
store :condition
store :order
store :view
validates :name, :presence => true
validates :prio, :presence => true
validates :link, :presence => true
validates :name, presence: true
validates :prio, presence: true
validates :link, presence: true
end

View file

@ -55,7 +55,7 @@ class Package < ApplicationModel
end
end
data.each {|file|
self.install( :file => path + '/' + file )
self.install( file: path + '/' + file )
}
data
end
@ -186,16 +186,16 @@ class Package < ApplicationModel
# package meta data
meta = {
:name => package.elements['zpm/name'].text,
:version => package.elements['zpm/version'].text,
:vendor => package.elements['zpm/vendor'].text,
:state => 'uninstalled',
:created_by_id => 1,
:updated_by_id => 1,
name: package.elements['zpm/name'].text,
version: package.elements['zpm/version'].text,
vendor: package.elements['zpm/vendor'].text,
state: 'uninstalled',
created_by_id: 1,
updated_by_id: 1,
}
# verify if package can get installed
package_db = Package.where( :name => meta[:name] ).first
package_db = Package.where( name: meta[:name] ).first
if package_db
if !data[:reinstall]
if Gem::Version.new( package_db.version ) == Gem::Version.new( meta[:version] )
@ -208,9 +208,9 @@ class Package < ApplicationModel
# uninstall files of old package
self.uninstall({
:name => package_db.name,
:version => package_db.version,
:migration_not_down => true,
name: package_db.name,
version: package_db.version,
migration_not_down: true,
})
end
@ -218,12 +218,12 @@ class Package < ApplicationModel
record = Package.create( meta )
if !data[:reinstall]
Store.add(
:object => 'Package',
:o_id => record.id,
:data => package.to_s,
:filename => meta[:name] + '-' + meta[:version] + '.zpm',
:preferences => {},
:created_by_id => UserInfo.current_user_id || 1,
object: 'Package',
o_id: record.id,
data: package.to_s,
filename: meta[:name] + '-' + meta[:version] + '.zpm',
preferences: {},
created_by_id: UserInfo.current_user_id || 1,
)
end
@ -253,13 +253,13 @@ class Package < ApplicationModel
# Package.reinstall( package_name )
def self.reinstall(package_name)
package = Package.where( :name => package_name ).first
package = Package.where( name: package_name ).first
if !package
raise "No such package '#{package_name}'"
end
file = self._get_bin( package.name, package.version )
self.install( :string => file, :reinstall => true )
self.install( string: file, reinstall: true )
end
# Package.uninstall( :name => 'package', :version => '0.1.1' )
@ -275,8 +275,8 @@ class Package < ApplicationModel
# package meta data
meta = {
:name => package.elements['zpm/name'].text,
:version => package.elements['zpm/version'].text,
name: package.elements['zpm/name'].text,
version: package.elements['zpm/version'].text,
}
# down migrations
@ -301,8 +301,8 @@ class Package < ApplicationModel
# delete package
record = Package.where(
:name => meta[:name],
:version => meta[:version],
name: meta[:name],
version: meta[:version],
).first
record.destroy
@ -340,15 +340,15 @@ class Package < ApplicationModel
def self._get_bin( name, version )
package = Package.where(
:name => name,
:version => version,
name: name,
version: version,
).first
if !package
raise "No such package '#{name}' version '#{version}'"
end
list = Store.list(
:object => 'Package',
:o_id => package.id,
object: 'Package',
o_id: package.id,
)
# find file
@ -442,7 +442,7 @@ class Package < ApplicationModel
location = @@root + '/db/addon/' + package.underscore
return true if !File.exists?( location )
migrations_done = Package::Migration.where( :name => package.underscore )
migrations_done = Package::Migration.where( name: package.underscore )
# get existing migrations
migrations_existing = []
@ -474,26 +474,26 @@ class Package < ApplicationModel
# down
if direction == 'reverse'
done = Package::Migration.where( :name => package.underscore, :version => version ).first
done = Package::Migration.where( name: package.underscore, version: version ).first
next if !done
logger.info "NOTICE: down package migration '#{migration}'"
load "#{location}/#{migration}"
classname = name.camelcase
Kernel.const_get(classname).down
record = Package::Migration.where( :name => package.underscore, :version => version ).first
record = Package::Migration.where( name: package.underscore, version: version ).first
if record
record.destroy
end
# up
else
done = Package::Migration.where( :name => package.underscore, :version => version ).first
done = Package::Migration.where( name: package.underscore, version: version ).first
next if done
logger.info "NOTICE: up package migration '#{migration}'"
load "#{location}/#{migration}"
classname = name.camelcase
Kernel.const_get(classname).up
Package::Migration.create( :name => package.underscore, :version => version )
Package::Migration.create( name: package.underscore, version: version )
end
# reload new files

View file

@ -3,5 +3,5 @@
class PostmasterFilter < ApplicationModel
store :perform
store :match
validates :name, :presence => true
validates :name, presence: true
end

View file

@ -1,7 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class RecentView < ApplicationModel
belongs_to :object_lookup, :class_name => 'ObjectLookup'
belongs_to :object_lookup, class_name: 'ObjectLookup'
after_create :notify_clients
after_update :notify_clients
@ -17,31 +17,31 @@ class RecentView < ApplicationModel
# create entry
record = {
:o_id => o_id,
:recent_view_object_id => object_lookup_id.to_i,
:created_by_id => user.id,
o_id: o_id,
recent_view_object_id: object_lookup_id.to_i,
created_by_id: user.id,
}
RecentView.create(record)
end
def self.log_destroy( requested_object, requested_object_id )
return if requested_object == 'RecentView'
RecentView.where( :recent_view_object_id => ObjectLookup.by_name( requested_object ) ).
where( :o_id => requested_object_id ).
RecentView.where( recent_view_object_id: ObjectLookup.by_name( requested_object ) ).
where( o_id: requested_object_id ).
destroy_all
end
def self.user_log_destroy( user )
RecentView.where( :created_by_id => user.id ).destroy_all
RecentView.where( created_by_id: user.id ).destroy_all
end
def self.list( user, limit = 10, type = nil )
if !type
recent_views = RecentView.where( :created_by_id => user.id ).
recent_views = RecentView.where( created_by_id: user.id ).
order('created_at DESC, id DESC').
limit(limit)
else
recent_views = RecentView.select('DISTINCT(o_id), recent_view_object_id').where( :created_by_id => user.id, :recent_view_object_id => ObjectLookup.by_name(type) ) .
recent_views = RecentView.select('DISTINCT(o_id), recent_view_object_id').where( created_by_id: user.id, recent_view_object_id: ObjectLookup.by_name(type) ) .
order('created_at DESC, id DESC').
limit(limit)
end
@ -68,8 +68,8 @@ class RecentView < ApplicationModel
assets = ApplicationModel.assets_of_object_list(recent_viewed)
return {
:stream => recent_viewed,
:assets => assets,
stream: recent_viewed,
assets: assets,
}
end
@ -77,8 +77,8 @@ class RecentView < ApplicationModel
Sessions.send_to(
self.created_by_id,
{
:event => 'RecentView::changed',
:data => {}
event: 'RecentView::changed',
data: {}
}
)
end
@ -90,7 +90,7 @@ class RecentView < ApplicationModel
# check if object exists
begin
return if !Kernel.const_get( object )
record = Kernel.const_get( object ).lookup( :id => o_id )
record = Kernel.const_get( object ).lookup( id: o_id )
return if !record
rescue
return
@ -98,6 +98,6 @@ class RecentView < ApplicationModel
# check permission
return if !record.respond_to?(:permission)
record.permission( :current_user => user )
record.permission( current_user: user )
end
end

View file

@ -2,8 +2,8 @@
class Role < ApplicationModel
has_and_belongs_to_many :users, :after_add => :cache_update, :after_remove => :cache_update
validates :name, :presence => true
activity_stream_support :role => Z_ROLENAME_ADMIN
has_and_belongs_to_many :users, after_add: :cache_update, after_remove: :cache_update
validates :name, presence: true
activity_stream_support role: Z_ROLENAME_ADMIN
latest_change_support
end

View file

@ -36,7 +36,7 @@ class Scheduler < ApplicationModel
if job.period
while true
self._start_job( job, runner, runner_count )
job = Scheduler.lookup( :id => job.id )
job = Scheduler.lookup( id: job.id )
# exit is job got deleted
break if !job
@ -124,7 +124,7 @@ class Scheduler < ApplicationModel
def self.check( name, time_warning = 10, time_critical = 20 )
time_warning_time = Time.now - time_warning.minutes
time_critical_time = Time.now - time_critical.minutes
scheduler = Scheduler.where( :name => name ).first
scheduler = Scheduler.where( name: name ).first
if !scheduler
puts "CRITICAL - no such scheduler jobs '#{name}'"
return true

View file

@ -36,11 +36,11 @@ class Setting < ApplicationModel
end
def self.set(name, value)
setting = Setting.where( :name => name ).first
setting = Setting.where( name: name ).first
if !setting
raise "Can't find config setting '#{name}'"
end
setting.state = { :value => value }
setting.state = { value: value }
setting.save
logger.info "Setting.set() name:#{name}, value:#{value.inspect}"
end
@ -60,7 +60,7 @@ class Setting < ApplicationModel
def state_check
if self.state || self.state == false
if !self.state.respond_to?('has_key?') || !self.state.has_key?(:value)
self.state = { :value => self.state }
self.state = { value: self.state }
end
end
end

View file

@ -1,7 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Signature < ApplicationModel
has_many :groups, :after_add => :cache_update, :after_remove => :cache_update
validates :name, :presence => true
has_many :groups, after_add: :cache_update, after_remove: :cache_update
validates :name, presence: true
latest_change_support
end

View file

@ -3,7 +3,7 @@
class Sla < ApplicationModel
store :condition
store :data
validates :name, :presence => true
validates :name, presence: true
after_create :escalation_calculation_rebuild
after_update :escalation_calculation_rebuild

View file

@ -5,9 +5,9 @@ class Store < ApplicationModel
load 'store/file.rb'
store :preferences
belongs_to :store_object, :class_name => 'Store::Object'
belongs_to :store_file, :class_name => 'Store::File'
validates :filename, :presence => true
belongs_to :store_object, class_name: 'Store::Object'
belongs_to :store_file, class_name: 'Store::File'
validates :filename, presence: true
=begin
@ -33,7 +33,7 @@ returns
data = data.stringify_keys
# lookup store_object.id
store_object = Store::Object.create_if_not_exists( :name => data['object'] )
store_object = Store::Object.create_if_not_exists( name: data['object'] )
data['store_object_id'] = store_object.id
# add to real store
@ -79,8 +79,8 @@ returns
def self.list(data)
# search
store_object_id = Store::Object.lookup( :name => data[:object] )
stores = Store.where( :store_object_id => store_object_id, :o_id => data[:o_id].to_i ).
store_object_id = Store::Object.lookup( name: data[:object] )
stores = Store.where( store_object_id: store_object_id, o_id: data[:o_id].to_i ).
order('created_at ASC, id ASC')
return stores
end
@ -102,9 +102,9 @@ returns
def self.remove(data)
# search
store_object_id = Store::Object.lookup( :name => data[:object] )
stores = Store.where( :store_object_id => store_object_id ).
where( :o_id => data[:o_id] ).
store_object_id = Store::Object.lookup( name: data[:object] )
stores = Store.where( store_object_id: store_object_id ).
where( o_id: data[:o_id] ).
order('created_at ASC, id ASC')
stores.each do |store|
@ -130,7 +130,7 @@ returns
# check backend for references
store = Store.find(store_id)
files = Store.where( :store_file_id => store.store_file_id )
files = Store.where( store_file_id: store.store_file_id )
if files.count == 1 && files.first.id == store.id
Store::File.find( store.store_file_id ).destroy
end
@ -140,7 +140,7 @@ returns
end
def content
file = Store::File.where( :id => self.store_file_id ).first
file = Store::File.where( id: self.store_file_id ).first
if !file
raise "No such file #{ self.store_file_id }!"
end
@ -148,7 +148,7 @@ returns
end
def provider
file = Store::File.where( :id => self.store_file_id ).first
file = Store::File.where( id: self.store_file_id ).first
if !file
raise "No such file #{ self.store_file_id }!"
end

View file

@ -8,7 +8,7 @@ class Store::File < ApplicationModel
def self.add(data)
sha = Digest::SHA256.hexdigest( data )
file = Store::File.where( :sha => sha ).first
file = Store::File.where( sha: sha ).first
if file == nil
# load backend based on config
@ -19,8 +19,8 @@ class Store::File < ApplicationModel
adapter = self.load_adapter( "Store::Provider::#{ adapter_name }" )
adapter.add( data, sha )
file = Store::File.create(
:provider => adapter_name,
:sha => sha,
provider: adapter_name,
sha: sha,
)
end
file
@ -33,7 +33,7 @@ class Store::File < ApplicationModel
c = adapter.get( self.sha )
else
# fallback until migration is done
c = Store::Provider::DB.where( :md5 => self.md5 ).first.data
c = Store::Provider::DB.where( md5: self.md5 ).first.data
end
c
end

View file

@ -1,5 +1,5 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Store::Object < ApplicationModel
validates :name, :presence => true
validates :name, presence: true
end

View file

@ -5,20 +5,20 @@ class Store::Provider::DB < ApplicationModel
def self.add(data, sha)
Store::Provider::DB.create(
:data => data,
:sha => sha,
data: data,
sha: sha,
)
true
end
def self.get(sha)
file = Store::Provider::DB.where( :sha => sha ).first
file = Store::Provider::DB.where( sha: sha ).first
return if !file
file.data
end
def self.delete(sha)
Store::Provider::DB.where( :sha => sha ).destroy_all
Store::Provider::DB.where( sha: sha ).destroy_all
true
end

View file

@ -1,8 +1,8 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Tag < ApplicationModel
belongs_to :tag_object, :class_name => 'Tag::Object'
belongs_to :tag_item, :class_name => 'Tag::Item'
belongs_to :tag_object, class_name: 'Tag::Object'
belongs_to :tag_item, class_name: 'Tag::Item'
@@cache_item = {}
@@cache_object = {}
@ -19,10 +19,10 @@ class Tag < ApplicationModel
# create history
Tag.create(
:tag_object_id => tag_object_id,
:tag_item_id => tag_item_id,
:o_id => data[:o_id],
:created_by_id => data[:created_by_id],
tag_object_id: tag_object_id,
tag_item_id: tag_item_id,
o_id: data[:o_id],
created_by_id: data[:created_by_id],
)
return true
end
@ -39,9 +39,9 @@ class Tag < ApplicationModel
# create history
result = Tag.where(
:tag_object_id => tag_object_id,
:tag_item_id => tag_item_id,
:o_id => data[:o_id],
tag_object_id: tag_object_id,
tag_item_id: tag_item_id,
o_id: data[:o_id],
)
result.each { |item|
item.destroy
@ -52,8 +52,8 @@ class Tag < ApplicationModel
def self.tag_list( data )
tag_object_id_requested = self.tag_object_lookup( data[:object] )
tag_search = Tag.where(
:tag_object_id => tag_object_id_requested,
:o_id => data[:o_id],
tag_object_id: tag_object_id_requested,
o_id: data[:o_id],
)
tags = []
tag_search.each {|tag|
@ -83,7 +83,7 @@ class Tag < ApplicationModel
return @@cache_item[ name ] if @@cache_item[ name ]
# lookup
tag_item = Tag::Item.where( :name => name ).first
tag_item = Tag::Item.where( name: name ).first
if tag_item
@@cache_item[ name ] = tag_item.id
return tag_item.id
@ -91,7 +91,7 @@ class Tag < ApplicationModel
# create
tag_item = Tag::Item.create(
:name => name
name: name
)
@@cache_item[ name ] = tag_item.id
return tag_item.id
@ -114,7 +114,7 @@ class Tag < ApplicationModel
return @@cache_object[ name ] if @@cache_object[ name ]
# lookup
tag_object = Tag::Object.where( :name => name ).first
tag_object = Tag::Object.where( name: name ).first
if tag_object
@@cache_object[ name ] = tag_object.id
return tag_object.id
@ -122,7 +122,7 @@ class Tag < ApplicationModel
# create
tag_object = Tag::Object.create(
:name => name
name: name
)
@@cache_object[ name ] = tag_object.id
return tag_object.id

View file

@ -2,6 +2,6 @@
class Template < ApplicationModel
store :options
validates :name, :presence => true
validates :name, presence: true
notify_clients_support
end

View file

@ -1,7 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class TextModule < ApplicationModel
validates :name, :presence => true
validates :content, :presence => true
validates :name, presence: true
validates :content, presence: true
notify_clients_support
end

View file

@ -22,41 +22,41 @@ class Ticket < ApplicationModel
latest_change_support
activity_stream_support :ignore_attributes => {
:create_article_type_id => true,
:create_article_sender_id => true,
:article_count => true,
activity_stream_support ignore_attributes: {
create_article_type_id: true,
create_article_sender_id: true,
article_count: true,
}
history_support :ignore_attributes => {
:create_article_type_id => true,
:create_article_sender_id => true,
:article_count => true,
history_support ignore_attributes: {
create_article_type_id: true,
create_article_sender_id: true,
article_count: true,
}
search_index_support(
:ignore_attributes => {
:create_article_type_id => true,
:create_article_sender_id => true,
:article_count => true,
ignore_attributes: {
create_article_type_id: true,
create_article_sender_id: true,
article_count: true,
},
:keep_attributes => {
:customer_id => true,
:organization_id => true,
keep_attributes: {
customer_id: true,
organization_id: true,
},
)
belongs_to :group
has_many :articles, :class_name => 'Ticket::Article', :after_add => :cache_update, :after_remove => :cache_update
has_many :articles, class_name: 'Ticket::Article', after_add: :cache_update, after_remove: :cache_update
belongs_to :organization
belongs_to :state, :class_name => 'Ticket::State'
belongs_to :priority, :class_name => 'Ticket::Priority'
belongs_to :owner, :class_name => 'User'
belongs_to :customer, :class_name => 'User'
belongs_to :created_by, :class_name => 'User'
belongs_to :updated_by, :class_name => 'User'
belongs_to :create_article_type, :class_name => 'Ticket::Article::Type'
belongs_to :create_article_sender, :class_name => 'Ticket::Article::Sender'
belongs_to :state, class_name: 'Ticket::State'
belongs_to :priority, class_name: 'Ticket::Priority'
belongs_to :owner, class_name: 'User'
belongs_to :customer, class_name: 'User'
belongs_to :created_by, class_name: 'User'
belongs_to :updated_by, class_name: 'User'
belongs_to :create_article_type, class_name: 'Ticket::Article::Type'
belongs_to :create_article_sender, class_name: 'Ticket::Article::Sender'
self.inheritance_column = nil
@ -76,7 +76,7 @@ returns
=end
def agent_of_group
Group.find( self.group_id ).users.where( :active => true ).joins(:roles).where( 'roles.name' => Z_ROLENAME_AGENT, 'roles.active' => true ).uniq()
Group.find( self.group_id ).users.where( active: true ).joins(:roles).where( 'roles.name' => Z_ROLENAME_AGENT, 'roles.active' => true ).uniq()
end
=begin
@ -128,12 +128,12 @@ returns
def merge_to(data)
# update articles
Ticket::Article.where( :ticket_id => self.id ).each {|article|
Ticket::Article.where( ticket_id: self.id ).each {|article|
article.touch
}
# quiet update of reassign of articles
Ticket::Article.where( :ticket_id => self.id ).update_all( ['ticket_id = ?', data[:ticket_id] ] )
Ticket::Article.where( ticket_id: self.id ).update_all( ['ticket_id = ?', data[:ticket_id] ] )
# touch new ticket (to broadcast change)
Ticket.find( data[:ticket_id] ).touch
@ -142,31 +142,31 @@ returns
# create new merge article
Ticket::Article.create(
:ticket_id => self.id,
:type_id => Ticket::Article::Type.lookup( :name => 'note' ).id,
:sender_id => Ticket::Article::Sender.lookup( :name => Z_ROLENAME_AGENT ).id,
:body => 'merged',
:internal => false,
:created_by_id => data[:user_id],
:updated_by_id => data[:user_id],
ticket_id: self.id,
type_id: Ticket::Article::Type.lookup( name: 'note' ).id,
sender_id: Ticket::Article::Sender.lookup( name: Z_ROLENAME_AGENT ).id,
body: 'merged',
internal: false,
created_by_id: data[:user_id],
updated_by_id: data[:user_id],
)
# add history to both
# link tickets
Link.add(
:link_type => 'parent',
:link_object_source => 'Ticket',
:link_object_source_value => data[:ticket_id],
:link_object_target => 'Ticket',
:link_object_target_value => self.id
link_type: 'parent',
link_object_source: 'Ticket',
link_object_source_value: data[:ticket_id],
link_object_target: 'Ticket',
link_object_target_value: self.id
)
# set state to 'merged'
self.state_id = Ticket::State.lookup( :name => 'merged' ).id
self.state_id = Ticket::State.lookup( name: 'merged' ).id
# rest owner
self.owner_id = User.where( :login => '-' ).first.id
self.owner_id = User.where( login: '-' ).first.id
# save ticket
self.save
@ -186,8 +186,8 @@ returns
=end
def online_notification_seen_state
state = Ticket::State.lookup( :id => self.state_id )
state_type = Ticket::StateType.lookup( :id => state.state_type_id )
state = Ticket::State.lookup( id: self.state_id )
state_type = Ticket::StateType.lookup( id: state.state_type_id )
return true if state_type.name == 'closed'
return true if state_type.name == 'merged'
false
@ -224,8 +224,8 @@ returns
return if !self.changes['state_id']
# check if new state isn't pending*
current_state = Ticket::State.lookup( :id => self.state_id )
current_state_type = Ticket::StateType.lookup( :id => current_state.state_type_id )
current_state = Ticket::State.lookup( id: self.state_id )
current_state_type = Ticket::StateType.lookup( id: current_state.state_type_id )
# in case, set pending_time to nil
if current_state_type.name !~ /^pending/i

View file

@ -26,13 +26,13 @@ returns
return if !self.class.activity_stream_support_config
role = self.class.activity_stream_support_config[:role]
ActivityStream.add(
:o_id => self['id'],
:type => type,
:object => self.class.name,
:group_id => self['group_id'],
:role => role,
:created_at => self.updated_at,
:created_by_id => user_id,
o_id: self['id'],
type: type,
object: self.class.name,
group_id: self['group_id'],
role: role,
created_at: self.updated_at,
created_by_id: user_id,
)
end

View file

@ -9,22 +9,22 @@ class Ticket::Article < ApplicationModel
include Ticket::Article::ActivityStreamLog
belongs_to :ticket
belongs_to :type, :class_name => 'Ticket::Article::Type'
belongs_to :sender, :class_name => 'Ticket::Article::Sender'
belongs_to :created_by, :class_name => 'User'
belongs_to :updated_by, :class_name => 'User'
belongs_to :type, class_name: 'Ticket::Article::Type'
belongs_to :sender, class_name: 'Ticket::Article::Sender'
belongs_to :created_by, class_name: 'User'
belongs_to :updated_by, class_name: 'User'
before_create :check_subject
before_update :check_subject
notify_clients_support
activity_stream_support :ignore_attributes => {
:type_id => true,
:sender_id => true,
activity_stream_support ignore_attributes: {
type_id: true,
sender_id: true,
}
history_support :ignore_attributes => {
:type_id => true,
:sender_id => true,
history_support ignore_attributes: {
type_id: true,
sender_id: true,
}
private
@ -39,12 +39,12 @@ class Ticket::Article < ApplicationModel
end
class Sender < ApplicationModel
validates :name, :presence => true
validates :name, presence: true
latest_change_support
end
class Type < ApplicationModel
validates :name, :presence => true
validates :name, presence: true
latest_change_support
end
end

View file

@ -25,15 +25,15 @@ returns
return if !self.class.activity_stream_support_config
role = self.class.activity_stream_support_config[:role]
ticket = Ticket.lookup( :id => self.ticket_id )
ticket = Ticket.lookup( id: self.ticket_id )
ActivityStream.add(
:o_id => self['id'],
:type => type,
:object => self.class.name,
:group_id => ticket.group_id,
:role => role,
:created_at => self.updated_at,
:created_by_id => user_id,
o_id: self['id'],
type: type,
object: self.class.name,
group_id: ticket.group_id,
role: role,
created_at: self.updated_at,
created_by_id: user_id,
)
end

View file

@ -44,7 +44,7 @@ returns
['created_by_id', 'updated_by_id'].each {|item|
if self[ item ]
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
user = User.lookup( :id => self[ item ] )
user = User.lookup( id: self[ item ] )
data = user.assets( data )
end
end

View file

@ -32,7 +32,7 @@ returns
['created_by_id', 'updated_by_id', 'owner_id', 'customer_id'].each {|item|
if self[ item ]
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
user = User.lookup( :id => self[ item ] )
user = User.lookup( id: self[ item ] )
data = user.assets( data )
end
end

View file

@ -17,7 +17,7 @@ returns
def self.rebuild_all
state_list_open = Ticket::State.by_category( 'open' )
tickets = Ticket.where( :state_id => state_list_open )
tickets = Ticket.where( state_id: state_list_open )
tickets.each {|ticket|
ticket.escalation_calculation
}
@ -39,7 +39,7 @@ returns
def escalation_calculation
# set escalation off if ticket is already closed
state = Ticket::State.lookup( :id => self.state_id )
state = Ticket::State.lookup( id: self.state_id )
if state.ignore_escalation?
# nothing to change
@ -177,8 +177,8 @@ returns
sla_selected = nil
sla_list = Cache.get( 'SLA::List::Active' )
if sla_list == nil
sla_list = Sla.where( :active => true )
Cache.write( 'SLA::List::Active', sla_list, { :expires_in => 1.hour } )
sla_list = Sla.where( active: true )
Cache.write( 'SLA::List::Active', sla_list, { expires_in: 1.hour } )
end
sla_list.each {|sla|
if !sla.condition || sla.condition.empty?

View file

@ -73,8 +73,8 @@ returns
end
}
return {
:history => list,
:assets => assets,
history: list,
assets: assets,
}
end

View file

@ -20,7 +20,7 @@ returns
# generate number
(1..50_000).each { |i|
number = adapter.generate
ticket = Ticket.where( :number => number ).first
ticket = Ticket.where( number: number ).first
return number if !ticket
}
raise "Can't generate new ticket number!"

View file

@ -14,9 +14,9 @@ module Ticket::Number::Date
# read counter
counter_increment = nil
Ticket::Counter.transaction do
counter = Ticket::Counter.where( :generator => 'Date' ).lock(true).first
counter = Ticket::Counter.where( generator: 'Date' ).lock(true).first
if !counter
counter = Ticket::Counter.new( :generator => 'Date', :content => '0' )
counter = Ticket::Counter.new( generator: 'Date', content: '0' )
end
# increase counter
@ -74,9 +74,9 @@ module Ticket::Number::Date
# probe format
if string =~ /#{ticket_hook}#{ticket_hook_divider}(#{system_id}\d{2,50})/i then
ticket = Ticket.where( :number => $1 ).first
ticket = Ticket.where( number: $1 ).first
elsif string =~ /#{ticket_hook}\s{0,2}(#{system_id}\d{2,50})/i then
ticket = Ticket.where( :number => $1 ).first
ticket = Ticket.where( number: $1 ).first
end
return ticket
end

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