y>V`>AAPAHjkBjkpy>V0 =(z>VPA(z>V`Ay>VP<px{>VP`3pR{>V`|z>V`>&P>V|y>VP>AлjkCjk z>V  Ipy>V#=(z>VP#A0|>V`#0V{>V`p#Gz>Vp#Hz>Vp`#A y>V#<y>V`$> jk HAƞApA`>V z>V 'Ipy>V*=(z>VP*A0|>V`*0V{>V`p*Gz>Vp*Hz>Vp`*A y>V*<y>V`+>`jk HAjkpA`>VB/** * Get form fields ready for select list options. * * In this function, we also do the logic to limit certain fields to certain provider field types. * * @since 1.0.0 * * @param array $form_fields List of form fields. * @param string $form_field_type Provider field type. * * @return array *///** * Retrieve provider account lists. * * @since 1.0.0 * * @param string $connection_id Unique connection ID. * @param string $account_id Account ID. * * @return WP_Error|array|object * @noinspection PhpMissingParamTypeInspection * @noinspection PhpUnusedParameterInspection */e/** * Retrieve provider account list groups. * * @since 1.0.0 * * @param string $connection_id Unique connection ID. * @param string $account_id Account ID. * @param string $list_id List ID. * * @return mixed array or error object * @noinspection PhpMissingParamTypeInspection * @noinspection PhpUnusedParameterInspection */e/** * Retrieve provider account list fields. * * @since 1.0.0 * * @param string $connection_id Unique connection ID. * @param string $account_id Account ID. * @param string $list_id List ID. * * @return mixed array or error object * @noinspection PhpMissingParamTypeInspection * @noinspection PhpUnusedParameterInspection *///** * Provider account list fields HTML. * * @since 1.0.0 * * @param string $connection_id Unique connection ID. * @param array $connection Connection data. * @param mixed $form Form id or form data. * * @return WP_Error|string * @noinspection HtmlUnknownAttribute */ y>VPo@ y>V`o@ y>Vpo@|>VHңjqpAz>VPqty>Vq<n{>Vq>y>Vr>PAPAPA(A(Apjk y>VP@ y>V`@ y>Vp@|>VHңjpAz>VPty>V<n{>V>y>V>PAPAPA(A(A8pjk*/** * Check if CAPTCHA processing is allowed. * * @since 1.8.3 * * @param array $entry ePackageKey, string $languageCode, ?array $componentSettings = null ): InstallationStatusDto { $providerModel = $this->providerTransformer->toModel($providerData, $borlabsServicePackageKey, $languageCode); $providerByNormalKey = $this->providerRepository->getByKey($providerData->key, $languageCode); if ($providerByNormalKey !== null && $providerByNormalKey->borlabsServicePackageKey === null && $providerByNormalKey->borlabsServiceProviderKey !== 'default' && $providerByNormalKey->borlabsServiceProviderKey !== 'unknown' ) { return $this->getFailureInstallationStatus( $providerByNormalKey, Formatter::interpolate($this->packageManagerComponentLocalizationStrings::get()['alert']['keyAlreadyInUse'], [ 'key' => $providerByNormalKey->key, 'resource' => $this->modelLocalizationStrings::get()['models'][ProviderModel::class], ]), ); } $provider = $this->providerRepository->getByBorlabsServiceProviderKey($providerData->key, $languageCode); if ($provider !== null) { $providerModel->id = $provider->id; if ( isset($componentSettings['overwrite-translation']) && $componentSettings['overwrite-translation'] === '0' ) { $providerModel->address = $provider->address; $providerModel->cookieUrl = $provider->cookieUrl; $providerModel->description = $provider->description; $providerModel->name = $provider->name; $providerModel->optOutUrl = $provider->optOutUrl; $providerModel->privacyUrl = $provider->privacyUrl; } // Do not overwrite the default provider (owner of the website & unknown) if ($providerModel->borlabsServiceProviderKey !== 'default' && $providerModel->borlabsServiceProviderKey !== 'unknown') { $this->providerRepository->update($providerModel); } } else { $providerModel = $this->providerRepository->insert($providerModel); } if ($providerModel->id === -1) { $this->log->error( 'Provider could not be installed.', [ 'componentSettings' => $componentSettings, 'languageCode' => $languageCode, 'providerData' => $providerData, ], ); } return new InstallationStatusDto( $providerModel->id !== -1 ? InstallationStatusEnum::SUCCESS() : InstallationStatusEnum::FAILURE(), ComponentTypeEnum::PROVIDER(), $providerModel->borlabsServiceProviderKey, $providerModel->name . ' (' . $providerModel->language . ')', $providerModel->id, ); } public function reassignToOtherPackage(PackageModel $packageModel, ProviderModel $providerModel): InstallationStatusDto { $providerModel->borlabsServicePackageKey = $packageModel->borlabsServicePackageKey; $success = $this->providerRepository->update($providerModel); if ($success) { return $this->getSuccessInstallationStatus($providerModel); } return $this->getFailureInstallationStatus($providerModel); } public function uninstall(PackageModel $packageModel, int $providerId): InstallationStatusDto { $providerModel = $this->providerRepository->findById($providerId, ['services', 'contentBlockers']); $usage = $this->checkUsage($providerModel, $packageModel); if (count($usage) === 0) { try { $this->providerRepository->deleteWithRelationChecks($providerModel, true); return $this->getSuccessInstallationStatus($providerModel); } catch (TranslatedException $e) { return $this->getFailureInstallationStatus($providerModel, $e->getTranslatedMessage()); } catch (GenericException $e) { $this->log->error('Service uninstall failed', [ 'exceptionMessage' => $e->getMessage(), ]); return $this->getFailureInstallationStatus($providerModel); } } else { return $this->reassignToOtherPackage($usage[0], $providerModel); } } private function getFailureInstallationStatus( ProviderModel $providerModel, ?string $message = null ): InstallationStatusDto { return new InstallationStatusDto( InstallationStatusEnum::FAILURE(), ComponentTypeEnum::PROVIDER(), $providerModel->key, $providerModel->name, $providerModel->id, null, $message, ); } private function getSuccessInstallationStatus(ProviderModel $providerModel): InstallationStatusDto { return new InstallationStatusDto( InstallationStatusEnum::SUCCESS(), ComponentTypeEnum::PROVIDER(), $providerModel->key, $providerModel->name, $providerModel->id, ); } }