1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* PayPal Donation extension for the phpBB Forum Software package. |
5
|
|
|
* |
6
|
|
|
* @copyright (c) 2015 Skouat |
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace skouat\ppde\migrations\v30x; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* This migration removes old data from 3.0 |
15
|
|
|
* installations of PayPal Donation MOD. |
16
|
|
|
*/ |
17
|
|
|
class v300_m1_converter_data extends \phpbb\db\migration\migration |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Run migration if donation_mod_version config exists |
21
|
|
|
* |
22
|
|
|
* @return bool |
23
|
|
|
*/ |
24
|
|
|
public function effectively_installed() |
25
|
|
|
{ |
26
|
|
|
return !isset($this->config['donation_mod_version']); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public static function depends_on() |
30
|
|
|
{ |
31
|
|
|
return array('\phpbb\db\migration\data\v31x\v313'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
|
|
public function update_data() |
38
|
|
|
{ |
39
|
|
|
return array( |
40
|
|
|
array('if', array( |
41
|
|
|
array('module.exists', array('acp', false, 'DONATION_OVERVIEW')), |
42
|
|
|
array('module.remove', array('acp', false, 'DONATION_OVERVIEW')), |
43
|
|
|
)), |
44
|
|
|
array('if', array( |
45
|
|
|
array('module.exists', array('acp', false, 'DONATION_CONFIG')), |
46
|
|
|
array('module.remove', array('acp', false, 'DONATION_CONFIG')), |
47
|
|
|
)), |
48
|
|
|
array('if', array( |
49
|
|
|
array('module.exists', array('acp', false, 'DONATION_DP_CONFIG')), |
50
|
|
|
array('module.remove', array('acp', false, 'DONATION_DP_CONFIG')), |
51
|
|
|
)), |
52
|
|
|
array('if', array( |
53
|
|
|
array('module.exists', array('acp', false, 'DONATION_DC_CONFIG')), |
54
|
|
|
array('module.remove', array('acp', false, 'DONATION_DC_CONFIG')), |
55
|
|
|
)), |
56
|
|
|
array('if', array( |
57
|
|
|
array('module.exists', array('acp', false, 'ACP_DONATION_MOD')), |
58
|
|
|
array('module.remove', array('acp', false, 'ACP_DONATION_MOD')), |
59
|
|
|
)), |
60
|
|
|
|
61
|
|
|
// Custom functions |
62
|
|
|
array('custom', array(array($this, 'rename_ppdm_configs'))), |
63
|
|
|
array('custom', array(array($this, 'remove_ppdm_configs'))), |
64
|
|
|
array('custom', array(array($this, 'rename_ppdm_permissions'))), |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Rename config data from PayPal Donation MOD |
70
|
|
|
*/ |
71
|
|
|
public function rename_ppdm_configs() |
72
|
|
|
{ |
73
|
|
|
$ppdm_config_names = array( |
74
|
|
|
'donation_account_id' => 'ppde_account_id', |
75
|
|
|
'donation_default_value' => 'ppde_default_value', |
76
|
|
|
'donation_dropbox_enable' => 'ppde_dropbox_enable', |
77
|
|
|
'donation_dropbox_value' => 'ppde_dropbox_value', |
78
|
|
|
'donation_goal' => 'ppde_goal', |
79
|
|
|
'donation_goal_enable' => 'ppde_goal_enable', |
80
|
|
|
'donation_install_date' => 'ppde_install_date', |
81
|
|
|
'donation_raised' => 'ppde_raised', |
82
|
|
|
'donation_raised_enable' => 'ppde_raised_enable', |
83
|
|
|
'donation_stats_index_enable' => 'ppde_stats_index_enable', |
84
|
|
|
'donation_used' => 'ppde_used', |
85
|
|
|
'donation_used_enable' => 'ppde_used_enable', |
86
|
|
|
'paypal_sandbox_address' => 'ppde_sandbox_address', |
87
|
|
|
); |
88
|
|
|
|
89
|
|
|
foreach ($ppdm_config_names as $old_name => $new_name) |
90
|
|
|
{ |
91
|
|
|
// Retrieve the current_value of the config |
92
|
|
|
$current_value = $this->config->offsetGet($old_name); |
93
|
|
|
// Rename the config |
94
|
|
|
$sql = 'UPDATE ' . $this->table_prefix . "config |
95
|
|
|
SET config_name = '" . $new_name . "' |
96
|
|
|
WHERE config_name = '" . $old_name . "'"; |
97
|
|
|
$this->db->sql_query($sql); |
98
|
|
|
// Set the new config name to the property $this->config. |
99
|
|
|
// This is necessary to prevent duplicate entry during the data_update() process |
100
|
|
|
$this->config->offsetSet($new_name, $current_value); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Remove config data from PayPal Donation MOD |
106
|
|
|
*/ |
107
|
|
|
public function remove_ppdm_configs() |
108
|
|
|
{ |
109
|
|
|
$ppdm_config_names = array( |
110
|
|
|
'donation_currency_enable', |
111
|
|
|
'donation_default_currency', |
112
|
|
|
'donation_enable', |
113
|
|
|
'donation_mod_version', |
114
|
|
|
'paypal_sandbox_enable', |
115
|
|
|
'paypal_sandbox_founder_enable', |
116
|
|
|
); |
117
|
|
|
|
118
|
|
|
// Delete all the unwanted configs |
119
|
|
|
$sql = 'DELETE FROM ' . $this->table_prefix . 'config |
120
|
|
|
WHERE ' . $this->db->sql_in_set('config_name', $ppdm_config_names); |
121
|
|
|
$this->db->sql_query($sql); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Rename permission from PayPal Donation MOD |
126
|
|
|
*/ |
127
|
|
|
public function rename_ppdm_permissions() |
128
|
|
|
{ |
129
|
|
|
$ppdm_permissions_names = array( |
130
|
|
|
'a_pdm_manage' => 'a_ppde_manage', |
131
|
|
|
'u_pdm_use' => 'u_ppde_use', |
132
|
|
|
); |
133
|
|
|
|
134
|
|
|
// Update all the configs kept in PPDE |
135
|
|
|
foreach ($ppdm_permissions_names as $old_name => $new_name) |
136
|
|
|
{ |
137
|
|
|
$sql = 'UPDATE ' . $this->table_prefix . "acl_options |
138
|
|
|
SET auth_option = '" . $new_name . "' |
139
|
|
|
WHERE auth_option = '" . $old_name . "'"; |
140
|
|
|
$this->db->sql_query($sql); |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|