Completed
Push — master ( 02e5e5...868d49 )
by Daniel
11:13
created

m12_add_hidden_forum_column   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 4
c 1
b 1
f 0
lcom 0
cbo 0
dl 0
loc 50
rs 10
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2013 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\sitemaker\migrations\v20x;
11
12
/**
13
 * Initial schema changes needed for Extension installation
14
 */
15
class m12_add_hidden_forum_column extends \phpbb\db\migration\migration
16
{
17
	/**
18
	 * @inheritdoc
19
	 */
20
	public static function depends_on()
21
	{
22
		return array(
23
			'\blitze\sitemaker\migrations\v20x\m1_initial_schema',
24
		);
25
	}
26
27
	/**
28
	 * Skip this migration if the hidden_forum column already exists
29
	 *
30
	 * @return bool True to skip this migration, false to run it
31
	 * @access public
32
	 */
33
	public function effectively_installed()
34
	{
35
		return $this->db_tools->sql_column_exists($this->table_prefix . 'forums', 'hidden_forum');
36
	}
37
38
	/**
39
	 * Update forums table schema
40
	 *
41
	 * @return array Array of table schema
42
	 * @access public
43
	 */
44
	public function update_schema()
45
	{
46
		return array(
47
			'add_columns'	=> array(
48
				$this->table_prefix . 'forums'	=> array(
49
					'hidden_forum'		=> array('BOOL', 0),
50
				),
51
			),
52
		);
53
	}
54
55
	/**
56
	 * @inheritdoc
57
	 */
58
	public function update_data()
59
	{
60
		return array(
61
			array('custom', array(array($this, 'set_hidden_forums'))),
62
		);
63
	}
64
65
	public function update_blocks_settings()
66
	{
67
		$data = array(
68
			'hidden_forum' => 1,
69
		);
70
		$sql = 'UPDATE ' . FORUMS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $data) . ' WHERE forum_id = ' . (int) $this->config['sitemaker_parent_forum_id'];
71
		$this->db->sql_query($sql);
72
	}
73
}
74