diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index cdbcc36cb..217c47866 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -357,13 +357,26 @@ class ProjectsController < ApplicationController end + # 项目邀请用户加入实现过程 # 两种情况:1、系统外用户;2、系统内用户 (通过邮件判定) def send_mail_to_member # 该邮箱未注册过 if !params[:mail].blank? && User.find_by_mail(params[:mail].to_s).nil? if !User.where("login =?", params[:mail]).first.nil? - # 用户名唯一,如果该邮箱被用户作为用户名使用则跳出 - flash[:error] = l(:notice_email_login_used) + # 用户名唯一,用户修改邮箱,未修改用户名,用户名等同邮箱的情况,默认改用户已经注册 + 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 @@ -393,7 +406,7 @@ 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 @@ -461,9 +474,9 @@ 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' diff --git a/app/views/mailer/request_member_to_project.html.erb b/app/views/mailer/request_member_to_project.html.erb index 7c0d25dbb..c2da231a3 100644 --- a/app/views/mailer/request_member_to_project.html.erb +++ b/app/views/mailer/request_member_to_project.html.erb @@ -4,9 +4,9 @@
  • <%= l(:mail_issue_content)%> -

    <%= @invitor_name %> 邀请您加入项目:<%= @project_name %>

    +

    <%= @invitor_name %> 邀请您加入项目:<%=link_to @project_name, project_url(@project) %>

    -

    点击“同意加入”按钮,即可快速加入项目!


    +

    点击“同意加入”按钮,即可快速加入项目,查看项目相关信息!


    diff --git a/app/views/mailer/send_invite_in_project.html.erb b/app/views/mailer/send_invite_in_project.html.erb index ec559732f..d752d6060 100644 --- a/app/views/mailer/send_invite_in_project.html.erb +++ b/app/views/mailer/send_invite_in_project.html.erb @@ -9,6 +9,7 @@

    <%= link_to @project_url, @project_url%>

    您的账号为:<%= @email %>

    密码为: <%= @password %>

    +

    为了您的账号安全,请勿将邮件信息告知他人!

  • diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 19271d93d..a979d7fff 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -52,7 +52,7 @@ zh: notice_not_authorized_archived_project: 要访问的项目已经归档。 notice_not_authorized_message: 您访问的消息不存在! notice_email_sent: "邮件已发送至 %{value}" - notice_email_login_used: 无法自动为该邮箱注册新用户,该邮箱地址已经有人作为登录名使用,您可以通过平台的注册功能为该用户注册账号! + notice_email_login_used: 无法自动为该邮箱注册新用户,该邮箱地址已经有人作为登录名使用! notice_email_invited: 已经向该邮箱发送过邀请,正在等待对方的回复! notice_email_error: "发送邮件时发生错误 (%{value})" notice_feeds_access_key_reseted: 您的RSS存取键已被重置。