def unfollow
add_default_dashboards_if_first_user_dashboard
- ActiveDashboard.destroy_all(['user_id=? AND dashboard_id=?', current_user.id, params[:id].to_i])
+ dashboard=Dashboard.find(:first, :conditions => ['shared=? and id=? and (user_id is null or user_id<>?)', true, params[:id].to_i, current_user.id])
+ if dashboard
+ ActiveDashboard.destroy_all(['user_id=? AND dashboard_id=?', current_user.id, params[:id].to_i])
- if ActiveDashboard.count(:conditions => ['user_id=?', current_user.id])==0
- flash[:notice]=Api::Utils.message('dashboard.default_restored')
+ if ActiveDashboard.count(:conditions => ['user_id=?', current_user.id])==0
+ flash[:notice]=Api::Utils.message('dashboard.default_restored')
+ end
end
redirect_to :action => 'index', :resource => params[:resource]
end
:confirm => message('dashboard.do_you_want_to_delete_dashboard'), :id => "delete-#{u active.name}", :class => 'link-action' %>
<% end %>
<% end %>
- <% if @actives.size() > 1 %>
+ <% if @actives.size() > 1 and active.shared? %>
|
<%= link_to message('unfollow'), {:action => :unfollow, :id => active.dashboard_id, :resource => params[:resource]}, :method => :post,
:id => "unfollow-#{u active.name}", :class => 'link-action' %>