| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Permissions\Hook; |
| 4 | |
| 5 | use MediaWiki\Title\Title; |
| 6 | use MediaWiki\User\User; |
| 7 | use Wikimedia\Message\MessageSpecifier; |
| 8 | |
| 9 | /** |
| 10 | * This is a hook handler interface, see docs/Hooks.md. |
| 11 | * Use the hook name "getUserPermissionsErrors" to register handlers implementing this interface. |
| 12 | * |
| 13 | * @stable to implement |
| 14 | * @ingroup Hooks |
| 15 | */ |
| 16 | interface GetUserPermissionsErrorsHook { |
| 17 | /** |
| 18 | * Use this hook to add a permissions error when permissions errors are |
| 19 | * checked for. Use instead of userCan for most cases. Return false if the user |
| 20 | * can't do it, and populate $result with the reason in the form of |
| 21 | * [ messagename, param1, param2, ... ] or a MessageSpecifier instance (you |
| 22 | * might want to use ApiMessage to provide machine-readable details for the API). |
| 23 | * |
| 24 | * @since 1.35 |
| 25 | * |
| 26 | * @param Title $title Title being checked against |
| 27 | * @param User $user Current user |
| 28 | * @param string $action Action being checked |
| 29 | * @param array|string|MessageSpecifier &$result User permissions error to add. If none, return true. |
| 30 | * For consistency, error messages should be plain text with no special coloring, |
| 31 | * bolding, etc. to show that they're errors; presenting them properly to the |
| 32 | * user as errors is done by the caller. |
| 33 | * @return bool|void True or no return value to continue or false to abort |
| 34 | */ |
| 35 | public function onGetUserPermissionsErrors( $title, $user, $action, &$result ); |
| 36 | } |