diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 86c220bd2..7632cf591 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -381,6 +381,11 @@ class ApplicationController < ActionController::Base if allowed true else + if params[:action] == 'show' + #更新申请结果反馈消息的状态 + messages = CourseMessage.where("course_message_type =? and course_id =? and user_id =? and viewed =?", 'CourseRequestDealResult', @course.id, User.current.id, false) + messages.update_all(:viewed => true) + end if @course && @course.archived? render_403 :message => :notice_not_authorized_archived_project else diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index ee953e913..37182dbcf 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -227,6 +227,8 @@ class AttachmentsController < ApplicationController format.js elsif @attachment.container.is_a?(Message) format.html { redirect_to_referer_or new_board_message_path(@attachment.container) } + elsif @attachment.container.is_a?(BlogComment) + format.html { redirect_to_referer_or user_blog_blog_comment_path(:user_id=>@attachment.container.author.id,:blog_id=>@attachment.container.blog_id,:id=>@attachment.container.id)} elsif @course.nil? format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } else diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb new file mode 100644 index 000000000..95790a68d --- /dev/null +++ b/app/controllers/blog_comments_controller.rb @@ -0,0 +1,121 @@ +class BlogCommentsController < ApplicationController + include ApplicationHelper + before_filter :find_user + def index + + end + def create + if User.current.logged? + @article = BlogComment.new + @article.author = User.current + @article.blog_id = params[:blog_id] + @article.safe_attributes = params[:blog_comment] + if request.post? + @article.save_attachments(params[:attachments]) + if @article.save + # 更新kindeditor上传的图片资源所有者 + # if params[:asset_id] + # ids = params[:asset_id].split(',') + # update_kindeditor_assets_owner ids,@article.id,OwnerTypeHelper::BLOGCOMMENT + # end + render_attachment_warning_if_needed(@article) + else + end + redirect_to user_blogs_path(:user_id=>params[:user_id]) + else + respond_to do |format| + format.html { + render :layout => 'new_base_user' + } + end + end + else + redirect_to signin_path + end + end + def new + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + def show + @article = BlogComment.find(params[:id]) + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + def update + @article = BlogComment.find(params[:id]) + @article.safe_attributes = params[:blog_comment] + @article.save_attachments(params[:attachments]) + if @article.save + render_attachment_warning_if_needed(@article) + else + end + redirect_to user_blog_blog_comment_path(:user_id=>params[:user_id],:blog_id=>params[:blog_id],:id=>params[:id]) + end + def destroy + @article = BlogComment.find(params[:id]) + if @article.parent_id.nil? #如果是文章被删,那么跳转到用户博客界面 + @article.children.delete + @article.delete + redirect_to user_blogs_path(:user_id=>User.current) + else + root = @article.root + @article.delete + redirect_to user_blog_blog_comment_path(:user_id=>root.author_id,:blog_id=>root.blog_id,:id=>root.id) + end + end + + def edit + @article = BlogComment.find(params[:id]) + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + + def quote + @blogComment = BlogComment.find(params[:id]) + @subject = @blogComment.title + @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') + + @content = "> #{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}\n> " + @temp = BlogComment.new + @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}
#{@blogComment.content.html_safe}
".html_safe + respond_to do | format| + format.js + end + end + + #回复 + def reply + @article = BlogComment.find(params[:id]).root + @quote = params[:quote][:quote] + @blogComment = BlogComment.new + @blogComment.author = User.current + @blogComment.blog = Blog.find(params[:blog_id]) + params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 + params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 + @blogComment.safe_attributes = params[:blog_comment] + @blogComment.content = @quote + @blogComment.content + @blogComment.title = "RE: #{@article.title}" unless params[:blog_comment][:title] + @article.children << @blogComment + @user_activity_id = params[:user_activity_id] + + attachments = Attachment.attach_files(@blogComment, params[:attachments]) + render_attachment_warning_if_needed(@blogComment) + #@article.save + # redirect_to user_blogs_path(:user_id=>params[:user_id]) + respond_to do |format| + format.html { redirect_to user_blog_blog_comment_path(:user_id=>@article.author_id,:blog_id=>@article.blog_id,:id=>@article)} + format.js + end + rescue Exception => e #如果上面的代码执行发生异常就捕获 + flash[:notice] = e.message + end + + private + def find_user + @user = User.find(params[:user_id]) + end +end diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb new file mode 100644 index 000000000..07bf60464 --- /dev/null +++ b/app/controllers/blogs_controller.rb @@ -0,0 +1,47 @@ +class BlogsController < ApplicationController + before_filter :find_blog,:except => [:index,:create,:new] + before_filter :find_user + def index + @articls = @user.blog.articles + @article = BlogComment.new + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + def create + + end + def new + + end + def show + + end + def update + + end + def destory + + end + def edit + + end + private + def find_blog + if params[:blog_id] + @blog = Blog.find(params[:blog_id]) + else + render_404 + end + if @blog.nil? + #如果某个user的blog不存在,那么就创建一条 + @blog = Blog.create(:name=>User.find(params[:id]).realname , + :description=>'', + :author_id=>params[:id]) + end + end + + def find_user + @user = User.find(params[:user_id]) + end +end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 56252253a..c8c482f81 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -31,7 +31,6 @@ class CoursesController < ApplicationController def join if User.current.logged? - # if params[:role] == 10 cs = CoursesService.new @user = User.current join = cs.join_course params,@user @@ -289,14 +288,11 @@ class CoursesController < ApplicationController def export_course_member_excel @all_members = student_homework_score(0,0,0,"desc") filename="#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}"; - # 如果是ie 需要转码 - if(/trident/.match(request.env["HTTP_USER_AGENT"]) != nil) - filename= URI::encode(filename) - end + respond_to do |format| format.xls { send_data(member_to_xls(@all_members,@course.course_groups), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{filename}.xls") + :filename => filename_for_content_disposition("#{filename}.xls")) } end end @@ -617,6 +613,10 @@ class CoursesController < ApplicationController 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) create_course_messages.update_all(:viewed => true) + #更新申请结果反馈消息的状态 + course_request_messages = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @course.id, 'CourseRequestDealResult', false) + course_request_messages.update_all(:viewed => true) + course_activities = @course.course_activities @canShowRealName = User.current.member_of_course? @course @page = params[:page] ? params[:page].to_i + 1 : 0 diff --git a/app/controllers/gantts_controller.rb b/app/controllers/gantts_controller.rb index ee132ac29..710bb2f47 100644 --- a/app/controllers/gantts_controller.rb +++ b/app/controllers/gantts_controller.rb @@ -42,8 +42,8 @@ class GanttsController < ApplicationController respond_to do |format| format.html { render :action => "show", :layout => 'base_projects' }#by young - format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image') - format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => "#{basename}.pdf") } + format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => filename_for_content_disposition("#{basename}.png")) } if @gantt.respond_to?('to_image') + format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{basename}.pdf") ) } end end end diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 5dd5363b9..93459578c 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -33,7 +33,7 @@ class HomeworkAttachController < ApplicationController format.js format.xls { send_data(homework_to_xls(@all_homework_list), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_not_rated)}).xls") + :filename => filename_for_content_disposition("#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_not_rated)}).xls") ) } end end @@ -66,7 +66,7 @@ class HomeworkAttachController < ApplicationController format.js format.xls { send_data(homework_to_xls(all_homework_list), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_been_rated)}).xls") + :filename => filename_for_content_disposition("#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_been_rated)}).xls") ) } end end @@ -101,7 +101,7 @@ class HomeworkAttachController < ApplicationController format.js format.xls { send_data(homework_to_xls(all_homework_list), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}.xls") + :filename => filename_for_content_disposition("#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}.xls") ) } end end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 923414583..e529dd3b9 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -151,7 +151,7 @@ class IssuesController < ApplicationController format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } format.pdf { pdf = issue_to_pdf(@issue, :journals => @journals) - send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") + send_data(pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{@project.identifier}-#{@issue.id}.pdf") ) } end end diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index a8f2a11f1..ec54ae8a4 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -413,7 +413,7 @@ class PollController < ApplicationController respond_to do |format| format.xls { send_data(poll_to_xls(poll_questions), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@poll.polls_name}.xls") + :filename => filename_for_content_disposition("#{@poll.polls_name}.xls") ) } end end diff --git a/app/controllers/stores_controller.rb b/app/controllers/stores_controller.rb index 85ea85241..0d1755294 100644 --- a/app/controllers/stores_controller.rb +++ b/app/controllers/stores_controller.rb @@ -84,7 +84,7 @@ class StoresController < ApplicationController respond_to do |format| format.xls { send_data(homework_to_xls(attachments), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{l(:label_file_lost_list)}.xls") + :filename => filename_for_content_disposition("#{l(:label_file_lost_list)}.xls") ) } end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7425692c0..6d049783e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -918,6 +918,12 @@ class UsersController < ApplicationController end def show + #更新用户申请成为课程老师或教辅消息的状态 + if params[:course_id] != nil + join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?", + params[:course_id], 'JoinCourseRequest', User.current.id, @user.id, false) + join_course_messages.update_all(:viewed => true) + end @page = params[:page] ? params[:page].to_i + 1 : 0 user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index da6d48b8d..c0351c6da 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -82,14 +82,14 @@ class WikiController < ApplicationController @content = @page.content_for_version(params[:version]) if User.current.allowed_to?(:export_wiki_pages, @project) if params[:format] == 'pdf' - send_data(wiki_page_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf") + send_data(wiki_page_to_pdf(@page, @project), :type => 'application/pdf', :filename => filename_for_content_disposition("#{@page.title}.pdf") ) return elsif params[:format] == 'html' export = render_to_string :action => 'export', :layout => false - send_data(export, :type => 'text/html', :filename => "#{@page.title}.html") + send_data(export, :type => 'text/html', :filename => filename_for_content_disposition("#{@page.title}.html")) return elsif params[:format] == 'txt' - send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt") + send_data(@content.text, :type => 'text/plain', :filename => filename_for_content_disposition("#{@page.title}.txt") ) return end end @@ -286,7 +286,7 @@ class WikiController < ApplicationController send_data(export, :type => 'text/html', :filename => "wiki.html") } format.pdf { - send_data(wiki_pages_to_pdf(@pages, @project), :type => 'application/pdf', :filename => "#{@project.identifier}.pdf") + send_data(wiki_pages_to_pdf(@pages, @project), :type => 'application/pdf', :filename => filename_for_content_disposition("#{@project.identifier}.pdf") ) } end end diff --git a/app/helpers/blog_comments_helper.rb b/app/helpers/blog_comments_helper.rb new file mode 100644 index 000000000..2b0c3e5bd --- /dev/null +++ b/app/helpers/blog_comments_helper.rb @@ -0,0 +1,2 @@ +module BlogCommentsHelper +end diff --git a/app/helpers/blogs_helper.rb b/app/helpers/blogs_helper.rb new file mode 100644 index 000000000..cc0dbd200 --- /dev/null +++ b/app/helpers/blogs_helper.rb @@ -0,0 +1,2 @@ +module BlogsHelper +end diff --git a/app/helpers/owner_type_helper.rb b/app/helpers/owner_type_helper.rb index c03f2d19e..7119d4f60 100644 --- a/app/helpers/owner_type_helper.rb +++ b/app/helpers/owner_type_helper.rb @@ -7,4 +7,5 @@ module OwnerTypeHelper BID = 6 JOURNALSFORMESSAGE = 7 HOMEWORKCOMMON = 8 + BLOGCOMMENT=9 end \ No newline at end of file diff --git a/app/models/blog.rb b/app/models/blog.rb new file mode 100644 index 000000000..bd338cdad --- /dev/null +++ b/app/models/blog.rb @@ -0,0 +1,16 @@ +class Blog < ActiveRecord::Base + # attr_accessible :title, :body + include Redmine::SafeAttributes + belongs_to :user + has_many :articles, :class_name => 'BlogComment', :conditions => "#{BlogComment.table_name}.parent_id IS NULL ", :order => "#{BlogComment.table_name}.created_on DESC" + has_many :blog_comments, :dependent => :destroy, :order => "#{BlogComment.table_name}.created_on DESC" + belongs_to :last_comment, :class_name => 'BlogComment', :foreign_key => :last_comment_id + acts_as_tree :dependent => :nullify + #acts_as_list :scope => '(user_id = #{user_id} AND parent_id #{user_id ? = "#{parent_id}" : "IS NULL"})' + acts_as_watchable + + validates :name, presence: true, length: {maximum: 30} + validates :description, length: {maximum: 255} + + safe_attributes 'name', 'description' +end diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb new file mode 100644 index 000000000..92970b663 --- /dev/null +++ b/app/models/blog_comment.rb @@ -0,0 +1,24 @@ +class BlogComment < ActiveRecord::Base + # attr_accessible :title, :body + include Redmine::SafeAttributes + belongs_to :blog + belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' + + acts_as_tree :counter_cache => :comments_count, :order => "#{BlogComment.table_name}.sticky desc ,#{BlogComment.table_name}.created_on ASC" + acts_as_attachable + belongs_to :last_reply, :class_name => 'BlogComment', :foreign_key => 'last_comment_id' + + acts_as_watchable + + validates_presence_of :title, :content + validates_length_of :title, :maximum => 255 + #validate :cannot_reply_to_locked_comment, :on => :create + safe_attributes 'title', 'content',"sticky", "locked" + + def deleted_attach_able_by? user + (user && user.logged? && (self.author == user) ) || user.admin? + end + + def project + end +end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index d797f1ce1..8891e6552 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -1009,6 +1009,16 @@ class Mailer < ActionMailer::Base end end + def join_course_request(course, user, role) + @receive = User.find(course.tea_id) + @course = course + @user = user + @role = role + @subject = "#{@user.show_name} #{l(:label_apply_join_course)} #{@course.name} " + mail :to => @receive.mail, + :subject => @subject + end + private @@ -1066,4 +1076,5 @@ class Mailer < ActionMailer::Base 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] } return newpass end + end diff --git a/app/models/user.rb b/app/models/user.rb index d66785460..7aaae3492 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -93,6 +93,7 @@ class User < Principal has_many :changesets, :dependent => :nullify has_one :preference, :dependent => :destroy, :class_name => 'UserPreference' has_one :rss_token, :class_name => 'Token', :conditions => "action='feeds'" + has_one :blog, :class_name => 'Blog', :foreign_key => "author_id" has_one :api_token, :class_name => 'Token', :conditions => "action='api'" belongs_to :auth_source belongs_to :ucourse, :class_name => 'Course', :foreign_key => :id #huang @@ -255,6 +256,18 @@ class User < Principal # count = self.journals_for_messages(:conditions => ["status=? and is_readed = ? " ,1, 0]).count end + def blog + @blog = Blog.where("author_id = #{self.id}").all[0] + if @blog.nil? + #如果某个user的blog不存在,那么就创建一条,并且跳转 + @blog = Blog.create(:name=>(User.find(self.id).realname), + :description=>'', + :author_id=>self.id) + @blog.save + end + @blog + end + # 查询指派给我的缺陷记录 def count_new_issue_assign_to self.issue_assigns diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index fb01e0398..807a26232 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -317,6 +317,7 @@ class CoursesService elsif current_user.allowed_to?(:as_teacher,course) @state = 3 else + Mailer.run.join_course_request(course, User.current, params[:role]) #如果加入角色为教师或者教辅 CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) @state = 6 @@ -325,25 +326,26 @@ class CoursesService @state = 1 end else - if params[:course_password] == course.password - if params[:role] == "10" - members = [] - members << Member.new(:role_ids => [10], :user_id => current_user.id) - course.members << members - StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) - @state = 0 + if params[:course_password] == course.password + if params[:role] == "10" + members = [] + members << Member.new(:role_ids => [10], :user_id => current_user.id) + course.members << members + StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) + @state = 0 + else + #如果已经发送过消息了,那么就要给个提示 + if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count != 0 + @state = 7 + else + Mailer.run.join_course_request(course, User.current, params[:role]) + CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) + @state = 6 + end + end else - #如果已经发送过消息了,那么就要给个提示 - if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count != 0 - @state = 7 - else - CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) - @state = 6 - end + @state = 1 end - else - @state = 1 - end end end else diff --git a/app/views/blog_comments/_attachments_links.html.erb b/app/views/blog_comments/_attachments_links.html.erb new file mode 100644 index 000000000..ca0f41d16 --- /dev/null +++ b/app/views/blog_comments/_attachments_links.html.erb @@ -0,0 +1,41 @@ +
+ <% for attachment in attachments %> + + + + <% if options[:length] %> + + <%= link_to_short_attachment attachment, :class => 'fl FilesName02', :download => true,:length => options[:length] -%> + (<%= number_to_human_size attachment.filesize , :precision => 0 %>) + <% if options[:deletable] %> + <%#= link_to image_tag('delete.png'), attachment_path(attachment), + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete, + :class => 'delete', + #:remote => true, + #:id => "attachments_" + attachment.id.to_s, + :title => l(:button_delete) %> + + <% end %> +
+ <% else %> + + <%= link_to_short_attachment attachment, :class => 'fl FilesName02', :download => true, :length => 45 -%> + (<%= number_to_human_size attachment.filesize , :precision => 0 %>) + <% if options[:deletable] %> + + <% end %> +
+ <% end %> + <% end %> + <% if defined?(thumbnails) && thumbnails %> + <% images = attachments.select(&:thumbnailable?) %> + <% if images.any? %> +
+ <% images.each do |attachment| %> +
<%= thumbnail_tag(attachment) %>
+ <% end %> +
+ <% end %> + <% end %> +
diff --git a/app/views/blog_comments/_blog_attachments.erb b/app/views/blog_comments/_blog_attachments.erb new file mode 100644 index 000000000..48fe91099 --- /dev/null +++ b/app/views/blog_comments/_blog_attachments.erb @@ -0,0 +1,78 @@ + +
+ +<% if defined?(container) && container && container.saved_attachments %> + <% container.attachments.each_with_index do |attachment, i| %> + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %><%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %><%= l(:field_is_public) %>: + <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %> + <%= if attachment.id.nil? + #待补充代码 + else + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') + end + %> + <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> + + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + +
+ <% end %> + <% container.saved_attachments.each_with_index do |attachment, i| %> + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %> + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %> + <%= l(:field_is_public) %>: + <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %> + <%= if attachment.id.nil? + #待补充代码 + else + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') + end + %> + <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> + + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + +
+ <% end %> +<% end %> +
+
+ + <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> + + <%#= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %> + 上传附件 + <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => 'file_selector', + :multiple => true, + :onchange => 'addInputFiles(this);', + :style => ie8? ? '' : 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js', :project => container), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :delete_all_files => l(:text_are_you_sure_all) + } %> + + <%= l(:label_no_file_uploaded) %> + + (<%= l(:label_max_size) %>: + <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) + + + <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
+ diff --git a/app/views/blog_comments/_edit.html.erb b/app/views/blog_comments/_edit.html.erb new file mode 100644 index 000000000..d56557ce7 --- /dev/null +++ b/app/views/blog_comments/_edit.html.erb @@ -0,0 +1,53 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'blog' %> +
+
+
+
+ +

