|
|
|
@ -33,7 +33,7 @@ class ProjectsController < ApplicationController
|
|
|
|
|
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar]
|
|
|
|
|
before_filter :file, :statistics #:watcherlist
|
|
|
|
|
# 除非项目内人员,不可查看成员, TODO: 完了写报表里去
|
|
|
|
|
before_filter :memberAccess, only: :member
|
|
|
|
|
# before_filter :memberAccess, only: :member
|
|
|
|
|
|
|
|
|
|
# accept_rss_auth :index
|
|
|
|
|
accept_api_auth :index, :show, :create, :update, :destroy
|
|
|
|
@ -358,24 +358,57 @@ class ProjectsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 项目邀请用户加入实现过程
|
|
|
|
|
# 两种情况:1、系统外用户;2、系统内用户 (通过邮件判定)
|
|
|
|
|
def send_mail_to_member
|
|
|
|
|
# 该邮箱未注册过
|
|
|
|
|
if !params[:mail].blank? && User.find_by_mail(params[:mail].to_s).nil?
|
|
|
|
|
email = params[:mail]
|
|
|
|
|
Mailer.run.send_invite_in_project(email, @project, User.current)
|
|
|
|
|
@is_zhuce = false
|
|
|
|
|
flash[:notice] = l(:notice_email_sent, :value => email)
|
|
|
|
|
if !User.where("login =?", params[:mail]).first.nil?
|
|
|
|
|
# 用户名唯一,用户修改邮箱,未修改用户名,用户名等同邮箱的情况,默认改用户已经注册
|
|
|
|
|
user = User.find_by_login(params[:mail].to_s)
|
|
|
|
|
if !user.member_of?(@project)
|
|
|
|
|
# 如果已经邀请过该用户,则不重复发送
|
|
|
|
|
if InviteList.where("project_id =? and mail =?", @project.id, params[:mail].to_s).first.nil?
|
|
|
|
|
email = params[:mail]
|
|
|
|
|
Mailer.request_member_to_project(email, @project, User.current).deliver
|
|
|
|
|
flash[:notice] = l(:notice_email_sent, :value => email)
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = l(:notice_email_invited)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = l(:label_member_of_project, :value => email)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
email = params[:mail]
|
|
|
|
|
Mailer.send_invite_in_project(email, @project, User.current).deliver
|
|
|
|
|
@is_zhuce = false
|
|
|
|
|
flash[:notice] = l(:notice_email_sent, :value => email)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 邮箱地址已被注册
|
|
|
|
|
elsif !User.find_by_mail(params[:mail].to_s).nil?
|
|
|
|
|
user = User.find_by_mail(params[:mail].to_s)
|
|
|
|
|
if !user.member_of?(@project)
|
|
|
|
|
email = params[:mail]
|
|
|
|
|
Mailer.run.request_member_to_project(email, @project, User.current)
|
|
|
|
|
flash[:notice] = l(:notice_email_sent, :value => email)
|
|
|
|
|
# 如果已经邀请过该用户,则不重复发送
|
|
|
|
|
invite_list = InviteList.where("project_id =? and mail =?", @project.id, params[:mail].to_s).first
|
|
|
|
|
if invite_list.nil?
|
|
|
|
|
email = params[:mail]
|
|
|
|
|
Mailer.request_member_to_project(email, @project, User.current).deliver
|
|
|
|
|
flash[:notice] = l(:notice_email_sent, :value => email)
|
|
|
|
|
else
|
|
|
|
|
# 已经发送过了,则隔3小时才能再次发送
|
|
|
|
|
if Time.now - invite_list.created_at > 10800
|
|
|
|
|
email = params[:mail]
|
|
|
|
|
Mailer.request_member_to_project(email, @project, User.current).deliver
|
|
|
|
|
flash[:notice] = l(:notice_email_sent, :value => email)
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = l(:notice_email_invited)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = l(:label_member_of_project, :value => email)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = l(:notice_registed_error, :value => email)
|
|
|
|
|
@is_zhuce = true
|
|
|
|
|
end
|
|
|
|
|
respond_to do |format|
|
|
|
|
@ -383,25 +416,26 @@ class ProjectsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#发送邮件邀请新用户
|
|
|
|
|
# 发送邮件邀请新用户页面对应方法
|
|
|
|
|
def invite_members_by_mail
|
|
|
|
|
if User.current.member_of?(@project) || User.current.admin?
|
|
|
|
|
@inviter_lists = InviteList.where(project_id:@project.id).all
|
|
|
|
|
@inviters = []
|
|
|
|
|
@waiters = []
|
|
|
|
|
unless @inviter_lists.blank?
|
|
|
|
|
@inviter_lists.each do|inviter_list|
|
|
|
|
|
unless inviter_list.user.nil?
|
|
|
|
|
if inviter_list.user.member_of?(@project)
|
|
|
|
|
@inviters << inviter_list.user
|
|
|
|
|
@inviters_count = @inviters.size
|
|
|
|
|
else
|
|
|
|
|
@waiters << inviter_list.user
|
|
|
|
|
@waiters_count = @waiters.size
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@inviter_lists = InviteList.where(project_id:@project.id).order("created_at desc")
|
|
|
|
|
|
|
|
|
|
# @inviters = []
|
|
|
|
|
# @waiters = []
|
|
|
|
|
# unless @inviter_lists.blank?
|
|
|
|
|
# @inviter_lists.each do|inviter_list|
|
|
|
|
|
# unless inviter_list.user.nil?
|
|
|
|
|
# if inviter_list.user.member_of?(@project)
|
|
|
|
|
# @inviters << inviter_list.user
|
|
|
|
|
# @inviters_count = @inviters.size
|
|
|
|
|
# else
|
|
|
|
|
# @waiters << inviter_list.user
|
|
|
|
|
# @waiters_count = @waiters.size
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
@is_zhuce = false
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html
|
|
|
|
@ -413,16 +447,16 @@ class ProjectsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 邀请Trustie注册用户
|
|
|
|
|
def invite_members
|
|
|
|
|
if User.current.member_of?(@project) || User.current.admin?
|
|
|
|
|
@member ||= @project.members.new
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
render_403
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
# def invite_members
|
|
|
|
|
# if User.current.member_of?(@project) || User.current.admin?
|
|
|
|
|
# @member ||= @project.members.new
|
|
|
|
|
# respond_to do |format|
|
|
|
|
|
# format.html
|
|
|
|
|
# end
|
|
|
|
|
# else
|
|
|
|
|
# render_403
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
def edit
|
|
|
|
|
end
|
|
|
|
@ -451,6 +485,10 @@ class ProjectsController < ApplicationController
|
|
|
|
|
flash[:notice] = l(:label_mail_invite_success)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
# 私有项目非项目成员无法访问成员列表
|
|
|
|
|
unless @project.is_public?
|
|
|
|
|
return render_403 unless User.current.member_of?(@project)
|
|
|
|
|
end
|
|
|
|
|
## 有角色参数的才是课程,没有的就是项目
|
|
|
|
|
@render_file = 'project_member_list'
|
|
|
|
|
# 判断是否课程
|
|
|
|
|