diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c4932b1b2..ca37e445c 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -26,7 +26,7 @@ class FilesController < ApplicationController before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project, :search_tag_attachment,:subfield_upload_file,:search_org_subfield_tag_attachment, :search_tag_attachment,:quote_resource_show_org_subfield,:find_org_subfield_attache, - :search_files_in_subfield,:upload_files_menu] + :search_files_in_subfield,:upload_files_menu,:file_hidden,:republish_file] helper :sort include SortHelper @@ -96,6 +96,33 @@ class FilesController < ApplicationController end end + def file_hidden + @file = Attachment.find params[:id] + @course = Course.find params[:course_id] + respond_to do |format| + format.js + end + end + + def republish_file + @file = Attachment.find params[:id] + @course = Course.find params[:course_id] + if params[:publish_time] + unless params[:publish_time] == "" + @file.publish_time = params[:publish_time] + end + end + if @file.publish_time > Date.today + @file.is_publish = 0 + else + @file.is_publish = 1 + end + @file.save + respond_to do |format| + format.js + end + end + def search_project sort = "" @sort = "" @@ -488,6 +515,23 @@ class FilesController < ApplicationController if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') Mailer.run.attachments_added(attachments[:files]) end + if !attachments.empty? && attachments[:files] + attachments[:files].each do |attachment| + if params[:publish_time] + if params[:publish_time] == "" + attachment.publish_time = Date.today + else + attachment.publish_time = params[:publish_time] + end + else + attachment.publish_time = Date.today + end + if attachment.publish_time > Date.today + attachment.is_publish = 0 + end + attachment.save + end + end if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array) params[:course_attachment_type].each do |type| tag_name = get_tag_name_by_type_number type diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index bae0232a5..2a4bcf9c8 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -30,7 +30,8 @@ class OrgSubfieldsController < ApplicationController if params[:id] @organization = Organization.find(params[:id]) else - @organization = Organization.where("domain=?",request.subdomain).first + domain = Secdomain.where("subname=?", request.subdomain).first + @organization = Organization.find(domain.pid) end @org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+ "subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+ diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 6e2da311f..f225e7f50 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -139,7 +139,7 @@ class OrganizationsController < ApplicationController end def check_uniq_domain - @is_exist = (Organization.where("domain=?", params[:org_domain]).count > 0) + @is_exist = (Secdomain.where("subname=?",params[:org_domain]).count > 0) end def find_organization @@ -322,7 +322,12 @@ class OrganizationsController < ApplicationController def agree_apply_subdomain @organization = Organization.find(params[:organization_id]) OrgMessage.find(params[:act_id]).update_attribute(:viewed, 1) - @organization.update_attribute(:domain, params[:org_domain]) + if Secdomain.where("pid=? and sub_type=2",@organization.id).count > 0 + domain = Secdomain.where("pid=? and sub_type=2",params[:organization_id]).first + Secdomain.update(domain.id, :subname => params[:org_domain]) + else + Secdomain.create(:sub_type => 2, :pid => params[:organization_id], :subname => params[:org_domain]) + end if OrgMessage.where("message_type='AgreeApplySubdomain' and organization_id=#{@organization.id} and content=?",params[:org_domain]).count == 0 OrgMessage.create(:user_id => params[:user_id], :organization_id => @organization.id, :message_type => 'AgreeApplySubdomain', :message_id => @organization.id, :sender_id => User.current.id, :viewed => 0, :content => params[:org_domain]) end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index e0afc38ae..e6ff904f3 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -98,14 +98,22 @@ class StudentWorkController < ApplicationController elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 if @homework.homework_type == 3 pro = @homework.student_work_projects.where(:user_id => User.current.id).first - @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + if pro.nil? + @stundet_works = [] + else + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + end else @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) end elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 if @homework.homework_type == 3 pro = @homework.student_work_projects.where(:user_id => User.current.id).first - my_work = @homework.student_works.where(:id => pro.student_work_id) + if pro.nil? + my_work = [] + else + my_work = @homework.student_works.where(:id => pro.student_work_id) + end else my_work = @homework.student_works.where(:user_id => User.current.id) end @@ -113,7 +121,11 @@ class StudentWorkController < ApplicationController elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 if @homework.homework_type == 3 pro = @homework.student_work_projects.where(:user_id => User.current.id).first - my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + if pro.nil? + my_work = [] + else + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + end else my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) end @@ -134,14 +146,22 @@ class StudentWorkController < ApplicationController elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 if @homework.homework_type == 3 pro = @homework.student_work_projects.where(:user_id => User.current.id).first - @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + if pro.nil? + @stundet_works = [] + else + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + end else @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) end elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 if @homework.homework_type == 3 pro = @homework.student_work_projects.where(:user_id => User.current.id).first - my_work = @homework.student_works.where(:id => pro.student_work_id) + if pro.nil? + my_work = [] + else + my_work = @homework.student_works.where(:id => pro.student_work_id) + end else my_work = @homework.student_works.where(:user_id => User.current.id) end @@ -149,7 +169,11 @@ class StudentWorkController < ApplicationController elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 if @homework.homework_type == 3 pro = @homework.student_work_projects.where(:user_id => User.current.id).first - my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + if pro.nil? + my_work = [] + else + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + end else my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 625a1de74..fb35d8495 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2144,22 +2144,22 @@ class UsersController < ApplicationController if(params[:type].blank? || params[:type] == "1") #全部 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 - @attachments = Attachment.where("(author_id = #{params[:id]} 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(',')}))").order("created_on desc") + @attachments = Attachment.where("(author_id = #{params[:id]} and is_publish = 1 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)").order("created_on desc") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话,应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源 - @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " + + @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and is_publish = 1 " + "and container_type in('Project','OrgSubfield','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(',')}))").order("created_on desc") + "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1)").order("created_on desc") end elsif params[:type] == "2" #课程资源 if User.current.id.to_i == params[:id].to_i 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' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1) ").order("created_on desc") else 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')"+ - "or (container_type = 'Course' and is_public = 1 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 is_public = 1 and container_type = 'Course' and is_publish = 1)"+ + "or (container_type = 'Course' and is_public = 1 and is_publish = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc") end elsif params[:type] == "3" #项目资源 if User.current.id.to_i == params[:id].to_i diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 40ed4a21a..2cdb277be 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -746,7 +746,7 @@ module CoursesHelper return[] unless course result = [] course.attachments.each do |attachment| - if attachment.is_public? || User.current.member_of_course?(course) || User.current.admin? + if attachment.is_public? ||User.current == attachment.author ||User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id))|| (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin? result << attachment end end diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index bd023f6d0..6b748649b 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -123,7 +123,8 @@ module FilesHelper attachments.each do |attachment| if attachment.is_public? || (attachment.container_type == "Project" && User.current.member_of?(attachment.project)) || - (attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)))|| + (attachment.container_type == "Course" && User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id)))|| + (attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)) && attachment.is_publish == 1)|| attachment.author_id == User.current.id || attachment.container_type == "OrgSubfield" result << attachment diff --git a/app/views/blog_comments/_simple_ke_reply_form.html.erb b/app/views/blog_comments/_simple_ke_reply_form.html.erb index 292587cad..e222d8e56 100644 --- a/app/views/blog_comments/_simple_ke_reply_form.html.erb +++ b/app/views/blog_comments/_simple_ke_reply_form.html.erb @@ -1,16 +1,3 @@ - -
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
diff --git a/app/views/courses/_user_homework_search_list.html.erb b/app/views/courses/_user_homework_search_list.html.erb index 585d8761a..750e7537c 100644 --- a/app/views/courses/_user_homework_search_list.html.erb +++ b/app/views/courses/_user_homework_search_list.html.erb @@ -2,18 +2,6 @@ <%= import_ke(enable_at: true, prettify: false, init_activity: true) %> <% end %> -
<% homework_commons.each do |homework_common|%> diff --git a/app/views/courses/syllabus.html.erb b/app/views/courses/syllabus.html.erb index 8182c949c..e12876ce9 100644 --- a/app/views/courses/syllabus.html.erb +++ b/app/views/courses/syllabus.html.erb @@ -4,18 +4,6 @@ <%= javascript_include_tag 'blog' %> <% end %> - +发布设置 + +<%= form_tag(republish_file_course_file_path(@course,@file), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> +
+ +
+ + <%#= calendar_for('attachment_publish_time')%> +
+ +
+
+ +
+ + +
+<% end %> +
+ \ No newline at end of file diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb new file mode 100644 index 000000000..fd0a165aa --- /dev/null +++ b/app/views/files/_resource_detail.html.erb @@ -0,0 +1,77 @@ +<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %> +
+
+
+ <%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %> +
+
+
+ <%= link_to truncate(file.filename,length: 35, omission: '...'), + download_named_attachment_path(file.id, file.filename), + :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkBlue f_14 f_b" %> + <%= file_preview_eye(file, class: 'preview') %> + + <% if file.is_public? == false%> + 私有 + <%end %> + + <% if file.is_publish == 0 %> + <%=file.publish_time %>  0点发布 + <% end %> +
+
+ 上传时间:<%= format_time(file.created_on)%> + <% if file.tag_list.length > 0%> + 上传类型:<%= file.tag_list[0] %> + <% end %> +

文件大小:<%= number_to_human_size(file.filesize) %>

+

下载<%= file.downloads%>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

+
+
+
+ + <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %> + <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %> +
+
+ +
    +
  • + <% if User.current.logged? %> + + <% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %> + <% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %> +
      + +
    • <%= link_to("发       送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
    • +
    • <%= link_to '延期发布',file_hidden_course_file_path(@course,file),:class => "postOptionLink",:remote=>true %>
    • +
    • <%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %>
    • + <% if @course.is_public? %> +
    • + + <%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %> + +
    • + <%end%> +
    • + <%= link_to( '删除资源', attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %> +
    • +
    + + <% end %> + <%else%> +
      +
    • <%= link_to("发  送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
    • +
    + <% end %> + <% end %> +
  • +
+ +
+
+
+
+
+
\ No newline at end of file diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb index 6cce4bf2e..de43977cd 100644 --- a/app/views/files/_upload_course_files.erb +++ b/app/views/files/_upload_course_files.erb @@ -1,3 +1,4 @@ +

<%= l(:label_upload_files)%>

@@ -21,10 +22,20 @@ <%= render :partial => 'files/new_style_attachment_list',:locals => {:container => course} %>
- - <%= l(:button_cancel)%> - - <%= submit_tag '确定',:onclick=>'submit_resource();',:onfocus=>'this.blur()',:id=>'submit_resource',:class=>'sendSourceText fr' %> + <% if User.current.allowed_to?(:as_teacher,course) %> +
+ +
+ + <%#= calendar_for('attachment_publish_time')%> +
+ +
+
+ <% end %> + <%= l(:button_cancel)%> + <%= l(:button_confirm)%> + <%#= submit_tag '确定',:onclick=>'submit_course_resource();',:onfocus=>'this.blur()',:id=>'submit_resource',:class=>'sendSourceText fr' %> <% end %>
@@ -35,8 +46,39 @@
\ No newline at end of file diff --git a/app/views/files/file_hidden.js.erb b/app/views/files/file_hidden.js.erb new file mode 100644 index 000000000..b95ab5104 --- /dev/null +++ b/app/views/files/file_hidden.js.erb @@ -0,0 +1,6 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'files/hidden_file',:locals => {:course => @course,:course_attachment_type => 1}) %>'); +showModal('ajax-modal', '311px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); +$('#ajax-modal').parent().addClass("popbox_polls"); \ No newline at end of file diff --git a/app/views/files/republish_file.js.erb b/app/views/files/republish_file.js.erb new file mode 100644 index 000000000..e85e5eb50 --- /dev/null +++ b/app/views/files/republish_file.js.erb @@ -0,0 +1,2 @@ +hideModal(); +$("#resource_detail_<%=@file.id %>").html("<%= escape_javascript(render :partial=>'files/resource_detail',:locals => {:file => @file}) %>") \ No newline at end of file diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index ad5d971ed..b63897951 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -1,18 +1,7 @@ <%= content_for(:header_tags) do %> <%= import_ke(enable_at: true,init_activity: true) %> <% end %> - + +<% domain = Secdomain.where("sub_type=2 and pid=?", @organization.id).first %>
配置
@@ -53,12 +54,12 @@
组织描述:
-
+
组织URL:
http:// - + .trustie.net申请 - <% if @organization.domain.present? and OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first.content == @organization.domain %> + <% if domain.present? and OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first.content == domain.subname %> (已批准) <% elsif OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).count > 0 %> (您申请了子域名<%= OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first.content %>,还未批准) @@ -127,8 +128,8 @@

域名目录(用户自定义url,可选)

- <% if @organization.domain %> - <%= @organization.domain %>.trustie.net/ + <% if domain %> + <%= domain.subname %>.trustie.net/ <% else %> 您还没有子域名,请先在左侧信息栏申请子域名 <% end %> diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb index 75b07557e..b04f96db5 100644 --- a/app/views/poll/_poll.html.erb +++ b/app/views/poll/_poll.html.erb @@ -62,7 +62,7 @@ <% if has_commit%>
  • <%= link_to l(:label_statistical_results), statistics_result_poll_path(poll.id), :class => "pollsbtn fr mr10"%>
  • <%else%> -
  • 统计结果
  • +
  • 统计结果
  • <%end%> <% end %> <% end%> \ No newline at end of file diff --git a/app/views/projects/_project_activities.html.erb b/app/views/projects/_project_activities.html.erb index 062d64096..c036633a5 100644 --- a/app/views/projects/_project_activities.html.erb +++ b/app/views/projects/_project_activities.html.erb @@ -35,18 +35,7 @@ }) }) - + <% unless forge_acts.empty? %> <% forge_acts.each do |activity| -%> - + <% user_activities.each do |user_activity| if user_activities %>