interim_stream_hackiness_helper.rb 921 Bytes
Newer Older
1 2 3 4 5 6 7
module InterimStreamHackinessHelper
  def commenting_disabled?(post)
    return true unless user_signed_in?
    if defined?(@commenting_disabled)
      @commenting_disabled
    elsif defined?(@stream)
      !@stream.can_comment?(post)
8
    else
9 10 11 12 13 14 15 16
      false
    end
  end

  def publisher_prefill_text
    if params[:prefill].present?
      params[:prefill]
    elsif defined?(@stream)
17
      @stream.publisher.prefill
18 19 20 21
    else
      nil
    end
  end
22 23

  def from_group(post)
24
    if defined?(@stream) && params[:controller] == 'multis'
25 26
      @stream.post_from_group(post)
    else
27
     []
28 29 30
    end
  end

31 32
  def what_stream_sentence(post)
    from_group(post).map{|x| I18n.t("streams.#{x.to_s}")}.to_sentence
33
  end
34 35 36 37

  def stream_settings_link(post)
    link_to "", "#{edit_user_path}#stream-preferences"
  end
38 39 40 41 42 43 44 45

  def publisher_open
    if defined?(@stream)
      @stream.publisher.open?
    else
      false
    end
  end
46
end