diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 2232602aa..923414583 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -113,12 +113,8 @@ class IssuesController < ApplicationController
def show
# 当前用户查看指派给他的缺陷消息,则设置消息为已读
- query = @issue.forge_messages
- query.each do |m|
- if m.user_id == User.current.id
- m.update_attribute(:viewed, true)
- end
- end
+ query = ForgeMessage.where("forge_message_type =? and user_id =? and forge_message_id =?", "Issue", User.current, @issue).first
+ query.update_attribute(:viewed, true) unless query.nil?
# 缺陷状态更新
query_journals = @issue.journals
query_journals.each do |query_journal|
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 251c47d4c..a8a302045 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -382,7 +382,10 @@ class ProjectsController < ApplicationController
end
else
email = params[:mail]
- Mailer.send_invite_in_project(email, @project, User.current).deliver
+ first_name = params[:first_name]
+ last_name = params[:last_name]
+ gender = params[:gender]
+ Mailer.send_invite_in_project(email, @project, User.current, first_name, last_name, gender).deliver
@is_zhuce = false
flash[:notice] = l(:notice_email_sent, :value => email)
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 73a26b52c..ae0b4d7c9 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -112,10 +112,17 @@ class UsersController < ApplicationController
case params[:type]
when nil
@message_alls = []
- messages = MessageAll.where("user_id =?" ,@user).order("created_at desc")
+ system_message_types = MessageAll.where("message_type =?", "SystemMessage").order("created_at desc")
+ messages = MessageAll.where("user_id =? and message_type !=?" ,@user, "SystemMessage").order("created_at desc")
messages.each do |message_all|
@message_alls << message_all.message
end
+ # 系统消息需要给每个人发送,之所以这样做,可以避免遍历系统所有用户
+ system_message_types.each do |system_message_type|
+ @message_alls << system_message_type.message
+ end
+ # 取出所有符合条件的按照创建时间排序
+ @message_alls = @message_alls.sort {|a,b| b.created_at <=> a.created_at}
when 'unviewed'
@message_alls = []
messages = MessageAll.where("user_id =?", @user).order("created_at desc")
@@ -128,13 +135,13 @@ class UsersController < ApplicationController
# when 'system_messages'
# @message_alls = SystemMessage.order("created_at desc").all
when 'apply'
- @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?" , "AppliedProject", @user).order("created_at desc")
+ @message_alls = ForgeMessage.where("forge_message_type in ('ProjectInvite', 'AppliedProject') and user_id =?", @user).order("created_at desc")
when 'homework'
@message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage') and user_id =?", @user).order("created_at desc")
when 'course_message'
@message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc")
- # when 'forge_message'
- # @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user).order("created_at desc")
+ when 'forge_message'
+ @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user).order("created_at desc")
# @message_alls_count = @message_alls.count
when 'course_news'
# 课程通知包含发布的通知和回复的通知
@@ -187,12 +194,8 @@ class UsersController < ApplicationController
message_new_time.onclick_time = Time.now
message_new_time.save
else
- # 24小时内显示
- contrast_time = Time.now - 86400
message_time.update_attributes(:onclick_time => Time.now)
end
- # 24小时内显示系统消息
- @user_system_messages = SystemMessage.where("created_at >?", contrast_time).order("created_at desc")
end
# 消息设置为已读
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 39e709beb..d797f1ce1 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -107,7 +107,7 @@ class Mailer < ActionMailer::Base
# author: alan
# 邀请未注册用户加入项目
# 功能: 在加入项目的同时自动注册用户
- def send_invite_in_project(email, project, invitor)
+ def send_invite_in_project(email, project, invitor, first_name, last_name, gender)
@email = email
@subject = "#{invitor.name} #{l(:label_invite_project)} #{project.name} "
@password = newpass(6)
@@ -116,7 +116,7 @@ class Mailer < ActionMailer::Base
login = login.sub(/%40/,'@')
us = UsersService.new
# 自动激活用户
- user = us.register_auto(login, email, @password)
+ user = us.register_auto(login, email, @password, first_name, last_name, gender)
InviteList.create(:user_id => user.id, :project_id => project.id, :mail =>email)
User.current = user unless User.current.nil?
@user = user
diff --git a/app/models/system_message.rb b/app/models/system_message.rb
index 2a810e8b8..a05610da7 100644
--- a/app/models/system_message.rb
+++ b/app/models/system_message.rb
@@ -5,4 +5,15 @@ class SystemMessage < ActiveRecord::Base
validates :subject, presence: true
# validates :description, presence: true
validates_length_of :description, maximum: 10000
+
+ has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
+
+ # 系统消息放置总消息列表
+ after_create :add_system_message
+
+ def add_system_message
+ if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
+ self.message_alls << MessageAll.new(:user_id => self.user_id)
+ end
+ end
end
diff --git a/app/services/users_service.rb b/app/services/users_service.rb
index 7e8e775ed..236dbc731 100644
--- a/app/services/users_service.rb
+++ b/app/services/users_service.rb
@@ -47,12 +47,16 @@ class UsersService
end
# 自动注册功能 FOR:邮件邀请
- def register_auto(login,mail,password)
+ def register_auto(login, mail, password, first_name, last_name, gender)
+ mail_notification = "day"
@user = User.new
@user.admin = false
@user.register
@user.login = login
@user.mail = mail
+ @user.firstname = first_name
+ @user.lastname = last_name
+ @user.mail_notification = mail_notification
password_confirmation = password
should_confirmation_password = true
if !password.blank? && !password_confirmation.blank? && should_confirmation_password
@@ -65,6 +69,7 @@ class UsersService
@user = automatically_register_lock(@user)
if @user.id != nil
ue = @user.user_extensions ||= UserExtensions.new
+ ue.gender = gender
ue.user_id = @user.id
ue.save
end
diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb
index d0cbc1f6b..fbbe40a93 100644
--- a/app/views/layouts/_logined_header.html.erb
+++ b/app/views/layouts/_logined_header.html.erb
@@ -112,7 +112,7 @@
$("#navHomepageSearchType").hide();
});
- $("#user_avatar img").mouseenter(function(){
+ $("#navHomepageProfile").mouseenter(function(){
$("#homepageProfileMenuIcon").addClass("homepageProfileMenuIconhover");
$("#topnav_login_list").show();
});
diff --git a/app/views/projects/invite_members_by_mail.html.erb b/app/views/projects/invite_members_by_mail.html.erb
index 44c571422..32a124078 100644
--- a/app/views/projects/invite_members_by_mail.html.erb
+++ b/app/views/projects/invite_members_by_mail.html.erb
@@ -44,9 +44,39 @@
}
+ function verifyLastName() {
+ var last_name = $.trim($('#last_name').val());
+ if(last_name.length > 30)
+ {
+ $("#valid_email").text("用户姓氏过长,最长为30个字符");
+ return false;
+ }
+ else
+ {
+ $("#valid_email").text("");
+ return true;
+ }
+
+ }
+
+ function verifyFirstName() {
+ var first_name = $.trim($('#first_name').val());
+ if(first_name.length > 30)
+ {
+ $("#valid_email").text("用户名字过长,最长为30个字符");
+ return false;
+ }
+ else
+ {
+ $("#valid_email").text("");
+ return true;
+ }
+
+ }
+
function senderEmail(obj)
{
- if(verifyAddress())
+ if(verifyAddress() && verifyFirstName() && verifyLastName() )
{
obj.parent().submit();
}
@@ -79,6 +109,15 @@
<%= text_field_tag 'mail', '', :class => "fb_item fl", :placeholder => l(:label_input_email), :onkeyup => "this.value=this.value.replace(' ','')", :style => "ime-mode:disabled;", :onblur => "verifyAddress(this);" %>
+
+ <%= text_field_tag 'last_name', '', :class => "fb_item_first_name fl", :placeholder => l(:label_input_email_lastname), :onkeyup => "this.value=this.value.replace(' ','')", :style => "ime-mode:disabled;", :onblur => "verifyLastName(this);" %>
+
+
+ <%= text_field_tag 'first_name', '', :class => "fb_item_last_name fl", :placeholder => l(:label_input_email_firstname), :onkeyup => "this.value=this.value.replace(' ','')", :style => "ime-mode:disabled;", :onblur => "verifyFirstName(this);" %>
+
+
+ 性别 男 女
+
diff --git a/app/views/users/_user_message_system.html.erb b/app/views/users/_user_message_system.html.erb
new file mode 100644
index 000000000..efbd5d76b
--- /dev/null
+++ b/app/views/users/_user_message_system.html.erb
@@ -0,0 +1,30 @@
+<% if ma.class == SystemMessage %>
+ <%# @user_system_messages.each do |usm| %>
+
+
+ <%= image_tag("/images/logo.png", width: "30px", height: "30px", class: "mt3") %>
+
+
+ Trustie平台 发布新消息:
+
+ 【系统消息】
+
+
+ <%= link_to ma.subject.blank? ? (ma.content.nil? ? ma.description.html_safe : ma.content.html_safe) : ma.subject, user_system_messages_path(User.current),
+ :id => "content_link_#{ma.id}",
+ :onmouseover =>"message_titile_show($(this),event);",
+ :onmouseout => "message_titile_hide($(this));"
+ %>
+
+
+ <% unless ma.subject.blank? %>
+
标题: <%= ma.subject %>
+ <% end %>
+ <% if (!ma.description.blank?) || (!ma.content.blank?) %>
+
内容:
<%= ma.description.nil? ? ma.content.html_safe : ma.description.html_safe %>
+ <% end %>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <%# end %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb
index bd794438c..84d5ec1bf 100644
--- a/app/views/users/user_messages.html.erb
+++ b/app/views/users/user_messages.html.erb
@@ -5,7 +5,7 @@
<%= link_to "全部",user_message_path(User.current), :class => "resourcesGrey" %>
<%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "resourcesGrey" %>
- <%= link_to "用户申请", user_message_path(User.current, :type => 'apply'), :class => "resourcesGrey" %>
+ <%= link_to "加入项目", user_message_path(User.current, :type => 'apply'), :class => "resourcesGrey" %>
<%# 课程相关消息 %>
<%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "resourcesGrey" %>
<%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "resourcesGrey" %>
@@ -17,7 +17,7 @@
<%# 项目相关消息 %>
<%= link_to "项目任务", user_message_path(User.current, :type => 'issue'), :class => "resourcesGrey" %>
-
+ <%= link_to "项目讨论区", user_message_path(User.current, :type => 'forge_message'), :class => "resourcesGrey" %>
<%# 项目相关消息 %>
@@ -41,40 +41,13 @@
<% end %>
<% end %>
- <%# 系统消息 %>
- <% if params[:type] != 'system_messages' %>
- <% @user_system_messages.each do |usm| %>
-
-
- <%= image_tag("/images/logo.png", width: "30px", height: "30px", class: "mt3") %>
-
-
- Trustie平台 发布新消息:
-
- 【系统消息】
-
-
- <%= link_to usm.subject.blank? ? (usm.content.nil? ? usm.description.html_safe : usm.content.html_safe) : usm.subject, user_system_messages_path(User.current),
- :id => "content_link_#{usm.id}",
- :onmouseover =>"message_titile_show($(this),event);",
- :onmouseout => "message_titile_hide($(this));"
- %>
-
-
- <% unless usm.subject.blank? %>
-
标题: <%= usm.subject %>
- <% end %>
- <% if (!usm.description.blank?) || (!usm.content.blank?) %>
-
内容:
<%= usm.description.nil? ? usm.content.html_safe : usm.description.html_safe %>
- <% end %>
-
- <%= time_tag(usm.created_at).html_safe %>
-
- <% end %>
- <% end %>
+
<% unless @message_alls.nil? %>
<% @message_alls.each do |ma| %>
+ <%# 系统消息 %>
+ <%= render :partial => 'users/user_message_system', :locals => {:ma => ma} %>
+
<%# 课程消息 %>
<%= render :partial => 'users/user_message_course', :locals => {:ma => ma} %>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 69288d933..5efe4a2cc 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -2024,7 +2024,11 @@ zh:
label_end_time: 截止时间
label_send_email: 确定发送
- label_input_email: 请输入邮箱地址
+ label_input_email: 请输入邮箱地址(必填)
+ label_input_email_firstname: 请输入用户名字(可选)
+ label_input_email_lastname: 请输入用户姓氏(可选)
+ label_input_email_gender: 请输入用户性别
+
#api end
project_module_files: 资源库
diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css
index 1d2116874..5d31c3984 100644
--- a/public/stylesheets/new_user.css
+++ b/public/stylesheets/new_user.css
@@ -447,8 +447,8 @@ a.resourcesTypeUser {background:url(images/homepage_icon.png) -178px -453px no-r
/*.resourcesUploadBox {float:right; width:103px; height:34px; background-color:#64bdd9; line-height:34px; vertical-align:middle; text-align:center; margin-left:12px;}*/
/*.resourcesUploadBox:hover {background-color:#0781b4;}*/
/* 个人主页右边部分*/
-.homepageSearchIcon {width:30px; height:32px; background:url(images/nav_icon.png) -8px 3px no-repeat; float:left;}
-input.homepageSearchIcon:hover {cursor: pointer;background:url(../images/nav_icon.png) -49px 3px no-repeat;}
+.homepageSearchIcon {width:30px; height:32px; background:url(images/nav_icon.png) -8px 3px no-repeat; float:left; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
+input.homepageSearchIcon:hover {cursor: pointer;background:url(../images/nav_icon.png) -49px 3px no-repeat; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
a.homepagePostTypeQuiz {background:url(images/homepage_icon.png) -90px -124px no-repeat; padding-left:23px;}
a.homepagePostTypeAssignment {background:url(images/homepage_icon.png) -93px -318px no-repeat; padding-left:23px;}
a.replyGrey {color:#888888; display:inline-block;}
@@ -803,17 +803,17 @@ a.sortArrowActiveU {background:url(images/post_image_list.png) -17px -20px no-re
.postDetailCreater {color:#888888; font-size:12px; float:left; margin-right:25px;}
.postDetailDate {color:#888888; font-size:12px; float:left;}
.postDetailReply { margin-top:28px; color:#888888; float:right;}
-a.postReplyIcon {background:url(images/post_image_list.png) -40px 2px no-repeat; width:18px; height:18px; float:left;}
-a.postReplyIcon:hover {background:url(images/post_image_list.png) -40px -29px no-repeat;}
+a.postReplyIcon {background:url(images/post_image_list.png) -40px 2px no-repeat; width:18px; height:18px; float:left; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
+a.postReplyIcon:hover {background:url(images/post_image_list.png) -40px -29px no-repeat; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
.postDetailInput {width:713px; height:28px; border:1px solid #d9d9d9; outline:none !important;}
.postAttIcon {background:url(images/post_image_list.png) 0px -91px no-repeat; width:16px; height:16px; padding-left:20px;}
.postAttIcon:hover {background:url(images/post_image_list.png) 0px -113px no-repeat;}
.postThemeContainer {width:720px;}
.postThemeWrap {width:655px; float:left;position: relative}
-.postLikeIcon {background:url(images/post_image_list.png) 0px -42px no-repeat ;float:right; padding-left:18px; margin-top:3px;}
-.postLikeIcon:hover {background:url(images/post_image_list.png) 0px -64px no-repeat ;}
-a.AnnexBtn{ background: url(images/homepage_icon2.png) 0px -343px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888;}
-a:hover.AnnexBtn{background: url(images/homepage_icon2.png) -90px -343px no-repeat !important; color:#3598db;}
+.postLikeIcon {background:url(images/post_image_list.png) 0px -42px no-repeat ;float:right; padding-left:18px; margin-top:3px; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
+.postLikeIcon:hover {background:url(images/post_image_list.png) 0px -64px no-repeat ; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
+a.AnnexBtn{ background: url(images/homepage_icon2.png) 0px -343px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
+a:hover.AnnexBtn{background: url(images/homepage_icon2.png) -90px -343px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
.postEdit {background:url(images/post_image_list.png) 0px -94px no-repeat; width:18px; height:18px; display:block; float:left;}
.postDelete {background:url(images/post_image_list.png) -42px -93px no-repeat; width:18px; height:18px; display:block; float:right;}
.pageBanner {width:968px; margin:0px auto; border:1px solid #dddddd; background-color: #FFF; padding: 10px 15px; float:left;}
diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css
index f769ff9e6..e044f9d51 100644
--- a/public/stylesheets/project.css
+++ b/public/stylesheets/project.css
@@ -44,7 +44,10 @@ a:hover.box_close{background:url(../images/img_floatbox.png) -22px 0 no-repeat;}
.box_main02{ width:390px; margin:15px auto;}
.box_h3{ color:#15bccf; font-size:16px;}
.box_p{ color:#404040; margin-bottom:5px;}
-.fb_item{ color:#919191; border:1px solid #919191; height:28px; margin-bottom:5px; padding-left:5px; width:290px;}
+.fb_item{ color:#919191; border:1px solid #919191; height:28px; margin-bottom:5px; padding-left:5px; width:200px;}
+.fb_item_first_name{ color:#919191; border:1px solid #919191; height:28px; margin-bottom:5px; padding-left:5px; width:150px;margin-left: 10px;}
+.fb_item_last_name{ color:#919191; border:1px solid #919191; height:28px; margin-bottom:5px; padding-left:5px; width:150px;margin-left: 10px;}
+.fb_item_gender{ color:#919191; border:1px solid #919191; height:29px; margin-bottom:5px; padding-left:5px; width:58px;margin-left: 10px;}
a.icon_addm{ background:url(../images/img_floatbox.png) 0 -33px no-repeat; width:16px; height:16px; display:block; margin:5px 0 0 5px;}
a:hover.icon_addm{background:url(../images/img_floatbox.png) 0 -61px no-repeat; }
a.icon_removem{ background:url(../images/img_floatbox.png) -22px -33px no-repeat;width:16px; height:16px; display:block; margin:5px 0 0 5px}
diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css
index e14fb48fe..dc2fecbba 100644
--- a/public/stylesheets/public.css
+++ b/public/stylesheets/public.css
@@ -445,9 +445,9 @@ a.uploadIcon {background:url(../images/resource_icon_list.png) 8px -60px no-repe
.navHomepageSearchBoxcontainer {margin-top:11px; }
.navHomepageSearchBox {width:380px; border:none; outline:none; height:32px; background-color:#ffffff;}
.navHomepageSearchInput {width:345px; height:32px; outline:none; border:none; float:left; padding-left:5px;; margin:0;}
-.homepageSearchIcon {width:30px; height:32px; background:url(../images/nav_icon.png) -8px 3px no-repeat; float:left;}
-a.homepageSearchIcon:hover {background:url(../images/nav_icon.png) -49px 3px no-repeat;}
-.navSearchTypeBox {width:368px; height:35px; position:absolute; border:1px solid #98a1a6; background-color:#ffffff; padding-left:10px; display:none; color:#3e3e3e; font-size:14px; top:43px;}
+.homepageSearchIcon {width:30px; height:32px; background:url(../images/nav_icon.png) -8px 3px no-repeat; float:left; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
+a.homepageSearchIcon:hover {background:url(../images/nav_icon.png) -49px 3px no-repeat; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
+.navSearchTypeBox {width:368px; height:35px; position:absolute; border:1px solid #98a1a6; background-color:#ffffff; padding-left:10px; display:none; color:#3e3e3e; font-size:14px;}
#navSearchAlert {display:none;}
.navHomepageNews {width:30px; display:block; float:right; margin-top:8px; position:relative;}
.homepageNewsIcon {background:url(../images/nav_icon.png) -5px -85px no-repeat; width:30px; height:35px; display:block;}