Commit 18b6de1dcbf3dcef2770252ca80753be5f17de35
1 parent
1538eb76
Exists in
master
and in
21 other branches
remove-content-button: pass content explicitly as a parameter
Showing
4 changed files
with
16 additions
and
16 deletions
Show diff stats
app/helpers/application_helper.rb
| ... | ... | @@ -1309,11 +1309,11 @@ module ApplicationHelper |
| 1309 | 1309 | !content.public? || content.folder? || (profile == user && user.communities.blank? && !environment.portal_enabled) |
| 1310 | 1310 | end |
| 1311 | 1311 | |
| 1312 | - def remove_content_button(action) | |
| 1312 | + def remove_content_button(action, content) | |
| 1313 | 1313 | method_name = "content_remove_#{action.to_s}" |
| 1314 | - plugin_condition = @plugins.dispatch(method_name, @page).include?(true) | |
| 1314 | + plugin_condition = @plugins.dispatch(method_name, content).include?(true) | |
| 1315 | 1315 | begin |
| 1316 | - core_condition = self.send(method_name, @page) | |
| 1316 | + core_condition = self.send(method_name, content) | |
| 1317 | 1317 | rescue NoMethodError |
| 1318 | 1318 | core_condition = false |
| 1319 | 1319 | end | ... | ... |
app/views/cms/view.html.erb
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | <%= _('Content management') %> |
| 3 | 3 | </h1> |
| 4 | 4 | |
| 5 | -<% if !environment.enabled?('cant_change_homepage') && !remove_content_button(:home) %> | |
| 5 | +<% if !environment.enabled?('cant_change_homepage') && !remove_content_button(:home, profile.home_page) %> | |
| 6 | 6 | <div class="cms-homepage"> |
| 7 | 7 | <%= _('Profile homepage:') %> |
| 8 | 8 | <% if profile.home_page %> |
| ... | ... | @@ -66,17 +66,17 @@ |
| 66 | 66 | <%= short_description %> |
| 67 | 67 | </td> |
| 68 | 68 | <td class="article-controls"> |
| 69 | - <%= expirable_button article, :edit, _('Edit'), {:action => 'edit', :id => article.id} if !remove_content_button(:edit) %> | |
| 69 | + <%= expirable_button article, :edit, _('Edit'), {:action => 'edit', :id => article.id} if !remove_content_button(:edit, article) %> | |
| 70 | 70 | <%= button_without_text :eyes, _('Public view'), article.view_url %> |
| 71 | - <%= display_spread_button(article) unless article.folder? || remove_content_button(:spread)%> | |
| 72 | - <% if !environment.enabled?('cant_change_homepage') && !remove_content_button(:home) %> | |
| 71 | + <%= display_spread_button(article) unless remove_content_button(:spread, article) %> | |
| 72 | + <% if !environment.enabled?('cant_change_homepage') && !remove_content_button(:home, article) %> | |
| 73 | 73 | <% if profile.home_page != article %> |
| 74 | 74 | <%= expirable_button article, :home, _('Use as homepage'), { :action => 'set_home_page', :id => article.id }, :method => :post %> |
| 75 | 75 | <% else %> |
| 76 | 76 | <%= button_without_text(:'home-not', _('Reset homepage'), { :action => 'set_home_page', :id => nil }, :method => :post) %> |
| 77 | 77 | <% end %> |
| 78 | 78 | <% end %> |
| 79 | - <%= display_delete_button(article) if !remove_content_button(:delete) %> | |
| 79 | + <%= display_delete_button(article) if !remove_content_button(:delete, article) %> | |
| 80 | 80 | </td> |
| 81 | 81 | </tr> |
| 82 | 82 | <% end %> | ... | ... |
app/views/content_viewer/_article_toolbar.html.erb
| ... | ... | @@ -2,40 +2,40 @@ |
| 2 | 2 | <div id="article-actions"> |
| 3 | 3 | |
| 4 | 4 | |
| 5 | - <% if @page.allow_edit?(user) && !remove_content_button(:edit) %> | |
| 5 | + <% if @page.allow_edit?(user) && !remove_content_button(:edit, @page) %> | |
| 6 | 6 | <% content = content_tag('span', label_for_edit_article(@page)) %> |
| 7 | 7 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'edit', :id => @page.id }) %> |
| 8 | 8 | <%= expirable_button @page, :edit, content, url %> |
| 9 | 9 | <% end %> |
| 10 | 10 | |
| 11 | - <% if @page != profile.home_page && !@page.has_posts? && @page.allow_delete?(user) && !remove_content_button(:delete)%> | |
| 11 | + <% if @page != profile.home_page && !@page.has_posts? && @page.allow_delete?(user) && !remove_content_button(:delete, @page)%> | |
| 12 | 12 | <% content = content_tag( 'span', _('Delete') ) %> |
| 13 | 13 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'destroy', :id => @page.id}) %> |
| 14 | 14 | <% options = {:method => :post, :confirm => delete_article_message(@page)} %> |
| 15 | 15 | <%= expirable_button @page, :delete, content, url, options %> |
| 16 | 16 | <% end %> |
| 17 | 17 | |
| 18 | - <% if @page.allow_spread?(user) && !remove_content_button(:spread) %> | |
| 18 | + <% if @page.allow_spread?(user) && !remove_content_button(:spread, @page) %> | |
| 19 | 19 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'publish', :id => @page.id }) %> |
| 20 | 20 | <%= expirable_button @page, :spread, content_tag( 'span', _('Spread this') ), url, {:class => 'colorbox'} if url %> |
| 21 | 21 | <% end %> |
| 22 | 22 | |
| 23 | 23 | <% if !@page.gallery? && (@page.allow_create?(user) || (@page.parent && @page.parent.allow_create?(user))) %> |
| 24 | - <% if @page.translatable? && !@page.native_translation.language.blank? && !remove_content_button(:locale) %> | |
| 24 | + <% if @page.translatable? && !@page.native_translation.language.blank? && !remove_content_button(:locale, @page) %> | |
| 25 | 25 | <% content = _('Add translation') %> |
| 26 | 26 | <% parent_id = (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)) %> |
| 27 | 27 | <% url = profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => parent_id, :type => @page.type, :article => { :translation_of_id => @page.native_translation.id })%> |
| 28 | 28 | <%= expirable_button @page, :locale, content, url %> |
| 29 | 29 | <% end %> |
| 30 | 30 | |
| 31 | - <%= 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) %> | |
| 31 | + <%= 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) %> | |
| 32 | 32 | <% end %> |
| 33 | 33 | |
| 34 | 34 | <% if @page.accept_uploads? && @page.allow_create?(user) %> |
| 35 | - <%= 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)%> | |
| 35 | + <%= 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)%> | |
| 36 | 36 | <% end %> |
| 37 | 37 | |
| 38 | - <% if !@page.allow_create?(user) && profile.community? && (@page.blog? || @page.parent && @page.parent.blog?) && !remove_content_button(:suggest) %> | |
| 38 | + <% if !@page.allow_create?(user) && profile.community? && (@page.blog? || @page.parent && @page.parent.blog?) && !remove_content_button(:suggest, @page) %> | |
| 39 | 39 | <% content = content_tag( 'span', _('Suggest an article') ) %> |
| 40 | 40 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'suggest_an_article'}) %> |
| 41 | 41 | <% options = {:id => 'suggest-article-link'} %> | ... | ... |
app/views/content_viewer/versioned_article.html.erb
| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | <div id="article-actions"> |
| 8 | 8 | <%= button(:clock, _('All versions'), {:controller => 'content_viewer', :profile => profile.identifier, :action => 'article_versions'}, :id => 'article-versions-link') %> |
| 9 | 9 | |
| 10 | - <% if @page.allow_edit?(user) && !remove_content_button(:undo) %> | |
| 10 | + <% if @page.allow_edit?(user) && !remove_content_button(:undo, @page) %> | |
| 11 | 11 | <% content = content_tag('span', _('Revert to this version')) %> |
| 12 | 12 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'edit', :id => @page.id, :version => @version }) %> |
| 13 | 13 | <%= expirable_button @page, :undo, content, url, :id => 'article-revert-version-link' %> | ... | ... |