-
Notifications
You must be signed in to change notification settings - Fork 2
/
beastly_extension.rb
48 lines (40 loc) · 1.2 KB
/
beastly_extension.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Uncomment this if you reference any of your controllers in activate
require_dependency 'application'
class BeastlyExtension < Radiant::Extension
version "0.1"
description "Allow your Radiant to play with Altered Beast forum software."
url "http://rubidine.com/open-source/beastly"
# define_routes do |map|
# map.connect 'admin/beastly/:action', :controller => 'admin/beastly'
# end
def activate
controllers = [
Admin::AbstractModelController,
Admin::ExportController,
Admin::ExtensionsController,
Admin::LayoutsController,
Admin::PagesController,
Admin::SnippetsController,
Admin::UsersController
]
controllers.each do |c|
methods = c.action_methods.to_a
methods << {
:when => :admin,
:denied_url => {:action=>'login', :controller=>'admin/welcome'},
:denied_message => 'You must have administrative privileges to perform this action'
}
c.send :only_allow_access_to, *methods
end
Admin::WelcomeController.class_eval do
def index
if current_user.admin?
redirect_to page_index_url
return
end
end
end
end
def deactivate
end
end