<input id="user" name="user" type="text" value="{$user}"{if $action == 'edit'} disabled{/if}>
{if $errorField == 'user'}
<small class="innerError">
- {if $errorType == 'empty'}
+ {if $errorType|is_array}
+ {foreach from=$errorType item='errorData'}
+ {lang}wcf.acp.trophy.userTrophy.user.error.{@$errorData.type}{/lang}
+ {/foreach}
+ {elseif $errorType == 'empty'}
{lang}wcf.global.form.error.empty{/lang}
{/if}
</small>
use wcf\data\trophy\category\TrophyCategoryCache;
use wcf\data\trophy\Trophy;
use wcf\data\user\trophy\UserTrophyAction;
-use wcf\data\user\UserList;
+use wcf\data\user\UserProfile;
use wcf\system\exception\UserInputException;
use wcf\system\language\I18nHandler;
use wcf\system\language\I18nValue;
use wcf\system\WCF;
+use wcf\util\ArrayUtil;
use wcf\util\StringUtil;
/**
if (isset($_POST['useCustomDescription'])) $this->useCustomDescription = 1;
$this->trophy = new Trophy($this->trophyID);
-
+ }
+
+ /**
+ * Validates the users.
+ *
+ * @throws UserInputException
+ */
+ protected function validateUser() {
// read userIDs
- $userAsArray = explode(',', $this->user);
+ $userAsArray = ArrayUtil::trim(explode(',', $this->user));
+
+ $userList = UserProfile::getUserProfilesByUsername($userAsArray);
- $userList = new UserList();
- $userList->getConditionBuilder()->add('user_table.username IN (?)', [$userAsArray]);
- $userList->readObjects();
+ $error = [];
- foreach ($userList as $user) {
- $this->userIDs[] = $user->userID;
+ foreach ($userList as $username => $user) {
+ if ($user === null) {
+ $error[] = [
+ 'type' => 'notFound',
+ 'username' => $username
+ ];
+ }
+ else {
+ $this->userIDs[] = $user->userID;
+ }
+ }
+
+ if (!empty($error)) {
+ throw new UserInputException('user', $error);
}
}
}
}
+ $this->validateUser();
+
if (empty($this->userIDs)) {
throw new UserInputException('user');
}
<item name="wcf.acp.trophy.delete.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} die Trophäe <span class="confirmationObject">{$trophy->getTitle()}</span> wirklich löschen?]]></item>
<item name="wcf.acp.trophy.userTrophy.user"><![CDATA[Benutzer]]></item>
<item name="wcf.acp.trophy.userTrophy.user.description"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Gebe{else}Geben Sie{/if} hier die Benutzer an, welche die Trophäe erhalten sollen.]]></item>
+ <item name="wcf.acp.trophy.userTrophy.user.error.notFound"><![CDATA[Der Benutzername „{$errorData[username]}“ konnte nicht gefunden werden.]]></item>
<item name="wcf.acp.trophy.userTrophy.description"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Gebe{else}Geben Sie{/if} hier die Trophäe an, welche an die Benutzer vergeben werden soll. {if LANGUAGE_USE_INFORMAL_VARIANT}Du kannst{else}Sie können{/if} keine automatisch vergebene Trophäen manuell vergeben.]]></item>
<item name="wcf.acp.trophy.userTrophy.useCustomDescription"><![CDATA[Benutzerdefinierte Trophäen-Beschreibung aktivieren]]></item>
<item name="wcf.acp.trophy.userTrophy.delete.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} die Trophäe <span class="confirmationObject">{$userTrophy->getTrophy()->getTitle()}</span> von <span class="confirmationObject">{$userTrophy->getUserProfile()->username}</span> wirklich löschen?]]></item>
<item name="wcf.acp.trophy.delete.confirmMessage"><![CDATA[Do you really want to delete the trophy <span class="confirmationObject">{$trophy->getTitle()}</span>?]]></item>
<item name="wcf.acp.trophy.userTrophy.user"><![CDATA[User]]></item>
<item name="wcf.acp.trophy.userTrophy.user.description"><![CDATA[Enter the names of the users who should be awarded the trophy.]]></item>
+ <item name="wcf.acp.trophy.userTrophy.user.error.notFound"><![CDATA[The username “{$errorData[username]}” does not exist.]]></item>
<item name="wcf.acp.trophy.userTrophy.description"><![CDATA[Select the trophy who should be awarded to the users. You cannot select automatically awarded trophies.]]></item>
<item name="wcf.acp.trophy.userTrophy.useCustomDescription"><![CDATA[Use custom trophy description]]></item>
<item name="wcf.acp.trophy.userTrophy.delete.confirmMessage"><![CDATA[Do you really want to delete the trophy <span class="confirmationObject">{$userTrophy->getTrophy()->getTitle()}</span> from <span class="confirmationObject">{$userTrophy->getUserProfile()->username}</span>?]]></item>