diff --git a/.gitignore b/.gitignore index 38f29a661..0727a920a 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,4 @@ vendor/cache /public/files /tags /config/initializers/gitlab_config.rb -/config/wechat.yml -/config/menu.yml 1234567 diff --git a/Gemfile b/Gemfile index a599613ba..d392c6561 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source 'https://rubygems.org/' +source 'https://ruby.taobao.org/' ### ����ִ��bundle config mirror.https://rubygems.org https://gems.ruby-china.org �л���ruby-chinaԴ unless RUBY_PLATFORM =~ /w32/ diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index cbd43bb79..af17e0f44 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -13,34 +13,18 @@ module Mobile end post do user = UserWechat.find_by_openid(params[:openid]).user -=begin - shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) - shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) - page = params[:page] ? params[:page] : 0 - user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" - user_course_ids = (user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" - course_types = "('Message','News','HomeworkCommon','Poll','Course')" - project_types = "('Message','Issue','ProjectCreateInfo')" - principal_types = "JournalsForMessage" - - blog_ids = "("+user.blog.id.to_s+","+((User.watched_by(user.id).count == 0 )? '0' :User.watched_by(user.id).map{|u| u.blog.id}.join(','))+")" - activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + - "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ - "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " + - "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc') -=end shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) page = params[:page] ? params[:page] : 0 - user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.map{|project| project.id}-shield_project_ids).join(",") + ")" - user_course_ids = (user.courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.map{|course| course.id}-shield_course_ids).join(",") + ")" + user_project_ids = (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).join(",") + ")" + user_course_ids = (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).join(",") + ")" course_types = "('Message','News','HomeworkCommon','Poll','Course')" project_types = "('Message','Issue','Project')" principal_types = "JournalsForMessage" watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(',')) user_ids = "(" + user.id.to_s + watched_user_ids + ")" - watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",") + watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").count == 0 ? " " :Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",") blog_ids = "(" + watched_user_blog_ids + ")" activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index a90ff323d..9e2a39a5a 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -98,6 +98,7 @@ module Mobile end expose :act_type #缺陷/作业/讨论区/留言等类型 expose :act_id + expose :id expose :container_type #课程/项目/博客/个人 expose :author, using: Mobile::Entities::User do |a, opt| #用户信息 if a.is_a? ::UserActivity diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 17f62f18c..e421b8c69 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -304,7 +304,7 @@ class CoursesController < ApplicationController @render_file = 'new_member_list' @score_sort_by = "desc" - @sort_type = "score" + @sort_type = params[:sort_type] ? params[:sort_type] : "score" @canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1' @role = params[:role].nil? ? '2':params[:role] @is_remote = true @@ -319,7 +319,7 @@ class CoursesController < ApplicationController if @course.open_student == 1 || User.current.member_of_course?(@course) @subPage_title = l :label_student_list page = params[:page].nil? ? 0 : (params['page'].to_i - 1) - @all_members = student_homework_score(0,page, 10,@score_sort_by) + @all_members = student_homework_score(0,page, 10,@score_sort_by,@sort_type) @members = @all_members else render_403 diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index b1d16debb..8ef399d10 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -304,7 +304,7 @@ class MessagesController < ApplicationController @content = "> #{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> " @temp = Message.new - @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, @message.author)}
#{@message.content.html_safe}
".html_safe + @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, @message.author.show_name)}
#{@message.content.html_safe}
".html_safe end def preview diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 3cbfc8466..a0ef84798 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -563,13 +563,23 @@ class OrganizationsController < ApplicationController # 设置为名师 def set_excellent_teacher @ex_teacher = User.find(params[:user]) - params[:type] == "student" ? @ex_teacher.update_column(:excellent_student, 1) : @ex_teacher.update_column(:excellent_teacher, 1) + @ex_teacher.update_column(:excellent_teacher, 1) end # 取消名师 def reset_excellent_teacher @ex_teacher = User.find(params[:user]) - params[:type] == "student" ? @ex_teacher.update_column(:excellent_student, 0) : @ex_teacher.update_column(:excellent_teacher, 0) + @ex_teacher.update_column(:excellent_teacher, 0) + end + + def set_excellent_student + @ex_student = User.find(params[:user]) + @ex_student.update_column(:excellent_student, 1) + end + + def reset_excellent_student + @ex_student = User.find(params[:user]) + @ex_student.update_column(:excellent_student, 0) end def hide_org_subfield diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index dd178a1ce..10431f01a 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -390,7 +390,7 @@ class StudentWorkController < ApplicationController student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')' end #开放作品 || 老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表 - if @homework.is_open == 1 || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) + if (@homework.is_open == 1 && @course.is_public == 1) || (@homework.is_open == 1 && @course.is_public == 0 && User.current.member_of_course?(@course)) || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) if @order == 'lastname' @stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name elsif @order == 'student_id' @@ -456,7 +456,7 @@ class StudentWorkController < ApplicationController @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name).count else - if @homework.is_open == 1 || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) + if (@homework.is_open == 1 &&@course.is_public == 1) || (@homework.is_open == 1 && @course.is_public == 0 && User.current.member_of_course?(@course)) || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) if @order == 'lastname' @stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name elsif @order == 'student_id' diff --git a/app/controllers/sub_document_comments_controller.rb b/app/controllers/sub_document_comments_controller.rb index 80c14f004..d6b335006 100644 --- a/app/controllers/sub_document_comments_controller.rb +++ b/app/controllers/sub_document_comments_controller.rb @@ -1,7 +1,7 @@ class SubDocumentCommentsController < ApplicationController before_filter :find_subdomain_and_subfield, :only => [:new, :create, :show, :index, :destroy, :edit] before_filter :find_subfield_content, :only => [:show, :index] - before_filter :authorize_allowed, :only => [:create, :add_reply] + before_filter :authorize_allowed, :only => [:create] helper :attachments,:organizations layout 'base_sub_domain' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 52c5f70bc..f5689ef64 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -570,7 +570,7 @@ class UsersController < ApplicationController end if !params[:search].nil? search = "%#{params[:search].to_s.strip.downcase}%" - @course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id} and #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)} + @course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id} and (#{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p)",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)} else @course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id}").select { |course| @user.allowed_to?(:as_teacher,course)} end diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index a37b5aaa2..ef59e0ed4 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -154,12 +154,7 @@ class WechatsController < ActionController::Base end end - - - ### controller method - - module Controllers def get_open_id begin @@ -167,7 +162,6 @@ class WechatsController < ActionController::Base code = params[:code] || session[:wechat_code] openid = get_openid_from_code(code) - raise "无法获取到微信openid" unless openid render :json => {status:0, openid: openid} rescue Exception=>e @@ -194,6 +188,8 @@ class WechatsController < ActionController::Base openid: openid, user: user ) + ws = WechatService.new + ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台", user.login, format_time(Time.now)) render :json => {status:0, msg: "绑定成功"} rescue Exception=>e render :json => {status: -1, msg: e.message} @@ -202,9 +198,25 @@ class WechatsController < ActionController::Base def login session[:wechat_code] = params[:code] if params[:code] + openid = get_openid_from_code(params[:code]) + @wechat_user = user_binded?(openid) + render 'wechats/login', layout: 'base_wechat' end + def user_activities + session[:wechat_code] = params[:code] if params[:code] + code = params[:code] || session[:wechat_code] + openid = get_openid_from_code(code) + @wechat_user = user_binded?(openid) + unless @wechat_user + redirect_to login_wechat_path + return + end + + render 'wechats/user_activities', layout: nil + end + private def get_openid_from_code(code) openid = session[:wechat_openid] @@ -226,37 +238,8 @@ class WechatsController < ActionController::Base uw = UserWechat.where(openid: openid).first end - def user_activity(user) - @user = user - shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{@user.id} and shield_type='Project'").map(&:shield_id) - shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{@user.id} and shield_type='Course'").map(&:shield_id) - @page = params[:page] ? params[:page].to_i + 1 : 0 - user_project_ids = (@user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" - user_course_ids = (@user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" - course_types = "('Message','News','HomeworkCommon','Poll','Course')" - project_types = "('Message','Issue','Project')" - principal_types = "JournalsForMessage" - - blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" - @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + - "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ - "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + - "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10) - end - - def process_activity(user_activity) - act= user_activity.act - case user_activity.container_type.to_s - when 'Course' - when 'Project' - case user_activity.act_type.to_s - when 'Issue' - [act.project.name.to_s+" | 项目问题", act.subject.to_s, url_to_avatar(act.author),"http://wechat.trustie.net/app.html#/issue/#{act.id}"] - end - end - end end diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 386e5733d..d9a9e1def 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -10,14 +10,14 @@ class ZipdownController < ApplicationController #勿删 before_filter :authorize, :only => [:assort,:download_user_homework] SAVE_FOLDER = "#{Rails.root}/files" OUTPUT_FOLDER = "#{Rails.root}/files/archiveZip" + MAX_PATH = 50 #统一下载功能 def download if User.current.logged? begin if params[:base64file] - file = Base64.decode64(params[:base64file]) - file = file.sub('*', '+') + file = decode64(params[:base64file]) send_file "#{OUTPUT_FOLDER}/#{file}", :filename => filename_for_content_disposition(file), :type => detect_content_type(file) else send_file "#{OUTPUT_FOLDER}/#{params[:file]}", :filename => filename_for_content_disposition(params[:filename]), :type => detect_content_type(params[:file]) @@ -125,7 +125,11 @@ class ZipdownController < ApplicationController end def encode64(str) - Base64.encode64(str).sub('+', '*') + Base64.urlsafe_encode64(str) + end + + def decode64(str) + Base64.urlsafe_decode64(str) end def zip_homework_common homework_common @@ -242,6 +246,12 @@ class ZipdownController < ApplicationController def zipping(zip_name_refer, files_paths, output_path, is_attachment=false, not_exist_file=[]) rename_zipfile = zip_name_refer ||= "#{Time.now.to_i.to_s}.zip" + # 文件名过长 + + if rename_zipfile.size > MAX_PATH + rename_zipfile = rename_zipfile[0,rename_zipfile.size-4][0,MAX_PATH-4] + rename_zipfile[-4,4] + end + zipfile_name = "#{output_path}/#{rename_zipfile}" Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index 49640d889..fb1231287 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -182,7 +182,7 @@ module ApiHelper timeIntoFormat = 0 updateAtValue = "" if timePassed < 0 - updateAtValue = "时间有问题" + updateAtValue = "刚刚" elsif timePassed < ONE_MINUTE updateAtValue = "1分钟前" elsif timePassed < ONE_HOUR diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index e6fd7591f..fa0d33f6e 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -181,7 +181,7 @@ module OrganizationsHelper if User.current.admin? @organization.org_subfields.order("priority") else - @organization.org_subfields.select { |os| (os.field_type != "Comptec" && os.field_type != "Compstu") }.sort_by {|os| os.priority} + @organization.org_subfields.select { |os| (os.field_type != "Comptec" && os.field_type != "Compstu" && os.field_type != "Comppro" && os.field_type != "Compcou" && os.field_type != "Compact") }.sort_by {|os| os.priority} end end diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index af21b4f69..05ae02fe2 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -21,7 +21,7 @@ class BlogComment < ActiveRecord::Base after_save :add_user_activity after_update :update_activity - after_create :update_parent_time, :blog_wechat_message + after_create :update_parent_time before_destroy :destroy_user_activity scope :like, lambda {|arg| @@ -77,16 +77,16 @@ class BlogComment < ActiveRecord::Base end #博客回复微信模板消息 - def blog_wechat_message - ws = WechatService.new - if self.parent_id.nil? - self.author.watcher_users.each do |watcher| - content = strip_html self.author.try(:realname) + " 发表了博客:" + self.title.html_safe, 200 - ws.message_update_template watcher.id, "blog_comment", self.id, "#{l(:label_new_blog_template)}", content, format_time(self.created_at) - end - else - content = strip_html self.content.html_safe, 200 - ws.comment_template self.parent.author_id, "blog_comment", self.parent_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), content - end - end + # def blog_wechat_message + # ws = WechatService.new + # if self.parent_id.nil? + # self.author.watcher_users.each do |watcher| + # content = strip_html self.author.try(:realname) + " 发表了博客:" + self.title.html_safe, 200 + # ws.message_update_template watcher.id, "blog_comment", self.id, "#{l(:label_new_blog_template)}", content, format_time(self.created_at) + # end + # else + # content = strip_html self.content.html_safe, 200 + # ws.comment_template self.parent.author_id, "blog_comment", self.parent_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), content + # end + # end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 8632c243a..edb5e472f 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -41,15 +41,15 @@ class Comment < ActiveRecord::Base after_destroy :down_course_score def act_as_system_message - ws = WechatService.new + #ws = WechatService.new if self.commented.course if self.author_id != self.commented.author_id self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false) - count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count - if count == 0 - content = strip_html self.comments.html_safe, 200 - ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content - end + # count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count + # if count == 0 + # content = strip_html self.comments.html_safe, 200 + # ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + # end end else # 项目相关 if self.author_id != self.commented.author_id diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index e4426e78f..a915b1545 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -30,7 +30,7 @@ class HomeworkCommon < ActiveRecord::Base :author => :author, :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} after_create :act_as_activity, :send_mail,:act_as_course_message - after_update :update_activity, :wechat_message + after_update :update_activity after_save :act_as_course_activity after_destroy :delete_kindeditor_assets @@ -63,7 +63,7 @@ class HomeworkCommon < ActiveRecord::Base count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count if count == 0 ws = WechatService.new - ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") + ws.homework_message_notice(m.user_id, "homework", self.id, "#{m.user.show_name},#{l(:label_new_homework_template)}:", self.course.name, "新作业:"+ self.name.html_safe, "作业内容请点击“详情”查看。") end # end end @@ -108,15 +108,15 @@ class HomeworkCommon < ActiveRecord::Base end #修改作业后发送微信模板消息 - def wechat_message - self.course.members.each do |member| - count = ShieldWechatMessage.where("container_type='User' and container_id=#{member.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count - if count == 0 - ws = WechatService.new - ws.homework_template(member.user_id, "homework", self.id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") - end - end - end + # def wechat_message + # self.course.members.each do |member| + # count = ShieldWechatMessage.where("container_type='User' and container_id=#{member.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count + # if count == 0 + # ws = WechatService.new + # ws.homework_template(member.user_id, "homework", self.id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") + # end + # end + # end delegate :language_name, :language, :to => :homework_detail_programing diff --git a/app/models/issue.rb b/app/models/issue.rb index b5e87feea..4cfea1f43 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -160,27 +160,27 @@ class Issue < ActiveRecord::Base unless self.author_id == self.assigned_to_id self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false) end - self.project.members.each do |m| - count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project_id}").count - if m.user_id != self.author_id && count == 0 - ws = WechatService.new - str = " 有新缺陷了: " - case self.tracker_id - when 1 - str = " 有新缺陷了: " - when 2 - str = " 有新功能了: " - when 3 - str = " 有新支持了: " - when 4 - str = " 有新任务了: " - when 5 - str = " 有新周报了: " - end - content = strip_html self.project.name + str + self.subject.html_safe, 200 - ws.message_update_template m.user_id, "issues", self.id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on) - end - end + # self.project.members.each do |m| + # count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project_id}").count + # if m.user_id != self.author_id && count == 0 + # ws = WechatService.new + # str = " 有新缺陷了: " + # case self.tracker_id + # when 1 + # str = " 有新缺陷了: " + # when 2 + # str = " 有新功能了: " + # when 3 + # str = " 有新支持了: " + # when 4 + # str = " 有新任务了: " + # when 5 + # str = " 有新周报了: " + # end + # content = strip_html self.project.name + str + self.subject.html_safe, 200 + # ws.message_update_template m.user_id, "issues", self.id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on) + # end + # end if self.tracker_id == 5 self.project.members.each do |m| if m.roles.first.to_s.include?("Manager") && m.user_id != self.author_id && m.user_id != self.assigned_to_id diff --git a/app/models/journal.rb b/app/models/journal.rb index eeaa17dd6..bea273a41 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -55,7 +55,6 @@ class Journal < ActiveRecord::Base # fq after_save :act_as_activity,:be_user_score, :act_as_forge_message, act_as_at_message(:notes, :user_id) - after_create :issue_wechat_message # end #after_destroy :down_user_score #before_save :be_user_score @@ -238,11 +237,11 @@ class Journal < ActiveRecord::Base end #缺陷回复微信模板消息 - def issue_wechat_message - if !self.notes.nil? && self.notes.gsub(' ','') != '' - ws = WechatService.new - content = strip_html self.notes.html_safe, 200 - ws.comment_template self.issue.author_id, "issues", self.journalized_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content - end - end + # def issue_wechat_message + # if !self.notes.nil? && self.notes.gsub(' ','') != '' + # ws = WechatService.new + # content = strip_html self.notes.html_safe, 200 + # ws.comment_template self.issue.author_id, "issues", self.journalized_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + # end + # end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index d0113744c..d8819515c 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -259,24 +259,24 @@ class JournalsForMessage < ActiveRecord::Base if self.m_parent_id.nil? if self.user_id != self.jour.user_id self.course_messages << CourseMessage.new(:user_id => self.jour.user_id,:course_id => self.jour.course.id, :viewed => false) - count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count - if count == 0 - ws = WechatService.new - #content = truncate(strip_tags(self.notes.to_s), length: 200) - content = strip_html self.notes.html_safe, 200 - ws.comment_template self.jour.user_id, "homework", self.jour_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content - end + # count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count + # if count == 0 + # ws = WechatService.new + # #content = truncate(strip_tags(self.notes.to_s), length: 200) + # content = strip_html self.notes.html_safe, 200 + # ws.comment_template self.jour.user_id, "homework", self.jour_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + # end end else if self.user_id != self.parent.user_id self.course_messages << CourseMessage.new(:user_id => self.parent.user_id,:course_id => self.jour.course.id, :viewed => false) - count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.parent.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count - if count == 0 - ws = WechatService.new - #content = truncate(strip_tags(self.notes.to_s), length: 200) - content = strip_html self.notes.html_safe, 200 - ws.comment_template self.parent.user_id, "homework", self.jour_id, "#{l(:label_new_second_comment_template)}", self.user.try(:realname), format_time(self.created_on), content - end + # count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.parent.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count + # if count == 0 + # ws = WechatService.new + # #content = truncate(strip_tags(self.notes.to_s), length: 200) + # content = strip_html self.notes.html_safe, 200 + # ws.comment_template self.parent.user_id, "homework", self.jour_id, "#{l(:label_new_second_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + # end end end end @@ -293,7 +293,7 @@ class JournalsForMessage < ActiveRecord::Base if self.user_id != self.jour_id # 过滤自己给自己的留言消息 receivers << self.jour content = strip_html self.notes, 200 - ws.message_update_template self.jour_id, "journal_for_message", self.id, "#{l(:label_new_journals_template)}", content, format_time(self.created_on) + ws.journal_notice self.jour_id, "journal_for_message", self.id, "#{l(:label_new_journals_template)}", self.user.show_name, format_time(self.created_on),content end else # 留言回复 reply_to = User.find(self.reply_id) @@ -303,8 +303,8 @@ class JournalsForMessage < ActiveRecord::Base if self.user_id != self.parent.jour_id && self.reply_id != self.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发 receivers << self.parent.jour end - content = strip_html self.notes, 200 - ws.comment_template self.reply_id, "journal_for_message", self.parent.id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + #content = strip_html self.notes, 200 + #ws.comment_template self.reply_id, "journal_for_message", self.parent.id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end receivers.each do |r| self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) diff --git a/app/models/message.rb b/app/models/message.rb index cf9adab4e..393fd3a60 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -258,28 +258,28 @@ class Message < ActiveRecord::Base # 主贴项目成员都能收到 # 回帖:帖子的发布人收到 def act_as_system_message - ws = WechatService.new + #ws = WechatService.new if self.course if self.parent_id.nil? # 主贴 self.course.members.includes(:user).each do |m| if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 #self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) - count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course.id}").count - if count == 0 - content = strip_html self.subject, 200 - ws.topic_publish_template m.user_id, "course_discussion", self.id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) - end + # count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course.id}").count + # if count == 0 + # content = strip_html self.subject, 200 + # ws.topic_publish_template m.user_id, "course_discussion", self.id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) + # end end end else # 回帖 parent_author_id = Message.find(self.parent_id).author_id if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.course_messages << CourseMessage.new(:user_id => parent_author_id, :course_id => self.board.course_id, :viewed => false) - count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count - if count == 0 - content = strip_html self.content.html_safe, 200 - ws.comment_template parent_author_id, "course_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content - end + # count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count + # if count == 0 + # content = strip_html self.content.html_safe, 200 + # ws.comment_template parent_author_id, "course_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + # end end end elsif self.project # 项目相关 @@ -287,22 +287,22 @@ class Message < ActiveRecord::Base self.project.members.includes(:user).each do |m| if m.user_id != self.author_id #self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) - count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project.id}").count - if count == 0 - content = strip_html self.subject, 200 - ws.topic_publish_template m.user_id, "project_discussion", self.id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) - end + # count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project.id}").count + # if count == 0 + # content = strip_html self.subject, 200 + # ws.topic_publish_template m.user_id, "project_discussion", self.id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) + # end end end else # 回帖 parent_author_id = Message.find(self.parent_id).author_id if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.forge_messages << ForgeMessage.new(:user_id => parent_author_id, :project_id => self.board.project_id, :viewed => false) - count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count - if count == 0 - content = strip_html self.content.html_safe, 200 - ws.comment_template parent_author_id, "project_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content - end + # count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count + # if count == 0 + # content = strip_html self.content.html_safe, 200 + # ws.comment_template parent_author_id, "project_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + # end end end end diff --git a/app/models/news.rb b/app/models/news.rb index 0b03dcc48..54f6fce08 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -174,7 +174,7 @@ class News < ActiveRecord::Base if count == 0 ws = WechatService.new content = strip_html self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, 200 - ws.message_update_template m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", content, format_time(self.created_on) + ws.class_notice m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", self.course.name, self.author.show_name, format_time(self.created_on), content, "点击查看通知详情" end end end diff --git a/app/services/wechat_service.rb b/app/services/wechat_service.rb index 6d8c0f234..3169763c4 100644 --- a/app/services/wechat_service.rb +++ b/app/services/wechat_service.rb @@ -110,4 +110,144 @@ class WechatService Rails.logger.info "send over. #{req}" end end + + def two_keys_template(openid, template_id, type, id, first, key1, key2, remark="") + data = { + touser:openid, + template_id:template_id, + url:"#{Setting.protocol}://#{Setting.host_name}/assets/wechat/app.html#/#{type}/#{id}", + topcolor:"#FF0000", + data:{ + first: { + value:first, + color:"#707070" + }, + keyword1:{ + value:key1, + color:"#707070" + }, + keyword2:{ + value:key2, + color:"#707070" + }, + remark:{ + value:remark, + color:"#707070" + } + } + } + data + end + + def four_keys_template(openid, template_id, type, id, first, key1, key2, key3, key4, remark="") + data = { + touser:openid, + template_id:template_id, + url:"#{Setting.protocol}://#{Setting.host_name}/assets/wechat/app.html#/#{type}/#{id}", + topcolor:"#FF0000", + data:{ + first: { + value:first, + color:"#707070" + }, + keyword1:{ + value:key1, + color:"#707070" + }, + keyword2:{ + value:key2, + color:"#707070" + }, + keyword3:{ + value:key3, + color:"#707070" + }, + keyword4:{ + value:key4, + color:"#707070" + }, + remark:{ + value:remark, + color:"#707070" + } + } + } + data + end + + def binding_succ_notice(user_id, first, key1, key2) + uw = UserWechat.where(user_id: user_id).first + unless uw.nil? + data = { + touser:uw.openid, + template_id:Wechat.config.binding_succ_notice, + url:"#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities", + topcolor:"#FF0000", + data:{ + first: { + value:first, + color:"#707070" + }, + keyword1:{ + value:key1, + color:"#707070" + }, + keyword2:{ + value:key2, + color:"#707070" + }, + remark:{ + value:"绑定成功后可使用微信查看Trustie平台最新动态", + color:"#707070" + } + } + } + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + Rails.logger.error "[homework] ===> #{e}" + end + Rails.logger.info "send over. #{req}" + end + end + + def journal_notice(user_id, type, id, first, key1, key2, remark="") + uw = UserWechat.where(user_id: user_id).first + unless uw.nil? + data = two_keys_template uw.openid,Wechat.config.journal_notice, type, id, first, key1, key2, remark + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + Rails.logger.error "[homework] ===> #{e}" + end + Rails.logger.info "send over. #{req}" + end + end + + def homework_message_notice(user_id, type, id, first, key1, key2, remark="") + uw = UserWechat.where(user_id: user_id).first + unless uw.nil? + data = two_keys_template uw.openid,Wechat.config.homework_message_notice, type, id, first, key1, key2, remark + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + Rails.logger.error "[homework] ===> #{e}" + end + Rails.logger.info "send over. #{req}" + end + end + + def class_notice(user_id, type, id, first, key1, key2, key3, key4, remark="") + uw = UserWechat.where(user_id: user_id).first + unless uw.nil? + data = four_keys_template uw.openid,Wechat.config.class_notice, type, id, first, key1, key2, key3, key4, remark + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + Rails.logger.error "[homework] ===> #{e}" + end + Rails.logger.info "send over. #{req}" + end + end + end \ No newline at end of file diff --git a/app/views/courses/_course_activity_users.html.erb b/app/views/courses/_course_activity_users.html.erb index a0cac45f7..93e0e7b77 100644 --- a/app/views/courses/_course_activity_users.html.erb +++ b/app/views/courses/_course_activity_users.html.erb @@ -1,6 +1,11 @@ <% unless contributor_course_scor(course.id).count == 0 %> 保存 <% end %> diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index c0bb15ab4..30c15c03d 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -29,13 +29,16 @@ - <% unless @project.gpid.nil? || @project.project_score.changeset_num == 0 || @project.rep_statics.blank? %> -
-
- <%= render :partial => "rep_static" %> -
-
-
+ <%# 时间紧,权限待优化 %> + <% unless @project.hidden_repo && !User.current.member_of?(@project) && !User.current.admin? %> + <% unless @project.gpid.nil? || @project.project_score.changeset_num == 0 || @project.rep_statics.blank? %> +
+
+ <%= render :partial => "rep_static" %> +
+
+
+ <% end %> <% end %> <%= render :partial => "project_activities", :locals => {:forge_acts => @events_pages, :page => 0, :type => @type} %> diff --git a/app/views/sub_document_comments/_new.html.erb b/app/views/sub_document_comments/_new.html.erb index c6cc13164..aec91c878 100644 --- a/app/views/sub_document_comments/_new.html.erb +++ b/app/views/sub_document_comments/_new.html.erb @@ -36,7 +36,7 @@ $('#doc_title_hint').hide(); } -
+
<%= form_tag org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id => @org_subfield.id, :sub_domain_id => @subdomain.id), :id => 'new_sub_document_form' do |f| %>
diff --git a/app/views/sub_document_comments/show.html.erb b/app/views/sub_document_comments/show.html.erb index 7050c1c66..f85f3ed25 100644 --- a/app/views/sub_document_comments/show.html.erb +++ b/app/views/sub_document_comments/show.html.erb @@ -8,7 +8,7 @@ showNormalImage('message_description_<%= @document.id %>'); }); -
+
<%= link_to image_tag(url_to_avatar(User.find(@document.creator_id)), :width => 45, :heigth => 45), user_url_in_org(@document.creator_id) %> @@ -138,7 +138,7 @@
<%# end %> - <% if User.current.logged?%> + <%# if User.current.logged?%>
@@ -151,7 +151,7 @@
- <% end %> + <%# end %>
diff --git a/app/views/users/_project_news.html.erb b/app/views/users/_project_news.html.erb index 55e2182b5..b354bc668 100644 --- a/app/views/users/_project_news.html.erb +++ b/app/views/users/_project_news.html.erb @@ -66,11 +66,7 @@
回复 <%= count>0 ? "(#{count})" : "" %> - <% if activity.author == User.current %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - <% end %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
<%#= format_date(activity.updated_on) %>
@@ -108,11 +104,7 @@ <% end %> <%= format_time(comment.created_on) %> - <% if comment.author == User.current %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - <% end %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%>
diff --git a/app/views/users/_show_unlogged.html.erb b/app/views/users/_show_unlogged.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index c7ab519f2..615b4cef4 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -1,4 +1,22 @@ +<% if @wechat_user %> +
+
+
+
+

