Skip to content

Commit

Permalink
Merge branch '6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
TimWolla committed Sep 28, 2023
2 parents 9e64957 + dbc240c commit 70e3d20
Show file tree
Hide file tree
Showing 33 changed files with 485 additions and 273 deletions.
7 changes: 7 additions & 0 deletions com.woltlab.wcf/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,20 @@ tar cvf com.woltlab.wcf/files_pre_check.tar -C wcfsetup/install/files/ \
<instruction type="script" run="standalone">acp/update_com.woltlab.wcf_6.0_favicon.php</instruction>
<instruction type="script" run="standalone">acp/update_com.woltlab.wcf_6.0_trophies.php</instruction>
<instruction type="script" run="standalone">acp/update_com.woltlab.wcf_6.0_removeDownloadedGravatars.php</instruction>
<instruction type="script" run="standalone">acp/update_com.woltlab.wcf_6.0_license.php</instruction>

<!-- Clean Up. -->
<instruction type="script" run="standalone">acp/update_com.woltlab.wcf_6.0_removeLegacyAppConfig.php</instruction>
<instruction type="fileDelete" />
<instruction type="templateDelete" />
</instructions>

<!--
Include in the update RC 1 → RC 2:
<instruction type="script" run="standalone">acp/update_com.woltlab.wcf_6.0_license.php</instruction>
-->

<instructions type="update" fromversion="6.0.0 Beta 4">
<instruction type="acpTemplate">acptemplates_update.tar</instruction>
<instruction type="file">files_update.tar</instruction>
Expand Down
2 changes: 1 addition & 1 deletion com.woltlab.wcf/templates/wysiwyg.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@
{/foreach}
];
void setupCkeditor(element, features, bbcodes, codeBlockLanguages);
void setupCkeditor(element, features, bbcodes, codeBlockLanguages, '{@$__wcf->getBBCodeHandler()->getCkeditorLicenseKey()|encodeJS}');
});
</script>
6 changes: 5 additions & 1 deletion ts/WoltLabSuite/Core/Component/Ckeditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function initializeConfiguration(
languages: codeBlockLanguages,
};

(configuration as any).woltlabBbcode = bbcodes;
configuration.woltlabBbcode = bbcodes;

