@attachments=Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc")
respond_todo|format|
format.js
end
end
# 删除用户资源
defuser_resource_delete
Attachment.delete(params[:resource_id])
@attachments=Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc")
respond_todo|format|
format.js
end
end
defdestroy
defdestroy
@user.destroy
@user.destroy
respond_todo|format|
respond_todo|format|
@ -1008,6 +1029,55 @@ class UsersController < ApplicationController
@user=User.find(params[:id])
@user=User.find(params[:id])
end
end
# 资源库 分为全部 课程资源 项目资源 附件
defuser_resource
#确定container_type
# @user = User.find(params[:id])
if(params[:type].nil?||params[:type]=="1")#全部
ifUser.current.id==params[:id]
@attachments=Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc")
else
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc")
end
elsifparams[:type]=="2"#课程资源
ifUser.current.id==params[:id]
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Course'").order("created_on desc")
else
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Course' ").order("created_on desc")
end
elsifparams[:type]=="3"#项目资源
ifUser.current.id==params[:id]
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc")
else
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc")
end
elsifparams[:type]=="4"#附件
ifUser.current.id==params[:id]
@attachments=Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
else
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
end
end
@type=params[:type]
respond_todo|format|
format.js
format.html{render:layout=>'base_users_new'}
end
end
# 根据资源关键字进行搜索
defresource_search
search=params[:search].to_s.strip.downcase
ifUser.current.id==params[:id]
@attachments=Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and (filename like '%#{search}%') ").order("created_on desc")
else
@attachments=Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and is_public = 1 and (filename like '%#{search}%') ").order("created_on desc")
end
respond_todo|format|
format.js
end
end
private
private
deffind_user
deffind_user
@ -1021,7 +1091,7 @@ class UsersController < ApplicationController
render_404
render_404
end
end
defsetting_layout(default_base='base_users')
defsetting_layout(default_base='base_users_new')
User.current.admin??default_base:default_base
User.current.admin??default_base:default_base
end
end
@ -1071,4 +1141,7 @@ class UsersController < ApplicationController