|
|
@ -19,13 +19,13 @@ class UsersController < ApplicationController
|
|
|
|
#Added by young
|
|
|
|
#Added by young
|
|
|
|
menu_item :activity
|
|
|
|
menu_item :activity
|
|
|
|
menu_item :user_information, :only => :info
|
|
|
|
menu_item :user_information, :only => :info
|
|
|
|
menu_item :project, :only => :user_projects
|
|
|
|
menu_item :user_project, :only => :user_projects
|
|
|
|
menu_item :requirement_focus, :only => :watch_bids
|
|
|
|
menu_item :requirement_focus, :only => :watch_bids
|
|
|
|
menu_item :user_newfeedback, :only => :user_newfeedback
|
|
|
|
menu_item :user_newfeedback, :only => :user_newfeedback
|
|
|
|
#Ended by young
|
|
|
|
#Ended by young
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before_filter :require_admin, :except => [:show, :index,:tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:edit,:update]
|
|
|
|
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, :user_watchlist, :user_fanslist,:edit,:update]
|
|
|
|
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership,
|
|
|
|
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership,
|
|
|
|
:destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info]
|
|
|
|
:destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info]
|
|
|
|
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save
|
|
|
|
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save
|
|
|
@ -155,15 +155,124 @@ class UsersController < ApplicationController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# @count = Redmine::Activity::Fetcher.new(User.current, :author => @user).scope_select {|t| !has["show_#{t}"].nil?}.events(nil, nil).count
|
|
|
|
# @count = Redmine::Activity::Fetcher.new(User.current, :author => @user).scope_select {|t| !has["show_#{t}"].nil?}.events(nil, nil).count
|
|
|
|
|
|
|
|
|
|
|
|
scope = User.logged.status(@status)
|
|
|
|
scope = UserStatus.visible
|
|
|
|
scope = scope.like(params[:name]) if params[:name].present?
|
|
|
|
|
|
|
|
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
|
|
|
|
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
|
|
|
|
|
|
|
|
# scope.each do |user|
|
|
|
|
|
|
|
|
# UserStatus.create(:changesets_count => user.changesets.count, :watchers_count => user.watcher_users.count, :user_id => user.id)
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
@user_count = scope.count
|
|
|
|
|
|
|
|
@user_pages = Paginator.new @user_count, @limit, params['page']
|
|
|
|
|
|
|
|
#@offset ||= @user_pages.offset
|
|
|
|
|
|
|
|
#@users = scope.order(sort_clause).limit(@limit).offset(@offset).all
|
|
|
|
|
|
|
|
@user_base_tag = params[:id]?'base_users':'base'
|
|
|
|
|
|
|
|
if params[:user_sort_type].present?
|
|
|
|
|
|
|
|
case params[:user_sort_type]
|
|
|
|
|
|
|
|
when '0'
|
|
|
|
|
|
|
|
@offset ||= @user_pages.reverse_offset
|
|
|
|
|
|
|
|
unless @offset == 0
|
|
|
|
|
|
|
|
@users_statuses = scope.offset(@offset).limit(@limit).all.reverse
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
limit = @user_count % @limit
|
|
|
|
|
|
|
|
if limit == 0
|
|
|
|
|
|
|
|
limit = @limit
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
@users_statuses = scope.offset(@offset).limit(limit).all.reverse
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
@s_type = 0
|
|
|
|
|
|
|
|
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
|
|
|
|
|
|
|
# @projects = @projects[@offset, @limit]
|
|
|
|
|
|
|
|
when '1'
|
|
|
|
|
|
|
|
@offset ||= @user_pages.reverse_offset
|
|
|
|
|
|
|
|
unless @offset == 0
|
|
|
|
|
|
|
|
@users_statuses = scope.reorder('changesets_count').offset(@offset).limit(@limit).all.reverse
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
limit = @user_count % @limit
|
|
|
|
|
|
|
|
if limit == 0
|
|
|
|
|
|
|
|
limit = @limit
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
@users_statuses = scope.reorder('changesets_count').offset(@offset).limit(limit).all.reverse
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
@s_type = 1
|
|
|
|
|
|
|
|
#sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count}
|
|
|
|
|
|
|
|
#@users = @users[@offset, @limit]
|
|
|
|
|
|
|
|
when '2'
|
|
|
|
|
|
|
|
@offset ||= @user_pages.reverse_offset
|
|
|
|
|
|
|
|
unless @offset == 0
|
|
|
|
|
|
|
|
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(@limit).all.reverse
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
limit = @user_count % @limit
|
|
|
|
|
|
|
|
if limit == 0
|
|
|
|
|
|
|
|
limit = @limit
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(limit).all.reverse
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
@s_type = 2
|
|
|
|
|
|
|
|
#@users = @users[@offset, @limit]
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
@offset ||= @user_pages.reverse_offset
|
|
|
|
|
|
|
|
unless @offset == 0
|
|
|
|
|
|
|
|
@users_statuses = scope.reorder('changesets_count').offset(@offset).limit(@limit).all.reverse
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
limit = @user_count % @limit
|
|
|
|
|
|
|
|
if limit == 0
|
|
|
|
|
|
|
|
limit = @limit
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
@users_statuses = scope.reorder('changesets_count').offset(@offset).limit(limit).all.reverse
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
@s_type = 1
|
|
|
|
|
|
|
|
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
|
|
|
|
|
|
|
# @projects = @projects[@offset, @limit]
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@users = []
|
|
|
|
|
|
|
|
@users_statuses.each do |obj|
|
|
|
|
|
|
|
|
@users << User.find_by_id("#{obj.user_id}")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
|
|
|
format.html {
|
|
|
|
|
|
|
|
@groups = Group.all.sort
|
|
|
|
|
|
|
|
render :layout => @user_base_tag
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
format.api
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def search
|
|
|
|
|
|
|
|
sort_init 'login', 'asc'
|
|
|
|
|
|
|
|
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case params[:format]
|
|
|
|
|
|
|
|
when 'xml', 'json'
|
|
|
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 15})
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
@limit = 15#per_page_option
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@status = params[:status] || 1
|
|
|
|
|
|
|
|
has = {
|
|
|
|
|
|
|
|
"show_changesets" => true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
scope = User.logged.status(@status)
|
|
|
|
|
|
|
|
scope = scope.like(params[:name]) if params[:name].present?
|
|
|
|
@user_count = scope.count
|
|
|
|
@user_count = scope.count
|
|
|
|
@user_pages = Paginator.new @user_count, @limit, params['page']
|
|
|
|
@user_pages = Paginator.new @user_count, @limit, params['page']
|
|
|
|
@offset ||= @user_pages.offset
|
|
|
|
|
|
|
|
@users = scope.order(sort_clause).limit(@limit).offset(@offset).all
|
|
|
|
|
|
|
|
@user_base_tag = params[:id]?'base_users':'base'
|
|
|
|
@user_base_tag = params[:id]?'base_users':'base'
|
|
|
|
|
|
|
|
@offset ||= @user_pages.reverse_offset
|
|
|
|
|
|
|
|
unless @offset == 0
|
|
|
|
|
|
|
|
@users = scope.offset(@offset).limit(@limit).all.reverse
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
limit = @user_count % @limit
|
|
|
|
|
|
|
|
if limit == 0
|
|
|
|
|
|
|
|
limit = @limit
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
@users = scope.offset(@offset).limit(limit).all.reverse
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html {
|
|
|
|
format.html {
|
|
|
|
@groups = Group.all.sort
|
|
|
|
@groups = Group.all.sort
|
|
|
@ -173,6 +282,7 @@ class UsersController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### modified by fq
|
|
|
|
### modified by fq
|
|
|
|
def show
|
|
|
|
def show
|
|
|
|
# has = {
|
|
|
|
# has = {
|
|
|
@ -215,6 +325,33 @@ class UsersController < ApplicationController
|
|
|
|
# @activity_pages = Paginator.new @activity_count, @limit, params['page']
|
|
|
|
# @activity_pages = Paginator.new @activity_count, @limit, params['page']
|
|
|
|
# @offset ||= @activity_pages.offset
|
|
|
|
# @offset ||= @activity_pages.offset
|
|
|
|
# @events_by_day_ = @events.slice(@offset,@limit)
|
|
|
|
# @events_by_day_ = @events.slice(@offset,@limit)
|
|
|
|
|
|
|
|
case params[:type]
|
|
|
|
|
|
|
|
when "1"
|
|
|
|
|
|
|
|
if @user == User.current
|
|
|
|
|
|
|
|
activity = Activity.where('user_id = ?', User.current.id).order('id desc')
|
|
|
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
|
|
|
|
@activity_count = activity.count
|
|
|
|
|
|
|
|
@activity_pages = Paginator.new @activity_count, @limit, params['page']
|
|
|
|
|
|
|
|
@offset ||= @activity_pages.offset
|
|
|
|
|
|
|
|
@activity = activity.offset(@offset).limit(@limit)
|
|
|
|
|
|
|
|
@state = 1
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
when "2"
|
|
|
|
|
|
|
|
message = []
|
|
|
|
|
|
|
|
if @user == User.current
|
|
|
|
|
|
|
|
message = JournalsForMessage.reference_message(@user.id)
|
|
|
|
|
|
|
|
message += Journal.reference_message(@user.id)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
|
|
|
|
@activity_count = message.size
|
|
|
|
|
|
|
|
@info_pages = Paginator.new @activity_count, @limit, params['page']
|
|
|
|
|
|
|
|
@offset ||= @info_pages.offset
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messages = message.sort {|x,y| y.created_on <=> x.created_on }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@message = messages[@offset, @limit]
|
|
|
|
|
|
|
|
@state = 2
|
|
|
|
|
|
|
|
else
|
|
|
|
if @user == User.current
|
|
|
|
if @user == User.current
|
|
|
|
watcher = User.watched_by(@user)
|
|
|
|
watcher = User.watched_by(@user)
|
|
|
|
watcher.push(User.current)
|
|
|
|
watcher.push(User.current)
|
|
|
@ -227,6 +364,9 @@ class UsersController < ApplicationController
|
|
|
|
@activity_pages = Paginator.new @activity_count, @limit, params['page']
|
|
|
|
@activity_pages = Paginator.new @activity_count, @limit, params['page']
|
|
|
|
@offset ||= @activity_pages.offset
|
|
|
|
@offset ||= @activity_pages.offset
|
|
|
|
@activity = activity.offset(@offset).limit(@limit)
|
|
|
|
@activity = activity.offset(@offset).limit(@limit)
|
|
|
|
|
|
|
|
@state = 0
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Modified by nie
|
|
|
|
#Modified by nie
|
|
|
|
unless User.current.admin?
|
|
|
|
unless User.current.admin?
|
|
|
@ -250,9 +390,9 @@ class UsersController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
message = []
|
|
|
|
message = []
|
|
|
|
if @user == User.current
|
|
|
|
if @user == User.current
|
|
|
|
|
|
|
|
|
|
|
|
message = JournalsForMessage.reference_message(@user.id)
|
|
|
|
message = JournalsForMessage.reference_message(@user.id)
|
|
|
|
message += Journal.reference_message(@user.id) end
|
|
|
|
message += Journal.reference_message(@user.id)
|
|
|
|
|
|
|
|
end
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
@info_count = message.size
|
|
|
|
@info_count = message.size
|
|
|
|
@info_pages = Paginator.new @info_count, @limit, params['page']
|
|
|
|
@info_pages = Paginator.new @info_count, @limit, params['page']
|
|
|
|