操作成功

+

您已经绑定过微信了,用户名: (<%= @wechat_user.user.login %>)

+
+
+

+ 确定 +

+
+ +
+
+ +<% else %>

@@ -62,4 +80,7 @@ }) }); - \ No newline at end of file + + + +<% end %> \ No newline at end of file diff --git a/app/views/wechats/user_activities.html.erb b/app/views/wechats/user_activities.html.erb new file mode 100644 index 000000000..b45587ae0 --- /dev/null +++ b/app/views/wechats/user_activities.html.erb @@ -0,0 +1,30 @@ + + + + 最新动态 + + + + + + + + + + + +

+
+ + + + + + + + + + + \ No newline at end of file diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index dc7cdc5fc..8a2c14e07 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -13,10 +13,10 @@
<% id = 'project_respond_form_'+ reply.id.to_s %> - <%= link_to "#{reply.user.show_name}(#{reply.user.login})", user_path(reply.user) %> + <%= link_to reply.user.show_name, user_path(reply.user) %> <%= l(:label_reply_to)%> <% if show_name %> - <%= link_to "#{parent_jour.user.show_name}(#{parent_jour.user.login})", user_path(parent_jour.user) %> + <%= link_to parent_jour.user.show_name, user_path(parent_jour.user) %> <% else %> <%= l(:label_anonymous) %> <% end %> diff --git a/config/locales/commons/zh.yml b/config/locales/commons/zh.yml index d65606678..70236d9ba 100644 --- a/config/locales/commons/zh.yml +++ b/config/locales/commons/zh.yml @@ -358,7 +358,7 @@ zh: # 意见反馈 # label_feedback: 意见反馈 - label_feedback_tips: "请在此提问平台问题,或直接加入师姐答疑群,谢谢!" + label_feedback_tips: "请在此发布平台问题和建议,或直接加入答疑群,谢谢!" label_technical_support: "QQ 在线支持:" label_feedback_success: "您的意见已经反馈到公共贴吧的新手讨论吧,我们会第一时间解决您的问题,谢谢支持!" label_feedback_value: "该帖来自用户反馈:)" diff --git a/config/locales/zh.yml b/config/locales/zh.yml index a347359bb..94be8af6d 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2128,7 +2128,7 @@ zh: label_resource_belongs_project: 所属项目 #微信模板消息 - label_new_homework_template: 您的课程有新作业了 + label_new_homework_template: 您有新作业了 label_update_homework_template: 您的作业已被修改 label_course_topic_template: 课程问答区有新帖子发布了 label_topic_comment_template: 您的帖子有新回复了 diff --git a/config/menu.yml b/config/menu.yml index de1952503..79659fb90 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,7 +2,7 @@ button: - type: "view" name: "最新动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.course.trustie.net/assets/wechat/app.html#/activities?response_type=code&scope=snsapi_base&state=123#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.course.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=123#wechat_redirect" - type: "click" name: "意见反馈" diff --git a/config/routes.rb b/config/routes.rb index 0349fc122..74b4e09aa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1245,6 +1245,7 @@ RedmineApp::Application.routes.draw do resource :wechat, only:[:show, :create] do collection do get :login + get :user_activities post :bind post :get_open_id end diff --git a/config/wechat.yml b/config/wechat.yml index 5b528487b..3d679c4ce 100644 --- a/config/wechat.yml +++ b/config/wechat.yml @@ -11,6 +11,12 @@ default: &default encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6" jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" + #template + binding_succ_notice: "n4KLwcWNrIMYkKxWL2hUwzunm5RTT54EbWem2MIUapU" + journal_notice: "XpHHYkqSGkwuF9vHthRdmPQLvCFRQ4_NbRBP12T7ciE" + homework_message_notice: "Kom0TsYYKsNKCS6luweYVRo9z-mH0wRPr24b1clGCPQ" + class_notice: "8LVu33l6bP-56SDomVgHn-yJc57YpCwwJ81rAJgRONk" + production: <<: *default diff --git a/lib/dalli-2.7.2/Gemfile b/lib/dalli-2.7.2/Gemfile index aeb2bb358..59c3c15a0 100644 --- a/lib/dalli-2.7.2/Gemfile +++ b/lib/dalli-2.7.2/Gemfile @@ -1,4 +1,4 @@ -source 'https://rubygems.org' +source 'https://ruby.taobao.org/' gemspec diff --git a/lib/gitlab-cli/Gemfile b/lib/gitlab-cli/Gemfile index 54fbdf177..846f49bed 100644 --- a/lib/gitlab-cli/Gemfile +++ b/lib/gitlab-cli/Gemfile @@ -1,4 +1,4 @@ -source 'https://rubygems.org' +source 'https://ruby.taobao.org/' # Specify your gem's dependencies in gitlab.gemspec gemspec diff --git a/lib/grack/Gemfile b/lib/grack/Gemfile index 2aa7df2fe..360e439a0 100644 --- a/lib/grack/Gemfile +++ b/lib/grack/Gemfile @@ -1,4 +1,4 @@ -source 'https://rubygems.org/' +source 'https://ruby.taobao.org/' gemspec diff --git a/lib/plugins/acts-as-taggable-on/Gemfile b/lib/plugins/acts-as-taggable-on/Gemfile index e37a382a0..4e6730add 100644 --- a/lib/plugins/acts-as-taggable-on/Gemfile +++ b/lib/plugins/acts-as-taggable-on/Gemfile @@ -1,4 +1,4 @@ -source 'https://rubygems.org' +source 'https://ruby.taobao.org/' gemspec diff --git a/lib/rails_kindeditor/Gemfile b/lib/rails_kindeditor/Gemfile index 9a36070cb..c4b60f19b 100644 --- a/lib/rails_kindeditor/Gemfile +++ b/lib/rails_kindeditor/Gemfile @@ -1,4 +1,4 @@ -source "https://rubygems.org" +source "https://ruby.taobao.org/" gemspec diff --git a/lib/wechat/Gemfile b/lib/wechat/Gemfile index ee4ef6e9e..8627d2525 100644 --- a/lib/wechat/Gemfile +++ b/lib/wechat/Gemfile @@ -1,4 +1,4 @@ -source 'https://rubygems.org' +source 'https://ruby.taobao.org/' gemspec diff --git a/plugins/redmine_ckeditor/Gemfile b/plugins/redmine_ckeditor/Gemfile index 115107d18..568df01b4 100644 --- a/plugins/redmine_ckeditor/Gemfile +++ b/plugins/redmine_ckeditor/Gemfile @@ -1,4 +1,4 @@ -source 'https://rubygems.org/' +source 'https://ruby.taobao.org/' gem 'rich', '1.4.6' gem 'kaminari' diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index 6b0f1621b..5503af1fe 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -83,7 +83,8 @@ function _inString(val, str, delimiter) { } function _addUnit(val, unit) { unit = unit || 'px'; - return val && /^\d+$/.test(val) ? val + unit : val; + //return val && /^\d+$/.test(val) ? val + unit : val; + return val && /^-?\d+(?:\.\d+)?$/.test(val) ? val + unit : val; } function _removeUnit(val) { var match; @@ -304,7 +305,7 @@ K.options = { img : ['id', 'class', 'src', 'width', 'height', 'border', 'alt', 'title', 'align', '.width', '.height', '.border'], 'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [ 'id', 'class', 'align', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.background', - '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.text-indent', '.margin-left' + '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.text-indent', '.margin-left', '.margin', '.border', '.padding' ], pre : ['id', 'class'], hr : ['id', 'class', '.page-break-after'], @@ -597,7 +598,7 @@ function _ready(fn) { } _bind(window, 'load', readyFunc); } -if (_IE) { +if (window.attachEvent) { window.attachEvent('onunload', function() { _each(_eventData, function(key, events) { if (events.el) { @@ -2531,6 +2532,7 @@ K.START_TO_START = _START_TO_START; K.START_TO_END = _START_TO_END; K.END_TO_END = _END_TO_END; K.END_TO_START = _END_TO_START; + function _nativeCommand(doc, key, val) { try { doc.execCommand(key, false, val); @@ -3361,6 +3363,10 @@ function _drag(options) { }); } clickEl.mousedown(function(e) { + //新加的 + if(e.button !== 0 && e.button !== 1) { + return; + } e.stopPropagation(); var self = clickEl.get(), x = _removeUnit(moveEl.css('left')), @@ -3681,13 +3687,20 @@ _extend(KEdit, KWidget, { if (isDocumentDomain) { doc.domain = document.domain; } + doc.write(_getInitHtml(themesPath, bodyClass, cssPath, cssData)); doc.close(); self.win = self.iframe[0].contentWindow; self.doc = doc; var cmd = _cmd(doc); self.afterChange(function(e) { - cmd.selection(); +// if (e.which == 8) { +// var range = cmd.range +// var bookmark = range.createBookmark(); +// cmd.doc.body.innerHTML = cmd.doc.body.innerHTML.replace(/

