<% if User.current.allowed_to?(:subscribe_to_project, @project) %> <% unless defined? @subscriber %> <% @subscriber = ProjectSubscriber.find_by_project_id_and_user_id(@project.id, User.current.id) %> <% end %> <% unless defined? @count %> <% @count = ProjectSubscriber.where(:project_id => @project).count %> <% end %>
<% if defined? link_to_remote %> <%= link_to_remote(@subscriber && !@subscriber.new_record? ? l(:button_update) : l(:label_subscribe), :url => { :controller => 'subscriptions', :action => 'subscription', :id => @project, :resource => defined?(resource) ? resource : nil }) %> <% else %> <%= link_to(@subscriber && !@subscriber.new_record? ? l(:button_update) : l(:label_subscribe), { :controller => 'subscriptions', :action => 'subscription', :id => @project, :resource => defined?(resource) ? resource : nil }, :remote => true) %> <% end %>

<%= l(:label_subscription) %> <% if User.current.allowed_to?(:view_number_of_subscribers, @project) && @count > 0 %> (<%= @count %>) <% end %>

<% if (controller_name == 'projects' || controller_name == 'subscriptions') && (!@subscriber || @subscriber.new_record? || request.post? || request.xhr?) %> <% if @message %>

<%= h(@message) %>

<% else %> <% if defined? remote_form_for %> <% form = remote_form_for(:subscriber, :url => { :controller => 'subscriptions', :action => 'subscribe', :id => @project }, :method => :post, :html => { :id => 'subscription-form' }) do %> <%= render(:partial => 'subscribe/checkboxes', :locals => { :project => @project, :subscriber => @subscriber }) %>

<%= submit_tag(@subscriber && !@subscriber.new_record? ? l(:button_update) : l(:label_subscribe), :class => 'small') %> <%= toggle_link(l(:button_cancel), 'subscription-form') %>

<% end %> <% else %> <% form = form_for(:subscriber, :url => { :controller => 'subscriptions', :action => 'subscribe', :id => @project }, :method => :post, :remote => true, :html => { :id => 'subscription-form' }) do %> <%= render(:partial => 'subscribe/checkboxes', :locals => { :project => @project, :subscriber => @subscriber }) %>

<%= submit_tag(@subscriber && !@subscriber.new_record? ? l(:button_update) : l(:label_subscribe), :class => 'small') %> <%= toggle_link(l(:button_cancel), 'subscription-form') %>

<% end %> <% end %> <%= form if Rails::VERSION::MAJOR >= 3 %> <% end %> <% end %>
<% end %>