Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
avatar_types | |
0.00% |
0 / 18 |
|
0.00% |
0 / 4 |
42 | |
0.00% |
0 / 1 |
depends_on | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
update_data | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
update_user_avatar_type | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
update_group_avatar_type | |
0.00% |
0 / 5 |
|
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\db\migration\data\v310; |
15 | |
16 | class avatar_types extends \phpbb\db\migration\migration |
17 | { |
18 | /** |
19 | * @var array avatar type map |
20 | */ |
21 | protected $avatar_type_map = array( |
22 | AVATAR_UPLOAD => 'avatar.driver.upload', |
23 | AVATAR_GALLERY => 'avatar.driver.local', |
24 | ); |
25 | |
26 | public static function depends_on() |
27 | { |
28 | return array( |
29 | '\phpbb\db\migration\data\v310\dev', |
30 | '\phpbb\db\migration\data\v310\avatars', |
31 | ); |
32 | } |
33 | |
34 | public function update_data() |
35 | { |
36 | return array( |
37 | array('custom', array(array($this, 'update_user_avatar_type'))), |
38 | array('custom', array(array($this, 'update_group_avatar_type'))), |
39 | ); |
40 | } |
41 | |
42 | public function update_user_avatar_type() |
43 | { |
44 | foreach ($this->avatar_type_map as $old => $new) |
45 | { |
46 | $sql = 'UPDATE ' . $this->table_prefix . "users |
47 | SET user_avatar_type = '$new' |
48 | WHERE user_avatar_type = '$old'"; |
49 | $this->db->sql_query($sql); |
50 | } |
51 | } |
52 | |
53 | public function update_group_avatar_type() |
54 | { |
55 | foreach ($this->avatar_type_map as $old => $new) |
56 | { |
57 | $sql = 'UPDATE ' . $this->table_prefix . "groups |
58 | SET group_avatar_type = '$new' |
59 | WHERE group_avatar_type = '$old'"; |
60 | $this->db->sql_query($sql); |
61 | } |
62 | } |
63 | } |