public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
francois (author)
Mon Mar 10 20:03:37 -0700 2008
commit  a0ce1ae632eba963b678dd36b3b67b7a04d42f59
tree    b84c3e3001e17152339598b254c7e4ce857ab8fb
parent  429ecf2948716ebb2905174653643eba4299a97e parent  752c317ef3e42ccd14c4cb53a8ca7c37734513ac
mephisto / app / controllers / admin / base_controller.rb
100644 27 lines (22 sloc) 1.065 kb
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
class Admin::BaseController < ApplicationController
  class_inheritable_reader :member_actions
  write_inheritable_attribute :member_actions, []
  before_filter { |c| UserMailer.default_url_options[:host] = c.request.host_with_port }
  before_filter :login_required, :except => :feed
 
  protected
    # standard authorization method. allow logged in users that are admins, or members in certain actions
    def authorized?
      logged_in? && (admin? || member_actions.include?(action_name) || allow_member?)
    end
 
    # further customize the authorization process, for those special methods that require extra validation
    def allow_member?
      true
    end
 
    def find_and_sort_templates
      @layouts, @templates = site.templates.partition { |t| t.dirname.to_s =~ /layouts$/ }
    end
    
    def self.clear_empty_templates_for(model, *attributes)
      options = attributes.last.is_a?(Hash) ? attributes.pop : {}
      before_filter(options) { |c| attributes.each { |attr| c.params[model][attr] = nil if c.params[model][attr] == '-' } }
    end
end