|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* phpBB Directory extension for the phpBB Forum Software package. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright (c) 2014 ErnadoO <http://www.phpbb-services.com> |
|
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace ernadoo\phpbbdirectory\migrations\converter; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Convert module |
|
15
|
|
|
*/ |
|
16
|
|
|
class convert_module extends \phpbb\db\migration\migration |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Skip this migration if an ACP_DIRECTORY module does not exist |
|
20
|
|
|
* |
|
21
|
|
|
* @return bool True if table does not exist |
|
22
|
|
|
* @access public |
|
23
|
|
|
*/ |
|
24
|
|
|
public function effectively_installed() |
|
25
|
|
|
{ |
|
26
|
|
|
$sql = 'SELECT module_id |
|
27
|
|
|
FROM ' . $this->table_prefix . "modules |
|
28
|
|
|
WHERE module_class = 'acp' |
|
29
|
|
|
AND module_basename = 'acp_directory' |
|
30
|
|
|
AND module_mode = 'main'"; |
|
31
|
|
|
$result = $this->db->sql_query($sql); |
|
32
|
|
|
$module_id = (int) $this->db->sql_fetchfield('module_id'); |
|
33
|
|
|
$this->db->sql_freeresult($result); |
|
34
|
|
|
|
|
35
|
|
|
// Skip migration if ACP_DIRECTORY module does not exist |
|
36
|
|
|
return !$module_id; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Add or update data in the database |
|
41
|
|
|
* |
|
42
|
|
|
* @return array Array of table data |
|
43
|
|
|
* @access public |
|
44
|
|
|
*/ |
|
45
|
|
|
public function update_data() |
|
46
|
|
|
{ |
|
47
|
|
|
return array( |
|
48
|
|
|
array('custom', array(array(&$this, 'rename_old_module'))), |
|
49
|
|
|
); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function rename_old_module() |
|
53
|
|
|
{ |
|
54
|
|
|
$module_data = array( |
|
55
|
|
|
'module_basename' => '\ernadoo\phpbbdirectory\acp\phpbbdirectory_module', |
|
56
|
|
|
'module_auth' => 'ext_ernadoo/phpbbdirectory' |
|
57
|
|
|
); |
|
58
|
|
|
|
|
59
|
|
|
$sql = 'UPDATE ' . $this->table_prefix . 'modules |
|
60
|
|
|
SET ' . $this->db->sql_build_array('UPDATE', $module_data) . " |
|
61
|
|
|
WHERE module_basename = 'acp_directory' |
|
62
|
|
|
AND module_mode IN ('main', 'settings', 'cat', 'val')"; |
|
63
|
|
|
$this->db->sql_query($sql); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|