Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
81 / 81 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| remove_jabber | |
100.00% |
81 / 81 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
| depends_on | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| update_schema | |
100.00% |
15 / 15 |
|
100.00% |
1 / 1 |
1 | |||
| revert_schema | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 | |||
| update_data | |
100.00% |
20 / 20 |
|
100.00% |
1 / 1 |
1 | |||
| revert_data | |
100.00% |
24 / 24 |
|
100.00% |
1 / 1 |
1 | |||
| move_jabber_to_email_notifications | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 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\db\migration\data\v400; |
| 15 | |
| 16 | use phpbb\db\migration\migration; |
| 17 | |
| 18 | class remove_jabber extends migration |
| 19 | { |
| 20 | public static function depends_on(): array |
| 21 | { |
| 22 | return [ |
| 23 | '\phpbb\db\migration\data\v310\notifications_use_full_name', |
| 24 | '\phpbb\db\migration\data\v31x\add_jabber_ssl_context_config_options', |
| 25 | '\phpbb\db\migration\data\v400\dev', |
| 26 | '\phpbb\db\migration\data\v400\add_webpush', |
| 27 | ]; |
| 28 | } |
| 29 | |
| 30 | public function update_schema(): array |
| 31 | { |
| 32 | return [ |
| 33 | 'drop_columns' => [ |
| 34 | $this->table_prefix . 'users' => [ |
| 35 | 'user_jabber', |
| 36 | ], |
| 37 | ], |
| 38 | 'add_columns' => [ |
| 39 | $this->table_prefix . 'user_notifications' => [ |
| 40 | 'id' => ['ULINT', null, 'auto_increment'], |
| 41 | ], |
| 42 | ], |
| 43 | 'add_primary_keys' => [ |
| 44 | $this->table_prefix . 'user_notifications' => ['id'], |
| 45 | ], |
| 46 | ]; |
| 47 | } |
| 48 | |
| 49 | public function revert_schema(): array |
| 50 | { |
| 51 | return [ |
| 52 | 'add_columns' => [ |
| 53 | $this->table_prefix . 'users' => [ |
| 54 | 'user_jabber' => ['VCHAR_UNI', ''], |
| 55 | ], |
| 56 | ], |
| 57 | 'drop_columns' => [ |
| 58 | $this->table_prefix . 'user_notifications' => [ |
| 59 | 'id', |
| 60 | ], |
| 61 | ], |
| 62 | ]; |
| 63 | } |
| 64 | |
| 65 | public function update_data(): array |
| 66 | { |
| 67 | return [ |
| 68 | ['config.remove', ['jab_enable']], |
| 69 | ['config.remove', ['jab_host']], |
| 70 | ['config.remove', ['jab_package_size']], |
| 71 | ['config.remove', ['jab_password']], |
| 72 | ['config.remove', ['jab_port']], |
| 73 | ['config.remove', ['jab_use_ssl']], |
| 74 | ['config.remove', ['jab_username']], |
| 75 | ['config.remove', ['jab_verify_peer']], |
| 76 | ['config.remove', ['jab_verify_peer_name']], |
| 77 | ['config.remove', ['jab_allow_self_signed']], |
| 78 | ['module.remove', [ |
| 79 | 'acp', |
| 80 | 'ACP_CLIENT_COMMUNICATION', |
| 81 | 'ACP_JABBER_SETTINGS', |
| 82 | ]], |
| 83 | ['permission.remove', ['a_jabber']], |
| 84 | ['permission.remove', ['u_sendim']], |
| 85 | ['custom', [[$this, 'move_jabber_to_email_notifications']]], |
| 86 | ]; |
| 87 | } |
| 88 | |
| 89 | public function revert_data(): array |
| 90 | { |
| 91 | return [ |
| 92 | ['config.add', ['jab_enable', 0]], |
| 93 | ['config.add', ['jab_host', '']], |
| 94 | ['config.add', ['jab_package_size', 20]], |
| 95 | ['config.add', ['jab_password', '']], |
| 96 | ['config.add', ['jab_port', 5222]], |
| 97 | ['config.add', ['jab_use_ssl', 0]], |
| 98 | ['config.add', ['jab_username', '']], |
| 99 | ['config.add', ['jab_verify_peer', 1]], |
| 100 | ['config.add', ['jab_verify_peer_name', 1]], |
| 101 | ['config.add', ['jab_allow_self_signed', 0]], |
| 102 | ['module.add', [ |
| 103 | 'acp', |
| 104 | 'ACP_CLIENT_COMMUNICATION', |
| 105 | [ |
| 106 | 'module_basename' => 'acp_jabber', |
| 107 | 'module_langname' => 'ACP_JABBER_SETTINGS', |
| 108 | 'module_mode' => 'settings', |
| 109 | 'module_auth' => 'acl_a_jabber', |
| 110 | ], |
| 111 | ]], |
| 112 | ['permission.add', ['a_jabber', true]], |
| 113 | ['permission.add', ['u_sendim', true]], |
| 114 | ]; |
| 115 | } |
| 116 | |
| 117 | public function move_jabber_to_email_notifications() |
| 118 | { |
| 119 | $sql = 'DELETE FROM ' . $this->tables['user_notifications'] . " |
| 120 | WHERE method = 'notification.method.jabber'"; |
| 121 | $this->db->sql_query($sql); |
| 122 | |
| 123 | return true; |
| 124 | } |
| 125 | } |