@ -41,12 +41,12 @@ class UsersController < ApplicationController
before_filter :can_show_course , :only = > [ :user_courses , :user_homeworks ]
before_filter :can_show_course , :only = > [ :user_courses , :user_homeworks ]
#edit has been deleted by huang, 2013-9-23
#edit has been deleted by huang, 2013-9-23
before_filter :find_user , :only = > [ :user_fanslist , :user_watchlist , :show , :edit , :update , :destroy , :edit_membership , :user_courses ,
before_filter :find_user , :only = > [ :user_fanslist , :user_watchlist , :show , :edit , :update , :destroy , :edit_membership , :user_courses ,
:user_homeworks , :destroy_membership , :user_activities , :user_projects , :user_newfeedback , :user_comments ,
:user_homeworks , :destroy_membership , :user_activities , :user_projects , :user_newfeedback , :user_comments ,
:watch_contests , :info , :watch_projects , :show_score , :topic_score_index , :project_score_index ,
:watch_contests , :info , :watch_projects , :show_score , :topic_score_index , :project_score_index ,
:activity_score_index , :influence_score_index , :score_index , :show_new_score , :topic_new_score_index , :project_new_score_index ,
:activity_score_index , :influence_score_index , :score_index , :show_new_score , :topic_new_score_index , :project_new_score_index ,
:activity_new_score_index , :influence_new_score_index , :score_new_index , :user_projects_index , :user_resource ,
:activity_new_score_index , :influence_new_score_index , :score_new_index , :user_projects_index , :user_resource ,
:user_courses4show , :user_projects4show , :user_course_activities , :user_project_activities , :user_feedback4show , :user_visitorlist , :user_messages , :edit_brief_introduction ,
:user_courses4show , :user_projects4show , :user_course_activities , :user_project_activities , :user_feedback4show , :user_visitorlist , :user_messages , :edit_brief_introduction ,
:user_import_homeworks , :user_search_homeworks , :user_import_resource ]
:user_import_homeworks , :user_search_homeworks , :user_import_resource ]
before_filter :auth_user_extension , only : :show
before_filter :auth_user_extension , only : :show
#before_filter :rest_user_score, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
#before_filter :select_entry, only: :user_projects
@ -223,7 +223,7 @@ class UsersController < ApplicationController
end
end
# end
# end
##added by fq
##added by fq
def watch_bids
def watch_bids
# cond = 'bids.reward_type <> 1'
# cond = 'bids.reward_type <> 1'
# @bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang
# @bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang
@ -286,7 +286,7 @@ class UsersController < ApplicationController
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? )
render_404
render_404
return
return
end
end
end
end
@ -405,19 +405,19 @@ class UsersController < ApplicationController
render_403
render_403
return
return
end
end
if ( params [ :type ] . nil ? || params [ :type ] == " 1 " ) #全部
if ( params [ :type ] . blank ? || params [ :type ] == " 1 " ) #全部
user_course_ids = User . current . courses . map { | c | c . id } #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
user_course_ids = User . current . courses . map { | c | c . id } #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type in('Project','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 ( ',' ) } )) " ) . order ( " created_on desc " )
" or (container_type = 'Course' and container_id in ( #{ user_course_ids . empty? ? '0' : user_course_ids . join ( ',' ) } )) " ) . order ( " created_on desc " )
elsif params [ :type ] == " 2 " #课程资源
elsif params [ :type ] == " 2 " #课程资源
user_course_ids = User . current . courses . map { | c | c . id }
user_course_ids = User . current . courses . map { | c | c . id }
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type = 'Course') or (container_type = 'Course' and container_id in ( #{ user_course_ids . empty? ? '0' : user_course_ids . join ( ',' ) } )) " ) . order ( " created_on desc " )
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type = 'Course') or (container_type = 'Course' and container_id in ( #{ user_course_ids . empty? ? '0' : user_course_ids . join ( ',' ) } )) " ) . order ( " created_on desc " )
elsif params [ :type ] == " 3 " #项目资源
elsif params [ :type ] == " 3 " #项目资源
@attachments = Attachment . where ( " author_id = #{ params [ :id ] } and container_type = 'Project' " ) . order ( " created_on desc " )
@attachments = Attachment . where ( " author_id = #{ params [ :id ] } and container_type = 'Project' " ) . order ( " created_on desc " )
elsif params [ :type ] == " 4 " #附件
elsif params [ :type ] == " 4 " #附件
@attachments = Attachment . where ( " author_id = #{ params [ :id ] } and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') " ) . order ( " created_on desc " )
@attachments = Attachment . where ( " author_id = #{ params [ :id ] } and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') " ) . order ( " created_on desc " )
elsif params [ :type ] == " 5 " #用户资源
elsif params [ :type ] == " 5 " #用户资源
@attachments = Attachment . where ( " author_id = #{ params [ :id ] } and container_type = 'Principal' " ) . order ( " created_on desc " )
@attachments = Attachment . where ( " author_id = #{ params [ :id ] } and container_type = 'Principal' " ) . order ( " created_on desc " )
end
end
@type = params [ :type ]
@type = params [ :type ]
@limit = 7
@limit = 7
@ -436,19 +436,19 @@ class UsersController < ApplicationController
#引入资源列表根据关键词过滤
#引入资源列表根据关键词过滤
def user_ref_resource_search
def user_ref_resource_search
search = params [ :search ] . to_s . strip . downcase
search = params [ :search ] . to_s . strip . downcase
if ( params [ :type ] . nil ? || params [ :type ] == " 1 " ) #全部
if ( params [ :type ] . blank ? || params [ :type ] == " 1 " ) #全部
user_course_ids = User . current . courses . map { | c | c . id } #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询
user_course_ids = User . current . courses . map { | c | c . id } #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询
@attachments = Attachment . where ( " ((author_id = #{ params [ :id ] } and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
@attachments = Attachment . where ( " ((author_id = #{ params [ :id ] } and container_type in('Project','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 (filename like '% #{ search } %') " ) . order ( " created_on desc " )
" or (container_type = 'Course' and container_id in ( #{ user_course_ids . empty? ? '0' : user_course_ids . join ( ',' ) } ))) and (filename like '% #{ search } %') " ) . order ( " created_on desc " )
elsif params [ :type ] == " 2 " #课程资源
elsif params [ :type ] == " 2 " #课程资源
user_course_ids = User . current . courses . map { | c | c . id }
user_course_ids = User . current . courses . map { | c | c . id }
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type = 'Course') or (container_type = 'Course' and container_id in ( #{ user_course_ids . empty? ? '0' : user_course_ids . join ( ',' ) } )) and (filename like '% #{ search } %') " ) . order ( " created_on desc " )
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type = 'Course') or (container_type = 'Course' and container_id in ( #{ user_course_ids . empty? ? '0' : user_course_ids . join ( ',' ) } )) and (filename like '% #{ search } %') " ) . order ( " created_on desc " )
elsif params [ :type ] == " 3 " #项目资源
elsif params [ :type ] == " 3 " #项目资源
@attachments = Attachment . where ( " author_id = #{ params [ :id ] } and container_type = 'Project' and (filename like '% #{ search } %') " ) . order ( " created_on desc " )
@attachments = Attachment . where ( " author_id = #{ params [ :id ] } and container_type = 'Project' and (filename like '% #{ search } %') " ) . order ( " created_on desc " )
elsif params [ :type ] == " 4 " #附件
elsif params [ :type ] == " 4 " #附件
@attachments = Attachment . where ( " author_id = #{ params [ :id ] } and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '% #{ search } %') " ) . order ( " created_on desc " )
@attachments = Attachment . where ( " author_id = #{ params [ :id ] } and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '% #{ search } %') " ) . order ( " created_on desc " )
elsif params [ :type ] == " 5 " #用户资源
elsif params [ :type ] == " 5 " #用户资源
@attachments = Attachment . where ( " author_id = #{ params [ :id ] } and container_type = 'Principal' and (filename like '% #{ search } %') " ) . order ( " created_on desc " )
@attachments = Attachment . where ( " author_id = #{ params [ :id ] } and container_type = 'Principal' and (filename like '% #{ search } %') " ) . order ( " created_on desc " )
end
end
@type = params [ :type ]
@type = params [ :type ]
@limit = 7
@limit = 7
@ -466,20 +466,20 @@ class UsersController < ApplicationController
#将资源批量引入
#将资源批量引入
def import_resources_to_homework
def import_resources_to_homework
@attachments = [ ]
@attachments = [ ]
unless params [ :checkbox1 ] . nil? || params [ :checkbox1 ] . blank?
unless params [ :checkbox1 ] . nil? || params [ :checkbox1 ] . blank?
params [ :checkbox1 ] . each do | id |
params [ :checkbox1 ] . each do | id |
atta = Attachment . find ( id )
atta = Attachment . find ( id )
att_copy = atta . copy
att_copy = atta . copy
att_copy . container_id = nil
att_copy . container_id = nil
att_copy . container_type = nil
att_copy . container_type = nil
att_copy . copy_from = atta . id
att_copy . copy_from = atta . id
att_copy . save
att_copy . save
@attachments << att_copy
@attachments << att_copy
end
end
respond_to do | format |
format . js
end
end
end
respond_to do | format |
format . js
end
end
end
@ -529,16 +529,16 @@ class UsersController < ApplicationController
sort_update %w( login firstname lastname mail admin created_on last_login_on )
sort_update %w( login firstname lastname mail admin created_on last_login_on )
case params [ :format ]
case params [ :format ]
when 'xml' , 'json'
when 'xml' , 'json'
@offset , @limit = api_offset_and_limit ( { :limit = > 15 } )
@offset , @limit = api_offset_and_limit ( { :limit = > 15 } )
else
else
@limit = 15
@limit = 15
end
end
# retrieve all users
# retrieve all users
# 先内连一下statuses 保证排序之后数量一致
# 先内连一下statuses 保证排序之后数量一致
scope = User . visible .
scope = User . visible .
joins ( " INNER JOIN user_statuses ON users.id = user_statuses.user_id " )
joins ( " INNER JOIN user_statuses ON users.id = user_statuses.user_id " )
# unknow
# unknow
scope = scope . in_group ( params [ :group_id ] ) if params [ :group_id ] . present?
scope = scope . in_group ( params [ :group_id ] ) if params [ :group_id ] . present?
@ -549,29 +549,29 @@ class UsersController < ApplicationController
# users classify
# users classify
case params [ :user_sort_type ]
case params [ :user_sort_type ]
when '0'
when '0'
# 创建时间排序
# 创建时间排序
@s_type = 0
@s_type = 0
@users = scope . reorder ( 'users.created_on DESC' )
@users = scope . reorder ( 'users.created_on DESC' )
when '1'
when '1'
# 活跃度排序, 就是所谓的得分情况
# 活跃度排序, 就是所谓的得分情况
@s_type = 1
@s_type = 1
@users = scope .
@users = scope .
joins ( " LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1 " ) .
joins ( " LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1 " ) .
reorder ( 'option_numbers.total_score DESC' )
reorder ( 'option_numbers.total_score DESC' )
when '2'
when '2'
# 粉丝数排序
# 粉丝数排序
@s_type = 2
@s_type = 2
@users = scope .
@users = scope .
#joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id").
#joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id").
reorder ( 'user_statuses.watchers_count DESC' )
reorder ( 'user_statuses.watchers_count DESC' )
else
else
# 默认活跃度排序
# 默认活跃度排序
@s_type = 1
@s_type = 1
@users = scope .
@users = scope .
joins ( " LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1 " ) .
joins ( " LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1 " ) .
reorder ( 'option_numbers.total_score DESC' )
reorder ( 'option_numbers.total_score DESC' )
end
end
# limit and offset
# limit and offset
@ -591,20 +591,20 @@ class UsersController < ApplicationController
sort_init 'login' , 'asc'
sort_init 'login' , 'asc'
sort_update %w( login firstname lastname mail admin created_on last_login_on )
sort_update %w( login firstname lastname mail admin created_on last_login_on )
( redirect_to user_url , :notice = > l ( :label_sumbit_empty ) ; return ) if params [ :name ] . blank?
( redirect_to user_url , :notice = > l ( :label_sumbit_empty ) ; return ) if params [ :name ] . blank?
case params [ :format ]
case params [ :format ]
when 'xml' , 'json'
when 'xml' , 'json'
@offset , @limit = api_offset_and_limit ( { :limit = > 15 } )
@offset , @limit = api_offset_and_limit ( { :limit = > 15 } )
else
else
@limit = 15 #per_page_option
@limit = 15 #per_page_option
end
end
#
#
#@status = params[:status] || 1
#@status = params[:status] || 1
#has = {
#has = {
# "show_changesets" => true
# "show_changesets" => true
#}
#}
# scope = User.logged.status(@status)
# scope = User.logged.status(@status)
# @search_by = params[:search_by] ? params[:search_by][:id] : 0
# @search_by = params[:search_by] ? params[:search_by][:id] : 0
# scope = scope.like(params[:name],@search_by) if params[:name].present?
# scope = scope.like(params[:name],@search_by) if params[:name].present?
@search_by = params [ :search_by ] ? params [ :search_by ] : 0
@search_by = params [ :search_by ] ? params [ :search_by ] : 0
us = UsersService . new
us = UsersService . new
@ -637,13 +637,13 @@ class UsersController < ApplicationController
def user_courses4show
def user_courses4show
@page = params [ :page ] . to_i + 1
@page = params [ :page ] . to_i + 1
@courses = @user . courses . visible . select ( " courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a " ) . order ( " a desc " ) . limit ( 5 ) . offset ( @page * 5 )
@courses = @user . courses . visible . select ( " courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a " ) . order ( " a desc " ) . limit ( 5 ) . offset ( @page * 5 )
end
end
#显示更多用户项目
#显示更多用户项目
def user_projects4show
def user_projects4show
@page = params [ :page ] . to_i + 1
@page = params [ :page ] . to_i + 1
@projects = @user . projects . visible . select ( " projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a " ) . order ( " a desc " ) . limit ( 5 ) . offset ( @page * 5 )
@projects = @user . projects . visible . select ( " projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a " ) . order ( " a desc " ) . limit ( 5 ) . offset ( @page * 5 )
end
end
def user_course_activities
def user_course_activities
lastid = nil
lastid = nil
@ -720,9 +720,7 @@ class UsersController < ApplicationController
end
end
def show
def show
@page = params [ :page ] ? params [ :page ] . to_i + 1 : 0
@page = params [ :page ] ? params [ :page ] . to_i + 1 : 0
user_project_ids = @user . projects . visible . empty? ? " (-1) " : " ( " + @user . projects . visible . map { | project | project . id } . join ( " , " ) + " ) "
user_project_ids = @user . projects . visible . empty? ? " (-1) " : " ( " + @user . projects . visible . map { | project | project . id } . join ( " , " ) + " ) "
user_course_ids = @user . courses . visible . empty? ? " (-1) " : " ( " + @user . courses . visible . map { | course | course . id } . join ( " , " ) + " ) "
user_course_ids = @user . courses . visible . empty? ? " (-1) " : " ( " + @user . courses . visible . map { | course | course . id } . join ( " , " ) + " ) "
course_types = " ('Message','News','HomeworkCommon','poll') "
course_types = " ('Message','News','HomeworkCommon','poll') "
@ -743,7 +741,7 @@ class UsersController < ApplicationController
@user_activities = UserActivity . where ( " container_type = 'Project' and container_id in #{ user_project_ids } and act_type = 'Message' " ) . order ( 'created_at desc' ) . limit ( 10 ) . offset ( @page * 10 )
@user_activities = UserActivity . where ( " container_type = 'Project' and container_id in #{ user_project_ids } and act_type = 'Message' " ) . order ( 'created_at desc' ) . limit ( 10 ) . offset ( @page * 10 )
else
else
@user_activities = UserActivity . where ( " (container_type = 'Project' and container_id in #{ user_project_ids } and act_type in #{ project_types } ) or (container_type = 'Course' and container_id in #{ user_course_ids } ) and act_type in #{ course_types } " ) . order ( 'created_at desc' ) . limit ( 10 ) . offset ( @page * 10 )
@user_activities = UserActivity . where ( " (container_type = 'Project' and container_id in #{ user_project_ids } and act_type in #{ project_types } ) or (container_type = 'Course' and container_id in #{ user_course_ids } ) and act_type in #{ course_types } " ) . order ( 'created_at desc' ) . limit ( 10 ) . offset ( @page * 10 )
end
end
else
else
@user_activities = UserActivity . where ( " (container_type = 'Project' and container_id in #{ user_project_ids } and act_type in #{ project_types } ) or (container_type = 'Course' and container_id in #{ user_course_ids } ) and act_type in #{ course_types } " ) . order ( 'created_at desc' ) . limit ( 10 ) . offset ( @page * 10 )
@user_activities = UserActivity . where ( " (container_type = 'Project' and container_id in #{ user_project_ids } and act_type in #{ project_types } ) or (container_type = 'Course' and container_id in #{ user_course_ids } ) and act_type in #{ course_types } " ) . order ( 'created_at desc' ) . limit ( 10 ) . offset ( @page * 10 )
end
end
@ -761,124 +759,124 @@ class UsersController < ApplicationController
# Author lizanle
# Author lizanle
# Description type 1 :所有动态包括我关注的人 type 2:我的动态 type 3:关于我的回复
# Description type 1 :所有动态包括我关注的人 type 2:我的动态 type 3:关于我的回复
case params [ :type ]
case params [ :type ]
when " 1 "
when " 1 "
if @user == User . current
if @user == User . current
activity = Activity . where ( 'user_id = ?' , User . current . id ) . order ( 'id desc' )
activity = Activity . where ( 'user_id = ?' , User . current . id ) . order ( 'id desc' )
@activity_count = activity . count
@activity_count = activity . count
@activity_pages = Paginator . new @activity_count , pre_count , params [ 'page' ]
@activity_pages = Paginator . new @activity_count , pre_count , params [ 'page' ]
@activity = activity . offset ( @activity_pages . offset ) . limit ( @activity_pages . per_page ) . all
@activity = activity . offset ( @activity_pages . offset ) . limit ( @activity_pages . per_page ) . all
@state = 1
@state = 1
end
when " 2 "
message = [ ]
if @user == User . current
message = JournalsForMessage . reference_message ( @user . id )
message += Journal . reference_message ( @user . id )
end
@activity_count = message . size
@info_pages = Paginator . new @activity_count , pre_count , params [ 'page' ]
messages = message . sort { | x , y | y . created_on < = > x . created_on }
@message = messages [ @info_pages . offset , @info_pages . per_page ]
@state = 2
else
# Time 2015-02-04 10:50:49
# Author lizanle
# Description 所有动态
where_condition = nil ;
# where_condition = "act_type <> 'JournalsForMessage'"
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
activity = Activity . where ( where_condition ) . where ( user_id : user_ids ) . order ( 'id desc' )
permission = ! User . current . admin?
if permission
#Issue
act_ids = activity . where ( act_type : 'Issue' ) . select ( 'act_id' ) . map { | x | x . act_id }
project_ids = Issue . where ( id : act_ids ) . select ( 'distinct project_id' ) . map { | x | x . project_id }
p_ids = [ ]
Project . where ( id : project_ids ) . each do | x |
p_ids << x . id unless x . visible? ( User . current )
end
ids = [ ]
ids << Issue . where ( id : act_ids , project_id : p_ids ) . map { | x | x . id }
#HomeworkCommon
act_ids = activity . where ( act_type : 'HomeworkCommon' ) . select ( 'act_id' ) . map { | x | x . act_id }
course_ids = HomeworkCommon . where ( id : act_ids ) . select ( 'distinct course_id' ) . map { | x | x . course_id }
c_ids = [ ]
Course . where ( id : course_ids ) . each do | x |
c_ids << x . id unless x . is_public != 0 && User . current . member_of_course? ( x )
end
end
ids << HomeworkCommon . where ( id : act_ids , course_id : c_ids ) . map { | x | x . id }
when " 2 "
message = [ ]
#Journal
if @user == User . current
act_ids = activity . where ( act_type : 'Journal' ) . select ( 'act_id' ) . map { | x | x . act_id }
message = JournalsForMessage . reference_message ( @user . id )
project_ids = Journal . where ( id :act_ids , journalized_type : 'Project' ) . select ( 'distinct journalized_id' ) . map { | x | x . journalized_id }
message += Journal . reference_message ( @user . id )
p_ids = [ ]
Project . where ( id : project_ids ) . each do | x |
p_ids << x . id unless x . visible? ( User . current )
end
end
ids << Journal . where ( id : act_ids , journalized_id : p_ids , journalized_type : 'Project' ) . map { | x | x . id }
@activity_count = message . size
@info_pages = Paginator . new @activity_count , pre_count , params [ 'page' ]
#News
messages = message . sort { | x , y | y . created_on < = > x . created_on }
act_ids = activity . where ( act_type : 'News' ) . select ( 'act_id' ) . map { | x | x . act_id }
@message = messages [ @info_pages . offset , @info_pages . per_page ]
project_ids = News . where ( id : act_ids ) . select ( 'distinct project_id' ) . map { | x | x . project_id }
@state = 2
p_ids = [ ]
else
Project . where ( id : project_ids ) . each do | x |
# Time 2015-02-04 10:50:49
p_ids << x . id unless x . visible? ( User . current )
# Author lizanle
# Description 所有动态
where_condition = nil ;
# where_condition = "act_type <> 'JournalsForMessage'"
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
end
ids << News . where ( id : act_ids , project_id : p_ids ) . map { | x | x . id }
activity = Activity . where ( where_condition ) . where ( user_id : user_ids ) . order ( 'id desc' )
permission = ! User . current . admin?
if permission
#Issue
act_ids = activity . where ( act_type : 'Issue' ) . select ( 'act_id' ) . map { | x | x . act_id }
project_ids = Issue . where ( id : act_ids ) . select ( 'distinct project_id' ) . map { | x | x . project_id }
p_ids = [ ]
Project . where ( id : project_ids ) . each do | x |
p_ids << x . id unless x . visible? ( User . current )
end
ids = [ ]
ids << Issue . where ( id : act_ids , project_id : p_ids ) . map { | x | x . id }
#HomeworkCommon
act_ids = activity . where ( act_type : 'HomeworkCommon' ) . select ( 'act_id' ) . map { | x | x . act_id }
course_ids = HomeworkCommon . where ( id : act_ids ) . select ( 'distinct course_id' ) . map { | x | x . course_id }
c_ids = [ ]
Course . where ( id : course_ids ) . each do | x |
c_ids << x . id unless x . is_public != 0 && User . current . member_of_course? ( x )
end
ids << HomeworkCommon . where ( id : act_ids , course_id : c_ids ) . map { | x | x . id }
#Journal
act_ids = activity . where ( act_type : 'Journal' ) . select ( 'act_id' ) . map { | x | x . act_id }
project_ids = Journal . where ( id :act_ids , journalized_type : 'Project' ) . select ( 'distinct journalized_id' ) . map { | x | x . journalized_id }
p_ids = [ ]
Project . where ( id : project_ids ) . each do | x |
p_ids << x . id unless x . visible? ( User . current )
end
ids << Journal . where ( id : act_ids , journalized_id : p_ids , journalized_type : 'Project' ) . map { | x | x . id }
#News
act_ids = activity . where ( act_type : 'News' ) . select ( 'act_id' ) . map { | x | x . act_id }
project_ids = News . where ( id : act_ids ) . select ( 'distinct project_id' ) . map { | x | x . project_id }
p_ids = [ ]
Project . where ( id : project_ids ) . each do | x |
p_ids << x . id unless x . visible? ( User . current )
end
ids << News . where ( id : act_ids , project_id : p_ids ) . map { | x | x . id }
project_ids = News . where ( id : act_ids ) . select ( 'distinct course_id' ) . map { | x | x . course_id }
project_ids = News . where ( id : act_ids ) . select ( 'distinct course_id' ) . map { | x | x . course_id }
c_ids = [ ]
c_ids = [ ]
Course . where ( id : project_ids ) . each do | x |
Course . where ( id : project_ids ) . each do | x |
c_ids << x . id unless x . is_public != 0 && User . current . member_of_course? ( x )
c_ids << x . id unless x . is_public != 0 && User . current . member_of_course? ( x )
end
end
ids << News . where ( id : act_ids , course_id : p_ids ) . map { | x | x . id }
ids << News . where ( id : act_ids , course_id : p_ids ) . map { | x | x . id }
#Message
#Message
act_ids = activity . where ( act_type : 'Message' ) . select ( 'act_id' ) . map { | x | x . act_id }
act_ids = activity . where ( act_type : 'Message' ) . select ( 'act_id' ) . map { | x | x . act_id }
board_ids = Message . where ( id : act_ids ) . select ( 'distinct board_id' ) . map { | x | x . board_id }
board_ids = Message . where ( id : act_ids ) . select ( 'distinct board_id' ) . map { | x | x . board_id }
project_ids = Board . where ( id : board_ids ) . select ( 'distinct project_id' ) . map { | x | x . project_id }
project_ids = Board . where ( id : board_ids ) . select ( 'distinct project_id' ) . map { | x | x . project_id }
p_ids = [ ]
p_ids = [ ]
Project . where ( id : project_ids ) . each do | x |
Project . where ( id : project_ids ) . each do | x |
p_ids << x . id unless x . visible? ( User . current )
p_ids << x . id unless x . visible? ( User . current )
end
end
ids << Message . where ( id : act_ids , board_id : p_ids ) . map { | x | x . id }
ids << Message . where ( id : act_ids , board_id : p_ids ) . map { | x | x . id }
project_ids = Board . where ( id : board_ids ) . select ( 'distinct course_id' ) . map { | x | x . course_id }
project_ids = Board . where ( id : board_ids ) . select ( 'distinct course_id' ) . map { | x | x . course_id }
c_ids = [ ]
c_ids = [ ]
Course . where ( id : project_ids ) . each do | x |
Course . where ( id : project_ids ) . each do | x |
c_ids << x . id unless x . is_public != 0 && User . current . member_of_course? ( x )
c_ids << x . id unless x . is_public != 0 && User . current . member_of_course? ( x )
end
end
ids << Message . where ( id : act_ids , board_id : c_ids ) . map { | x | x . id }
ids << Message . where ( id : act_ids , board_id : c_ids ) . map { | x | x . id }
logger . debug " filter ids #{ ids } "
logger . debug " filter ids #{ ids } "
activity = activity . where ( 'act_id not in (?)' , ids . flatten ) . order ( 'id desc' ) unless ids . flatten . empty?
activity = activity . where ( 'act_id not in (?)' , ids . flatten ) . order ( 'id desc' ) unless ids . flatten . empty?
end
end
# activity = activity.reject { |e|
# activity = activity.reject { |e|
# e.act.nil? ||
# e.act.nil? ||
# (!User.current.admin? && !e.act.nil?
# (!User.current.admin? && !e.act.nil?
# (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) ||
# (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) ||
# (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) ||
# (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) ||
# (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) ||
# (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) ||
# (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) ||
# (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) ||
# (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course))))))
# (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course))))))
# }
# }
#
#
@activity_count = activity . count
@activity_count = activity . count
@activity_pages = Paginator . new @activity_count , pre_count , params [ 'page' ]
@activity_pages = Paginator . new @activity_count , pre_count , params [ 'page' ]
@activity = activity . slice ( @activity_pages . offset , @activity_pages . per_page )
@activity = activity . slice ( @activity_pages . offset , @activity_pages . per_page )
@state = 0
@state = 0
end
end
if params [ :user ] . present?
if params [ :user ] . present?
@ -906,7 +904,7 @@ class UsersController < ApplicationController
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
render_404
render_404
return
return
end
end
end
end
@ -938,7 +936,7 @@ class UsersController < ApplicationController
unless User . current . admin?
unless User . current . admin?
if ! @user . active?
if ! @user . active?
render_404
render_404
return
return
end
end
end
end
@ -996,7 +994,7 @@ class UsersController < ApplicationController
unless @user . id . nil?
unless @user . id . nil?
#后台注册的用户默认权限为男性开发员
#后台注册的用户默认权限为男性开发员
ue = UserExtensions . create ( :identity = > 3 ,
ue = UserExtensions . create ( :identity = > 3 ,
:gender = > 0 ,
:gender = > 0 ,
:user_id = > @user . id )
:user_id = > @user . id )
ue . save
ue . save
end
end
@ -1066,8 +1064,8 @@ class UsersController < ApplicationController
@user = User . find ( params [ :id ] )
@user = User . find ( params [ :id ] )
#@user.save_attachments(params[:attachments],User.current)
#@user.save_attachments(params[:attachments],User.current)
# Container_type为Principal
# Container_type为Principal
Attachment . attach_filesex ( @user , params [ :attachments ] , params [ :attachment_type ] )
Attachment . attach_filesex ( @user , params [ :attachments ] , params [ :attachment_type ] )
if ( params [ :type ] . nil? || params [ :type ] == " 1 " ) #全部
if ( params [ :type ] . blank? || params [ :type ] == " 1 " ) #全部
if User . current . id . to_i == params [ :id ] . to_i
if User . current . id . to_i == params [ :id ] . to_i
user_course_ids = User . current . courses . map { | c | c . id } #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
user_course_ids = User . current . courses . map { | c | c . id } #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
@ -1122,14 +1120,14 @@ class UsersController < ApplicationController
# 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源
# 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源
def user_resource_delete
def user_resource_delete
if params [ :resource_id ] . present?
if params [ :resource_id ] . present?
Attachment . where ( " author_id = #{ User . current . id } " ) . delete ( params [ :resource_id ] )
Attachment . where ( " author_id = #{ User . current . id } " ) . delete ( params [ :resource_id ] )
elsif params [ :checkbox1 ] . present?
elsif params [ :checkbox1 ] . present?
params [ :checkbox1 ] . each do | id |
params [ :checkbox1 ] . each do | id |
Attachment . where ( " author_id = #{ User . current . id } " ) . delete ( id )
Attachment . where ( " author_id = #{ User . current . id } " ) . delete ( id )
end
end
end
end
if ( params [ :type ] . nil ? || params [ :type ] == " 1 " ) #全部
if ( params [ :type ] . blank ? || params [ :type ] == " 1 " ) #全部
if User . current . id . to_i == params [ :id ] . to_i
if User . current . id . to_i == params [ :id ] . to_i
user_course_ids = User . current . courses . map { | c | c . id } #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
user_course_ids = User . current . courses . map { | c | c . id } #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
@ -1176,17 +1174,17 @@ class UsersController < ApplicationController
@offset || = @atta_pages . offset
@offset || = @atta_pages . offset
#@curse_attachments_all = @all_attachments[@offset, @limit]
#@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments , 25
@attachments = paginateHelper @attachments , 25
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?
@course = @user . courses . where ( " #{ Course . table_name } .id = #{ params [ :search ] . to_i } or #{ Course . table_name } .name like '% #{ params [ :search . to_s ] } %' " )
@course = @user . courses . where ( " #{ Course . table_name } .id = #{ params [ :search ] . to_i } or #{ Course . table_name } .name like '% #{ params [ :search . to_s ] } %' " )
. select { | course | @user . allowed_to? ( :as_teacher , course ) }
. select { | course | @user . allowed_to? ( :as_teacher , course ) }
else
else
@course = @user . courses
@course = @user . courses
. select { | course | @user . allowed_to? ( :as_teacher , course ) }
. select { | course | @user . allowed_to? ( :as_teacher , course ) }
@ -1218,28 +1216,28 @@ class UsersController < ApplicationController
# 将资源发送到对应的课程,分为发送单个,或者批量发送
# 将资源发送到对应的课程,分为发送单个,或者批量发送
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?
send_id = params [ :send_id ]
send_id = params [ :send_id ]
ori = Attachment . find_by_id ( send_id )
ori = Attachment . find_by_id ( send_id )
course_ids = params [ :course_ids ]
course_ids = params [ :course_ids ]
if course_ids . nil?
if course_ids . nil?
@flag = false
@flag = false
end
end
unless course_ids . nil?
unless course_ids . nil?
course_ids . each do | id |
course_ids . each do | id |
next if ori . blank?
next if ori . blank?
attach_copied_obj = ori . copy
attach_copied_obj = ori . copy
attach_copied_obj . tag_list . add ( ori . tag_list ) # tag关联
attach_copied_obj . tag_list . add ( ori . tag_list ) # tag关联
attach_copied_obj . container = Course . find ( id )
attach_copied_obj . container = Course . find ( id )
attach_copied_obj . created_on = Time . now
attach_copied_obj . created_on = Time . now
attach_copied_obj . author_id = User . current . id
attach_copied_obj . author_id = User . current . id
if attach_copied_obj . attachtype == nil
if attach_copied_obj . attachtype == nil
attach_copied_obj . attachtype = 4
attach_copied_obj . attachtype = 4
end
end
attach_copied_obj . save
attach_copied_obj . save
@save_message = attach_copied_obj . errors . full_messages
@save_message = attach_copied_obj . errors . full_messages
end
end
end
end
elsif params [ :send_ids ] . present?
elsif params [ :send_ids ] . present?
send_ids = params [ :send_ids ] . split ( " " )
send_ids = params [ :send_ids ] . split ( " " )
course_ids = params [ :course_ids ]
course_ids = params [ :course_ids ]
@ -1266,8 +1264,20 @@ class UsersController < ApplicationController
end
end
end
end
else
else
@flag = false
@flag = false
end
end
user_course_ids = User . current . courses . map { | c | c . id } #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type in('Project','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 ( ',' ) } )) " ) . order ( " created_on desc " )
@type = params [ :type ]
@limit = 25
@user = User . current
@is_remote = true
@atta_count = @attachments . count
@atta_pages = Paginator . new @atta_count , @limit , params [ 'page' ] || 1
@offset || = @atta_pages . offset
#@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments , 25
respond_to do | format |
respond_to do | format |
format . js
format . js
end
end
@ -1324,7 +1334,18 @@ class UsersController < ApplicationController
else
else
@flag = true
@flag = true
end
end
user_course_ids = User . current . courses . map { | c | c . id } #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type in('Project','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 ( ',' ) } )) " ) . order ( " created_on desc " )
@type = params [ :type ]
@limit = 25
@user = User . current
@is_remote = true
@atta_count = @attachments . count
@atta_pages = Paginator . new @atta_count , @limit , params [ 'page' ] || 1
@offset || = @atta_pages . offset
#@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments , 25
respond_to do | format |
respond_to do | format |
format . js
format . js
end
end
@ -1332,15 +1353,15 @@ class UsersController < ApplicationController
# 资源预览
# 资源预览
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 ;
if %w( pdf pptx doc docx xls xlsx ) . any? { | x | @file . filename . downcase . end_with? ( x ) }
if %w( pdf pptx doc docx xls xlsx ) . any? { | x | @file . filename . downcase . end_with? ( x ) }
@preview_able = true ;
@preview_able = true ;
end
end
respond_to do | format |
respond_to do | format |
format . js
format . js
end
end
end
end
# 重命名资源
# 重命名资源
@ -1380,7 +1401,7 @@ class UsersController < ApplicationController
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
end
end
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' ) }
@ -1395,31 +1416,31 @@ class UsersController < ApplicationController
@obj_flag = params [ :tag_for_save ] [ :object_flag ]
@obj_flag = params [ :tag_for_save ] [ :object_flag ]
case @obj_flag
case @obj_flag
when '1' then
when '1' then
@obj = User . find_by_id ( @obj_id )
@obj = User . find_by_id ( @obj_id )
when '2' then
when '2' then
@obj = Project . find_by_id ( @obj_id )
@obj = Project . find_by_id ( @obj_id )
when '3' then
when '3' then
@obj = Issue . find_by_id ( @obj_id )
@obj = Issue . find_by_id ( @obj_id )
when '4' then
when '4' then
# @obj = Bid.find_by_id(@obj_id)
# @obj = Bid.find_by_id(@obj_id)
when '5' then
when '5' then
@obj = Forum . find_by_id ( @obj_id )
@obj = Forum . find_by_id ( @obj_id )
when '6'
when '6'
@obj = Attachment . find_by_id ( @obj_id )
@obj = Attachment . find_by_id ( @obj_id )
when '7' then
when '7' then
@obj = Contest . find_by_id ( @obj_id )
@obj = Contest . find_by_id ( @obj_id )
when '8'
when '8'
@obj = OpenSourceProject . find_by_id ( @obj_id )
@obj = OpenSourceProject . find_by_id ( @obj_id )
when '9'
when '9'
@obj = Course . find_by_id ( @obj_id )
@obj = Course . find_by_id ( @obj_id )
else
else
@obj = nil
@obj = nil
end
end
unless @obj . nil?
unless @obj . nil?
@obj . tag_list . add ( @tags . split ( " , " ) )
@obj . tag_list . add ( @tags . split ( " , " ) )
else
else
return
return
end
end
if @obj . save
if @obj . save
logger . debug " #{ __FILE__ } : #{ __LINE__ } ===> #{ @obj . to_json } "
logger . debug " #{ __FILE__ } : #{ __LINE__ } ===> #{ @obj . to_json } "
@ -1510,9 +1531,9 @@ class UsersController < ApplicationController
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
@ -1539,7 +1560,7 @@ class UsersController < ApplicationController
render_403
render_403
return
return
end
end
if ( params [ :type ] . nil ? || params [ :type ] == " 1 " ) #全部
if ( params [ :type ] . blank ? || params [ :type ] == " 1 " ) #全部
if User . current . id . to_i == params [ :id ] . to_i
if User . current . id . to_i == params [ :id ] . to_i
user_course_ids = User . current . courses . map { | c | c . id } #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
user_course_ids = User . current . courses . map { | c | c . id } #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
@attachments = Attachment . where ( " (author_id = #{ params [ :id ] } and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
@ -1603,9 +1624,9 @@ class UsersController < ApplicationController
else
else
user_course_ids = User . find ( params [ :id ] ) . courses . visible . map { | c | c . id } #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
user_course_ids = User . find ( params [ :id ] ) . courses . visible . map { | c | c . id } #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@attachments = Attachment . where ( " ((author_id = #{ params [ :id ] } and is_public = 1 and container_type in " +
@attachments = Attachment . where ( " ((author_id = #{ params [ :id ] } and is_public = 1 and container_type in " +
" ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
" ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
" or (container_type = 'Course' and is_public = 1 and container_id in ( #{ user_course_ids . empty? ? '0' : user_course_ids . join ( ',' ) } )) ) " +
" or (container_type = 'Course' and is_public = 1 and container_id in ( #{ user_course_ids . empty? ? '0' : user_course_ids . join ( ',' ) } )) ) " +
" and (filename like '% #{ search } %') " ) . order ( " created_on desc " )
" and (filename like '% #{ search } %') " ) . order ( " created_on desc " )
end
end
elsif params [ :type ] == " 2 " #课程资源
elsif params [ :type ] == " 2 " #课程资源
if User . current . id . to_i == params [ :id ] . to_i
if User . current . id . to_i == params [ :id ] . to_i
@ -1614,7 +1635,7 @@ class UsersController < ApplicationController
else
else
user_course_ids = User . find ( params [ :id ] ) . courses . visible . map { | c | c . id } #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
user_course_ids = User . find ( params [ :id ] ) . courses . visible . map { | c | c . id } #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@attachments = Attachment . where ( " ((author_id = #{ params [ :id ] } and is_public = 1 and container_type = 'Course') " +
@attachments = Attachment . where ( " ((author_id = #{ params [ :id ] } and is_public = 1 and container_type = 'Course') " +
" or (container_type = 'Course' and is_public = 1 and container_id in ( #{ user_course_ids . empty? ? '0' : user_course_ids . join ( ',' ) } )) ) " +
" or (container_type = 'Course' and is_public = 1 and container_id in ( #{ user_course_ids . empty? ? '0' : user_course_ids . join ( ',' ) } )) ) " +
" and (filename like '% #{ search } %') " ) . order ( " created_on desc " )
" and (filename like '% #{ search } %') " ) . order ( " created_on desc " )
end
end
elsif params [ :type ] == " 3 " #项目资源
elsif params [ :type ] == " 3 " #项目资源