UserModel::addIpFilters PHP Method

addIpFilters() private method

Appends filters to the current SQL object. Filters users with a given IP Address in the UserIP table. Extends filtering to IPs in the GDN_User table for any fields passed in the $fields param.
private addIpFilters ( string $ip, array $fields = [] )
$ip string The IP Address to search for.
$fields array The additional fields to check in the UserTable
    private function addIpFilters($ip, $fields = [])
    {
        $this->SQL->join('UserIP uip', 'u.userID = uip.UserID', 'left');
        $this->SQL->orOp()->beginWhereGroup()->orWhere('uip.IPAddress', inet_pton($ip));
        $allowedFields = ['LastIPAddress', 'InsertIPAddress', 'UpdateIPAddress'];
        foreach ($fields as $field) {
            if (in_array($field, $allowedFields)) {
                $this->SQL->orWhereIn('u.' . $field, [$ip, inet_pton($ip)]);
            }
        }
        $this->SQL->endWhereGroup();
    }
UserModel