farra / radiant-members-extension
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
dbfc995
radiant-members-extension / members_extension.rb
| 65f96455 » | farra | 2008-09-15 | 1 | # Uncomment this if you reference any of your controllers in activate | |
| 73f811a3 » | farra | 2008-09-16 | 2 | require_dependency 'application' | |
| 65f96455 » | farra | 2008-09-15 | 3 | ||
| 4 | class MembersExtension < Radiant::Extension | ||||
| 5 | version "1.0" | ||||
| 6 | description "Extends Radiant user model for site members" | ||||
| 7 | url "http://cubiclemuses.com/cm" | ||||
| 8 | |||||
| 9 | define_routes do |map| | ||||
| 73f811a3 » | farra | 2008-09-16 | 10 | map.connect 'admin/members/register/:action', :controller => 'admin/members/register' | |
| 11 | map.connect 'admin/members/:action', :controller => 'admin/members/profile' | ||||
| 65f96455 » | farra | 2008-09-15 | 12 | end | |
| 13 | |||||
| 14 | def activate | ||||
| 73f811a3 » | farra | 2008-09-16 | 15 | admin.tabs.add "Profile", "/admin/members/", :after => "Layouts", :visibility => [:all] | |
| 65f96455 » | farra | 2008-09-15 | 16 | ||
| 73f811a3 » | farra | 2008-09-16 | 17 | User.class_eval do | |
| 65f96455 » | farra | 2008-09-15 | 18 | file_column :photo, :magick => { :geometry => "80x80>" } | |
| 73f811a3 » | farra | 2008-09-16 | 19 | validates_presence_of :email, :message => 'required' | |
| 20 | end | ||||
| 65f96455 » | farra | 2008-09-15 | 21 | ||
| 73f811a3 » | farra | 2008-09-16 | 22 | Radiant::AdminUI::Tab.class_eval do | |
| 23 | |||||
| 24 | alias_method :initialize_less_securely, :initialize unless method_defined?(:initialize_more_securely) | ||||
| 25 | |||||
| 26 | def initialize_more_securely(name, url, options = {}) | ||||
| 27 | @name, @url = name, url | ||||
| 28 | @visibility = [options[:for], options[:visibility]].flatten.compact | ||||
| 29 | @visibility = [:developer,:admin] if @visibility.empty? | ||||
| 30 | end | ||||
| 31 | |||||
| 32 | alias_method :initialize, :initialize_more_securely | ||||
| 33 | |||||
| 34 | end | ||||
| 35 | |||||
| 36 | Admin::PageController.class_eval do | ||||
| 37 | only_allow_access_to :index, :new, :edit, :remove, | ||||
| 38 | :when => [:developer, :admin], | ||||
| 39 | :denied_url => { :controller => 'welcome', :action => 'index' }, | ||||
| 40 | :denied_message => 'You must have developer privileges to perform this action.' | ||||
| 41 | end | ||||
| 42 | |||||
| 43 | Admin::SnippetController.class_eval do | ||||
| 44 | only_allow_access_to :index, :new, :edit, :remove, | ||||
| 45 | :when => [:developer, :admin], | ||||
| 46 | :denied_url => { :controller => 'welcome', :action => 'index' }, | ||||
| 47 | :denied_message => 'You must have developer privileges to perform this action.' | ||||
| 48 | end | ||||
| 49 | |||||
| 50 | Admin::WelcomeController.class_eval do | ||||
| 51 | alias_method :index_to_page, :index unless method_defined?(:index_to_profile) | ||||
| 52 | |||||
| 53 | def index_to_profile | ||||
| 54 | redirect_to :controller => 'admin/members/profile', :action => 'index' | ||||
| 55 | end | ||||
| 56 | |||||
| 57 | alias_method :index, :index_to_profile | ||||
| 58 | end | ||||
| 59 | |||||
| 60 | |||||
| 65f96455 » | farra | 2008-09-15 | 61 | end | |
| 62 | |||||
| 63 | def deactivate | ||||
| 64 | admin.tabs.remove "Profile" | ||||
| 65 | end | ||||
| 66 | |||||
| 67 | end | ||||
