diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 74b0950..ce247a0 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1309,11 +1309,11 @@ module ApplicationHelper
!content.public? || content.folder? || (profile == user && user.communities.blank? && !environment.portal_enabled)
end
- def remove_content_button(action)
+ def remove_content_button(action, content)
method_name = "content_remove_#{action.to_s}"
- plugin_condition = @plugins.dispatch(method_name, @page).include?(true)
+ plugin_condition = @plugins.dispatch(method_name, content).include?(true)
begin
- core_condition = self.send(method_name, @page)
+ core_condition = self.send(method_name, content)
rescue NoMethodError
core_condition = false
end
diff --git a/app/views/cms/view.html.erb b/app/views/cms/view.html.erb
index 3acf080..65fd5dc 100644
--- a/app/views/cms/view.html.erb
+++ b/app/views/cms/view.html.erb
@@ -2,7 +2,7 @@
<%= _('Content management') %>
-<% if !environment.enabled?('cant_change_homepage') && !remove_content_button(:home) %>
+<% if !environment.enabled?('cant_change_homepage') && !remove_content_button(:home, profile.home_page) %>
<%= _('Profile homepage:') %>
<% if profile.home_page %>
@@ -66,17 +66,17 @@
<%= short_description %>
- <%= expirable_button article, :edit, _('Edit'), {:action => 'edit', :id => article.id} if !remove_content_button(:edit) %>
+ <%= expirable_button article, :edit, _('Edit'), {:action => 'edit', :id => article.id} if !remove_content_button(:edit, article) %>
<%= button_without_text :eyes, _('Public view'), article.view_url %>
- <%= display_spread_button(article) unless article.folder? || remove_content_button(:spread)%>
- <% if !environment.enabled?('cant_change_homepage') && !remove_content_button(:home) %>
+ <%= display_spread_button(article) unless remove_content_button(:spread, article) %>
+ <% if !environment.enabled?('cant_change_homepage') && !remove_content_button(:home, article) %>
<% if profile.home_page != article %>
<%= expirable_button article, :home, _('Use as homepage'), { :action => 'set_home_page', :id => article.id }, :method => :post %>
<% else %>
<%= button_without_text(:'home-not', _('Reset homepage'), { :action => 'set_home_page', :id => nil }, :method => :post) %>
<% end %>
<% end %>
- <%= display_delete_button(article) if !remove_content_button(:delete) %>
+ <%= display_delete_button(article) if !remove_content_button(:delete, article) %>
|
<% end %>
diff --git a/app/views/content_viewer/_article_toolbar.html.erb b/app/views/content_viewer/_article_toolbar.html.erb
index bd72af6..09dfc75 100644
--- a/app/views/content_viewer/_article_toolbar.html.erb
+++ b/app/views/content_viewer/_article_toolbar.html.erb
@@ -2,40 +2,40 @@
- <% if @page.allow_edit?(user) && !remove_content_button(:edit) %>
+ <% if @page.allow_edit?(user) && !remove_content_button(:edit, @page) %>
<% content = content_tag('span', label_for_edit_article(@page)) %>
<% url = profile.admin_url.merge({ :controller => 'cms', :action => 'edit', :id => @page.id }) %>
<%= expirable_button @page, :edit, content, url %>
<% end %>
- <% if @page != profile.home_page && !@page.has_posts? && @page.allow_delete?(user) && !remove_content_button(:delete)%>
+ <% if @page != profile.home_page && !@page.has_posts? && @page.allow_delete?(user) && !remove_content_button(:delete, @page)%>
<% content = content_tag( 'span', _('Delete') ) %>
<% url = profile.admin_url.merge({ :controller => 'cms', :action => 'destroy', :id => @page.id}) %>
<% options = {:method => :post, :confirm => delete_article_message(@page)} %>
<%= expirable_button @page, :delete, content, url, options %>
<% end %>
- <% if @page.allow_spread?(user) && !remove_content_button(:spread) %>
+ <% if @page.allow_spread?(user) && !remove_content_button(:spread, @page) %>
<% url = profile.admin_url.merge({ :controller => 'cms', :action => 'publish', :id => @page.id }) %>
<%= expirable_button @page, :spread, content_tag( 'span', _('Spread this') ), url, {:class => 'colorbox'} if url %>
<% end %>
<% if !@page.gallery? && (@page.allow_create?(user) || (@page.parent && @page.parent.allow_create?(user))) %>
- <% if @page.translatable? && !@page.native_translation.language.blank? && !remove_content_button(:locale) %>
+ <% if @page.translatable? && !@page.native_translation.language.blank? && !remove_content_button(:locale, @page) %>
<% content = _('Add translation') %>
<% parent_id = (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)) %>
<% url = profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => parent_id, :type => @page.type, :article => { :translation_of_id => @page.native_translation.id })%>
<%= expirable_button @page, :locale, content, url %>
<% end %>
- <%= colorbox_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)))) unless remove_content_button(:new) %>
+ <%= colorbox_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)))) unless remove_content_button(:new, @page) %>
<% end %>
<% if @page.accept_uploads? && @page.allow_create?(user) %>
- <%= button('upload-file', _('Upload files'), profile.admin_url.merge(:controller => 'cms', :action => 'upload_files', :parent_id => (@page.folder? ? @page : @page.parent))) unless remove_content_button(:upload)%>
+ <%= button('upload-file', _('Upload files'), profile.admin_url.merge(:controller => 'cms', :action => 'upload_files', :parent_id => (@page.folder? ? @page : @page.parent))) unless remove_content_button(:upload, @page)%>
<% end %>
- <% if !@page.allow_create?(user) && profile.community? && (@page.blog? || @page.parent && @page.parent.blog?) && !remove_content_button(:suggest) %>
+ <% if !@page.allow_create?(user) && profile.community? && (@page.blog? || @page.parent && @page.parent.blog?) && !remove_content_button(:suggest, @page) %>
<% content = content_tag( 'span', _('Suggest an article') ) %>
<% url = profile.admin_url.merge({ :controller => 'cms', :action => 'suggest_an_article'}) %>
<% options = {:id => 'suggest-article-link'} %>
diff --git a/app/views/content_viewer/versioned_article.html.erb b/app/views/content_viewer/versioned_article.html.erb
index 67ebb51..7523b89 100644
--- a/app/views/content_viewer/versioned_article.html.erb
+++ b/app/views/content_viewer/versioned_article.html.erb
@@ -7,7 +7,7 @@
<%= button(:clock, _('All versions'), {:controller => 'content_viewer', :profile => profile.identifier, :action => 'article_versions'}, :id => 'article-versions-link') %>
- <% if @page.allow_edit?(user) && !remove_content_button(:undo) %>
+ <% if @page.allow_edit?(user) && !remove_content_button(:undo, @page) %>
<% content = content_tag('span', _('Revert to this version')) %>
<% url = profile.admin_url.merge({ :controller => 'cms', :action => 'edit', :id => @page.id, :version => @version }) %>
<%= expirable_button @page, :undo, content, url, :id => 'article-revert-version-link' %>
--
libgit2 0.21.2