\s*<\/p>/g,""); +// range.moveToBookmark(bookmark); +// } + cmd.selection(); }); if (_WEBKIT) { K(doc).click(function(e) { @@ -3824,9 +3837,20 @@ _extend(KEdit, KWidget, { if (!self.designMode) { val = self.html(); self.designMode = true; - self.html(val); + + //self.html(val); + //self.textarea.hide(); + //self.iframe.show(); + //新加 self.textarea.hide(); - self.iframe.show(); + self.html(val); + var iframe = self.iframe; + var height = _removeUnit(self.height); + iframe.height(height - 2); + iframe.show(); + setTimeout(function() { + iframe.height(height); + }, 0); } } else { if (self.designMode) { @@ -3958,7 +3982,7 @@ _extend(KToolbar, KWidget, { }else if(!$("#full",container).is(':hidden')){ pdiv = $("#full",container); } - return (this._itemMap[name] = K('span.ke-icon-' + name, pdiv).parent()); + return (this._itemMap[name] = K('span.ke-icon-' + name, this.div).parent()); }, select : function(name) { _selectToolbar.call(this, name, function(knode) { @@ -4864,6 +4888,11 @@ KEditor.prototype = { }, loadPlugin : function(name, fn) { var self = this; + //新加 + var _pluginStatus = this._pluginStatus; + if (!_pluginStatus) { + _pluginStatus = this._pluginStatus = {}; + } if (_plugins[name]) { if (!_isFunction(_plugins[name])) { setTimeout(function() { @@ -4871,7 +4900,12 @@ KEditor.prototype = { }, 100); return self; } - _plugins[name].call(self, KindEditor); + //_plugins[name].call(self, KindEditor); + //新加 + if(!_pluginStatus[name]) { + _plugins[name].call(self, KindEditor); + _pluginStatus[name] = 'inited'; + } if (fn) { fn.call(self); } @@ -5510,6 +5544,11 @@ function _create(expr, options) { _each(_plugins, function(name, fn) { if (_isFunction(fn)) { fn.call(editor, KindEditor); + //新加 + if (!editor._pluginStatus) { + editor._pluginStatus = {}; + } + editor._pluginStatus[name] = 'inited'; } }); return editor.create(); @@ -5772,13 +5811,14 @@ _plugin('core', function(K) { click : function() { self.select().exec('formatblock', '<' + key + '>').hideMenu(); //by yk利用html的特性使h1 h2 h3 h4标签之间不能相互包含 并将空的标签去掉 - if (key != "p"){ +// if (key != "p"){ var val = self.select().html(); self.select().html(val); + self.cmd.doc.body.innerHTML = self.cmd.doc.body.innerHTML.replace(/

