Completed
Push — develop-3.2 ( ec81a5...eb42f9 )
by Matt
32:34
created

v320_disable_bbcodes::revert_data()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
*
4
* Advanced BBCode Box
5
*
6
* @copyright (c) 2018 Matt Friedman
7
* @license GNU General Public License, version 2 (GPL-2.0)
8
*
9
*/
10
11
namespace vse\abbc3\migrations;
12
13
use phpbb\db\migration\container_aware_migration;
14
15
class v320_disable_bbcodes extends container_aware_migration
16
{
17
	/**
18
	 * {@inheritdoc}
19
	 */
20
	public static function depends_on()
21
	{
22
		return array(
23
			'\vse\abbc3\migrations\v310_m4_install_data',
24
			'\vse\abbc3\migrations\v310_m5_update_bbcodes',
25
			'\vse\abbc3\migrations\v310_m6_update_bbcodes',
26
			'\vse\abbc3\migrations\v310_m7_update_bbcodes',
27
			'\vse\abbc3\migrations\v320_m8_update_bbcodes',
28
		);
29
	}
30
31
	/**
32
	 * {@inheritdoc}
33
	 */
34
	public function revert_data()
35
	{
36
		return array(
37
			array('custom', array(array($this, 'disable_bbcodes'))),
38
		);
39
	}
40
	/**
41
	 * Set ABBC3 BBCodes Display on Post to 0 so they will no longer
42
	 * appear in posting buttons when extension is purged. Users can manage
43
	 * themselves and decide if they want to keep or delete any of the BBCodes.
44
	 */
45
	public function disable_bbcodes()
46
	{
47
		$sql = 'UPDATE ' . BBCODES_TABLE . '
48
			SET display_on_posting = 0
49
			WHERE ' . $this->db->sql_in_set('bbcode_tag', [
50
				'font=', 'highlight=', 'align=', 'float=', 'pre', 's', 'sup', 'sub',
51
				'glow=', 'shadow=', 'dropshadow=', 'blur=', 'fade', 'dir=', 'marq=',
52
				'spoil', 'hidden', 'offtopic', 'mod=', 'nfo', 'soundcloud', 'BBvideo=',
53
			]);
54
		$this->db->sql_query($sql);
55
	}
56
}
57