Guest User

Untitled

a guest
Jul 16th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. module ApplicationHelperPatch
  2. def self.included(base) # :nodoc:
  3. base.send(:include, InstanceMethods)
  4. end
  5.  
  6. module InstanceMethods
  7. # To hide or not to hide.
  8. def sp_css_hide(name)
  9. return sp_can_view(name) ? name: "#{name} #{SitePen::CSS_HIDE_FIELD}"
  10. end
  11.  
  12. # To view or not to view.
  13. def sp_can_view(name)
  14. # Admins can view everything
  15. return name if User.current.admin?
  16.  
  17. # If there is a permission and the user can't do it, hide it
  18. perm = "view_#{name}".to_sym
  19. if Redmine::AccessControl.permission(perm)
  20. if !User.current.allowed_to?(perm, @project, :global => true)
  21. return nil
  22. end
  23. end
  24.  
  25. # Otherwise, let them see it
  26. return name
  27. end
  28. end
  29. end
Add Comment
Please, Sign In to add comment