Completed
Push — develop ( 6f1d60...1f2a5d )
by Daniel
11:12
created

c1_remove_modules::update_data()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
rs 9.0856
cc 3
eloc 12
nc 3
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\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