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

This commit is contained in:
Martin Edenhofer 2015-05-01 15:08:56 +02:00
commit d071d595ae
32 changed files with 104 additions and 92 deletions

View file

@ -76,7 +76,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# validate url
messages = {}
if !Setting.get('system_online_service')
if !params[:url] || params[:url] !~ /^(http|https):\/\/.+?$/
if !params[:url] || params[:url] !~ %r{^(http|https)://.+?$}
messages[:url] = 'A URL looks like http://zammad.example.com'
end
end
@ -107,7 +107,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# split url in http_type and fqdn
settings = {}
if !Setting.get('system_online_service')
if params[:url] =~ /^(http|https):\/\/(.+?)$/
if params[:url] =~ %r{/^(http|https)://(.+?)$}
Setting.set('http_type', $1)
settings[:http_type] = $1
Setting.set('fqdn', $2)

View file

@ -6,7 +6,7 @@ class ImportOtrsController < ApplicationController
return if setup_done_response
# validate
if !params[:url] || params[:url] !~ /^(http|https):\/\/.+?$/
if !params[:url] || params[:url] !~ %r{^(http|https)://.+?$}
render json: {
result: 'invalid',
message: 'Invalid!',
@ -44,7 +44,7 @@ class ImportOtrsController < ApplicationController
suffixes.each {|suffix|
url = params[:url] + suffix + '?Action=ZammadMigrator'
# strip multible / in url
url.gsub!(/([^:])(\/+\/)/, '\\1/')
url.gsub!(%r{([^:])(/+/)}, '\\1/')
response = UserAgent.request( url )
#Setting.set('import_mode', true)

View file

@ -55,14 +55,14 @@ class SessionsController < ApplicationController
end
# return new session data
render json: {
render status: :created,
json: {
session: user,
models: models,
collections: collections,
assets: assets,
logon_session: logon_session_key,
},
status: :created
}
end
def show

View file

@ -606,8 +606,8 @@ class OwnModel < ApplicationModel
class_name = self.class.name
class_name.gsub!(/::/, '')
Sessions.broadcast(
:event => class_name + ':touch',
:data => { :id => self.id, :updated_at => self.updated_at }
event: class_name + ':touch',
data: { id: self.id, updated_at: self.updated_at }
)
end

View file

@ -110,7 +110,7 @@ add a avatar
# twitter workaround to get bigger avatar images
# see also https://dev.twitter.com/overview/general/user-profile-images-and-banners
if data[:url] =~ /\/\/pbs.twimg.com\//i
if data[:url] =~ %r{//pbs.twimg.com/}i
data[:url].sub!(/normal\.png$/, 'bigger.png')
end

View file

@ -152,6 +152,7 @@ class Link < ApplicationModel
end
private
def self.link_type_get(data)
linktype = Link::Type.where( name: data[:name] ).first
if !linktype

View file

@ -12,6 +12,7 @@ class Observer::Ticket::CloseTime < ActiveRecord::Observer
end
private
def _check(record)
# puts 'check close time'

View file

@ -20,6 +20,8 @@ class Observer::Ticket::LastContact < ActiveRecord::Observer
if record.ticket.last_contact_customer == nil ||
record.ticket.last_contact_agent == nil ||
record.ticket.last_contact_agent.to_i > record.ticket.last_contact_customer.to_i
# set last_contact customer
record.ticket.last_contact_customer = record.created_at
# set last_contact

View file

@ -70,7 +70,7 @@ class Observer::Ticket::Notification::BackgroundJob
object: 'Ticket',
o_id: ticket.id,
seen: seen,
created_by_id: ticket.updated_by_id ||  1,
created_by_id: ticket.updated_by_id || 1,
user_id: user.id,
)
@ -135,7 +135,7 @@ class Observer::Ticket::Notification::BackgroundJob
history_type: 'notification',
history_object: 'Ticket',
value_to: recipient_list,
created_by_id: ticket.updated_by_id ||  1
created_by_id: ticket.updated_by_id || 1
)
end

View file

@ -12,6 +12,7 @@ class Observer::Ticket::OnlineNotificationSeen < ActiveRecord::Observer
end
private
def _check(record)
# return if we run import mode

View file

@ -118,6 +118,7 @@ return all online notifications of an object
)
.order( 'created_at DESC, id DESC' )
.limit( 10_000 )
list = []
notifications.each do |item|
data = item.attributes

View file

@ -82,7 +82,7 @@ class Package < ApplicationModel
def self._package_base_dir?(package_base_dir)
package = false
Dir.glob( package_base_dir + '/*.szpm') do |entry|
package = entry.sub( /^.*\/(.+?)\.szpm$/, '\1')
package = entry.sub( %r{^.*/(.+?)\.szpm$}, '\1')
end
if package == false
raise "Can't link package, '#{package_base_dir}' is no package source directory!"
@ -133,7 +133,7 @@ class Package < ApplicationModel
entry = entry.sub( '//', '/' )
file = entry
file = file.sub( /#{package_base_dir.to_s}/, '' )
file = file.sub( /^\//, '' )
file = file.sub( %r{^/}, '' )
# ignore files
if file =~ /^README/

View file

@ -51,6 +51,7 @@ class Setting < ApplicationModel
end
private
def delete_cache
@@current[:settings_config] = nil
end

View file

@ -10,6 +10,7 @@ class Sla < ApplicationModel
after_destroy :escalation_calculation_rebuild
private
def escalation_calculation_rebuild
Cache.delete( 'SLA::List::Active' )
Ticket::Escalation.rebuild_all

View file

@ -7,6 +7,7 @@ class Taskbar < ApplicationModel
before_update :update_last_contact, :set_user
private
def update_last_contact
self.last_contact = Time.now
end

View file

@ -173,9 +173,9 @@ returns
data[:start_page] ||= 1
tickets = Ticket.where( group_id: group_ids )
.where( _condition( overview_selected.condition ) )
.order( overview_selected[:order][:by].to_s + ' ' + overview_selected[:order][:direction].to_s )#.
# limit( overview_selected.view[ data[:view_mode].to_sym ][:per_page] ).
# offset( overview_selected.view[ data[:view_mode].to_sym ][:per_page].to_i * ( data[:start_page].to_i - 1 ) )
.order( overview_selected[:order][:by].to_s + ' ' + overview_selected[:order][:direction].to_s )
# .limit( overview_selected.view[ data[:view_mode].to_sym ][:per_page] )
# .offset( overview_selected.view[ data[:view_mode].to_sym ][:per_page].to_i * ( data[:start_page].to_i - 1 ) )
tickets_count = Ticket.where( group_id: group_ids )
.where( _condition( overview_selected.condition ) )

View file

@ -26,6 +26,7 @@ class Token < ActiveRecord::Base
end
private
def generate_token
begin
self.name = SecureRandom.hex(20)

View file

@ -167,6 +167,7 @@ translate strings in ruby context, e. g. for notifications
end
private
def set_initial
return if target_initial

View file

@ -83,10 +83,10 @@ class String
string.gsub!( /^\s*/m, '' )
# pre/code handling 1/2
string.gsub!( /<pre>(.+?)<\/pre>/m ) { |placeholder|
string.gsub!( %r{<pre>(.+?)</pre>}m ) { |placeholder|
placeholder = placeholder.gsub(/\n/, '###BR###')
}
string.gsub!( /<code>(.+?)<\/code>/m ) { |placeholder|
string.gsub!( %r{<code>(.+?)</code>/}m ) { |placeholder|
placeholder = placeholder.gsub(/\n/, '###BR###')
}
@ -103,12 +103,12 @@ class String
string.gsub!(/<blockquote(| [^>]*)>/i, '> ')
# add hr
string.gsub!(/<hr(|\/| [^>]*)>/i, "___\n")
string.gsub!(%r{<hr(|/| [^>]*)>}i, "___\n")
# add new lines
string.gsub!( /\<(br|table)(|\/| [^>]*)\>/i, "\n" )
string.gsub!( /\<\/(div|p|pre|blockquote|table|tr)(|\s.+?)\>/i, "\n" )
string.gsub!( /\<\/td\>/i, ' ' )
string.gsub!( %r{\<(br|table)(|/| [^>]*)\>}i, "\n" )
string.gsub!( %r{\</(div|p|pre|blockquote|table|tr)(|\s.+?)\>}i, "\n" )
string.gsub!( %r{/</td\>}i, ' ' )
# strip all other tags
string.gsub!( /\<.+?\>/, '' )

View file

@ -1004,7 +1004,7 @@ module Import::OTRS2
if group_lookup['Name'] == 'admin' && permissions && permissions.include?('rw')
roles.push 'Admin'
end
if group_lookup['Name'] =~ /^(stats|report)/ && permissions && ( permissions.include?('ro') ||  permissions.include?('rw') )
if group_lookup['Name'] =~ /^(stats|report)/ && permissions && ( permissions.include?('ro') || permissions.include?('rw') )
roles.push 'Report'
end
end

View file

@ -241,6 +241,7 @@ returns
end
private
def self.get_http(uri, options)
http = Net::HTTP.new(uri.host, uri.port)