@@ -12,99 +12,99 @@ |
||
12 | 12 | */ |
13 | 13 | class listener implements EventSubscriberInterface |
14 | 14 | { |
15 | - /** @var \phpbb\config\config */ |
|
16 | - protected $config; |
|
15 | + /** @var \phpbb\config\config */ |
|
16 | + protected $config; |
|
17 | 17 | |
18 | - /** @var \phpbb\controller\helper */ |
|
19 | - protected $helper; |
|
18 | + /** @var \phpbb\controller\helper */ |
|
19 | + protected $helper; |
|
20 | 20 | |
21 | - /** @var \phpbb\template\template */ |
|
22 | - protected $template; |
|
21 | + /** @var \phpbb\template\template */ |
|
22 | + protected $template; |
|
23 | 23 | |
24 | - /** @var \phpbb\user */ |
|
25 | - protected $user; |
|
24 | + /** @var \phpbb\user */ |
|
25 | + protected $user; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Constructor. |
|
29 | - * |
|
30 | - * @param \phpbb\config\config $config Config object |
|
31 | - * @param \phpbb\controller\helper $helper Helper object |
|
32 | - * @param \phpbb\template\template $template Template object |
|
33 | - * @param \phpbb\user $user User object |
|
34 | - */ |
|
35 | - public function __construct(\phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\user $user) |
|
36 | - { |
|
37 | - $this->config = $config; |
|
38 | - $this->helper = $helper; |
|
39 | - $this->template = $template; |
|
40 | - $this->user = $user; |
|
41 | - } |
|
27 | + /** |
|
28 | + * Constructor. |
|
29 | + * |
|
30 | + * @param \phpbb\config\config $config Config object |
|
31 | + * @param \phpbb\controller\helper $helper Helper object |
|
32 | + * @param \phpbb\template\template $template Template object |
|
33 | + * @param \phpbb\user $user User object |
|
34 | + */ |
|
35 | + public function __construct(\phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\user $user) |
|
36 | + { |
|
37 | + $this->config = $config; |
|
38 | + $this->helper = $helper; |
|
39 | + $this->template = $template; |
|
40 | + $this->user = $user; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Assign functions defined in this class to event listeners in the core. |
|
45 | - * |
|
46 | - * @return array |
|
47 | - * @static |
|
48 | - */ |
|
49 | - public static function getSubscribedEvents() |
|
50 | - { |
|
51 | - return [ |
|
52 | - 'core.page_header' => 'page_header', |
|
53 | - 'core.acp_board_config_edit_add' => 'acp_board_config_edit_add', |
|
54 | - ]; |
|
55 | - } |
|
43 | + /** |
|
44 | + * Assign functions defined in this class to event listeners in the core. |
|
45 | + * |
|
46 | + * @return array |
|
47 | + * @static |
|
48 | + */ |
|
49 | + public static function getSubscribedEvents() |
|
50 | + { |
|
51 | + return [ |
|
52 | + 'core.page_header' => 'page_header', |
|
53 | + 'core.acp_board_config_edit_add' => 'acp_board_config_edit_add', |
|
54 | + ]; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Send AJAX URL to template. |
|
59 | - * |
|
60 | - * @return null |
|
61 | - */ |
|
62 | - public function page_header() |
|
63 | - { |
|
64 | - $this->template->assign_vars([ |
|
65 | - 'U_AJAXNOTIFICATION' => $this->helper->route('tas2580_ajaxnotification', []), |
|
66 | - 'U_AJAXNOTIFICATION_TIMER' => $this->config['ajaxnotification_timeout'] * 1000, |
|
67 | - ]); |
|
68 | - } |
|
57 | + /** |
|
58 | + * Send AJAX URL to template. |
|
59 | + * |
|
60 | + * @return null |
|
61 | + */ |
|
62 | + public function page_header() |
|
63 | + { |
|
64 | + $this->template->assign_vars([ |
|
65 | + 'U_AJAXNOTIFICATION' => $this->helper->route('tas2580_ajaxnotification', []), |
|
66 | + 'U_AJAXNOTIFICATION_TIMER' => $this->config['ajaxnotification_timeout'] * 1000, |
|
67 | + ]); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Add field to acp_board load settings page. |
|
72 | - * |
|
73 | - * @param object $event The event object |
|
74 | - * |
|
75 | - * @return null |
|
76 | - */ |
|
77 | - public function acp_board_config_edit_add($event) |
|
78 | - { |
|
79 | - if ($event['mode'] == 'load') { |
|
80 | - $this->user->add_lang_ext('tas2580/ajaxnotification', 'common'); |
|
70 | + /** |
|
71 | + * Add field to acp_board load settings page. |
|
72 | + * |
|
73 | + * @param object $event The event object |
|
74 | + * |
|
75 | + * @return null |
|
76 | + */ |
|
77 | + public function acp_board_config_edit_add($event) |
|
78 | + { |
|
79 | + if ($event['mode'] == 'load') { |
|
80 | + $this->user->add_lang_ext('tas2580/ajaxnotification', 'common'); |
|
81 | 81 | |
82 | - $display_vars = $event['display_vars']; |
|
83 | - $insert = ['ajaxnotification_timeout' => [ |
|
84 | - 'lang' => 'ACP_AJAXNOTIFICATION_TIMEOUT', |
|
85 | - 'validate' => 'int:0:99999', |
|
86 | - 'type' => 'number:0:99999', |
|
87 | - 'explain' => true, |
|
88 | - 'append' => ' '.$this->user->lang['SECONDS'], |
|
89 | - ]]; |
|
90 | - $display_vars['vars'] = $this->array_insert($display_vars['vars'], 'legend2', $insert); |
|
91 | - $event['display_vars'] = $display_vars; |
|
92 | - } |
|
93 | - } |
|
82 | + $display_vars = $event['display_vars']; |
|
83 | + $insert = ['ajaxnotification_timeout' => [ |
|
84 | + 'lang' => 'ACP_AJAXNOTIFICATION_TIMEOUT', |
|
85 | + 'validate' => 'int:0:99999', |
|
86 | + 'type' => 'number:0:99999', |
|
87 | + 'explain' => true, |
|
88 | + 'append' => ' '.$this->user->lang['SECONDS'], |
|
89 | + ]]; |
|
90 | + $display_vars['vars'] = $this->array_insert($display_vars['vars'], 'legend2', $insert); |
|
91 | + $event['display_vars'] = $display_vars; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | |
95 | - private function array_insert(&$array, $position, $insert) |
|
96 | - { |
|
97 | - if (is_int($position)) { |
|
98 | - array_splice($array, $position, 0, $insert); |
|
99 | - } else { |
|
100 | - $pos = array_search($position, array_keys($array)); |
|
101 | - $array = array_merge( |
|
102 | - array_slice($array, 0, $pos), |
|
103 | - $insert, |
|
104 | - array_slice($array, $pos) |
|
105 | - ); |
|
106 | - } |
|
95 | + private function array_insert(&$array, $position, $insert) |
|
96 | + { |
|
97 | + if (is_int($position)) { |
|
98 | + array_splice($array, $position, 0, $insert); |
|
99 | + } else { |
|
100 | + $pos = array_search($position, array_keys($array)); |
|
101 | + $array = array_merge( |
|
102 | + array_slice($array, 0, $pos), |
|
103 | + $insert, |
|
104 | + array_slice($array, $pos) |
|
105 | + ); |
|
106 | + } |
|
107 | 107 | |
108 | - return $array; |
|
109 | - } |
|
108 | + return $array; |
|
109 | + } |
|
110 | 110 | } |
@@ -10,47 +10,47 @@ |
||
10 | 10 | |
11 | 11 | class main |
12 | 12 | { |
13 | - /** @var \phpbb\path_helper */ |
|
14 | - protected $path_helper; |
|
15 | - |
|
16 | - /** @var Container */ |
|
17 | - protected $phpbb_container; |
|
18 | - |
|
19 | - /** @var \phpbb\user */ |
|
20 | - protected $user; |
|
21 | - |
|
22 | - /** |
|
23 | - * Constructor. |
|
24 | - * |
|
25 | - * @param \phpbb\path_helper $path_helper |
|
26 | - * @param Container $phpbb_container |
|
27 | - * @param \phpbb\user $user |
|
28 | - */ |
|
29 | - public function __construct(\phpbb\path_helper $path_helper, Container $phpbb_container, \phpbb\user $user) |
|
30 | - { |
|
31 | - $this->path_helper = $path_helper; |
|
32 | - $this->phpbb_container = $phpbb_container; |
|
33 | - $this->user = $user; |
|
34 | - } |
|
35 | - |
|
36 | - public function query() |
|
37 | - { |
|
38 | - $phpbb_notifications = $this->phpbb_container->get('notification_manager'); |
|
39 | - $notifications = $phpbb_notifications->load_notifications([ |
|
40 | - 'user_id' => $this->user->data['user_id'], |
|
41 | - 'all_unread' => true, |
|
42 | - 'limit' => 5, |
|
43 | - ]); |
|
44 | - |
|
45 | - $result = []; |
|
46 | - foreach ($notifications['notifications'] as $notification) { |
|
47 | - $data = $notification->prepare_for_display(); |
|
48 | - $data['U_MARK_READ'] = $this->path_helper->update_web_root_path($data['U_MARK_READ']); |
|
49 | - $data['URL'] = $this->path_helper->update_web_root_path($data['URL']); |
|
50 | - $data['L_MARK_READ'] = $this->user->lang['MARK_READ']; |
|
51 | - $result[] = $data; |
|
52 | - } |
|
53 | - |
|
54 | - return new JsonResponse($result); |
|
55 | - } |
|
13 | + /** @var \phpbb\path_helper */ |
|
14 | + protected $path_helper; |
|
15 | + |
|
16 | + /** @var Container */ |
|
17 | + protected $phpbb_container; |
|
18 | + |
|
19 | + /** @var \phpbb\user */ |
|
20 | + protected $user; |
|
21 | + |
|
22 | + /** |
|
23 | + * Constructor. |
|
24 | + * |
|
25 | + * @param \phpbb\path_helper $path_helper |
|
26 | + * @param Container $phpbb_container |
|
27 | + * @param \phpbb\user $user |
|
28 | + */ |
|
29 | + public function __construct(\phpbb\path_helper $path_helper, Container $phpbb_container, \phpbb\user $user) |
|
30 | + { |
|
31 | + $this->path_helper = $path_helper; |
|
32 | + $this->phpbb_container = $phpbb_container; |
|
33 | + $this->user = $user; |
|
34 | + } |
|
35 | + |
|
36 | + public function query() |
|
37 | + { |
|
38 | + $phpbb_notifications = $this->phpbb_container->get('notification_manager'); |
|
39 | + $notifications = $phpbb_notifications->load_notifications([ |
|
40 | + 'user_id' => $this->user->data['user_id'], |
|
41 | + 'all_unread' => true, |
|
42 | + 'limit' => 5, |
|
43 | + ]); |
|
44 | + |
|
45 | + $result = []; |
|
46 | + foreach ($notifications['notifications'] as $notification) { |
|
47 | + $data = $notification->prepare_for_display(); |
|
48 | + $data['U_MARK_READ'] = $this->path_helper->update_web_root_path($data['U_MARK_READ']); |
|
49 | + $data['URL'] = $this->path_helper->update_web_root_path($data['URL']); |
|
50 | + $data['L_MARK_READ'] = $this->user->lang['MARK_READ']; |
|
51 | + $result[] = $data; |
|
52 | + } |
|
53 | + |
|
54 | + return new JsonResponse($result); |
|
55 | + } |
|
56 | 56 | } |
@@ -7,11 +7,11 @@ |
||
7 | 7 | |
8 | 8 | class initial_extension extends \phpbb\db\migration\migration |
9 | 9 | { |
10 | - public function update_data() |
|
11 | - { |
|
12 | - return [ |
|
13 | - // Add configs |
|
14 | - ['config.add', ['ajaxnotification_timeout', '10']], |
|
15 | - ]; |
|
16 | - } |
|
10 | + public function update_data() |
|
11 | + { |
|
12 | + return [ |
|
13 | + // Add configs |
|
14 | + ['config.add', ['ajaxnotification_timeout', '10']], |
|
15 | + ]; |
|
16 | + } |
|
17 | 17 | } |
@@ -4,14 +4,14 @@ |
||
4 | 4 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
5 | 5 | */ |
6 | 6 | if (!defined('IN_PHPBB')) { |
7 | - exit; |
|
7 | + exit; |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | if (empty($lang) || !is_array($lang)) { |
11 | - $lang = []; |
|
11 | + $lang = []; |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | $lang = array_merge($lang, [ |
15 | - 'ACP_AJAXNOTIFICATION_TIMEOUT' => 'Timeout für Ajax Benachrichtigungen', |
|
16 | - 'ACP_AJAXNOTIFICATION_TIMEOUT_EXPLAIN' => 'Gib in Sekunden an wie oft nach neuen Benachrichtigungen geschaut werden soll. Beachte das eine zu niedrige Zahl den Server sehr stark belasten kann.', |
|
15 | + 'ACP_AJAXNOTIFICATION_TIMEOUT' => 'Timeout für Ajax Benachrichtigungen', |
|
16 | + 'ACP_AJAXNOTIFICATION_TIMEOUT_EXPLAIN' => 'Gib in Sekunden an wie oft nach neuen Benachrichtigungen geschaut werden soll. Beachte das eine zu niedrige Zahl den Server sehr stark belasten kann.', |
|
17 | 17 | ]); |