<small class="innerError">
{if $errorType == 'empty'}
{lang}wcf.global.form.error.empty{/lang}
+ {elseif $errorType[duplicate]|isset}
+ {lang}wcf.acp.updateServer.serverURL.error.duplicate{/lang}
{else}
{lang}wcf.acp.updateServer.serverURL.error.{@$errorType}{/lang}
{/if}
namespace wcf\acp\form;
use wcf\data\package\update\server\PackageUpdateServer;
use wcf\data\package\update\server\PackageUpdateServerAction;
+use wcf\data\package\update\server\PackageUpdateServerList;
use wcf\form\AbstractForm;
use wcf\system\exception\UserInputException;
use wcf\system\request\LinkHandler;
public function validate() {
parent::validate();
+ $this->validateServerURL();
+ }
+
+ /**
+ * Validates the server URL.
+ */
+ protected function validateServerURL() {
if (empty($this->serverURL)) {
throw new UserInputException('serverURL');
}
if (!PackageUpdateServer::isValidServerURL($this->serverURL)) {
throw new UserInputException('serverURL', 'invalid');
}
+
+ if (($duplicate = $this->findDuplicateServer())) {
+ throw new UserInputException('serverURL', [
+ 'duplicate' => $duplicate,
+ ]);
+ }
+ }
+
+ /**
+ * Returns the first package update server with a matching serverURL.
+ */
+ protected function findDuplicateServer() {
+ $packageServerList = new PackageUpdateServerList();
+ $packageServerList->readObjects();
+ foreach ($packageServerList as $packageServer) {
+ if ($packageServer->serverURL == $this->serverURL) {
+ return $packageServer;
+ }
+ }
+
+ return null;
}
/**
<item name="wcf.acp.updateServer.packages"><![CDATA[Pakete]]></item>
<item name="wcf.acp.updateServer.serverURL"><![CDATA[Adresse]]></item>
<item name="wcf.acp.updateServer.serverURL.error.invalid"><![CDATA[Die eingetragene Adresse ist ungültig.]]></item>
+ <item name="wcf.acp.updateServer.serverURL.error.duplicate"><![CDATA[Dieser Paketserver ist bereits hinterlegt. {if LANGUAGE_USE_INFORMAL_VARIANT}Du kannst{else}Sie können{/if} <a href="{link controller="PackageUpdateServerEdit" id=$errorType[duplicate]->packageUpdateServerID}{/link}"><strong>den bestehenden Paketserver bearbeiten</strong></a>.]]></item>
<item name="wcf.acp.updateServer.status"><![CDATA[Status]]></item>
<item name="wcf.acp.updateServer.lastUpdateTime"><![CDATA[Letzter Zugriff]]></item>
</category>
<item name="wcf.acp.updateServer.packages"><![CDATA[Packages]]></item>
<item name="wcf.acp.updateServer.serverURL"><![CDATA[Address]]></item>
<item name="wcf.acp.updateServer.serverURL.error.invalid"><![CDATA[The address is invalid.]]></item>
+ <item name="wcf.acp.updateServer.serverURL.error.duplicate"><![CDATA[The given server is already configured. You can <a href="{link controller="PackageUpdateServerEdit" id=$errorType[duplicate]->packageUpdateServerID}{/link}"><strong>edit the existing server</strong></a>.]]></item>
<item name="wcf.acp.updateServer.status"><![CDATA[Status]]></item>
<item name="wcf.acp.updateServer.lastUpdateTime"><![CDATA[Last Access]]></item>
</category>