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
49
50
51
52
53
54
55 |
class ProjectAreaController < ApplicationController
before_filter :find_project
before_filter :authorize
class << self
def menu_item(*args, &block)
options = args.extract_options!
if args.first
RetroAM.menu_map.push(self, args.first, options, &block)
elsif options[:use]
RetroAM.menu_links[name] = options[:use]
elsif options[:none]
RetroAM.menu_links[name] = options[:use]
end
end
def authorize?(action_name, request_params = {}, user = User.current, project = Project.current)
name = RetroAM.menu_links[self.name] || self.name
item = RetroAM.menu_items.find {|i| i.active?(name, action_name) }
module_enabled?(project, item) && module_accessible?(project, item) ? super : false
end
def module_enabled?(project, item)
project.present? and item.present? and project.enabled_modules.include?(item.name)
end
protected :module_enabled?
def module_accessible?(project, item)
project.present? and item.present? and item.accessible?(project)
end
protected :module_accessible?
end
protected
def fresh_when(options = {})
options[:etag] = [User.current, Project.current, flash] + Array(options[:etag])
super
end
def find_project
project = Project.find_by_short_name! params[:project_id]
Project.current = User.current.projects.active.find(project.short_name)
I18n.locale = Project.current.locale if Project.current && Project.current.locale
end
def render_rss(klass, records = nil, options = {})
records ||= instance_variable_get("@#{klass.name.tableize}".to_sym)
render :xml => klass.to_rss(records, options).to_s, :content_type => 'application/rss+xml'
end
end |