|
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_notifications extends \phpbb\db\migration\migration |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Skip this migration if phpbb_directory_notifications table does not exist |
|
20
|
|
|
* |
|
21
|
|
|
* @return bool True if table does not exist |
|
22
|
|
|
* @access public |
|
23
|
|
|
*/ |
|
24
|
|
|
public function effectively_installed() |
|
25
|
|
|
{ |
|
26
|
|
|
return !$this->db_tools->sql_table_exists($this->table_prefix . 'directory_notifications'); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
static public function depends_on() |
|
30
|
|
|
{ |
|
31
|
|
|
return array( |
|
32
|
|
|
'\ernadoo\phpbbdirectory\migrations\v10x\v1_0_0', |
|
33
|
|
|
); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Add or update data in the database |
|
38
|
|
|
* |
|
39
|
|
|
* @return array Array of table data |
|
40
|
|
|
* @access public |
|
41
|
|
|
*/ |
|
42
|
|
|
public function update_data() |
|
43
|
|
|
{ |
|
44
|
|
|
return array( |
|
45
|
|
|
array('custom', array(array(&$this, 'copy_from_notifications'))), |
|
46
|
|
|
); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Copy category track from 3.0.x table |
|
51
|
|
|
* |
|
52
|
|
|
* @return null |
|
53
|
|
|
*/ |
|
54
|
|
|
public function copy_from_notifications() |
|
55
|
|
|
{ |
|
56
|
|
|
$sql = 'SELECT n_user_id, n_cat_id |
|
57
|
|
|
FROM ' . $this->table_prefix . 'directory_notifications'; |
|
58
|
|
|
$result = $this->db->sql_query($sql); |
|
59
|
|
|
|
|
60
|
|
|
while ($row = $this->db->sql_fetchrow($result)) |
|
61
|
|
|
{ |
|
62
|
|
|
$data = array( |
|
63
|
|
|
'cat_id' => (int) $row['n_cat_id'], |
|
64
|
|
|
'user_id' => (int) $row['n_user_id'], |
|
65
|
|
|
'notify_status' => 1, |
|
66
|
|
|
); |
|
67
|
|
|
|
|
68
|
|
|
$sql = 'INSERT INTO ' . $this->table_prefix . 'directory_watch ' . $this->db->sql_build_array('INSERT', $data); |
|
69
|
|
|
$this->db->sql_query($sql); |
|
70
|
|
|
} |
|
71
|
|
|
$this->db->sql_freeresult($result); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|