initial_module::update_schema()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 46
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 46
rs 8.9411
cc 1
eloc 34
nc 1
nop 0
1
<?php
2
/**
3
*
4
* @package phpBB Extension - tas2580 Mobile Notifier
5
* @copyright (c) 2015 tas2580 (https://tas2580.net)
6
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
*
8
*/
9
10
namespace tas2580\paypal\migrations;
11
12
class initial_module extends \phpbb\db\migration\migration
13
{
14
	public function update_data()
15
	{
16
		return array(
17
			// Add ACP module
18
			array('module.add', array(
19
				'acp',
20
				'ACP_CAT_DOT_MODS',
21
				'ACP_PAYPAL_TITLE'
22
			)),
23
			array('module.add', array('acp', 'ACP_PAYPAL_TITLE', array(
24
					'module_basename'	=> '\tas2580\paypal\acp\paypal_module',
25
					'modes'				=> array('settings'),
26
				),
27
			)),
28
			// Add ACP module
29
			array('module.add', array('acp', 'ACP_PAYPAL_TITLE', array(
30
					'module_basename'	=> '\tas2580\paypal\acp\paypal_module',
31
					'modes'				=> array('items'),
32
				),
33
			)),
34
			array('module.add', array('acp', 'ACP_PAYPAL_TITLE', array(
35
					'module_basename'	=> '\tas2580\paypal\acp\paypal_module',
36
					'modes'				=> array('donations'),
37
				),
38
			)),
39
			array('custom', array(array($this, 'add_config_values'))),
40
		);
41
	}
42
	public function update_schema()
43
	{
44
		return array(
45
			'add_tables'	=> array(
46
				$this->table_prefix . 'paypal_amount'	=> array(
47
					'COLUMNS'	=> array(
48
						'amount_id'			=> array('UINT', null, 'auto_increment'),
49
						'amount_value'		=> array('UINT', '0'),
50
					),
51
					'PRIMARY_KEY'	=> 'amount_id',
52
				),
53
				$this->table_prefix . 'paypal_config'	=> array(
54
					'COLUMNS'	=> array(
55
						'paypal_email'			=> array('VCHAR:255', ''),
56
						'paypal_title'			=> array('VCHAR:255', ''),
57
						'paypal_currency'		=> array('VCHAR:255', ''),
58
						'paypal_text'			=> array('MTEXT_UNI', ''),
59
						'bbcode_uid'			=> array('VCHAR:10', ''),
60
						'bbcode_bitfield'		=> array('VCHAR:32', ''),
61
						'paypal_sandbox'		=> array('BOOL', 0),
62
					),
63
				),
64
				$this->table_prefix . 'paypal_donations'	=> array(
65
					'COLUMNS'	=> array(
66
						'donation_id'			=> array('UINT', null, 'auto_increment'),
67
						'user_id'				=> array('UINT', 0),
68
						'item_id'				=> array('UINT', 0),
69
						'item_name'				=> array('VCHAR:255', ''),
70
						'donation_time'			=> array('VCHAR:14', ''),
71
						'donation_amount'		=> array('VCHAR:255', ''),
72
					),
73
					'PRIMARY_KEY'	=> 'donation_id',
74
				),
75
				$this->table_prefix . 'paypal_items'	=> array(
76
					'COLUMNS'	=> array(
77
						'item_id'				=> array('UINT', null, 'auto_increment'),
78
						'item_name'				=> array('VCHAR:255', ''),
79
						'item_text'				=> array('MTEXT_UNI', ''),
80
						'bbcode_uid'			=> array('VCHAR:10', ''),
81
						'bbcode_bitfield'		=> array('VCHAR:32', ''),
82
					),
83
					'PRIMARY_KEY'	=> 'item_id',
84
				),
85
			),
86
		);
87
	}
88
	public function revert_schema()
89
	{
90
		return array(
91
			'drop_tables'	=> array(
92
				$this->table_prefix . 'paypal_config',
93
				$this->table_prefix . 'paypal_amount',
94
				$this->table_prefix . 'paypal_items',
95
			),
96
		);
97
	}
98
99
	public function add_config_values()
100
	{
101
102
		$sql_data = array(
103
			'paypal_email'				=> '',
104
			'paypal_title'				=> '',
105
			'paypal_currency'			=> '',
106
			'paypal_text'				=> '',
107
			'bbcode_uid'				=> '',
108
			'bbcode_bitfield'			=> '',
109
			'paypal_sandbox'			=> 0,
110
		);
111
		$sql = 'INSERT INTO ' . $this->table_prefix . 'paypal_config
112
			' . $this->db->sql_build_array('INSERT', $sql_data);
113
		$this->db->sql_query($sql);
114
115
	}
116
117
}
118