diff --git a/.metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch b/.metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch
index f21eed9f2..678ced8a0 100644
--- a/.metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch
+++ b/.metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch
@@ -2,6 +2,7 @@
+
diff --git a/.metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch b/.metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch
index 2134fa92c..f7b0844d8 100644
--- a/.metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch
+++ b/.metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch
@@ -2,6 +2,7 @@
+
diff --git a/.rspec b/.rspec
new file mode 100644
index 000000000..8c18f1abd
--- /dev/null
+++ b/.rspec
@@ -0,0 +1,2 @@
+--format documentation
+--color
diff --git a/Gemfile b/Gemfile
deleted file mode 100644
index 318b8dcf0..000000000
--- a/Gemfile
+++ /dev/null
@@ -1,125 +0,0 @@
-source 'https://rubygems.org'
-
-unless RUBY_PLATFORM =~ /w32/
- # unix-like only
- gem 'iconv'
- gem 'rubyzip'
- gem 'zip-zip'
-end
-
-gem 'seems_rateable', path: 'lib/seems_rateable'
-gem "rails", "3.2.13"
-gem "jquery-rails", "~> 2.0.2"
-gem "i18n", "~> 0.6.0"
-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'
-
-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'
-# 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
-
-
-# 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"
- gem "rack-openid"
-end
-
-# Optional gem for exporting the gantt to a PNG file, not supported with jruby
-platforms :jruby do
- # jruby-openssl is bundled with JRuby 1.7.0
- gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0'
- gem "activerecord-jdbc-adapter", "1.2.5"
-end
-
-# Include database gems for the adapters found in the database
-# configuration file
-require 'erb'
-require 'yaml'
-database_file = File.join(File.dirname(__FILE__), "config/database.yml")
-if File.exist?(database_file)
- database_config = YAML::load(ERB.new(IO.read(database_file)).result)
- adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
- if adapters.any?
- adapters.each do |adapter|
- case adapter
- when 'mysql2'
- gem "mysql2", "= 0.3.11", :platforms => [:mri, :mingw]
- gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
- when 'mysql'
- gem "mysql", "~> 2.8.1", :platforms => [:mri, :mingw]
- gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
- when /postgresql/
- gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw]
- gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
- when /sqlite3/
- gem "sqlite3", :platforms => [:mri, :mingw]
- gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
- when /sqlserver/
- gem "tiny_tds", "~> 0.5.1", :platforms => [:mri, :mingw]
- gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw]
- else
- warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems")
- end
- end
- else
- warn("No adapter found in config/database.yml, please configure it first")
- end
-else
- warn("Please configure your config/database.yml first")
-end
-
-local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
-if File.exists?(local_gemfile)
- puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v`
- instance_eval File.read(local_gemfile)
-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/controllers/account_controller.rb b/app/controllers/account_controller.rb
index 6c95294d7..69c2d3002 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -345,7 +345,10 @@ class AccountController < ApplicationController
if user.save and token.save
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
Mailer.register(token).deliver
+
+
flash[:notice] = l(:notice_account_register_done)
+
render action: 'email_valid', locals: {:mail => user.mail}
else
yield if block_given?
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 2721c57c7..06e5dac30 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,7 +257,30 @@ 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 auth_login1(token = params[:token])
+ if(!User.current.logged? && !token.nil?)
+
+ User.current =try_to_autologin1
+ end
+ end
def authorize_allowed(ctrl = params[:controller], action = params[:action], global = false)
#modify by NWB
if @project
@@ -261,6 +293,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 +322,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 +853,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/bids_controller.rb b/app/controllers/bids_controller.rb
index ec2fb7d77..7e5894b83 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -9,6 +9,8 @@ class BidsController < ApplicationController
menu_item :homework_statistics, :only => :homework_statistics
menu_item :edit, :only => :edit
+
+
before_filter :can_show_course,only: []
before_filter :can_show_contest,only: []
#Ended by young
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 9d35b9fb0..edd3f1b9d 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -500,8 +500,7 @@ class CoursesController < ApplicationController
end
end
- def
- course
+ def course
@school_id = params[:school_id]
per_page_option = 10
if @school_id == "0" or @school_id.nil?
diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb
index 03d1454ef..54b8c6305 100644
--- a/app/controllers/forums_controller.rb
+++ b/app/controllers/forums_controller.rb
@@ -160,12 +160,15 @@ class ForumsController < ApplicationController
def create
@forum = Forum.new(params[:forum])
@forum.creator_id = User.current.id
+ if @forum.save
+ respond_to do |format|
- respond_to do |format|
- if @forum.save
- format.html { redirect_to @forum, notice: l(:label_forum_create_succ) }
- format.json { render json: @forum, status: :created, location: @forum }
- else
+ format.html { redirect_to @forum, notice: l(:label_forum_create_succ) }
+ format.json { render json: @forum, status: :created, location: @forum }
+ end
+
+ else
+ respond_to do |format|
flash.now[:error] = "#{l :label_forum_create_fail}: #{@forum.errors.full_messages[0]}"
format.html { render action: "new" }
format.json { render json: @forum.errors, status: :unprocessable_entity }
diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb
index 8b9bf9099..8e69d1d72 100644
--- a/app/controllers/homework_attach_controller.rb
+++ b/app/controllers/homework_attach_controller.rb
@@ -26,6 +26,7 @@ class HomeworkAttachController < ApplicationController
get_not_batch_homework_list sort,direction, @bid.id
@cur_page = params[:page] || 1
@cur_type = 1
+ @cur_sort,@cur_direction = params[:sort] || "s_socre", params[:direction] || "desc"
@direction = direction == 'asc'? 'desc' : 'asc'
respond_to do |format|
format.js
@@ -433,7 +434,7 @@ class HomeworkAttachController < ApplicationController
#添加留言
def addjours
@is_teacher,@is_anonymous_comments,@m_score = params[:is_teacher]=="true",params[:is_anonymous_comments]=="true",params[:stars_value]
- @cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5
+ @cur_page,@cur_type = params[:page] || 1,params[:cur_type] || 5
@homework = HomeworkAttach.find(params[:homework_id])
@stars_reates = @homework.rates(:quality)
homework = @homework
@@ -479,7 +480,7 @@ class HomeworkAttachController < ApplicationController
if @cur_type == "1" #如果当前是老师未批列表,需要刷新整个作业列表界面
@bid = @homework.bid
- get_not_batch_homework_list "s_socre","desc",@homework.bid_id
+ get_not_batch_homework_list params[:cur_sort] || "s_socre",params[:cur_direction] || "desc",@homework.bid_id
elsif @cur_type == "2" #老师已批列表
@result_homework = HomeworkAttach.find_by_sql("SELECT homework_attaches.*,
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score,
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 8ee8d099e..8f00c49cd 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -17,6 +17,9 @@
class MyController < ApplicationController
layout "users_base"
+ # edit
+ before_filter :auth_login1, :only => [:account]
+ #
before_filter :require_login
helper :issues
diff --git a/app/controllers/poll_answer_controller.rb b/app/controllers/poll_answer_controller.rb
deleted file mode 100644
index 521f7ed3f..000000000
--- a/app/controllers/poll_answer_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class PollAnswerController < ApplicationController
-end
\ No newline at end of file
diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb
index a21fdb549..4abddaa5e 100644
--- a/app/controllers/poll_controller.rb
+++ b/app/controllers/poll_controller.rb
@@ -1,2 +1,419 @@
class PollController < ApplicationController
+ before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:republish_poll,:poll_result]
+ before_filter :find_container, :only => [:new,:create, :index]
+ before_filter :is_member_of_course, :only => [:index,:show,:poll_result]
+ before_filter :is_course_teacher, :only => [:new,:create,:edit,:update,:destroy,:publish_poll,:republish_poll]
+ include PollHelper
+ def index
+ if @course
+ @is_teacher = User.current.allowed_to?(:as_teacher,@course)
+ if @is_teacher
+ polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}")
+ else
+ polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status = 2")
+ end
+ @polls = paginateHelper polls,20 #分页
+ respond_to do |format|
+ format.html{render :layout => 'base_courses'}
+ end
+ elsif @project
+ #项目的问卷调查相关代码
+ end
+ end
+
+ def show
+ @poll = Poll.find params[:id]
+ #已提交问卷的用户不能再访问该界面
+ if has_commit_poll?(@poll.id,User.current.id) && (!User.current.admin?)
+ render_403
+ else
+ @can_edit_poll = (!has_commit_poll?(@poll.id,User.current.id)) || User.current.admin?
+ @percent = get_percent(@poll,User.current)
+ poll_questions = @poll.poll_questions
+ @poll_questions = paginateHelper poll_questions,5 #分页
+ respond_to do |format|
+ format.html {render :layout => 'base_courses'}
+ end
+ end
+ end
+
+ def new
+ if @course
+ option = {
+ :polls_name => "",
+ :polls_type => @course.class.to_s,
+ :polls_group_id => @course.id,
+ :polls_status => 1,
+ :user_id => User.current.id,
+ :published_at => Time.now,
+ :closed_at => Time.now,
+ :polls_description => ""
+ }
+ @poll = Poll.create option
+ if @poll
+ redirect_to edit_poll_url @poll.id
+ end
+ elsif @project
+ #项目的问卷调查相关代码
+ end
+ end
+
+ def create
+
+ end
+
+ def edit
+ respond_to do |format|
+ format.html{render :layout => 'base_courses'}
+ end
+ end
+
+ def update
+ @poll.polls_name = params[:polls_name].empty? ? l(:label_poll_title) : params[:polls_name]
+ @poll.polls_description = params[:polls_description].empty? ? l(:label_poll_description) : params[:polls_description]
+ if @poll.save
+ respond_to do |format|
+ format.js
+ end
+ else
+ render_404
+ end
+ end
+
+ def destroy
+ if @poll && @poll.destroy
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+
+ def statistics_result
+ @poll = Poll.find(params[:id])
+ poll_questions = @poll.poll_questions
+ @poll_questions = paginateHelper poll_questions, 5
+ respond_to do |format|
+ format.html{render :layout => 'base_courses'}
+ end
+ end
+
+ def get_poll_totalcount poll_question
+ @total_questions_count = poll_question.poll_votes.count
+ end
+
+ def get_poll_everycount poll_answer
+ @every_answer_count = poll_answer.poll_votes.count
+ end
+
+
+ #添加题目
+ def create_poll_question
+ question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title]
+ option = {
+ :is_necessary => (params[:is_necessary]=="true" ? 1 : 0),
+ :question_title => question_title,
+ :question_type => params[:question_type] || 1,
+ :question_number => @poll.poll_questions.count + 1
+ }
+ @poll_questions = @poll.poll_questions.new option
+ if params[:question_answer]
+ for i in 1..params[:question_answer].count
+ answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
+ question_option = {
+ :answer_position => i,
+ :answer_text => answer
+ }
+ @poll_questions.poll_answers.new question_option
+ end
+ end
+ if @poll_questions.save
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+
+ #修改题目
+ def update_poll_question
+ @poll_question = PollQuestion.find params[:poll_question]
+ #@poll = @poll_question.poll
+ @poll_question.is_necessary = params[:is_necessary]=="true" ? 1 : 0
+ @poll_question.question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title]
+ ################处理选项
+ if params[:question_answer]
+ @poll_question.poll_answers.each do |answer|
+ answer.destroy unless params[:question_answer].keys.include? answer.id.to_s
+ end
+ for i in 1..params[:question_answer].count
+ question = @poll_question.poll_answers.find_by_id params[:question_answer].keys[i-1]
+ answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
+ if question
+ question.answer_position = i
+ question.answer_text = answer
+ question.save
+ else
+ question_option = {
+ :answer_position => i,
+ :answer_text => answer
+ }
+ @poll_question.poll_answers.new question_option
+ end
+ end
+ end
+ @poll_question.save
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ #删除题目
+ def delete_poll_question
+ @poll_question = PollQuestion.find params[:poll_question]
+ @poll = @poll_question.poll
+ poll_questions = @poll.poll_questions.where("question_number > #{@poll_question.question_number}")
+ poll_questions.each do |question|
+ question.question_number -= 1
+ question.save
+ end
+ if @poll_question && @poll_question.destroy
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+
+ #发布问卷
+ def publish_poll
+ @poll.polls_status = 2
+ @poll.published_at = Time.now
+ if @poll.save
+ if params[:is_remote]
+ redirect_to poll_index_url(:polls_type => "Course", :polls_group_id => @course.id)
+ else
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+ end
+
+ #提交答案
+ def commit_answer
+ pq = PollQuestion.find(params[:poll_question_id])
+ if has_commit_poll?(@poll.id,User.current.id) && (!User.current.admin?)
+ render :json => {:text => "failure"}
+ return
+ end
+ if pq.question_type == 1
+ #单选题
+ pv = PollVote.find_by_poll_question_id_and_user_id(params[:poll_question_id],User.current.id)
+ if pv.nil?
+ #尚未答该题,添加答案
+ pv = PollVote.new
+ pv.user_id = User.current.id
+ pv.poll_question_id = params[:poll_question_id]
+ end
+ #修改该题对应答案
+ pv.poll_answer_id = params[:poll_answer_id]
+ if pv.save
+ #保存成功返回成功信息及当前以答题百分比
+ @percent = get_percent(@poll,User.current)
+ render :json => {:text => "ok" ,:percent => format("%.2f" ,@percent)}
+ else
+ #返回失败信息
+ render :json => {:text => "failure"}
+ end
+ elsif pq.question_type == 2
+ #多选题
+ pv = PollVote.find_by_poll_answer_id_and_user_id(params[:poll_answer_id],User.current.id)
+ if pv.nil?
+ #尚未答该题,添加答案
+ pv = PollVote.new
+ pv.user_id = User.current.id
+ pv.poll_question_id = params[:poll_question_id]
+ pv.poll_answer_id = params[:poll_answer_id]
+ if pv.save
+ @percent = get_percent(@poll,User.current)
+ render :json => {:text => "true",:percent => format("%.2f" ,@percent)}
+ else
+ render :json => {:text => "failure"}
+ end
+ else
+ #pv不为空,则当前选项之前已被选择,再次点击则是不再选择该项,故删除该答案
+ if pv.delete
+ @percent = get_percent(@poll,User.current)
+ render :json => {:text => "false" ,:percent => format("%.2f" ,@percent)}
+ else
+ render :json => {:text => "failure"}
+ end
+ end
+ elsif pq.question_type == 3 || pq.question_type == 4
+ #单行文本,多行文本题
+ pv = PollVote.find_by_poll_question_id_and_user_id(params[:poll_question_id],User.current.id)
+ if pv.nil?
+ #pv为空之前尚未答题,添加答案
+ if params[:vote_text].nil? || params[:vote_text].blank?
+ #用户提交空答案,视作不作答
+ @percent = get_percent(@poll,User.current)
+ render :json => {:text => pv.vote_text,:percent => format("%.2f" ,@percent)}
+ else
+ #添加答案
+ pv = PollVote.new
+ pv.user_id = User.current.id
+ pv.poll_question_id = params[:poll_question_id]
+ pv.vote_text = params[:vote_text]
+ if pv.save
+ @percent = get_percent(@poll,User.current)
+ render :json => {:text => pv.vote_text,:percent => format("%.2f" ,@percent)}
+ else
+ render :json => {:text => "failure"}
+ end
+ end
+ else
+ #pv不为空说明用户之前已作答
+ if params[:vote_text].nil? || params[:vote_text].blank?
+ #用户提交空答案,视为删除答案
+ if pv.delete
+ @percent = get_percent(@poll,User.current)
+ render :json => {:text => pv.vote_text,:percent => format("%.2f" ,@percent)}
+ else
+ render :json => {:text => "failure"}
+ end
+ else
+ #用户修改答案
+ pv.vote_text = params[:vote_text]
+ if pv.save
+ @percent = get_percent(@poll,User.current)
+ render :json => {:text => pv.vote_text,:percent => format("%.2f" ,@percent)}
+ else
+ render :json => {:text => "failure"}
+ end
+ end
+ end
+
+ else
+ render :json => {:text => "failure"}
+ end
+ end
+
+ #提交问卷
+ def commit_poll
+ @uncomplete_question = get_uncomplete_question(@poll,User.current)
+ if @uncomplete_question.count < 1
+ pu = get_poll_user(@poll.id,User.current.id)
+ pu.user_id = User.current.id
+ pu.poll_id = @poll.id
+ if pu.save
+ #redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course')
+ @status = 0 #提交成功
+ else
+ @status = 2 #未知错误
+ end
+ else
+ @status = 1 #有未做得必答题
+ end
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ #重新发布问卷
+ def republish_poll
+ @poll.poll_questions.each do |poll_question|
+ poll_question.poll_votes.destroy_all
+ end
+ @poll.poll_users.destroy_all
+ @poll.polls_status = 1
+ @poll.save
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ #显示某个学生某份问卷的填写结果
+ def poll_result
+ @poll_questions = paginateHelper @poll.poll_questions,5
+ respond_to do |format|
+ format.html{render :layout => 'base_courses'}
+ end
+ end
+
+ private
+ def find_poll_and_course
+ @poll = Poll.find params[:id]
+ @course = Course.find @poll.polls_group_id
+ rescue Exception => e
+ render_404
+ end
+
+ def find_container
+ if params[:polls_type] && params[:polls_group_id]
+ case params[:polls_type]
+ when "Course"
+ @course = Course.find_by_id params[:polls_group_id]
+ when "Project"
+ @project = Project.find_by_id params[:polls_group_id]
+ end
+ else
+ render_404
+ end
+ end
+
+ def is_member_of_course
+ render_403 unless(@course && User.current.member_of_course?(@course))
+ end
+
+ def is_course_teacher
+ @is_teacher = User.current.allowed_to?(:as_teacher,@course)
+ render_403 unless(@course && @is_teacher)
+ end
+
+ #获取未完成的题目
+ def get_uncomplete_question poll,user
+ necessary_questions = poll.poll_questions.where("#{PollQuestion.table_name}.is_necessary = 1")
+ uncomplete_question = []
+ necessary_questions.each do |question|
+ answers = get_user_answer(question,user)
+ if answers.nil? || answers.count < 1
+ uncomplete_question << question
+ end
+ end
+ uncomplete_question
+ end
+
+ #获取用户对某个问题的答案
+ def get_user_answer(question,user)
+ user_answer = question.poll_votes.where("#{PollVote.table_name}.user_id = #{user.id}")
+ user_answer
+ end
+
+ def get_complete_question(poll,user)
+ questions = poll.poll_questions
+ complete_question = []
+ questions.each do |question|
+ answers = get_user_answer(question,user)
+ if !(answers.nil? || answers.count < 1)
+ complete_question << question
+ end
+ end
+ complete_question
+ end
+
+ def get_percent poll,user
+ complete_count = get_complete_question(poll,user).count
+ if poll.poll_questions.count == 0
+ return 0
+ else
+ return (complete_count.to_f / poll.poll_questions.count.to_f)*100
+ end
+ end
+
+ #PollUser记录用户是否已提交问卷有对应的记录则已提交,没有则新建一个
+ def get_poll_user poll_id,user_id
+ pu = PollUser.find_by_poll_id_and_user_id(poll_id,user_id)
+ if pu.nil?
+ pu = PollUser.new
+ end
+ pu
+ end
end
\ No newline at end of file
diff --git a/app/controllers/poll_question_controller.rb b/app/controllers/poll_question_controller.rb
deleted file mode 100644
index 46a75c0ab..000000000
--- a/app/controllers/poll_question_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class PollQuestionController < ApplicationController
-end
\ No newline at end of file
diff --git a/app/controllers/poll_user_controller.rb b/app/controllers/poll_user_controller.rb
deleted file mode 100644
index 0373fe085..000000000
--- a/app/controllers/poll_user_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class PollUserController < ApplicationController
-end
\ No newline at end of file
diff --git a/app/controllers/poll_vote_controller.rb b/app/controllers/poll_vote_controller.rb
deleted file mode 100644
index e77bdc622..000000000
--- a/app/controllers/poll_vote_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class PollVoteController < ApplicationController
-end
\ No newline at end of file
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 5d43a4e20..a2e793a10 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -31,14 +31,16 @@ class ProjectsController < ApplicationController
menu_item :feedback, :only => :feedback
menu_item l(:label_course_file), :only => :index
menu_item l(:label_course_news), :only => :index
-
- before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches]
+# edit
+ before_filter :authorize1, :only => [:show]
+#
+ before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_project]
# before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file,
# :statistics, :feedback, :course, :enterprise_course, :course_enterprise, :project_respond, :share,
# :show_projects_score, :issue_score_index, :news_score_index, :file_score_index, :code_submit_score_index, :projects_topic_score_index]
#此条勿删 课程相关权限 ,:new_homework,:homework,:feedback,,:member
- before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course]
+ before_filter :authorize, :only => [: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
@@ -116,8 +118,8 @@ class ProjectsController < ApplicationController
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").joins("LEFT JOIN #{ProjectScore.table_name} ON #{Project.table_name}.id = #{ProjectScore.table_name}.project_id").
where("#{Project.table_name}.project_type = ? ", Project::ProjectType_project)
- @project_count = @projects_all.count
- @project_pages = Paginator.new @project_count, per_page_option, params['page']
+ @poll_questions_count = @projects_all.count
+ @poll_questions_pages = Paginator.new @project_count, per_page_option, params['page']
#gcm activity count
@@ -556,6 +558,11 @@ class ProjectsController < ApplicationController
# Show @project
def show
+ if(@project && !@project.is_public && !User.current.member_of?(@project))
+ render_403
+ return
+ end
+
@project_type = params[:project_type]
# try to redirect to the requested menu item
@@ -910,6 +917,14 @@ class ProjectsController < ApplicationController
end
end
end
+
+ #加入私有项目
+ def join_project
+ respond_to do |format|
+ format.js
+ end
+ end
+
private
def memberAccess
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 7b4d488a9..58af43da3 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -15,8 +15,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class UsersController < ApplicationController
+
layout :setting_layout
#Added by young
+ before_filter :auth_login1, :only => [:show, :user_activities]
menu_item :activity
menu_item :user_information, :only => :info
menu_item :user_course, :only => :user_courses
@@ -29,6 +31,9 @@ class UsersController < ApplicationController
#Ended by young
+ # edit
+
+ #
before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info,
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index cb88742ad..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
diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index a862753ef..22eb9bfae 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -111,6 +111,10 @@ module CoursesHelper
#garble count
# end
+ #获取课程所有成员
+ def course_all_member course
+ course.members
+ end
# 学生人数计算
# add by nwb
def studentCount course
@@ -561,12 +565,13 @@ module CoursesHelper
def course_in_current_or_next_term course
is_current_term = false
is_next_term = false
- if course.time == Time.now.year && course.term == cur_course_term
+ year_now = Time.now.month < 3 ? Time.now.year - 1:Time.now.year
+ if course.time == year_now && course.term == cur_course_term
is_current_term = true
end
- if cur_course_term == "秋季学期" && course.time == (Time.now.year + 1) && course.term == "春季学期"
+ if cur_course_term == "秋季学期" && course.time == (year_now + 1) && course.term == "春季学期"
is_next_term = true
- elsif cur_course_term == "春季学期" && course.time == Time.now.year && course.term == "秋季学期"
+ elsif cur_course_term == "春季学期" && course.time == year_now && course.term == "秋季学期"
is_next_term = true
end
is_current_term || is_next_term
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/helpers/poll_helper.rb b/app/helpers/poll_helper.rb
new file mode 100644
index 000000000..60d82c096
--- /dev/null
+++ b/app/helpers/poll_helper.rb
@@ -0,0 +1,77 @@
+# encoding: utf-8
+#
+# Redmine - project management software
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module PollHelper
+ #判断选项是否被选中
+ def answer_be_selected?(answer,user)
+ pv = answer.poll_votes.where("#{PollVote.table_name}.user_id = #{user.id} ")
+ if !pv.nil? && pv.count > 0
+ true
+ else
+ false
+ end
+ end
+
+ #获取文本题答案
+ def get_anwser_vote_text(question_id,user_id)
+ pv = PollVote.find_by_poll_question_id_and_user_id(question_id,user_id)
+ if pv.nil?
+ ''
+ else
+ pv.vote_text
+ end
+ end
+
+ #判断用户是否已经提交了问卷
+ def has_commit_poll?(poll_id,user_id)
+ pu = PollUser.find_by_poll_id_and_user_id(poll_id,user_id)
+ if pu.nil?
+ false
+ else
+ true
+ end
+ end
+
+ #统计答题百分比,统计结果保留两位小数
+ def statistics_result_percentage(e, t)
+ e = e.to_f
+ t = t.to_f
+ t == 0 ? 0 : format("%.2f", e*100/t)
+ end
+
+ #多选的时候查询去重
+ def total_answer id
+ total = PollVote.find_by_sql("SELECT distinct(user_id) FROM `poll_votes` where poll_question_id = #{id}").count
+ end
+
+ #页面体型显示
+ def options_show pq
+ case pq
+ when 1
+ "单选题"
+ when 2
+ "多选题"
+ when 3
+ "单行主观题"
+ else
+ "多行主观题"
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/app/models/contest.rb b/app/models/contest.rb
index ad54e8fb4..650e363a8 100644
--- a/app/models/contest.rb
+++ b/app/models/contest.rb
@@ -15,7 +15,8 @@ class Contest < ActiveRecord::Base
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
has_many :contestnotifications, :dependent => :destroy, :include => :author
-
+
+
acts_as_attachable
diff --git a/app/models/forum.rb b/app/models/forum.rb
index dc1603288..e47d18b02 100644
--- a/app/models/forum.rb
+++ b/app/models/forum.rb
@@ -23,7 +23,7 @@ class Forum < ActiveRecord::Base
acts_as_taggable
scope :by_join_date, order("created_at DESC")
-
+ after_create :send_email
def reset_counters!
self.class.reset_counters!(id)
end
@@ -38,6 +38,11 @@ class Forum < ActiveRecord::Base
self.creator == user || user.admin?
end
+ def send_email
+ Thread.start do
+ Mailer.forum_add(self).deliver if Setting.notified_events.include?('forum_add')
+ end
+ end
# Updates topic_count, memo_count and last_memo_id attributes for +board_id+
def self.reset_counters!(forum_id)
forum_id = forum_id.to_i
diff --git a/app/models/forum_observer.rb b/app/models/forum_observer.rb
new file mode 100644
index 000000000..1c514d6ab
--- /dev/null
+++ b/app/models/forum_observer.rb
@@ -0,0 +1,8 @@
+class ForumObserver < ActiveRecord::Observer
+ def after_create(forum)
+ Thread.start do
+ Mailer.forum_add(forum).deliver if Setting.notified_events.include?('forum_add')
+ end
+
+ end
+end
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/journals_for_message_observer.rb b/app/models/journals_for_message_observer.rb
index 093002a2c..0e5f29d03 100644
--- a/app/models/journals_for_message_observer.rb
+++ b/app/models/journals_for_message_observer.rb
@@ -1,7 +1,9 @@
# Added by young
class JournalsForMessageObserver < ActiveRecord::Observer
def after_create(journals_for_message)
+ thread1 = Thread.start do
Mailer.journals_for_message_add(User.current, journals_for_message).deliver
+ end
end
end
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index a7f850766..23ac36054 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -26,7 +26,37 @@ class Mailer < ActionMailer::Base
def self.default_url_options
{ :host => Setting.host_name, :protocol => Setting.protocol }
end
-
+
+ # 贴吧新建贴吧发送邮件
+ # example Mailer.forum(forum).deliver
+ def forum_add(forum)
+
+ redmine_headers 'Forum' => forum.id
+ @forum = forum
+ @author = forum.creator
+ recipients = forum.creator.mail
+ # cc = wiki_content.page.wiki.watcher_recipients - recipients
+
+ @forum_url = url_for(:controller => 'forums', :action => 'show', :id => forum.id)
+ mail :to => recipients,:subject => "[ #{l(:label_forum)} : #{forum.name} #{l(:notice_successful_create)}]"
+
+ end
+
+ def forum_message_added(memo)
+ @memo = memo
+ redmine_headers 'Memo' => memo.id
+ @forum = memo.forum
+ @author = memo.author
+ recipients ||= []
+ mems = memo.self_and_siblings
+ mems.each do |mem|
+ recipients << mem.author.mail unless recipients.include? mem.author.mail
+ end
+ # cc = wiki_content.page.wiki.watcher_recipients - recipients
+
+ @memo_url = url_for(forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id)))
+ mail :to => recipients,:subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]"
+ end
# Builds a Mail::Message object used to email recipients of the added journals for message.
# 留言分为直接留言,和对留言人留言的回复
@@ -62,13 +92,13 @@ class Mailer < ActionMailer::Base
course = journals_for_message.jour
@author = journals_for_message.user
#课程的教师
- @teachers = searchTeacherAndAssistant journals_for_message.jour
+ @members = course_all_member journals_for_message.jour
#收件人邮箱
@recipients ||= []
- @teachers.each do |teacher|
- if teacher.user.notify_about? journals_for_message
+ @members.each do |teacher|
+
@recipients << teacher.user.mail
- end
+
end
mail :to => @recipients,
@@ -95,29 +125,52 @@ 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}"
+ user = User.find_by_mail(recipients)
+
+ token = Token.new(:user =>user , :action => 'autologin')
+ token.save
+ @token = token
+ @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :token => @token.value)
+
+ # edit
+ @issue_author_url = url_for(user_activities_url(@author,:token => @token.value))
+ @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value)
+
+ @user_url = url_for(my_account_url(user,:token => @token.value))
+ cc = nil
+ if recipients == issue.recipients[0]
+ cc = issue.watcher_recipients - issue.recipients
+ end
+ 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 +180,45 @@ class Mailer < ActionMailer::Base
message_id journal
references issue
@author = journal.user
- recipients = journal.recipients
+
+ user = User.find_by_mail(recipients)
+
+ token = Token.new(:user =>user , :action => 'autologin')
+ token.save
+ @token = token
+
+
+ # edit
+ @issue_author_url = url_for(:controller => 'users', :action => 'show', :id => issue.author_id, :token => @token.value)
+ @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value)
+ @user_url = url_for(my_account_url(user,:token => @token.value))
+
+ @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 = nil
+ if recipients == journal.recipients[0]
+ cc = journal.watcher_recipients - journal.recipients
+ end
+
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
# 用户申请加入项目邮件通知
@@ -237,7 +317,7 @@ class Mailer < ActionMailer::Base
recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
when 'Course'
added_to_url = url_for(:controller => 'files', :action => 'index', :course_id => container)
- added_to = "#{l(:label_course)}: #{container}"
+ added_to = "#{l(:label_course)}: #{container.name}"
recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
when 'Version'
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
@@ -278,13 +358,25 @@ class Mailer < ActionMailer::Base
# news_added(news) => Mail::Message object
# Mailer.news_added(news).deliver => sends an email to the news' project recipients
def news_added(news)
- redmine_headers 'Project' => news.project.identifier
- @author = news.author
- message_id news
- @news = news
- @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
- mail :to => news.recipients,
- :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
+
+ if news.project
+ redmine_headers 'Project' => news.project.identifier
+ @author = news.author
+ message_id news
+ @news = news
+ @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
+ mail :to => news.recipients,
+ :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
+ elsif news.course
+ redmine_headers 'Course' => news.course.id
+ @author = news.author
+ message_id news
+ @news = news
+ recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail }
+ @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
+ mail :to => recipients,
+ :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}"
+ end
end
# Builds a Mail::Message object used to email recipients of a news' project when a news comment is added.
@@ -294,15 +386,28 @@ class Mailer < ActionMailer::Base
# Mailer.news_comment_added(comment) => sends an email to the news' project recipients
def news_comment_added(comment)
news = comment.commented
- redmine_headers 'Project' => news.project.identifier
- @author = comment.author
- message_id comment
- @news = news
- @comment = comment
- @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
- mail :to => news.recipients,
- :cc => news.watcher_recipients,
- :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}"
+ if news.project
+ redmine_headers 'Project' => news.project.identifier
+ @author = comment.author
+ message_id comment
+ @news = news
+ @comment = comment
+ @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
+ mail :to => news.recipients,
+ :cc => news.watcher_recipients,
+ :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}"
+ elsif news.course
+ redmine_headers 'Course' => news.course.id
+ @author = comment.author
+ message_id comment
+ @news = news
+ @comment = comment
+ @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
+ recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail }
+
+ mail :to => recipients,
+ :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}"
+ end
end
# Builds a Mail::Message object used to email the recipients of the specified message that was posted.
@@ -311,18 +416,33 @@ class Mailer < ActionMailer::Base
# message_posted(message) => Mail::Message object
# Mailer.message_posted(message).deliver => sends an email to the recipients
def message_posted(message)
- redmine_headers 'Project' => message.project.identifier,
- 'Topic-Id' => (message.parent_id || message.id)
- @author = message.author
- message_id message
- references message.parent unless message.parent.nil?
- recipients = message.recipients
- cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients)
- @message = message
- @message_url = url_for(message.event_url)
- mail :to => recipients,
- :cc => cc,
- :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}"
+ if message.project
+ redmine_headers 'Project' => message.project.identifier,
+ 'Topic-Id' => (message.parent_id || message.id)
+ @author = message.author
+ message_id message
+ references message.parent unless message.parent.nil?
+ recipients = message.recipients
+ cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients)
+ @message = message
+ @message_url = url_for(message.event_url)
+ mail :to => recipients,
+ :cc => cc,
+ :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}"
+ elsif message.course
+ redmine_headers 'Course' => message.course.id,
+ 'Topic-Id' => (message.parent_id || message.id)
+ @author = message.author
+ message_id message
+ references message.parent unless message.parent.nil?
+ recipients = message.course.notified_users.select { |user| user.allowed_to?(:view_files, message.course) }.collect { |u| u.mail }
+ cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients)
+ @message = message
+ @message_url = url_for(message.event_url)
+ mail :to => recipients,
+ :cc => cc,
+ :subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}"
+ end
end
# Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was added.
@@ -615,5 +735,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/memo.rb b/app/models/memo.rb
index 495f97ad3..165f8e144 100644
--- a/app/models/memo.rb
+++ b/app/models/memo.rb
@@ -47,7 +47,7 @@ class Memo < ActiveRecord::Base
"parent_id",
"replies_count"
- after_create :add_author_as_watcher, :reset_counters!#,:be_user_score -- 公共区发帖暂不计入得分
+ after_create :add_author_as_watcher, :reset_counters!, :sendmail#,:be_user_score -- 公共区发帖暂不计入得分
# after_update :update_memos_forum
after_destroy :reset_counters!#,:down_user_score -- 公共区发帖暂不计入得分
# after_create :send_notification
@@ -58,6 +58,12 @@ class Memo < ActiveRecord::Base
# includes(:forum => ).where()
# }
+ def sendmail
+ thread1=Thread.new do
+ Mailer.forum_message_added(self).deliver if Setting.notified_events.include?('forum_message_added')
+ end
+ end
+
def cannot_reply_to_locked_topic
errors.add :base, l(:label_memo_locked) if root.locked? && self != root
end
diff --git a/app/models/memo_observer.rb b/app/models/memo_observer.rb
new file mode 100644
index 000000000..66cabe923
--- /dev/null
+++ b/app/models/memo_observer.rb
@@ -0,0 +1,8 @@
+class MemoObserver < ActiveRecord::Observer
+ def after_create(memo)
+
+ thread1=Thread.new do
+ Mailer.forum_message_added(memo).deliver if Setting.notified_events.include?('forum_message_added')
+ end
+ end
+end
diff --git a/app/models/poll.rb b/app/models/poll.rb
index 803ee6ac6..06f1369c1 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -3,7 +3,7 @@ class Poll < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :user
- has_many :poll_questions, :dependent => :destroy
+ has_many :poll_questions, :dependent => :destroy,:order => "#{PollQuestion.table_name}.question_number"
has_many :poll_users, :dependent => :destroy
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
end
diff --git a/app/models/poll_question.rb b/app/models/poll_question.rb
index 66dcea67e..2d9912fc2 100644
--- a/app/models/poll_question.rb
+++ b/app/models/poll_question.rb
@@ -3,6 +3,6 @@ class PollQuestion < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :poll
- has_many :poll_answers, :dependent => :destroy
+ has_many :poll_answers, :order => "#{PollAnswer.table_name}.answer_position",:dependent => :destroy
has_many :poll_votes, :dependent => :destroy
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 735b80762..bef65fe54 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -188,7 +188,7 @@ class User < Principal
validates_confirmation_of :password, :allow_nil => true
validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
validate :validate_password_length
-
+ validates_email_realness_of :mail
before_create :set_mail_notification
before_save :update_hashed_password
before_destroy :remove_references_before_destroy
@@ -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/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb
index 2d6c35555..1009f405f 100644
--- a/app/views/bids/_bid_homework_show.html.erb
+++ b/app/views/bids/_bid_homework_show.html.erb
@@ -56,18 +56,30 @@
<%= link_to(bid.name, course_for_bid_path(bid), :class => 'bid_path') %>
-
+ |
<% if User.current.logged? && is_cur_course_student(@course) %>
<% cur_user_homework = cur_user_homework_for_bid(bid) %>
+
+ <% if bid.open_anonymous_evaluation == 1 %>
+ <% case bid.comment_status %>
+ <% when 0 %>
+ 未开启匿评
+ <% when 1 %>
+ 匿评中..
+ <% when 2 %>
+ 匿评结束
+ <% end %>
+ <% end%>
+
<% if cur_user_homework && cur_user_homework.empty? %>
<%= link_to l(:label_commit_homework),new_exercise_book_path(bid) %>
<% else %>
-
- <%= l(:lable_has_commit_homework)%>
-
+
+ 已 提 交
+
<% end %>
<% end %>
<% if (User.current.admin?||User.current.allowed_to?(:as_teacher,@course)) %>
diff --git a/app/views/courses/_course_form.html.erb b/app/views/courses/_course_form.html.erb
index c48d24935..d293f9ed1 100644
--- a/app/views/courses/_course_form.html.erb
+++ b/app/views/courses/_course_form.html.erb
@@ -127,9 +127,7 @@
<%= l(:label_new_course_description) %>
-
+
diff --git a/app/views/courses/_member_list.html.erb b/app/views/courses/_member_list.html.erb
index 41b4f41e7..dd543ec2c 100644
--- a/app/views/courses/_member_list.html.erb
+++ b/app/views/courses/_member_list.html.erb
@@ -56,24 +56,36 @@
<% if @canShowCode %>
- -
- <%= l(:label_bidding_user_studentname) %> :
- <%= link_to member.user.show_name, user_path(member.user) %>
-
-
+ <% if member.user.show_name == '' && member.user.user_extensions.student_id == '' %>
+ -
+ <%= l(:label_username)%>
+ <%= link_to(member.user.name, user_path(member.user)) %>
+
+ <% else %>
+ <% unless member.user.show_name == ''%>
+ -
+ <%= l(:label_bidding_user_studentname) %> :
+ <%= link_to member.user.show_name, user_path(member.user) %>
+
+
+ <% end %>
+ <% unless member.user.user_extensions.student_id == '' %>
+ -
+ <%= l(:label_bidding_user_studentcode) %> :
+ <%= link_to member.user.user_extensions.student_id, user_path(member.user) %>
+
+ <% end %>
+ <% end %>
<%#= content_tag "li", "#{l(:label_bidding_user_studentname)}#{' : '}"link_to(member.user.show_name, user_path(member.user)) %>
<% else %>
- <%= content_tag "li", link_to(member.user.name, user_path(member.user)) %>
- <% end %>
-
-
- <% if @canShowCode %>
-
- <%= l(:label_bidding_user_studentcode) %> :
- <%= link_to member.user.user_extensions.student_id, user_path(member.user) %>
+ <%= l(:label_username)%>
+ <%= link_to(member.user.name, user_path(member.user)) %>
- <%#= content_tag "li", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :style=> "color:#1c9ec7;" %>
- <% end %>
+ <% end %>
+
+
+
<% if @subPage_title == l(:label_student_list) %>
<%= link_to format("%0.2f",member.score.nil? ? 0 : member.score.to_s), {
diff --git a/app/views/courses/_member_list_detail.html.erb b/app/views/courses/_member_list_detail.html.erb
index f37067cb5..bc6cbd242 100644
--- a/app/views/courses/_member_list_detail.html.erb
+++ b/app/views/courses/_member_list_detail.html.erb
@@ -7,24 +7,36 @@
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 40, :height => 40)) %>
<% if @canShowCode %>
- -
- <%= l(:label_bidding_user_studentname) %> :
- <%= link_to member.user.show_name, user_path(member.user) %>
-
-
+ <% if member.user.show_name == '' && member.user.user_extensions.student_id == '' %>
+ -
+ <%= l(:label_username)%>
+ <%= link_to(member.user.name, user_path(member.user)) %>
+
+ <% else %>
+ <% unless member.user.show_name == ''%>
+ -
+ <%= l(:label_bidding_user_studentname) %> :
+ <%= link_to member.user.show_name, user_path(member.user) %>
+
+
+ <% end %>
+ <% unless member.user.user_extensions.student_id == '' %>
+ -
+ <%= l(:label_bidding_user_studentcode) %> :
+ <%= link_to member.user.user_extensions.student_id, user_path(member.user) %>
+
+ <% end %>
+ <% end %>
<%#= content_tag "li", "#{l(:label_bidding_user_studentname)}#{' : '}"link_to(member.user.show_name, user_path(member.user)) %>
<% else %>
- <%= content_tag "li", link_to(member.user.name, user_path(member.user)) %>
- <% end %>
-
-
- <% if @canShowCode %>
-
- <%= l(:label_bidding_user_studentcode) %> :
- <%= link_to member.user.user_extensions.student_id, user_path(member.user) %>
+ <%= l(:label_username)%>
+ <%= link_to(member.user.name, user_path(member.user)) %>
- <%#= content_tag "li", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :style=> "color:#1c9ec7;" %>
<% end %>
+
+
+
<% if @subPage_title == l(:label_student_list) %>
<%= link_to format("%0.2f",member.score.to_s), {
diff --git a/app/views/courses/member.html.erb b/app/views/courses/member.html.erb
index 2599760ad..803be3731 100644
--- a/app/views/courses/member.html.erb
+++ b/app/views/courses/member.html.erb
@@ -56,7 +56,7 @@
<%= stylesheet_link_tag 'course_group', :media => 'all' %>
-
+
<%= @subPage_title %>
diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb
index 48beebdf8..78514daca 100644
--- a/app/views/homework_attach/_addjour.html.erb
+++ b/app/views/homework_attach/_addjour.html.erb
@@ -31,7 +31,7 @@
:url => {:controller => 'homework_attach',
:action => 'addjours',
:homework_id => homework_attach.id,
- :cur_page => cur_page,
+ :page => cur_page,
:cur_type => cur_type,
:is_anonymous_comments => @is_anonymous_comments,
:is_teacher => @is_teacher
diff --git a/app/views/homework_attach/_homework.html.erb b/app/views/homework_attach/_homework.html.erb
index c2b87832c..fca25e8ee 100644
--- a/app/views/homework_attach/_homework.html.erb
+++ b/app/views/homework_attach/_homework.html.erb
@@ -19,7 +19,7 @@
<% else %>
<% homework_filename = homework.name %>
<% end %>
- <%= link_to homework_filename , homework_attach_path(homework,:cur_page => @cur_page,:cur_type => @cur_type), :title => homework_filename, :remote => true%>
+ <%= link_to homework_filename , homework_attach_path(homework,:cur_page => @cur_page,:cur_type => @cur_type,:cur_sort => @cur_sort, :cur_direction => @cur_direction), :title => homework_filename, :remote => true%>
提交时间:
<%= format_time homework.created_at%>
@@ -46,7 +46,7 @@
<% if is_teacher %>
- <%= link_to l(:label_work_rating),homework_attach_path(homework,:cur_page => @cur_page,:cur_type => @cur_type),:remote => true %>
+ <%= link_to l(:label_work_rating),homework_attach_path(homework,:cur_page => @cur_page,:cur_type => @cur_type,:cur_sort => @cur_sort, :cur_direction => @cur_direction),:remote => true %>
<% if Time.parse(bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %>
迟交!
<% end %>
diff --git a/app/views/layouts/_base_feedback.html.erb b/app/views/layouts/_base_feedback.html.erb
index 62b3a01e3..f1c829c1f 100644
--- a/app/views/layouts/_base_feedback.html.erb
+++ b/app/views/layouts/_base_feedback.html.erb
@@ -1,49 +1,122 @@
-
-
-
-
-意见反馈浮窗
+
-
-
-
-
-
-
- <% 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) %>白羽
+
+
+
+
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
index 43adab15f..466e711c2 100644
--- a/app/views/layouts/base_courses.html.erb
+++ b/app/views/layouts/base_courses.html.erb
@@ -47,12 +47,36 @@
|
+
<%= form_tag({:controller => 'courses', :action => 'search'},:id => "course_search_form", :method => :get) do %>
<%= text_field_tag 'name', params[:name], :size => 20, :style => "float:left" %>
-
+
<%= l(:label_search)%>
+
+
<%#= submit_tag l(:label_search), :class => "ButtonColor m3p10", :name => nil, :style => "float:left;padding-top: 3px; margin: 0px;padding-bottom:0px;" %>
<% end %>
@@ -275,6 +299,24 @@
+
+
+
+
+ <%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id)%>
+
+
+
diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb
index 8cae51063..0d234a69c 100644
--- a/app/views/layouts/base_newcontest.html.erb
+++ b/app/views/layouts/base_newcontest.html.erb
@@ -70,7 +70,7 @@
<%= l(:label_search)%>
-
+
<% end %>
|
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb
index 3937c1822..67e4da0f4 100644
--- a/app/views/layouts/base_projects.html.erb
+++ b/app/views/layouts/base_projects.html.erb
@@ -71,7 +71,7 @@
<%= l(:label_search)%>
-
+
<% end %>
diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb
index dd2de21b7..abb896b61 100644
--- a/app/views/layouts/mailer.html.erb
+++ b/app/views/layouts/mailer.html.erb
@@ -1,33 +1,52 @@
+Trustie项目邮件
+
+
+
+
-
-
-<%= yield %>
-
-
+
+
+
+
+
+
<%= l(:mail_issue_greetings)%>
+
+ <%= yield %>
+
+
+
+
diff --git a/app/views/mailer/_issue.html.erb b/app/views/mailer/_issue.html.erb
index f0dc88d8b..cd5fbc091 100644
--- a/app/views/mailer/_issue.html.erb
+++ b/app/views/mailer/_issue.html.erb
@@ -1,15 +1,50 @@
-<%= link_to(h("#{issue.tracker.name} ##{issue.project_index}: #{issue.subject}"), issue_url) %>
-
-
-- <%=l(:field_author)%>: <%=h issue.author %>
-- <%=l(:field_status)%>: <%=h issue.status %>
-- <%=l(:field_priority)%>: <%=h issue.priority %>
-- <%=l(:field_assigned_to)%>: <%=h issue.assigned_to %>
-- <%=l(:field_category)%>: <%=h issue.category %>
-- <%=l(:field_fixed_version)%>: <%=h issue.fixed_version %>
-<% issue.custom_field_values.each do |c| %>
- - <%=h c.custom_field.name %>: <%=h show_value(c) %>
-<% end %>
+
+
+
+ <%= link_to(h("#{@issue.author}(#{@issue.author.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %>
+ <%= l(:mail_issue_title_userin)%>
+ <%= link_to(h("#{@issue.project.name}"), @project_url, :style=>'color:#1b55a7; font-weight:bold;') %><%= l(:mail_issue_title_active)%>
+
+
+ - <%= l(:mail_issue_subject)%><%= link_to(issue.subject, issue_url, :style=>'color:#1b55a7; font-weight:bold;') %>
+ - <%= l(:mail_issue_sent_from)%><%= issue.project.name %>| <%= l(:mail_issue_from_project)%>
+ - <%= l(:mail_issue_content)%>
+
+ <% if @journal.nil? %>
+ <%= issue.description %>
+ <% else %>
+ <%= @journal.notes %>
+ <% end%>
+
+
+ -
+
+ <% unless @issue.attachments.nil? %>
+ <%= l(:mail_issue_attachments)%>
+
+ <% @issue.attachments.each do |attach| %>
+
<%= link_to_attachment(attach, :download => true, :token => @token.value, :only_path => false, :style=>'color:#1b55a7; font-weight:bold;')%>
+ <% end %>
+ <% end %>
+
+
+
+
+
+
+
+
+<%# issue.custom_field_values.each do |c| %>
+
diff --git a/app/views/mailer/_issue.text.erb b/app/views/mailer/_issue.text.erb
index 7ab8acfeb..8848e494a 100644
--- a/app/views/mailer/_issue.text.erb
+++ b/app/views/mailer/_issue.text.erb
@@ -1,13 +1,23 @@
-<%= "#{issue.tracker.name} ##{issue.project_index}: #{issue.subject}" %>
-<%= issue_url %>
-
-* <%=l(:field_author)%>: <%= issue.author %>
-* <%=l(:field_status)%>: <%= issue.status %>
-* <%=l(:field_priority)%>: <%= issue.priority %>
-* <%=l(:field_assigned_to)%>: <%= issue.assigned_to %>
-* <%=l(:field_category)%>: <%= issue.category %>
-* <%=l(:field_fixed_version)%>: <%= issue.fixed_version %>
-<% issue.custom_field_values.each do |c| %>* <%= c.custom_field.name %>: <%= show_value(c) %>
-<% end -%>
-----------------------------------------
-<%= issue.description %>
+
+ <%= link_to(h("#{@issue.author}(#{@issue.author.show_name})"), @issue_author_url) %>
+ <%= l(:mail_issue_title_userin)%>
+ <%= link_to(h("#{@issue.project.name}"),@project_url) %><%= l(:mail_issue_title_active)%>
+<%= l(:mail_issue_subject)%><%= link_to(issue.subject, issue_url) %>
+<%= l(:mail_issue_sent_from)%>| <%= l(:mail_issue_from_project)%>
+<%= l(:mail_issue_content)%>
+ <% if @journal.nil? %>
+ <%= issue.description %>
+ <% else %>
+ <%= @journal.notes %>
+ <% end%>
+ <% unless @issue.attachments.nil? %>
+<%= l(:mail_issue_attachments)%>
+
+
+ <% @issue.attachments.each do |attach| %>
+ <%= link_to_attachment(attach, :download => true, :token => @token.value, :only_path => false) %><%= l(:label_added) %>
+ <% end %>
+ <% end %>
+
+
+ <%= link_to( l(:mail_issue_reply), issue_url) %>
diff --git a/app/views/mailer/forum_add.html.erb b/app/views/mailer/forum_add.html.erb
new file mode 100644
index 000000000..8da8b7891
--- /dev/null
+++ b/app/views/mailer/forum_add.html.erb
@@ -0,0 +1,4 @@
+<%= link_to(h(@forum.name), @forum_url) %>
+<%=h @forum.creator.name %>
+
+<%= @forum.description.html_safe %>
\ No newline at end of file
diff --git a/app/views/mailer/forum_add.text.erb b/app/views/mailer/forum_add.text.erb
new file mode 100644
index 000000000..ba7246a49
--- /dev/null
+++ b/app/views/mailer/forum_add.text.erb
@@ -0,0 +1,4 @@
+<%= @forum_url %>
+<%= @author.name %>
+
+<%= @forum.description %>
diff --git a/app/views/mailer/forum_message_added.html.erb b/app/views/mailer/forum_message_added.html.erb
new file mode 100644
index 000000000..743c06ae7
--- /dev/null
+++ b/app/views/mailer/forum_message_added.html.erb
@@ -0,0 +1,4 @@
+<%= link_to(h(@memo.subject), @memo_url) %>
+<%=h @memo.author.name %>
+
+<%= @memo.content.html_safe %>
\ No newline at end of file
diff --git a/app/views/mailer/forum_message_added.text.erb b/app/views/mailer/forum_message_added.text.erb
new file mode 100644
index 000000000..bd084cd40
--- /dev/null
+++ b/app/views/mailer/forum_message_added.text.erb
@@ -0,0 +1,5 @@
+<%= @memo_url %>
+<%= @author.name %>
+
+<%= @memo.subject %>
+<%= @memo.content %>
diff --git a/app/views/mailer/issue_add.html.erb b/app/views/mailer/issue_add.html.erb
index 8c9da02da..0b60097a7 100644
--- a/app/views/mailer/issue_add.html.erb
+++ b/app/views/mailer/issue_add.html.erb
@@ -1,3 +1,9 @@
-<%= l(:text_issue_added, :id => "##{@issue.project_index}", :author => h(@issue.author)) %>
-
-<%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %>
+
+
+
+ <%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %>
+
+
+
+
+
diff --git a/app/views/mailer/issue_add.text.erb b/app/views/mailer/issue_add.text.erb
index dbba47d49..c5b391685 100644
--- a/app/views/mailer/issue_add.text.erb
+++ b/app/views/mailer/issue_add.text.erb
@@ -1,4 +1,3 @@
-<%= l(:text_issue_added, :id => "##{@issue.project_index}", :author => @issue.author) %>
-----------------------------------------
<%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %>
+<%= link_to( l(:mail_issue_footer), @user_url) %>
\ No newline at end of file
diff --git a/app/views/mailer/issue_edit.html.erb b/app/views/mailer/issue_edit.html.erb
index be7076cb6..f7412402c 100644
--- a/app/views/mailer/issue_edit.html.erb
+++ b/app/views/mailer/issue_edit.html.erb
@@ -1,11 +1,11 @@
-<%= l(:text_issue_updated, :id => "##{@issue.project_index}", :author => h(@journal.user)) %>
+
+ <%= l(:text_issue_updated, :id => "##{@issue.project_index}", :author => h(@journal.user)) %>
-
-<% details_to_strings(@journal.details, false, :only_path => false).each do |string| %>
- - <%= string %>
-<% end %>
-
+
+
+
+
-<%= textilizable(@journal, :notes, :only_path => false) %>
-
<%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %>
+
+
diff --git a/app/views/mailer/issue_edit.text.erb b/app/views/mailer/issue_edit.text.erb
index 45b8d3ecf..1434a7a33 100644
--- a/app/views/mailer/issue_edit.text.erb
+++ b/app/views/mailer/issue_edit.text.erb
@@ -1,12 +1,8 @@
<%= l(:text_issue_updated, :id => "##{@issue.project_index}", :author => @journal.user) %>
-<% details_to_strings(@journal.details, true).each do |string| -%>
-<%= string %>
-<% end -%>
-<% if @journal.notes? -%>
-<%= @journal.notes %>
-<% end -%>
-----------------------------------------
+--------------------------------------------------------------------------------
<%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %>
+
+<%= link_to( l(:mail_issue_footer), @user_url) %>
\ No newline at end of file
diff --git a/app/views/mailer/message_posted.html.erb b/app/views/mailer/message_posted.html.erb
index f43a8cf0f..4bb487405 100644
--- a/app/views/mailer/message_posted.html.erb
+++ b/app/views/mailer/message_posted.html.erb
@@ -1,4 +1,10 @@
-<%=h @message.board.project.name %> - <%=h @message.board.name %>: <%= link_to(h(@message.subject), @message_url) %>
+
+ <% if @message.project %>
+ <%=h @message.board.project.name %> - <%=h @message.board.name %>: <%= link_to(h(@message.subject), @message_url) %>
+ <% elsif @message.course %>
+ <%=h @message.board.course.name %> - <%=h @message.board.name %>: <%= link_to(h(@message.subject), @message_url) %>
+ <% end %>
+
<%=h @message.author %>
<%= textilizable(@message, :content, :only_path => false) %>
diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb
index 597229369..47cfb4221 100644
--- a/app/views/my/account.html.erb
+++ b/app/views/my/account.html.erb
@@ -123,10 +123,10 @@
-
-
-