Verify that a given delivery execution is allowed to be executed

@param DeliveryExecutionInterface $deliveryExecution
@param User $user
324198
public function verifyResumeAuthorization(DeliveryExecutionInterface $deliveryExecution, User $user)
    {
        foreach ($this->getProviders() as $provider) {
            $provider->verifyResumeAuthorization($deliveryExecution, $user);
        }
        $this->getServiceManager()->get(EventManager::SERVICE_ID)->trigger(new DeliveryExecutionVerified($deliveryExecution));
    }
450999
public function checkCode(UserInterface $user, $code)
    {
        return $this->authenticator->checkCode($user->getTwoStepVerificationCode(), $code);
    }
1088606
protected function checkActivation(UserInterface $user)
    {
        $completed = $this->activations->completed($user);

        if (! $completed) {
            $exception = new NotActivatedException('Your account has not been activated yet.');

            $exception->setUser($user);

            throw $exception;
        }
    }
768527
public function byDeliveryExecution()
    {
        try
        {
            $this->checkMethod();

            $this->validateParams(array(self::DELIVERY_EXECUTION));

            $deliveryExecution = $this->getQtiResultService()->getDeliveryExecutionById(
                $this->getRequestParameter(self::DELIVERY_EXECUTION)
            );

            $this->returnValidXml($this->getQtiResultService()->getDeliveryExecutionXml($deliveryExecution));
        } catch (Exception $e) {
            $this->returnFailure($e);
        }
    }
928899
protected function createRememberTokenIfDoesntExist(UserInterface $user)
    {
        $rememberToken = $user->getRememberToken();

        if (empty($rememberToken)) {
            $this->refreshRememberToken($user);
        }
    }
539964
public function legacyTransition(DeliveryExecution $deliveryExecution, $state)
    {
        switch ($state) {
            case DeliveryExecution::STATE_FINISHED:
                $result = $this->finish($deliveryExecution);
                break;
            case DeliveryExecution::STATE_ACTIVE:
                $result = $this->run($deliveryExecution);
                break;
            case DeliveryExecution::STATE_PAUSED:
                $result = $this->pause($deliveryExecution);
                break;
            default:
                $this->logWarning('Unrecognised state '.$state);
                $result = $this->setState($deliveryExecution, $state);
        }
        return $result;
    }
1184526
protected function terminateExecution(DeliveryExecution $deliveryExecution) {
        if ($this->wetRun === true) {
            $deliveryExecutionStateService = ServiceManager::getServiceManager()->get(DeliveryExecutionStateService::SERVICE_ID);
            $deliveryExecutionStateService->terminateExecution(
                $deliveryExecution,
                [
                    'reasons' => $this->getTerminationReasons(),
                    'comment' => __('The assessment was automatically terminated by the system due to inactivity.'),
                ]
            );
            $this->addReport(Report::TYPE_INFO, "Delivery execution {$deliveryExecution->getIdentifier()} has been terminated.");
        } else {
            $this->addReport(Report::TYPE_INFO, "Delivery execution {$deliveryExecution->getIdentifier()} should be terminated.");
        }
    }
725757
public function getLinkedDeliveryExecutions(\core_kernel_classes_Resource $delivery, \core_kernel_classes_Resource $link, $userId)
    {
        $class = new \core_kernel_classes_Class(OntologyLTIDeliveryExecutionLink::CLASS_LTI_DELIVERYEXECUTION_LINK);
        $links = $class->searchInstances([
            OntologyLTIDeliveryExecutionLink::PROPERTY_LTI_DEL_EXEC_LINK_USER => $userId,
            OntologyLTIDeliveryExecutionLink::PROPERTY_LTI_DEL_EXEC_LINK_LINK => $link,
        ], [
            'like' => false
        ]);
        $result = [];
        foreach ($links as $link) {
            $execId = $link->getUniquePropertyValue(new \core_kernel_classes_Property(OntologyLTIDeliveryExecutionLink::PROPERTY_LTI_DEL_EXEC_LINK_EXEC_ID));
            $deliveryExecution = ServiceProxy::singleton()->getDeliveryExecution($execId);
            if ($delivery->equals($deliveryExecution->getDelivery())) {
                $result[] = $deliveryExecution;
            }
        }
        return $result;
    }
