Checks if the User with email $email exists

@param string $email User email
@param string $parentGroupName User group name to search inside

@return boolean true if it exists, false if not
502208
public function checkUserExistenceByEmail( $email, $parentGroupName = null )
    {
        /** @var \eZ\Publish\API\Repository\Repository $repository */
        $repository = $this->getRepository();
        $userService = $repository->getUserService();

        $existingUsers = $userService->loadUsersByEmail( $email );
        if ( count( $existingUsers ) == 0 )
        {
            return false;
        }

        if ( $parentGroupName )
        {
            foreach ( $existingUsers as $user )
            {
                $userGroups = $userService->loadUserGroupsOfUser( $user );
                foreach ( $userGroups as $userGroup )
                {
                    if ( $userGroup->getFieldValue( 'name' ) == $parentGroupName )
                        return true;
                }
            }
        }

        return false;
    }
567383
public function isValid($email)
    {
        // Does it look like an email address?
        if (! $this->isEmail($email)) {
            return false;
        }

        // Is is an example domain?
        if ($this->isExample($email)) {
            return false;
        }

        // Is is a it disposable?
        if ($this->isDisposable($email)) {
            return false;
        }

        // Is it role based?
        if ($this->isRole($email)) {
            return false;
        }

        // Does it have an MX record?
        if (! $this->hasMx($email)) {
            return false;
        }

        return true;
    }
1220824
private function checkHeadersForInjection(\sb\Email $email)
    {

        if (\preg_match("~\r|:~i", $email->to) || preg_match("~\r|:~i", $email->from)) {
            return true;
        }

        return false;
    }
478375
public function ensureUserGroupDoesntExist( $name, $parentGroupName = null )
    {
        $repository = $this->getRepository();
        $userService = $repository->getUserService();

        if ( $parentGroupName )
        {
            // find parent group name
            $searchResults = $this->searchUserGroups( $parentGroupName );
            if ( empty( $searchResults ) )
            {
                throw new \Exception( "Could not find parent User Group with name '$name'." );
            }

            $parentGroupLocationId = $searchResults[0]->valueObject->contentInfo->mainLocationId;
        }
        else
        {
            $parentGroupLocationId = null;
        }

        $searchResults = $this->searchUserGroups( $name, $parentGroupLocationId );

        if ( empty( $searchResults ) )
        {
            // no existing User Groups found
            return;
        }
        // else, remove existing groups
        $repository->sudo(
            function() use( $searchResults, $userService )
            {
                foreach ( $searchResults as $searchHit )
                {
                    //Attempt to delete User Group
                    try
                    {
                        $userGroup = $userService->loadUserGroup( $searchHit->valueObject->contentInfo->id );
                        $userService->deleteUserGroup( $userGroup );
                    }
                    catch ( ApiExceptions\NotFoundException $e )
                    {
                        // nothing to do
                    }
                }
            }
        );
    }
1092757
public function isEmailTaken($email)
    {
        $query = "SELECT count(*) FROM {$this->config->table_users} WHERE email = :email";
        $query_prepared = $this->dbh->prepare($query);
        $query_prepared->execute(['email' => $email]);

        if ($query_prepared->fetchColumn() == 0) {
            return false;
        }

        return true;
    }
217226
protected function grouped_parent_exists($pelement, $elements) {
        foreach ($elements as $element) {
            if ($pelement->get_path() == $element->get_path()) {
                continue; // Don't compare against itself
            }
            // If element is grouped and parent of pelement, return true
            if ($element->is_grouped() and strpos($pelement->get_path() .  '/', $element->get_path()) === 0) {
                return true;
            }
        }
        return false; // no grouped parent found
    }
923968
public function hasParent($itemName, $parentName)
    {
        $parents = $this->getParents($itemName);
        if (in_array($parentName, $parents)) {
            return true;
        }
        return false;
    }
42842
private function userFromEmail($email)
    {
        $parts = explode('@', $email);

        if (count($parts) == 2) {
            return strtolower($parts[0]);
        }

        return null;
    }
800646
public function accountExists($email)
	{
		// E-Mail check
		$stmntEmailCheck = $this->db->prepare("SELECT ID FROM " . $this->settings['db_login_table'] . " WHERE email = ?");
		$resEmailCheck = $this->db->select($stmntEmailCheck, array($email));

		return (count($resEmailCheck) > 0)?$resEmailCheck[0]->ID:false;
	}
626187
public function iHaveUserGroupWithIdInGroup( $name, $id, $parentGroup )
    {
        $userGroup = $this->getUserGroupManager()->ensureUserGroupExists( $name, $parentGroup );
        $this->addValuesToMap( $id, $userGroup->id );
    }
655612
public function isValidEmail($email)
    {
        if (filter_var($email, FILTER_VALIDATE_EMAIL) !== false) {
            return true;
        }
        if (filter_var($email, FILTER_SANITIZE_EMAIL) !== false) {
            return true;
        } else {
            return false;
        }
    }
465745
public function validateEmail($email)
    {
        // Split email address up and disallow '..'
        $pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
        if ((strpos($email, '..') === false) && preg_match( $pattern, $email))
        {
            return true;
        }

        return false;
    }
35062
public function checkUserExistenceByUsername($username, $parentGroupName = null)
    {
        if ($parentGroupName) {
            // find parent group name
            $searchResults = $this->searchUserGroups($parentGroupName);
            if (empty($searchResults)) {
                // group not found, so return immediately
                return false;
            }
            $groupId = $searchResults[0]->valueObject->contentInfo->id;
        } else {
            $groupId = null;
        }
        $searchResults = $this->searchUserByLogin($username, $groupId);

        return empty($searchResults) ? false : true;
    }
852903
public function assertUserGroupWithNameExistsInGroup( $name, $parentGroup )
    {
        Assertion::assertTrue(
            $this->getUserGroupManager()->checkUserGroupExistenceByName( $name, $parentGroup ),
            "Couldn't find UserGroup with name '$name' in parent group '$parentGroup'."
        );
    }
1333738
public function isDisposable($email)
    {
        if (! $this->isEmail($email)) {
            return null;
        }

        $hostname = $this->hostnameFromEmail($email);

        if ($hostname) {
            // Load disposable domains
            if (is_null($this->disposable)) {
                $data = new \EmailData\Data();
                $file = $data->getPathToDataFile('php');
                $this->disposable = include($file);
            }

            // Search array for hostname
            if (in_array($hostname, $this->disposable)) {
                return true;
            }

            return false;
        }

        return null;
    }
1374654
public static function find_by_email($email)
	{
		if (empty($email))
		{
			return false;
		}

		$db = \App::get('db');
		$db->setQuery("SELECT username FROM `#__xprofiles` WHERE `email`=" . $db->quote($email));

		$result = $db->loadColumn();

		if (empty($result))
		{
			return false;
		}

		return $result;
	}
1317604
public function iHaveUserInGroup( $username, $parentGroupName )
    {
        $email = $this->findNonExistingUserEmail( $username );
        $password = $this->getUserManager()->getDefaultPassword();
        $user = $this->getUserManager()->ensureUserExists( $username, $email, $password, $parentGroupName );
        $this->addValuesToKeyMap( $email, $user->email );
    }