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

c1_remove_modules   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 0
dl 0
loc 40
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\converter;
11
12
class c1_remove_modules extends \phpbb\db\migration\migration
13
{
14
	/**
15
	 * This does not work when uninstalling for some reason
16
	 *
17
	 * Skip this migration if the module_dir column does not exist
18
	 *
19
	 * @return bool True to skip this migration, false to run it
20
	 * @access public
21
	 *
22
	public function effectively_installed()
23
	{
24
		return !$this->db_tools->sql_column_exists($this->table_prefix . 'modules', 'module_dir');
25
	}
26
	*/
27
28
	public function update_data()
29
	{
30
		if (!$this->db_tools->sql_column_exists($this->table_prefix . 'modules', 'module_dir'))
31
		{
32
			return array();
33
		}
34
35
		$sql = 'SELECT *
36
			FROM ' . $this->table_prefix . "modules
37
			WHERE module_dir <> ''
38
				OR " . $this->db->sql_in_set('module_langname', array('CMS', 'GCP', 'GRP', 'PRO')) . '
39
			ORDER BY right_id ASC';
40
		$result = $this->db->sql_query($sql);
41
42
		$migrations_ary = array();
43
		while ($row = $this->db->sql_fetchrow($result))
44
		{
45
			$migrations_ary[] = array('module.remove', array($row['module_class'], $row['parent_id'], $row['module_id']));
46
		}
47
		$this->db->sql_freeresult($result);
48
49
		return $migrations_ary;
50
	}
51
}
52