diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 03581d0c2..7ccfb0e10 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -80,7 +80,7 @@ class BoardsController < ApplicationController includes(:last_reply). limit(@topic_pages.per_page). offset(@topic_pages.offset). - order(sort_clause). + order("last_replies_messages.created_on desc"). preload(:author, {:last_reply => :author}). all elsif @course @@ -88,7 +88,7 @@ class BoardsController < ApplicationController includes(:last_reply). # limit(@topic_pages.per_page). # offset(@topic_pages.offset). - order(sort_clause). + order("last_replies_messages.created_on desc"). preload(:author, {:last_reply => :author}). all : [] @topics = paginateHelper board_topics,10 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9c261df85..bb62695c0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -593,6 +593,17 @@ module ApplicationHelper Project.project_tree(projects, &block) end + # 判断当前用户是否为项目管理员 + def is_project_manager?(user_id,project_id) + @result = false + mem = Member.where("user_id = ? and project_id = ?",user_id, project_id) + unless mem.blank? + mem.first.roles.to_s.include?("Manager") + @result = false + end + return @result + end + def principals_check_box_tags(name, principals) s = '' principals.each do |principal| diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb index 24256ccab..c3e7fc3ff 100644 --- a/app/views/attachments/upload.js.erb +++ b/app/views/attachments/upload.js.erb @@ -3,14 +3,15 @@ var fileSpan = $('#attachments_<%= j params[:attachment_id] %>'); fileSpan.hide(); alert("<%= escape_javascript @attachment.errors.full_messages.join(', ') %>"); <% else %> -$('', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan); fileSpan.find('a.remove-upload') - .attr({ - "data-remote": true, - "data-method": 'delete', - "href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' - }) - .off('click'); + .attr({ + "data-remote": true, + "data-method": 'delete', + "href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' + }) + .off('click'); +$('', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan); + //var divattach = fileSpan.find('div.div_attachments'); //divattach.html('<%= j(render :partial => 'tags/tagEx', :locals => {:obj => @attachment, :object_flag => "6"})%>'); <% end %> diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index fba80127b..a380ad67f 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -3,7 +3,7 @@ <%= render :partial => 'form_course', :locals => {:f => f, :topic => @message} %>
  • <%= l(:button_cancel) %> - <%= l(:button_submit)%> + <%= l(:button_submit)%>
  • <% end %> diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 5dde6c460..2d0bda162 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -32,7 +32,7 @@

    讨论区共有<%= @topic_count %>个帖子

    <% if @topics.any? %> <% @topics.each do |topic| %> -
    +
    <%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %>
    <% author = topic.author.to_s + ":" %> @@ -40,12 +40,10 @@

      <%= h(topic.subject) %>

    <% if topic.course_editable_by?(User.current) %> - <%= l(:button_edit) %> - <% end %> - <% if topic.sticky? %> - <%= l(:label_board_sticky)%> + <%= l(:button_edit) %> <% end %> + <%= link_to( l(:button_delete), {:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'}, @@ -55,7 +53,9 @@ :style => ' margin-right: 10px;' ) if topic.destroyable_by?(User.current) %> - + <% if topic.sticky? %> + <%= l(:label_board_sticky)%> + <% end %>
    - <%= topic.content %> + <%= topic.content.html_safe %>
    @@ -100,7 +100,8 @@ <%= form_for reply, :as => :reply, :url => {:controller=>'messages',:action => 'reply', :id => topic.id, :board_id => topic.board_id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message_form' + topic.id.to_s} do |f| %> <%= render :partial => 'form_project', :locals => {:f => f, :replying => true} %> - <%= l(:label_memo_create)%> + <%= toggle_link l(:button_cancel), "reply" + topic.id.to_s, :focus => 'message_content',:class => 'grey_btn fr ml10' %> + <%= l(:label_memo_create)%> <% end %>
    diff --git a/app/views/boards/_edit.html.erb b/app/views/boards/_edit.html.erb index 15358c03a..0bb15b167 100644 --- a/app/views/boards/_edit.html.erb +++ b/app/views/boards/_edit.html.erb @@ -12,7 +12,7 @@ } do |f| %> <%= render :partial => 'form_project', :locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %> - <%= l(:button_submit)%> + <%= l(:button_submit)%> <%= l(:button_cancel) %> <%#= link_to l(:button_cancel), board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "blue_btn grey_btn fl c_white" %> @@ -31,10 +31,10 @@ } do |f| %> <%= render :partial => 'form_course', :locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %> - <%= l(:button_submit)%> - <%= link_to l(:button_cancel), board_message_url(topic.board,topic.root, :r => (topic.parent_id &&topic.id)), :class => "blue_btn grey_btn fl c_white" %> + <%= l(:button_submit)%> + <%= l(:button_cancel) %> - <% end %> + <% end %>
    <% end %> diff --git a/app/views/boards/_form_course.html.erb b/app/views/boards/_form_course.html.erb index 09ee1c3b4..945f58c22 100644 --- a/app/views/boards/_form_course.html.erb +++ b/app/views/boards/_form_course.html.erb @@ -8,16 +8,16 @@ <%= f.text_field :subject, { size: 60, id: "message_subject",:class=>"talk_input w585" }.merge(extra_option) %> -

    +

    <% else %>
  • - <%= f.text_field :subject, { size: 60, id: "message_subject", onkeyup: "regexSubject();",:class=>"talk_input w585" }.merge(extra_option) %> + <%= f.text_field :subject, { size: 60, id: "message_subject#{f.object.id}", onkeyup: "regexSubject('#{f.object.id}');",:class=>"talk_input w585" }.merge(extra_option) %> -

    +

  • <% end %>
  • @@ -40,12 +40,12 @@ <% end %> <%= text_area :quote,:quote,:style => 'display:none' %> <% if replying%> - <%= f.text_area :content, :class => 'talk_text fl', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)", :style=>"width: 575px;" %> + <%= f.text_area :content, :class => 'talk_text fl', :id => "message_content#{f.object.id}", :onkeyup => "regexContent('#{f.object.id}');", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)", :style=>"width: 575px;" %> <% else %> - <%= f.text_area :content, :class => 'talk_text fl', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)" %> + <%= f.text_area :content, :class => 'talk_text fl', :id => "message_content#{f.object.id}", :onkeyup => "regexContent('#{f.object.id}');", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)" %> <% end %>
    -

    +

  • diff --git a/app/views/boards/_form_project.html.erb b/app/views/boards/_form_project.html.erb index 3ecffa3e2..8288debe2 100644 --- a/app/views/boards/_form_project.html.erb +++ b/app/views/boards/_form_project.html.erb @@ -5,19 +5,19 @@
  • - <%= f.text_field :subject, { size: 60, id: "message_subject",:class=>"talk_input w585" }.merge(extra_option) %> + <%= f.text_field :subject, { size: 60, id: "message_subject#{f.object.id}",:class=>"talk_input w585" }.merge(extra_option) %> -

    +

  • <% else %>
  • - <%= f.text_field :subject, { size: 60, id: "message_subject", onkeyup: "regexSubject();",:class=>"talk_input w585" }.merge(extra_option) %> + <%= f.text_field :subject, { size: 60, id: "message_subject#{f.object.id}", onkeyup: "regexSubject('#{f.object.id}');",:class=>"talk_input w585" }.merge(extra_option) %> -

    +

  • <% end %>
  • @@ -36,16 +36,16 @@
  • <% unless replying %> - + <% end %> <%= text_area :quote,:quote,:style => 'display:none' %> <% if replying%> - <%= f.text_area :content, :class => 'talk_text fl', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)", :style=>"width: 575px;" %> + <%= f.text_area :content, :class => 'talk_text fl', :id => "message_content#{f.object.id}", :onkeyup => "regexContent('#{f.object.id}');", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)", :style=>"width: 575px;" %> <% else %> - <%= f.text_area :content, :class => 'talk_text fl', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)" %> + <%= f.text_area :content, :class => 'talk_text fl', :id => "message_content#{f.object.id}", :onkeyup => "regexContent('#{f.object.id}');", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)" %> <% end %>
    -

    +

  • diff --git a/app/views/boards/_project_new_topic.html.erb b/app/views/boards/_project_new_topic.html.erb index 3f7c569e1..cab1bbb7b 100644 --- a/app/views/boards/_project_new_topic.html.erb +++ b/app/views/boards/_project_new_topic.html.erb @@ -4,7 +4,7 @@
  • <%= l(:button_cancel) %> - <%= l(:button_submit)%> + <%= l(:button_submit)%>
  • <% end %> \ No newline at end of file diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index 8a9ffd990..63bb66a6a 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -33,7 +33,7 @@ <% if @topics.any? %> <% @topics.each do |topic| %> -
    +
    <%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %>
    <% author = topic.author.to_s + ":" %> @@ -215,20 +215,5 @@ $("#message_form").submit(); } } - function regexContent() - { - var content = $.trim($("#message_content").val()); - if(content.length ==0) - { - $("#message_content_span").text("<%= l(:label_reply_empty) %>"); - $("#message_content_span").css('color','#ff0000'); - flag = false; - } - else - { - $("#message_content_span").text("<%= l(:label_field_correct) %>"); - $("#message_content_span").css('color','#008000'); - flag = true; - } - } + \ No newline at end of file diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index 2e736bdf7..c111aeaf0 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -25,14 +25,29 @@ <% if @project %> <%= render :partial => 'project_show', locals: {project: @project} %> diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 2a818b892..cc3bb33f1 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -15,7 +15,7 @@   <%= l(:label_new_activity) %>: <%= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : - (e.event_type.eql?("bid") ? homework_course_path(@course) : e.event_url),:class => "problem_tit c_dblue fl fb"%> + (e.event_type.eql?("bid") ? homework_course_path(@course) : (e.event_type.eql?("message") || e.event_type.eql?("reply") ? course_boards_path(@course,:topic_id => e.id) : e.event_url)),:class => "problem_tit c_dblue fl fb"%>

    <%= e.event_description.html_safe %>
    diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb index b2862a634..d3e383a4e 100644 --- a/app/views/files/_project_file_list.html.erb +++ b/app/views/files/_project_file_list.html.erb @@ -20,16 +20,14 @@

    <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> <% if User.current.logged? %> - - - <%# if project.is_public? %> + <%#--私有项目资源不能引用,不能设置公开私有--%> + <%#--公开项目资源可以应用,管理员和资源上传者拥有设置公开私有权限--%> <%= link_to(l(:label_slected_to_other_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> - <% if (Member.where(:user_id => User.current.id, :project_id => @project.id).first.roles.to_s.include?("Manager") || file.author_id == User.current.id) && project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project" %> + <% if (is_project_manager?(User.current.id, @project.id) || file.author_id == User.current.id) && project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project" %> <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> <% end %> - <%# end %> <% end %>
    diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 972606f31..f3c453019 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -66,9 +66,7 @@ <%= link_to h(e.user), user_path(e.user_id), :class => "problem_name c_orange fl" %> <%= l(:label_new_activity) %> : <%= link_to format_activity_title("#{act.board.name}: #{act.subject}"), - {:controller => 'messages', - :action => 'show', - :board_id => act.board_id}.merge(act.parent_id.nil? ? {:id => act.id} : {:id => act.parent_id, :r => act.id, :anchor => "message-#{act.id}"}), + project_boards_path(@project,:topic_id => act.id), :class => "problem_tit fl fb " %>

    <%= textAreailizable act,:content %>
    diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index fe36b2cd1..6083b547c 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -323,10 +323,9 @@   <%= link_to format_activity_title("#{act.board.name}: #{act.subject}"), - {:controller => 'messages', - :action => 'show', - :board_id => act.board_id}.merge(act.parent_id.nil? ? {:id => act.id} : {:id => act.parent_id, :r => act.id, :anchor => "message-#{act.id}"}) %> - + act.board.project ? project_boards_path(act.board.project,:topic_id => act.id) : course_boards_path(act.board.course,:topic_id => act.id), + :class => "problem_tit fl fb " %> + <% else %> diff --git a/app/views/users/user_activities.html.erb b/app/views/users/user_activities.html.erb index 080e772a1..9165e6f2e 100644 --- a/app/views/users/user_activities.html.erb +++ b/app/views/users/user_activities.html.erb @@ -28,7 +28,13 @@ - + diff --git a/public/javascripts/course.js b/public/javascripts/course.js index f0b1338da..227048ef6 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -151,45 +151,48 @@ function submit_edit_course(id) /////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////课程讨论区 -function regexSubject() -{ - var content = $.trim($("#message_subject").val()); - if(content.length ==0) - { - $("#subject_span").text("主题不能为空"); - $("#subject_span").css('color','#ff0000'); +function regexSubject(id) { + var subjectid = "#message_subject" + id ; + var content = $.trim($(subjectid).val()); + var message = "#subject_span" + id; + if (content.length == 0) { + $(message).text("主题不能为空"); + $(message).css('color', '#ff0000'); return false; } - else - { - $("#subject_span").text("填写正确"); - $("#subject_span").css('color','#008000'); + else { + $(message).text("填写正确"); + $(message).css('color', '#008000'); return true; } return false; } -function regexContent() -{ - var content = message_content_editor.html(); - if(content.length ==0) - { - $("#message_content_span").text("描述不能为空"); - $("#message_content_span").css('color','#ff0000'); +function regexContent(id) { + var contentid = "#message_content" + id; + var message = "#message_content_span"+ id; + var content = $.trim($(contentid).val()); + if (content.length == 0) { + $(message).text("描述不能为空"); + $(message).css('color', '#ff0000'); return false; } - else - { - $("#message_content_span").text("填写正确"); - $("#message_content_span").css('color','#008000'); + else { + $(message).text("填写正确"); + $(message).css('color', '#008000'); return true; } return false; } -function submitCoursesBoard() -{ - message_content_editor.sync(); - if(regexSubject()&®exContent()){$("#message-form").submit();} + +// 项目讨论区编辑和提交 +function submitProjectsBoard(id) { + var formid = "#message-form" + id; + if (regexSubject(id) && regexContent(id)) { + $(formid).submit(); + } } + + /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// 课程通知 function regexTitle() diff --git a/public/javascripts/project.js b/public/javascripts/project.js index 0bc094b1d..70888e5d0 100644 --- a/public/javascripts/project.js +++ b/public/javascripts/project.js @@ -144,42 +144,51 @@ $(function(){ /////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////项目讨论区 -function regexSubject() { - var content = $.trim($("#message_subject").val()); +function regexSubject(id) { + + var subjectid = "#message_subject" + id ; + var content = $.trim($(subjectid).val()); + var message = "#subject_span" + id; if (content.length == 0) { - $("#subject_span").text("主题不能为空"); - $("#subject_span").css('color', '#ff0000'); + $(message).text("主题不能为空"); + $(message).css('color', '#ff0000'); return false; } else { - $("#subject_span").text("填写正确"); - $("#subject_span").css('color', '#008000'); + $(message).text("填写正确"); + $(message).css('color', '#008000'); return true; } return false; } -function regexContent() { - var content = $.trim($("#message_content").val()); +function regexContent(id) { + + var contentid = "#message_content" + id; + var message = "#message_content_span"+ id; + var content = $.trim($(contentid).val()); if (content.length == 0) { - $("#message_content_span").text("描述不能为空"); - $("#message_content_span").css('color', '#ff0000'); + + $(message).text("描述不能为空"); + $(message).css('color', '#ff0000'); return false; } else { - $("#message_content_span").text("填写正确"); - $("#message_content_span").css('color', '#008000'); + + $(message).text("填写正确"); + $(message).css('color', '#008000'); return true; } return false; } // 项目讨论区编辑和提交 -function submitProjectsBoard() { - if (regexSubject() && regexContent()) { - $("#message-form").submit(); +function submitProjectsBoard(id) { + var formid = "#message-form" + id; + + if (regexSubject(id) && regexContent(id)) { + $(formid).submit(); } } - // 提交新闻 function regexTitle() { var name = $("#news_title").val(); diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index 14a7a9a34..3b04e23bf 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -738,6 +738,6 @@ a:hover.Reply_pic{border:1px solid #64bdd9;} .Replybox{ float:left; width:495px; margin-left:5px;} .talk_nextpage{ border:none; width:410px; margin:0 auto;} .newtalk { margin-top:8px; margin-right:8px;} -.talk_new{ border-bottom:1px dashed #d9d9d9; padding-bottom:10px;} + #about_newtalk{ display:none;}
    <%= content_tag('span', h(e.project), :class => 'project') %> <%= l(:label_new_activity) %> <%= link_to format_activity_title(e.event_title), e.event_url %> <%= content_tag('span', h(e.project), :class => 'project') %> <%= l(:label_new_activity) %> + <% if e.event_type.eql?("message") || e.event_type.eql?("reply") %> + <%= link_to format_activity_title(e.event_title), e.board.project ? project_boards_path(e.board.project,:topic_id => e.id):course_boards_path(e.board.course,:topic_id => e.id) %> + <%else %> + <%= link_to format_activity_title(e.event_title), e.event_url %> + <%end%> +

    <%= format_activity_description(e.event_description) %>