833022
public function submitCartDirectly(
        ApiOrderInterface $cart,
        UserInterface $user,
        $locale
    ) {
        $orderWasSubmitted = true;

        try {
            $this->checkIfCartIsValid($user, $cart, $locale);

            // set order-date to current date
            $cart->setOrderDate(new \DateTime());

            // change status of order to confirmed
            $this->orderManager->convertStatus($cart, OrderStatus::STATUS_CONFIRMED);

            // order-addresses have to be set to the current contact-addresses
            $this->reApplyOrderAddresses($cart, $user);

            $customer = $user->getContact();

            // send confirmation email to customer
            $this->orderEmailManager->sendCustomerConfirmation(
                $customer->getMainEmail(),
                $cart,
                $customer
            );

            $shopOwnerEmail = null;

            // get responsible person of contacts account
            if ($customer->getMainAccount() &&
                $customer->getMainAccount()->getResponsiblePerson() &&
                $customer->getMainAccount()->getResponsiblePerson()->getMainEmail()
            ) {
                $shopOwnerEmail = $customer->getMainAccount()->getResponsiblePerson()->getMainEmail();
            }

            // send confirmation email to shop owner
            $this->orderEmailManager->sendShopOwnerConfirmation(
                $shopOwnerEmail,
                $cart,
                $customer
            );

            // flush on success
            $this->em->flush();
        } catch (CartSubmissionException $cse) {
            $orderWasSubmitted = false;
        }

        return $orderWasSubmitted;
    }
942485
public function register(UserInterface $user, string $code)
    {
        $params = [
            'user' => $user,
            'code' => $code
        ];

        $this->send(self::SUBJECT_KEY_REGISTER, $user, $params);
    }
936728
public function getRuntime(DeliveryExecution $execution)
    {
        $delivery = $execution->getDelivery();
        return $this->getServiceLocator()->get(RuntimeService::SERVICE_ID)->getRuntime($delivery->getUri());
    }
221951
public function getLinkedDeliveryExecutions(\core_kernel_classes_Resource $delivery, \core_kernel_classes_Resource $link, $userId)
    {

        $data = $this->getPersistence()->get(self::LTI_DE_LINK_LINK . $link->getUri() . $userId);

        $ltiDeliveryExecutionLinks = KvLTIDeliveryExecutionLink::unSerialize($data);

        $results = [];
        foreach ($ltiDeliveryExecutionLinks as $ltiDeliveryExecutionLink){
            $deliveryExecution = ServiceProxy::singleton()->getDeliveryExecution($ltiDeliveryExecutionLink->getDeliveryExecutionId());
            if ($delivery->equals($deliveryExecution->getDelivery())) {
                $results[] = $deliveryExecution;
            }
        }
        return $results;
    }
966986
function isRecipient($user) {
        $user = $this->client->users->resolve($user);
        return $this->recipients->has($user->id);
    }
563583
public function getUserExecutions(core_kernel_classes_Resource $assembly, $userUri)
    {
        $query = $this->getQueryBuilder()
            ->select("*")
            ->from(self::TABLE_NAME)
            ->where(self::COLUMN_DELIVERY_ID . " = :deliveryId")
            ->andWhere(self::COLUMN_USER_ID . " = :userId")
            ->setParameter("deliveryId", $assembly->getUri())
            ->setParameter("userId", $userUri)
        ;

        return array_map(function($row) {
            return $this->parseQueryResult($row);
        }, $query->execute()->fetchAll());
    }
1004863
public function verifyStartAuthorization($deliveryId, User $user)
    {
        foreach ($this->getProviders() as $provider) {
            $provider->verifyStartAuthorization($deliveryId, $user);
        }
    }
1314473
private function userAttemptBruteForceLockHasExceeded(User $user)
    {
        if ($user->login_attempt_lock_expiration > time()) {
            $user->updateAttributes(['login_attempt' => 0]);
            
            return true;
        }
        
        return false;
    }
560305
public function checkCountries($user, $invAddress, $deliveryAddress)
    {
        $billingCountry = isset($invAddress['oxuser__oxcountryid']) ? $invAddress['oxuser__oxcountryid'] : null;
        $deliveryCountry = isset($deliveryAddress['oxaddress__oxcountryid']) ? $deliveryAddress['oxaddress__oxcountryid'] : null;

        if ($billingCountry || $deliveryCountry) {
            $database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

            if (($billingCountry == $deliveryCountry) || (!$billingCountry && $deliveryCountry) || ($billingCountry && !$deliveryCountry)) {
                $billingCountry = $billingCountry ? $billingCountry : $deliveryCountry;
                $query = "select oxactive from oxcountry where oxid = " . $database->quote($billingCountry) . " ";
            } else {
                $query = "select ( select oxactive from oxcountry where oxid = " . $database->quote($billingCountry) . " ) and
                              ( select oxactive from oxcountry where oxid = " . $database->quote($deliveryCountry) . " ) ";
            }

            if (!$database->getOne($query)) {
                $exception = oxNew(\OxidEsales\Eshop\Core\Exception\UserException::class);
                $exception->setMessage(\OxidEsales\Eshop\Core\Registry::getLang()->translateString('ERROR_MESSAGE_INPUT_NOTALLFIELDS'));

                $this->addValidationError("oxuser__oxcountryid", $exception);
            }
        }
    }