protected function _getLoginQuery($userName, $password, $shopId, $isAdmin)
    {
        $database = DatabaseProvider::getDb();
        $userNameCondition = $this->formQueryPartForUserName($userName, $database);
        $shopOrRightsCondition = $this->formQueryPartForAdminView($shopId, $isAdmin);
        $passwordCondition = $this->formQueryPartForSha512Password($password, $database, $userNameCondition, $shopOrRightsCondition);
        $userActiveCondition = $this->formQueryPartForActiveUser();


        $query = "SELECT `oxid`
                    FROM oxuser 
                    WHERE 1  
                    AND $userActiveCondition 
                    AND $passwordCondition 
                    AND $userNameCondition 
                    $shopOrRightsCondition
                    ";

        return $query;
    }