</pages>
</action>
- <action name="sendMail">
+ <action name="delete">
<actionclassname><![CDATA[wcf\system\clipboard\action\UserClipboardAction]]></actionclassname>
<showorder>2</showorder>
<pages>
<page><![CDATA[wcf\acp\page\UserListPage]]></page>
</pages>
</action>
-
- <action name="delete">
+
+ <action name="ban">
<actionclassname><![CDATA[wcf\system\clipboard\action\UserClipboardAction]]></actionclassname>
<showorder>3</showorder>
<pages>
<page><![CDATA[wcf\acp\page\UserListPage]]></page>
</pages>
</action>
+
+ <action name="sendMail">
+ <actionclassname><![CDATA[wcf\system\clipboard\action\UserClipboardAction]]></actionclassname>
+ <showorder>4</showorder>
+ <pages>
+ <page><![CDATA[wcf\acp\page\UserListPage]]></page>
+ </pages>
+ </action>
<action name="exportMailAddress">
<actionclassname><![CDATA[wcf\system\clipboard\action\UserClipboardAction]]></actionclassname>
- <showorder>4</showorder>
+ <showorder>5</showorder>
<pages>
<page><![CDATA[wcf\acp\page\UserListPage]]></page>
</pages>
this.ban([ $button.data('objectID') ]);
}
}, this));
+
+ // bind listener
+ $('.jsClipboardEditor').each($.proxy(function(index, container) {
+ var $container = $(container);
+ var $types = eval($container.data('types'));
+ if (WCF.inArray('com.woltlab.wcf.user', $types)) {
+ $container.on('clipboardAction', $.proxy(this._execute, this));
+ return false;
+ }
+ }, this));
+ },
+
+ /**
+ * Handles clipboard actions.
+ *
+ * @param object event
+ * @param string type
+ * @param string actionName
+ * @param object parameters
+ */
+ _execute: function(event, type, actionName, parameters) {
+ if (actionName == 'com.woltlab.wcf.user.ban') {
+ this.ban(parameters.objectIDs);
+ }
},
/**
var $notification = new WCF.System.Notification();
$notification.show();
+
+ WCF.Clipboard.reload();
}
};
\ No newline at end of file
$statement->execute(
array_merge(array(1, $this->parameters['banReason']), $conditionBuilder->getParameters())
);
+
+ $this->unmarkItems();
}
/**
public function unmarkAll() {
ClipboardHandler::getInstance()->removeItems(ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user'));
}
+
+ /**
+ * Unmarks users.
+ *
+ * @param array<integer> $userIDs
+ */
+ protected function unmarkItems(array $userIDs = array()) {
+ if (empty($userIDs)) {
+ $userIDs = $this->objectIDs;
+ }
+
+ if (!empty($userIDs)) {
+ ClipboardHandler::getInstance()->unmark($userIDs, ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user'));
+ }
+ }
}
/**
* @see wcf\system\clipboard\action\AbstractClipboardAction::$supportedActions
*/
- protected $supportedActions = array('assignToGroup', 'delete', 'exportMailAddress', 'sendMail');
+ protected $supportedActions = array('assignToGroup', 'ban', 'delete', 'exportMailAddress', 'sendMail');
/**
* @see wcf\system\clipboard\action\IClipboardAction::execute()
protected function validateDelete() {
// check permissions
if (!WCF::getSession()->getPermission('admin.user.canDeleteUser')) {
- return 0;
+ return array();
}
- // user cannot delete itself
- $userIDs = array_keys($this->objects);
- foreach ($userIDs as $index => $userID) {
- if ($userID == WCF::getUser()->userID) {
- unset($userIDs[$index]);
+ return $this->__validateAccessibleGroups(array_keys($this->objects));
+ }
+
+ /**
+ * Returns the ids of the users which can be banned.
+ *
+ * @return array<integer>
+ */
+ protected function validateBan() {
+ // check permissions
+ if (!WCF::getSession()->getPermission('admin.user.canBanUser')) {
+ return array();
+ }
+
+ return $this->__validateAccessibleGroups(array_keys($this->objects));
+ }
+
+ /**
+ * Validates accessible groups.
+ *
+ * @return array<integer>
+ */
+ protected function __validateAccessibleGroups(array $userIDs, $ignoreOwnUser = true) {
+ if ($ignoreOwnUser) {
+ foreach ($userIDs as $index => $userID) {
+ if ($userID == WCF::getUser()->userID) {
+ unset($userIDs[$index]);
+ }
}
}
if (!isset($userToGroup[$row['userID']])) {
$userToGroup[$row['userID']] = array();
}
-
+
$userToGroup[$row['userID']][] = $row['groupID'];
}
<category name="wcf.clipboard">
<item name="wcf.clipboard.item.unmarkAll"><![CDATA[Demarkieren]]></item>
<item name="wcf.clipboard.item.com.woltlab.wcf.user.assignToGroup"><![CDATA[Benutzergruppe zuweisen]]></item>
+ <item name="wcf.clipboard.item.com.woltlab.wcf.user.ban"><![CDATA[Sperren ({#$count})]]></item>
<item name="wcf.clipboard.item.com.woltlab.wcf.user.delete"><![CDATA[Löschen ({#$count})]]></item>
<item name="wcf.clipboard.item.com.woltlab.wcf.user.delete.confirmMessage"><![CDATA[{if $count == 1}Einen{else}{#$count}{/if} Benutzer löschen?]]></item>
<item name="wcf.clipboard.item.com.woltlab.wcf.user.exportMailAddress"><![CDATA[E-Mail-Adressen exportieren]]></item>
<category name="wcf.clipboard">
<item name="wcf.clipboard.item.unmarkAll"><![CDATA[Unmark All]]></item>
<item name="wcf.clipboard.item.com.woltlab.wcf.user.assignToGroup"><![CDATA[Assign to User Group]]></item>
+ <item name="wcf.clipboard.item.com.woltlab.wcf.user.ban"><![CDATA[TODO: Sperren ({#$count})]]></item>
<item name="wcf.clipboard.item.com.woltlab.wcf.user.delete"><![CDATA[Delete ({#$count})]]></item>
<item name="wcf.clipboard.item.com.woltlab.wcf.user.delete.confirmMessage"><![CDATA[Do you really want to delete {#$count} user{if $count != 1}s{/if}?]]></item>
<item name="wcf.clipboard.item.com.woltlab.wcf.user.exportMailAddress"><![CDATA[Export Email addresses]]></item>