2011-10-24 23:07:11 +01:00
|
|
|
class ActionController::Base
|
2011-10-23 22:39:44 +01:00
|
|
|
|
|
|
|
def can_perform? target = :system
|
|
|
|
c = self.controller_name
|
|
|
|
a = self.action_name
|
|
|
|
|
2011-10-31 18:14:25 +00:00
|
|
|
unless current_user.can_perform? c, a, target
|
2011-10-23 22:39:44 +01:00
|
|
|
flash[:notice] = t('layout.not_access')
|
2011-10-28 18:55:10 +01:00
|
|
|
if request.env['HTTP_REFERER']
|
|
|
|
redirect_to(:back)
|
|
|
|
else
|
|
|
|
redirect_to(:root)
|
|
|
|
end
|
2011-10-23 22:39:44 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-31 18:14:25 +00:00
|
|
|
def check_global_access
|
|
|
|
can_perform? :system
|
|
|
|
end
|
|
|
|
|
2011-10-23 22:39:44 +01:00
|
|
|
def rights_to target
|
2011-10-24 11:47:32 +01:00
|
|
|
ActiveRecord::Base.rights_to target
|
|
|
|
end
|
|
|
|
|
|
|
|
def roles_to target
|
|
|
|
ActiveRecord::Base.roles_to target
|
2011-10-23 22:39:44 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|