*/
import AcpUserContentRemoveHandler from "./Content/Remove/Handler";
-import * as Ajax from "../../../Ajax";
import * as Core from "../../../Core";
import * as EventHandler from "../../../Event/Handler";
import * as Language from "../../../Language";
-import * as UiNotification from "../../../Ui/Notification";
import UiDropdownSimple from "../../../Ui/Dropdown/Simple";
-import { AjaxCallbackObject, DatabaseObjectActionResponse } from "../../../Ajax/Data";
import DomUtil from "../../../Dom/Util";
+import SendNewPasswordAction from "./Action/SendNewPasswordAction";
+import ToggleConfirmEmailAction from "./Action/ToggleConfirmEmailAction";
+import DisableAction from "./Action/DisableAction";
+import BanAction from "./Action/BanAction";
interface RefreshUsersData {
userIds: number[];
});
}
- const sendNewPassword = dropdownMenu.querySelector(".jsSendNewPassword") as HTMLAnchorElement;
- if (sendNewPassword !== null) {
- sendNewPassword.addEventListener("click", (event) => {
- event.preventDefault();
-
- // emulate clipboard selection
- EventHandler.fire("com.woltlab.wcf.clipboard", "com.woltlab.wcf.user", {
- data: {
- actionName: "com.woltlab.wcf.user.sendNewPassword",
- parameters: {
- confirmMessage: Language.get("wcf.acp.user.action.sendNewPassword.confirmMessage"),
- objectIDs: [userId],
- },
- },
- responseData: {
- actionName: "com.woltlab.wcf.user.sendNewPassword",
- objectIDs: [userId],
- },
- });
- });
- }
-
const deleteContent = dropdownMenu.querySelector(".jsDeleteContent") as HTMLAnchorElement;
if (deleteContent !== null) {
new AcpUserContentRemoveHandler(deleteContent, userId);
}
+ const sendNewPassword = dropdownMenu.querySelector(".jsSendNewPassword") as HTMLAnchorElement;
+ if (sendNewPassword !== null) {
+ new SendNewPasswordAction(sendNewPassword, userId, userRow);
+ }
+
const toggleConfirmEmail = dropdownMenu.querySelector(".jsConfirmEmailToggle") as HTMLAnchorElement;
if (toggleConfirmEmail !== null) {
- toggleConfirmEmail.addEventListener("click", (event) => {
- event.preventDefault();
+ new ToggleConfirmEmailAction(toggleConfirmEmail, userId, userRow);
+ }
- Ajax.api(
- {
- _ajaxSetup: () => {
- const isEmailConfirmed = Core.stringToBool(userRow.dataset.emailConfirmed!);
-
- return {
- data: {
- actionName: (isEmailConfirmed ? "un" : "") + "confirmEmail",
- className: "wcf\\data\\user\\UserAction",
- objectIDs: [userId],
- },
- };
- },
- } as AjaxCallbackObject,
- undefined,
- (data: DatabaseObjectActionResponse) => {
- document.querySelectorAll(".jsUserRow").forEach((userRow: HTMLTableRowElement) => {
- const userId = ~~userRow.dataset.objectId!;
- if (data.objectIDs.includes(userId)) {
- const confirmEmailButton = dropdownMenu.querySelector(".jsConfirmEmailToggle") as HTMLAnchorElement;
-
- switch (data.actionName) {
- case "confirmEmail":
- userRow.dataset.emailConfirmed = "true";
- confirmEmailButton.textContent = confirmEmailButton.dataset.unconfirmEmailMessage!;
- break;
-
- case "unconfirmEmail":
- userRow.dataset.emailEonfirmed = "false";
- confirmEmailButton.textContent = confirmEmailButton.dataset.confirmEmailMessage!;
- break;
-
- default:
- throw new Error("Unreachable");
- }
- }
- });
-
- UiNotification.show();
- },
- );
- });
+ const enableUser = dropdownMenu.querySelector(".jsEnable") as HTMLAnchorElement;
+ if (enableUser !== null) {
+ new DisableAction(enableUser, userId, userRow);
+ }
+
+ const banUser = dropdownMenu.querySelector(".jsBan") as HTMLAnchorElement;
+ if (banUser !== null) {
+ new BanAction(banUser, userId, userRow);
}
}
}
}
-export = AcpUiUserEditor;
+export = AcpUiUserEditor;
\ No newline at end of file
<script data-relocate="true">
$(function() {
WCF.Clipboard.init('wcf\\acp\\page\\UserListPage', {@$hasMarkedItems});
-
+
WCF.Language.addObject({
'wcf.acp.user.banReason': '{jslang}wcf.acp.user.banReason{/jslang}',
'wcf.acp.user.banReason.description': '{jslang}wcf.acp.user.banReason.description{/jslang}',
'wcf.user.status.isDisabled': '{jslang}wcf.user.status.isDisabled{/jslang}'
});
WCF.ACP.User.BanHandler.init();
-
+
{if $__wcf->session->getPermission('admin.user.canEnableUser')}
WCF.ACP.User.EnableHandler.init();
{/if}
-
+
{if $__wcf->session->getPermission('admin.user.canEditPassword')}
WCF.ACP.User.SendNewPasswordHandler.init();
{/if}
-
+
require(['Language', 'WoltLabSuite/Core/Acp/Ui/User/Editor', 'WoltLabSuite/Core/Acp/Ui/User/Content/Remove/Clipboard'], function (Language, AcpUiUserList, AcpUserContentRemoveClipboard) {
Language.addObject({
- 'wcf.acp.user.action.sendNewPassword.confirmMessage': '{jslang}wcf.acp.user.action.sendNewPassword.confirmMessage{/jslang}'
+ 'wcf.acp.user.action.sendNewPassword.confirmMessage': '{jslang}wcf.acp.user.action.sendNewPassword.confirmMessage{/jslang}',
});
-
+
new AcpUiUserList();
-
+
new AcpUserContentRemoveClipboard.default();
});
-
+
{event name='javascriptInit'}
});
</script>
<div class="contentHeaderTitle">
<h1 class="contentTitle">{lang}{@$pageTitle}{/lang}{if $items} <span class="badge badgeInverse">{#$items}</span>{/if}</h1>
</div>
-
+
{hascontent}
<nav class="contentHeaderNavigation">
<ul>
{if $__wcf->session->getPermission('admin.user.canAddUser')}
<li><a href="{link controller='UserAdd'}{/link}" class="button"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.acp.user.add{/lang}</span></a></li>
{/if}
-
+
{event name='contentHeaderNavigation'}
{/content}
</ul>
{content}
{assign var=encodedURL value=$url|rawurlencode}
{assign var=encodedAction value=$action|rawurlencode}
-
+
{pages print=true assign=pagesLinks controller="UserList" id=$searchID link="pageNo=%d&action=$encodedAction&sortField=$sortField&sortOrder=$sortOrder"}
{/content}
</div>
<th class="columnMark"><label><input type="checkbox" class="jsClipboardMarkAll"></label></th>
<th class="columnID columnUserID{if $sortField == 'userID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='UserList' id=$searchID}action={@$encodedAction}&pageNo={@$pageNo}&sortField=userID&sortOrder={if $sortField == 'userID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
<th class="columnTitle columnUsername{if $sortField == 'username'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='UserList' id=$searchID}action={@$encodedAction}&pageNo={@$pageNo}&sortField=username&sortOrder={if $sortField == 'username' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.user.username{/lang}</a></th>
-
+
{foreach from=$columnHeads key=column item=columnLanguageVariable}
<th class="column{$column|ucfirst}{if $columnStyling[$column]|isset} {$columnStyling[$column]}{/if}{if $sortField == $column} active {@$sortOrder}{/if}"{if $column === 'registrationDate'} colspan="2"{/if}><a href="{link controller='UserList' id=$searchID}action={@$encodedAction}&pageNo={@$pageNo}&sortField={$column}&sortOrder={if $sortField == $column && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}{$columnLanguageVariable}{/lang}</a></th>
{/foreach}
-
+
{event name='columnHeads'}
</tr>
</thead>
-
+
<tbody class="jsReloadPageWhenEmpty">
{foreach from=$users item=user}
<tr class="jsUserRow jsClipboardObject jsObjectActionObject" data-object-id="{@$user->getObjectID()}" data-banned="{if $user->banned}true{else}false{/if}" data-enabled="{if !$user->activationCode}true{else}false{/if}" data-email-confirmed="{if $user->isEmailConfirmed()}true{else}false{/if}">
<td class="columnIcon">
<div class="dropdown" id="userListDropdown{@$user->userID}">
<a href="#" class="dropdownToggle button small"><span class="icon icon16 fa-pencil"></span> <span>{lang}wcf.global.button.edit{/lang}</span></a>
-
+
<ul class="dropdownMenu">
{event name='dropdownItems'}
-
+
{if $user->userID !== $__wcf->user->userID}
+ {if $user->accessible && $__wcf->session->getPermission('admin.user.canEnableUser')}
+ <li><a href="#" class="jsEnable" data-enable-message="{lang}wcf.acp.user.enable{/lang}" data-disable-message="{lang}wcf.acp.user.disable{/lang}">{lang}wcf.acp.user.{if !$user->activationCode}disable{else}enable{/if}{/lang}</a></li>
+ {/if}
+
{if $user->accessible && $__wcf->session->getPermission('admin.user.canEnableUser')}
<li><a href="#" class="jsConfirmEmailToggle" data-confirm-email-message="{lang}wcf.acp.user.action.confirmEmail{/lang}" data-unconfirm-email-message="{lang}wcf.acp.user.action.unconfirmEmail{/lang}">{lang}wcf.acp.user.action.{if $user->isEmailConfirmed()}un{/if}confirmEmail{/lang}</a></li>
{/if}
-
+
+ {if $user->bannable}
+ <li><a href="#" class="jsBan" data-ban-message="{lang}wcf.acp.user.ban{/lang}" data-unban-message="{lang}wcf.acp.user.unban{/lang}">{lang}wcf.acp.user.{if $user->banned}unban{else}ban{/if}{/lang}</a></li>
+ {/if}
+
{if $__wcf->session->getPermission('admin.user.canMailUser')}
<li><a href="{link controller='UserMail' id=$user->userID}{/link}">{lang}wcf.acp.user.action.sendMail{/lang}</a></li>
{/if}
-
+
{if $user->accessible && $__wcf->session->getPermission('admin.user.canEditPassword')}
<li><a href="#" class="jsSendNewPassword">{lang}wcf.acp.user.action.sendNewPassword{/lang}</a></li>
{/if}
{/if}
-
+
{if $user->accessible && $__wcf->session->getPermission('admin.user.canExportGdprData')}
<li><a href="{link controller='UserExportGdpr' id=$user->userID}{/link}">{lang}wcf.acp.user.exportGdpr{/lang}</a></li>
{/if}
-
+
{if $user->deletable}
<li class="dropdownDivider"></li>
<li><a href="#" class="jsDispatchDelete">{lang}wcf.global.button.delete{/lang}</a></li>
<li><a href="#" class="jsDeleteContent">{lang}wcf.acp.content.removeContent{/lang}</a></li>
{/if}
-
+
{if $user->editable}
<li class="dropdownDivider"></li>
<li><a href="{link controller='UserEdit' id=$user->userID}{/link}" class="jsEditLink">{lang}wcf.global.button.edit{/lang}</a></li>
{/if}
</ul>
</div>
-
+
<div class="jsLegacyButtons" style="display: none">
{* The old buttons (with the exception of the edit button) should remain here
for backwards-compatibility, they're sometimes referenced with JavaScript-
based insert calls. Clicks are forwarded to them anyway, thus there is no
significant downside, other than "just" some more legacy code. *}
-
+
{if $user->deletable}
{objectAction action="delete" objectTitle=$user->getTitle()}
{/if}
- {if $user->bannable}
- <span class="icon icon16 fa-{if $user->banned}lock{else}unlock{/if} jsBanButton jsTooltip pointer" title="{lang}wcf.acp.user.{if $user->banned}unban{else}ban{/if}{/lang}" data-object-id="{@$user->userID}" data-ban-message="{lang}wcf.acp.user.ban{/lang}" data-unban-message="{lang}wcf.acp.user.unban{/lang}" data-banned="{if $user->banned}true{else}false{/if}"></span>
- {/if}
- {if $user->canBeEnabled}
- <span class="icon icon16 fa-{if !$user->activationCode}check-square-o{else}square-o{/if} jsEnableButton jsTooltip pointer" title="{lang}wcf.acp.user.{if !$user->activationCode}disable{else}enable{/if}{/lang}" data-object-id="{@$user->userID}" data-enable-message="{lang}wcf.acp.user.enable{/lang}" data-disable-message="{lang}wcf.acp.user.disable{/lang}" data-enabled="{if !$user->activationCode}true{else}false{/if}"></span>
- {/if}
-
+
{event name='rowButtons'}
</div>
</td>
{$user->username}
{/if}
</span>
-
+
<span class="userStatusIcons">
{if $user->banned}<span class="icon icon16 fa-lock jsTooltip jsUserStatusBanned" title="{lang}wcf.user.status.banned{/lang}"></span>{/if}
{if $user->activationCode != 0}
{/if}
{/if}
</span>
-
+
{if MODULE_USER_RANK}
{if $user->getUserTitle()} <span class="badge userTitleBadge{if $user->getRank() && $user->getRank()->cssClassName} {@$user->getRank()->cssClassName}{/if}">{$user->getUserTitle()}</span>{/if}
{if $user->getRank() && $user->getRank()->rankImage} <span class="userRankImage">{@$user->getRank()->getImage()}</span>{/if}
{/if}
</td>
-
+
{foreach from=$columnHeads key=column item=columnLanguageVariable}
{if $column === 'registrationDate'}
<td class="columnDate columnRegistrationIpAddress">
{/if}
<td class="column{$column|ucfirst}{if $columnStyling[$column]|isset} {$columnStyling[$column]}{/if}">{if $columnValues[$user->userID][$column]|isset}{@$columnValues[$user->userID][$column]}{/if}</td>
{/foreach}
-
+
{event name='columns'}
</tr>
{/foreach}
</tbody>
</table>
</div>
-
+
<footer class="contentFooter">
{hascontent}
<div class="paginationBottom">
{content}{@$pagesLinks}{/content}
</div>
{/hascontent}
-
+
{hascontent}
<nav class="contentFooterNavigation">
<ul>
{if $__wcf->session->getPermission('admin.user.canAddUser')}
<li><a href="{link controller='UserAdd'}{/link}" class="button"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.acp.user.add{/lang}</span></a></li>
{/if}
-
+
{event name='contentFooterNavigation'}
{/content}
</ul>
* @module WoltLabSuite/Core/Acp/Ui/User/Editor
* @since 3.1
*/
-define(["require", "exports", "tslib", "./Content/Remove/Handler", "../../../Ajax", "../../../Core", "../../../Event/Handler", "../../../Language", "../../../Ui/Notification", "../../../Ui/Dropdown/Simple", "../../../Dom/Util"], function (require, exports, tslib_1, Handler_1, Ajax, Core, EventHandler, Language, UiNotification, Simple_1, Util_1) {
+define(["require", "exports", "tslib", "./Content/Remove/Handler", "../../../Core", "../../../Event/Handler", "../../../Language", "../../../Ui/Dropdown/Simple", "../../../Dom/Util", "./Action/SendNewPasswordAction", "./Action/ToggleConfirmEmailAction", "./Action/DisableAction", "./Action/BanAction"], function (require, exports, tslib_1, Handler_1, Core, EventHandler, Language, Simple_1, Util_1, SendNewPasswordAction_1, ToggleConfirmEmailAction_1, DisableAction_1, BanAction_1) {
"use strict";
Handler_1 = tslib_1.__importDefault(Handler_1);
- Ajax = tslib_1.__importStar(Ajax);
Core = tslib_1.__importStar(Core);
EventHandler = tslib_1.__importStar(EventHandler);
Language = tslib_1.__importStar(Language);
- UiNotification = tslib_1.__importStar(UiNotification);
Simple_1 = tslib_1.__importDefault(Simple_1);
Util_1 = tslib_1.__importDefault(Util_1);
+ SendNewPasswordAction_1 = tslib_1.__importDefault(SendNewPasswordAction_1);
+ ToggleConfirmEmailAction_1 = tslib_1.__importDefault(ToggleConfirmEmailAction_1);
+ DisableAction_1 = tslib_1.__importDefault(DisableAction_1);
+ BanAction_1 = tslib_1.__importDefault(BanAction_1);
class AcpUiUserEditor {
/**
* Initializes the edit dropdown for each user.
editLink.click();
});
}
- const sendNewPassword = dropdownMenu.querySelector(".jsSendNewPassword");
- if (sendNewPassword !== null) {
- sendNewPassword.addEventListener("click", (event) => {
- event.preventDefault();
- // emulate clipboard selection
- EventHandler.fire("com.woltlab.wcf.clipboard", "com.woltlab.wcf.user", {
- data: {
- actionName: "com.woltlab.wcf.user.sendNewPassword",
- parameters: {
- confirmMessage: Language.get("wcf.acp.user.action.sendNewPassword.confirmMessage"),
- objectIDs: [userId],
- },
- },
- responseData: {
- actionName: "com.woltlab.wcf.user.sendNewPassword",
- objectIDs: [userId],
- },
- });
- });
- }
const deleteContent = dropdownMenu.querySelector(".jsDeleteContent");
if (deleteContent !== null) {
new Handler_1.default(deleteContent, userId);
}
+ const sendNewPassword = dropdownMenu.querySelector(".jsSendNewPassword");
+ if (sendNewPassword !== null) {
+ new SendNewPasswordAction_1.default(sendNewPassword, userId, userRow);
+ }
const toggleConfirmEmail = dropdownMenu.querySelector(".jsConfirmEmailToggle");
if (toggleConfirmEmail !== null) {
- toggleConfirmEmail.addEventListener("click", (event) => {
- event.preventDefault();
- Ajax.api({
- _ajaxSetup: () => {
- const isEmailConfirmed = Core.stringToBool(userRow.dataset.emailConfirmed);
- return {
- data: {
- actionName: (isEmailConfirmed ? "un" : "") + "confirmEmail",
- className: "wcf\\data\\user\\UserAction",
- objectIDs: [userId],
- },
- };
- },
- }, undefined, (data) => {
- document.querySelectorAll(".jsUserRow").forEach((userRow) => {
- const userId = ~~userRow.dataset.objectId;
- if (data.objectIDs.includes(userId)) {
- const confirmEmailButton = dropdownMenu.querySelector(".jsConfirmEmailToggle");
- switch (data.actionName) {
- case "confirmEmail":
- userRow.dataset.emailConfirmed = "true";
- confirmEmailButton.textContent = confirmEmailButton.dataset.unconfirmEmailMessage;
- break;
- case "unconfirmEmail":
- userRow.dataset.emailEonfirmed = "false";
- confirmEmailButton.textContent = confirmEmailButton.dataset.confirmEmailMessage;
- break;
- default:
- throw new Error("Unreachable");
- }
- }
- });
- UiNotification.show();
- });
- });
+ new ToggleConfirmEmailAction_1.default(toggleConfirmEmail, userId, userRow);
+ }
+ const enableUser = dropdownMenu.querySelector(".jsEnable");
+ if (enableUser !== null) {
+ new DisableAction_1.default(enableUser, userId, userRow);
+ }
+ const banUser = dropdownMenu.querySelector(".jsBan");
+ if (banUser !== null) {
+ new BanAction_1.default(banUser, userId, userRow);
}
}
/**