-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathDevtoolsNotificationTestPage.class.php
More file actions
87 lines (71 loc) · 2.33 KB
/
DevtoolsNotificationTestPage.class.php
File metadata and controls
87 lines (71 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace wcf\acp\page;
use wcf\data\object\type\ObjectTypeCache;
use wcf\page\AbstractPage;
use wcf\system\user\notification\event\ITestableUserNotificationEvent;
use wcf\system\user\notification\UserNotificationHandler;
use wcf\system\WCF;
/**
* Shows a list of available testable user notification events.
*
* @author Matthias Schmidt
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*/
class DevtoolsNotificationTestPage extends AbstractPage
{
/**
* @inheritDoc
*/
public $activeMenuItem = 'wcf.acp.menu.link.devtools.notificationTest';
/**
* available testable user notification events
* @var ITestableUserNotificationEvent[][]
*/
protected $events = [];
/**
* @inheritDoc
*/
public $neededPermissions = ['admin.configuration.package.canInstallPackage'];
#[\Override]
public function readData()
{
parent::readData();
$this->events = UserNotificationHandler::getInstance()->getAvailableEvents();
// filter events
foreach ($this->events as $objectTypeID => $events) {
foreach ($events as $eventName => $event) {
if (!$event instanceof ITestableUserNotificationEvent) {
unset($this->events[$objectTypeID][$eventName]);
}
}
if (empty($this->events[$objectTypeID])) {
unset($this->events[$objectTypeID]);
}
}
$groupedEvents = [];
foreach ($this->events as $objectType => $events) {
$objectTypeObj = ObjectTypeCache::getInstance()->getObjectTypeByName(
'com.woltlab.wcf.notification.objectType',
$objectType
);
$category = ($objectTypeObj->category ?: $objectType);
if (!isset($groupedEvents[$category])) {
$groupedEvents[$category] = [];
}
foreach ($events as $event) {
$groupedEvents[$category][] = $event;
}
}
\ksort($groupedEvents);
$this->events = $groupedEvents;
}
#[\Override]
public function assignVariables()
{
parent::assignVariables();
WCF::getTPL()->assign([
'events' => $this->events,
]);
}
}