create_course_messages=@course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?",User.current.id,'Course',@course.id,0)
@org_logo_attchment=Attachment.where("container_id =? and container_type =? and attachtype =?",@organization,"Organization",0).order("created_on desc").first
@org_banner_attchment=Attachment.where("container_id =? and container_type =? and attachtype =?",@organization,"Organization",1).order("created_on desc").first
# @org_acts = 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)
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)
project_acts=OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' and org_act_type = 'Message' order by updated_at desc limit 2;")
project_acts=OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' and org_act_type = 'issue' order by updated_at desc limit 4;")
else
project_acts=nil
end
#project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' and org_act_type = 'issue' order by updated_at desc limit 4;")
end
# 获取整过项目的动态
defget_project_activities_orgorg,project_ids
unlessproject_ids.blank?
project_acts=OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids.join(',')}) and container_type = 'project'
#project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' and org_act_type = 'issue' order by updated_at desc limit 4;")
end
# 获取整过课程的动态
defget_course_activities_orgorg,course_ids
unlesscourse_ids.blank?
project_acts=OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids.join(',')}) and container_type = 'course'
#project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' order by updated_at desc limit 5;")
#project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'HomeworkCommon' order by updated_at desc limit 1;")
project_acts=OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'HomeworkCommon' order by updated_at desc limit 1;")
else
project_acts=nil
end
#project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' order by updated_at desc limit 5;")
#project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'HomeworkCommon' order by updated_at desc limit 1;")
project_acts=OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'Message' order by updated_at desc limit 1;")
project_acts=OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'News' order by updated_at desc limit 1;")
else
project_acts=nil
end
#project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'News' order by updated_at desc limit 1;")
end
defupdate
@organization=Organization.find(params[:id])
@organization.name=params[:organization][:name]
@ -120,12 +248,17 @@ class OrganizationsController < ApplicationController
@ -157,11 +290,6 @@ class OrganizationsController < ApplicationController
end
end
defclear_org_avatar_temp
end
defset_homepage
@org=Organization.find(params[:id])
@org.home_id=params[:home_id]
@ -224,8 +352,8 @@ class OrganizationsController < ApplicationController
if!params[:name].nil?
condition="%#{params[:name].strip}%".gsub("","")
end
sql="select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'"+
"and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id})"
sql="select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.is_public = 1 and courses.name like '#{condition}'"+
"and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id}) and courses.is_delete=0"
@ -268,8 +396,8 @@ class OrganizationsController < ApplicationController
if!params[:name].nil?
condition="%#{params[:name].strip}%".gsub("","")
end
sql="select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'"+
" and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id})"
sql="select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.is_public = 1 and projects.name like '#{condition}'"+
" and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id}) and status=1"
join_project_messages=ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?",user,project,"JoinProject")
join_project_messages.eachdo|join_project|
join_project.update_attribute(:viewed,true)
end
#更新被移出项目消息的viewed字段
remove_project_messages=ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?",user,project,"RemoveFromProject")
remove_project_messages.update_all(:viewed=>true)
# 更新加入项目消息
project__messages=ForgeMessage.where("forge_message_type in ('ProjectInvite', 'JoinProject', 'RemoveFromProject') and user_id =? and project_id =? ",user,project)
student_work_messages=CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?",User.current.id,@homework.course,StudentWork.name,0)
student_work_messages.eachdo|message|
message.update_attribute(:viewed,true)
end
# 作品打分消息状态更新
studentworks_scores=CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?",User.current.id,@homework.course,"StudentWorksScore",0)
studentworks_scores.eachdo|studentworks_score|
@ -230,12 +351,12 @@ class StudentWorkController < ApplicationController
render_403
return
end
@student_work_count=(search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order}#{@b_sort}"),@name).count
end
@score=@b_sort=="desc"?"asc":"desc"
# 消息传过来的ID
@message_student_work_id=params[:student_work_id]
respond_todo|format|
format.js
format.html
@ -369,6 +490,8 @@ class StudentWorkController < ApplicationController
# sql = "SELECT distinct c.* FROM `courses` c, tags t, taggings ts where t.id = ts.tag_id and ts.taggable_id = c.id and c.is_excellent = 1 and is_delete = 0 and
# ts.taggable_type = 'Course' and t.name like '%#{keywords}%'"
OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and org_subfield_id = #{field_id} and parent_id is null order by updated_at desc limit 8;")
end
defget_message_reply_org(org_id,ids)
# OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id is not null order by updated_at desc limit 1;")
OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id in (#{ids}) order by updated_at desc limit 1;")
end
defget_attach_org(field_id)
Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;")
# Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;")
course_count=CourseMessage.where("user_id =? and viewed =? and created_at >?",User.current.id,0,User.current.onclick_time.onclick_time).count
forge_count=ForgeMessage.where("user_id =? and viewed =? and created_at >?",User.current.id,0,User.current.onclick_time.onclick_time).count
user_feedback_count=UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?",User.current.id,0,User.current.onclick_time.onclick_time).count
user_memo_count=MemoMessage.where("user_id =? and viewed =? and created_at >?",User.current.id,0,User.current.onclick_time.onclick_time).count