|
|
@ -499,7 +499,7 @@ class UsersController < ApplicationController
|
|
|
|
when nil
|
|
|
|
when nil
|
|
|
|
# 系统消息为管理员发送,我的消息中包含有系统消息
|
|
|
|
# 系统消息为管理员发送,我的消息中包含有系统消息
|
|
|
|
@message_alls = []
|
|
|
|
@message_alls = []
|
|
|
|
messages = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" ,@user.id, "SystemMessage", "SystemMessage").includes(:message).order("created_at desc")
|
|
|
|
messages = MessageAll.where(:user_id => @user.id).includes(:message).order("created_at desc")
|
|
|
|
messages.each do |message_all|
|
|
|
|
messages.each do |message_all|
|
|
|
|
mess = message_all.message
|
|
|
|
mess = message_all.message
|
|
|
|
unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1)
|
|
|
|
unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1)
|
|
|
@ -2298,16 +2298,15 @@ class UsersController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@message_count = @message_alls.count
|
|
|
|
@message_count = @message_alls.count
|
|
|
|
@message_alls = paginateHelper @message_alls, 20
|
|
|
|
@message_alls = paginateHelper @message_alls, 20
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 课程社区
|
|
|
|
# 课程社区
|
|
|
|
def course_community
|
|
|
|
def course_community
|
|
|
|
@course_community = "课程"
|
|
|
|
@course_community = "课程"
|
|
|
|
if params[:course_id] != nil
|
|
|
|
if params[:course_id] != nil
|
|
|
|
join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?",
|
|
|
|
join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?",
|
|
|
@ -2373,10 +2372,10 @@ def course_community
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
format.html {render :layout => 'base_course_community'}
|
|
|
|
format.html {render :layout => 'base_course_community'}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 项目社区
|
|
|
|
# 项目社区
|
|
|
|
def project_community
|
|
|
|
def project_community
|
|
|
|
# 看别人的主页显示动态
|
|
|
|
# 看别人的主页显示动态
|
|
|
|
#更新用户申请成为课程老师或教辅消息的状态
|
|
|
|
#更新用户申请成为课程老师或教辅消息的状态
|
|
|
|
@project_community = "项目"
|
|
|
|
@project_community = "项目"
|
|
|
@ -2426,10 +2425,10 @@ def project_community
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
format.html {render :layout => 'base_project_community'}
|
|
|
|
format.html {render :layout => 'base_project_community'}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 竞赛社区
|
|
|
|
# 竞赛社区
|
|
|
|
def contest_community
|
|
|
|
def contest_community
|
|
|
|
@contest_community = "竞赛"
|
|
|
|
@contest_community = "竞赛"
|
|
|
|
shield_contest_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Contest'").map(&:shield_id)
|
|
|
|
shield_contest_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Contest'").map(&:shield_id)
|
|
|
|
@page = params[:page] ? params[:page].to_i + 1 : 0
|
|
|
|
@page = params[:page] ? params[:page].to_i + 1 : 0
|
|
|
@ -2482,9 +2481,9 @@ def contest_community
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
format.html {render :layout => 'base_contest_community'}
|
|
|
|
format.html {render :layout => 'base_contest_community'}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def show_old
|
|
|
|
def show_old
|
|
|
|
pre_count = 10 #limit
|
|
|
|
pre_count = 10 #limit
|
|
|
|
# Time 2015-02-04 11:46:34
|
|
|
|
# Time 2015-02-04 11:46:34
|
|
|
|
# Author lizanle
|
|
|
|
# Author lizanle
|
|
|
@ -2630,7 +2629,7 @@ def show_old
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Modified by nie
|
|
|
|
#Modified by nie
|
|
|
|
unless User.current.admin?
|
|
|
|
unless User.current.admin?
|
|
|
|
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
|
|
|
|
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
|
|
|
|
# redirect_to home_path
|
|
|
|
# redirect_to home_path
|
|
|
@ -2643,12 +2642,12 @@ def show_old
|
|
|
|
format.html
|
|
|
|
format.html
|
|
|
|
format.api
|
|
|
|
format.api
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
##end fq
|
|
|
|
##end fq
|
|
|
|
|
|
|
|
|
|
|
|
#### added by fq
|
|
|
|
#### added by fq
|
|
|
|
def info
|
|
|
|
def info
|
|
|
|
|
|
|
|
|
|
|
|
message = []
|
|
|
|
message = []
|
|
|
|
if @user == User.current
|
|
|
|
if @user == User.current
|
|
|
@ -2675,17 +2674,17 @@ def info
|
|
|
|
format.html
|
|
|
|
format.html
|
|
|
|
format.api
|
|
|
|
format.api
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
#### end
|
|
|
|
#### end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def new
|
|
|
|
def new
|
|
|
|
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
|
|
|
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
|
|
|
@auth_sources = AuthSource.all
|
|
|
|
@auth_sources = AuthSource.all
|
|
|
|
render :layout => "users_base"
|
|
|
|
render :layout => "users_base"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
def create
|
|
|
|
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
|
|
|
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
|
|
|
|
@user.safe_attributes = params[:user]
|
|
|
|
@user.safe_attributes = params[:user]
|
|
|
|
@user.admin = params[:user][:admin] || false
|
|
|
|
@user.admin = params[:user][:admin] || false
|
|
|
@ -2729,14 +2728,14 @@ def create
|
|
|
|
:user_id => @user.id)
|
|
|
|
:user_id => @user.id)
|
|
|
|
ue.save
|
|
|
|
ue.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def edit
|
|
|
|
def edit
|
|
|
|
@auth_sources = AuthSource.all
|
|
|
|
@auth_sources = AuthSource.all
|
|
|
|
@membership ||= Member.new
|
|
|
|
@membership ||= Member.new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def watch_projects
|
|
|
|
def watch_projects
|
|
|
|
@watch_projects = Project.joins(:watchers).where("project_type <>? and watchable_type = ? and `watchers`.user_id = ?", '1','Project', @user.id)
|
|
|
|
@watch_projects = Project.joins(:watchers).where("project_type <>? and watchable_type = ? and `watchers`.user_id = ?", '1','Project', @user.id)
|
|
|
|
@state = 1
|
|
|
|
@state = 1
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
@ -2745,9 +2744,9 @@ def watch_projects
|
|
|
|
}
|
|
|
|
}
|
|
|
|
format.api
|
|
|
|
format.api
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
def update
|
|
|
|
@user.admin = params[:user][:admin] if params[:user][:admin]
|
|
|
|
@user.admin = params[:user][:admin] if params[:user][:admin]
|
|
|
|
@user.login = params[:user][:login] if params[:user][:login]
|
|
|
|
@user.login = params[:user][:login] if params[:user][:login]
|
|
|
|
if params[:user][:password].present? && (@user.auth_source_id.nil? || params[:user][:auth_source_id].blank?)
|
|
|
|
if params[:user][:password].present? && (@user.auth_source_id.nil? || params[:user][:auth_source_id].blank?)
|
|
|
@ -2788,10 +2787,10 @@ def update
|
|
|
|
format.api { render_validation_errors(@user) }
|
|
|
|
format.api { render_validation_errors(@user) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 上传用户资源
|
|
|
|
# 上传用户资源
|
|
|
|
def user_resource_create
|
|
|
|
def user_resource_create
|
|
|
|
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
|
|
|
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
|
|
|
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
|
|
|
|
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
|
|
|
|
# user_org_ids = User.current.organizations.map {|o| o.id}
|
|
|
|
# user_org_ids = User.current.organizations.map {|o| o.id}
|
|
|
@ -2843,10 +2842,10 @@ def user_resource_create
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源
|
|
|
|
# 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源
|
|
|
|
def user_resource_delete
|
|
|
|
def user_resource_delete
|
|
|
|
if params[:resource_id].present?
|
|
|
|
if params[:resource_id].present?
|
|
|
|
Attachment.where("author_id =? and id =?", User.current.id, params[:resource_id]).first.destroy
|
|
|
|
Attachment.where("author_id =? and id =?", User.current.id, params[:resource_id]).first.destroy
|
|
|
|
elsif params[:checkbox1].present?
|
|
|
|
elsif params[:checkbox1].present?
|
|
|
@ -2901,10 +2900,10 @@ def user_resource_delete
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#根据id或者名称搜索教师或者助教为当前用户的课程
|
|
|
|
#根据id或者名称搜索教师或者助教为当前用户的课程
|
|
|
|
def search_user_course
|
|
|
|
def search_user_course
|
|
|
|
@user = User.current
|
|
|
|
@user = User.current
|
|
|
|
if !params[:search].nil?
|
|
|
|
if !params[:search].nil?
|
|
|
|
search = "%#{params[:search].to_s.strip.downcase}%"
|
|
|
|
search = "%#{params[:search].to_s.strip.downcase}%"
|
|
|
@ -2921,10 +2920,10 @@ def search_user_course
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 根据id或者名称搜索当前用户所在的项目
|
|
|
|
# 根据id或者名称搜索当前用户所在的项目
|
|
|
|
def search_user_project
|
|
|
|
def search_user_project
|
|
|
|
@user = User.current
|
|
|
|
@user = User.current
|
|
|
|
if !params[:search].nil?
|
|
|
|
if !params[:search].nil?
|
|
|
|
search = "%#{params[:search].to_s.strip.downcase}%"
|
|
|
|
search = "%#{params[:search].to_s.strip.downcase}%"
|
|
|
@ -2941,10 +2940,10 @@ def search_user_project
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 将资源发送到对应的课程,分为发送单个,或者批量发送
|
|
|
|
# 将资源发送到对应的课程,分为发送单个,或者批量发送
|
|
|
|
def add_exist_file_to_course
|
|
|
|
def add_exist_file_to_course
|
|
|
|
@flag = true
|
|
|
|
@flag = true
|
|
|
|
if params[:send_id].present?
|
|
|
|
if params[:send_id].present?
|
|
|
|
rs = ResourcesService.new
|
|
|
|
rs = ResourcesService.new
|
|
|
@ -3052,10 +3051,10 @@ def add_exist_file_to_course
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 添加资源到对应的项目
|
|
|
|
# 添加资源到对应的项目
|
|
|
|
def add_exist_file_to_project
|
|
|
|
def add_exist_file_to_project
|
|
|
|
@flag = true
|
|
|
|
@flag = true
|
|
|
|
# 发送单个资源
|
|
|
|
# 发送单个资源
|
|
|
|
if params[:send_id].present?
|
|
|
|
if params[:send_id].present?
|
|
|
@ -3213,9 +3212,9 @@ def add_exist_file_to_project
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def add_exist_file_to_org
|
|
|
|
def add_exist_file_to_org
|
|
|
|
@flag = true
|
|
|
|
@flag = true
|
|
|
|
if params[:send_id].present?
|
|
|
|
if params[:send_id].present?
|
|
|
|
send_id = params[:send_id]
|
|
|
|
send_id = params[:send_id]
|
|
|
@ -3353,9 +3352,9 @@ def add_exist_file_to_org
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def share_news_to_course
|
|
|
|
def share_news_to_course
|
|
|
|
news = News.find(params[:send_id])
|
|
|
|
news = News.find(params[:send_id])
|
|
|
|
course_ids = params[:course_ids]
|
|
|
|
course_ids = params[:course_ids]
|
|
|
|
course_ids.each do |course_id|
|
|
|
|
course_ids.each do |course_id|
|
|
|
@ -3372,9 +3371,9 @@ def share_news_to_course
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def share_news_to_project
|
|
|
|
def share_news_to_project
|
|
|
|
news = News.find(params[:send_id])
|
|
|
|
news = News.find(params[:send_id])
|
|
|
|
project_ids = params[:project_ids]
|
|
|
|
project_ids = params[:project_ids]
|
|
|
|
project_ids.each do |project_id|
|
|
|
|
project_ids.each do |project_id|
|
|
|
@ -3393,9 +3392,9 @@ def share_news_to_project
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def share_news_to_org
|
|
|
|
def share_news_to_org
|
|
|
|
news = News.find(params[:send_id])
|
|
|
|
news = News.find(params[:send_id])
|
|
|
|
field_id = params[:subfield]
|
|
|
|
field_id = params[:subfield]
|
|
|
|
org_news = News.create(:org_subfield_id => field_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1)
|
|
|
|
org_news = News.create(:org_subfield_id => field_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1)
|
|
|
@ -3409,9 +3408,9 @@ def share_news_to_org
|
|
|
|
:is_public => attach.is_public, :quotes => 0)
|
|
|
|
:is_public => attach.is_public, :quotes => 0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'News', :org_act_id => org_news.id, :user_id => User.current.id)
|
|
|
|
OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'News', :org_act_id => org_news.id, :user_id => User.current.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def share_message_to_course
|
|
|
|
def share_message_to_course
|
|
|
|
@message = Message.find(params[:send_id])
|
|
|
|
@message = Message.find(params[:send_id])
|
|
|
|
course_ids = params[:course_ids]
|
|
|
|
course_ids = params[:course_ids]
|
|
|
|
course_ids.each do |course_id|
|
|
|
|
course_ids.each do |course_id|
|
|
|
@ -3429,9 +3428,9 @@ def share_message_to_course
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def share_message_to_project
|
|
|
|
def share_message_to_project
|
|
|
|
@message = Message.find(params[:send_id])
|
|
|
|
@message = Message.find(params[:send_id])
|
|
|
|
project_ids = params[:project_ids]
|
|
|
|
project_ids = params[:project_ids]
|
|
|
|
project_ids.each do |project_id|
|
|
|
|
project_ids.each do |project_id|
|
|
|
@ -3449,9 +3448,9 @@ def share_message_to_project
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def share_message_to_org
|
|
|
|
def share_message_to_org
|
|
|
|
field_id = params[:subfield]
|
|
|
|
field_id = params[:subfield]
|
|
|
|
@message = Message.find(params[:send_id])
|
|
|
|
@message = Message.find(params[:send_id])
|
|
|
|
@message.quotes = @message.quotes.nil? ? 1 : (@message.quotes + 1)
|
|
|
|
@message.quotes = @message.quotes.nil? ? 1 : (@message.quotes + 1)
|
|
|
@ -3468,14 +3467,14 @@ def share_message_to_org
|
|
|
|
:is_public => attach.is_public, :quotes => 0)
|
|
|
|
:is_public => attach.is_public, :quotes => 0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'Message', :org_act_id => mes.id, :user_id => User.current.id)
|
|
|
|
OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'Message', :org_act_id => mes.id, :user_id => User.current.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def change_org_subfield
|
|
|
|
def change_org_subfield
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 资源预览
|
|
|
|
# 资源预览
|
|
|
|
def resource_preview
|
|
|
|
def resource_preview
|
|
|
|
preview_id = params[:resource_id]
|
|
|
|
preview_id = params[:resource_id]
|
|
|
|
@file = Attachment.find(preview_id)
|
|
|
|
@file = Attachment.find(preview_id)
|
|
|
|
@preview_able = false;
|
|
|
|
@preview_able = false;
|
|
|
@ -3485,10 +3484,10 @@ def resource_preview
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 重命名资源
|
|
|
|
# 重命名资源
|
|
|
|
def rename_resource
|
|
|
|
def rename_resource
|
|
|
|
@attachment = Attachment.find(params[:res_id]) if params[:res_id].present?
|
|
|
|
@attachment = Attachment.find(params[:res_id]) if params[:res_id].present?
|
|
|
|
if @attachment != nil
|
|
|
|
if @attachment != nil
|
|
|
|
@attachment.filename = params[:res_name]
|
|
|
|
@attachment.filename = params[:res_name]
|
|
|
@ -3502,26 +3501,26 @@ def rename_resource
|
|
|
|
else
|
|
|
|
else
|
|
|
|
render :text=>'fail'
|
|
|
|
render :text=>'fail'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
def destroy
|
|
|
|
@user.destroy
|
|
|
|
@user.destroy
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_back_or_default(admin_users_path) }
|
|
|
|
format.html { redirect_back_or_default(admin_users_path) }
|
|
|
|
format.api { render_api_ok }
|
|
|
|
format.api { render_api_ok }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def edit_membership
|
|
|
|
def edit_membership
|
|
|
|
@membership = Member.edit_membership(params[:membership_id], params[:membership], @user)
|
|
|
|
@membership = Member.edit_membership(params[:membership_id], params[:membership], @user)
|
|
|
|
@membership.save
|
|
|
|
@membership.save
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to edit_user_url(@user, :tab => 'memberships') }
|
|
|
|
format.html { redirect_to edit_user_url(@user, :tab => 'memberships') }
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def destroy_membership
|
|
|
|
def destroy_membership
|
|
|
|
@membership = Member.find(params[:membership_id])
|
|
|
|
@membership = Member.find(params[:membership_id])
|
|
|
|
if @membership.deletable?
|
|
|
|
if @membership.deletable?
|
|
|
|
@membership.destroy
|
|
|
|
@membership.destroy
|
|
|
@ -3530,10 +3529,10 @@ def destroy_membership
|
|
|
|
format.html { redirect_to edit_user_url(@user, :tab => 'memberships') }
|
|
|
|
format.html { redirect_to edit_user_url(@user, :tab => 'memberships') }
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
################# added by william
|
|
|
|
################# added by william
|
|
|
|
def tag_save
|
|
|
|
def tag_save
|
|
|
|
@tags = params[:tag_for_save][:name]
|
|
|
|
@tags = params[:tag_for_save][:name]
|
|
|
|
@obj_id = params[:tag_for_save][:object_id]
|
|
|
|
@obj_id = params[:tag_for_save][:object_id]
|
|
|
|
@obj_flag = params[:tag_for_save][:object_flag]
|
|
|
|
@obj_flag = params[:tag_for_save][:object_flag]
|
|
|
@ -3574,9 +3573,9 @@ def tag_save
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
format.html
|
|
|
|
format.html
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def tag_saveEx
|
|
|
|
def tag_saveEx
|
|
|
|
@tags = params[:tag_name]
|
|
|
|
@tags = params[:tag_name]
|
|
|
|
@obj_id = params[:obj_id]
|
|
|
|
@obj_id = params[:obj_id]
|
|
|
|
@obj_flag = params[:obj_flag]
|
|
|
|
@obj_flag = params[:obj_flag]
|
|
|
@ -3617,9 +3616,9 @@ def tag_saveEx
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
format.html
|
|
|
|
format.html
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
###add by huang
|
|
|
|
###add by huang
|
|
|
|
def user_watchlist
|
|
|
|
def user_watchlist
|
|
|
|
limit = 10;
|
|
|
|
limit = 10;
|
|
|
|
query = User.watched_by(@user.id);
|
|
|
|
query = User.watched_by(@user.id);
|
|
|
|
@obj_count = query.count();
|
|
|
|
@obj_count = query.count();
|
|
|
@ -3627,9 +3626,9 @@ def user_watchlist
|
|
|
|
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
|
|
|
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
|
|
|
@action = 'watch'
|
|
|
|
@action = 'watch'
|
|
|
|
render :template=>'users/user_fanslist',:layout=>'new_base_user'
|
|
|
|
render :template=>'users/user_fanslist',:layout=>'new_base_user'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
###add by huang
|
|
|
|
###add by huang
|
|
|
|
def user_fanslist
|
|
|
|
def user_fanslist
|
|
|
|
limit = 10;
|
|
|
|
limit = 10;
|
|
|
|
query = @user.watcher_users;
|
|
|
|
query = @user.watcher_users;
|
|
|
|
@obj_count = query.count();
|
|
|
|
@obj_count = query.count();
|
|
|
@ -3637,8 +3636,8 @@ def user_fanslist
|
|
|
|
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
|
|
|
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
|
|
|
@action = 'fans'
|
|
|
|
@action = 'fans'
|
|
|
|
render :layout=>'new_base_user'
|
|
|
|
render :layout=>'new_base_user'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def user_visitorlist
|
|
|
|
def user_visitorlist
|
|
|
|
limit = 10;
|
|
|
|
limit = 10;
|
|
|
|
#query = @user.watcher_users;
|
|
|
|
#query = @user.watcher_users;
|
|
|
|
query = User.joins("join visitors v on #{User.table_name}.id=v.user_id")
|
|
|
|
query = User.joins("join visitors v on #{User.table_name}.id=v.user_id")
|
|
|
@ -3648,62 +3647,62 @@ def user_visitorlist
|
|
|
|
@list = query.order("v.updated_on desc").limit(limit).offset(@obj_pages.offset).all();
|
|
|
|
@list = query.order("v.updated_on desc").limit(limit).offset(@obj_pages.offset).all();
|
|
|
|
@action = 'visitor'
|
|
|
|
@action = 'visitor'
|
|
|
|
render :template=>'users/user_fanslist',:layout=>'base_users_new'
|
|
|
|
render :template=>'users/user_fanslist',:layout=>'base_users_new'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#william
|
|
|
|
#william
|
|
|
|
def update_extensions(user_extensions)
|
|
|
|
def update_extensions(user_extensions)
|
|
|
|
user_extensions = params[:user_extensions]
|
|
|
|
user_extensions = params[:user_extensions]
|
|
|
|
unless user_extensions.nil?
|
|
|
|
unless user_extensions.nil?
|
|
|
|
user_extensions = UserExtensions.find_by_id(user_extensions.user_id)
|
|
|
|
user_extensions = UserExtensions.find_by_id(user_extensions.user_id)
|
|
|
|
|
|
|
|
|
|
|
|
# user_extensions.
|
|
|
|
# user_extensions.
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def update_score
|
|
|
|
def update_score
|
|
|
|
@user = User.find(params[:id])
|
|
|
|
@user = User.find(params[:id])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#修改个人简介
|
|
|
|
#修改个人简介
|
|
|
|
def edit_brief_introduction
|
|
|
|
def edit_brief_introduction
|
|
|
|
if @user && @user.extensions
|
|
|
|
if @user && @user.extensions
|
|
|
|
@user.extensions.update_column("brief_introduction",params[:brief_introduction])
|
|
|
|
@user.extensions.update_column("brief_introduction",params[:brief_introduction])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取公共资源
|
|
|
|
# 获取公共资源
|
|
|
|
def get_public_resources user_course_ids, user_project_ids, order, score
|
|
|
|
def get_public_resources user_course_ids, user_project_ids, order, score
|
|
|
|
attachments = Attachment.where("(is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
attachments = Attachment.where("(is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取公共资源搜索
|
|
|
|
# 获取公共资源搜索
|
|
|
|
def get_public_resources_search user_course_ids, user_project_ids, order, score, search
|
|
|
|
def get_public_resources_search user_course_ids, user_project_ids, order, score, search
|
|
|
|
attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取我的资源
|
|
|
|
# 获取我的资源
|
|
|
|
def get_my_resources author_id, user_course_ids, user_project_ids, order, score
|
|
|
|
def get_my_resources author_id, user_course_ids, user_project_ids, order, score
|
|
|
|
attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('OrgSubfield','Principal','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
|
|
|
|
attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('OrgSubfield','Principal','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
|
|
|
|
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
|
|
|
|
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
|
|
|
|
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取我的资源查询结果
|
|
|
|
# 获取我的资源查询结果
|
|
|
|
def get_my_resources_search (author_id, user_course_ids, user_project_ids, order, score, search)
|
|
|
|
def get_my_resources_search (author_id, user_course_ids, user_project_ids, order, score, search)
|
|
|
|
@attachments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
|
|
|
|
@attachments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
|
|
|
|
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
|
|
|
|
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
|
|
|
|
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取我的课程资源
|
|
|
|
# 获取我的课程资源
|
|
|
|
def get_course_resources author_id, user_course_ids, order, score
|
|
|
|
def get_course_resources author_id, user_course_ids, order, score
|
|
|
|
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and container_type = 'Course')"+
|
|
|
|
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and container_type = 'Course')"+
|
|
|
|
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})
|
|
|
|
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})
|
|
|
|
and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# # 获取我的私有资源分享结果
|
|
|
|
# # 获取我的私有资源分享结果
|
|
|
|
# def get_my_private_resources apply_ids, resource_type, order, score
|
|
|
|
# def get_my_private_resources apply_ids, resource_type, order, score
|
|
|
@ -3716,92 +3715,92 @@ end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取我的课程资源中搜索结果
|
|
|
|
# 获取我的课程资源中搜索结果
|
|
|
|
def get_course_resources_search author_id, user_course_ids, order, score, search
|
|
|
|
def get_course_resources_search author_id, user_course_ids, order, score, search
|
|
|
|
attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+
|
|
|
|
attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+
|
|
|
|
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})
|
|
|
|
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})
|
|
|
|
and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取公共资源中课程资源
|
|
|
|
# 获取公共资源中课程资源
|
|
|
|
def get_course_resources_public user_course_ids, order, score
|
|
|
|
def get_course_resources_public user_course_ids, order, score
|
|
|
|
attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1)").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1)").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取公共资源中课程资源搜索结果
|
|
|
|
# 获取公共资源中课程资源搜索结果
|
|
|
|
def get_course_resources_public_search user_course_ids, order, score, search
|
|
|
|
def get_course_resources_public_search user_course_ids, order, score, search
|
|
|
|
attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取我的项目资源
|
|
|
|
# 获取我的项目资源
|
|
|
|
def get_project_resources author_id, user_project_ids, order, score
|
|
|
|
def get_project_resources author_id, user_project_ids, order, score
|
|
|
|
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+
|
|
|
|
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+
|
|
|
|
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')})
|
|
|
|
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')})
|
|
|
|
and is_publish = 1 and container_id is not null)").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
and is_publish = 1 and container_id is not null)").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取我的项目资源搜索
|
|
|
|
# 获取我的项目资源搜索
|
|
|
|
def get_project_resources_search author_id, user_project_ids, order, score, search
|
|
|
|
def get_project_resources_search author_id, user_project_ids, order, score, search
|
|
|
|
attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+
|
|
|
|
attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+
|
|
|
|
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')})
|
|
|
|
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')})
|
|
|
|
and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取公共资源的项目资源
|
|
|
|
# 获取公共资源的项目资源
|
|
|
|
def get_project_resources_public user_project_ids, order, score
|
|
|
|
def get_project_resources_public user_project_ids, order, score
|
|
|
|
attchments = Attachment.where("container_type = 'Project' and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
attchments = Attachment.where("container_type = 'Project' and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取公共资源的项目资源搜索
|
|
|
|
# 获取公共资源的项目资源搜索
|
|
|
|
def get_project_resources_public_search user_project_ids, order, score, search
|
|
|
|
def get_project_resources_public_search user_project_ids, order, score, search
|
|
|
|
attchments = Attachment.where("(container_type = 'Project' and container_id is not null and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
attchments = Attachment.where("(container_type = 'Project' and container_id is not null and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取我上传的附件
|
|
|
|
# 获取我上传的附件
|
|
|
|
def get_attch_resources author_id, order, score
|
|
|
|
def get_attch_resources author_id, order, score
|
|
|
|
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue',
|
|
|
|
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue',
|
|
|
|
'Document','Message','News','StudentWorkScore','HomewCommon'))").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
'Document','Message','News','StudentWorkScore','HomewCommon'))").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取我上传的附件搜索结果
|
|
|
|
# 获取我上传的附件搜索结果
|
|
|
|
def get_attch_resources_search author_id, order, score, search
|
|
|
|
def get_attch_resources_search author_id, order, score, search
|
|
|
|
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue',
|
|
|
|
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue',
|
|
|
|
'Document','Message','News','StudentWorkScore','HomewCommon')) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
'Document','Message','News','StudentWorkScore','HomewCommon')) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取公共资源中我上传的附件
|
|
|
|
# 获取公共资源中我上传的附件
|
|
|
|
def get_attch_resources_public order, score
|
|
|
|
def get_attch_resources_public order, score
|
|
|
|
attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
|
|
|
|
attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
|
|
|
|
and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取公共资源中我上传的附件
|
|
|
|
# 获取公共资源中我上传的附件
|
|
|
|
def get_attch_resources_public_search order, score, search
|
|
|
|
def get_attch_resources_public_search order, score, search
|
|
|
|
attchments = Attachment.where("(container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
|
|
|
|
attchments = Attachment.where("(container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
|
|
|
|
and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取我的用户类型资源
|
|
|
|
# 获取我的用户类型资源
|
|
|
|
def get_principal_resources author_id, order, score
|
|
|
|
def get_principal_resources author_id, order, score
|
|
|
|
attchments = Attachment.where("author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
attchments = Attachment.where("author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取我的用户类型资源搜索
|
|
|
|
# 获取我的用户类型资源搜索
|
|
|
|
def get_principal_resources_search author_id, order, score, search
|
|
|
|
def get_principal_resources_search author_id, order, score, search
|
|
|
|
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取我的用户类型资源
|
|
|
|
# 获取我的用户类型资源
|
|
|
|
def get_principal_resources_public order, score
|
|
|
|
def get_principal_resources_public order, score
|
|
|
|
attchments = Attachment.where("container_type = 'Principal' and is_public =1 and container_id is not null").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
attchments = Attachment.where("container_type = 'Principal' and is_public =1 and container_id is not null").order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 获取我的用户类型资源
|
|
|
|
# 获取我的用户类型资源
|
|
|
|
def get_principal_resources_public_search order, score, search
|
|
|
|
def get_principal_resources_public_search order, score, search
|
|
|
|
attchments = Attachment.where("(container_type = 'Principal'and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
attchments = Attachment.where("(container_type = 'Principal'and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 资源库 分为全部 课程资源 项目资源 附件
|
|
|
|
# 资源库 分为全部 课程资源 项目资源 附件
|
|
|
|
def user_resource
|
|
|
|
def user_resource
|
|
|
|
# 别人的资源库是没有权限去看的
|
|
|
|
# 别人的资源库是没有权限去看的
|
|
|
|
if User.current.id.to_i != @user.id.to_i
|
|
|
|
if User.current.id.to_i != @user.id.to_i
|
|
|
|
render_403
|
|
|
|
render_403
|
|
|
@ -3865,10 +3864,10 @@ def user_resource
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
format.html {render :layout => 'new_base'}
|
|
|
|
format.html {render :layout => 'new_base'}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 导入资源
|
|
|
|
# 导入资源
|
|
|
|
def import_resources
|
|
|
|
def import_resources
|
|
|
|
@resource_id = params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id]
|
|
|
|
@resource_id = params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id]
|
|
|
|
@resource_type = params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project"
|
|
|
|
@resource_type = params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project"
|
|
|
|
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
|
|
|
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
|
|
@ -3895,9 +3894,9 @@ def import_resources
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
format.html {render :layout => 'new_base'}
|
|
|
|
format.html {render :layout => 'new_base'}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def import_resources_search
|
|
|
|
def import_resources_search
|
|
|
|
@resource_id = params[:mul_id]
|
|
|
|
@resource_id = params[:mul_id]
|
|
|
|
@resource_type = params[:mul_type]
|
|
|
|
@resource_type = params[:mul_type]
|
|
|
|
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
|
|
|
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
|
|
@ -3928,10 +3927,10 @@ def import_resources_search
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
# format.html {render :layout => 'new_base'}
|
|
|
|
# format.html {render :layout => 'new_base'}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 内容导入到对象中
|
|
|
|
# 内容导入到对象中
|
|
|
|
def import_into_container
|
|
|
|
def import_into_container
|
|
|
|
send_ids = params[:checkbox1]
|
|
|
|
send_ids = params[:checkbox1]
|
|
|
|
# mul_id为当前课程id、项目id、组织id的多种形态
|
|
|
|
# mul_id为当前课程id、项目id、组织id的多种形态
|
|
|
|
mul_id = params[:mul_id]
|
|
|
|
mul_id = params[:mul_id]
|
|
|
@ -3985,10 +3984,10 @@ def import_into_container
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 根据资源关键字进行搜索
|
|
|
|
# 根据资源关键字进行搜索
|
|
|
|
def resource_search
|
|
|
|
def resource_search
|
|
|
|
@order, @b_sort = params[:order] || "created_on", params[:sort] || "desc"
|
|
|
|
@order, @b_sort = params[:order] || "created_on", params[:sort] || "desc"
|
|
|
|
@score = @b_sort == "desc" ? "asc" : "desc"
|
|
|
|
@score = @b_sort == "desc" ? "asc" : "desc"
|
|
|
|
@user = User.current
|
|
|
|
@user = User.current
|
|
|
@ -4048,17 +4047,17 @@ def resource_search
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def user_organizations
|
|
|
|
def user_organizations
|
|
|
|
@user = User.current
|
|
|
|
@user = User.current
|
|
|
|
@orgs = @user.organizations
|
|
|
|
@orgs = @user.organizations
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html {render :layout => 'static_base'}
|
|
|
|
format.html {render :layout => 'static_base'}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def search_user_orgs
|
|
|
|
def search_user_orgs
|
|
|
|
name=""
|
|
|
|
name=""
|
|
|
|
if !params[:search_orgs].nil?
|
|
|
|
if !params[:search_orgs].nil?
|
|
|
|
name = params[:search_orgs].strip
|
|
|
|
name = params[:search_orgs].strip
|
|
|
@ -4071,9 +4070,9 @@ def search_user_orgs
|
|
|
|
format.html {render :layout => 'static_base'}
|
|
|
|
format.html {render :layout => 'static_base'}
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def search_user_org
|
|
|
|
def search_user_org
|
|
|
|
@user = User.current
|
|
|
|
@user = User.current
|
|
|
|
if !params[:search].nil? #发送到有栏目类型为资源的组织中
|
|
|
|
if !params[:search].nil? #发送到有栏目类型为资源的组织中
|
|
|
|
search = "%#{params[:search].to_s.strip.downcase}%"
|
|
|
|
search = "%#{params[:search].to_s.strip.downcase}%"
|
|
|
@ -4098,9 +4097,9 @@ def search_user_org
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def user_courselist
|
|
|
|
def user_courselist
|
|
|
|
@order, @c_sort, @type, @list_type = 1, 2, 1, 1
|
|
|
|
@order, @c_sort, @type, @list_type = 1, 2, 1, 1
|
|
|
|
|
|
|
|
|
|
|
|
@my_syllabuses = @user.syllabuses
|
|
|
|
@my_syllabuses = @user.syllabuses
|
|
|
@ -4133,10 +4132,10 @@ def user_courselist
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html {render :layout => 'base_course_community'}
|
|
|
|
format.html {render :layout => 'base_course_community'}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#课程列表的排序
|
|
|
|
#课程列表的排序
|
|
|
|
def sort_syllabus_list
|
|
|
|
def sort_syllabus_list
|
|
|
|
@order, @c_sort, @type, @list_type = params[:order] || 1, params[:sort] || 1, params[:type] || 1, params[:list_type] || 1
|
|
|
|
@order, @c_sort, @type, @list_type = params[:order] || 1, params[:sort] || 1, params[:type] || 1, params[:list_type] || 1
|
|
|
|
|
|
|
|
|
|
|
|
#确定 sort_type
|
|
|
|
#确定 sort_type
|
|
|
@ -4179,10 +4178,10 @@ def sort_syllabus_list
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#归档班级列表
|
|
|
|
# 归档班级列表
|
|
|
|
def user_archive_courses
|
|
|
|
def user_archive_courses
|
|
|
|
if User.current.logged?
|
|
|
|
if User.current.logged?
|
|
|
|
@order, @c_sort, @type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
|
|
|
|
@order, @c_sort, @type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
|
|
|
|
|
|
|
|
|
|
|
@ -4222,10 +4221,10 @@ def user_archive_courses
|
|
|
|
format.html {render :layout => 'base_course_community'}
|
|
|
|
format.html {render :layout => 'base_course_community'}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#展开课程下的班级
|
|
|
|
# 展开课程下的班级
|
|
|
|
def expand_courses
|
|
|
|
def expand_courses
|
|
|
|
@syllabus = Syllabus.where("id = #{params[:syllabus_id]}").first
|
|
|
|
@syllabus = Syllabus.where("id = #{params[:syllabus_id]}").first
|
|
|
|
unless @syllabus.nil?
|
|
|
|
unless @syllabus.nil?
|
|
|
|
if params[:is_delete] && params[:is_delete] == '1'
|
|
|
|
if params[:is_delete] && params[:is_delete] == '1'
|
|
|
@ -4237,10 +4236,10 @@ def expand_courses
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#收藏班级/项目/竞赛
|
|
|
|
# 收藏班级/项目/竞赛
|
|
|
|
def cancel_or_collect
|
|
|
|
def cancel_or_collect
|
|
|
|
if params[:project]
|
|
|
|
if params[:project]
|
|
|
|
@project = Project.find params[:project]
|
|
|
|
@project = Project.find params[:project]
|
|
|
|
member = Member.where("user_id = #{@user.id} and project_id = #{@project.id}")
|
|
|
|
member = Member.where("user_id = #{@user.id} and project_id = #{@project.id}")
|
|
|
@ -4266,10 +4265,10 @@ def cancel_or_collect
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 用户竞赛列表
|
|
|
|
# 用户竞赛列表
|
|
|
|
def user_contestlist
|
|
|
|
def user_contestlist
|
|
|
|
# 我创建的竞赛
|
|
|
|
# 我创建的竞赛
|
|
|
|
@contest_community = "竞赛"
|
|
|
|
@contest_community = "竞赛"
|
|
|
|
@my_contests = @user.contests.where(:user_id => @user.id).order("created_at desc")
|
|
|
|
@my_contests = @user.contests.where(:user_id => @user.id).order("created_at desc")
|
|
|
@ -4281,9 +4280,9 @@ def user_contestlist
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html {render :layout => 'base_contest_community'}
|
|
|
|
format.html {render :layout => 'base_contest_community'}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def user_projectlist
|
|
|
|
def user_projectlist
|
|
|
|
@order, @c_sort, @type, @list_type = 1, 2, 1, 1
|
|
|
|
@order, @c_sort, @type, @list_type = 1, 2, 1, 1
|
|
|
|
#limit = 5
|
|
|
|
#limit = 5
|
|
|
|
|
|
|
|
|
|
|
@ -4299,9 +4298,9 @@ def user_projectlist
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html {render :layout => 'base_project_community'}
|
|
|
|
format.html {render :layout => 'base_project_community'}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def sort_project_list
|
|
|
|
def sort_project_list
|
|
|
|
@order, @c_sort, @type, @list_type = params[:order] || 1, params[:sort] || 1, params[:type] || 1, params[:list_type] || 1
|
|
|
|
@order, @c_sort, @type, @list_type = params[:order] || 1, params[:sort] || 1, params[:type] || 1, params[:list_type] || 1
|
|
|
|
#limit = 5
|
|
|
|
#limit = 5
|
|
|
|
|
|
|
|
|
|
|
@ -4341,9 +4340,9 @@ def sort_project_list
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.js
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def all_journals
|
|
|
|
def all_journals
|
|
|
|
if params[:type].present?
|
|
|
|
if params[:type].present?
|
|
|
|
case params[:type]
|
|
|
|
case params[:type]
|
|
|
|
when 'OrgDocumentComment'
|
|
|
|
when 'OrgDocumentComment'
|
|
|
@ -4398,46 +4397,46 @@ def all_journals
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@journals = get_no_children_comments_all @journals
|
|
|
|
@journals = get_no_children_comments_all @journals
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def homepage
|
|
|
|
def homepage
|
|
|
|
@article = @user.base_homepage
|
|
|
|
@article = @user.base_homepage
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html {render :layout => 'clear_base'}
|
|
|
|
format.html {render :layout => 'clear_base'}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
private
|
|
|
|
def show_system_message
|
|
|
|
def show_system_message
|
|
|
|
# 系统消息总显示在最前面,显示周期30天
|
|
|
|
# 系统消息总显示在最前面,显示周期30天
|
|
|
|
@system_messages = SystemMessage.where("created_at > ?", Time.now - 86400 * 30)
|
|
|
|
@system_messages = SystemMessage.where("created_at > ?", Time.now - 86400 * 30)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def find_user
|
|
|
|
def find_user
|
|
|
|
if params[:id] == 'current'
|
|
|
|
if params[:id] == 'current'
|
|
|
|
require_login || return
|
|
|
|
require_login || return
|
|
|
|
@user = User.current
|
|
|
|
@user = User.current
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@user = User.find(params[:id])
|
|
|
|
@user = User.find(params[:id])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
render_404
|
|
|
|
render_404
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def setting_layout(default_base='base_users_new')
|
|
|
|
def setting_layout(default_base='base_users_new')
|
|
|
|
User.current.admin? ? default_base : default_base
|
|
|
|
User.current.admin? ? default_base : default_base
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 必填自己的工作单位,其实就是学校
|
|
|
|
# 必填自己的工作单位,其实就是学校
|
|
|
|
def auth_user_extension
|
|
|
|
def auth_user_extension
|
|
|
|
if @user == User.current && @user.user_extensions.nil?
|
|
|
|
if @user == User.current && @user.user_extensions.nil?
|
|
|
|
flash[:error] = l(:error_complete_occupation)
|
|
|
|
flash[:error] = l(:error_complete_occupation)
|
|
|
|
redirect_to my_account_url
|
|
|
|
redirect_to my_account_url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#重置用户得分
|
|
|
|
#重置用户得分
|
|
|
|
def rest_user_score
|
|
|
|
def rest_user_score
|
|
|
|
memo_num(@user)
|
|
|
|
memo_num(@user)
|
|
|
|
messges_for_issue_num(@user)
|
|
|
|
messges_for_issue_num(@user)
|
|
|
|
issues_status_num(@user)
|
|
|
|
issues_status_num(@user)
|
|
|
@ -4449,17 +4448,17 @@ def rest_user_score
|
|
|
|
attachment_num(@user)
|
|
|
|
attachment_num(@user)
|
|
|
|
issue_done_ratio_num(@user)
|
|
|
|
issue_done_ratio_num(@user)
|
|
|
|
post_issue_num(@user)
|
|
|
|
post_issue_num(@user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#验证是否显示课程
|
|
|
|
#验证是否显示课程
|
|
|
|
def can_show_course
|
|
|
|
def can_show_course
|
|
|
|
@first_page = FirstPage.find_by_page_type('project')
|
|
|
|
@first_page = FirstPage.find_by_page_type('project')
|
|
|
|
if @first_page.show_course == 2
|
|
|
|
if @first_page.show_course == 2
|
|
|
|
render_404
|
|
|
|
render_404
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def recorded_visitor
|
|
|
|
def recorded_visitor
|
|
|
|
if(User.current.logged? && User.current != @user)
|
|
|
|
if(User.current.logged? && User.current != @user)
|
|
|
|
#impl = Visitor.where('user_id=? and master_id=?',User.current.id,@user.id).find;
|
|
|
|
#impl = Visitor.where('user_id=? and master_id=?',User.current.id,@user.id).find;
|
|
|
|
# impl = Visitor.find_by_sql('user_id=? and master_id=?',[User.current.id,@user.id]);
|
|
|
|
# impl = Visitor.find_by_sql('user_id=? and master_id=?',[User.current.id,@user.id]);
|
|
|
@ -4473,7 +4472,7 @@ def recorded_visitor
|
|
|
|
end
|
|
|
|
end
|
|
|
|
impl.save
|
|
|
|
impl.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|