Module: Plugins::VisibilityPost::VisibilityPostHelper
- Defined in:
- app/apps/plugins/visibility_post/visibility_post_helper.rb
Instance Method Summary collapse
- #plugin_visibility_can_visit(args) ⇒ Object
- #plugin_visibility_create_post(args) ⇒ Object
- #plugin_visibility_extra_columns(args) ⇒ Object
- #plugin_visibility_filter_post(args) ⇒ Object
- #plugin_visibility_new_post(args) ⇒ Object
- #plugin_visibility_on_active(plugin) ⇒ Object
- #plugin_visibility_on_inactive(plugin) ⇒ Object
- #plugin_visibility_post_list(args) ⇒ Object
-
#plugin_visibility_post_the_content(args) ⇒ Object
object.content.translate(@_deco_locale), post: object.
Instance Method Details
#plugin_visibility_can_visit(args) ⇒ Object
28 29 30 31 32 33 |
# File 'app/apps/plugins/visibility_post/visibility_post_helper.rb', line 28 def plugin_visibility_can_visit(args) post = args[:post] return args[:flag] = false if post.published_at.present? && post.published_at > Time.now return if post.visibility != 'private' args[:flag] = false unless signin? && post.visibility_value.split(",").include?(current_site.visitor_role) end |
#plugin_visibility_create_post(args) ⇒ Object
20 21 22 |
# File 'app/apps/plugins/visibility_post/visibility_post_helper.rb', line 20 def plugin_visibility_create_post(args) save_visibility(args[:post]) end |
#plugin_visibility_extra_columns(args) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'app/apps/plugins/visibility_post/visibility_post_helper.rb', line 35 def plugin_visibility_extra_columns(args) if args[:from_body] args[:content] = "<td><i class='fa fa-#{{"private"=>"lock", ""=>"lock", "public"=>"eye", "password"=>"eye-slash"}[args[:post].visibility]}'></i> #{args[:post].visibility}</td>" args[:content] = "<td>#{args[:post].published_at.present? ? args[:post].published_at.strftime('%B %e, %Y %H:%M') : args[:post].the_created_at}</td>" else args[:content] = "<th>#{t('camaleon_cms.admin.table.visibility')}</th>" args[:content] = "<th>#{t('camaleon_cms.admin.table.date_published')}</th>" end end |
#plugin_visibility_filter_post(args) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/apps/plugins/visibility_post/visibility_post_helper.rb', line 45 def plugin_visibility_filter_post(args) args[:active_record] = args[:active_record].where("(#{CamaleonCms::Post.table_name}.published_at is null or #{CamaleonCms::Post.table_name}.published_at <= ?)", Time.now) if signin? if ActiveRecord::Base.connection.adapter_name.downcase.include?("mysql") args[:active_record] = args[:active_record].where("visibility != 'private' or (visibility = 'private' and FIND_IN_SET(?, #{CamaleonCms::Post.table_name}.visibility_value))", current_site.visitor_role) else args[:active_record] = args[:active_record].where("visibility != 'private' or (visibility = 'private' and (',' || #{CamaleonCms::Post.table_name}.visibility_value || ',') LIKE '%,#{current_site.visitor_role},%')") end else args[:active_record] = args[:active_record].where("visibility != 'private'") end end |
#plugin_visibility_new_post(args) ⇒ Object
24 25 26 |
# File 'app/apps/plugins/visibility_post/visibility_post_helper.rb', line 24 def plugin_visibility_new_post(args) args[:extra_settings] << form_html(args[:post]) end |
#plugin_visibility_on_active(plugin) ⇒ Object
9 10 |
# File 'app/apps/plugins/visibility_post/visibility_post_helper.rb', line 9 def plugin_visibility_on_active(plugin) end |
#plugin_visibility_on_inactive(plugin) ⇒ Object
12 13 |
# File 'app/apps/plugins/visibility_post/visibility_post_helper.rb', line 12 def plugin_visibility_on_inactive(plugin) end |
#plugin_visibility_post_list(args) ⇒ Object
15 16 17 18 |
# File 'app/apps/plugins/visibility_post/visibility_post_helper.rb', line 15 def plugin_visibility_post_list(args) args[:posts] = args[:posts].where(visibility: "private") if params[:s] == "private" args[:btns][:private] = "#{t('camaleon_cms.admin.table.private')} (#{args[:all_posts].where(visibility: "private").size})" end |
#plugin_visibility_post_the_content(args) ⇒ Object
object.content.translate(@_deco_locale), post: object
2 3 4 5 6 7 |
# File 'app/apps/plugins/visibility_post/visibility_post_helper.rb', line 2 def plugin_visibility_post_the_content(args) #{content: object.content.translate(@_deco_locale), post: object} if args[:post].visibility == "password" return if params[:post_password].present? && params[:post_password] == args[:post].visibility_value args[:content] = _password_form end end |