wiki.techinc.nl/includes/block/UserBlockCommandFactory.php
Martin Urbanec d64efdeacb Introduce backend class for unblocking users
Create UnblockUserFactory service, which returns an UnblockUser.
UnblockUser::unblock replaces SpecialUnblock::processUnblock, which
is now deprecated.

Update SpecialUnblock and ApiUnblock to use UnblockUser, removing
the API module's dependency on the special page.

Update SpecialUnblock::processUIUnblock to use UnblockUser, and mark
it for internal use only. It now returns a Status object.

Also add BlockPermissionChecker::checkBasePermissions, which checks
for the 'block' right and the 'hideuser' right if necessary.

Bug: T250020
Change-Id: Ide31da469297f4582ad0e3f7f1a7c40d542923f8
2020-08-25 13:34:36 +01:00

73 lines
1.8 KiB
PHP

<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
namespace MediaWiki\Block;
use MediaWiki\HookContainer\HookContainer;
use User;
class UserBlockCommandFactory implements UnblockUserFactory {
/**
* @var BlockPermissionCheckerFactory
*/
private $blockPermissionCheckerFactory;
/**
* @var HookContainer
*/
private $hookContainer;
/**
* @param BlockPermissionCheckerFactory $blockPermissionCheckerFactory
* @param HookContainer $hookContainer
*/
public function __construct(
BlockPermissionCheckerFactory $blockPermissionCheckerFactory,
HookContainer $hookContainer
) {
$this->blockPermissionCheckerFactory = $blockPermissionCheckerFactory;
$this->hookContainer = $hookContainer;
}
/**
* @param User|string $target
* @param User $performer
* @param string $reason
* @param array $tags
*
* @return UnblockUser
*/
public function newUnblockUser(
$target,
User $performer,
string $reason,
array $tags = []
) : UnblockUser {
return new UnblockUser(
$this->blockPermissionCheckerFactory,
$this->hookContainer,
$target,
$performer,
$reason,
$tags
);
}
}