diff --git a/.gitignore b/.gitignore index ffa4a1bc7..fdb7a3c6b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ /config/database.yml /config/configuration.yml /config/additional_environment.rb + /files/* /log/* /public/tmp/* diff --git a/Gemfile b/Gemfile index fbe74f8dd..660a7ff49 100644 --- a/Gemfile +++ b/Gemfile @@ -1,83 +1,84 @@ -source 'http://ruby.taobao.org' -#source 'http://ruby.sdutlinux.org/' - -unless RUBY_PLATFORM =~ /w32/ - # unix-like only - gem 'iconv' -end - -gem "mysql2", "= 0.3.18" -gem 'redis-rails' -gem 'rubyzip' -gem 'delayed_job_active_record'#, :group => :production -gem 'daemons' -gem 'grape', '~> 0.9.0' -gem 'grape-entity' -gem 'seems_rateable', '~> 1.0.13' -gem "rails", "3.2.13" -gem "jquery-rails", "~> 2.0.2" -gem "i18n", "~> 0.6.0" -gem 'coderay', '~> 1.1.0' -gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] -gem "builder", "3.0.0" -gem 'acts-as-taggable-on', '2.4.1' -gem 'spreadsheet' -gem 'ruby-ole' -gem 'rails_kindeditor',path:'lib/rails_kindeditor' -gem "rmagick", ">= 2.0.0" - -group :development do - gem 'grape-swagger' - gem 'better_errors', '~> 1.1.0' - gem 'rack-mini-profiler', '~> 0.9.3' -end - -group :development, :test do - unless RUBY_PLATFORM =~ /w32/ - gem 'pry-rails' - if RUBY_VERSION >= '2.0.0' - gem 'pry-byebug' - end - gem 'pry-stack_explorer' - end - - gem 'rspec-rails', '~> 3.0' - gem 'factory_girl_rails' -end - -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails', '~> 3.2.3' - gem 'coffee-rails', '~> 3.2.1' - - # See https://github.com/sstephenson/execjs#readme for more supported runtimes - gem 'therubyracer', :platforms => :ruby - - gem 'uglifier', '>= 1.0.3' -end - -# Optional gem for LDAP authentication -group :ldap do - gem "net-ldap", "~> 0.3.1" -end - - -# Optional gem for OpenID authentication -group :openid do - gem "ruby-openid", "~> 2.1.4", :require => "openid" - gem "rack-openid" -end - - -database_file = File.join(File.dirname(__FILE__), "config/database.yml") -if File.exist?(database_file) -else - warn("Please configure your config/database.yml first") -end - -# Load plugins' Gemfiles -Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file| - puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v` - instance_eval File.read(file) -end +source 'http://ruby.taobao.org' +#source 'http://ruby.sdutlinux.org/' + +unless RUBY_PLATFORM =~ /w32/ + # unix-like only + gem 'iconv' +end + +gem 'rest-client' +gem "mysql2", "= 0.3.18" +gem 'redis-rails' +gem 'rubyzip' +gem 'delayed_job_active_record'#, :group => :production +gem 'daemons' +gem 'grape', '~> 0.9.0' +gem 'grape-entity' +gem 'seems_rateable', '~> 1.0.13' +gem "rails", "3.2.13" +gem "jquery-rails", "~> 2.0.2" +gem "i18n", "~> 0.6.0" +gem 'coderay', '~> 1.1.0' +gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] +gem "builder", "3.0.0" +gem 'acts-as-taggable-on', '2.4.1' +gem 'spreadsheet' +gem 'ruby-ole' +gem 'rails_kindeditor',path:'lib/rails_kindeditor' +#gem "rmagick", ">= 2.0.0" + +group :development do + gem 'grape-swagger' + gem 'better_errors', '~> 1.1.0' + gem 'rack-mini-profiler', '~> 0.9.3' +end + +group :development, :test do + unless RUBY_PLATFORM =~ /w32/ + gem 'pry-rails' + if RUBY_VERSION >= '2.0.0' + gem 'pry-byebug' + end + gem 'pry-stack_explorer' + end + + gem 'rspec-rails', '~> 3.0' + gem 'factory_girl_rails' +end + +# Gems used only for assets and not required +# in production environments by default. +group :assets do + gem 'sass-rails', '~> 3.2.3' + gem 'coffee-rails', '~> 3.2.1' + + # See https://github.com/sstephenson/execjs#readme for more supported runtimes + gem 'therubyracer', :platforms => :ruby + + gem 'uglifier', '>= 1.0.3' +end + +# Optional gem for LDAP authentication +group :ldap do + gem "net-ldap", "~> 0.3.1" +end + + +# Optional gem for OpenID authentication +group :openid do + gem "ruby-openid", "~> 2.1.4", :require => "openid" + gem "rack-openid" +end + + +database_file = File.join(File.dirname(__FILE__), "config/database.yml") +if File.exist?(database_file) +else + warn("Please configure your config/database.yml first") +end + +# Load plugins' Gemfiles +Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file| + puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v` + instance_eval File.read(file) +end diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb index edc7bcf54..86132a93a 100644 --- a/app/api/mobile/apis/comments.rb +++ b/app/api/mobile/apis/comments.rb @@ -91,6 +91,7 @@ module Mobile desc '课程留言列表' params do optional :token, type: String + optional :page,type:Integer,desc:'页数' end get ':id/course_message' do cs = CommentService.new @@ -99,6 +100,19 @@ module Mobile present :status, 0 end + desc '留言详情' + params do + requires :token, type: String + requires :comment_parent_id,type:Integer,desc:'留言id' + optional :course_id,type:Integer,desc:'课程id' + end + get ':comment_parent_id/comment_details' do + cs = CommentService.new + jour = cs.comment_detail params,current_user + present :data, jour, with: Mobile::Entities::Jours + present :status, 0 + end + end end end diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 008a08f2f..73d1e357c 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -258,7 +258,7 @@ module Mobile requires :course_id,type: Integer,desc: '课程id' optional :name,type:String,desc:'课件名称可能包含的字符' end - get ":course_id/attachments" do + post ":course_id/attachments" do cs = CoursesService.new count = cs.course_attachments params present :data, count, with: Mobile::Entities::Attachment diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 147cbfda5..583a130d1 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -94,6 +94,59 @@ module Mobile present :status, 0 end + desc "用户留言" + params do + requires :token, type: String + requires :user_id, type: Integer,desc: '被留言的用户id' + requires :page,type:Integer,desc:'请求数据的页码' + end + get ':user_id/messages' do + us = UsersService.new + jours = us.get_all_messages params + present :data,jours,with:Mobile::Entities::Jours + present :status,0 + end + + desc "回复用户留言" + params do + requires :token, type: String + requires :user_id, type: Integer,desc: '被留言的用户id' + requires :content,type:String,desc:'留言内容' + requires :ref_user_id,type:Integer,desc:'被回复的用户id' + requires :parent_id,type:Integer,desc:'留言父id' + requires :ref_message_id,type:Integer,desc:'引用消息id' + optional :type,type:Integer,desc:'回复类型' + optional :course_id,type:Integer,desc:'课程id' + end + post ':user_id/reply_message' do + us = UsersService.new + jours = us.reply_user_messages params,current_user + present :status,0 + end + + desc "给用户留言" + params do + requires :token, type: String + requires :user_id, type: Integer,desc:'被留言的用户id' + requires :content, type: String,desc:'留言内容' + end + post ':user_id/leave_message' do + us = UsersService.new + us.leave_message params,current_user + present :data,0 + end + + desc "与我相关" + params do + requires :token, type: String + requires :page,type:Integer,desc:'页码' + end + get ':user_id/all_my_dynamic' do + us = UsersService.new + my_jours = us.reply_my_messages params,current_user + present :data,my_jours,with:Mobile::Entities::Jours + present :status,0 + end end end end diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index 10fd0f893..97eabd21f 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -14,6 +14,11 @@ module Mobile else f.send(field) end + else + case f + when :course_name + f[:jour_type] == "Course" ? f.course.name : "" + end end end end @@ -27,6 +32,11 @@ module Mobile jours_expose :notes jours_expose :m_reply_id jours_expose :m_parent_id + expose :course,using:Mobile::Entities::Course do |f,opt| + if f.is_a?(::JournalsForMessage) && f[:jour_type] == "Course" + f.course + end + end expose :reply_user,using: Mobile::Entities::User do |f, opt| f.at_user end diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 7976e1aa4..181f76b22 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -338,6 +338,9 @@ class AccountController < ApplicationController :secure => (Redmine::Configuration['autologin_cookie_secure'] ? true : false), :httponly => true } + if Redmine::Configuration['cookie_domain'].present? + cookie_options = cookie_options.merge(domain: Redmine::Configuration['cookie_domain']) + end cookies[autologin_cookie_name] = cookie_options end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0dc86fb01..10e5e6f06 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -199,7 +199,11 @@ class ApplicationController < ActionController::Base # Logs out current user def logout_user if User.current.logged? - cookies.delete(autologin_cookie_name) + if Redmine::Configuration['cookie_domain'].present? + cookies.delete(autologin_cookie_name, domain: Redmine::Configuration['cookie_domain']) + else + cookies.delete autologin_cookie_name + end # Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin']) self.logged_user = nil end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 532fbb51e..eb6df6d3c 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -69,9 +69,12 @@ class AttachmentsController < ApplicationController if candown || User.current.admin? || User.current.id == @attachment.author_id @attachment.increment_download if stale?(:etag => @attachment.digest) - send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), - :type => detect_content_type(@attachment), - :disposition => 'attachment' #inline can open in browser + req = RestClient.post 'http://192.168.80.107/Any2HtmlHandler.ashx', :txtDes => File.new(@attachment.diskfile, 'rb') + render :text => req.body + + # send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), + # :type => detect_content_type(@attachment), + # :disposition => 'attachment' #inline can open in browser end else diff --git a/app/controllers/avatar_controller.rb b/app/controllers/avatar_controller.rb index ef7cdf2f7..a7c0e7b95 100644 --- a/app/controllers/avatar_controller.rb +++ b/app/controllers/avatar_controller.rb @@ -1,9 +1,9 @@ class AvatarController < ApplicationController - - + + include ActionView::Helpers::NumberHelper #before_filter :set_cache_buster include AvatarHelper - + def upload # Make sure that API users get used to set this content type # as it won't trigger Rails' automatic parsing of the request body for parameters @@ -24,48 +24,58 @@ class AvatarController < ApplicationController else @image_file=params[:filename] end + @temp_file = StringIO.new(@temp_file) end end end if @temp_file && (@temp_file.size > 0) - diskfile=disk_filename(@source_type,@source_id) - @urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file)) + if @temp_file.size > Setting.upload_avatar_max_size.to_i + @status = 1 + @msg = l(:error_upload_avatar_to_large, :max_size => number_to_human_size(Setting.upload_avatar_max_size.to_i)) + elsif Trustie::Utils::Image.new(@temp_file).image? + diskfile=disk_filename(@source_type,@source_id) + @urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file)) - # 用户头像上传时进行特别处理 - if @source_type == 'User' + # 用户头像上传时进行特别处理 + if @source_type == 'User' diskfile += "temp" @urlfile += "temp" - end + end - logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)") - path = File.dirname(diskfile) - unless File.directory?(path) - FileUtils.mkdir_p(path) - end - md5 = Digest::MD5.new - File.open(diskfile, "wb") do |f| - if @temp_file.respond_to?(:read) - buffer = "" - while (buffer = @temp_file.read(8192)) - f.write(buffer) - md5.update(buffer) + logger.info("Saving avatar '#{diskfile}' (#{@temp_file.size} bytes)") + path = File.dirname(diskfile) + unless File.directory?(path) + FileUtils.mkdir_p(path) + end + md5 = Digest::MD5.new + File.open(diskfile, "wb") do |f| + if @temp_file.respond_to?(:read) + @temp_file.rewind + buffer = "" + while (buffer = @temp_file.read(8192)) + f.write(buffer) + md5.update(buffer) + end + else + f.write(@temp_file) + md5.update(@temp_file) end - else - f.write(@temp_file) - md5.update(@temp_file) end + + Trustie::Utils::Image.new(diskfile,true).compress(300) + @status = 0 + @msg = '' + else + @status = 2 + @msg = l(:not_valid_image_file) end -# self.digest = md5.hexdigest end @temp_file = nil - image = Trustie::Utils::Image.new(diskfile,true) - image.compress(300) - respond_to do |format| format.json{ - render :inline => "#{@urlfile.to_s}?#{Time.now.to_i}",:content_type => 'text/html' + render :inline => {status: @status, message:@msg, url:"#{@urlfile.to_s}?#{Time.now.to_i}"}.to_json,:content_type => 'text/html' return } format.js diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index c98df27d3..35236414f 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -675,11 +675,12 @@ class BidsController < ApplicationController #删除作业 #by xianbo def homework_destroy - @bid_to_destroy = Bid.find params[:course_id] + @bid_to_destroy = Bid.find params[:id] + course_url = course_homework_path(@bid_to_destroy.courses.first) (render_403; return false) unless User.current.admin?||User.current.id==@bid_to_destroy.author_id @bid_to_destroy.destroy respond_to do |format| - format.html { redirect_to :back } + format.html { redirect_to course_url } format.js #format.api { render_api_ok } end diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 7ccfb0e10..db5bded55 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -32,13 +32,17 @@ class BoardsController < ApplicationController #modify by nwb @flag = params[:flag] || false if @project - @boards = @project.boards.includes(:last_message => :author).all - @boards = [] << @boards[0] if @boards.any? - if @boards.size == 1 - @board = @boards.first - show and return + if !@project.is_public? && !User.current.member_of?(@project) && !User.current.admin? + render_403 + else + @boards = @project.boards.includes(:last_message => :author).all + @boards = [] << @boards[0] if @boards.any? + if @boards.size == 1 + @board = @boards.first + show and return + end + render :layout => false if request.xhr? end - render :layout => false if request.xhr? elsif @course if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) @boards = @course.boards.includes(:last_message => :author).all @@ -76,19 +80,19 @@ class BoardsController < ApplicationController if @project @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] @topics = @board.topics. - reorder("#{Message.table_name}.sticky DESC"). + reorder("#{Message.table_name}.sticky DESC, #{Message.table_name}.created_on desc"). includes(:last_reply). limit(@topic_pages.per_page). offset(@topic_pages.offset). - order("last_replies_messages.created_on desc"). + preload(:author, {:last_reply => :author}). all elsif @course - board_topics = @board ? @board.topics.reorder("#{Message.table_name}.sticky DESC"). + board_topics = @board ? @board.topics.reorder("#{Message.table_name}.sticky DESC, #{Message.table_name}.created_on desc"). includes(:last_reply). # limit(@topic_pages.per_page). # offset(@topic_pages.offset). - order("last_replies_messages.created_on desc"). + preload(:author, {:last_reply => :author}). all : [] @topics = paginateHelper board_topics,10 diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index d616daadc..be69b1777 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -342,10 +342,15 @@ 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)}"; + # 如果是ie11 需要转码 + if(/rv\:11\.0/.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 => "#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}.xls") + :filename => "#{filename}.xls") } end end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 69e7105aa..0003f7586 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -23,7 +23,7 @@ class FilesController < ApplicationController before_filter :auth_login1, :only => [:index] before_filter :logged_user_by_apptoken,:only => [:index] before_filter :find_project_by_project_id#, :except => [:getattachtype] - before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search,:search_project,:quote_resource_show_project,:search_tag_attachment] + before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,:search_tag_attachment] helper :sort include SortHelper @@ -46,6 +46,13 @@ class FilesController < ApplicationController @obj_attachments = paginateHelper @all_attachments,10 end + def searchone4reload + attachment = Attachment.find_by_id(params[:fileid]); + respond_to do |format| + format.html{render :layout => nil,:locals=>{:file=>attachment,:course=>@course}} + end + end + def search sort = "" @sort = "" @@ -60,9 +67,7 @@ class FilesController < ApplicationController end sort = "#{@sort} #{@order}" end - # show_attachments [@course] - begin q = "%#{params[:name].strip}%" #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? @@ -101,14 +106,18 @@ class FilesController < ApplicationController end sort = "#{@sort} #{@order}" end - begin q = "%#{params[:name].strip}%" #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? if params[:insite] - @result = find_public_attache q,sort - @result = visable_attachemnts_insite @result,@project - @searched_attach = paginateHelper @result,10 + if q == "%%" + @result = [] + @searched_attach = paginateHelper @result,10 + else + @result = find_public_attache q,sort + @result = visable_attachemnts_insite @result,@project + @searched_attach = paginateHelper @result,10 + end else @result = find_project_attache q,@project,sort @result = visable_attachemnts @result diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index b6035ca51..539d84e65 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -84,15 +84,10 @@ class IssuesController < ApplicationController @issue_pages = Paginator.new @issue_count, @limit, params['page'] @offset ||= @issue_pages.offset @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], - :order => sort_clause, - :offset => @offset, - :limit => @limit) + :order => sort_clause, + :offset => @offset, + :limit => @limit) @issue_count_by_group = @query.issue_count_by_group - - - - - respond_to do |format| format.js format.html { render :template => 'issues/index', :layout => @project_base_tag }#by young @@ -131,11 +126,11 @@ class IssuesController < ApplicationController @edit_allowed = User.current.allowed_to?(:edit_issues, @project) @priorities = IssuePriority.active @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) - + @project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq - - respond_to do |format| + + respond_to do |format|`` format.html { retrieve_previous_and_next_issue_ids render :template => 'issues/show', :layout => @project_base_tag#by young @@ -174,7 +169,7 @@ class IssuesController < ApplicationController attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} redirect_to new_project_issue_url(@issue.project, :issue => attrs) else - redirect_to issue_url(@issue) + redirect_to issue_url(@issue.id) end } format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) } @@ -244,7 +239,8 @@ class IssuesController < ApplicationController flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? respond_to do |format| - format.html { redirect_back_or_default issue_path(@issue) } + + format.html { redirect_to issue_url(@issue.id) } format.api { render_api_ok } end else diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 619f91245..e33eb8d75 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -193,7 +193,7 @@ class MessagesController < ApplicationController else redirect_to board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)) end - elsif request.get? + elsif request.get? || request.post? if params[:is_board] if @project redirect_to project_boards_path(@project) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 96807d2dc..fbafd16e9 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -31,7 +31,7 @@ class ProjectsController < ApplicationController before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course] before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches] before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] - before_filter :file, :statistics, :watcherlist + before_filter :file, :statistics #:watcherlist # 除非项目内人员,不可查看成员, TODO: 完了写报表里去 before_filter :memberAccess, only: :member @@ -243,14 +243,7 @@ class ProjectsController < ApplicationController # Author lizanle # Description 项目动态展示方法,删除了不必要的代码 def show - # params[:login]为邮箱邀请用户加入,主要功能: - # 1、自动注册 - # 2、加入项目、创建角色 - # 3、用户得分 - if params[:email] - user = User.find_by_mail(params[:email].to_s) - Member.create(:role_ids => [4], :user_id => user.id,:project_id => @project.id) - end + if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return end @@ -348,7 +341,7 @@ class ProjectsController < ApplicationController if !params[:mail].blank? && User.find_by_mail(params[:mail].to_s).nil? email = params[:mail] Mailer.run.send_invite_in_project(email, @project, User.current) - @is_zhuce =false + @is_zhuce = false flash[:notice] = l(:notice_email_sent, :value => email) elsif !User.find_by_mail(params[:mail].to_s).nil? user = User.find_by_mail(params[:mail].to_s) @@ -399,6 +392,26 @@ class ProjectsController < ApplicationController # by young # include CoursesHelper def member + # params[:login]为邮箱邀请用户加入,主要功能: + # 1、自动注册 + # 2、加入项目、创建角色 + # 3、用户得分 + if params[:mail] + user = User.find(params[:user_id]) + user.activate! + Member.create(:role_ids => [4], :user_id => params[:user_id],:project_id => params[:id]) + UserGrade.create(:user_id => params[:user_id], :project_id => params[:id]) + token = Token.get_token_from_user(user, 'autologin') + #user = User.try_to_autologin(token.value) + if user + start_user_session(user) + user.save + redirect_to project_member_path(params[:id]) + return + # account_ project_member_path(params[:id]) + flash[:notice] = l(:label_mail_invite_success) + end + end ## 有角色参数的才是课程,没有的就是项目 @render_file = 'project_member_list' # 判断是否课程 @@ -417,10 +430,14 @@ class ProjectsController < ApplicationController @members = @project.member_principals.includes(:roles, :principal).all.sort end else - roles = Role.find_all_givable - @subPage_title = l :label_member_list - @members = @project.member_principals.includes(:roles, :principal).joins("LEFT JOIN #{OptionNumber.table_name} ON #{OptionNumber.table_name}.user_id = #{Member.table_name}.user_id and #{OptionNumber.table_name}.score_type = 2 AND #{Member.table_name}.project_id = #{OptionNumber.table_name}.project_id").order("#{OptionNumber.table_name}.total_score DESC").all - @applied_members = appied_project_members(@project, @members) + if !@project.is_public? && !User.current.member_of?(@project) && !User.current.admin? + render_403 + else + roles = Role.find_all_givable + @subPage_title = l :label_member_list + @members = @project.member_principals.includes(:roles, :principal).joins("LEFT JOIN #{OptionNumber.table_name} ON #{OptionNumber.table_name}.user_id = #{Member.table_name}.user_id and #{OptionNumber.table_name}.score_type = 2 AND #{Member.table_name}.project_id = #{OptionNumber.table_name}.project_id").order("#{OptionNumber.table_name}.total_score DESC").all + @applied_members = appied_project_members(@project, @members) + end end @members = paginateHelper @members render :layout => 'base_courses' if @project.project_type == 1 @@ -676,11 +693,13 @@ class ProjectsController < ApplicationController true end - # added by huang - def watcherlist - if @watched - @users -= watched.watcher_users + unless @project.nil? + if !@project.is_public? && !User.current.member_of?(@project) && !User.current.admin? + render_403 + else + @users -= watched.watcher_users if @watched + end end end diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb index 51ff293f1..12fead4f2 100644 --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -1,3 +1,5 @@ +require 'net/http' + class TestController < ApplicationController helper :UserScore @@ -5,6 +7,10 @@ class TestController < ApplicationController def bootstrap; end + def view_office + + end + def zip homeworks_attach_path = [] homework_id = params[:homework_id] diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 6e067fb83..20b855fd8 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -16,74 +16,77 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class WelcomeController < ApplicationController + # layout "base_welcome" include ApplicationHelper include WelcomeHelper helper :project_score - caches_action :robots + caches_action :robots, :course, :contest, expires_in: 2.hours, layout: false #before_filter :find_first_page, :only => [:index] # before_filter :fake, :only => [:index, :course] before_filter :entry_select, :only => [:index] def index # 企业版定制: params[:project]为传过来的参数 - unless params[:organization].nil? - @organization = Organization.find params[:organization] - # @organization_projects = Project.joins(:project_status).joins("LEFT JOIN project_scores ON projects.id = project_scores.project_id").where("projects.organization_id = ?", @organization.id).order("score DESC").limit(10).all - @organization_projects = @organization.projects.visible.joins("LEFT JOIN project_scores ON projects.id = project_scores.project_id").order("project_scores.score DESC").limit(10).all - @part_projects = @organization_projects.count < 9 ? find_miracle_project( 9 - @organization_projects.count, 3,"score desc") : [] - # @cur_projects = Project.find(params[:organization]) - # @organization = @cur_projects.enterprise_name - # @organization_projects = (current_user.admin? || User.current.member_of?(@cur_projects)) ? Project.where("enterprise_name =? ", @organization) : Project.all_public.where("enterprise_name =? ", @organization) - # @e_count = @organization_projects.count - # @part_projects = [] - # # 取十个 - # @organization_projects.each do |obj| - # break if(@organization_projects[10] == obj) - # @part_projects << Project.visible.find_by_id("#{obj.id}") unless obj.id.nil? - # end - # # 不够十个的用最火项目替代 - # @e_count < 9 ? @part_projects = find_miracle_project( 9 - @e_count, 3,"score desc") : @part_projects - # # 配置文件首页定制 - @enterprise_page = FirstPage.find_by_page_type('enterprise') - if @enterprise_page.nil? - @enterprise_page = FirstPage.new - @enterprise_page.page_type = 'enterprise' + + unless params[:organization].nil? + @organization = Organization.find params[:organization] + # @organization_projects = Project.joins(:project_status).joins("LEFT JOIN project_scores ON projects.id = project_scores.project_id").where("projects.organization_id = ?", @organization.id).order("score DESC").limit(10).all + @organization_projects = @organization.projects.visible.joins("LEFT JOIN project_scores ON projects.id = project_scores.project_id").order("project_scores.score DESC").limit(10).all + @part_projects = @organization_projects.count < 9 ? find_miracle_project( 9 - @organization_projects.count, 3,"score desc") : [] + # @cur_projects = Project.find(params[:organization]) + # @organization = @cur_projects.enterprise_name + # @organization_projects = (current_user.admin? || User.current.member_of?(@cur_projects)) ? Project.where("enterprise_name =? ", @organization) : Project.all_public.where("enterprise_name =? ", @organization) + # @e_count = @organization_projects.count + # @part_projects = [] + # # 取十个 + # @organization_projects.each do |obj| + # break if(@organization_projects[10] == obj) + # @part_projects << Project.visible.find_by_id("#{obj.id}") unless obj.id.nil? + # end + # # 不够十个的用最火项目替代 + # @e_count < 9 ? @part_projects = find_miracle_project( 9 - @e_count, 3,"score desc") : @part_projects + # # 配置文件首页定制 + @enterprise_page = FirstPage.find_by_page_type('enterprise') + if @enterprise_page.nil? + @enterprise_page = FirstPage.new + @enterprise_page.page_type = 'enterprise' + end + # 主页配置部分结束 end - # 主页配置部分结束 - end - # end 企业版定制结束 + # end 企业版定制结束 - if @first_page.nil? || @first_page.sort_type.nil? - @projects = find_miracle_project(10, 3,"score desc") - else - case @first_page.sort_type - when 0 - @my_projects = find_my_projects - @other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : [] - @projects = find_miracle_project(10, 3,"created_on desc") - #@projects = @projects_all.order("created_on desc") - when 1 - @my_projects = find_my_projects - @other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : [] - @projects = find_miracle_project(10, 3,"score desc") - #@projects = @projects_all.order("grade desc") - when 2 - @my_projects = find_my_projects - @other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : [] - @projects = find_miracle_project(10, 3,"watchers_count desc") - #@projects = @projects_all.order("watchers_count desc") + if @first_page.nil? || @first_page.sort_type.nil? + @projects = find_miracle_project(10, 3,"score desc") + else + case @first_page.sort_type + when 0 + @my_projects = find_my_projects + @other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : [] + @projects = find_miracle_project(10, 3,"created_on desc") + #@projects = @projects_all.order("created_on desc") + when 1 + @my_projects = find_my_projects + @other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : [] + @projects = find_miracle_project(10, 3,"score desc") + #@projects = @projects_all.order("grade desc") + when 2 + @my_projects = find_my_projects + @other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : [] + @projects = find_miracle_project(10, 3,"watchers_count desc") + #@projects = @projects_all.order("watchers_count desc") - #gcm - #when '3' - #@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array) - # @projects=handle_project @projects_all,@project_activity_count - # @s_type = 3 - # @projects = @projects[@project_pages.offset, @project_pages.per_page] + #gcm + #when '3' + #@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array) + # @projects=handle_project @projects_all,@project_activity_count + # @s_type = 3 + # @projects = @projects[@project_pages.offset, @project_pages.per_page] - else - @projects = @projects_all.order("score desc") + else + @projects = @projects_all.order("score desc") + end end - end + rescue Exception => e render_404 end diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 3d6772ea8..cc6c4f47e 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -85,6 +85,9 @@ class WordsController < ApplicationController elsif @journal_destroyed.jour_type == "Course" @course = Course.find @journal_destroyed.jour_id @jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count + elsif @journal_destroyed.jour_type == "Principal" + @user = User.find(@journal_destroyed.jour_id) + @jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count end respond_to do |format| format.js diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 9b0b97ff2..043552872 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -9,10 +9,14 @@ class ZipdownController < ApplicationController #统一下载功能 def download - begin - send_file "#{OUTPUT_FOLDER}/#{params[:file]}", :filename => params[:filename], :type => detect_content_type(params[:file]) - rescue => e - render file: 'public/no_file_found.html' + if User.current.logged? + begin + send_file "#{OUTPUT_FOLDER}/#{params[:file]}", :filename => params[:filename], :type => detect_content_type(params[:file]) + rescue => e + render file: 'public/no_file_found.html' + end + else + render_403 end end diff --git a/app/helpers/account_helper.rb b/app/helpers/account_helper.rb index 7ad6fe65b..827557a40 100644 --- a/app/helpers/account_helper.rb +++ b/app/helpers/account_helper.rb @@ -47,6 +47,18 @@ module AccountHelper user end + # 自动创建一个新用户,但是初始状态是锁定的 + def automatically_register_lock(user, &block) + user.lock + user.last_login_on = Time.now + if user.save + UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0) + else + yield if block_given? + end + user + end + def administrator_manually__register(user, &block) if user.save UserStatus.create(:user_id => user.id ,:changsets_count => 0, :watchers_count => 0) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7f3d2c1a2..5ae70fd7c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -622,8 +622,8 @@ module ApplicationHelper # 公开项目资源可以引用,admin和管理员和资源上传者拥有设置公开私有权限 def authority_pubilic_for_files(project, file) @result = false - if (is_project_manager?(User.current.id, @project.id) || file.author_id == User.current.id || User.current.admin) && - project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project" + if (is_project_manager?(User.current.id, @project.id) && User.current.allowed_to?(:manage_files, project)) || file.author_id == User.current.id || User.current.admin && + project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project" @result = true end return @result diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index b72a191db..aae150728 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -67,29 +67,33 @@ module IssuesHelper s.html_safe end - #获取跟踪类型 - #REDO:时间紧需要优化,两个方法可以综合成一个 + #获取跟踪类型及样式 + #REDO:时间紧可以优化. def get_issue_type(value) + issuetype = [] if value == "缺陷" || value == 1 - class_type = "red_btn_cir ml10" + issuetype << "red_btn_cir ml10" + issuetype << "缺陷" elsif value == "功能" || value == 2 - class_type = "blue_btn_cir ml10" + issuetype << "blue_btn_cir ml10" + issuetype << "功能" elsif value == "支持" || value == 3 - class_type = "green_btn_cir ml10" + issuetype << "green_btn_cir ml10" + issuetype << "支持" + elsif value == "任务" || value == 4 + issuetype << "orange_btn_cir ml10" + issuetype << "任务" else - class_type = "orange_btn_cir ml10" + issuetype << "bgreen_btn_cir ml10" + issuetype << "周报" end end - def get_issue_typevalue(value) - if value == "缺陷" || value == 1 - assign = "缺陷" - elsif value == "功能" || value == 2 - assign = "功能" - elsif value == "支持" || value == 3 - assign = "支持" + def principals_options_for_isuue_list(project) + if User.current.member_of?(project) + project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["<< #{l(:label_me)} >>", User.current.id]).unshift(["指派给", 0]) else - assign = "任务" + project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["指派给", 0]) end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 508e58ba3..12925b0b1 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -65,6 +65,16 @@ module ProjectsHelper content_tag('div', content, :class => "tabs") end + # 判断我的项目中是否有重名项目 + def judge_same_projectname(user, project_name) + result = false + my_projects = user.projects + my_projects.each do |mp| + result = true if mp.name == project_name + end + return result + end + # Added by young def course_settings_tabs tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'}, diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index d9d910a66..43d01a5dd 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -255,7 +255,7 @@ module QueriesHelper # Give it a name, required to be valid @query = IssueQuery.new(:name => "_") @query.project = @project - params[:f] = %w(subject status_id priority_id author_id assigned_to_id) unless params[:status_id].nil? + params[:f] = %w(subject status_id priority_id author_id assigned_to_id created_on) unless params[:status_id].nil? params[:op] = {'subject' => "~" , 'status_id' => ( params[:status_id] == '0' ? "!":"=" ), 'priority_id' => ( params[:priority_id] == '0' ? "!":"=" ), @@ -266,6 +266,22 @@ module QueriesHelper 'priority_id' => [params[:priority_id]], 'author_id' => [params[:author_id]], 'assigned_to_id' => [params[:assigned_to_id]]} unless params[:status_id].nil? + if(params[:status_id] != nil) + if( params[:issue_create_date_start]!=nil && params[:issue_create_date_start]!='' && + params[:issue_create_date_end]!=nil && params[:issue_create_date_end]!='' ) + params[:op][:created_on]='><' + params[:v][:created_on]=[params[:issue_create_date_start],params[:issue_create_date_end]] + elsif(params[:issue_create_date_start]!=nil && params[:issue_create_date_start]!='') + params[:op][:created_on]='>=' + params[:v][:created_on]=[params[:issue_create_date_start]] + elsif(params[:issue_create_date_end]!=nil && params[:issue_create_date_end]!='') + params[:op][:created_on]='<=' + params[:v][:created_on]=[params[:issue_create_date_end]] + else + params[:op][:created_on]='!' + params[:v][:created_on]='' + end + end @query.build_from_params(params) #session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names} # else diff --git a/app/models/invite_list.rb b/app/models/invite_list.rb new file mode 100644 index 000000000..f1ba8546f --- /dev/null +++ b/app/models/invite_list.rb @@ -0,0 +1,5 @@ +class InviteList < ActiveRecord::Base + attr_accessible :project_id, :user_id + # belongs_to :user + # belongs_to :project +end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 7756b7e27..dbc5d3cff 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -58,14 +58,10 @@ class Mailer < ActionMailer::Base us = UsersService.new # 自动激活用户 user = us.register_auto(login, @email, @password) - - Member.create(:role_ids => [4], :user_id => user.id,:project_id => project.id) - UserGrade.create(:user_id => user.id, :project_id => project.id) User.current = user unless User.current.nil? @user = user - @token = Token.get_token_from_user(user, 'autologin') - @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id,:user => user, :token => @token.value - ) + + @project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true) mail :to => email, :subject => @subject end @@ -76,8 +72,9 @@ class Mailer < ActionMailer::Base @invitor_name = "#{invitor.name}" @project_name = "#{project.name}" @user = user + @project = project @token = Token.get_token_from_user(user, 'autologin') - @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :email => email, :token => @token.value) + @project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value) mail :to => email, :subject => @subject end diff --git a/app/models/project.rb b/app/models/project.rb index a60f43157..4a546a430 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -67,7 +67,7 @@ class Project < ActiveRecord::Base has_many :student, :through => :students_for_courses, :source => :user has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy has_many :applied_projects - + # has_many :invite_lists # end #ADDED BY NIE @@ -114,7 +114,7 @@ class Project < ActiveRecord::Base validates_presence_of :name, :identifier validates_uniqueness_of :identifier - validates_uniqueness_of :name + # validates_uniqueness_of :name validates_associated :wiki#, :repository # validates_length_of :description, :maximum => 255 validates_length_of :name, :maximum => 255 diff --git a/app/models/user.rb b/app/models/user.rb index a74025050..a1f00a234 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -130,6 +130,10 @@ class User < Principal has_many :documents # 项目中关联的文档再次与人关联 # end + # 邮件邀请状态 + # has_many :invite_lists + # end + ######added by nie has_many :project_infos, :dependent => :destroy has_one :user_status, :dependent => :destroy diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb index f75e14b85..2464297da 100644 --- a/app/services/comment_service.rb +++ b/app/services/comment_service.rb @@ -94,11 +94,24 @@ class CommentService def course_messages params,current_user @course = ::Course.find(params[:id]) if (current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course))) - @jours = @course.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + @jours = @course.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC').page(params[:page] ||= 1).per(10) else raise '403' end @jours end + def comment_detail params,current_user + if !params[:course_id].nil? && params[:course_id] != 0 + course = Course.find(params[:course_id]) + jour = course.journals_for_messages.where("id = ? ",params[:comment_parent_id]) + jour + else + jour1 = JournalsForMessage.where("id = ? ",params[:comment_parent_id]) + jour1 + end + end + + + end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 26d8df16f..49170bf30 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -364,19 +364,20 @@ class CoursesService latest_course_dynamics = [] latest_news = course.news.order("created_on desc").first unless latest_news.nil? - latest_course_dynamics << {:type => 1,:time => latest_news.created_on,:message => l(:label_recently_updated_notification,:locale => get_user_language(current_user))} + latest_course_dynamics << {:type => 1,:time => latest_news.created_on, + :message =>latest_news.author.realname<< l(:label_recently_updated_notification,:locale => get_user_language(current_user))<<":"<< latest_news.title } end latest_message = course.journals_for_messages.order("created_on desc").first unless latest_message.nil? - latest_course_dynamics << {:type => 2,:time => latest_message.created_on,:message => l(:label_recently_updated_message,:locale => get_user_language(current_user))} + latest_course_dynamics << {:type => 2,:time => latest_message.created_on,:message =>latest_message.user.realname << l(:label_recently_updated_message,:locale => get_user_language(current_user))<<":"< 3,:time => latest_attachment.created_on,:message => l(:label_recently_updated_courseware,:locale => get_user_language(current_user))} + latest_course_dynamics << {:type => 3,:time => latest_attachment.created_on,:message =>latest_attachment.author.realname<< l(:label_recently_updated_courseware,:locale => get_user_language(current_user))<<":"< 4,:time => latest_bid.updated_on,:message => l(:label_recently_updated_homework,:locale => get_user_language(current_user))} + latest_course_dynamics << {:type => 4,:time => latest_bid.updated_on,:message => latest_bid.author.realname< get_user_language(current_user))<<":"< 4,:time => latest_homework_attach.updated_at,:message => l(:label_recently_updated_homework,:locale => get_user_language(current_user))} + latest_course_dynamics << {:type => 4,:time => latest_homework_attach.updated_at,:message =>latest_homework_attach.user.realname<< l(:label_recently_updated_homework,:locale => get_user_language(current_user))<<":"<<(latest_homework_attach.name.nil? ? latest_homework_attach.description : latest_homework_attach.name)} end latest_course_dynamics.sort!{|order,newer| newer[:time] <=> order[:time]} latest_course_dynamic = latest_course_dynamics.first diff --git a/app/services/users_service.rb b/app/services/users_service.rb index afefc6ff1..aff0a975c 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -4,6 +4,7 @@ class UsersService include AvatarHelper include CoursesHelper include ApiHelper + include WordsHelper #将用户注册的功能函数写这里 #参数约定 #成功返回注册后的User实例,失败直接抛异常 @@ -61,7 +62,7 @@ class UsersService else @user.password = "" end - @user = automatically_register(@user) + @user = automatically_register_lock(@user) if @user.id != nil ue = @user.user_extensions ||= UserExtensions.new ue.user_id = @user.id @@ -154,8 +155,47 @@ class UsersService @user end + # 获取某个用户的所有留言信息 + def get_all_messages params + user = User.find(params[:user_id]) + jours = user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC').page(params[:page] || 1).per(10) + jours.update_all(:is_readed => true, :status => false) + jours.each do |journal| + fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false) + end + jours + end + # 回复用户 + def reply_user_messages params,current_user + user = User.find(params[:user_id]) + m_parent_id = params[:parent_id] + author_id = current_user.id + reply_id = params[:ref_user_id] + ref_message_id = params[:ref_message_id] + content = params[:content] + options = {:user_id => author_id, # 作者id + :status => true, + :m_parent_id => m_parent_id,# 父留言id + :m_reply_id => ref_message_id, # 子留言 id + :reply_id => reply_id, # 被留言用户id + :notes => content, + :is_readed => false} + if(params[:type] == 1) + user.add_jour(nil, nil,nil,options) + elsif(params[:type] == 2) + Course.find(params[:course_id]).journals_for_messages.build(options).save! unless params[:course_id].nil? + else + end + + end + + # 给用户留言 + def leave_message params,current_user + obj = User.find(params[:user_id]).add_jour(current_user, params[:content], 0) + obj + end #关注列表 @@ -205,10 +245,10 @@ class UsersService "show_changesets" => true } scope = User.logged.status(status) + search_by = params[:search_by] ? params[:search_by] : "0" if params[:is_search_assitant].nil? #modify by yutao 2015/5/18 没有params[:user_id]参数时去掉"id not in (?)"条件(bug:#2270) start #say by yutao: params[:user_id]这个是指谁发起的搜索么? 如果是 这个值貌似应该从session获取 怪怪的赶脚-_-! - search_by = params[:search_by] ? params[:search_by] : "0" if params[:name].present? if !params[:user_id].nil? watcher = User.watched_by(params[:user_id]) @@ -225,4 +265,42 @@ class UsersService scope end + # 课程留言中与我相关的回复 + def my_course_messages params,current_user + #找到我所有的课程 + @user = current_user + if !current_user.admin? && !@user.active? + raise '404' + return + end + if current_user == @user || current_user.admin? + membership = @user.coursememberships.all + end + # membership.sort! {|older, newer| newer.created_on <=> older.created_on } + message_list = [] + membership.each do |mp| + #课程轮询找到与我相关的回复 + message_list << mp.course.journals_for_messages.where("reply_id = ?",current_user.id) + end + message_list + end + + # 获取与我相关的留言:我的留言,回复我的留言 + def my_personal_messages params,current_user + jours = current_user.journals_for_messages.where('m_parent_id is null or reply_id = ?',current_user.id) + jours.update_all(:is_readed => true, :status => false) + jours + end + + # 所有的与我相关 + def reply_my_messages params,current_user + jours = my_personal_messages params,current_user + jours1 = my_course_messages params,current_user + my_jours = [] + my_jours << jours << jours1 + my_jours.flatten!.sort! {|older, newer| newer.created_on <=> older.created_on } + my_jours_arr = Kaminari.paginate_array(my_jours, total_count: my_jours.count).page(params[:page] || 1).per(10) + my_jours_arr + end + end diff --git a/app/views/attachments/_project_file_links.html.erb b/app/views/attachments/_project_file_links.html.erb index a18d819da..fe0e9ab97 100644 --- a/app/views/attachments/_project_file_links.html.erb +++ b/app/views/attachments/_project_file_links.html.erb @@ -28,7 +28,8 @@
<% is_float ||= false %> <% for attachment in attachments %> -

+

+

<%if is_float%>

<% end%> @@ -50,9 +51,10 @@ :id => attachment, :filename => attachment.filename%> <% end %> - - <%= h(truncate(" - #{attachment.description}", length: options[:length] ? options[:length]:15, omission: '...')) unless attachment.description.blank? %> - +
+
+ <%= h(" - #{attachment.description}") unless attachment.description.blank? %> +
( <%= number_to_human_size attachment.filesize %>) diff --git a/app/views/attachments/add_exist_file_to_courses.js.erb b/app/views/attachments/add_exist_file_to_courses.js.erb index eec1e255a..c84a89184 100644 --- a/app/views/attachments/add_exist_file_to_courses.js.erb +++ b/app/views/attachments/add_exist_file_to_courses.js.erb @@ -4,4 +4,5 @@ $("#error_show").html("<%= @message.html_safe %>"); <% else %> closeModal(); + searchone4reload('<%=params[:file_id]%>'); <% end %> diff --git a/app/views/bids/_new_homework_form.html.erb b/app/views/bids/_new_homework_form.html.erb index 7a5f628f9..5958fccff 100644 --- a/app/views/bids/_new_homework_form.html.erb +++ b/app/views/bids/_new_homework_form.html.erb @@ -15,10 +15,10 @@ <% if edit_mode %> - <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:owner_id => bid.id,:owner_type =>OwnerTypeHelper::BID %> + <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:owner_id => bid.id,:owner_type =>OwnerTypeHelper::BID,:resizeType => 0 %> <% else %> <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor' %> + <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:resizeType => 0 %> <% end %>
diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index a380ad67f..61c774a95 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -1,9 +1,12 @@ -<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> +<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> <%= render :partial => 'form_course', :locals => {:f => f, :topic => @message} %>
  • - <%= l(:button_cancel) %> - <%= l(:button_submit)%> +
    + <%= l(:button_cancel) %> + + <%= l(:button_submit)%> +
  • <% end %> diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 2a078553c..0d9d6a780 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -1,26 +1,29 @@ +
    +
    +

    + <% if User.current.language == "zh"%> + <%= h @board.name %> + <% else %> + <%= l(:project_module_boards) %> + <% end %> - - -
    -

    - <% if User.current.language == "zh"%> - <%= h @board.name %> - <% else %> - <%= l(:project_module_boards) %> +

    + <% if User.current.logged? %> + <%= l(:label_message_new) %> <% end %> - -

    - <%= l(:label_message_new) %> +
    +
    +
    + +
    -
    -
    -
      - <%= render :partial => 'course_new' %> -
    -
    <% if !User.current.logged?%>
    @@ -29,135 +32,109 @@
    <% end %> -

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

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

      <%= h(topic.subject) %>

    - <% if topic.course_editable_by?(User.current) %> - <%= l(:button_edit) %> - <% end %> - - <%= link_to( - l(:button_delete), - {:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :class => 'talk_edit fr', - :style => ' margin-right: 10px;' - ) if topic.destroyable_by?(User.current) %> - - <% if topic.sticky? %> - <%= l(:label_board_sticky)%> - <% end %> -
    - - -
    -
    - <%= topic.content.html_safe %> -
    +

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

    +<% if @topics.any? %> + <% @topics.each do |topic| %> +
    + <%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %> +
    + <% author = topic.author.to_s %> +
    + <%= link_to author, user_path(topic.author), :class =>"talkmain_name fl ",:title=>author, + :style=>'max-width:60px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;' %> +
    +

      :

    + +

      <%= h(topic.subject) %>

    + <% if topic.course_editable_by?(User.current) %> + <%= l(:button_edit) %> + <% end %> + + <%= link_to( + l(:button_delete), + {:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :class => 'talk_edit fr', + :style => ' margin-right: 10px;' + ) if topic.destroyable_by?(User.current) %> + + <% if topic.sticky? %> + <%= l(:label_board_sticky)%> + <% end %> +
    + + +
    +
    + <%= topic.content.html_safe %>
    +
    - - <%= link_to_attachments_course topic, :author => false %> +

    + <%= link_to_attachments_course topic, :author => false %> - <%= l(:label_activity_time)%>:  <%= format_time topic.created_on %> + <%= l(:label_activity_time)%>:  <%= format_time topic.created_on %> -
    - <%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => 'message_content',:class => ' c_dblue fr' %> - -
    +
    + <%= l(:button_reply) %> +
    -
    - @@ -25,14 +26,15 @@ <%= form_for topic, { :as => :message, :url => {:controller => 'messages',:action => 'edit', :is_board => 'true',:id => topic.id, :board_id => topic.board_id}, - :html => {:multipart => true, + :html => {:multipart => true, :name=>'message-form', :id => 'message-form' + topic.id.to_s, - :method => :post} + :method => :post,:nhname=>'form'} } do |f| %> <%= render :partial => 'form_course', :locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %> - <%= l(:button_submit)%> - <%= l(:button_cancel) %> +
    + <%= l(:button_cancel) %> + <%= l(:button_submit)%> <% end %> diff --git a/app/views/boards/_form_course.html.erb b/app/views/boards/_form_course.html.erb index 945f58c22..65e750b57 100644 --- a/app/views/boards/_form_course.html.erb +++ b/app/views/boards/_form_course.html.erb @@ -5,19 +5,19 @@
  • - <%= f.text_field :subject, { size: 60, id: "message_subject",:class=>"talk_input w585" }.merge(extra_option) %> + <%= f.text_field :subject, { size: 60, id: "message_subject",:class=>"talk_input w585", :nhname=>'inputsubject' }.merge(extra_option) %> -

    +

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

    +

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

    +

  • diff --git a/app/views/boards/_form_project.html.erb b/app/views/boards/_form_project.html.erb index 8288debe2..f6b41b53f 100644 --- a/app/views/boards/_form_project.html.erb +++ b/app/views/boards/_form_project.html.erb @@ -1,23 +1,35 @@ + <%= error_messages_for 'message' %> <% replying ||= false %> <% extra_option = replying ? { readonly: true} : { maxlength: 200 } %> <% if replying %> -
  • +
  • - <%= f.text_field :subject, { size: 60, id: "message_subject#{f.object.id}",:class=>"talk_input w585" }.merge(extra_option) %> + <%= f.text_field :subject, { size: 60, id: "message_subject#{f.object.id}",:class=>"talk_input w585", :nhname=>'inputsubject' }.merge(extra_option) %> -

    +

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

    +

  • <% end %>
  • @@ -34,18 +46,47 @@
  • -
    +
    <% unless replying %> <% end %> - <%= text_area :quote,:quote,:style => 'display:none' %> + <%= text_area :quote,:quote,:style => 'display:none',:nhname=>"quote_input" %> + +
    <% if replying%> - <%= f.text_area :content, :class => 'talk_text fl', :id => "message_content#{f.object.id}", :onkeyup => "regexContent('#{f.object.id}');", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)", :style=>"width: 575px;" %> + + <%= f.text_area :content, + :width => '89%', + :height => 300, + :id => "message_content#{f.object.id}", + :nhname => 'textarea', + :onkeyup => "regexContent('#{f.object.id}');", + :class => 'talk_text fl', + :placeholder => "最多3000个汉字(或6000个英文字符)", + :maxlength => 5000 %> + <% else %> - <%= f.text_area :content, :class => 'talk_text fl', :id => "message_content#{f.object.id}", :onkeyup => "regexContent('#{f.object.id}');", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)" %> + + <%= f.text_area :content, + :width => '90%', + :height => 300, + :class => 'talk_text fl', + :editor_id => "message_content#{f.object.id}_edit", + :id => "message_content#{f.object.id}", + :onkeyup => "regexContent('#{f.object.id}');", + :class => 'talk_text fl', + :nhname => 'textarea', + :placeholder => "最多3000个汉字(或6000个英文字符)", + :maxlength => 5000 %> + <% end %> +
    -

    + <% if replying%> +

    + <% else %> +

    + <%end %>
  • diff --git a/app/views/boards/_project_new_topic.html.erb b/app/views/boards/_project_new_topic.html.erb index cab1bbb7b..00a3d2016 100644 --- a/app/views/boards/_project_new_topic.html.erb +++ b/app/views/boards/_project_new_topic.html.erb @@ -1,10 +1,11 @@ -<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> +<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'},:html => {:nhname=>'form', :multipart => true, :id => 'message-form', :name=>'message-form'} do |f| %> <%= render :partial => 'form_project', :locals => {:f => f, :topic => @message} %>
  • - <%= l(:button_cancel) %> +
    + <%= l(:button_cancel) %> - <%= l(:button_submit)%> + <%= l(:button_submit)%>
  • <% end %> \ No newline at end of file diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index 63bb66a6a..aed6b80e5 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -1,219 +1,251 @@ -
    -

    - <% if User.current.language == "zh"%> - <%= h @board.name %> - <% else %> - <%= l(:project_module_boards) %> +
    +
    +

    + <% if User.current.language == "zh"%> + <%= h @board.name %> + <% else %> + <%= l(:project_module_boards) %> + <% end %> +

    + <% if User.current.logged? %> + <%= l(:label_message_new) %> <% end %> - -

    - <%= l(:label_message_new) %> -
    -
    - - -<% if !User.current.logged? %> -
    +
    +
    + <% if !User.current.logged? %> +
    <%= l(:label_user_login_project_board) %> <%= link_to l(:label_user_login_new), signin_path, :class => "c_blue ml5" %> -
    -<% end %> - - -
    +
    + <% end %> +
    +
    + +
    +
    -
    -
      - <%= render :partial => 'project_new_topic' %> -
    -
    - -

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

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

      <%= h(topic.subject) %>

    - <% if topic.editable_by?(User.current) %> - <%= l(:button_edit) %> - <% end %> - - <%= link_to( - l(:button_delete), - {:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :class => 'talk_edit fr', - :style => ' margin-right: 10px;' - ) if topic.destroyable_by?(User.current) %> - - <% if topic.sticky? %> - <%= l(:label_board_sticky)%> + <% if @topics.any? %> + <% @topics.each do |topic| %> +
    + <%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %> +
    + <% author = topic.author.to_s %> +
    + <%= link_to author, user_path(topic.author), :class =>"talkmain_name fl ",:title=>author, + :style=>'max-width:60px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;' %> +
    +

      :

    + +

      <%= h(topic.subject) %>

    +
    + <% if topic.editable_by?(User.current) %> + <%= l(:button_edit) %> + <% end %> + <%= link_to( + l(:button_delete), + {:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :class => 'talk_edit fr', + :style => ' margin-right: 10px;' + ) if topic.destroyable_by?(User.current) %> + <% if topic.sticky? %> + <%= l(:label_board_sticky)%> + <% end %> + +
    +
    +
    +
    + <%= topic.content.html_safe %> +
    +
    + + <%= link_to_attachments_course topic, :author => false %> + <%= l(:label_activity_time)%>:  <%= format_time topic.created_on %> +
    + <% if User.current.logged? %> + <%= l(:button_reply) %> + <% end %> +
    + +
    +
    + <% reply = Message.new(:subject => "RE: #{topic.subject}")%> + <% if !topic.locked? && authorize_for('messages', 'reply') %> + - - -
    - <% reply = Message.new(:subject => "RE: #{@message.subject}")%> - <% if !topic.locked? && authorize_for('messages', 'reply') %> - -
    - - <% end %> - <% replies_all = topic.children. - includes(:author, :attachments, {:board => :project}). - reorder("#{Message.table_name}.created_on DESC").offset(2). - all %> - <% replies_show = topic.children. - includes(:author, :attachments, {:board => :project}). - reorder("#{Message.table_name}.created_on DESC").limit(2). - all %> - <% unless replies_show.empty? %> - <% reply_count = 0 %> -
    -
      - <% replies_show.each do |message| %> - -
    • - <%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class =>'Msg_pic' %> -
      - <%= link_to_user_header message.author,false,:class => 'fl c_orange ' %> -
      -

      <%= textAreailizable message,:content,:attachments => message.attachments %>

      - -
      - <%= format_time(message.created_on) %> - <%= link_to( - - l(:button_delete), - {:controller => 'messages', :action => 'destroy', :id => message.id, :board_id => message.board_id, :is_board => 'true'}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete), - :class => ' c_dblue fr' - ) if message.course_destroyable_by?(User.current) %> -
      -
      - -
    • - <% end %> -
    -
    - +
    + + <% end %> + +
    + <%if topic.replies_count>2 %> + + <% end %> + <% end %>
    - - <% end %> +
    + <% end %> <% else %>

    <%= l(:label_no_data) %>

    <% end %> -
      - <%= pagination_links_full @topic_pages, @topic_count, :per_page_links => false, :remote => false, :flag => true %> -
    - +
      + <%= pagination_links_full @topic_pages, @topic_count, :per_page_links => false, :remote => false, :flag => true %> +
    + <%# other_formats_links do |f| %> - <%#= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> + <%#= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> <%# end %> + <% html_title @board.name %> + <% content_for :header_tags do %> + <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %> + <% end %> +
    +
    -<% html_title @board.name %> - -<% content_for :header_tags do %> - <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %> -<% end %> -
    \ No newline at end of file diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index c111aeaf0..863d524ec 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -1,3 +1,13 @@ + +<%= javascript_include_tag "/assets/kindeditor/kindeditor-min" %> + +<% if @project %> + <%= render :partial => 'project_show', locals: {project: @project} %> +<% elsif @course %> + <%= render :partial => 'course_show', locals: {course: @course} %> +<% end %> + -<% if @project %> - <%= render :partial => 'project_show', locals: {project: @project} %> -<% elsif @course %> - <%= render :partial => 'course_show', locals: {course: @course} %> -<% end %> + \ No newline at end of file diff --git a/app/views/contests/index.html.erb b/app/views/contests/index.html.erb index 170f11037..26e9e2114 100644 --- a/app/views/contests/index.html.erb +++ b/app/views/contests/index.html.erb @@ -46,9 +46,7 @@ <%= text_field_tag 'name', params[:name], :size => 30, :onkeyup => 'regexName1();', :width => "125px" %> <%= hidden_field_tag 'project_type', params[:project_type] %> <%#= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %> - - <%= l(:label_search)%> - + <%= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %>
    diff --git a/app/views/courses/_course.html.erb b/app/views/courses/_course.html.erb index 222d90458..420a22f8a 100644 --- a/app/views/courses/_course.html.erb +++ b/app/views/courses/_course.html.erb @@ -39,8 +39,8 @@

    <%= content_tag "span", "#{l(:label_course_brief_introduction)}:", :class => "course-font" %> - <%= content_tag "div", course.short_description, :class => "brief_introduction", :title => course.short_description %>

    + <%= content_tag "div", course.short_description, :class => "brief_introduction",:style=>'float:left;', :title => course.short_description %>
    diff --git a/app/views/courses/homework.html.erb b/app/views/courses/homework.html.erb index f7cf2a360..32728adf0 100644 --- a/app/views/courses/homework.html.erb +++ b/app/views/courses/homework.html.erb @@ -21,6 +21,9 @@

    <%= l(:lebel_homework_commit)%> ( <%= link_to bid.homeworks.count, course_for_bid_path(bid.id), :class => 'c_red'%> )

    <% if @is_teacher%> <%= bid_anonymous_comment(bid)%> + <% if bid.homeworks.empty? %> + <%= link_to(l(:button_delete),bids_homework_path(:id => bid.id), :method => :delete, :confirm => l(:label_delete_confirm), :class => "fr mr10 work_edit") %> + <% end %> <%= link_to(l(:button_edit),edit_bid_path(:course_id =>@course.id, :bid_id => bid.id), :class => "fr mr10 work_edit") %> <% elsif @is_student%> <%= student_anonymous_comment bid %> @@ -28,7 +31,7 @@ <% end %>
    @@ -59,4 +62,4 @@
      <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
    -
    \ No newline at end of file +
    diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 1769b1a45..ebccfcaf4 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -1,4 +1,15 @@ - <%= form_tag(projects_search_path, :method => :get, :id => "project_search_form") do %> - <%= text_field_tag 'name', params[:name], :size => 20, :onkeyup => "regexName();", :style => "float:left" %> - <%= hidden_field_tag 'project_type', params[:project_type] %> - <%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %> - - <%= l(:label_search)%> - -
    - - <% end %> -
    - <%= link_to request.host()+"/forums", forums_path %> diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 71975c5c3..faf73918d 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -1,247 +1,246 @@ <% @nav_dispaly_project_label = 1 -@nav_dispaly_forum_label = 1 %> + @nav_dispaly_forum_label = 1 %> <%#@nav_dispaly_project_label = 1 %> - - - <%= h html_title %> - - - <%= csrf_meta_tag %> - <%= favicon %> - <%= javascript_heads %> - <%= heads_for_theme %> - <%= stylesheet_link_tag 'public', 'pleft', 'project','jquery/jquery-ui-1.9.2' %> - <%= javascript_include_tag 'cookie','project', 'header','select_list_move' %> - <%= call_hook :view_layouts_base_html_head %> - - <%= yield :header_tags -%> + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= javascript_heads %> + <%= heads_for_theme %> + <%= stylesheet_link_tag 'public', 'pleft', 'project','jquery/jquery-ui-1.9.2' %> + <%= javascript_include_tag 'cookie','project', 'header','select_list_move' %> + <%= call_hook :view_layouts_base_html_head %> + + <%= yield :header_tags -%> - - - - - -
    - <%= render :partial => 'layouts/new_header'%> + + + +
    + + <%= render :partial => 'layouts/new_header'%> +
    + + +
    +
    +

    + + <%= l(:label_projects_community) %> + +

    + +
    + +
    - -
    -
    -

    - - <%= l(:label_projects_community) %> - -

    - -
    - -
    123
    - <%= render :partial => 'layouts/new_feedback' %> - - - <%= call_hook :view_layouts_base_body_bottom %> - +
    + +
    + <%= render_flash_messages %> + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
    +
    +
    +
    + <%= render :partial => 'layouts/new_footer'%> +
    +
    +
    + + <% text = @project.project_new_type == 1 ? "development_group" : (@project.project_new_type == 2 ? "research_group" : "friend_organization")%> +
    +
    +

    请选择项目类型:

    +
      +
    • id="development_group"/>
    • +
    • id="research_group"/>
    • +
    • id="friend_organization"/>
    • +
    + 确定 +
    + + +
    +
    123
    +<%= render :partial => 'layouts/new_feedback' %> + + +<%= call_hook :view_layouts_base_body_bottom %> + diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 1f74ccd5d..269017eb8 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -199,7 +199,7 @@ <% end %> - <% elsif @user.user_extensions.identity == 3 && @user.user_extensions.occupation.empty? %> + <% elsif @user.user_extensions.identity == 3 && @user.user_extensions.occupation %> <%= l(:field_occupation) %>: diff --git a/app/views/layouts/base_welcome.html.erb b/app/views/layouts/base_welcome.html.erb index d04f492ef..6d3b900c6 100644 --- a/app/views/layouts/base_welcome.html.erb +++ b/app/views/layouts/base_welcome.html.erb @@ -5,10 +5,9 @@ <%=h html_title %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> - <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> + <%= stylesheet_link_tag 'public', 'pleft', 'project', :media => 'all' %> + <%= javascript_include_tag "jquery.leanModal.min" %> - <%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%> <%= csrf_meta_tag %> <%= favicon %> @@ -18,32 +17,26 @@ <%= yield :header_tags -%> - -
    -
    -
    - <%=render :partial => 'layouts/base_header'%> + +
    + <%= render :partial => 'layouts/new_header' %> +
    <%= render_flash_messages %> <%= yield %> <%= call_hook :view_layouts_base_content %>
    - <%=render :partial => 'layouts/base_footer'%> + <%=render :partial => 'layouts/new_footer'%>
    - -
    -
    <%= call_hook :view_layouts_base_body_bottom %> diff --git a/app/views/layouts/project_base.html.erb b/app/views/layouts/project_base.html.erb deleted file mode 100644 index af376b1f5..000000000 --- a/app/views/layouts/project_base.html.erb +++ /dev/null @@ -1,47 +0,0 @@ -<% @nav_dispaly_project_label = 1 - @nav_dispaly_forum_label = 1 %> - - - - - <%=h html_title %> - - - <%= csrf_meta_tag %> - <%= favicon %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> - <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> - <%= javascript_heads %> - <%= javascript_include_tag "jquery.leanModal.min" %> - <%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%> - <%= heads_for_theme %> - <%= call_hook :view_layouts_base_html_head %> - - <%= yield :header_tags -%> - - -
    -
    -
    - <%=render :partial => 'layouts/base_header'%> -
    -
    - <%= render_flash_messages %> - <%= yield %> - <%= call_hook :view_layouts_base_content %> -
    - <%=render :partial => 'layouts/base_footer'%> -
    - -
    -
    - - - - - -
    -
    -<%= call_hook :view_layouts_base_body_bottom %> - - diff --git a/app/views/memos/quote.js.erb b/app/views/memos/quote.js.erb index b3d860916..3dbf9eb95 100644 --- a/app/views/memos/quote.js.erb +++ b/app/views/memos/quote.js.erb @@ -1,4 +1,5 @@ //ckeditor.setData("<%= raw escape_javascript(@content) %>"); $('#message_quote').html("<%= raw escape_javascript(@temp.content.html_safe) %>"); $('#quote').val("<%= raw escape_javascript(@content) %>"); -showAndScrollTo("new_memo", "cke_editor01"); \ No newline at end of file +showAndScrollTo("new_memo", "cke_editor01"); +$("img").removeAttr("align"); \ No newline at end of file diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index fb66c621e..5452aa893 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -182,4 +182,5 @@ } }); }; + $("img").removeAttr("align"); \ No newline at end of file diff --git a/app/views/news/_course_news.html.erb b/app/views/news/_course_news.html.erb index 947b95076..7877782f6 100644 --- a/app/views/news/_course_news.html.erb +++ b/app/views/news/_course_news.html.erb @@ -36,9 +36,9 @@ <%= link_to h(news.title), news_path(news),:class => 'problem_tit fl fb c_dblue' %>
    -

    +

    <%= news.description.html_safe %> -

    +
    diff --git a/app/views/news/_project_show.html.erb b/app/views/news/_project_show.html.erb index 9d598f0b5..f95192d64 100644 --- a/app/views/news/_project_show.html.erb +++ b/app/views/news/_project_show.html.erb @@ -82,8 +82,9 @@ :onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_news, @project) %> <%= delete_link news_path(@news),:class => 'talk_edit fr' if User.current.allowed_to?(:manage_news, @project) %>
    -
    <%= textAreailizable(@news, :description) %>
    <%= l(:label_create_time) %> : <%= format_time(@news.created_on) %>
    - <%= link_to_attachments_course @news %> +
    <%= textAreailizable(@news, :description) %>
    + <%= link_to_attachments_course @news %>
    + <%= l(:label_create_time) %> : <%= format_time(@news.created_on) %>
    diff --git a/app/views/projects/_development_group.html.erb b/app/views/projects/_development_group.html.erb new file mode 100644 index 000000000..d4bc7012a --- /dev/null +++ b/app/views/projects/_development_group.html.erb @@ -0,0 +1,52 @@ + +<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %> + +<% end %> +<% unless @project.enabled_modules.where("name = 'boards'").empty? %> + +<% end%> +<% unless @project.enabled_modules.where("name = 'files'").empty? %> + +<% end %> +<%# --版本库被设置成私有、module中设置不显示、没有创建版本库 三种情况不显示-- %> +<% if visible_repository?(@project) %> + +<% end %> + + + diff --git a/app/views/projects/_friend_group.html.erb b/app/views/projects/_friend_group.html.erb new file mode 100644 index 000000000..03df67b0e --- /dev/null +++ b/app/views/projects/_friend_group.html.erb @@ -0,0 +1,28 @@ + +<% unless @project.enabled_modules.where("name = 'boards'").empty? %> + +<% end%> +<% unless @project.enabled_modules.where("name = 'files'").empty? %> + +<% end %> \ No newline at end of file diff --git a/app/views/projects/_research_team.html.erb b/app/views/projects/_research_team.html.erb new file mode 100644 index 000000000..6dc27a2fb --- /dev/null +++ b/app/views/projects/_research_team.html.erb @@ -0,0 +1,39 @@ + +<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %> + +<% end %> +<% unless @project.enabled_modules.where("name = 'boards'").empty? %> + +<% end%> +<% unless @project.enabled_modules.where("name = 'files'").empty? %> + +<% end%> diff --git a/app/views/projects/invite_members.html.erb b/app/views/projects/invite_members.html.erb index d30ecd8e4..a6a13e2b7 100644 --- a/app/views/projects/invite_members.html.erb +++ b/app/views/projects/invite_members.html.erb @@ -1,4 +1,3 @@ -

    <%= l(:label_invite_join) %>

    @@ -68,5 +67,37 @@ var text=$(label).text(); $(label).attr("title",text); } + + function nh_show_err_message(msg){ + $("#RSide>.flash").remove(); + $("#RSide").prepend('
    '+msg+'
    '); + } + $('#new_membership').submit(function(){ + var user_ischeck=false; + $("input[name='membership[user_ids][]']").each(function(){ + if($(this).prop('checked')){ + user_ischeck=true; + } + }); + var role_ischeck=false; + $("input[name='membership[role_ids][]']").each(function(){ + if($(this).prop('checked')){ + role_ischeck=true; + } + }); + if(user_ischeck==false && role_ischeck==false){ + nh_show_err_message('请选择用户和角色!'); + return false; + } + if(user_ischeck==false){ + nh_show_err_message('请选择用户!'); + return false; + } + if(role_ischeck==false){ + nh_show_err_message('请选择角色!'); + return false; + } + return true; + }); }); \ No newline at end of file diff --git a/app/views/projects/settings.html.erb b/app/views/projects/settings.html.erb index 25ec1c4d5..e70e20cef 100644 --- a/app/views/projects/settings.html.erb +++ b/app/views/projects/settings.html.erb @@ -1,6 +1,6 @@
    @@ -21,7 +21,7 @@
    -
    + <% else %> + <% if cur_school_course.count < 9 %> <%= render :partial => 'more_course', :locals => {:school_id => nil}%> @@ -160,6 +164,7 @@ <%= render :partial => 'no_course_title', :locals => {:course_title => l(:label_school_less_course)} %> <% all_new_hot_course = find_all_new_hot_course(9-cur_school_course.count, @school_id, year_now, course_term)%> + <% while (all_new_hot_course.count + cur_school_course.count) < 9%> <% if course_term == "春季学期" year_now -= 1 @@ -170,10 +175,13 @@ <%break if Time.new.strftime("%Y").to_i - year_now >= 2%> <% all_new_hot_course += find_all_new_hot_course(9-(all_new_hot_course.count + cur_school_course.count), @school_id, year_now, course_term)%> <% end%> - <%= render :partial => 'course_list', :locals => {:course_list => all_new_hot_course} %> + <% cache all_new_hot_course.max().created_at do %> + <%= render :partial => 'course_list', :locals => {:course_list => all_new_hot_course} %> + <% end %> <% end %>
    + <% end %>
    @@ -186,10 +194,11 @@ <%= link_to "更多>>", forums_path %> - + <% topics = find_new_forum_topics(10) %>
      - <% find_new_forum_topics(10).each do |topic| %> + + <% topics.each do |topic| %>
    • <% end %> +
    -<%= render partial: 'link_to_another' %> \ No newline at end of file +<%= render partial: 'link_to_another' %> diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index dc8ef7f35..3acee0acf 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -23,7 +23,7 @@ $(document).ready(function($) { $("#loggedas").find("a").attr("target", "_blank"); //$("#content .tabs_new~ .pagination").find("a").removeAttr("target"); - }); + });
    @@ -45,7 +45,7 @@ <% if @organization.nil? %> <% unless @first_page.nil? %> <%= l(:label_welcome_trustie_project)%><%= l(:label_welcome_trustie_project_description)%> @@ -68,7 +68,7 @@
    - +<% cache :expire_in => 2.hours do%>

    <%= l(:lable_hot_projects)%>

    <% if User.current.logged? %> @@ -113,7 +113,7 @@
    - +<% end %>
      @@ -151,10 +151,10 @@
      - <%end %> + <% end %>
    -<%= render partial: 'link_to_another' %> \ No newline at end of file +<%= render partial: 'link_to_another' %> diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb index 43da9a7d8..dabd3a8c7 100644 --- a/app/views/words/destroy.js.erb +++ b/app/views/words/destroy.js.erb @@ -5,6 +5,8 @@ $('#jours_count').html("<%= @jours_count %>"); <% elsif @course && @jours_count%> $('#course_jour_count').html("(<%= @jours_count %>)"); + <% elsif @user && @jours_count%> + $('#jour_count').html("<%= @jours_count %>"); <% end %> var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>') destroyedItem.fadeOut(600,function(){ diff --git a/config/additional_environment.rb b/config/additional_environment.rb new file mode 100644 index 000000000..5c73f6aab --- /dev/null +++ b/config/additional_environment.rb @@ -0,0 +1,3 @@ +if Rails.env.production? + config.cache_store = :redis_store, 'redis://localhost:6379/0/cache', { expires_in: 90.minutes } +end \ No newline at end of file diff --git a/config/additional_environment.rb.example b/config/additional_environment.rb.example deleted file mode 100644 index 2a317a396..000000000 --- a/config/additional_environment.rb.example +++ /dev/null @@ -1,10 +0,0 @@ -# Copy this file to additional_environment.rb and add any statements -# that need to be passed to the Rails::Initializer. `config` is -# available in this context. -# -# Example: -# -# config.log_level = :debug -# ... -# - diff --git a/config/application.rb b/config/application.rb index 4a0e56115..9e7a2ba81 100644 --- a/config/application.rb +++ b/config/application.rb @@ -31,7 +31,7 @@ module RedmineApp end # Custom directories with classes and modules you want to be autoloadable. config.autoload_paths += %W(#{config.root}/lib) - + config.autoload_paths += %w(#{RAILS_ROOT}/app/sweepers) # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named. # config.plugins = [ :exception_notification, :ssl_requirement, :all ] diff --git a/config/configuration.yml b/config/configuration.yml index 87a54a976..390754a87 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -103,7 +103,7 @@ default: # autologin_cookie_name: the name of the cookie (default: autologin) # autologin_cookie_path: the cookie path (default: /) # autologin_cookie_secure: true sets the cookie secure flag (default: false) - autologin_cookie_name: + autologin_cookie_name: "autologin_trustie" autologin_cookie_path: autologin_cookie_secure: @@ -200,7 +200,7 @@ default: # specific configuration options for production environment # that overrides the default ones production: - # CJK support + cookie_domain: ".trustie.net" rmagick_font_path: /usr/share/fonts/ipa-mincho/ipam.ttf email_delivery: delivery_method: :smtp diff --git a/config/environments/development.rb b/config/environments/development.rb index 5c2427320..2aca152cb 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -10,8 +10,9 @@ RedmineApp::Application.configure do config.logger = Logger.new('log/development.log', 'daily') # daily, weekly or monthly # Show full error reports and disable caching config.consider_all_requests_local = true - config.action_controller.perform_caching = false + config.action_controller.perform_caching = true config.cache_store = :file_store, "#{Rails.root }/files/cache_store/" + #config.cache_store = :dalli_store # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = true diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb new file mode 100644 index 000000000..4aa95a27b --- /dev/null +++ b/config/initializers/redis.rb @@ -0,0 +1 @@ +$redis = Redis.new(:host => "127.0.0.1", :port => 6379) \ No newline at end of file diff --git a/config/locales/commons/en.yml b/config/locales/commons/en.yml index 5eb92f07e..c0e29b797 100644 --- a/config/locales/commons/en.yml +++ b/config/locales/commons/en.yml @@ -113,6 +113,7 @@ en: one: "1 error prohibited this %{model} from being saved" other: "%{count} errors prohibited this %{model} from being saved" messages: + record_invalid: "validate error: %{errors}" inclusion: "is not included in the list" exclusion: "is reserved" invalid: "is invalid" @@ -428,4 +429,4 @@ en: previous: "« Previous" next: "Next »" truncate: "..." - \ No newline at end of file + diff --git a/config/locales/commons/zh.yml b/config/locales/commons/zh.yml index 231c5280a..a023bc8cb 100644 --- a/config/locales/commons/zh.yml +++ b/config/locales/commons/zh.yml @@ -121,6 +121,7 @@ zh: one: "由于发生了一个错误 %{model} 无法保存" other: "%{count} 个错误使得 %{model} 无法保存" messages: + record_invalid: "校验失败: %{errors}" inclusion: "不包含于列表中" exclusion: "是保留关键字" invalid: "是无效的" @@ -352,7 +353,7 @@ zh: # label_feedback: 意见反馈 label_feedback_tips: "欢迎反馈网站问题,课程中遇到的问题请反馈给相关老师!" - label_technical_support: "技术支持:" + label_technical_support: "QQ 在线支持:" label_feedback_success: "您的意见已经反馈到公共贴吧的新手讨论吧,我们会第一时间解决您的问题,谢谢支持!" label_feedback_value: "该帖来自用户反馈:)" @@ -435,4 +436,4 @@ zh: last: "末页 »" previous: "« 上一页" next: "下一页 »" - truncate: "..." \ No newline at end of file + truncate: "..." diff --git a/config/locales/en.yml b/config/locales/en.yml index 8989ae36a..8419ae188 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -183,6 +183,10 @@ en: setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_plain_text_mail: Plain text mail (no HTML) setting_host_name: Host name and path + setting_host_course: Host course and path + setting_host_contest: Host contest and path + setting_host_user: Host user and path + setting_host_repository: Host repository and path setting_text_formatting: Text formatting setting_wiki_compression: Wiki history compression setting_feeds_limit: Maximum number of items in Atom feeds @@ -755,6 +759,7 @@ en: button_create_and_continue: Create and continue button_test: Test button_edit: Edit + button_delete: Delete button_edit_associated_wikipage: "Edit associated Wiki page: %{page_title}" button_add: Add button_change: Change @@ -1521,4 +1526,5 @@ en: label_commit_failed: commit failed #api end error_upload_avatar_to_large: "too big (%{max_size})" + not_valid_image_file: not a valid image file diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 180b0322a..8ca078084 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -342,6 +342,7 @@ zh: label_invite_trustie_user_tips: "输入姓名、邮箱、昵称" label_user_role_null: 用户和角色不能留空! label_invite_project: 邀请您加入项目 + label_mail_invite_success: 您已成功加入项目! label_invite_success: 邀请成功 label_invite_members: 邀请用户 # diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 8adf7d492..7d926bd34 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -193,6 +193,10 @@ zh: setting_bcc_recipients: 使用密件抄送 (bcc) setting_plain_text_mail: 纯文本(无HTML) setting_host_name: 主机名称 + setting_host_course: 课程域名 + setting_host_contest: 竞赛域名 + setting_host_user: 用户域名 + setting_host_repository: 仓库域名 setting_text_formatting: 文本格式 setting_wiki_compression: 压缩Wiki历史文档 setting_feeds_limit: RSS Feed内容条数限制 @@ -396,6 +400,7 @@ zh: label_document_added: 文档已添加 label_forum_message_added: 贴吧发帖成功 label_forum_add: 贴吧创建成功 + label_forum_reply: 贴吧回复成功 label_message_reply: 回帖人 label_document_public_info: (打钩为公开,不打钩则不公开,若不公开,仅项目成员可见该文档。) label_role: 角色 @@ -847,6 +852,7 @@ zh: button_create_and_continue: 创建并继续 button_test: 测试 button_edit: 编辑 + button_delete: 删除 button_edit_associated_wikipage: "编辑相关wiki页面: %{page_title}" button_add: 新增 button_change: 修改 @@ -1989,3 +1995,4 @@ zh: label_code: 代码 error_upload_avatar_to_large: "超过大小限制 (%{max_size})" + not_valid_image_file: 不是有效的图片文件 diff --git a/config/oneapm.yml b/config/oneapm.yml new file mode 100644 index 000000000..e5b2e7bed --- /dev/null +++ b/config/oneapm.yml @@ -0,0 +1,135 @@ +# +# OneApm RubyAgent Configuration +# + +# Here are the settings that are common to all environments +common: &default_settings + # ============================== LICENSE KEY =============================== + + # + # Get your license key from oneapm.com + # + license_key: 'BAQMBw8FUwR2542UFFpDXFgVVk66e2dZWB4EBlQHSf846wgBGwICFQoD0498BAEfBgNIAlQ=' + + # Agent Enabled (Ruby/Rails Only) + # Valid values are true, false and auto. + # + # agent_enabled: auto + + # This app_name will be the application name in oneapm.com in your account. + # + # Caution: If you change this name, a new application will appear in the OneApm + # user interface with the new name, and data will stop reporting to the + # app with the old name. + # + app_name: trusite + + # When "true", the agent collects performance data about your + # application and reports this data to the OneApm service at + # oneapm.com. This global switch is normally overridden for each + # environment below. (formerly called 'enabled') + monitor_mode: true + + # Specify its log level here. + log_level: info + + # log_file_path: 'log' + # log_file_name: 'oneapm_agent.log' + + # The oneapm agent communicates with the service via https by default. + # ssl: true + + # ======================== Browser Monitoring ============================= + browser_monitoring: + # By default the agent automatically injects the monitoring JavaScript + # into web pages. Set this attribute to false to turn off this behavior. + auto_instrument: true + + # Proxy settings for connecting to the OneApm server. + # + # proxy_host: hostname + # proxy_port: 8080 + # proxy_user: + # proxy_pass: + + # Tells transaction tracer and error collector (when enabled) + # whether or not to capture HTTP params. When true, frameworks can + # exclude HTTP parameters from being captured. + # Rails: the RoR filter_parameter_logging excludes parameters + capture_params: false + + # Transaction tracer captures deep information about slow + # transactions and sends this to the OneApm service once a + # minute. Included in the transaction is the exact call sequence of + # the transactions including any SQL statements issued. + transaction_tracer: + + # Transaction tracer is enabled by default. + enabled: true + + # Threshold in seconds for when to collect a transaction + # trace. When the response time of a controller action exceeds + # this threshold, a transaction trace will be recorded and sent to + # OneApm. Valid values are any float value, or (default) "apdex_f", + # which will use the threshold for an dissatisfying Apdex + # controller action - four times the Apdex T value. + transaction_threshold: apdex_f + + # When transaction tracer is on, SQL statements can optionally be + # recorded. The recorder has three modes, "off" which sends no + # SQL, "raw" which sends the SQL statement in its original form, + # and "obfuscated", which strips out numeric and string literals. + record_sql: obfuscated + + # Threshold in seconds for when to collect stack trace for a SQL + # call. In other words, when SQL statements exceed this threshold, + # then capture and send to OneApm the current stack trace. This is + # helpful for pinpointing where long SQL calls originate from. + stack_trace_threshold: 0.500 + + # Determines whether the agent will capture query plans for slow + # SQL queries. Only supported in mysql and postgres. Should be + # set to false when using other adapters. + # explain_enabled: true + + # Threshold for query execution time below which query plans will + # not be captured. Relevant only when `explain_enabled` is true. + # explain_threshold: 0.5 + + # Error collector captures information about uncaught exceptions and + # sends them to OneApm for viewing + error_collector: + + # Error collector is enabled by default. + enabled: true + + # Ignore the following errors, add your own. + ignore_errors: "ActionController::RoutingError,Sinatra::NotFound" + +# ===================== Application Environments ======================== +# Environment-specific settings are in this section. +# For Rails applications, RAILS_ENV is used to determine the environment. + +# NOTE if your application has other named environments, you should +# provide oneapm configuration settings for these environments here. + +development: + <<: *default_settings + # Turn on communication to OneApm service in development mode + monitor_mode: true + app_name: My Application (Development) + +test: + <<: *default_settings + monitor_mode: false + +# Turn on the agent in production for 24x7 monitoring. +production: + <<: *default_settings + monitor_mode: true + +# Staging environment which behaves identically to production. +staging: + <<: *default_settings + monitor_mode: true + app_name: My Application (Staging) diff --git a/config/routes.rb b/config/routes.rb index 1d57a091b..8aab06ccc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -132,6 +132,7 @@ RedmineApp::Application.routes.draw do match 'courselist' match 'zip' match 'mailer' + match 'view_office' end ##new added by linchun #以发布应用的形式参与竞赛 resources :softapplications do @@ -273,7 +274,7 @@ RedmineApp::Application.routes.draw do post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit' post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy' # boards end - # post 'bids/homework_destroy', :to => 'bids#homework_destroy' + delete 'bids/homework', :to => 'bids#homework_destroy' # Misc issue routes. TODO: move into resources match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues' @@ -729,6 +730,7 @@ RedmineApp::Application.routes.draw do collection do match "getattachtype", :via => [:get, :post] match "search",:via => [:post,:get] + match "searchone4reload",:via => [:post,:get] match "search_tag_attachment", :via => [:post,:get] end member do diff --git a/db/migrate/20150528024616_create_invite_lists.rb b/db/migrate/20150528024616_create_invite_lists.rb new file mode 100644 index 000000000..222a3a3f8 --- /dev/null +++ b/db/migrate/20150528024616_create_invite_lists.rb @@ -0,0 +1,10 @@ +class CreateInviteLists < ActiveRecord::Migration + def change + create_table :invite_lists do |t| + t.integer :project_id + t.integer :user_id + + t.timestamps + end + end +end diff --git a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb index c3252ed1c..1f4c867ba 100644 --- a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb +++ b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb @@ -4,6 +4,7 @@ module RailsKindeditor def kindeditor_tag(name, content = nil, options = {}) id = sanitize_to_id(name) input_html = { :id => id }.merge(options.delete(:input_html) || {}) + input_html = input_html.merge(style: 'display:none') output = ActiveSupport::SafeBuffer.new output << text_area_tag(name, content, input_html) output << javascript_tag(js_replace(id, options.merge(window_onload: 'true'))) @@ -12,6 +13,7 @@ module RailsKindeditor def kindeditor(name, method, options = {}) # TODO: Refactory options: 1. kindeditor_option 2. html_option input_html = (options.delete(:input_html) || {}).stringify_keys + input_html = input_html.merge(style: 'display:none') output_buffer = ActiveSupport::SafeBuffer.new output_buffer << build_text_area_tag(name, method, self, options, input_html) output_buffer << javascript_tag(js_replace(input_html['id'],options.merge(window_onload: 'true'))) diff --git a/lib/redmine/notifiable.rb b/lib/redmine/notifiable.rb index 42a81980f..57cc86225 100644 --- a/lib/redmine/notifiable.rb +++ b/lib/redmine/notifiable.rb @@ -20,8 +20,8 @@ module Redmine notifications << Notifiable.new('message_posted') notifications << Notifiable.new('wiki_content_added') notifications << Notifiable.new('wiki_content_updated') - notifications << Notifiable.new('forum_add') - notifications << Notifiable.new('forum_message_added', 'forum_add') + notifications << Notifiable.new('forum_reply') + notifications << Notifiable.new('forum_message_added', 'forum_reply') notifications end end diff --git a/lib/trustie/utils/image.rb b/lib/trustie/utils/image.rb index 9178b291a..7e23e7b66 100644 --- a/lib/trustie/utils/image.rb +++ b/lib/trustie/utils/image.rb @@ -3,11 +3,36 @@ module Trustie module Utils class Image - def initialize(file, bak) + def initialize(file, bak=false) @file = file @bak = bak end + def bitmap?(data) + data[0,2]==77.chr + 66.chr + end + + def gif?(data) + data[0,4]==71.chr + 73.chr + 70.chr + 56.chr + end + + def jpeg?(data) + data[0,3]== 0xff.chr + 0xd8.chr + 0xff.chr + end + def png?(data) + data[0,2]==0x89.chr + 80.chr + end + + def image? + data = '' + if @file.respond_to?(:read) + data = @file.read(9) + @file.rewind + end + return false if data.size < 9 + bitmap?(data) || gif?(data) || jpeg?(data) || png?(data) + end + def compress(size=300) backup if @bak begin diff --git a/public/assets/kindeditor/kindeditor-min.js b/public/assets/kindeditor/kindeditor-min.js new file mode 100644 index 000000000..7b35f52fb --- /dev/null +++ b/public/assets/kindeditor/kindeditor-min.js @@ -0,0 +1,182 @@ +/* KindEditor 4.1.10 (2013-11-23), Copyright (C) kindsoft.net, Licence: http://www.kindsoft.net/license.php */(function(w,i){function Z(a){if(!a)return!1;return Object.prototype.toString.call(a)==="[object Array]"}function wa(a){if(!a)return!1;return Object.prototype.toString.call(a)==="[object Function]"}function J(a,b){for(var c=0,d=b.length;c=0}function s(a,b){b=b||"px";return a&&/^\d+$/.test(a)?a+b:a}function t(a){var b;return a&&(b=/(\d+)/.exec(a))?parseInt(b[1],10):0}function C(a){return a.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}function fa(a){return a.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&")}function ga(a){var b=a.split("-"),a="";m(b,function(b,d){a+=b>0?d.charAt(0).toUpperCase()+ +d.substr(1):d});return a}function ya(a){function b(a){a=parseInt(a,10).toString(16).toUpperCase();return a.length>1?a:"0"+a}return a.replace(/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/ig,function(a,d,e,g){return"#"+b(d)+b(e)+b(g)})}function u(a,b){var b=b===i?",":b,c={},d=Z(a)?a:a.split(b),e;m(d,function(a,b){if(e=/^(\d+)\.\.(\d+)$/.exec(b))for(var d=parseInt(e[1],10);d<=parseInt(e[2],10);d++)c[d.toString()]=!0;else c[b]=!0});return c}function Ja(a,b){return Array.prototype.slice.call(a,b||0)} +function l(a,b){return a===i?b:a}function E(a,b,c){c||(c=b,b=null);var d;if(b){var e=function(){};e.prototype=b.prototype;d=new e;m(c,function(a,b){d[a]=b})}else d=c;d.constructor=a;a.prototype=d;a.parent=b?b.prototype:null}function eb(a){var b;if(b=/\{[\s\S]*\}|\[[\s\S]*\]/.exec(a))a=b[0];b=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;b.lastIndex=0;b.test(a)&&(a=a.replace(b,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})); +if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return eval("("+a+")");throw"JSON parse error";}function Rb(a,b,c){a.addEventListener?a.addEventListener(b,c,fb):a.attachEvent&&a.attachEvent("on"+b,c)}function za(a,b,c){a.removeEventListener?a.removeEventListener(b,c,fb):a.detachEvent&&a.detachEvent("on"+b,c)}function gb(a,b){this.init(a,b)}function hb(a){try{delete a[$]}catch(b){a.removeAttribute&& +a.removeAttribute($)}}function aa(a,b,c){if(b.indexOf(",")>=0)m(b.split(","),function(){aa(a,this,c)});else{var d=a[$]||null;d||(a[$]=++ib,d=ib);v[d]===i&&(v[d]={});var e=v[d][b];e&&e.length>0?za(a,b,e[0]):(v[d][b]=[],v[d].el=a);e=v[d][b];e.length===0&&(e[0]=function(b){var c=b?new gb(a,b):i;m(e,function(b,d){b>0&&d&&d.call(a,c)})});J(c,e)<0&&e.push(c);Rb(a,b,e[0])}}function ha(a,b,c){if(b&&b.indexOf(",")>=0)m(b.split(","),function(){ha(a,this,c)});else{var d=a[$]||null;if(d)if(b===i)d in v&&(m(v[d], +function(b,c){b!="el"&&c.length>0&&za(a,b,c[0])}),delete v[d],hb(a));else if(v[d]){var e=v[d][b];if(e&&e.length>0){c===i?(za(a,b,e[0]),delete v[d][b]):(m(e,function(a,b){a>0&&b===c&&e.splice(a,1)}),e.length==1&&(za(a,b,e[0]),delete v[d][b]));var g=0;m(v[d],function(){g++});g<2&&(delete v[d],hb(a))}}}}function jb(a,b){if(b.indexOf(",")>=0)m(b.split(","),function(){jb(a,this)});else{var c=a[$]||null;if(c){var d=v[c][b];if(v[c]&&d&&d.length>0)d[0]()}}}function Ka(a,b,c){b=/^\d{2,}$/.test(b)?b:b.toUpperCase().charCodeAt(0); +aa(a,"keydown",function(d){d.ctrlKey&&d.which==b&&!d.shiftKey&&!d.altKey&&(c.call(a),d.stop())})}function ba(a){for(var b={},c=/\s*([\w\-]+)\s*:([^;]*)(;|$)/g,d;d=c.exec(a);){var e=B(d[1].toLowerCase());d=B(ya(d[2]));b[e]=d}return b}function I(a){for(var b={},c=/\s+(?:([\w\-:]+)|(?:([\w\-:]+)=([^\s"'<>]+))|(?:([\w\-:"]+)="([^"]*)")|(?:([\w\-:"]+)='([^']*)'))(?=(?:\s|\/|>)+)/g,d;d=c.exec(a);){var e=(d[1]||d[2]||d[4]||d[6]).toLowerCase();b[e]=(d[2]?d[3]:d[4]?d[5]:d[7])||""}return b}function Sb(a,b){return a= +/\s+class\s*=/.test(a)?a.replace(/(\s+class=["']?)([^"']*)(["']?[\s>])/,function(a,d,e,g){return(" "+e+" ").indexOf(" "+b+" ")<0?e===""?d+b+g:d+e+" "+b+g:a}):a.substr(0,a.length-1)+' class="'+b+'">'}function Tb(a){var b="";m(ba(a),function(a,d){b+=a+":"+d+";"});return b}function ia(a,b,c,d){function e(a){for(var a=a.split("/"),b=[],c=0,d=a.length;c0&&b.pop():e!==""&&e!="."&&b.push(e)}return"/"+b.join("/")}function g(b,c){if(a.substr(0,b.length)===b){for(var e=[], +h=0;h0&&(h+="/"+e.join("/"));d=="/"&&(h+="/");return h+a.substr(b.length)}else if(f=/^(.*)\//.exec(b))return g(f[1],++c)}b=l(b,"").toLowerCase();a.substr(0,5)!="data:"&&(a=a.replace(/([^:])\/\//g,"$1/"));if(J(b,["absolute","relative","domain"])<0)return a;c=c||location.protocol+"//"+location.host;if(d===i)var h=location.pathname.match(/^(\/.*)\//),d=h?h[1]:"";var f;if(f=/^(\w+:\/\/[^\/]*)/.exec(a)){if(f[1]!==c)return a}else if(/^\w+:/.test(a))return a;/^\//.test(a)? +a=c+e(a.substr(1)):/^\w+:\/\//.test(a)||(a=c+e(d+"/"+a));b==="relative"?a=g(c+d,0).substr(2):b==="absolute"&&a.substr(0,c.length)===c&&(a=a.substr(c.length));return a}function U(a,b,c,d,e){a==null&&(a="");var c=c||"",d=l(d,!1),e=l(e,"\t"),g="xx-small,x-small,small,medium,large,x-large,xx-large".split(","),a=a.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/ig,function(a,b,c,d){return b+c.replace(/<(?:br|br\s[^>]*)>/ig,"\n")+d}),a=a.replace(/<(?:br|br\s[^>]*)\s*\/?>\s*<\/p>/ig,"

    "),a=a.replace(/(<(?:p|p\s[^>]*)>)\s*(<\/p>)/ig, +"$1
    $2"),a=a.replace(/\u200B/g,""),a=a.replace(/\u00A9/g,"©"),a=a.replace(/\u00AE/g,"®"),a=a.replace(/<[^>]+/g,function(a){return a.replace(/\s+/g," ")}),h={};b&&(m(b,function(a,b){for(var c=a.split(","),d=0,e=c.length;d]*)>)([\s\S]*?)(<\/script>)/ig,"")),h.style||(a=a.replace(/(<(?:style|style\s[^>]*)>)([\s\S]*?)(<\/style>)/ig,"")));var f=[],a=a.replace(/(\s*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"'<>]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+='[^']*'))*)(\/)?>(\s*)/g, +function(a,n,q,r,K,ja,i){var n=n||"",q=q||"",l=r.toLowerCase(),o=K||"",r=ja?" "+ja:"",i=i||"";if(b&&!h[l])return"";r===""&&kb[l]&&(r=" /");lb[l]&&(n&&(n=" "),i&&(i=" "));La[l]&&(q?i="\n":n="\n");d&&l=="br"&&(i="\n");if(mb[l]&&!La[l])if(d){q&&f.length>0&&f[f.length-1]===l?f.pop():f.push(l);i=n="\n";K=0;for(ja=q?f.length:f.length-1;K=0&&(z[a]=ia(d,c));(b&&a!=="style"&&!h[l]["*"]&&!h[l][a]||l==="body"&&a==="contenteditable"||/^kindeditor_\d+$/.test(a))&&delete z[a];if(a==="style"&&d!==""){var e=ba(d);m(e,function(a){b&&!h[l].style&&!h[l]["."+a]&&delete e[a]}); +var g="";m(e,function(a,b){g+=a+":"+b+";"});z.style=g}});o="";m(z,function(a,b){a==="style"&&b===""||(b=b.replace(/"/g,"""),o+=" "+a+'="'+b+'"')})}l==="font"&&(l="span");return n+"<"+q+l+o+r+">"+i}),a=a.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/ig,function(a,b,c,d){return b+c.replace(/\n/g,'\n')+d}),a=a.replace(/\n\s*\n/g,"\n"),a=a.replace(/\n/g,"\n");return B(a)}function nb(a,b){a=a.replace(//ig, +"").replace(//ig,"").replace(/]*>[\s\S]*?<\/style>/ig,"").replace(/]*>[\s\S]*?<\/script>/ig,"").replace(/]+>[\s\S]*?<\/w:[^>]+>/ig,"").replace(/]+>[\s\S]*?<\/o:[^>]+>/ig,"").replace(/[\s\S]*?<\/xml>/ig,"").replace(/<(?:table|td)[^>]*>/ig,function(a){return a.replace(/border-bottom:([#\w\s]+)/ig,"border:$1")});return U(a,b)}function ob(a){if(/\.(rm|rmvb)(\?|$)/i.test(a))return"audio/x-pn-realaudio-plugin";if(/\.(swf|flv)(\?|$)/i.test(a))return"application/x-shockwave-flash"; +return"video/x-ms-asf-plugin"}function pb(a){return I(unescape(a))}function Ma(a){var b="0&&(h+="width:"+c+"px;");/\D/.test(d)?h+="height:"+d+";":d>0&&(h+="height:"+d+"px;");c=/realaudio/i.test(e)?"ke-rm":/flash/i.test(e)?"ke-flash":"ke-media";c='';return c}function Aa(a,b){if(a.nodeType==9&&b.nodeType!=9)return!0;for(;b=b.parentNode;)if(b==a)return!0;return!1}function Ba(a,b){var b=b.toLowerCase(),c=null;if(!Vb&&a.nodeName.toLowerCase()!="script"){var d=a.ownerDocument.createElement("div");d.appendChild(a.cloneNode(!1));d=I(fa(d.innerHTML));b in d&&(c=d[b])}else try{c=a.getAttribute(b,2)}catch(e){c=a.getAttribute(b,1)}b==="style"&&c!==null&&(c=Tb(c));return c}function Ca(a,b){function c(a){if(typeof a!="string")return a;return a.replace(/([^\w\-])/g, +"\\$1")}function d(a,b){return a==="*"||a.toLowerCase()===c(b.toLowerCase())}function e(a,b,c){var e=[];(a=(c.ownerDocument||c).getElementById(a.replace(/\\/g,"")))&&d(b,a.nodeName)&&Aa(c,a)&&e.push(a);return e}function g(a,b,c){var e=c.ownerDocument||c,g=[],h,f,j;if(c.getElementsByClassName){e=c.getElementsByClassName(a.replace(/\\/g,""));h=0;for(f=e.length;h-1&&g.push(j)}return g}function h(a,b,d,e){for(var g=[],d=e.getElementsByTagName(d),h=0,f=d.length;h])+)/.exec(a))?j[1]:"*";if(j=/#((?:[\w\-]|\\.)+)$/.exec(a))c= +e(j[1],k,b);else if(j=/\.((?:[\w\-]|\\.)+)$/.exec(a))c=g(j[1],k,b);else if(j=/\[((?:[\w\-]|\\.)+)\]/.exec(a))c=h(j[1].toLowerCase(),null,k,b);else if(j=/\[((?:[\w\-]|\\.)+)\s*=\s*['"]?((?:\\.|[^'"]+)+)['"]?\]/.exec(a)){c=j[1].toLowerCase();j=j[2];if(c==="id")k=e(j,k,b);else if(c==="class")k=g(j,k,b);else if(c==="name"){c=[];j=(b.ownerDocument||b).getElementsByName(j.replace(/\\/g,""));for(var n,r=0,q=j.length;r1){var n=[];m(k,function(){m(Ca(this,b),function(){J(this,n)<0&&n.push(this)})});return n}for(var b=b||document,k=[],q,r=/((?:\\.|[^\s>])+|[\s>])/g;q=r.exec(a);)q[1]!==" "&&k.push(q[1]);q=[];if(k.length==1)return f(k[0],b);var r=!1,K,l,i,o,p,z,L,F,s,t;z=0;for(lenth=k.length;z")r=!0;else{if(z>0){l=[];L=0;for(s=q.length;L