+
+
+ <%if User.current.id == user.id%> +
+ <%= f.check_box :sticky%> + <%= label_tag 'message_sticky', l(:label_board_sticky) %> + <%= f.check_box :locked%> + <%= label_tag 'message_locked', l(:label_board_locked) %> +
+
+ <% end %> +
+
+ <%= text_area :quote,:quote,:style => 'display:none' %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + + <%= f.kindeditor :content,:editor_id => 'message_content_editor', + :owner_id => article.nil? ? 0: article.id, + :owner_type => OwnerTypeHelper::BLOGCOMMENT, + :width => '100%', + :height => 300, + :minHeight=>300, + :class => 'talk_text fl', + :input_html => { :id => 'message_content', + :class => 'talk_text fl', + :maxlength => 5000 }%> +
+

+
+
+
+
+ <%= render :partial => 'blog_comments/blog_attachments', :locals => {:container => article} %> +
+
+
+
+ 确定 + + 取消 +
+
+
+
+
+
\ No newline at end of file diff --git a/app/views/blog_comments/_new.html.erb b/app/views/blog_comments/_new.html.erb new file mode 100644 index 000000000..2a2281a40 --- /dev/null +++ b/app/views/blog_comments/_new.html.erb @@ -0,0 +1,62 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'blog' %> +
+
+
+
+ +

