Commit 1389ea0d311ea58447777c35f7aa66f2c4f0281b
1 parent
79e1ad7b
Exists in
master
and in
27 other branches
publish-content: display only valid options
When the content being displayed is from the user, we should not display the "publish on my profile" option. The same goes for the "publish on communities" option if the user has no communities or the "publish on portal community" option if the environment has no portal community. If none of this options is available the spread button is also not displayed.
Showing
2 changed files
with
56 additions
and
41 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -1296,8 +1296,19 @@ module ApplicationHelper |
1296 | 1296 | end |
1297 | 1297 | end |
1298 | 1298 | |
1299 | + def content_remove_spread(content) | |
1300 | + not (profile != user || user.communities.present? || @portal_enabled) | |
1301 | + end | |
1302 | + | |
1299 | 1303 | def remove_content_button(action) |
1300 | - @plugins.dispatch("content_remove_#{action.to_s}", @page).include?(true) | |
1304 | + method_name = "content_remove_#{action.to_s}" | |
1305 | + plugin_condition = @plugins.dispatch(method_name, @page).include?(true) | |
1306 | + begin | |
1307 | + core_condition = self.send(method_name, @page) | |
1308 | + rescue NoMethodError | |
1309 | + core_condition = false | |
1310 | + end | |
1311 | + core_condition || plugin_condition | |
1301 | 1312 | end |
1302 | 1313 | |
1303 | 1314 | def template_options(kind, field_name) | ... | ... |
app/views/cms/publish.html.erb
... | ... | @@ -30,56 +30,60 @@ |
30 | 30 | <% end %> |
31 | 31 | |
32 | 32 | <ul class='publish-targets'> |
33 | - <li onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')"> | |
34 | - <strong><%= _("Publish this article on your profile") %></strong> | |
35 | - <div class='description'><%= _('You can publish this article on your profile where your friends and followers will see.') %></div> | |
36 | - <%= form_tag do %> | |
37 | - <%= hidden_field_tag :back_to, @back_to %> | |
38 | - <div class='publish-article-title'> | |
39 | - <%= labelled_text_field _('Title'), 'name', @article.name %> | |
40 | - </div> | |
33 | + <% if profile != user %> | |
34 | + <li onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')"> | |
35 | + <strong><%= _("Publish this article on your profile") %></strong> | |
36 | + <div class='description'><%= _('You can publish this article on your profile where your friends and followers will see.') %></div> | |
37 | + <%= form_tag do %> | |
38 | + <%= hidden_field_tag :back_to, @back_to %> | |
39 | + <div class='publish-article-title'> | |
40 | + <%= labelled_text_field _('Title'), 'name', @article.name %> | |
41 | + </div> | |
41 | 42 | |
42 | - <% button_bar do %> | |
43 | - <%= submit_button 'spread', _('Spread this') %> | |
43 | + <% button_bar do %> | |
44 | + <%= submit_button 'spread', _('Spread this') %> | |
45 | + <% end %> | |
44 | 46 | <% end %> |
45 | - <% end %> | |
46 | - </li> | |
47 | + </li> | |
48 | + <% end %> | |
47 | 49 | |
48 | - <li onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')"> | |
49 | - <strong><%= _("Publish this article on communities you are part of") %></strong> | |
50 | - <div class='description'><%= _('You can submit this article to one or more communities you are a member of, just search for the community below.') %></div> | |
51 | - <%= form_tag :action => 'publish_on_communities', :id => @article.id do %> | |
52 | - <%= hidden_field_tag :back_to, @back_to %> | |
53 | - <% search_action = url_for(:action => 'search_communities_to_publish') %> | |
54 | - <%= token_input_field_tag(:q, 'search-communities-to-publish', search_action, { :hint_text => _('Type in a search for your community'), :zindex => 10000, :focus => false }) %> | |
50 | + <% if user.communities.present? %> | |
51 | + <li onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')"> | |
52 | + <strong><%= _("Publish this article on communities you are part of") %></strong> | |
53 | + <div class='description'><%= _('You can submit this article to one or more communities you are a member of, just search for the community below.') %></div> | |
54 | + <%= form_tag :action => 'publish_on_communities', :id => @article.id do %> | |
55 | + <%= hidden_field_tag :back_to, @back_to %> | |
56 | + <% search_action = url_for(:action => 'search_communities_to_publish') %> | |
57 | + <%= token_input_field_tag(:q, 'search-communities-to-publish', search_action, { :hint_text => _('Type in a search for your community'), :zindex => 10000, :focus => false }) %> | |
55 | 58 | |
56 | - <div class='publish-article-title'> | |
57 | - <%= labelled_text_field _('Title'), 'name', @article.name %> | |
58 | - </div> | |
59 | - <% button_bar do %> | |
60 | - <%= submit_button 'spread', _('Spread this') %> | |
59 | + <div class='publish-article-title'> | |
60 | + <%= labelled_text_field _('Title'), 'name', @article.name %> | |
61 | + </div> | |
62 | + <% button_bar do %> | |
63 | + <%= submit_button 'spread', _('Spread this') %> | |
64 | + <% end %> | |
61 | 65 | <% end %> |
62 | - <% end %> | |
63 | - </li> | |
66 | + </li> | |
67 | + <% end %> | |
64 | 68 | |
65 | 69 | |
66 | -<% if @portal_enabled %> | |
67 | - <li onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')"> | |
68 | - <strong><%= _("Publish your article on portal community") %></strong> | |
69 | - <div class='description'><%= _('You can suggest this article to the portal community, where it can show up on the homepage.') %></div> | |
70 | + <% if @portal_enabled %> | |
71 | + <li onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')"> | |
72 | + <strong><%= _("Publish your article on portal community") %></strong> | |
73 | + <div class='description'><%= _('You can suggest this article to the portal community, where it can show up on the homepage.') %></div> | |
70 | 74 | |
71 | - <%= form_tag :action => 'publish_on_portal_community', :id => @article.id do %> | |
72 | - <%= hidden_field_tag :back_to, @back_to %> | |
73 | - <div class='publish-article-title'> | |
74 | - <%= labelled_text_field _('Title'), :name, @article.name %> | |
75 | - </div> | |
75 | + <%= form_tag :action => 'publish_on_portal_community', :id => @article.id do %> | |
76 | + <%= hidden_field_tag :back_to, @back_to %> | |
77 | + <div class='publish-article-title'> | |
78 | + <%= labelled_text_field _('Title'), :name, @article.name %> | |
79 | + </div> | |
76 | 80 | |
77 | - <% button_bar do %> | |
78 | - <%= submit_button 'spread', _('Spread this') %> | |
79 | - <% end %> | |
81 | + <% button_bar do %> | |
82 | + <%= submit_button 'spread', _('Spread this') %> | |
83 | + <% end %> | |
84 | + <% end %> | |
85 | + </li> | |
80 | 86 | <% end %> |
81 | - </li> | |
82 | -<% end %> | |
83 | 87 | </ul> |
84 | 88 | |
85 | 89 | </div> | ... | ... |