From: Alexander Ebert Date: Sat, 17 Jun 2023 14:26:25 +0000 (+0200) Subject: Basic prototype for the license page X-Git-Tag: 6.0.0_Beta_4~6^2~17 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e7ddedb4c2da5e500ba8d823069338be807dd1a5;p=GitHub%2FWoltLab%2FWCF.git Basic prototype for the license page --- diff --git a/wcfsetup/install/files/acp/templates/license.tpl b/wcfsetup/install/files/acp/templates/license.tpl new file mode 100644 index 0000000000..1b657acb22 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/license.tpl @@ -0,0 +1,78 @@ +{include file='header' pageTitle='wcf.acp.license'} + +
+
+

{lang}wcf.acp.license{/lang}

+
+ + {hascontent} + + {/hascontent} +
+ +
+

TODO: License

+ +
+
TODO: License Number
+
{$licenseNumber}
+
+
+
TODO: License Type
+
{$licenseData[license][type]}
+
+
+ +
+

TODO: WoltLab Products

+ +
+ + + + + + + + + {foreach from=$licenseData[woltlab] key=package item=majorVersion} + + + + + {/foreach} + +
TODO: NameTODO: Major Version
{$package}{$majorVersion}
+
+
+ +
+

TODO: WoltLab Plugin-Store

+ +
+ + + + + + + + + {foreach from=$licenseData[pluginstore] key=package item=majorVersion} + + + + + {/foreach} + +
TODO: NameTODO: Major Version
{$package}{$majorVersion}
+
+
+ +{include file='footer'} diff --git a/wcfsetup/install/files/lib/acp/page/LicensePage.class.php b/wcfsetup/install/files/lib/acp/page/LicensePage.class.php new file mode 100644 index 0000000000..da67af311f --- /dev/null +++ b/wcfsetup/install/files/lib/acp/page/LicensePage.class.php @@ -0,0 +1,80 @@ +licenseData = $this->fetchLicenseData(); + + $this->licenseNumber = (new PackageUpdateServer(1))->loginUsername; + } + + public function assignVariables() + { + parent::assignVariables(); + + WCF::getTPL()->assign([ + 'licenseData' => $this->licenseData, + 'licenseNumber' => $this->licenseNumber, + ]); + } + + // TODO: This code was stol… liberated from "FirstTimeSetupLicenseForm" and + // should propably be moved into a helper class. We might even want to refresh + // the data with requests to the package servers to implicitly fetch the + // latest purchases. + private function fetchLicenseData(): array|object + { + $pus = new PackageUpdateServer(1); + + $request = new Request( + 'POST', + 'https://api.woltlab.com/2.0/customer/license/list.json', + [ + 'content-type' => 'application/x-www-form-urlencoded', + ], + \http_build_query([ + 'licenseNo' => $pus->loginUsername, + 'serialNo' => $pus->loginPassword, + 'instanceId' => \hash_hmac('sha256', 'api.woltlab.com', \WCF_UUID), + ], '', '&', \PHP_QUERY_RFC1738) + ); + + $response = HttpFactory::makeClientWithTimeout(5)->send($request); + return (new MapperBuilder()) + ->allowSuperfluousKeys() + ->mapper() + ->map( + <<<'EOT' + array { + status: 200, + license: array { + authCode: string, + type: string, + expiryDates?: array, + }, + pluginstore: array, + woltlab: array, + } + EOT, + Source::json($response->getBody()) + ); + } +}