|
|
|
@ -112,39 +112,20 @@ class UsersController < ApplicationController
|
|
|
|
|
|
|
|
|
|
#added by young
|
|
|
|
|
def user_projects
|
|
|
|
|
|
|
|
|
|
#add by huang
|
|
|
|
|
unless User.current.admin?
|
|
|
|
|
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
|
|
|
|
|
render_404
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
#end
|
|
|
|
|
# if User.current.admin?
|
|
|
|
|
# @memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}")
|
|
|
|
|
# else
|
|
|
|
|
# cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
|
|
|
|
|
# @memberships = @user.memberships.all(:conditions => cond)
|
|
|
|
|
# end
|
|
|
|
|
#events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
|
|
|
|
|
#@events_by_day = events.group_by(&:event_date)
|
|
|
|
|
# @state = 0
|
|
|
|
|
|
|
|
|
|
limit = 10;
|
|
|
|
|
query = Project.joins("join members m on #{Project.table_name}.id=m.project_id")
|
|
|
|
|
query = query.where("m.user_id = ? and #{Project.table_name}.project_type=?",@user.id,Project::ProjectType_project)
|
|
|
|
|
projects = @user.projects.visible.order("updated_on desc")
|
|
|
|
|
if(params[:status] == '1')
|
|
|
|
|
query = query.where("#{Project.table_name}.user_id = ?",@user.id);
|
|
|
|
|
projects = projects.where("user_id = ?",@user.id)
|
|
|
|
|
elsif(params[:status] == '2')
|
|
|
|
|
query = query.where("#{Project.table_name}.user_id <> ?",@user.id);
|
|
|
|
|
projects = projects.where("user_id <> ?",@user.id)
|
|
|
|
|
end
|
|
|
|
|
@obj_count = query.count();
|
|
|
|
|
|
|
|
|
|
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
|
|
|
|
@list = query.order("#{Project.table_name}.updated_on desc,#{Project.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
|
|
|
|
@params = params
|
|
|
|
|
|
|
|
|
|
@list = paginateHelper projects,10
|
|
|
|
|
@params = params[:status]
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html{render :layout=>'base_users_new'}
|
|
|
|
|
format.api
|
|
|
|
@ -262,57 +243,20 @@ class UsersController < ApplicationController
|
|
|
|
|
def user_courses
|
|
|
|
|
|
|
|
|
|
unless User.current.admin?
|
|
|
|
|
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
|
|
|
|
|
if !@user.active?
|
|
|
|
|
render_404
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#@user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
|
|
|
|
|
|
|
|
|
limit = 10;
|
|
|
|
|
query = Course.joins("join members m on #{Course.table_name}.id=m.course_id")
|
|
|
|
|
query = query.where("m.user_id = ?",@user.id)
|
|
|
|
|
courses = @user.courses.visible.order("created_at desc")
|
|
|
|
|
if(params[:status] == '1')
|
|
|
|
|
query = query.where("endup_time >= ? or endup_time is null or endup_time=''",Time.now);
|
|
|
|
|
courses = courses.where("endup_time >= ? or endup_time is null or endup_time=''",Time.now)
|
|
|
|
|
elsif(params[:status] == '2')
|
|
|
|
|
query = query.where("endup_time < ?",Time.now);
|
|
|
|
|
courses = courses.where("endup_time < ?",Time.now)
|
|
|
|
|
end
|
|
|
|
|
@obj_count = query.count();
|
|
|
|
|
|
|
|
|
|
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
|
|
|
|
@list = query.order("#{Course.table_name}.updated_at desc,#{Course.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
|
|
|
|
@params = params
|
|
|
|
|
@list = paginateHelper courses,10
|
|
|
|
|
@params = params[:status]
|
|
|
|
|
render :layout=>'base_users_new'
|
|
|
|
|
|
|
|
|
|
# if User.current == @user || User.current.admin?
|
|
|
|
|
# membership = @user.coursememberships.all
|
|
|
|
|
# else
|
|
|
|
|
# membership = @user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
# membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
|
|
|
|
# @memberships = []
|
|
|
|
|
# membership.collect { |e|
|
|
|
|
|
# @memberships.push(e)
|
|
|
|
|
# }
|
|
|
|
|
# ## 判断课程是否过期 [需封装]
|
|
|
|
|
# @memberships_doing = []
|
|
|
|
|
# @memberships_done = []
|
|
|
|
|
# #now_time = Time.now.year
|
|
|
|
|
# @memberships.map { |e|
|
|
|
|
|
# #end_time = e.course.get_time.year
|
|
|
|
|
# isDone = course_endTime_timeout?(e.course)
|
|
|
|
|
# if isDone
|
|
|
|
|
# @memberships_done.push e
|
|
|
|
|
# else
|
|
|
|
|
# @memberships_doing.push e
|
|
|
|
|
# end
|
|
|
|
|
# }
|
|
|
|
|
# respond_to do |format|
|
|
|
|
|
# format.html
|
|
|
|
|
# format.api
|
|
|
|
|
# end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# modified by fq
|
|
|
|
@ -482,95 +426,6 @@ class UsersController < ApplicationController
|
|
|
|
|
render :layout=>nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# def user_course_activities
|
|
|
|
|
# @list = []
|
|
|
|
|
# lastid = nil
|
|
|
|
|
# if params[:lastid]!=nil && !params[:lastid].empty?
|
|
|
|
|
# lastid = params[:lastid];
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
# user_ids = []
|
|
|
|
|
# if @user == User.current
|
|
|
|
|
# watcher = User.watched_by(@user)
|
|
|
|
|
# watcher.push(User.current)
|
|
|
|
|
# user_ids = watcher.map{|x| x.id}
|
|
|
|
|
# else
|
|
|
|
|
# user_ids << @user.id
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
# query_rec_count = 8
|
|
|
|
|
# query_times = 10 #query_times次没查到query_rec_count条记录就不查了
|
|
|
|
|
# query_i = 0;
|
|
|
|
|
# while( true )
|
|
|
|
|
# query_i = query_i+1
|
|
|
|
|
# if(query_i>query_times)
|
|
|
|
|
# break
|
|
|
|
|
# end
|
|
|
|
|
# query = Activity.where(user_id: user_ids)
|
|
|
|
|
# if(lastid != nil)
|
|
|
|
|
# query = query.where("id < ?",lastid)
|
|
|
|
|
# end
|
|
|
|
|
# lastid,item_list = query_activities(query,'course');
|
|
|
|
|
# for item in item_list
|
|
|
|
|
# @list << item
|
|
|
|
|
# if @list.count() >= query_rec_count
|
|
|
|
|
# break
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
# if @list.count() >= query_rec_count
|
|
|
|
|
# break
|
|
|
|
|
# end
|
|
|
|
|
# if lastid == nil
|
|
|
|
|
# break
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
# render :layout=>nil
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
# def user_project_activities
|
|
|
|
|
# @list = []
|
|
|
|
|
# lastid = nil
|
|
|
|
|
# if params[:lastid]!=nil && !params[:lastid].empty?
|
|
|
|
|
# lastid = params[:lastid];
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
# user_ids = []
|
|
|
|
|
# if @user == User.current
|
|
|
|
|
# watcher = User.watched_by(@user)
|
|
|
|
|
# watcher.push(User.current)
|
|
|
|
|
# user_ids = watcher.map{|x| x.id}
|
|
|
|
|
# else
|
|
|
|
|
# user_ids << @user.id
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
# query_rec_count = 8
|
|
|
|
|
# query_times = 10 #query_times次没查到query_rec_count条记录就不查了
|
|
|
|
|
# query_i = 0;
|
|
|
|
|
# while( true )
|
|
|
|
|
# query_i = query_i+1
|
|
|
|
|
# if(query_i>query_times)
|
|
|
|
|
# break
|
|
|
|
|
# end
|
|
|
|
|
# query = Activity.where(user_id: user_ids)
|
|
|
|
|
# if(lastid != nil)
|
|
|
|
|
# query = query.where("id < ?",lastid)
|
|
|
|
|
# end
|
|
|
|
|
# lastid,item_list = query_activities(query,'project');
|
|
|
|
|
# for item in item_list
|
|
|
|
|
# @list << item
|
|
|
|
|
# if @list.count() >= query_rec_count
|
|
|
|
|
# break
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
# if @list.count() >= query_rec_count
|
|
|
|
|
# break
|
|
|
|
|
# end
|
|
|
|
|
# if lastid == nil
|
|
|
|
|
# break
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
# render :action=>'user_course_activities',:layout=>nil
|
|
|
|
|
# end
|
|
|
|
|
def user_course_activities
|
|
|
|
|
lastid = nil
|
|
|
|
|
if params[:lastid]!=nil && !params[:lastid].empty?
|
|
|
|
@ -629,7 +484,7 @@ class UsersController < ApplicationController
|
|
|
|
|
query = query.where("#{Activity.table_name}.id < ?",lastid)
|
|
|
|
|
end
|
|
|
|
|
query = query.order("#{Activity.table_name}.id desc")
|
|
|
|
|
@list = query_activities(query);
|
|
|
|
|
@list = query_activities(query)
|
|
|
|
|
|
|
|
|
|
render :action=>'user_course_activities',:layout=>nil
|
|
|
|
|
end
|
|
|
|
|