}
}
}
-
-
-};
-
-/**
- * Namespace for WCF.ACP.User
- */
-WCF.ACP.User = {};
-
-/**
- * UserList clipboard API
- */
-WCF.ACP.User.List = function() { this.init(); };
-WCF.ACP.User.List.prototype = {
- /**
- * Initializes the UserList clipboard API.
- */
- init: function() {
- $('body').bind('clipboardAction', $.proxy(this.handleClipboardEvent, this));
- },
-
- /**
- * Event handler for clipboard editor item actions.
- */
- handleClipboardEvent: function(event, type, actionName) {
- // ignore unrelated events
- if ((type != 'com.woltlab.wcf.user') || (actionName != 'user.delete')) return;
-
- var $item = $(event.target);
- this._delete($item);
- },
-
- /**
- * Handle delete action.
- *
- * @param jQuery item
- */
- _delete: function(item) {
- var $confirmMessage = item.data('internalData')['confirmMessage'];
- WCF.System.Confirmation.show($confirmMessage, function() {
- WCF.Clipboard.sendRequest(item);
- });
- }
};
/**
<script type="text/javascript">
//<![CDATA[
$(function() {
- WCF.Clipboard.init('wcf\\acp\\page\\UserListPage', {@$hasMarkedItems});
- new WCF.ACP.User.List();
+ var actionObjects = { };
+ actionObjects['com.woltlab.wcf.user'] = { };
+ actionObjects['com.woltlab.wcf.user']['delete'] = new WCF.Action.Delete('wcf\\data\\user\\UserAction', $('.jsUserRow'), $('#userTableContainer .wcf-menu li:first-child .wcf-badge'));
+
+ WCF.Clipboard.init('wcf\\acp\\page\\UserListPage', {@$hasMarkedItems}, actionObjects);
+
+ var options = { };
+ {if $pages > 1}
+ options.refreshPage = true;
+ {/if}
+
+ new WCF.Table.EmptyTableHandler($('#userTableContainer'), 'jsUserRow', options);
});
//]]>
</script>
</nav>
</div>
-<div class="wcf-box wcf-boxTitle wcf-marginTop wcf-shadow1">
+<div id="userTableContainer" class="wcf-box wcf-boxTitle wcf-marginTop wcf-shadow1">
<nav class="wcf-menu">
<ul>
<li{if $action == ''} class="active"{/if}><a href="{link controller='UserList'}{/link}"><span>{lang}wcf.acp.user.list.all{/lang}</span> <span class="wcf-badge" title="{lang}wcf.acp.user.list.count{/lang}">{#$items}</span></a></li>
<tbody>
{content}
{foreach from=$users item=user}
- <tr id="userRow{@$user->userID}">
+ <tr class="jsUserRow">
<td class="columnMark"><input type="checkbox" class="jsClipboardItem" data-object-id="{@$user->userID}" /></td>
<td class="columnIcon">
{if $user->editable}
<img src="{@$__wcf->getPath()}icon/edit1D.svg" alt="" title="{lang}wcf.acp.user.edit{/lang}" />
{/if}
{if $user->deletable}
- <a onclick="return confirm('{lang}wcf.acp.user.delete.sure{/lang}')" href="{link controller='UserDelete' id=$user->userID}url={@$encodedURL}{/link}"><img src="{@$__wcf->getPath()}icon/delete1.svg" alt="" title="{lang}wcf.acp.user.delete{/lang}" class="jsTooltip" /></a>
+ <img src="{@$__wcf->getPath()}icon/delete1.svg" alt="" title="{lang}wcf.acp.user.delete{/lang}" class="jsTooltip jsDeleteButton" data-object-id="{@$user->userID}" data-confirm-message="{lang}wcf.acp.user.delete.sure{/lang}" />
{else}
<img src="{@$__wcf->getPath()}icon/delete1D.svg" alt="" title="{lang}wcf.acp.user.delete{/lang}" />
{/if}
/**
* Class and function collection for WCF
*
- * @author Markus Bartz, Tim Düsterhus, Alexander Ebert
+ * @author Markus Bartz, Tim Düsterhus, Alexander Ebert, Matthias Schmidt
* @copyright 2001-2011 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*/
*/
_actionProxy: null,
+ /**
+ * action objects
+ * @var object
+ */
+ _actionObjects: {},
+
/**
* list of clipboard containers
* @var jQuery
/**
* Initializes the clipboard API.
*/
- init: function(page, hasMarkedItems) {
+ init: function(page, hasMarkedItems, actionObjects) {
this._page = page;
- if (hasMarkedItems) this._hasMarkedItems = true;
+ this._actionObjects = actionObjects;
+ if (!actionObjects) {
+ this._actionObjects = {};
+ }
+ if (hasMarkedItems) {
+ this._hasMarkedItems = true;
+ }
this._actionProxy = new WCF.Action.Proxy({
success: $.proxy(this._actionSuccess, this),
for (var $itemIndex in $editor.items) {
var $item = $editor.items[$itemIndex];
var $listItem = $('<li>' + $item.label + '</li>').appendTo($itemList);
+ $listItem.data('objectType', $typeName);
$listItem.data('actionName', $item.actionName).data('parameters', $item.parameters);
$listItem.data('internalData', $item.internalData).data('url', $item.url).data('type', $typeName);
WCF.CloseOverlayHandler.addCallback($containerID, $.proxy(this._closeLists, this));
}
},
-
+
+ /**
+ * Closes the clipboard editor item list.
+ */
_closeLists: function() {
$('.jsClipboardEditor ul ol').each(function(index, list) {
$(this).removeClass('open');
window.location.href = $url;
}
- if ($listItem.data('parameters').className && $listItem.data('parameters').actionName) {
- new WCF.Action.Proxy({
- autoSend: true,
- data: {
- actionName: $listItem.data('parameters').actionName,
- className: $listItem.data('parameters').className,
- objectIDs: this._markedObjectIDs
- },
- success: $.proxy(this._loadMarkedItems, this)
- });
+ if ($listItem.data('parameters').className && $listItem.data('parameters').actionName && $listItem.data('parameters').objectIDs) {
+ var $confirmMessage = $listItem.data('internalData')['confirmMessage'];
+ if ($confirmMessage) {
+ WCF.System.Confirmation.show($confirmMessage, $.proxy(function() {
+ this._executeAJAXActions($listItem);
+ }, this));
+ }
+ else {
+ this._executeAJAXActions($listItem);
+ }
}
// fire event
$listItem.trigger('clipboardAction', [ $listItem.data('type'), $listItem.data('actionName'), $listItem.data('parameters') ]);
},
+ /**
+ * Executes the AJAX actions for the given editor list item.
+ *
+ * @param jQuery listItem
+ */
+ _executeAJAXActions: function(listItem) {
+ var objectIDs = [];
+ $.each(listItem.data('parameters').objectIDs, function(index, objectID) {
+ objectIDs.push(parseInt(objectID));
+ });
+
+ new WCF.Action.Proxy({
+ autoSend: true,
+ data: {
+ actionName: listItem.data('parameters').actionName,
+ className: listItem.data('parameters').className,
+ objectIDs: objectIDs
+ },
+ success: $.proxy(this._loadMarkedItems, this)
+ });
+
+ if (this._actionObjects[listItem.data('objectType')] && this._actionObjects[listItem.data('objectType')][listItem.data('parameters').actionName]) {
+ this._actionObjects[listItem.data('objectType')][listItem.data('parameters').actionName].triggerEffect(objectIDs);
+ }
+ },
+
/**
* Sends a clipboard proxy request.
*
* @param object jqXHR
*/
_success: function(data, textStatus, jqXHR) {
- // remove items
+ this.triggerEffect(data.objectIDs);
+ },
+
+ /**
+ * Triggers the delete effect for the objects with the given ids.
+ *
+ * @param array objectIDs
+ */
+ triggerEffect: function(objectIDs) {
this.containerList.each($.proxy(function(index, container) {
var $objectID = $(container).find('.jsDeleteButton').data('objectID');
- if (WCF.inArray($objectID, data.objectIDs)) {
+ if (WCF.inArray($objectID, objectIDs)) {
$(container).wcfBlindOut('up', function() {
$(container).empty().remove();
}, container);
* @param object jqXHR
*/
_success: function(data, textStatus, jqXHR) {
- // remove items
+ this.triggerEffect(data.objectIDs);
+ },
+
+ /**
+ * Triggers the toggle effect for the objects with the given ids.
+ *
+ * @param array objectIDs
+ */
+ triggerEffect: function(objectIDs) {
this.containerList.each($.proxy(function(index, container) {
var $toggleButton = $(container).find(this.toggleButtonSelector);
- if (WCF.inArray($toggleButton.data('objectID'), data.objectIDs)) {
+ if (WCF.inArray($toggleButton.data('objectID'), objectIDs)) {
$(container).wcfHighlight();
// toggle icon source
break;
case 'delete':
- $count = $this->validateDelete($objects);
- if (!$count) {
+ $userIDs = $this->validateDelete($objects);
+ if (!count($userIDs)) {
return null;
}
- $item->addInternalData('confirmMessage', WCF::getLanguage()->getDynamicVariable('wcf.clipboard.item.user.delete.confirmMessage', array('count' => $count)));
+ $item->addInternalData('confirmMessage', WCF::getLanguage()->getDynamicVariable('wcf.clipboard.item.user.delete.confirmMessage', array('count' => count($userIDs))));
$item->addParameter('actionName', 'delete');
$item->addParameter('className', 'wcf\data\user\UserAction');
+ $item->addParameter('objectIDs', $userIDs);
$item->setName('user.delete');
break;
}
/**
- * Returns number of users which can be deleted.
+ * Returns the ids of the users which can be deleted.
*
* @param array<wcf\data\user\User> $objects
* @return integer
}
// user cannot delete itself
- $count = count($objects);
$userIDs = array_keys($objects);
foreach ($userIDs as $index => $userID) {
if ($userID == WCF::getUser()->userID) {
- $count--;
unset($objects[$userID]);
unset($userIDs[$index]);
}
}
// no valid users found
- if (!$count) return 0;
+ if (!count($userIDs)) return array();
// fetch user to group associations
$conditions = new PreparedStatementConditionBuilder();
}
// validate if user's group is accessible for current user
- $count = count($objects);
- foreach ($userIDs as $index => $userID) {
- if (!isset($userToGroup[$userID])) {
- $count--;
- continue;
- }
-
- if (!UserGroup::isAccessibleGroup($userToGroup[$userID])) {
- $count--;
+ foreach ($userIDs as $userID) {
+ if (!isset($userToGroup[$userID]) || !UserGroup::isAccessibleGroup($userToGroup[$userID])) {
+ unset($userIDs[$userID]);
}
}
- return $count;
+ return $userIDs;
}
/**