shareOptions.go 736 B

123456789101112131415161718192021222324252627
  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. } else if s.Owner == username {
  20. //This user own this file
  21. return true
  22. }
  23. }
  24. return false
  25. }