if (features.autosave !== "") {
initializeAutosave(element, configuration, features.autosave);
Expand Down Expand Up @@ -252,6 +252,7 @@ export async function setupCkeditor(
features: Features,
bbcodes: WoltlabBbcodeItem[],
codeBlockLanguages: CKEditor5.CodeBlock.CodeBlockConfig["languages"],
licenseKey: string,
): Promise<CKEditor> {
if (instances.has(element)) {
throw new TypeError(`Cannot initialize the editor for '${element.id}' twice.`);
Expand Down Expand Up @@ -279,6 +280,9 @@ export async function setupCkeditor(
}

const configuration = initializeConfiguration(element, features, bbcodes, codeBlockLanguages, CKEditor5);
if (licenseKey) {
configuration.licenseKey = licenseKey;
}

normalizeLegacyMessage(element);

Expand Down
5 changes: 3 additions & 2 deletions ts/WoltLabSuite/Core/Component/GoogleMaps/Geocoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ class Geocoding {
this.#element.dataset.googleMapsLat = lat.toString();
this.#element.dataset.googleMapsLng = lng.toString();

if (this.#element.hasAttribute("data-google-maps-geocoding-store") && this.#element.form) {
this.#store(this.#element.dataset.googleMapsGeocdingStore || "", lat, lng);
const prefix = this.#element.dataset.googleMapsGeocodingStore;
if (prefix != null && this.#element.form) {
this.#store(prefix, lat, lng);
}
}

Expand Down
12 changes: 6 additions & 6 deletions wcfsetup/install/files/acp/templates/license.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<header class="contentHeader">
<div class="contentHeaderTitle">
<h1 class="contentTitle">{lang}wcf.acp.license{/lang}</span></h1>
{if $licenseNumber}
<p class="contentDescription">{lang}wcf.acp.license.licenseNo{/lang}</p>
{if $licenseData->getLicenseNumber()}
<p class="contentDescription">{lang licenseNumber=$licenseData->getLicenseNumber()}wcf.acp.license.licenseNo{/lang}</p>
{/if}
</div>

Expand All @@ -59,7 +59,7 @@
{/hascontent}
</header>

{if $licenseData[license][type] === 'developer'}
{if $licenseData->getLicenseType() === 'developer'}
<p class="warning">{lang}wcf.acp.license.developerLicense{/lang}</p>
{/if}

Expand All @@ -76,7 +76,7 @@
</thead>
<tbody>
{content}
{foreach from=$licenseData[woltlab] key=package item=majorVersion}
{foreach from=$availablePackages[woltlab] key=package item=majorVersion}
<tr class="licensed_packages__package" data-package="{$package}">
{if $installedPackages[$package]|isset}
<td class="columnText">
Expand Down Expand Up @@ -104,7 +104,7 @@
{lang accessibleVersion=$requiresLicenseExtension[$package]}wcf.acp.license.package.outdated{/lang}
</span>
{/if}
<a href="https://www.woltlab.com/license-extend/{$licenseNumber}/" class="externalURL" rel="nofollow noopener" target="_blank">{lang}wcf.acp.license.extend{/lang}</a>
<a href="https://www.woltlab.com/license-extend/{$licenseData->getLicenseNumber()}/" class="externalURL" rel="nofollow noopener" target="_blank">{lang}wcf.acp.license.extend{/lang}</a>
</span>
{else}
<button type="button" class="button small jsInstallPackage" data-package="{$package}" data-package-version="{$installablePackages[$package]}">
Expand Down Expand Up @@ -135,7 +135,7 @@
</thead>
<tbody>
{content}
{foreach from=$licenseData[pluginstore] key=package item=majorVersion}
{foreach from=$availablePackages[pluginstore] key=package item=majorVersion}
<tr class="licensed_packages__package" data-package="{$package}">
{if $installedPackages[$package]|isset}
<td class="columnText">
Expand Down
2 changes: 1 addition & 1 deletion wcfsetup/install/files/acp/templates/wysiwyg.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@
{/foreach}
];
void setupCkeditor(element, features, bbcodes, codeBlockLanguages);
void setupCkeditor(element, features, bbcodes, codeBlockLanguages, '{@$__wcf->getBBCodeHandler()->getCkeditorLicenseKey()|encodeJS}');
});
</script>
22 changes: 0 additions & 22 deletions wcfsetup/install/files/acp/update_com.woltlab.wcf_6.0.0.rc.1.php

This file was deleted.

36 changes: 36 additions & 0 deletions wcfsetup/install/files/acp/update_com.woltlab.wcf_6.0_license.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* Validates the license credentials and writes the license file.
*
* @author Alexander Ebert
* @copyright 2001-2023 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*/

use wcf\data\package\update\server\PackageUpdateServer;
use wcf\data\package\update\server\PackageUpdateServerEditor;
use wcf\system\package\license\LicenseApi;

try {
$licenseApi = new LicenseApi();
$licenseData = $licenseApi->fetchFromRemote();
$licenseApi->updateLicenseFile($licenseData);

// If we’re still here it means that the credentials are actually valid. Now
// we can check if the credentials for both servers are in sync, because
// traditionally users could use their account credentials to authenticate.
$updateServer = PackageUpdateServer::getWoltLabUpdateServer();
$storeServer = PackageUpdateServer::getPluginStoreServer();

if ($updateServer->getAuthData() !== $storeServer->getAuthData()) {
$authData = $updateServer->getAuthData();

(new PackageUpdateServerEditor($storeServer))->update([
'username' => $authData['username'],
'password' => $authData['password'],
]);
}
} catch (\Throwable) {
// This action must be silent, failing to execute is not an issue here.
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

namespace wcf\acp\form;

use CuyZ\Valinor\Mapper\MappingError;
use CuyZ\Valinor\Mapper\Source\Source;
use CuyZ\Valinor\MapperBuilder;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Psr7\Request;
use Psr\Http\Client\ClientExceptionInterface;
use wcf\data\option\Option;
use wcf\data\option\OptionAction;
Expand All @@ -21,7 +17,9 @@
use wcf\system\form\builder\field\TextFormField;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
use wcf\system\form\builder\field\validation\FormFieldValidator;
use wcf\system\io\HttpFactory;
use wcf\system\package\license\exception\ParsingFailed;
use wcf\system\package\license\LicenseApi;
use wcf\system\package\license\LicenseData;
use wcf\system\request\LinkHandler;
use wcf\util\HeaderUtil;

Expand All @@ -40,7 +38,9 @@ final class FirstTimeSetupLicenseForm extends AbstractFormBuilderForm
*/
public $neededPermissions = ['admin.configuration.package.canEditServer'];

private array $apiResponse;
private LicenseApi $licenseApi;

private LicenseData $licenseData;

/**
* @inheritDoc
Expand All @@ -61,6 +61,8 @@ protected function createForm()
{
parent::createForm();

$this->licenseApi = new LicenseApi();

$this->form->appendChildren([
$credentialsContainer = FormContainer::create('credentials')
->label('wcf.acp.firstTimeSetup.license.credentials')
Expand All @@ -84,13 +86,16 @@ protected function createForm()
\assert($licenseNo instanceof TextFormField);

try {
$this->apiResponse = $this->getLicenseData($licenseNo->getValue(), $serialNo->getValue());
$this->licenseData = $this->licenseApi->fetchFromRemote([
'username' => $licenseNo->getValue(),
'password' => $serialNo->getValue(),
]);
} catch (ConnectException) {
$serialNo->addValidationError(new FormFieldValidationError(
'failedConnect',
'wcf.acp.firstTimeSetup.license.credentials.error.failedConnect'
));
} catch (ClientExceptionInterface | MappingError) {
} catch (ClientExceptionInterface | ParsingFailed) {
$serialNo->addValidationError(new FormFieldValidationError(
'failedValidation',
'wcf.acp.firstTimeSetup.license.credentials.error.failedValidation'
Expand All @@ -113,43 +118,6 @@ protected function createForm()
);
}

private function getLicenseData(string $licenseNo, string $serialNo): array
{
$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' => $licenseNo,
'serialNo' => $serialNo,
'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<string, int>,
},
pluginstore: array<string, string>,
woltlab: array<string, string>,
}
EOT,
Source::json($response->getBody())
);
}

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -189,8 +157,12 @@ public function save()
Option::getOptionByName('first_time_setup_state')->optionID => 1,
];

if (isset($this->apiResponse) && isset($this->apiResponse['license']['authCode'])) {
$optionData[Option::getOptionByName('package_server_auth_code')->optionID] = $this->apiResponse['license']['authCode'];
if (isset($this->licenseData)) {
$this->licenseApi->updateLicenseFile($this->licenseData);

if (isset($this->licenseData->license['authCode'])) {
$optionData[Option::getOptionByName('package_server_auth_code')->optionID] = $this->licenseData->license['authCode'];
}
}

$objectAction = new OptionAction(
Expand Down
Loading

0 comments on commit 70e3d20

Please sign in to comment.