+
+ +
+ <%#= render :partial => 'course_new_topic', :locals => {:f => f, :topic => @message} %> + +
+
\ No newline at end of file diff --git a/app/views/blog_comments/_reply_form.html.erb b/app/views/blog_comments/_reply_form.html.erb new file mode 100644 index 000000000..cc4c0e952 --- /dev/null +++ b/app/views/blog_comments/_reply_form.html.erb @@ -0,0 +1,35 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +
  • + +
    <%= f.text_field :title, { size: 60, id: "message_subject",:class=>"talk_input w585 fl" }.merge({ hidden: "hidden"}) %>
    + +
    +
  • +
  • +
    +
  • +
  • +
    + + <%= text_area :quote,:quote,:style => 'display:none' %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + + + + <%= f.kindeditor :content, :editor_id => 'message_content_editor', + :width => '99%', + :height => 100, + :minHeight=>100, + :input_html => { :id => 'message_content', + :class => 'talk_text fl', + :maxlength => 5000 }%> +
    +

    +
  • +
    +
  • +
    +
  • diff --git a/app/views/blog_comments/_simple_ke_reply_form.html.erb b/app/views/blog_comments/_simple_ke_reply_form.html.erb new file mode 100644 index 000000000..fa7ff0c4a --- /dev/null +++ b/app/views/blog_comments/_simple_ke_reply_form.html.erb @@ -0,0 +1,31 @@ + + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
    +
    +
    + <%= form_for @blog_comment, :as => :reply, :url => {:controller => 'blog_comments',:action => 'reply', :id => @blogComment.id}, :html => {:multipart => true, :id => 'new_form'} do |f| %> + + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/blog_comments/edit.html.erb b/app/views/blog_comments/edit.html.erb new file mode 100644 index 000000000..a878063db --- /dev/null +++ b/app/views/blog_comments/edit.html.erb @@ -0,0 +1,6 @@ +<% if User.current.logged? && User.current.id == @user.id %> + <%= form_for @article, :url =>{:controller=>'blog_comments',:action => 'update',:user_id=>@user.id , :blog_id => @article.id},:method=>'PUT', + :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> + <%= render :partial => 'blog_comments/edit', :locals => {:f => f, :article => @article, :edit_mode => true, :user => @user} %> + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/blog_comments/quote.js.erb b/app/views/blog_comments/quote.js.erb new file mode 100644 index 000000000..4d16745ca --- /dev/null +++ b/app/views/blog_comments/quote.js.erb @@ -0,0 +1,10 @@ +if($("#reply_message_<%= @blogComment.id%>").length > 0) { + $("#reply_message_<%= @blogComment.id%>").replaceWith("<%= escape_javascript(render :partial => 'simple_ke_reply_form', :locals => {:reply => @blogComment,:temp =>@temp,:subject =>@subject}) %>"); + $(function(){ + $('#reply_subject').val("<%= raw escape_javascript(@subject) %>"); + $('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>"); + init_activity_KindEditor_data(<%= @blogComment.id%>,null,"85%"); + }); +}else if($("#reply_to_message_<%= @blogComment.id%>").length >0) { + $("#reply_to_message_<%= @blogComment.id%>").replaceWith("

    "); +} \ No newline at end of file diff --git a/app/views/blog_comments/reply.js.erb b/app/views/blog_comments/reply.js.erb new file mode 100644 index 000000000..7ebe4d077 --- /dev/null +++ b/app/views/blog_comments/reply.js.erb @@ -0,0 +1,2 @@ +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>"); +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); \ No newline at end of file diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb new file mode 100644 index 000000000..2d4754a0a --- /dev/null +++ b/app/views/blog_comments/show.html.erb @@ -0,0 +1,175 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor",'blog' %> + + + +
    +
    +
    + <%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %> +
    +
    + <% if @article.author.id == User.current.id%> + + <%end%> + +
    + +
    + <% if @article.try(:author).try(:realname) == ' ' %> + <%= link_to @article.try(:author), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> + <% else %> + <%= link_to @article.try(:author).try(:realname), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> + <% end %> +
    +
    <%= format_time( @article.created_on)%>
    +
    +
    + <%= @article.content.html_safe%> +
    +
    +
    + <%#= link_to_attachments_course @topic, :author => false %> + <% if @article.attachments.any?%> + <% options = {:author => true, :deletable => false} %> + <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => @article.attachments, :options => options, :is_float => true} %> + <% end %> +
    +
    +
    +
    +
    + <% count=0 %> + <% if @article.parent %> + <% count=@article.parent.children.count%> + <% else %> + <% count=@article.children.count%> + <% end %> +
    + <% unless count == 0 %> +
    +
    回复(<%=count %>)
    +
    + +
    +
    + <%@article.children.reorder('created_on desc').each_with_index do |reply,i| %> + +
    +
    + <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> +
    +
    +
    + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% end %> +
    +
    + <%= reply.content.html_safe%> +
    +
    + <%= format_time(reply.created_on) %> + +
    +

    +
    +
    +
    + <% end %> +
    + + <% end %> +
    + <% if !@article.locked? && User.current.logged?%> +
    + +
    +
    + <%= form_for :blog_comment, :url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %> + <%= render :partial => 'blog_comments/reply_form', :locals => {:f => f,:user=>@user,:article=>@article} %> + <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'canel_message_replay();', :class => " grey_btn fr c_white mt10 mr5" %> + <%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-right: 5px;" %> + <% end %> +
    +
    +
    + <% end %> +
    +
    \ No newline at end of file diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb new file mode 100644 index 000000000..943d21852 --- /dev/null +++ b/app/views/blogs/_article.html.erb @@ -0,0 +1,145 @@ +
    +
    +
    + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> +
    +
    +
    + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to activity.blog.name+" | 博客", user_blogs_path(:user_id=>activity.author_id,:host=>Setting.host_user), :class => "newsBlue ml15 mr5"%> +
    + + <% if activity.sticky == 1%> + 置顶 + <% end%> + <% if activity.locked%> +        + <% end%> +
    +
    + 发帖时间:<%= format_time(activity.created_on) %> +
    + +
    + <% if activity.parent_id.nil? %> + <%= activity.content.to_s.html_safe%> + <% else %> + <%= activity.parent.content.to_s.html_safe%> + <% end %> +
    +
    +
    + <% if activity.attachments.any?%> + <% options = {:author => true, :deletable => false } %> + <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => activity.attachments, :options => options, :is_float => true} %> + <% end %> +
    + +
    +
    +
    + <% count=0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> +
    +
    +
    +
    回复( + <%= count %> + )
    +
    <%#=format_date(activity.updated_on)%>
    + <%if count > 3 %> + + <% end %> +
    + + <% activity= activity.parent ? activity.parent : activity%> + <% replies_all_i = 0 %> + <% if count > 0 %> +
    +
      + <% activity.children.reorder("created_on desc").each do |reply|%> + + <% replies_all_i=replies_all_i+1 %> +
    • +
      + <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %> +
      +
      +
      + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> +
      +
      + <%= reply.content.html_safe %> +
      +
      +
      +
    • + <% end %> +
    +
    + <% end %> + + <% if !activity.locked? %> +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller=>'blog_comments',:action => 'reply', :id => activity.id, :blog_id => activity.blog.id, :user_id => activity.author_id},:method => "post",:remote=>true) do |f|%> + + + + + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    +
    + <% end %> +
    +
    diff --git a/app/views/blogs/_article_list.html.erb b/app/views/blogs/_article_list.html.erb new file mode 100644 index 000000000..e397da2cc --- /dev/null +++ b/app/views/blogs/_article_list.html.erb @@ -0,0 +1,101 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor", '/assets/kindeditor/pasteimg', "init_activity_KindEditor" %> + + + +
    +
    +
    + <%= @user.name%>的博客 +
    +
    + <% if User.current.logged? && User.current.id == @user.id %> + <%= labelled_form_for @article, :url =>{:controller=>'blog_comments',:action => 'create',:user_id=>user.id , :blog_id => blog.id}, + :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> + <%= render :partial => 'blog_comments/new', :locals => {:f => f, :article => @article, :edit_mode => false, :user => @user} %> + <% end %> + <% end %> + + <% if topics%> + <% topics.each do |topic| %> + + <% if topic %> + <%= render :partial => 'blogs/article', :locals => {:activity => topic, :user_activity_id => topic.id} %> + <% end %> + <% end %> + + <%# if topics.count == 10 %> + + <%# end %> + <% end%> +
    + + diff --git a/app/views/blogs/index.html.erb b/app/views/blogs/index.html.erb new file mode 100644 index 000000000..0e69d1654 --- /dev/null +++ b/app/views/blogs/index.html.erb @@ -0,0 +1,187 @@ + + +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +<%#= javascript_include_tag "/assets/kindeditor/kindeditor-min" %> + + +<%= render :partial => 'blogs/article_list', :locals => {:blog=>@user.blog,:topics => @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.created_on desc"), :page => 0, :user => @user} %> + + + diff --git a/app/views/blogs/show.html.erb b/app/views/blogs/show.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/courses/_join_private_course.html.erb b/app/views/courses/_join_private_course.html.erb index 4122a7105..5748d981e 100644 --- a/app/views/courses/_join_private_course.html.erb +++ b/app/views/courses/_join_private_course.html.erb @@ -4,33 +4,33 @@ 快速进入课程通道 diff --git a/app/views/mailer/join_course_request.html.erb b/app/views/mailer/join_course_request.html.erb new file mode 100644 index 000000000..61b7eaa6f --- /dev/null +++ b/app/views/mailer/join_course_request.html.erb @@ -0,0 +1,14 @@ +
    + + +
    +
    diff --git a/app/views/mailer/join_course_request.text.erb b/app/views/mailer/join_course_request.text.erb new file mode 100644 index 000000000..62e2315c5 --- /dev/null +++ b/app/views/mailer/join_course_request.text.erb @@ -0,0 +1,4 @@ +<%= @user.show_name %>申请成为课程<%= @course.name %>的<%= @role.eql?('9') ? '老师': '教辅' %> +<%=link_to user_message_url(@receive),user_message_url(@receive)%> + + diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index 79142c441..f4a1675b1 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -115,7 +115,7 @@ <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> <% end %> -
    +
    <%= reply.content.html_safe%>
    diff --git a/app/views/student_work/_work_attachments.html.erb b/app/views/student_work/_work_attachments.html.erb index a75f68f70..098bb94d0 100644 --- a/app/views/student_work/_work_attachments.html.erb +++ b/app/views/student_work/_work_attachments.html.erb @@ -2,7 +2,7 @@
    <%= link_to_short_attachment attachment, :class => 'link_file_a fl', :download => true -%> <%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload fl', :confirm => l(:text_are_you_sure)) if attachment.id && User.current == attachment.author %> - (<%= number_to_human_size attachment.filesize %>) + (<%= number_to_human_size attachment.filesize %>)
    <% end -%> diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 4bde4476d..70494192d 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -43,7 +43,7 @@
    截止时间:<%= activity.end_time.to_s %>
    -
    +
    <%= activity.description.html_safe %>
    @@ -52,6 +52,10 @@
    +
    + <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => activity.attachments} %> +
    +
    <%# if is_teacher%>