|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Copyright (C) 2018 |
|
5
|
|
|
* Nathan Boiron <[email protected]> |
|
6
|
|
|
* Romain Canon <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This file is part of the TYPO3 NotiZ project. |
|
9
|
|
|
* It is free software; you can redistribute it and/or modify it |
|
10
|
|
|
* under the terms of the GNU General Public License, either |
|
11
|
|
|
* version 3 of the License, or any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* For the full copyright and license information, see: |
|
14
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace CuyZ\Notiz\Controller\Backend\Manager; |
|
18
|
|
|
|
|
19
|
|
|
use CuyZ\Notiz\Controller\Backend\Menu; |
|
20
|
|
|
use CuyZ\Notiz\Core\Notification\Activable; |
|
21
|
|
|
use TYPO3\CMS\Extbase\Mvc\Exception\StopActionException; |
|
22
|
|
|
|
|
23
|
|
|
class NotificationActivationController extends ManagerController |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @param string $notificationType |
|
27
|
|
|
* @param string $notificationIdentifier |
|
28
|
|
|
* @param string $filterEvent |
|
29
|
|
|
*/ |
|
30
|
|
|
public function processAction($notificationType, $notificationIdentifier, $filterEvent = null) |
|
31
|
|
|
{ |
|
32
|
|
|
$definition = $this->getDefinition(); |
|
33
|
|
|
|
|
34
|
|
|
if (!$definition->hasNotification($notificationType)) { |
|
35
|
|
|
$this->addErrorMessage( |
|
36
|
|
|
'Backend/Module/Manager/ListNotifications:notification_type_not_found', |
|
37
|
|
|
$notificationType |
|
38
|
|
|
); |
|
39
|
|
|
|
|
40
|
|
|
$this->returnToList($notificationType, $filterEvent); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
$notificationDefinition = $definition->getNotification($notificationType); |
|
44
|
|
|
$processor = $notificationDefinition->getProcessor(); |
|
45
|
|
|
|
|
46
|
|
|
$notification = $processor->getNotificationFromIdentifier($notificationIdentifier); |
|
47
|
|
|
|
|
48
|
|
|
if (!$notification instanceof Activable) { |
|
49
|
|
|
$this->returnToList($notificationType, $filterEvent); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
if ($notification->isActive()) { |
|
53
|
|
|
$processor->disable($notification); |
|
54
|
|
|
|
|
55
|
|
|
$this->returnToList($notificationType, $filterEvent); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
$processor->enable($notification); |
|
59
|
|
|
|
|
60
|
|
|
$this->returnToList($notificationType, $filterEvent); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param string $notificationType |
|
65
|
|
|
* @param string $filterEvent |
|
66
|
|
|
* @throws StopActionException |
|
67
|
|
|
*/ |
|
68
|
|
|
private function returnToList($notificationType, $filterEvent) |
|
69
|
|
|
{ |
|
70
|
|
|
$this->forward( |
|
71
|
|
|
'process', |
|
72
|
|
|
'Backend\\Manager\\ListNotifications', |
|
73
|
|
|
null, |
|
74
|
|
|
[ |
|
75
|
|
|
'notificationIdentifier' => $notificationType, |
|
76
|
|
|
'filterEvent' => $filterEvent, |
|
77
|
|
|
] |
|
78
|
|
|
); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @return string |
|
83
|
|
|
*/ |
|
84
|
|
|
protected function getMenu() |
|
85
|
|
|
{ |
|
86
|
|
|
return Menu::MANAGER_NOTIFICATIONS; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|