Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
jabber | |
0.00% |
0 / 15 |
|
0.00% |
0 / 5 |
156 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
get_type | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
is_available | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
12 | |||
global_available | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
30 | |||
notify | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | namespace phpbb\notification\method; |
15 | |
16 | use phpbb\notification\type\type_interface; |
17 | use phpbb\user; |
18 | use phpbb\user_loader; |
19 | use phpbb\config\config; |
20 | use phpbb\di\service_collection; |
21 | use phpbb\messenger\method\messenger_interface; |
22 | |
23 | /** |
24 | * Jabber notification method class |
25 | * This class handles sending Jabber messages for notifications |
26 | */ |
27 | |
28 | class jabber extends \phpbb\notification\method\messenger_base |
29 | { |
30 | /** @var user */ |
31 | protected $user; |
32 | |
33 | /** @var config */ |
34 | protected $config; |
35 | |
36 | /** @var service_collection */ |
37 | protected $messenger; |
38 | |
39 | /** |
40 | * Notification Method jabber Constructor |
41 | * |
42 | * @param user_loader $user_loader |
43 | * @param user $user |
44 | * @param config $config |
45 | * @param string $phpbb_root_path |
46 | * @param string $php_ext |
47 | * @param service_collection $messenger |
48 | */ |
49 | public function __construct(user_loader $user_loader, user $user, config $config, $phpbb_root_path, $php_ext, service_collection $messenger) |
50 | { |
51 | parent::__construct($messenger, $user_loader, $phpbb_root_path, $php_ext); |
52 | |
53 | $this->user = $user; |
54 | $this->config = $config; |
55 | } |
56 | |
57 | /** |
58 | * Get notification method name |
59 | * |
60 | * @return string |
61 | */ |
62 | public function get_type() |
63 | { |
64 | return 'notification.method.jabber'; |
65 | } |
66 | |
67 | /** |
68 | * Is this method available for the user? |
69 | * This is checked on the notifications options |
70 | * |
71 | * @param type_interface|null $notification_type An optional instance of a notification type. If provided, this |
72 | * method additionally checks if the type provides an email template. |
73 | * @return bool |
74 | */ |
75 | public function is_available(type_interface $notification_type = null) |
76 | { |
77 | return parent::is_available($notification_type) && $this->global_available() && !empty($this->user->data['user_jabber']); |
78 | } |
79 | |
80 | /** |
81 | * Is this method available at all? |
82 | * This is checked before notifications are sent |
83 | */ |
84 | public function global_available() |
85 | { |
86 | return !( |
87 | empty($this->config['jab_enable']) || |
88 | empty($this->config['jab_host']) || |
89 | empty($this->config['jab_username']) || |
90 | empty($this->config['jab_password']) || |
91 | !@extension_loaded('xml') |
92 | ); |
93 | } |
94 | |
95 | public function notify() |
96 | { |
97 | if (!$this->global_available()) |
98 | { |
99 | return; |
100 | } |
101 | |
102 | $this->notify_using_messenger(messenger_interface::NOTIFY_IM, 'short/'); |
103 | } |
104 | } |