@param string $userName
@param int    $shopId

@return false|string
325258
private function getUserIdByUserName($userName, $shopId)
    {

        $select = "SELECT `OXID` 
          FROM `oxuser` 
          WHERE `OXACTIVE` = 1 
          AND `OXUSERNAME` = ? 
          AND `OXPASSWORD` != ''";
        if (Registry::getConfig()->getConfigParam('blMallUsers')) {
            $select .= "ORDER BY OXSHOPID = ? DESC";
        } else {
            $select .= "AND OXSHOPID = ?";
        }
        $sOxId = \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->getOne(
            $select,
            [$userName,
             $shopId]
        );

        return $sOxId;
    }
477834
public function createChooseCardJsPackage($cardid = null, $cardtype = null, $shopid = null)
    {
        $data = array();
        $data['api_ticket'] = $this->getJsCardTicket();
        $data['app_id'] = $this->appid;
        $data['timestamp'] = time();
        $data['nonceStr'] = Tools::createNoncestr();
        !empty($cardid) && $data['cardId'] = $cardid;
        !empty($cardtype) && $data['cardType'] = $cardtype;
        !empty($shopid) && $data['shopId'] = $shopid;
        $data['cardSign'] = $this->getTicketSignature($data);
        $data['signType'] = 'SHA1';
        unset($data['api_ticket'], $data['app_id']);
        return $data;
    }
99356
public function getNextOxsort($shopId)
    {
        $query = "SELECT MAX(`oxsort`)+10 FROM `oxdiscount` WHERE `oxshopid` = ?";
        $nextSort = \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->getOne($query, [$shopId]);

        return (int) $nextSort;
    }
859304
public static function getAvatarById($userId, $size = self::AVATAR_MIDDLE)
    {
        $user = User::findOne(['id' => $userId]);
        if ($user) {
            return self::getAvatar($user, $size);
        }
        return '';
    }
1004967
public function username($username)
    {
        $app = Application::getFacadeApplication();
        $validator = $app->make('validator/user/name');
        foreach ($validator->getValidators() as $handle => $validator) {
            if ($handle !== 'unique_username') {
                if (!$validator->isValid($username)) {
                    return false;
                }
            }
        }

        return true;
    }
805356
public function exceedsLimit($user_id, $store_id)
    {
        if ($this->user->isSuperadmin($user_id)) {
            return false; // No limits for superadmin
        }

        $limit = $this->getLimit($user_id);

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

        $conditions = array(
            'user_id' => $user_id,
            'store_id' => $store_id
        );

        $existing = $this->getList($conditions);
        return count($existing) > $limit;
    }
423797
public function getUser($username)
    {
        $resellers = $this->getUsers();
        return isset($resellers[$username]) ? $resellers[$username] : null;
    }
783444
public static function createInstance($auth_domain_id, $username)
	{
		if (empty($auth_domain_id) || empty($username))
		{
			return false;
		}

		$row = self::blank();
		$row->set('auth_domain_id', $auth_domain_id);
		$row->set('username', $username);
		$row->save();

		if (!$row->get('id'))
		{
			return false;
		}

		return $row;
	}
185090
public function handleOnModuleActivation(ModuleSetting $moduleSetting, string $moduleId, int $shopId)
    {
        if (!$this->canHandle($moduleSetting)) {
            throw new WrongModuleSettingException($moduleSetting, self::class);
        }

        foreach ($moduleSetting->getValue() as $shopModuleSettingData) {
            $shopModuleSetting = new ShopModuleSetting();
            $shopModuleSetting
                ->setShopId($shopId)
                ->setModuleId($moduleId);

            $shopModuleSetting = $this->mapDataToShopModuleSetting($shopModuleSetting, $shopModuleSettingData);

            $this->shopModuleSettingDao->save($shopModuleSetting);
        }
    }
496775
public function flushAccess($itemName, $userId)
    {
        if (($cache = $this->getCache()) !== null) {
            $cacheKey = $this->resolveCacheKey($itemName, $userId);
            return $cache->delete($cacheKey);
        }
        return false;
    }
674277
public static function get($mShopId)
    {
        $sSQL = 'SELECT 1 FROM oxshops WHERE oxid = %s';
        $oDb = DatabaseProvider::getDb();

        if (!$oDb->getOne(sprintf($sSQL, $oDb->quote($mShopId)))) { // invalid shop id
            // Not using oxConfig::_isValidShopId() because its not static, but YES it should be
            return null;
        }

        return new ShopConfig($mShopId);
    }
36327
public function activate(string $moduleId, int $shopId)
    {
        if ($this->stateService->isActive($moduleId, $shopId) === true) {
            throw new ModuleSetupException('Module with id "'. $moduleId . '" is already active.');
        }

        $moduleConfiguration = $this->moduleConfigurationDao->get($moduleId, $shopId);

        $this->moduleSettingsHandlingService->handleOnActivation($moduleConfiguration, $shopId);

        $this->moduleServicesActivationService->activateModuleServices($moduleId, $shopId);

        $this->stateService->setActive($moduleId, $shopId);

        $moduleConfiguration->setAutoActive(true);
        $this->moduleConfigurationDao->save($moduleConfiguration, $shopId);

        $this->classExtensionChainService->updateChain($shopId);

        $this->eventDispatcher->dispatch(
            FinalizingModuleActivationEvent::NAME,
            new FinalizingModuleActivationEvent($shopId, $moduleId)
        );
    }
24427
public function usernameToGuid($username)
    {
        $this->adldap->utilities()->validateNotNull('Username', $username);

        $this->adldap->utilities()->validateLdapIsBound();

        $filter = $this->adldap->getUserIdKey().'='.$username;

        $fields = ['objectGUID'];

        $results = $this->connection->search($this->adldap->getBaseDn(), $filter, $fields);

        $numEntries = $this->connection->countEntries($results);

        if ($numEntries > 0) {
            $entry = $this->connection->getFirstEntry($results);

            $guid = $this->connection->getValuesLen($entry, 'objectGUID');

            $strGUID = $this->adldap->utilities()->binaryToText($guid[0]);

            return $strGUID;
        }

        return false;
    }
658763
public function addShopWifi($shop_id, $ssid, $password = null)
    {
        $data = ['shop_id' => $shop_id, 'ssid' => $ssid, 'password' => $password];
        $url = 'https://api.weixin.qq.com/bizwifi/device/add?access_token=ACCESS_TOKEN';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
633053
public function getByUsername($username)
    {
        if (!is_string($username)) {
            return false;
        }

        $data = [
            'where' => [
                [
                    'column' => $this->tableAlias . '.username',
                    'value'  => $username,
                ],
            ],
        ];

        $user = $this->getAll(null, null, $data);

        return empty($user) ? false : $user[0];
    }
854197
public function get($shopId)
    {
        $resource = 'shop/' . $shopId . '.json';
        $response = $this->getServiceResponse($resource);

        $getShopResponse = new Models\ResponseShopGet($response);

        return $getShopResponse->getShop();
    }
319032
public function getFiles(array $shopIds)
    {
        $this->restClient->getConfig()->setPath(
            'request.options/headers/Authorization',
            $this->operatorKey
        );
        $command = $this->restClient->getCommand(
            'GetDocuments',
            array(
                'shopIds' => $shopIds,
            )
        );

        $result = $this->restClient->execute($command);

        return $result['shop_documents'];
    }