Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module ApplicationHelperPatch
- def self.included(base) # :nodoc:
- base.send(:include, InstanceMethods)
- end
- module InstanceMethods
- # To hide or not to hide.
- def sp_css_hide(name)
- return sp_can_view(name) ? name: "#{name} #{SitePen::CSS_HIDE_FIELD}"
- end
- # To view or not to view.
- def sp_can_view(name)
- # Admins can view everything
- return name if User.current.admin?
- # If there is a permission and the user can't do it, hide it
- perm = "view_#{name}".to_sym
- if Redmine::AccessControl.permission(perm)
- if !User.current.allowed_to?(perm, @project, :global => true)
- return nil
- end
- end
- # Otherwise, let them see it
- return name
- end
- end
- end
Add Comment
Please, Sign In to add comment