diff --git a/Gemfile b/Gemfile index 634af9683..6c2101345 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,5 @@ -source 'https://rubygems.org' +source 'http://rubygems.org' +#source 'http://ruby.sdutlinux.org/' unless RUBY_PLATFORM =~ /w32/ # unix-like only @@ -15,23 +16,42 @@ gem "coderay", "~> 1.0.6" 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' group :development do gem 'better_errors', path: 'lib/better_errors' gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler' - if ENV['PRY'] - gem 'pry' - gem 'pry-nav' - end end group :test do - # shoulda的版本做了改动 - #gem "shoulda", "~> 3.3.2" - gem "shoulda", "> 3.3.2" - gem "mocha", "~> 0.13.3" - gem 'capybara', '~> 2.0.0' - gem 'nokogiri', '< 1.6.0' + gem "shoulda", "~> 3.5.0" + gem "mocha", "~> 1.1.0" + gem 'capybara', '~> 2.4.1' + gem 'nokogiri', '~> 1.6.3' + gem 'factory_girl', '~> 4.4.0' + gem 'selenium-webdriver', '~> 2.42.0' + + + # platforms :mri, :mingw do + # group :rmagick do + # # RMagick 2 supports ruby 1.9 + # # RMagick 1 would be fine for ruby 1.8 but Bundler does not support + # # different requirements for the same gem on different platforms + # gem "rmagick", ">= 2.0.0" + # end + #end +end + +group :development, :test do + # gem "guard-rails", '~> 0.5.3' + gem 'spork-testunit', '~> 0.0.8' + # gem 'guard-spork', '~> 1.5.1' + # gem 'guard-test', '~> 1.0.0' + gem 'ruby-prof', '~> 0.15.1' unless RUBY_PLATFORM =~ /w32/ + gem 'pry' + gem 'pry-nav' + end @@ -53,15 +73,6 @@ group :ldap do end -platforms :mri, :mingw do - group :rmagick do - # RMagick 2 supports ruby 1.9 - # RMagick 1 would be fine for ruby 1.8 but Bundler does not support - # different requirements for the same gem on different platforms - gem "rmagick", ">= 2.0.0" - end -end - # Optional gem for OpenID authentication group :openid do gem "ruby-openid", "~> 2.1.4", :require => "openid" diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2721c57c7..fe9f6c1b6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -156,7 +156,16 @@ class ApplicationController < ActionController::Base user end end + def try_to_autologin1 + # auto-login feature starts a new session + user = User.try_to_autologin(params[:token]) + if user + start_user_session(user) + end + user + + end # Sets the logged in user def logged_user=(user) reset_session @@ -248,6 +257,24 @@ class ApplicationController < ActionController::Base end end end + def authorize1(ctrl = params[:controller], action = params[:action],token = params[:token], global = false) + + if(!User.current.logged? && !token.nil?) + + User.current =try_to_autologin1 + end + allowed = authorize_allowed(params[:controller], params[:action],global) + + if allowed + true + else + if @project && @project.archived? + render_403 :message => :notice_not_authorized_archived_project + else + deny_access + end + end + end def authorize_allowed(ctrl = params[:controller], action = params[:action], global = false) #modify by NWB @@ -261,6 +288,7 @@ class ApplicationController < ActionController::Base allowed end def authorize_attachment_download(ctrl = params[:controller], action = params[:action], global = false) + case @attachment.container_type when "Memo" allowed = User.current.allowed_to?(:memos_attachments_download,nil,:global => true) @@ -289,6 +317,37 @@ class ApplicationController < ActionController::Base end end + def authorize_attachment_download1(ctrl = params[:controller], action = params[:action],token = params[:token], global = false) + if(!User.current.logged? && !token.nil?) + User.current = try_to_autologin1 + end + case @attachment.container_type + when "Memo" + allowed = User.current.allowed_to?(:memos_attachments_download,nil,:global => true) + when "Message" + if @project + allowed = User.current.allowed_to?(:projects_attachments_download,@project,:global => false) + elsif @course + allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false) + end + when "contest" + return true + when "Course" + allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false) + else + return true + end + + if allowed + true + else + if @project && @project.archived? + render_403 :message => :notice_not_authorized_archived_project + else + deny_access + end + end + end def authorize_course(ctrl = params[:controller], action = params[:action], global = false) allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @course || @course, :global => global) if allowed @@ -789,4 +848,29 @@ class ApplicationController < ActionController::Base @organizer = WebFooterOranizer.first @companies = WebFooterCompany.all end + + + + + def password_authentication + user, last_login_on = User.try_to_login(params[:user_name], params[:password]) + + + successful_authentication(user, last_login_on) + + end + + + def successful_authentication(user, last_login_on) + logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}" + # Valid user + self.logged_user = user + # generate a key and set cookie if autologin + if params[:autologin] && Setting.autologin? + set_autologin_cookie(user) + end + call_hook(:controller_account_success_authentication_after, {:user => user }) + + + end end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 952dcdf44..2c6a002b4 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -17,11 +17,12 @@ class AttachmentsController < ApplicationController layout "users_base" + before_filter :find_project, :only => [:show, :download, :thumbnail, :destroy, :delete_homework]#, :except => [:upload, :autocomplete] before_filter :file_readable, :read_authorize, :only => [:show, :thumbnail]#Modified by young before_filter :delete_authorize, :only => :destroy before_filter :authorize_global, :only => :upload - before_filter :authorize_attachment_download, :only => :download + before_filter :authorize_attachment_download1, :only => :download #before_filter :login_without_softapplication, only: [:download] accept_api_auth :show, :download, :upload require 'iconv' diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e76fa31dc..9d35b9fb0 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -810,9 +810,9 @@ class CoursesController < ApplicationController # modify by nwb # 添加私密性判断 if User.current.member_of_course?(@course)|| User.current.admin? - events = @activity.events(@date_from, @date_to) + events = @activity.events(@days, @course.created_at) else - events = @activity.events(@date_from, @date_to, :is_public => 1) + events = @activity.events(@days, @course.created_at, :is_public => 1) end # 无新动态时,显示老动态 diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index cd51d2e58..03d1454ef 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -13,6 +13,44 @@ class ForumsController < ApplicationController include SortHelper PageLimit = 20 + def create_feedback + if User.current.logged? + @memo = Memo.new(params[:memo]) + @memo.forum_id = "1" + @memo.author_id = User.current.id + #@forum = @memo.forum + respond_to do |format| + if @memo.save + format.html { redirect_to forum_path(@memo.forum) } + else + sort_init 'updated_at', 'desc' + sort_update 'created_at' => "#{Memo.table_name}.created_at", + 'replies' => "#{Memo.table_name}.replies_count", + 'updated_at' => "COALESCE (last_replies_memos.created_at, #{Memo.table_name}.created_at)" + + @topic_count = @forum.topics.count + @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] + @memos = @forum.topics. + reorder("#{Memo.table_name}.sticky DESC"). + includes(:last_reply). + limit(@topic_pages.per_page). + offset(@topic_pages.offset). + order(sort_clause). + preload(:author, {:last_reply => :author}). + all + + flash.now[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" + # back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id) + format.html { render action: :show, layout: 'base_forums' }#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" } + format.json { render json: @memo.errors, status: :unprocessable_entity } + end + end + else + respond_to do |format| + format.html { redirect_to signin_path } + end + end + end def create_memo @memo = Memo.new(params[:memo]) @@ -49,16 +87,15 @@ class ForumsController < ApplicationController end end end - + def index @offset, @limit = api_offset_and_limit({:limit => 10}) @forums_all = Forum.reorder("sticky DESC") @forums_count = @forums_all.count @forums_pages = Paginator.new @forums_count, @limit, params['page'] - @offset ||= @forums_pages.offset - @forums = @forums_all.offset(@offset).limit(@limit).all + @forums = @forums_all.offset(@offset).limit(@limit).all #@forums = Forum.all respond_to do |format| format.html # index.html.erb @@ -86,14 +123,12 @@ class ForumsController < ApplicationController preload(:author, {:last_reply => :author}). all - - # @offset, @limit = api_offset_and_limit({:limit => 10}) # @forum = Forum.find(params[:id]) # @memos_all = @forum.topics # @topic_count = @memos_all.count # @topic_pages = Paginator.new @topic_count, @limit, params['page'] - + # @offset ||= @topic_pages.offset # @memos = @memos_all.offset(@offset).limit(@limit).all respond_to do |format| @@ -176,7 +211,6 @@ class ForumsController < ApplicationController @forums_count = @forums_all.count @forums_pages = Paginator.new @forums_count, @limit, params['page'] - @offset ||= @forums_pages.offset @forums = @forums_all.offset(@offset).limit(@limit).all respond_to do |format| @@ -197,7 +231,7 @@ class ForumsController < ApplicationController @memos_all = @forum.topics.where("subject LIKE ?", q) @topic_count = @memos_all.count @topic_pages = Paginator.new @topic_count, @limit, params['page'] - + @offset ||= @topic_pages.offset @memos = @memos_all.offset(@offset).limit(@limit).all respond_to do |format| @@ -205,20 +239,17 @@ class ForumsController < ApplicationController render 'show', :layout => 'base_forums' } format.json { render json: @forum } - end + end end - - private - def find_forum_if_available @forum = Forum.find(params[:id]) if params[:id] rescue ActiveRecord::RecordNotFound render_404 nil - end + end def authenticate_user_edit find_forum_if_available diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index f3c2b199c..c0d83fdcd 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -19,10 +19,13 @@ class IssuesController < ApplicationController layout 'base_projects'#Added by young default_search_scope :issues + before_filter :authorize1, :only => [:show] before_filter :find_issue, :only => [:show, :edit, :update] before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] before_filter :find_project, :only => [:new, :create, :update_form] + #before_filter :authorize, :except => [:index, :show] before_filter :authorize, :except => [:index] + before_filter :find_optional_project, :only => [:index] before_filter :check_for_default_issue_status, :only => [:new, :create] before_filter :build_new_issue_from_params, :only => [:new, :create, :update_form] @@ -107,7 +110,7 @@ class IssuesController < ApplicationController end def show - + @journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all @journals.each_with_index {|j,i| j.indice = i+1} @journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project) diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 308cb62ca..8ee8d099e 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -150,6 +150,7 @@ class MyController < ApplicationController File.delete(diskfile1) end end + end # Destroys user's account diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 0b7cbbb5f..5d43a4e20 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -597,8 +597,8 @@ class ProjectsController < ApplicationController "show_wiki_edits"=>true, "show_journals_for_messages" => true } - @date_to ||= Date.today + 1 - @date_from = @date_to - @days-1.years + + @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) # 决定显示所用用户或单个用户活动 @@ -612,9 +612,9 @@ class ProjectsController < ApplicationController # modify by nwb # 添加私密性判断 if User.current.member_of?(@project)|| User.current.admin? - events = @activity.events(@date_from, @date_to) + events = @activity.events(@days) else - events = @activity.events(@date_from, @date_to, :is_public => 1) + events = @activity.events(@days,nil, :is_public => 1) end @offset, @limit = api_offset_and_limit({:limit => 10}) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ab796c4e3..7b4d488a9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -41,7 +41,7 @@ class UsersController < ApplicationController :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index] before_filter :auth_user_extension, only: :show - before_filter :rest_user_score, only: :show + #before_filter :rest_user_score, only: :show #before_filter :select_entry, only: :user_projects accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx @@ -188,9 +188,9 @@ class UsersController < ApplicationController for user in @watcher events << Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 30) end - - - + + + @events_by_day = events.group_by(&:event_date) unless User.current.admin? diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 12637e2fb..b329e4c27 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -7,17 +7,6 @@ class ZipdownController < ApplicationController SAVE_FOLDER = "#{Rails.root}/files" OUTPUT_FOLDER = "#{Rails.root}/tmp/archiveZip" - #通过作业Id找到项目(课程) - def find_project_by_bid_id - obj_class = params[:obj_class] - obj_id = params[:obj_id] - obj = obj_class.constantize.find(obj_id) - case obj.class.to_s.to_sym - when :Bid - @project = obj.courses[0] - end - end - def assort if params[:obj_class] == "Bid" bid = Bid.find params[:obj_id] @@ -33,8 +22,8 @@ class ZipdownController < ApplicationController end send_file zipfile, :filename => bid.name + ".zip", :type => detect_content_type(zipfile) if zipfile - rescue Exception => e - render file: 'public/no_file_found.html' + #rescue Exception => e + # render file: 'public/no_file_found.html' end #下载某一学生的作业的所有文件 @@ -56,12 +45,23 @@ class ZipdownController < ApplicationController else render_403 end - rescue => e - render file: 'public/file_not_found.html' + #rescue => e + # render file: 'public/file_not_found.html' end private + #通过作业Id找到项目(课程) + def find_project_by_bid_id + obj_class = params[:obj_class] + obj_id = params[:obj_id] + obj = obj_class.constantize.find(obj_id) + case obj.class.to_s.to_sym + when :Bid + @project = obj.courses[0] + end + end + def zip_bid(bid) # Todo: User Access Controll bid_homework_path = [] @@ -101,10 +101,20 @@ class ZipdownController < ApplicationController Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| input_filename.each do |filename| + flag = true + index = 1 rename_file = ic.iconv( (File.basename(filename)) ).to_s rename_file = ic.iconv( filename_to_real( File.basename(filename))).to_s if is_attachment - zipfile.add(rename_file, filename) + begin + zipfile.add(rename_file, filename) + flag = false + rescue Exception => e + zipfile.get_output_stream('FILE_NOTICE.txt') do |os| + os.write l(:label_file_exist) + end + next + end end unless not_exist_file.empty? zipfile.get_output_stream('FILE_LOST.txt') do |os| @@ -113,9 +123,9 @@ class ZipdownController < ApplicationController end end zipfile_name - rescue Errno => e - logger.error "[zipdown#zipping] ===> #{e}" - @error = e + #rescue Errno => e + # logger.error "[zipdown#zipping] ===> #{e}" + # @error = e end def detect_content_type(name) content_type = Redmine::MimeType.of(name) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8c2542aa2..7efa02503 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -140,10 +140,12 @@ module ApplicationHelper # * :text - Link text (default to attachment filename) # * :download - Force download (default: false) def link_to_attachment(attachment, options={}) + token = options[:token] if options[:token] text = options.delete(:text) || attachment.filename route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path html_options = options.slice!(:only_path) url = send(route_method, attachment, attachment.filename, options) + url << "?token=#{token}" unless token.nil? link_to text, url, html_options end @@ -1593,6 +1595,12 @@ module ApplicationHelper end s end + + def get_memo + @new_memo = Memo.new + #@new_memo.subject = "有什么想说的,尽管来咆哮吧~~" + @public_forum = Forum.find(1) + end private diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 8390fc61c..6a708051a 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -224,6 +224,7 @@ module IssuesHelper # as an array of strings def details_to_strings(details, no_html=false, options={}) options[:only_path] = (options[:only_path] == false ? false : true) + options[:token] = options[:token] if options[:token] strings = [] values_by_field = {} details.each do |detail| @@ -312,7 +313,11 @@ module IssuesHelper old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank? if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key) # Link to the attachment if it has not been removed - value = link_to_attachment(atta, :download => true, :only_path => options[:only_path]) + if options[:token].nil? + value = link_to_attachment(atta, :download => true, :only_path => options[:only_path]) + else + value = link_to_attachment(atta, :download => true, :only_path => options[:only_path], :token => options[:token]) + end if options[:only_path] != false && atta.is_text? value += link_to( image_tag('magnifier.png'), diff --git a/app/models/issue_observer.rb b/app/models/issue_observer.rb index 3369387ee..50cbf2a42 100644 --- a/app/models/issue_observer.rb +++ b/app/models/issue_observer.rb @@ -18,8 +18,12 @@ class IssueObserver < ActiveRecord::Observer def after_create(issue) - thread1=Thread.new do - Mailer.issue_add(issue).deliver if Setting.notified_events.include?('issue_added') - end + Thread.start do + recipients = issue.recipients + recipients.each do |rec| + Mailer.issue_add(issue,rec).deliver if Setting.notified_events.include?('issue_added') + end + end + end end diff --git a/app/models/issue_overdue.rb b/app/models/issue_overdue.rb index 5caec94c9..3002b74ef 100644 --- a/app/models/issue_overdue.rb +++ b/app/models/issue_overdue.rb @@ -20,7 +20,11 @@ class IssueOverdue < ActiveRecord::Base #发邮件 #puts "11" + issue.id.to_s #Mailer.issue_expire(issue).deliver - Mailer.issue_add(issue).deliver + recipients = issue.recipients + recipients.each do |rec| + + Mailer.issue_edit(issue,rec).deliver + end break end end diff --git a/app/models/journal_observer.rb b/app/models/journal_observer.rb index 0357fb74d..10d3f7b4b 100644 --- a/app/models/journal_observer.rb +++ b/app/models/journal_observer.rb @@ -23,8 +23,12 @@ class JournalObserver < ActiveRecord::Observer (Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) || (Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?) ) - Thread.new do - Mailer.issue_edit(journal).deliver + Thread.start do + recipients = journal.recipients + recipients.each do |rec| + + Mailer.issue_edit(journal,rec).deliver + end end end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index a7f850766..b432461c7 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -95,29 +95,45 @@ class Mailer < ActionMailer::Base # Example: # issue_add(issue) => Mail::Message object # Mailer.issue_add(issue).deliver => sends an email to issue recipients - def issue_add(issue) + def issue_add(issue, recipients) issue_id = issue.project_index redmine_headers 'Project' => issue.project.identifier, 'Issue-Id' => issue_id, 'Issue-Author' => issue.author.login redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to message_id issue + @author = issue.author @issue = issue - @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id) - recipients = issue.recipients - cc = issue.watcher_recipients - recipients - mail :to => recipients, - :cc => cc, - :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" + + + token = Token.new(:user => User.find_by_mail(recipients), :action => 'autologin') + token.save + @token = token + @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :token => @token.value) + + + cc = issue.watcher_recipients - issue.recipients + subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" + mail(:to => recipients, + :cc => cc, + :subject => subject) end + # issue.attachments.each do |attach| + # attachments["#{attach.filename}"] = File.read("#{attach.disk_filename}") + # end + # cc = issue.watcher_recipients - recipients + #mail.attachments['test'] = File.read("#{RAILS.root}/files/2015/01/150114094010_libegl.dll") + + + # Builds a Mail::Message object used to email recipients of the edited issue. # # Example: # issue_edit(journal) => Mail::Message object # Mailer.issue_edit(journal).deliver => sends an email to issue recipients - def issue_edit(journal) + def issue_edit(journal,recipients) issue = journal.journalized.reload issue_id = issue.project_index redmine_headers 'Project' => issue.project.identifier, @@ -127,18 +143,34 @@ class Mailer < ActionMailer::Base message_id journal references issue @author = journal.user - recipients = journal.recipients + + + token = Token.new(:user => User.find_by_mail(recipients), :action => 'autologin') + token.save + @token = token + @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}", :token => @token.value) + + + + # Watchers in cc - cc = journal.watcher_recipients - recipients + + cc = journal.watcher_recipients - journal.recipients s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] " s << "(#{issue.status.name}) " if journal.new_value_for('status_id') s << issue.subject @issue = issue @journal = journal - @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}") - mail :to => recipients, - :cc => cc, - :subject => s + # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}") + mail(:to => recipients, + :cc => cc, + :subject => s) + end + + def self.deliver_mailer(to,cc, subject) + mail :to => to, + :cc => cc, + :subject => subject end # 用户申请加入项目邮件通知 @@ -615,5 +647,15 @@ class Mailer < ActionMailer::Base Rails.logger end - + def add_attachments(obj) + if email.attachments && email.attachments.any? + email.attachments.each do |attachment| + obj.attachments << Attachment.create(:container => obj, + :file => attachment.decoded, + :filename => attachment.filename, + :author => user, + :content_type => attachment.mime_type) + end + end + end end diff --git a/app/models/user.rb b/app/models/user.rb index 735b80762..52619b038 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -380,7 +380,7 @@ class User < Principal raise text end - # Returns the user who matches the given autologin +key+ or nil + def self.try_to_autologin(key) user = Token.find_active_user('autologin', key, Setting.autologin.to_i) if user @@ -466,7 +466,11 @@ class User < Principal User.hash_password("#{salt}#{User.hash_password clear_password}") == hashed_password end end + def check_password1?(clear_password) + + clear_password == hashed_password + end # Generates a random salt and computes hashed_password for +clear_password+ # The hashed password is stored in the following form: SHA1(salt + SHA1(password)) def salt_password(clear_password) diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index db1f555d3..e107e50b3 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -36,6 +36,7 @@ $('#ajax-modal').html('<%= escape_javascript(render :partial => 'homework_attach/praise_alert') %>'); showModal('ajax-modal', '480px'); $('#ajax-modal').css('height','240px'); + $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + ""); $('#ajax-modal').parent().css("top","").css("left","").css("width","511"); diff --git a/app/views/forums/create_feedback.js.erb b/app/views/forums/create_feedback.js.erb new file mode 100644 index 000000000..b94ac73aa --- /dev/null +++ b/app/views/forums/create_feedback.js.erb @@ -0,0 +1,6 @@ +$(function(){ + $("#button1").click(function(){ + myTips("您的意见已经反馈到公共贴吧的新手讨论吧,我们会第一时间解决您的问题,谢谢支持!","success"); + }); + +}) \ No newline at end of file diff --git a/app/views/homework_attach/new.html.erb b/app/views/homework_attach/new.html.erb index 661e15d5b..77077f102 100644 --- a/app/views/homework_attach/new.html.erb +++ b/app/views/homework_attach/new.html.erb @@ -78,7 +78,10 @@   作品描述    :  - <%= f.text_area "description", :class => "w620", :style=>"width:432px;", :maxlength => 3000, :placeholder => "最多3000个汉字", :onkeyup => "regexDescription();"%> + <%= f.text_area "description", :class => "w620", :maxlength => 3000, :style => "width:430px", :placeholder => "最多3000个汉字", :onkeyup => "regexDescription();"%> +
+ +


diff --git a/app/views/layouts/_base_feedback.html.erb b/app/views/layouts/_base_feedback.html.erb new file mode 100644 index 000000000..62b3a01e3 --- /dev/null +++ b/app/views/layouts/_base_feedback.html.erb @@ -0,0 +1,150 @@ + + + + +意见反馈浮窗 + + + + + + + +
+
+ + <% get_memo %> + <%= form_for(@new_memo, :url => create_feedback_forum_path(@public_forum)) do |f| %> +
+

+ <%= f.text_area :subject, :class => "opnionText",:placeholder => "有什么想说的,尽管来咆哮吧~~"%> +

+

+ <%= f.hidden_field :content, :required => true ,:value=>'该贴来自用户反馈!'%> +

+ <%#= f.submit :value => l(:label_memo_create), :class => "opnionButton", :id => "button1" %> + 提  交 + <% end %> +
+ + + +
+
+ +
+
技术支持:
+

<%= l(:label_course_adcolick) %>黄井泉
+ <%= l(:label_course_adcolick) %>白羽

+
+ +
+ + + + + diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index 6f87d4171..445a5abf4 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -27,6 +27,7 @@ #@nav_dispaly_user_label = 1 end %> +<%= render :partial => "layouts/base_feedback" %>