cloud_controller/app/models/service.rb
def visible_to_user?(user, plan=nil)
    return false if !plans || !user.email
    return true unless acls

    if !plan
      plans.each do |p|
        return true if visible_to_user?(user, p)
      end
      return false
    else
      # for certain plan, user should match service acls and plan acls
      p_acls = acls["plans"] && acls["plans"][plan]
      validate_by_acls?(user, acls) && validate_by_acls?(user, p_acls)
    end
  end
# Predicate function that returns true if the service is visible to the supplied
# user. False otherwise.
#
# There are two parts of acls. One is service acls applied to service as a whole
# One is plan acls applied to specific service plan.
#
# A example of acls structure:
# acls:
#   users:              #service acls
#   - foo@bar.com
#   - foo1@bar.com
#   wildcards:          #service acls
#   - *@foo.com
#   - *@foo1.com
#   plans:
#     plan_a:           #plan acls
#       users:
#       - foo2@foo.com
#       wildcards:
#       - *@foo1.com
#
# The following chart shows service visibility:
#
# P_ACLs\S_ACLs | Empty       | HasACLs                    |
#   Empty       | True        | S_ACL(user)                |
#   HasACLs     | P_ACL(user) | S_ACL(user) && P_ACL(user) |
Predicate function that returns true if the service is visible to the supplied
user. False otherwise.

There are two parts of acls. One is service acls applied to service as a whole
One is plan acls applied to specific service plan.



The following chart shows service visibility.


Predicate function that returns true if the service is visible to the supplied user . False otherwise . There are two parts of acls . One is service acls applied to service as a whole One is plan acls applied to specific service plan . The following chart shows service visibility .
def visible_to_user?(user, plan=nil)
    return false if !plans || !user.email
    return true unless acls
    if !plan
      plans.each do |p|
        return true if visible_to_user?(user, p)
      end
      return false
    else
      p_acls = acls["plans"] && acls["plans"][plan]
      validate_by_acls?(user, acls) && validate_by_acls?(user, p_acls)
    end
  end
def visible_to_user? ( user , plan = nil ) return false if ! plans || ! user . email return true unless acls if ! plan plans . each do | p | return true if visible_to_user? ( user , p ) end return false else p_acls = acls [ "plans" ] && acls [ "plans" ] [ plan ] validate_by_acls? ( user , acls ) && validate_by_acls? ( user , p_acls ) end end
Predicate function that returns true if the service is visible to the supplied
user.
Predicate function that returns true if the service is visible to the supplied user .
# for certain plan, user should match service acls and plan acls
user
plan