1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

Allow revoking of suspensions in ACP

This commit is contained in:
Tim Düsterhus 2013-06-22 18:43:38 +02:00
parent 9848b5820b
commit 8edb5e3f47
2 changed files with 38 additions and 1 deletions

View File

@ -5,6 +5,33 @@
$(function() { $(function() {
new WCF.Search.User('#username', null, false, [ ], false); new WCF.Search.User('#username', null, false, [ ], false);
new WCF.Search.User('#issuerUsername', null, false, [ ], false); new WCF.Search.User('#issuerUsername', null, false, [ ], false);
var proxy = new WCF.Action.Proxy({
success: function (data, textStatus, jqXHR) {
$('.jsSuspensionRow').each(function(index, row) {
var row = $(row);
if (WCF.inArray(row.data('objectID'), data.objectIDs)) {
row.find('.jsRevokeButton').addClass('disabled').removeClass('pointer').off('click');
(new WCF.System.Notification('{"chat.acp.suspension.revoke.success"|language|encodeJS}')).show();
}
});
}
});
$('.jsRevokeButton:not(.disabled)').click(function () {
var objectID = $(this).parents('.jsSuspensionRow').data('objectID');
WCF.System.Confirmation.show($(this).data('confirmMessage'), $.proxy(function (action) {
if (action === 'confirm') {
proxy.setOption('data', {
actionName: 'revoke',
className: '\\chat\\data\\suspension\\SuspensionAction',
objectIDs: [ objectID ]
});
proxy.sendRequest();
}
}, this));
});
}); });
//]]> //]]>
</script> </script>
@ -108,7 +135,7 @@
{foreach from=$objects item=$suspension} {foreach from=$objects item=$suspension}
<tr class="jsSuspensionRow" data-object-id="{$suspension->suspensionID}"> <tr class="jsSuspensionRow" data-object-id="{$suspension->suspensionID}">
<td class="columnIcon"> <td class="columnIcon">
<span class="icon icon16 icon-undo{if $suspension->expires <= TIME_NOW} disabled{/if}" title="{lang}chat.acp.suspension.revoked{/lang}"></span> <span class="icon icon16 icon-undo{if $suspension->expires <= TIME_NOW} disabled{else} pointer{/if} jsRevokeButton" title="{lang}chat.acp.suspension.revoked{/lang}" data-confirm-message="{lang}chat.acp.suspension.revoke.sure{/lang}"></span>
{event name='rowButtons'} {event name='rowButtons'}
</td> </td>
<td id="columnID">{#$suspension->suspensionID}</td> <td id="columnID">{#$suspension->suspensionID}</td>

View File

@ -1,5 +1,6 @@
<?php <?php
namespace chat\data\suspension; namespace chat\data\suspension;
use \wcf\system\WCF;
/** /**
* Executes chat-suspension-related actions. * Executes chat-suspension-related actions.
@ -16,6 +17,15 @@ class SuspensionAction extends \wcf\data\AbstractDatabaseObjectAction {
*/ */
protected $className = '\chat\data\suspension\SuspensionEditor'; protected $className = '\chat\data\suspension\SuspensionEditor';
/**
* Validates permissions and parameters
*/
public function validateRevoke() {
WCF::getSession()->checkPermissions((array) 'admin.chat.canManageSuspensions');
$this->parameters['revoker'] = WCF::getUser()->userID;
}
/** /**
* Revokes suspensions. * Revokes suspensions.
*/ */