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 | |
18 | /** |
19 | * Jabber notification method class |
20 | * This class handles sending Jabber messages for notifications |
21 | */ |
22 | |
23 | class jabber extends \phpbb\notification\method\messenger_base |
24 | { |
25 | /** @var \phpbb\user */ |
26 | protected $user; |
27 | |
28 | /** @var \phpbb\config\config */ |
29 | protected $config; |
30 | |
31 | /** |
32 | * Notification Method jabber Constructor |
33 | * |
34 | * @param \phpbb\user_loader $user_loader |
35 | * @param \phpbb\user $user |
36 | * @param \phpbb\config\config $config |
37 | * @param string $phpbb_root_path |
38 | * @param string $php_ext |
39 | */ |
40 | public function __construct(\phpbb\user_loader $user_loader, \phpbb\user $user, \phpbb\config\config $config, $phpbb_root_path, $php_ext) |
41 | { |
42 | parent::__construct($user_loader, $phpbb_root_path, $php_ext); |
43 | |
44 | $this->user = $user; |
45 | $this->config = $config; |
46 | } |
47 | |
48 | /** |
49 | * Get notification method name |
50 | * |
51 | * @return string |
52 | */ |
53 | public function get_type() |
54 | { |
55 | return 'notification.method.jabber'; |
56 | } |
57 | |
58 | /** |
59 | * Is this method available for the user? |
60 | * This is checked on the notifications options |
61 | * |
62 | * @param type_interface|null $notification_type An optional instance of a notification type. If provided, this |
63 | * method additionally checks if the type provides an email template. |
64 | * @return bool |
65 | */ |
66 | public function is_available(type_interface $notification_type = null) |
67 | { |
68 | return parent::is_available($notification_type) && $this->global_available() && !empty($this->user->data['user_jabber']); |
69 | } |
70 | |
71 | /** |
72 | * Is this method available at all? |
73 | * This is checked before notifications are sent |
74 | */ |
75 | public function global_available() |
76 | { |
77 | return !( |
78 | empty($this->config['jab_enable']) || |
79 | empty($this->config['jab_host']) || |
80 | empty($this->config['jab_username']) || |
81 | empty($this->config['jab_password']) || |
82 | !@extension_loaded('xml') |
83 | ); |
84 | } |
85 | |
86 | public function notify() |
87 | { |
88 | if (!$this->global_available()) |
89 | { |
90 | return; |
91 | } |
92 | |
93 | $this->notify_using_messenger(NOTIFY_IM, 'short/'); |
94 | } |
95 | } |