Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 68
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
notifications
0.00% covered (danger)
0.00%
0 / 68
0.00% covered (danger)
0.00%
0 / 5
30
0.00% covered (danger)
0.00%
0 / 1
 effectively_installed
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 depends_on
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 update_schema
0.00% covered (danger)
0.00%
0 / 37
0.00% covered (danger)
0.00%
0 / 1
2
 revert_schema
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 update_data
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14namespace phpbb\db\migration\data\v310;
15
16class notifications extends \phpbb\db\migration\migration
17{
18    public function effectively_installed()
19    {
20        return $this->db_tools->sql_table_exists($this->table_prefix . 'notifications');
21    }
22
23    public static function depends_on()
24    {
25        return array('\phpbb\db\migration\data\v310\dev');
26    }
27
28    public function update_schema()
29    {
30        return array(
31            'add_tables'        => array(
32                $this->table_prefix . 'notification_types'    => array(
33                    'COLUMNS'            => array(
34                        'notification_type'            => array('VCHAR:255', ''),
35                        'notification_type_enabled'    => array('BOOL', 1),
36                    ),
37                    'PRIMARY_KEY'        => array('notification_type', 'notification_type_enabled'),
38                ),
39                $this->table_prefix . 'notifications'        => array(
40                    'COLUMNS'            => array(
41                        'notification_id'                  => array('UINT', null, 'auto_increment'),
42                        'item_type'                           => array('VCHAR:255', ''),
43                        'item_id'                          => array('UINT', 0),
44                        'item_parent_id'                   => array('UINT', 0),
45                        'user_id'                        => array('UINT', 0),
46                        'notification_read'                => array('BOOL', 0),
47                        'notification_time'                => array('TIMESTAMP', 1),
48                        'notification_data'                   => array('TEXT_UNI', ''),
49                    ),
50                    'PRIMARY_KEY'        => 'notification_id',
51                    'KEYS'                => array(
52                        'item_ident'        => array('INDEX', array('item_type', 'item_id')),
53                        'user'                => array('INDEX', array('user_id', 'notification_read')),
54                    ),
55                ),
56                $this->table_prefix . 'user_notifications'    => array(
57                    'COLUMNS'            => array(
58                        'item_type'            => array('VCHAR:255', ''),
59                        'item_id'            => array('UINT', 0),
60                        'user_id'            => array('UINT', 0),
61                        'method'            => array('VCHAR:255', ''),
62                        'notify'            => array('BOOL', 1),
63                    ),
64                ),
65            ),
66        );
67    }
68
69    public function revert_schema()
70    {
71        return array(
72            'drop_tables'    => array(
73                $this->table_prefix . 'notification_types',
74                $this->table_prefix . 'notifications',
75                $this->table_prefix . 'user_notifications',
76            ),
77        );
78    }
79
80    public function update_data()
81    {
82        return array(
83            array('module.add', array(
84                'ucp',
85                'UCP_MAIN',
86                array(
87                    'module_basename'    => 'ucp_notifications',
88                    'module_langname'    => 'UCP_NOTIFICATION_LIST',
89                    'module_mode'        => 'notification_list',
90                    'module_auth'        => 'cfg_allow_board_notifications',
91                ),
92            )),
93            array('module.add', array(
94                'ucp',
95                'UCP_PREFS',
96                array(
97                    'module_basename'    => 'ucp_notifications',
98                    'module_langname'    => 'UCP_NOTIFICATION_OPTIONS',
99                    'module_mode'        => 'notification_options',
100                ),
101            )),
102            array('config.add', array('load_notifications', 1)),
103        );
104    }
105}