2011-10-23 22:39:44 +01:00
|
|
|
class ApplicationController::Base
|
|
|
|
|
|
|
|
def can_perform? target = :system
|
|
|
|
c = self.controller_name
|
|
|
|
a = self.action_name
|
|
|
|
|
|
|
|
current_user.can_perform? c, a, target
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_global_rights
|
|
|
|
unless can_perform?
|
|
|
|
flash[:notice] = t('layout.not_access')
|
|
|
|
redirect_to(:back)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|