Completed
Push — master ( 9866a1...02e5e5 )
by Daniel
08:18
created

m12_add_hidden_forum_column::update_data()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
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
	/**
19
	 * Skip this migration if the hidden_forum column already exists
20
	 *
21
	 * @return bool True to skip this migration, false to run it
22
	 * @access public
23
	 */
24
	public function effectively_installed()
25
	{
26
		return $this->db_tools->sql_column_exists($this->table_prefix . 'forums', 'hidden_forum');
27
	}
28
29
	/**
30
	 * Update forums table schema
31
	 *
32
	 * @return array Array of table schema
33
	 * @access public
34
	 */
35
	public function update_schema()
36
	{
37
		return array(
38
			'add_columns'	=> array(
39
				$this->table_prefix . 'forums'	=> array(
40
					'hidden_forum'		=> array('BOOL', 0),
41
				),
42
			),
43
		);
44
	}
45
46
	/**
47
	 * @inheritdoc
48
	 */
49
	public function update_data()
50
	{
51
		return array(
52
			array('custom', array(array($this, 'set_hidden_forums'))),
53
		);
54
	}
55
56
	public function update_blocks_settings()
57
	{
58
		$data = array(
59
			'hidden_forum' => 1,
60
		);
61
		$sql = 'UPDATE ' . FORUMS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $data) . ' WHERE forum_id = ' . (int) $this->config['sitemaker_parent_forum_id'];
62
		$this->db->sql_query($sql);
63
	}
64
}
65