\s*<\/p>/g,""); val = self.select().html().replace(/(

\s*<\/h1>)|(

\s*<\/h2>)|(

\s*<\/h3>)|(

\s*<\/h4>)/g,""); self.select().html(val); self.select(); - } +// } } }); }); @@ -6059,6 +6099,9 @@ _plugin('core', function(K) { } else { cmd.range.selectNodeContents(div[0]); cmd.select(); + //新加 + div[0].tabIndex = -1; + div[0].focus(); } setTimeout(function() { movePastedData(); diff --git a/public/assets/kindeditor/plugins/autoheight/autoheight.js b/public/assets/kindeditor/plugins/autoheight/autoheight.js index cdd3f94f8..1a067e134 100644 --- a/public/assets/kindeditor/plugins/autoheight/autoheight.js +++ b/public/assets/kindeditor/plugins/autoheight/autoheight.js @@ -27,9 +27,19 @@ KindEditor.plugin('autoheight', function(K) { var edit = self.edit; var body = edit.doc.body; edit.iframe.height(minHeight); + + //最高418 超过用滚动条 self.resize(null, Math.max( - (K.IE ? body.scrollHeight : body.offsetHeight) + (K.IE ? body.scrollHeight : body.offsetHeight) > 385 ? 385+33 : (K.IE ? body.scrollHeight : body.offsetHeight) + 33, minHeight)); + + if( self.height == "418px" ){ + edit.iframe[0].scroll = 'yes'; + body.style.overflowY = 'auto'; + } + else{ + hideScroll(); + } } function init() { diff --git a/public/assets/kindeditor/plugins/code/code.js b/public/assets/kindeditor/plugins/code/code.js index 760f20bc7..3a3a982ea 100644 --- a/public/assets/kindeditor/plugins/code/code.js +++ b/public/assets/kindeditor/plugins/code/code.js @@ -42,6 +42,9 @@ KindEditor.plugin('code', function(K) { yesBtn : { name : self.lang('yes'), click : function(e) { + if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(self.edit.html())){ + self.edit.html(''); + } var type = K('.ke-code-type', dialog.div).val(), code = textarea.val(), cls = type === '' ? '' : ' lang-' + type, diff --git a/public/assets/kindeditor/plugins/code/previewcode.css b/public/assets/kindeditor/plugins/code/previewcode.css index cf9c219e9..f9f7c4b78 100644 --- a/public/assets/kindeditor/plugins/code/previewcode.css +++ b/public/assets/kindeditor/plugins/code/previewcode.css @@ -46,7 +46,7 @@ .ke-content div.ref .ref_body {margin:0;padding:2px;line-height:20px;color:#666;font-size:9pt;} -.ke-content blockquote {margin:15px 10px;border:2px solid #eee;padding:5px 5px 5px 35px;background:#f4f5f7 url('../img/blockquote.gif') no-repeat left top;color:#060;font-size:9pt;} +.ke-content blockquote {margin:15px 10px;border:2px solid #eee;padding:5px 5px 5px 35px;} span.at {color:#269ac9;} span.at a{color:#269ac9;text-decoration: none;} @@ -54,5 +54,5 @@ span.at a{color:#269ac9;text-decoration: none;} .ke-content ol li{list-style-type: decimal;} .ke-content ul li{list-style-type: disc;} .ke-content ol,.ke-content ul,.ke-content h1,.ke-content h2,.ke-content h3,.ke-content h4{margin-top:0;margin-bottom: 0;} -.ke-content a{color: #15bccf;} +.ke-content a{color: #136ec2;} .ke-content a:link,.ke-content a:visited{text-decoration:none;} diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 1bab8dfb4..d7f48c4b2 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -8,7 +8,7 @@
-
+