shareOptions.go 658 B

123456789101112131415161718192021222324
  1. package shareEntry
  2. func (s *ShareOption) IsOwnedBy(username string) bool {
  3. return s.Owner == username
  4. }
  5. func (s *ShareOption) IsAccessibleBy(username string, usergroup []string) bool {
  6. if s.Permission == "anyone" || s.Permission == "signedin" {
  7. return true
  8. } else if s.Permission == "samegroup" || s.Permission == "groups" {
  9. for _, thisUserGroup := range usergroup {
  10. if stringInSlice(thisUserGroup, s.Accessibles) {
  11. //User's group is in the allowed group
  12. return true
  13. }
  14. }
  15. } else if s.Permission == "users" {
  16. if stringInSlice(username, s.Accessibles) {
  17. //User's name is in the allowed group
  18. return true
  19. }
  20. }
  21. return false
  22. }