\ No newline at end of file
diff --git a/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco
index fb9bf07cf..959a0f72c 100644
--- a/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco
+++ b/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco
@@ -1,11 +1,51 @@
<% for article in @articles: %>
+
+
-<% end %>
\ No newline at end of file
+<% end %>
diff --git a/app/assets/javascripts/app/views/ticket_zoom/edit.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/edit.jst.eco
index 085637035..ad74a8cc8 100644
--- a/app/assets/javascripts/app/views/ticket_zoom/edit.jst.eco
+++ b/app/assets/javascripts/app/views/ticket_zoom/edit.jst.eco
@@ -1,8 +1,31 @@
+
+
\ No newline at end of file
diff --git a/app/assets/javascripts/app/views/user_zoom.jst.eco b/app/assets/javascripts/app/views/user_zoom.jst.eco
index 9230fe898..5b011cb50 100644
--- a/app/assets/javascripts/app/views/user_zoom.jst.eco
+++ b/app/assets/javascripts/app/views/user_zoom.jst.eco
@@ -5,7 +5,7 @@
-
<%= @user.displayName() %>
+
\ No newline at end of file
diff --git a/app/assets/javascripts/app/views/user_zoom/widgets.jst.eco b/app/assets/javascripts/app/views/user_zoom/widgets.jst.eco
deleted file mode 100644
index b247ef4af..000000000
--- a/app/assets/javascripts/app/views/user_zoom/widgets.jst.eco
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/app/assets/javascripts/app/views/widget/organization.jst.eco b/app/assets/javascripts/app/views/widget/organization.jst.eco
index e77973dbf..ff5937b8d 100644
--- a/app/assets/javascripts/app/views/widget/organization.jst.eco
+++ b/app/assets/javascripts/app/views/widget/organization.jst.eco
@@ -21,6 +21,15 @@
<% end %>
<% end %>
+ <% if @organization.members: %>
+
-<% if @user.image: %>
-
+<% if @user.imageUrl: %>
+
<% end %>
<%= @user.displayName() %>
<% for row in @userData: %>
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 99741cdf3..848319c87 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -6,7 +6,6 @@ class ApplicationController < ActionController::Base
helper_method :current_user,
:authentication_check,
:config_frontend,
- :user_data_full,
:is_role,
:model_create_render,
:model_update_render,
@@ -77,6 +76,7 @@ class ApplicationController < ActionController::Base
# update session updated_at
def session_update
+ #sleep 0.6
# on many paralell requests, session got reinitialised if Time. is used, as workaround use DateTime.
#session[:ping] = Time.now.utc.iso8601
@@ -318,6 +318,13 @@ class ApplicationController < ActionController::Base
def model_show_render (object, params)
begin
+
+ if params[:full]
+ generic_object_full = object.full( params[:id] )
+ render :json => generic_object_full, :status => :ok
+ return
+ end
+
generic_object = object.find( params[:id] )
model_show_render_item(generic_object)
rescue Exception => e
diff --git a/app/controllers/long_polling_controller.rb b/app/controllers/long_polling_controller.rb
index a4b884a0d..e2f8aa8b2 100644
--- a/app/controllers/long_polling_controller.rb
+++ b/app/controllers/long_polling_controller.rb
@@ -59,7 +59,7 @@ class LongPollingController < ApplicationController
user_id = session[:user_id]
user = {}
if user_id
- user = User.user_data_full( user_id )
+ user = User.find( user_id )
end
log 'notice', "send auth login (user_id #{user_id})", client_id
Sessions.create( client_id, user, { :type => 'ajax' } )
diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb
index ce9e5ddb7..f3267447e 100644
--- a/app/controllers/organizations_controller.rb
+++ b/app/controllers/organizations_controller.rb
@@ -90,6 +90,11 @@ curl http://localhost/api/v1/organizations/#{id}.json -v -u #{login}:#{password}
return
end
end
+ if params[:full]
+ full = Organization.full( params[:id] )
+ render :json => full
+ return
+ end
model_show_render(Organization, params)
end
diff --git a/app/controllers/sessions/collection_base.rb b/app/controllers/sessions/collection_base.rb
index b3abe18e1..04efc5b8c 100644
--- a/app/controllers/sessions/collection_base.rb
+++ b/app/controllers/sessions/collection_base.rb
@@ -1,34 +1,37 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module ExtraCollection
- def session( collections, user )
+ def session( collections, assets, user )
# all base stuff
- collections[ Taskbar.to_app_model ] = Taskbar.where( :user_id => user.id )
- collections[ Role.to_app_model ] = Role.all
- collections[ Group.to_app_model ] = Group.all
+ assets = {}
+ collections[ Taskbar.to_app_model ] = Taskbar.where( :user_id => user.id )
+ collections[ Taskbar.to_app_model ].each {|item|
+ assets = item.assets(assets)
+ }
+ collections[ Role.to_app_model ] = []
+ Role.all.each {|item|
+ assets = item.assets(assets)
+ }
+
+ collections[ Group.to_app_model ] = []
+ Group.all.each {|item|
+ assets = item.assets(assets)
+ }
if !user.is_role('Customer')
- collections[ Organization.to_app_model ] = Organization.all
+ collections[ Organization.to_app_model ] = []
+ Organization.all.each {|item|
+ assets = item.assets(assets)
+ }
else
if user.organization_id
- collections[ Organization.to_app_model ] = Organization.where( :id => user.organization_id )
+ collections[ Organization.to_app_model ] = []
+ Organization.where( :id => user.organization_id ).each {|item|
+ assets = item.assets(assets)
+ }
end
end
end
- def push( collections, user )
-
- # all base stuff
- #collections[ Role.to_app_model ] = Role.all
- #collections[ Group.to_app_model ] = Group.all
-
- #if !user.is_role('Customer')
- # collections[ Organization.to_app_model ] = Organization.all
- #else
- # if user.organization_id
- # collections[ Organization.to_app_model ] = Organization.where( :id => user.organization_id )
- # end
- #end
- end
- module_function :session, :push
+ module_function :session
end
diff --git a/app/controllers/sessions/collection_network.rb b/app/controllers/sessions/collection_network.rb
index 2048dc58c..466801d86 100644
--- a/app/controllers/sessions/collection_network.rb
+++ b/app/controllers/sessions/collection_network.rb
@@ -1,7 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module ExtraCollection
- def session( collections, user )
+ def session( collections, assets, user )
collections[ Network.to_app_model ] = Network.all
collections[ Network::Category.to_app_model ] = Network::Category.all
@@ -9,13 +9,6 @@ module ExtraCollection
collections[ Network::Privacy.to_app_model ] = Network::Privacy.all
end
- def push( collections, user )
- collections[ Network.to_app_model ] = Network.all
- collections[ Network::Category.to_app_model ] = Network::Category.all
- collections[ Network::Category::Type.to_app_model ] = Network::Category::Type.all
- collections[ Network::Privacy.to_app_model ] = Network::Privacy.all
-
- end
- module_function :session, :push
-end
+ module_function :session
+end
\ No newline at end of file
diff --git a/app/controllers/sessions/collection_ticket.rb b/app/controllers/sessions/collection_ticket.rb
index 032b79a91..b040711f9 100644
--- a/app/controllers/sessions/collection_ticket.rb
+++ b/app/controllers/sessions/collection_ticket.rb
@@ -1,42 +1,43 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module ExtraCollection
- def session( collections, user )
+ def session( collections, assets, user )
# all ticket stuff
- collections[ Ticket::StateType.to_app_model ] = Ticket::StateType.all
- collections[ Ticket::State.to_app_model ] = Ticket::State.all
- collections[ Ticket::Priority.to_app_model ] = Ticket::Priority.all
- collections[ Ticket::Article::Type.to_app_model ] = Ticket::Article::Type.all
- collections[ Ticket::Article::Sender.to_app_model ] = Ticket::Article::Sender.all
-
+ collections[ Ticket::StateType.to_app_model ] = []
+ Ticket::StateType.all.each {|item|
+ assets = item.assets(assets)
+ }
+ collections[ Ticket::State.to_app_model ] = []
+ Ticket::State.all.each {|item|
+ assets = item.assets(assets)
+ }
+ collections[ Ticket::Priority.to_app_model ] = []
+ Ticket::Priority.all.each {|item|
+ assets = item.assets(assets)
+ }
+ collections[ Ticket::Article::Type.to_app_model ] = []
+ Ticket::Article::Type.all.each {|item|
+ assets = item.assets(assets)
+ }
+ collections[ Ticket::Article::Sender.to_app_model ] = []
+ Ticket::Article::Sender.all.each {|item|
+ assets = item.assets(assets)
+ }
if !user.is_role('Customer')
# all signatures
- collections[ Signature.to_app_model ] = Signature.all
+ collections[ Signature.to_app_model ] = []
+ Signature.all.each {|item|
+ assets = item.assets(assets)
+ }
# all email addresses
- collections[ EmailAddress.to_app_model ] = EmailAddress.all
+ collections[ EmailAddress.to_app_model ] = []
+ EmailAddress.all.each {|item|
+ assets = item.assets(assets)
+ }
end
end
- def push( collections, user )
-
- # all ticket stuff
- #collections[ Ticket::StateType.to_app_model ] = Ticket::StateType.all
- #collections[ Ticket::State.to_app_model ] = Ticket::State.all
- #collections[ Ticket::Priority.to_app_model ] = Ticket::Priority.all
- #collections[ Ticket::Article::Type.to_app_model ] = Ticket::Article::Type.all
- #collections[ Ticket::Article::Sender.to_app_model ] = Ticket::Article::Sender.all
-
- #if !user.is_role('Customer')
-
- # all signatures
- # collections[ Signature.to_app_model ] = Signature.all
-
- # all email addresses
- # collections[ EmailAddress.to_app_model ] = EmailAddress.all
- #end
- end
-
- module_function :session, :push
-end
+ module_function :session
+end
\ No newline at end of file
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 1da4ff7a2..dd1c6561c 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -31,10 +31,9 @@ class SessionsController < ApplicationController
user.activity_stream_log( 'session started', user.id, true )
# auto population of default collections
- collections = SessionHelper::default_collections(user)
+ collections, assets = SessionHelper::default_collections(user)
- # set session user_id
- user = User.find_fulldata(user.id)
+ assets = user.assets(assets)
# check logon session
logon_session_key = nil
@@ -52,6 +51,7 @@ class SessionsController < ApplicationController
render :json => {
:session => user,
:collections => collections,
+ :assets => assets,
:logon_session => logon_session_key,
},
:status => :created
@@ -84,15 +84,18 @@ class SessionsController < ApplicationController
# Save the user ID in the session so it can be used in
# subsequent requests
- user = User.user_data_full( user_id )
+ user = User.find( user_id )
# auto population of default collections
- collections = SessionHelper::default_collections( User.find(user_id) )
+ collections, assets = SessionHelper::default_collections(user)
+
+ assets = user.assets(assets)
# return current session
render :json => {
:session => user,
:collections => collections,
+ :assets => assets,
:config => config_frontend,
}
end
diff --git a/app/controllers/ticket_overviews_controller.rb b/app/controllers/ticket_overviews_controller.rb
index a64abd9b8..44773158f 100644
--- a/app/controllers/ticket_overviews_controller.rb
+++ b/app/controllers/ticket_overviews_controller.rb
@@ -49,7 +49,7 @@ class TicketOverviewsController < ApplicationController
end
# get related users
- assets = { User.to_app_model => {} }
+ assets = {}
overview[:ticket_ids].each {|ticket_id|
ticket = Ticket.lookup( :id => ticket_id )
assets = ticket.assets(assets)
@@ -70,9 +70,7 @@ class TicketOverviewsController < ApplicationController
Group.find(group_id).users.each {|user|
next if !agents[ user.id ]
groups_users[ group_id ].push user.id
- if !assets[ User.to_app_model ][user.id]
- assets[ User.to_app_model ][user.id] = User.user_data_full(user.id)
- end
+ assets = user.assets( assets )
}
}
diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb
index 439ac8126..326ccde40 100644
--- a/app/controllers/tickets_controller.rb
+++ b/app/controllers/tickets_controller.rb
@@ -262,23 +262,20 @@ class TicketsController < ApplicationController
# get related users
assets = {}
- assets[ User.to_app_model ] = {}
assets = ticket.assets(assets)
# get attributes to update
attributes_to_change = Ticket::ScreenOptions.attributes_to_change( :user => current_user, :ticket => ticket )
attributes_to_change[:owner_id].each { |user_id|
- if !assets[ User.to_app_model ][user_id]
- assets[ User.to_app_model ][user_id] = User.user_data_full( user_id )
- end
+ user = User.find(user_id)
+ assets = user.assets(assets)
}
attributes_to_change[:group_id__owner_id].each {|group_id, user_ids|
user_ids.each {|user_id|
- if !assets[ User.to_app_model ][user_id]
- assets[ User.to_app_model ][user_id] = User.user_data_full( user_id )
- end
+ user = User.find(user_id)
+ assets = user.assets(assets)
}
}
@@ -322,16 +319,14 @@ class TicketsController < ApplicationController
assets = {}
assets[ User.to_app_model ] = {}
attributes_to_change[:owner_id].each { |user_id|
- if !assets[ User.to_app_model ][user_id]
- assets[ User.to_app_model ][user_id] = User.user_data_full( user_id )
- end
+ user = User.find(user_id)
+ assets = user.assets(assets)
}
attributes_to_change[:group_id__owner_id].each {|group_id, user_ids|
user_ids.each {|user_id|
- if !assets[ User.to_app_model ][user_id]
- assets[ User.to_app_model ][user_id] = User.user_data_full( user_id )
- end
+ user = User.find(user_id)
+ assets = user.assets(assets)
}
}
@@ -345,9 +340,7 @@ class TicketsController < ApplicationController
owner_ids = []
ticket.agent_of_group.each { |user|
owner_ids.push user.id
- if !assets[ User.to_app_model ][user.id]
- assets[ User.to_app_model ][user.id] = User.user_data_full( user.id )
- end
+ assets = user.assets(assets)
}
# get related articles
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 90cf6653e..3ebbfce45 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -70,7 +70,7 @@ curl http://localhost/api/v1/users.json -v -u #{login}:#{password}
end
users_all = []
users.each {|user|
- users_all.push User.user_data_full( user.id )
+ users_all.push User.lookup( :id => user.id ).attributes_with_associations
}
render :json => users_all, :status => :ok
end
@@ -101,7 +101,14 @@ curl http://localhost/api/v1/users/#{id}.json -v -u #{login}:#{password}
return
end
end
- user = User.user_data_full( params[:id] )
+
+ if params[:full]
+ full = User.full( params[:id] )
+ render :json => full
+ return
+ end
+
+ user = User.find( params[:id] )
render :json => user
end
@@ -245,7 +252,7 @@ curl http://localhost/api/v1/users.json -v -u #{login}:#{password} -H "Content-T
)
end
- user_new = User.user_data_full( user.id )
+ user_new = User.find( user.id )
render :json => user_new, :status => :created
rescue Exception => e
render :json => { :error => e.message }, :status => :unprocessable_entity
@@ -309,7 +316,7 @@ curl http://localhost/api/v1/users/2.json -v -u #{login}:#{password} -H "Content
end
# get new data
- user_new = User.user_data_full( params[:id] )
+ user_new = User.find( params[:id] )
render :json => user_new, :status => :ok
rescue Exception => e
render :json => { :error => e.message }, :status => :unprocessable_entity
diff --git a/app/models/application_model.rb b/app/models/application_model.rb
index c79684762..aaaf4e568 100644
--- a/app/models/application_model.rb
+++ b/app/models/application_model.rb
@@ -883,4 +883,25 @@ destory object dependencies, will be executed automatically
def destroy_dependencies
end
+=begin
+
+return object and assets
+
+ data = Model.full(123)
+ data = {
+ :id => 123,
+ :assets => assets,
+ }
+
+=end
+
+ def self.full(id)
+ object = self.find(id)
+ assets = object.assets({})
+ {
+ :id => id,
+ :assets => assets,
+ }
+ end
+
end
diff --git a/app/models/application_model/assets.rb b/app/models/application_model/assets.rb
index b3655b49a..4fa7f1b1c 100644
--- a/app/models/application_model/assets.rb
+++ b/app/models/application_model/assets.rb
@@ -12,7 +12,7 @@ get all assets / related models for this user
returns
result = {
- :users => {
+ :User => {
123 => user_model_123,
1234 => user_model_1234,
}
@@ -26,23 +26,18 @@ returns
data[ self.class.to_app_model ] = {}
end
if !data[ self.class.to_app_model ][ self.id ]
- data[ self.class.to_app_model ][ self.id ] = self.attributes
+ data[ self.class.to_app_model ][ self.id ] = self.attributes_with_associations
end
return data if !self['created_by_id'] && !self['updated_by_id']
- if !data[ User.to_app_model ]
- data[ User.to_app_model ] = {}
- end
- if self['created_by_id']
- if !data[ User.to_app_model ][ self['created_by_id'] ]
- data[ User.to_app_model ][ self['created_by_id'] ] = User.user_data_full( self['created_by_id'] )
+ ['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 ] )
+ data = user.assets( data )
+ end
end
- end
- if self['updated_by_id']
- if !data[ User.to_app_model ][ self['updated_by_id'] ]
- data[ User.to_app_model ][ self['updated_by_id'] ] = User.user_data_full( self['updated_by_id'] )
- end
- end
+ }
data
end
diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb
index a161de696..c4eb040d1 100644
--- a/app/models/channel/email_parser.rb
+++ b/app/models/channel/email_parser.rb
@@ -122,6 +122,10 @@ class Channel::EmailParser
data[:body] = mail.text_part.body.decoded
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 => '?')
+ end
+
# html attachment/body may exists and will be converted to text
else
filename = '-no name-'
@@ -129,7 +133,11 @@ class Channel::EmailParser
filename = 'html-email'
data[:body] = mail.html_part.body.to_s
data[:body] = Encode.conv( mail.html_part.charset.to_s, data[:body] )
- data[:body] = html2ascii( data[:body] )
+ data[:body] = html2ascii( data[:body] ).to_s.force_encoding('utf-8')
+
+ if !data[:body].valid_encoding?
+ data[:body] = data[:body].encode('utf-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')
+ end
# any other attachments
else
@@ -188,6 +196,10 @@ class Channel::EmailParser
data[:body] = mail.body.decoded
data[:body] = Encode.conv( mail.charset, data[:body] )
+ if !data[:body].valid_encoding?
+ data[:body] = data[:body].encode('utf-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')
+ end
+
# html part
else
filename = '-no name-'
@@ -195,7 +207,11 @@ class Channel::EmailParser
filename = 'html-email'
data[:body] = mail.body.decoded
data[:body] = Encode.conv( mail.charset, data[:body] )
- data[:body] = html2ascii( data[:body] )
+ data[:body] = html2ascii( data[:body] ).to_s.force_encoding('utf-8')
+
+ if !data[:body].valid_encoding?
+ data[:body] = data[:body].encode('utf-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')
+ end
# any other attachments
else
diff --git a/app/models/history/assets.rb b/app/models/history/assets.rb
index c61dc1c3d..8f37e1cf4 100644
--- a/app/models/history/assets.rb
+++ b/app/models/history/assets.rb
@@ -22,11 +22,9 @@ returns
def assets (data)
- if !data[ User.to_app_model ]
- data[ User.to_app_model ] = {}
- end
- if !data[ User.to_app_model ][ self['created_by_id'] ]
- data[ User.to_app_model ][ self['created_by_id'] ] = User.user_data_full( self['created_by_id'] )
+ if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self['created_by_id'] ]
+ user = User.lookup( :id => self['created_by_id'] )
+ data = user.assets( data )
end
data
diff --git a/app/models/organization.rb b/app/models/organization.rb
index dc155b89b..b15d33540 100644
--- a/app/models/organization.rb
+++ b/app/models/organization.rb
@@ -1,16 +1,20 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Organization < ApplicationModel
+ require 'organization/assets'
include Organization::Assets
extend Organization::Search
include Organization::SearchIndex
- has_and_belongs_to_many :users
- has_many :members, :class_name => 'User'
- validates :name, :presence => true
+ has_and_belongs_to_many :users
+ has_many :members, :class_name => 'User'
+ validates :name, :presence => true
+
+ after_create :notify_clients_after_create
+ after_update :notify_clients_after_update
activity_stream_support :role => 'Admin'
history_support
search_index_support
-end
+end
\ No newline at end of file
diff --git a/app/models/organization/assets.rb b/app/models/organization/assets.rb
index 86fbc239d..9ad1eacee 100644
--- a/app/models/organization/assets.rb
+++ b/app/models/organization/assets.rb
@@ -29,15 +29,25 @@ returns
data[ User.to_app_model ] = {}
end
if !data[ Organization.to_app_model ][ self.id ]
- data[ Organization.to_app_model ][ self.id ] = self.attributes
- data[ Organization.to_app_model ][ self.id ][:user_ids] = []
- users = User.where( :organization_id => self.id ).limit(10)
- users.each {|user|
- data[ User.to_app_model ][ user.id ] = User.user_data_full( user.id )
- data[ Organization.to_app_model ][ self.id ][:user_ids].push user.id
- }
+ data[ Organization.to_app_model ][ self.id ] = self.attributes_with_associations
+ 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 )
+ data = user.assets( data )
+ end
+ }
+ end
end
+ ['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 ] )
+ data = user.assets( data )
+ end
+ end
+ }
data
end
-end
+end
\ No newline at end of file
diff --git a/app/models/package.rb b/app/models/package.rb
index 77aec2b9b..e7b995dd2 100644
--- a/app/models/package.rb
+++ b/app/models/package.rb
@@ -317,7 +317,7 @@ class Package < ApplicationModel
rescue => e
puts "TRIED TO RELOAD '#{entry}'"
puts 'ERROR: ' + e.inspect
- puts 'Traceback: ' + e.backtrace
+ puts 'Traceback: ' + e.backtrace.inspect
end
end
}
diff --git a/app/models/ticket/article/assets.rb b/app/models/ticket/article/assets.rb
index 4bde9e77e..42bb98024 100644
--- a/app/models/ticket/article/assets.rb
+++ b/app/models/ticket/article/assets.rb
@@ -41,15 +41,14 @@ returns
data[ Ticket::Article.to_app_model ][ self.id ]['attachments'] = self.attachments
end
- if !data[ User.to_app_model ]
- data[ User.to_app_model ] = {}
- end
- if !data[ User.to_app_model ][ self['created_by_id'] ]
- data[ User.to_app_model ][ self['created_by_id'] ] = User.user_data_full( self['created_by_id'] )
- end
- if !data[ User.to_app_model ][ self['updated_by_id'] ]
- data[ User.to_app_model ][ self['updated_by_id'] ] = User.user_data_full( self['updated_by_id'] )
- end
+ ['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 ] )
+ data = user.assets( data )
+ end
+ end
+ }
data
end
diff --git a/app/models/ticket/assets.rb b/app/models/ticket/assets.rb
index ff4472861..856ef52fd 100644
--- a/app/models/ticket/assets.rb
+++ b/app/models/ticket/assets.rb
@@ -27,24 +27,16 @@ returns
data[ Ticket.to_app_model ] = {}
end
if !data[ Ticket.to_app_model ][ self.id ]
- data[ Ticket.to_app_model ][ self.id ] = self.attributes
- end
-
- if !data[ User.to_app_model ]
- data[ User.to_app_model ] = {}
- end
- if !data[ User.to_app_model ][ self.owner_id ]
- data[ User.to_app_model ][ self.owner_id ] = User.user_data_full( self.owner_id )
- end
- if !data[ User.to_app_model ][ self.customer_id ]
- data[ User.to_app_model ][ self.customer_id ] = User.user_data_full( self.customer_id )
- end
- if !data[ User.to_app_model ][ self.created_by_id ]
- data[ User.to_app_model ][ self.created_by_id ] = User.user_data_full( self.created_by_id )
- end
- if !data[ User.to_app_model ][ self.updated_by_id ]
- data[ User.to_app_model ][ self.updated_by_id ] = User.user_data_full( self.updated_by_id )
+ data[ Ticket.to_app_model ][ self.id ] = self.attributes_with_associations
end
+ ['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 ] )
+ data = user.assets( data )
+ end
+ end
+ }
data
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 6c512fe70..d4948764d 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -3,6 +3,7 @@
require 'digest/md5'
class User < ApplicationModel
+ require 'user/assets'
include User::Assets
extend User::Search
include User::SearchIndex
@@ -360,108 +361,6 @@ returns
return user
end
- def self.find_fulldata(user_id)
-
- cache = self.cache_get(user_id, true)
- return cache if cache
-
- # get user
- user = User.find(user_id)
- data = user.attributes
-
- # do not show password
- user['password'] = ''
-
- # get linked accounts
- data['accounts'] = {}
- authorizations = user.authorizations() || []
- authorizations.each do | authorization |
- data['accounts'][authorization.provider] = {
- :uid => authorization[:uid],
- :username => authorization[:username]
- }
- end
-
- # set roles
- roles = []
- user.roles.select('id, name').where( :active => true ).each { |role|
- roles.push role.attributes
- }
- data['roles'] = roles
- data['role_ids'] = user.role_ids
-
- groups = []
- user.groups.select('id, name').where( :active => true ).each { |group|
- groups.push group.attributes
- }
- data['groups'] = groups
- data['group_ids'] = user.group_ids
-
- organization = user.organization
- if organization
- data['organization'] = organization.attributes
- end
-
- organizations = []
- user.organizations.select('id, name').where( :active => true ).each { |organization|
- organizations.push organization.attributes
- }
- data['organizations'] = organizations
- data['organization_ids'] = user.organization_ids
-
- self.cache_set(user.id, data, true)
-
- return data
- end
-
- def self.user_data_full (user_id)
-
- # get user
- user = User.find_fulldata(user_id)
-
- # do not show password
- user['password'] = ''
-
- # TEMP: compat. reasons
- user['preferences'] = {} if user['preferences'] == nil
-
- items = []
- if user['preferences'][:tickets_open].to_i > 0
- item = {
- :url => '',
- :name => 'open',
- :count => user['preferences'][:tickets_open] || 0,
- :title => 'Open Tickets',
- :class => 'user-tickets',
- :data => 'open'
- }
- items.push item
- end
- if user['preferences'][:tickets_closed].to_i > 0
- item = {
- :url => '',
- :name => 'closed',
- :count => user['preferences'][:tickets_closed] || 0,
- :title => 'Closed Tickets',
- :class => 'user-tickets',
- :data => 'closed'
- }
- items.push item
- end
-
- # show linked topics and items
- if items.count > 0
- topic = {
- :title => 'Tickets',
- :items => items,
- }
- user['links'] = []
- user['links'].push topic
- end
-
- return user
- end
-
=begin
update last login date and reset login_failed (is automatically done by auth and sso backend)
diff --git a/app/models/user/assets.rb b/app/models/user/assets.rb
index b6cfb30a6..03e848747 100644
--- a/app/models/user/assets.rb
+++ b/app/models/user/assets.rb
@@ -12,7 +12,7 @@ get all assets / related models for this user
returns
result = {
- :users => {
+ :User => {
123 => user_model_123,
1234 => user_model_1234,
}
@@ -26,22 +26,61 @@ returns
data[ User.to_app_model ] = {}
end
if !data[ User.to_app_model ][ self.id ]
- data[ User.to_app_model ][ self.id ] = User.user_data_full( self.id )
+ attributes = self.attributes_with_associations
+
+ # do not transfer crypted pw
+ attributes['password'] = ''
+
+ # get linked accounts
+ attributes['accounts'] = {}
+ authorizations = self.authorizations()
+ authorizations.each do | authorization |
+ attributes['accounts'][authorization.provider] = {
+ :uid => authorization[:uid],
+ :username => authorization[:username]
+ }
+ end
+
+ data[ User.to_app_model ][ self.id ] = attributes
+
+ # get roles
+ if attributes['role_ids']
+ attributes['role_ids'].each {|role_id|
+ role = Role.lookup( :id => role_id )
+ data = role.assets( data )
+ }
+ end
+
+ # get groups
+ if attributes['group_ids']
+ attributes['group_ids'].each {|group_id|
+ group = Group.lookup( :id => group_id )
+ data = group.assets( data )
+ }
+ end
+
+ # get groups
+ if attributes['organization_ids']
+ attributes['organization_ids'].each {|organization_id|
+ organization = Organization.lookup( :id => organization_id )
+ data = organization.assets( data )
+ }
+ end
end
if self.organization_id
- if !data[ Organization.to_app_model ]
- data[ Organization.to_app_model ] = {}
- end
- if !data[ Organization.to_app_model ][ self.organization_id ]
- data[ Organization.to_app_model ][ self.organization_id ] = Organization.find( self.organization_id )
+ if !data[ Organization.to_app_model ] || !data[ Organization.to_app_model ][ self.organization_id ]
+ organization = Organization.lookup( :id => self.organization_id )
+ data = organization.assets( data )
end
end
- if !data[ User.to_app_model ][ self.created_by_id ]
- data[ User.to_app_model ][ self.created_by_id ] = User.user_data_full( self.created_by_id )
- end
- if !data[ User.to_app_model ][ self.updated_by_id ]
- data[ User.to_app_model ][ self.updated_by_id ] = User.user_data_full( self.updated_by_id )
- end
+ ['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 ] )
+ data = user.assets( data )
+ end
+ end
+ }
data
end
diff --git a/lib/cache.rb b/lib/cache.rb
index 4fb96344e..47cc952f8 100644
--- a/lib/cache.rb
+++ b/lib/cache.rb
@@ -16,6 +16,9 @@ module Cache
end
def self.clear
# puts 'Cache.clear...'
+ # workaround, set test cache before clear whole cache, Rails.cache.clear complains about not existing cache dir
+ Cache.write('test',1 )
+
Rails.cache.clear
end
end
\ No newline at end of file
diff --git a/lib/session_helper.rb b/lib/session_helper.rb
index ba30e230a..d9c16c298 100644
--- a/lib/session_helper.rb
+++ b/lib/session_helper.rb
@@ -3,31 +3,17 @@ module SessionHelper
# auto population collections, store all here
default_collection = {}
+ assets = {}
# load collections to deliver from external files
dir = File.expand_path('../../', __FILE__)
files = Dir.glob( "#{dir}/app/controllers/sessions/collection_*.rb" )
for file in files
load file
- ExtraCollection.session( default_collection, user )
+ ExtraCollection.session( default_collection, assets, user )
end
- return default_collection
- end
- def self.push_collections(user)
-
- # auto population collections, store all here
- push_collections = {}
-
- # load collections to deliver from external files
- dir = File.expand_path('../../', __FILE__)
- files = Dir.glob( "#{dir}/app/controllers/sessions/collection_*.rb" )
- for file in files
- load file
- ExtraCollection.push( push_collections, user )
- end
-
- return push_collections
+ return default_collection, assets
end
def self.cleanup_expired
diff --git a/lib/sessions/backend/ticket_create.rb b/lib/sessions/backend/ticket_create.rb
index fb080b5de..e950b2e83 100644
--- a/lib/sessions/backend/ticket_create.rb
+++ b/lib/sessions/backend/ticket_create.rb
@@ -45,7 +45,7 @@ class Sessions::Backend::TicketCreate
users = {}
create_attributes[:owner_id].each {|user_id|
if !users[user_id]
- users[user_id] = User.user_data_full(user_id)
+ users[user_id] = User.find(user_id).attributes
end
}
data = {
diff --git a/script/install.sh b/script/install.sh
new file mode 100644
index 000000000..aee26438a
--- /dev/null
+++ b/script/install.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+get_distro(){
+ arch=$(uname -m)
+ kernel=$(uname -r)
+ if [ -f /etc/lsb-release ]; then
+ os=$(lsb_release -s -d)
+ elif [ -f /etc/debian_version ]; then
+ os="Debian $(cat /etc/debian_version)"
+ elif [ -f /etc/redhat-release ]; then
+ os=`cat /etc/redhat-release`
+ else
+ os="$(uname -s) $(uname -r)"
+ fi
+}
+
diff --git a/test/browser/manage_test.rb b/test/browser/manage_test.rb
index e24d2b736..178403470 100644
--- a/test/browser/manage_test.rb
+++ b/test/browser/manage_test.rb
@@ -76,11 +76,11 @@ class ManageTest < TestCase
},
{
:execute => 'click',
- :css => 'a[data-type="edit"]:last-child',
+ :css => '.table-overview tr:last-child td',
},
{
:execute => 'wait',
- :value => 1,
+ :value => 2,
},
{
:execute => 'set',
@@ -146,7 +146,7 @@ class ManageTest < TestCase
},
{
:execute => 'click',
- :css => 'a[data-type="edit"]:last-child',
+ :css => '.table-overview tr:last-child td',
},
{
:execute => 'wait',
diff --git a/test/fixtures/mail22.box b/test/fixtures/mail22.box
new file mode 100644
index 000000000..74a98bdeb
--- /dev/null
+++ b/test/fixtures/mail22.box
@@ -0,0 +1,69 @@
+From ireoniqla@lipetsk.ru Tue Aug 5 22:38:39 2014
+Return-Path:
+X-Original-To: info@znuny.nix
+Delivered-To: znuny-sales@arber.znuny.nix
+Received: from X53.bbn2-087.lipetsk.ru (unknown [95.179.87.53])
+ by arber.znuny.nix (Postfix) with ESMTP id A732E60260
+ for ; Tue, 5 Aug 2014 22:38:38 +0200 (CEST)
+Message-ID:
+Date: Wed, 6 Aug 2014 00:38:37 +0400
+From: Gilbertina Suthar
+MIME-Version: 1.0
+To: Info
+Subject: P..E..N-I..S__-E N L A R-G E-M..E..N T-___P..I-L-L..S...Info.
+Content-Type: text/html; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: quoted-printable
+X-UID: 1429
+Status: RO
+Content-Length: 3051
+Lines: 48
+
+Puzzled by =
+judith bronte dave. Melvin will want her way through with. Continued =
+adam helped charlie cried. Soon joined the master bathroom. Grinned adam =
+rubbed his arms she nodded. Freemont and they talked with =
+beppe. Thinking of bed and whenever adam. Mike was too tired man =
+to hear.
I°0PQSHEJlÔNwf˜Ì1§3S¬73Î1mEbb5N37¢LϖC7AlFnRº♦HG64BÉ4Ò¦Måâ4ÊzkΙN⌉7⌉TBNÐT×xPIògIÎÃlLøÕML⊥ÞøSaΨRBreathed adam =
+gave the master bedroom door. Better get charlie took the =
+wall. Charlotte clark smile he saw charlie. Dave and leaned her =
+tears adam.