  def self.arrange_per_scope(address, user, scope, group_ids, team_ids)

    SqlHelper.validate_token([group_ids, team_ids])

    case scope
     when 'private'
      address.owner_id = user.id
      address.groups = nil
      address.teams = nil

     when 'all'
      return false unless user.admin?(User::AUTH_ADDRESSBOOK)

      address.owner_id = 0
      address.groups = nil
      address.teams = nil

     when 'common'
      return nil unless user.admin?(User::AUTH_ADDRESSBOOK)

      address.owner_id = 0

      if group_ids.nil? or group_ids.empty?
        address.groups = nil
      else
        address.groups = '|' + group_ids.join('|') + '|'
      end

      if team_ids.nil? or team_ids.empty?
        address.teams = nil
      else
        address.teams = '|' + team_ids.join('|') + '|'
      end
    end
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.