| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\OATHAuth\Hook; |
| 4 |
|
| 5 |
use MediaWiki\Extension\Notifications\AttributeManager; |
| 6 |
use MediaWiki\Extension\Notifications\Hooks\BeforeCreateEchoEventHook; |
| 7 |
use MediaWiki\Extension\Notifications\UserLocator; |
| 8 |
use MediaWiki\Extension\OATHAuth\Notifications\DisablePresentationModel; |
| 9 |
use MediaWiki\Extension\OATHAuth\Notifications\EnablePresentationModel; |
| 10 |
use MediaWiki\Extension\OATHAuth\Notifications\RecoveryCodeCountPresentationModel; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
class EchoHandler implements BeforeCreateEchoEventHook { |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
public function onBeforeCreateEchoEvent( |
| 29 |
array &$notifications, array &$notificationCategories, array &$notificationIcons |
| 30 |
) { |
| 31 |
|
| 32 |
$notifications['oathauth-disable'] = [ |
| 33 |
'category' => 'system', |
| 34 |
'group' => 'negative', |
| 35 |
'section' => 'alert', |
| 36 |
'presentation-model' => DisablePresentationModel::class, |
| 37 |
'canNotifyAgent' => true, |
| 38 |
AttributeManager::ATTR_LOCATORS => [ |
| 39 |
[ [ UserLocator::class, 'locateEventAgent' ] ], |
| 40 |
], |
| 41 |
]; |
| 42 |
|
| 43 |
|
| 44 |
$notifications['oathauth-enable'] = [ |
| 45 |
'category' => 'system', |
| 46 |
'group' => 'positive', |
| 47 |
'section' => 'alert', |
| 48 |
'presentation-model' => EnablePresentationModel::class, |
| 49 |
'canNotifyAgent' => true, |
| 50 |
AttributeManager::ATTR_LOCATORS => [ |
| 51 |
[ [ UserLocator::class, 'locateEventAgent' ] ], |
| 52 |
], |
| 53 |
]; |
| 54 |
|
| 55 |
|
| 56 |
$notifications['oathauth-recoverycodes-count'] = [ |
| 57 |
'category' => 'system', |
| 58 |
'group' => 'negative', |
| 59 |
'section' => 'alert', |
| 60 |
'presentation-model' => RecoveryCodeCountPresentationModel::class, |
| 61 |
'canNotifyAgent' => true, |
| 62 |
'user-locators' => [ 'EchoUserLocator::locateEventAgent' ], |
| 63 |
]; |
| 64 |
} |
| 65 |
} |