<font></font>
<div id="message_list_detail">
<h4 class="shadowbox_news_title">未读消息</h4>
<p style="display: none;" id="none_message" class="shadowbox_news_p text_c">无未读消息</p>
<ul class="shadowbox_news_list">
  <% messages.each do |ma| %>
    <% if ma.class == SystemMessage %>
        <li><a href="<%=user_system_messages_path(User.current) %>" target="_blank" title="Trustie平台 发布新消息：<%= ma.subject.blank? ? (ma.content.nil? ? message_content(ma.description) : message_content(ma.content)) : ma.subject%>"><span class="shadowbox_news_user">Trustie平台 </span>发布新消息：<%= ma.subject.blank? ? (ma.content.nil? ? message_content(ma.description) : message_content(ma.content)) : ma.subject%></a></li>
    <% elsif ma.class == CourseMessage %>
      <% if ma.course_message_type == "News" %>
          <li><a href="<%=news_path(ma.course_message.id) %>" target="_blank" title="<%=ma.course_message.author.show_name %> 发布了通知：<%= ma.course_message.title%>"><span class="shadowbox_news_user"><%=ma.course_message.author.show_name %> </span>发布了通知：<%= ma.course_message.title%></a></li>
      <% elsif ma.course_message_type == "Comment" %>
          <li><a href="<%=news_path(ma.course_message.commented.id) %>" target="_blank" title="<%=ma.course_message.author.show_name %> 评论了通知：<%=ma.course_message.commented.title%>"><span class="shadowbox_news_user"><%=ma.course_message.author.show_name %> </span>评论了通知：<%= ma.course_message.commented.title%></a></li>
      <% elsif ma.course_message_type == "HomeworkCommon" && ma.status.nil? %>
          <li><a href="<%= (!User.current.allowed_to?(:as_teacher, ma.course_message.course) && cur_user_works_for_homework(ma.course_message).nil?) ? new_student_work_path(:homework => ma.course_message.id) : student_work_index_path(:homework => ma.course_message.id) %>" target="_blank" title="<%=ma.course_message.user.show_name %>老师 发布了班级作业：作业标题：<%= ma.course_message.name%>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %>老师 </span>发布了班级作业：作业标题：<%= ma.course_message.name%></a></li>
      <% elsif ma.course_message_type == "HomeworkCommon" && ma.status == 1 %>
          <li><a href="<%= student_work_index_path(:homework => ma.course_message.id) %>" target="_blank" title="<%=ma.course_message.user.show_name %>老师 发布的作业：作业标题：<%= ma.course_message.name%>的截止日期快到了"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %>老师 </span>发布的作业：作业标题：<%= ma.course_message.name%>的截止日期快到了</a></li>
      <% elsif ma.course_message_type == "HomeworkCommon" && ma.status == 2 %>
          <li><a href="<%= student_work_index_path(:homework => ma.course_message.id) %>" target="_blank" title="<%=ma.course_message.user.show_name %>老师 启动了作业匿评：作业标题：<%= ma.course_message.name%>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %>老师 </span>启动了作业匿评：作业标题：<%= ma.course_message.name%></a></li>
      <% elsif ma.course_message_type == "HomeworkCommon" && ma.status == 3 %>
          <li><a href="<%= student_work_index_path(:homework => ma.course_message.id) %>" target="_blank" title="<%=ma.course_message.user.show_name %>老师 关闭了作业匿评：作业标题：<%= ma.course_message.name%>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %>老师 </span>关闭了作业匿评：作业标题：<%= ma.course_message.name%></a></li>
      <% elsif ma.course_message_type == "HomeworkCommon" && ma.status == 4 %>
          <li><a href="<%= student_work_index_path(:homework => ma.course_message.id) %>" target="_blank" title="<%=ma.course_message.user.show_name %>老师 启动作业匿评失败：<%= ma.course_message.name%>(失败原因：提交作品的人数低于2人)"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %>老师 </span>启动作业匿评失败：<%= ma.course_message.name%>(失败原因：提交作品的人数低于2人)</a></li>
      <% elsif ma.course_message_type == "HomeworkCommon" && ma.status == 5 %>
          <li><a href="<%= student_work_index_path(:homework => ma.course_message.id) %>" target="_blank" title="<%=User.find(ma.apply_user_id).show_name %> 申请引用作业：<%= ma.course_message.name%>"><span class="shadowbox_news_user"><%=User.find(ma.apply_user_id).show_name %> </span>申请引用作业：<%= ma.course_message.name%></a></li>
      <% elsif ma.course_message_type == "HomeworkCommon" && ma.status == 6 %>
          <li><a href="<%= (User.current.member_of_course?(ma.course_message.course) || User.current.admin? || (ma.course_message.is_open == 1 && ma.course_message.course.is_public == 1)) ? student_work_index_path(:homework => ma.course_message.id) : 'javascript:void(0)' %>" target="_blank" title="<%=ma.course_message.user.show_name %> <%= ma.apply_result == 1 ? '同意' : '拒绝'%>引用作业：<%= ma.course_message.name%>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %> </span><%= ma.apply_result == 1 ? '同意' : '拒绝'%>引用作业：<%= ma.course_message.name%></a></li>
      <% elsif ma.course_message_type == "ApplyResource" && ma.status == 0 %>
          <% if ma.course_message.container_type == "Course" %>
              <% href = course_files_path(ma.course_message.container_id) %>
          <% elsif ma.course_message.container_type == "Project" %>
              <% href = project_files_path(ma.course_message.container_id) %>
          <% elsif ma.course_message.container_type == "OrgSubfield" %>
              <% href = org_subfield_files_path(ma.course_message.container_id) %>
          <% else %>
              <% href = 'javascript:void(0)' %>
          <% end %>
          <li><a href="<%= href %>" target="_blank" title="<%=ma.course_message.user.show_name %> 申请引用资源：<%= ma.course_message.find_attachment(ma.course_message.attachment_id).try(:filename)%>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %> </span>申请引用资源：<%= ma.course_message.find_attachment(ma.course_message.attachment_id).try(:filename)%></a></li>
      <% elsif ma.course_message_type == "ApplyResource" && ma.status == 1 %>
          <% if ma.course_message.container_type == "Course" %>
              <% href = course_files_path(ma.course_message.container_id) %>
          <% elsif ma.course_message.container_type == "Project" %>
              <% href = project_files_path(ma.course_message.container_id) %>
          <% elsif ma.course_message.container_type == "OrgSubfield" %>
              <% href = org_subfield_files_path(ma.course_message.container_id) %>
          <% else %>
              <% href = 'javascript:void(0)' %>
          <% end %>
          <li><a href="<%= href %>" target="_blank" title="<%=User.find(ma.course_message.apply_user_id).show_name %> <%= ma.apply_result == 2 ? '同意' : '拒绝'%>引用资源：<%= ma.course_message.find_attachment(ma.course_message.attachment_id).try(:filename)%>"><span class="shadowbox_news_user"><%=User.find(ma.course_message.apply_user_id).show_name %> </span><%= ma.apply_result == 2 ? '同意' : '拒绝'%>引用资源：<%= ma.course_message.find_attachment(ma.course_message.attachment_id).try(:filename)%></a></li>
      <% elsif ma.course_message_type == "Poll" %>
          <li><a href="<%= poll_path(ma.course_message.id) %>" target="_blank" title="<%=ma.course_message.user.show_name %> 发布了问卷：<%= ma.course_message.polls_name.nil? ? "未命名问卷" : ma.course_message.polls_name %>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %> </span>发布了问卷：<%= ma.course_message.polls_name.nil? ? "未命名问卷" : ma.course_message.polls_name%></a></li>
      <% elsif ma.course_message_type == "Message" %>
          <% content = ma.course_message.parent_id.nil? ? ma.course_message.subject : message_content(ma.course_message.content) %>
          <% href = board_message_path(ma.course_message.board_id, ma.course_message.parent_id ? ma.course_message.parent_id : ma.course_message.id) %>
          <li><a href="<%= href %>" target="_blank" title="<%=ma.course_message.author.show_name %> <%= ma.course_message.parent_id.nil? ? "发布了班级帖子：" : "评论了班级帖子：" %><%= content%>"><span class="shadowbox_news_user"><%=ma.course_message.author.show_name %> </span><%= ma.course_message.parent_id.nil? ? "发布了班级帖子：" : "评论了班级帖子：" %><%= content%></a></li>
      <% elsif ma.course_message_type == "StudentWorksScore" %>
          <li><a href="<%= student_work_index_path(:homework => ma.course_message.student_work.homework_common_id) %>" target="_blank" title="<%=ma.course_message.reviewer_role == 3 ? '匿名用户' : ma.course_message.user.show_name+"老师" %> <%= ma.status == 0 ? "评阅了您的作品：" : "重新评阅了您的作品:" %><%= message_content(ma.content) if !ma.content.nil?%>"><span class="shadowbox_news_user"><%=ma.course_message.reviewer_role == 3 ? '匿名用户' : ma.course_message.user.show_name+"老师" %> </span><%= ma.status == 0 ? "评阅了您的作品：" : "重新评阅了您的作品:" %><%=  message_content(ma.content) if !ma.content.nil?%></a></li>
      <% elsif ma.course_message_type == "JournalsForMessage" %>
          <% if ma.course_message.jour_type == 'Course' %>
              <li><a href="<%= course_feedback_path(ma.course_id) %>" target="_blank" title="<%=ma.course_message.user.show_name %> 在班级中留言了：<%= message_content(ma.course_message.notes)%>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %> </span>在班级中留言了：<%= message_content(ma.course_message.notes)%></a></li>
          <% elsif ma.course_message.jour_type == 'HomeworkCommon' %>
              <li><a href="<%= homework_common_index_url_in_org(ma.course_id) %>" target="_blank" title="<%=ma.course_message.user.show_name %> <%=ma.course_message.m_parent_id.nil? ? '回复了您的作业：' : '在作业中回复了您：' %><%= message_content(ma.course_message.notes)%>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %> </span><%=ma.course_message.m_parent_id.nil? ? '回复了您的作业：' : '在作业中回复了您：' %><%= message_content(ma.course_message.notes)%></a></li>
          <% else %>
              <li><a href="<%= student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id,:show_work_id => ma.course_message.jour.student_work_id) %>" target="_blank" title="<%=ma.course_message.user.show_name %><%=ma.course_message.user.allowed_to?(:as_teacher, ma.course) ? '老师' : '同学' %> 回复了作品评论：<%= message_content(ma.course_message.notes)%>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %><%=ma.course_message.user.allowed_to?(:as_teacher, ma.course) ? '老师' : '同学' %> </span>回复了作品评论：<%= message_content(ma.course_message.notes)%></a></li>
          <% end %>
      <% elsif ma.course_message_type == "StudentWork" && !ma.course_message.homework_common.nil? && !User.current.allowed_to?(:as_teacher, ma.course_message.homework_common.course) %>
          <li><a href="<%=student_work_index_path(:homework => ma.course_message.homework_common_id) %>" target="_blank" title="<%=ma.course_message.homework_common.user.show_name %>老师 发布的作业：<%=ma.course_message.homework_common.name %>,由于迟交作业，您及您的作品都不能参与该作业的匿评"><span class="shadowbox_news_user"><%=ma.course_message.homework_common.user.show_name %>老师 </span>发布的作业：<%=ma.course_message.homework_common.name %>,由于迟交作业，您及您的作品都不能参与该作业的匿评</a></li>
      <% elsif ma.course_message_type == "StudentWork" && ma.status == 1 %>
          <li><a href="<%=student_work_index_path(:homework => ma.course_message.homework_common_id, :show_work_id => ma.course_message_id) %>" target="_blank" title="<%=ma.course_message.user.show_name %>同学 重新提交了作品：<%=ma.course_message.name %>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %>同学 </span>重新提交了作品：<%=ma.course_message.name %></a></li>
      <% elsif ma.course_message_type == "StudentWork" && ma.status == 2 %>
          <li><a href="<%=student_work_index_path(:homework => ma.course_message.homework_common_id, :show_work_id => ma.course_message_id) %>" target="_blank" title="<%=ma.course_message.user.show_name %>同学 追加新附件了：作业标题：<%=ma.course_message.homework_common.name %>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %>同学 </span>追加新附件了：作业标题：<%=ma.course_message.homework_common.name %></a></li>
      <% elsif ma.course_message_type == "Course" %>
          <li><a href="<%=course_path(ma.course_message) %>" target="_blank" title="系统提示 您成功创建了班级：班级名称：<%=ma.course_message.name %>"><span class="shadowbox_news_user">系统提示 </span>您成功创建了班级：班级名称：<%=ma.course_message.name %></a></li>
      <% elsif ma.course_message_type == "JoinCourseRequest" %>
          <% content = User.find(ma.course_message_id).name+"申请成为班级\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content && ma.content.include?('9')  ? "教师" : "教辅"}" %>
          <li><a href="<%=user_path(User.find(ma.course_message_id), :course_id => ma.course_id) %>" target="_blank" title="系统提示 您有了新的班级成员申请：<%=content %>"><span class="shadowbox_news_user">系统提示 </span>您有了新的班级成员申请：<%=content %></a></li>
      <% elsif ma.course_message_type == "CourseRequestDealResult" %>
          <% content = ma.status == 1 ? '您申请成为班级"'+Course.find(ma.course_id).name+'"的'+(ma.content == '9' ? '老师' : '教辅')+'申请已通过' : '您申请成为班级"'+Course.find(ma.course_id).name+'"的'+(ma.content && ma.content.include?('9')  ? '教师' : '教辅')+'的申请被拒绝' %>
          <li><a href="<%=course_path(Course.find(ma.course_id)) %>" target="_blank" title="系统提示 班级申请进度反馈：<%=content %>"><span class="shadowbox_news_user">系统提示 </span>班级申请进度反馈：<%=content %></a></li>
      <% elsif ma.course_message_type == "JoinCourse" and ma.status == 0 %>
          <li><a href="<%=course_member_path(ma.course) %>" target="_blank" title="<%=User.find(ma.course_message_id).show_name %> 将您加入了班级：<%=ma.course.name %>"><span class="shadowbox_news_user"><%=User.find(ma.course_message_id).show_name %> </span>将您加入了班级：<%=ma.course.name %></a></li>
      <% elsif ma.course_message_type == "JoinCourse" and ma.status == 1 %>
          <li><a href="<%=user_path(ma.course_message_id) %>" target="_blank" title="系统提示 您增加了新的班级成员：<%=User.find(ma.course_message_id).login+"("+User.find(ma.course_message_id).show_name+")" %>"><span class="shadowbox_news_user">系统提示 </span>您增加了新的班级成员：<%=User.find(ma.course_message_id).login+"("+User.find(ma.course_message_id).show_name+")" %></a></li>
      <% elsif ma.course_message_type == "RemoveFromCourse" %>
          <li><a href="<%=member_course_path(ma.course) %>" target="_blank" title="<%=User.find(ma.course_message_id).show_name %> 将您移出了班级：<%=ma.course.name %>"><span class="shadowbox_news_user"><%=User.find(ma.course_message_id).show_name %> </span>将您移出了班级：<%=ma.course.name %></a></li>
      <% elsif ma.course_message_type == "Exercise" && ma.status == 2 %>
          <li><a href="<%=exercise_path(:id => ma.course_message.id) %>" target="_blank" title="<%=ma.course_message.user.show_name %>老师 发布了班级测验：测验题目:<%=ma.course_message.exercise_name %>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %>老师 </span>发布了班级测验：测验题目:<%=ma.course_message.exercise_name %></a></li>
      <% elsif ma.course_message_type == "Exercise" && ma.status == 3 %>
          <li><a href="<%=exercise_path(:id => ma.course_message.id) %>" target="_blank" title="<%=ma.course_message.user.show_name %>老师 发布的测验：<%=ma.course_message.exercise_name %> 截止时间快到了"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %>老师 </span>发布的测验：<%=ma.course_message.exercise_name %> 截止时间快到了</a></li>
      <% end %>
    <% elsif ma.class == AppliedMessage %>
      <% if ma.applied_type == "AppliedProject" %>
          <li><%=link_to "<span class='shadowbox_news_user'>#{applied_project_users(ma)}</span>".html_safe, user_path(applied_project_users(ma)), :target => '_blank' %>
            <span><%= applied_project_tip_header(ma) %>以“<%= applied_project_message_type(ma.role) %>”身份加入<% project = Project.find(ma.project_id) %>
                <%= link_to project.name, project_path(ma.project_id), :class => "link-blue", :target => '_blank', :title => "#{project.name}" %>
            </span>
      <% elsif ma.applied_type == "ApplyAddSchools" && ma.status == 0 %>
          <li>
            <% content = '<span class="shadowbox_news_user">'+User.where("id=?", ma.applied_user_id).first.show_name+' </span>提交了申请：添加新的单位：'+"“"+ma.name+"”" %>
            <%= link_to content.html_safe, unapplied_schools_path(:flag => 1, :applied_message_id => ma.id), :title => "#{User.where("id=?", ma.applied_user_id).first.show_name}提交了申请：添加新的单位“#{ma.name}”", :target => '_blank' %>
          </li>
      <% elsif ma.applied_type == "ApplyAddSchools" && ma.status == 1 %>
          <li>
            <% content = "<span class='shadowbox_news_user'>系统提示：</span>“#{ma.name}”的申请，已通过审核。谢谢！" %>
            <%= link_to content.html_safe, { :controller=> "my",:action => "account",:flag => 1, :applied_message_id => ma.id }, :title => "系统提示：“#{ma.name}”的申请，已通过审核。谢谢！", :target => '_blank'%>
          </li>
      <% elsif ma.applied_type == "ApplyAddSchools" && ma.status == 2 %>
          <li>
            <% content = "<span class='shadowbox_news_user'>系统提示：</span>“#{ma.applied.name}”的申请，因名称不符合规范，系统已将其更改为“#{ma.name}”。谢谢！" %>
            <%= link_to content.html_safe, { :controller=> "my",:action => "account", :flag => 1, :applied_message_id => ma.id }, :title => "系统提示：“#{ma.applied.name}”的申请，因名称不符合规范，系统已将其更改为“#{ma.name}”。谢谢！", :target => '_blank'%>
          </li>
      <% elsif ma.applied_type == "ApplyAddSchools" && ma.status == 3 %>
          <li>
            <% content = "<span class='shadowbox_news_user'>系统提示：</span>“#{ma.name}”的申请，经确认为无效的单位信息，已被删除，请重新编辑您的单位资料。谢谢！" %>
            <%= link_to content.html_safe, { :controller=> "my",:action => "account", :flag => 1, :applied_message_id => ma.id }, :title => "系统提示：“#{ma.name}”的申请，经确认为无效的单位信息，已被删除，请重新编辑您的单位资料。谢谢！", :target => '_blank'%>
          </li>
      <% end %>
    <% elsif ma.class == ForgeMessage %>
      <% if ma.forge_message_type == "AppliedProject" %>
          <li><a href="<%=settings_project_path(:id => ma.project, :tab => "members") %>" target="_blank" title="<%=ma.forge_message.user.show_name %> 申请加入项目：<%= ma.project.name%>"><span class="shadowbox_news_user"><%=ma.forge_message.user.show_name %> </span>申请加入项目：<%= ma.project.name%></a></li>
      <% elsif ma.forge_message_type == "JoinProject" %>
          <li><a href="<%=project_member_path(ma.project) %>" target="_blank" title="<%=User.find(ma.forge_message_id).show_name %> 将您加入了项目：<%= ma.project.name%>"><span class="shadowbox_news_user"><%=User.find(ma.forge_message_id).show_name %> </span>将您加入了项目：<%= ma.project.name%></a></li>
      <% elsif ma.forge_message_type == "RemoveFromProject" %>
          <li><a href="<%=member_project_path(ma.project) %>" target="_blank" title="<%=User.find(ma.forge_message_id).show_name %> 将您移出了项目：<%= ma.project.name%>"><span class="shadowbox_news_user"><%=User.find(ma.forge_message_id).show_name %> </span>将您移出了项目：<%= ma.project.name%></a></li>
      <% elsif ma.forge_message_type == "RemoveFromProject" %>
          <li><a href="<%=project_path(ma.project) %>" target="_blank" title="<%=User.find(ma.forge_message_id).show_name %> 邀请你加入项目：<%= ma.project.name%>"><span class="shadowbox_news_user"><%=User.find(ma.forge_message_id).show_name %> </span>邀请你加入项目：<%= ma.project.name%></a></li>
      <% elsif ma.forge_message_type == "Issue" && ma.status == 1 %>
          <li><a href="<%=issue_path(:id => ma.forge_message.id) %>" target="_blank" title="<%=ma.forge_message.author.show_name %> <%= ma.forge_message.tracker_id == 5 ? "发布的周报：":"指派给你的问题："%><%= ma.forge_message.subject%> 截止时间快到了！"><span class="shadowbox_news_user"><%=ma.forge_message.author.show_name %> </span><%= ma.forge_message.tracker_id == 5 ? "发布的周报：":"指派给你的问题："%><%= ma.forge_message.subject%> 截止时间快到了！</a></li>
      <% elsif ma.forge_message_type == "Issue" && ma.status != 1 %>
          <li><a href="<%=issue_path(:id => ma.forge_message.id) %>" target="_blank" title="<%=ma.forge_message.author.show_name %> <%= ma.forge_message.tracker_id == 5 ? "发布了周报：":"指派了问题给你："%><%= ma.forge_message.subject%>"><span class="shadowbox_news_user"><%=ma.forge_message.author.show_name %> </span><%= ma.forge_message.tracker_id == 5 ? "发布了周报：":"指派了问题给你："%><%= ma.forge_message.subject%></a></li>
      <% elsif ma.forge_message_type == "Journal" && ma.forge_message %>
          <li><a href="<%=issue_path(:id => ma.forge_message.journalized_id) %>" target="_blank" title="<%=ma.forge_message.user.show_name %> 更新了问题状态：<%= ma.forge_message.journalized.subject%>"><span class="shadowbox_news_user"><%=ma.forge_message.user.show_name %> </span>更新了问题状态：<%= ma.forge_message.journalized.subject%></a></li>
      <% elsif ma.forge_message_type == "Message" %>
          <li><a href="<%=board_message_path(ma.forge_message.board_id, ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id) %>" target="_blank" title="<%=ma.forge_message.author.show_name %> <%= ma.forge_message.parent_id.nil? ? "发布了项目帖子：" : "评论了项目帖子：" %><%= ma.forge_message.subject%>"><span class="shadowbox_news_user"><%=ma.forge_message.author.show_name %> </span><%= ma.forge_message.parent_id.nil? ? "发布了项目帖子：" : "评论了项目帖子：" %><%= ma.forge_message.subject%></a></li>
      <% elsif ma.forge_message_type == "News" %>
          <li><a href="<%=news_path(ma.forge_message.id) %>" target="_blank" title="<%=ma.forge_message.author.show_name %> 发布了新闻：<%= ma.forge_message.title.html_safe%>"><span class="shadowbox_news_user"><%=ma.forge_message.author.show_name %> </span>发布了新闻：<%= ma.forge_message.title.html_safe%></a></li>
      <% elsif ma.forge_message_type == "Comment" %>
          <li><a href="<%=news_path(ma.forge_message.commented.id) %>" target="_blank" title="<%=ma.forge_message.author.show_name %> 评论了新闻：<%= ma.forge_message.commented.title%>"><span class="shadowbox_news_user"><%=ma.forge_message.author.show_name %> </span>评论了新闻：<%= ma.forge_message.commented.title%></a></li>
      <% end %>
    <% elsif ma.class == MemoMessage %>
      <% if ma.memo_type == "Memo" && !ma.memo.nil? && !ma.memo.author.nil? %>
          <li><a href="<%=forum_memo_path(ma.memo.forum_id, ma.memo.parent_id ? ma.memo.parent_id: ma.memo.id) %>" target="_blank" title="<%=ma.memo.author.show_name %> <%= ma.memo.parent_id.nil? ? "在贴吧发布帖子：" : "回复了贴吧帖子：" %><%= ma.memo.parent_id.nil? ? ma.memo.subject : message_content(ma.memo.content)%>"><span class="shadowbox_news_user"><%=ma.memo.author.show_name %> </span><%= ma.memo.parent_id.nil? ? "在贴吧发布帖子：" : "回复了贴吧帖子：" %><%= ma.memo.parent_id.nil? ? ma.memo.subject : message_content(ma.memo.content)%></a></li>
      <% end %>
    <% elsif ma.class == UserFeedbackMessage %>
      <% if ma.journals_for_message_type == "JournalsForMessage" %>
          <li><a href="<%=feedback_path(ma.journals_for_message.jour_id) %>" target="_blank" title="<%=ma.journals_for_message.user.show_name %> <%= ma.journals_for_message.reply_id == 0 || ma.journals_for_message.reply_id.nil? ? "给你留言了：" : "回复了你的留言：" %><%= message_content(ma.journals_for_message.notes)%>"><span class="shadowbox_news_user"><%=ma.journals_for_message.user.show_name %> </span><%= ma.journals_for_message.reply_id == 0 || ma.journals_for_message.reply_id.nil? ? "给你留言了：" : "回复了你的留言：" %><%= message_content(ma.journals_for_message.notes)%></a></li>
      <% end %>
    <% elsif ma.class == OrgMessage %>
      <% if ma.message_type == 'ApplySubdomain' && ma.organization %>
          <li><a href="<%=agree_apply_subdomain_organizations_path( :organization_id => ma.organization_id, :org_domain => ma.content, :user_id => ma.sender_id, :act_id => ma.id ) %>" target="_blank" title="<%=ma.organization.name %> 申请子域名：<%= (Secdomain.where("sub_type=2 and pid=?", ma.organization.id).count == 0 || (Secdomain.where("sub_type=2 and pid=?", ma.organization.id).count > 0 && Secdomain.where("sub_type=2 and pid=?", ma.organization.id).first.subname != ma.content)) ? "同意申请":"申请已批准"%>"><span class="shadowbox_news_user"><%=ma.organization.name %> </span>申请子域名：<%= (Secdomain.where("sub_type=2 and pid=?", ma.organization.id).count == 0 || (Secdomain.where("sub_type=2 and pid=?", ma.organization.id).count > 0 && Secdomain.where("sub_type=2 and pid=?", ma.organization.id).first.subname != ma.content)) ? "同意申请":"申请已批准"%></a></li>
      <% elsif ma.message_type == 'AgreeApplySubdomain' %>
          <li><a href="javascript:void(0)" target="_blank" title="系统提示 管理员同意了您的子域名申请：<%= ma.content%>"><span class="shadowbox_news_user">系统提示 </span>管理员同意了您的子域名申请：<%= ma.content%></a></li>
      <% end %>
    <% elsif AtMessage === ma && ma.at_valid? %>
      <% if ma.at_message_type == "Message" && !ma.at_message.course.nil? %>
        <% href = course_boards_path(ma.at_message.course,:parent_id => ma.at_message.parent_id ? ma.at_message.parent_id : ma.at_message.id, :topic_id => ma.at_message.id) %>
        <li><a href="<%=href %>" target="_blank" title="<%=ma.author.show_name %> 提到了你：<%= ma.subject.html_safe%>"><span class="shadowbox_news_user"><%=ma.author.show_name %> </span>提到了你：<%= ma.subject.html_safe%></a></li>
      <% elsif ma.at_message_type == "Message" && !ma.at_message.project.nil? %>
        <% href = project_boards_path(ma.at_message.project,:parent_id => ma.at_message.parent_id ? ma.at_message.parent_id : ma.at_message.id, :topic_id => ma.at_message.id) %>
        <li><a href="<%=href %>" target="_blank" title="<%=ma.author.show_name %> 提到了你：<%= ma.subject.html_safe%>"><span class="shadowbox_news_user"><%=ma.author.show_name %> </span>提到了你：<%= ma.subject.html_safe%></a></li>
      <% else %>
        <% content = '<span class="shadowbox_news_user">'+ma.author.show_name+' </span>提到了你：'+ma.subject.html_safe %>
        <li><%=link_to content.html_safe, ma.url, :title => ma.author.show_name+' 提到了你：'+ma.subject.html_safe, :target => '_blank' %></li>
      <% end %>
    <% end %>
  <% end %>
</ul>
  <a onclick = "show_more();" id = "show_more_messages" style="display: none; cursor: pointer;" class = "shadowbox_news_all">展开更多</a>
<%= link_to '查看全部', user_message_path(User.current),:id =>'show_all_messages', :class => "shadowbox_news_all", :style => "display:none", :target =>"_Blank" %>
</div>

<script type="text/javascript">
    $(function(){
        if($(".shadowbox_news_list li").length > 5) {
            $(".shadowbox_news_list li").hide();
            $(".shadowbox_news_list li").eq(0).show();
            $(".shadowbox_news_list li").eq(1).show();
            $(".shadowbox_news_list li").eq(2).show();
            $(".shadowbox_news_list li").eq(3).show();
            $(".shadowbox_news_list li").eq(4).show();
            $("#show_more_messages").show();
        } else if ($(".shadowbox_news_list li").length == 0) {
            $("#none_message").show();
            $("#show_all_messages").show();
        }
        else {
            $("#show_all_messages").show();
        }
    });
    function show_more() {
        $(".shadowbox_news_list li").show();
        $("#show_more_messages").hide();
        $("#show_all_messages").show();
    }
</script>