@org_activities=OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page]||1).per(10)
# @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,( SELECT `courses`.* FROM `courses` INNER JOIN `members` ON `courses`.`id` = `members`.`course_id` WHERE `members`.`user_id` = u.id AND (courses.status<>9)) as course_count
# from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc")
@org_teachers=User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc")
@org_activities=OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page]||1).per(10)
end
else
else
shield_project_ids=ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id)
shield_project_ids=ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id)
shield_course_ids=ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id)
shield_course_ids=ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id)
@ -142,6 +158,57 @@ class OrganizationsController < ApplicationController
@org_teachers=User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
@org_teachers=User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
@org_teachers=User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from attachments where attachments.author_id = u.id) as course_count
@org_teachers=User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
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}")
@ -2625,6 +2628,7 @@ class UsersController < ApplicationController
@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}")
@ -2632,6 +2636,7 @@ class UsersController < ApplicationController
@ -2680,12 +2688,14 @@ class UsersController < ApplicationController
# 获取我上传的附件
# 获取我上传的附件
defget_attch_resourcesauthor_id,order,score
defget_attch_resourcesauthor_id,order,score
author_id=User.find_by_login(author_id).id
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',
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',
@ -2704,11 +2714,13 @@ class UsersController < ApplicationController
# 获取我的用户类型资源
# 获取我的用户类型资源
defget_principal_resourcesauthor_id,order,score
defget_principal_resourcesauthor_id,order,score
author_id=User.find_by_login(author_id).id
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}")
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
@ -2725,7 +2737,7 @@ class UsersController < ApplicationController
# 资源库 分为全部 课程资源 项目资源 附件
# 资源库 分为全部 课程资源 项目资源 附件
defuser_resource
defuser_resource
# 别人的资源库是没有权限去看的
# 别人的资源库是没有权限去看的
ifUser.current.id.to_i!=params[:id].to_i
ifUser.current.id.to_i!=@user.id.to_i
render_403
render_403
return
return
end
end
@ -2780,13 +2792,13 @@ class UsersController < ApplicationController
self.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count
end
defmy_students
my_students=StudentsForCourse.find_by_sql("SELECT SUM(student_count) as students_count, c.tea_id FROM courses c, (SELECT course_id , COUNT(id) AS student_count FROM students_for_courses GROUP BY course_id) AS ct
WHEREc.id=ct.course_idandc.tea_id=#{self.id} GROUP BY c.tea_id").first
<% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %>
<% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %>