<% projects.each do |project|%>
    <li class="homepageLeftMenuCoursesLine pr">
      <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count %>
      <%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "projectsLineGrey hidden",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目：":"私有项目：") + project.name%>
        <ul class="<%= count > 0 ? 'shild shildP':'subNavArrow'%>">
          <li>
            <ul class="subNavMenu boxShadow">
              <li class="subNavRow">
                <%=link_to "问题跟踪", project_issues_path(project), :class => 'fl fontGrey2', :target => '_blank',:style => "width:48px;" %>
                <%=link_to "+", new_project_issue_path(project), :class => 'fr fb', :target => '_blank',:style => "width:48px;", :title => '发布问题',:style =>'width:10px;' %>
                <div class="cl"></div>
              </li>
              <li class="subNavRow">
                <%=link_to "资源", project_files_path(project),:class => 'fl fontGrey2 w48' %>
                <%=link_to "+", upload_files_menu_path(:project_id => project.id),:remote => true,:class => 'fr fb',:title => '上传资源'%>
                <div class="cl"></div>
              </li>
              <li class="subNavRow">
                <%=link_to "论坛", project_boards_path(project),:class => 'fl fontGrey2 w48', :target => '_blank'%>
                <%=link_to "+", project_boards_path(project, :flag => true),:class => 'fr fb', :target => '_blank',:title => '发布帖子'%>
                <div class="cl"></div>
              </li>
              <% if (User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, project)) && rep_is_gitlab?(project) %>
                  <li class="subNavRow">
                    <%= link_to '版本库', url_for(:controller => 'projects', :action => 'settings', :id => project.id, :tab=>'repositories') , :target => '_blank',:class => "fl w48",:title => '版本库' %>
                    <div class="cl"></div>
                  </li>
              <% end %>
              <% if User.current == @user %>
                  <li class="subNavRow">
                    <% if ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count == 0 %>
                        <%= link_to "屏蔽动态", shield_activities_path(:user_id => user.id, :project_id => project.id), :method => 'post',:remote => true %>
                    <% else %>
                        <%= link_to "显示动态", show_acts_shield_activities_path(:user_id => user.id, :project_id => project.id),:method => 'delete',:remote => true %>
                    <% end %>
                    <div class="cl"></div>
                  </li>
                  <li class="subNavRow">
                    <% if ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count == 0 %>
                        <%= link_to "屏蔽微信消息", shield_wechat_messages_path(:user_id => user.id, :project_id => project.id), :method => 'post',:remote => true %>
                    <% else %>
                        <%= link_to "接收微信消息", show_messages_shield_wechat_messages_path(:user_id => user.id, :project_id => project.id),:method => 'delete',:remote => true %>
                    <% end %>
                    <div class="cl"></div>
                  </li>
              <% end %>
              <% if  User.current.logged? && (User.current.admin? || is_project_manager?(User.current,project))  %>
                  <li class="subNavRow">
                    <%= link_to project.is_public? ? "设为私有" : "设为公开", {:controller => 'projects', :action => 'set_public_or_private', :id => project.id,:user_page => true},
                                :id => 'set_project_public_'+ project.id.to_s,:method => 'post',:remote=>true,:confirm=>"您确定要设置为"+(project.is_public? ? "私有" : "公开")+"吗"%>
                    <div class="cl"></div>
                  </li>
              <% end %>
            </ul>
          </li>
        </ul>
    </li>
<% end %>
<% if projects.size == 5%>
    <li class="homepageLeftMenuMore" id="user_show_more_project">
      <input type="hidden" value="<%= page%>" id="project_page_num">
      <a href="javascript:void(0);" class="homepageLeftMenuMoreIcon" onclick="show_more_project('<%=  user_projects4show_user_path(user.id)%>');"></a>
    </li>
<% end%>

<script type="text/javascript">
    var projectcount = <%= @user.projects.visible.count %>;
    var projectshowcount = document.getElementsByClassName("projectsLineGrey").length;

    if((projectcount <= projectshowcount)&&(projectcount > 5)){
        $("#user_show_more_project").hide();
        $('#user_hide_project').show();
    }
</script>
