| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\Notifications\Api; |
| 4 |
|
| 5 |
use MediaWiki\Api\ApiBase; |
| 6 |
use MediaWiki\Context\ContextSource; |
| 7 |
use MediaWiki\Message\Message; |
| 8 |
use MediaWiki\Permissions\Authority; |
| 9 |
use Wikimedia\Message\MessageSpecifier; |
| 10 |
|
| 11 |
trait ApiEchoPermissionsTrait { |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
abstract public function getAuthority(): Authority; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
abstract public function dieWithError( $msg, $code = null, $data = null, $httpCode = 0 ); |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
abstract public function msg( $key ); |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
private function checkReadNotificationsPermissions(): void { |
| 41 |
if ( !$this->getAuthority()->isRegistered() ) { |
| 42 |
$this->dieWithError( 'apierror-mustbeloggedin-generic', 'login-required' ); |
| 43 |
} |
| 44 |
if ( !$this->getAuthority()->isAllowed( 'echo-read-notifications' ) ) { |
| 45 |
$this->dieWithError( [ |
| 46 |
'apierror-permissiondenied', |
| 47 |
$this->msg( 'action-echo-read-notifications' ), |
| 48 |
] ); |
| 49 |
} |
| 50 |
} |
| 51 |
} |