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 = <<EOM
From: #{current_user.name} &lt;#{current_user.email}&gt;
To: #{reader.name} &lt;#{reader.email}&gt;
Date: #{Time.now.to_date.to_s :long}
<strong>Subject: #{subject}</strong>

Dear #{reader.name},

#{body}

EOM
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