Module: Admin::GroupsHelper

Defined in:
app/helpers/admin/groups_helper.rb

Instance Method Summary collapse

Instance Method Details

#choose_page(object, field, select_options = {}) ⇒ Object



18
19
20
21
22
23
# File 'app/helpers/admin/groups_helper.rb', line 18

def choose_page(object, field, select_options={})
  root = Page.respond_to?(:homepage) ? Page.homepage : Page.find_by_parent_id(nil)
  options = page_option_branch(root)
  options.unshift ['<none>', nil]
  select object, field, options, select_options
end

#message_preview(subject, body, reader) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/admin/groups_helper.rb', line 3

def message_preview(subject, body, reader)
  preview = "From: \#{current_user.name} &lt;\#{current_user.email}&gt;\nTo: \#{reader.name} &lt;\#{reader.email}&gt;\nDate: \#{Time.now.to_date.to_s :long}\n<strong>Subject: \#{subject}</strong>\n\nDear \#{reader.name},\n\n\#{body}\n\n"
simple_format(preview)
end

#page_option_branch(page, depth = 0) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'app/helpers/admin/groups_helper.rb', line 25

def page_option_branch(page, depth=0)
  options = []
  unless page.title.first == '_'
    options << ["#{". " * depth}#{h(page.title)}", page.id]
    page.children.each do |child|
      options += page_option_branch(child, depth + 1)
    end
  end
  options
end