aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/db/migration/data/v30x/release_3_0_1_rc1.php
blob: d1ae0b9cbcd5f7de4093c08c43ae608fb8ed540d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/

namespace phpbb\db\migration\data\v30x;

class release_3_0_1_rc1 extends \phpbb\db\migration\migration
{
	public function effectively_installed()
	{
		return phpbb_version_compare($this->config['version'], '3.0.1-RC1', '>=');
	}

	static public function depends_on()
	{
		return array('\phpbb\db\migration\data\v30x\release_3_0_0');
	}

	public function update_schema()
	{
		return array(
			'add_columns' => array(
				$this->table_prefix . 'forums' => array(
					'display_subforum_list' => array('BOOL', 1),
				),
				$this->table_prefix . 'sessions' => array(
					'session_forum_id' => array('UINT', 0),
				),
			),
			'drop_keys' => array(
				$this->table_prefix . 'groups' => array(
					'group_legend',
				),
			),
			'add_index' => array(
				$this->table_prefix . 'sessions' => array(
					'session_forum_id' => array('session_forum_id'),
				),
				$this->table_prefix . 'groups' => array(
					'group_legend_name' => array('group_legend', 'group_name'),
				),
			),
		);
	}

	public function revert_schema()
	{
		return array(
			'drop_columns' => array(
				$this->table_prefix . 'forums' => array(
					'display_subforum_list',
				),
				$this->table_prefix . 'sessions' => array(
					'session_forum_id',
				),
			),
			'add_index' => array(
				$this->table_prefix . 'groups' => array(
					'group_legend' => array('group_legend'),
				),
			),
			'drop_keys' => array(
				$this->table_prefix . 'sessions' => array(
					'session_forum_id',
				),
				$this->table_prefix . 'groups' => array(
					'group_legend_name',
				),
			),
		);
	}

	public function update_data()
	{
		return array(
			array('custom', array(array(&$this, 'fix_unset_last_view_time'))),
			array('custom', array(array(&$this, 'reset_smiley_size'))),

			array('config.update', array('version', '3.0.1-RC1')),
		);
	}

	public function fix_unset_last_view_time()
	{
		$sql = 'UPDATE ' . $this->table_prefix . "topics
			SET topic_last_view_time = topic_last_post_time
			WHERE topic_last_view_time = 0";
		$this->sql_query($sql);
	}

	public function reset_smiley_size()
	{
		// Update smiley sizes
		$smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif');

		foreach ($smileys as $smiley)
		{
			if (file_exists($this->phpbb_root_path . 'images/smilies/' . $smiley))
			{
				list($width, $height) = getimagesize($this->phpbb_root_path . 'images/smilies/' . $smiley);

				$sql = 'UPDATE ' . SMILIES_TABLE . '
					SET smiley_width = ' . $width . ', smiley_height = ' . $height . "
					WHERE smiley_url = '" . $this->db->sql_escape($smiley) . "'";

				$this->sql_query($sql);
			}
		}
	}
}