Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 55
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
add_mention_settings
0.00% covered (danger)
0.00%
0 / 55
0.00% covered (danger)
0.00%
0 / 3
30
0.00% covered (danger)
0.00%
0 / 1
 depends_on
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 effectively_installed
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
 update_data
0.00% covered (danger)
0.00%
0 / 51
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\v400;
15
16class add_mention_settings extends \phpbb\db\migration\migration
17{
18    public static function depends_on()
19    {
20        return ['\phpbb\db\migration\data\v400\dev'];
21    }
22
23    public function effectively_installed(): bool
24    {
25        return $this->config->offsetExists('allow_mentions')
26            && $this->config->offsetExists('mention_batch_size')
27            && $this->config->offsetExists('mention_names_limit');
28    }
29
30    public function update_data()
31    {
32        return [
33            ['config.add', ['allow_mentions', true]],
34            ['config.add', ['mention_batch_size', 50]],
35            ['config.add', ['mention_names_limit', 10]],
36
37            // Set up user permissions
38            ['permission.add', ['u_mention', true]],
39            ['if', [
40                ['permission.role_exists', ['ROLE_USER_FULL']],
41                ['permission.permission_set', ['ROLE_USER_FULL', 'u_mention']],
42            ]],
43            ['if', [
44                ['permission.role_exists', ['ROLE_USER_STANDARD']],
45                ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_mention']],
46            ]],
47            ['if', [
48                ['permission.role_exists', ['ROLE_USER_LIMITED']],
49                ['permission.permission_set', ['ROLE_USER_LIMITED', 'u_mention']],
50            ]],
51            ['if', [
52                ['permission.role_exists', ['ROLE_USER_NOPM']],
53                ['permission.permission_set', ['ROLE_USER_NOPM', 'u_mention']],
54            ]],
55            ['if', [
56                ['permission.role_exists', ['ROLE_USER_NOAVATAR']],
57                ['permission.permission_set', ['ROLE_USER_NOAVATAR', 'u_mention']],
58            ]],
59
60            // Set up forum permissions
61            ['permission.add', ['f_mention', false]],
62            ['if', [
63                ['permission.role_exists', ['ROLE_FORUM_FULL']],
64                ['permission.permission_set', ['ROLE_FORUM_FULL', 'f_mention']],
65            ]],
66            ['if', [
67                ['permission.role_exists', ['ROLE_FORUM_STANDARD']],
68                ['permission.permission_set', ['ROLE_FORUM_STANDARD', 'f_mention']],
69            ]],
70            ['if', [
71                ['permission.role_exists', ['ROLE_FORUM_LIMITED']],
72                ['permission.permission_set', ['ROLE_FORUM_LIMITED', 'f_mention']],
73            ]],
74            ['if', [
75                ['permission.role_exists', ['ROLE_FORUM_ONQUEUE']],
76                ['permission.permission_set', ['ROLE_FORUM_ONQUEUE', 'f_mention']],
77            ]],
78            ['if', [
79                ['permission.role_exists', ['ROLE_FORUM_POLLS']],
80                ['permission.permission_set', ['ROLE_FORUM_POLLS', 'f_mention']],
81            ]],
82            ['if', [
83                ['permission.role_exists', ['ROLE_FORUM_LIMITED_POLLS']],
84                ['permission.permission_set', ['ROLE_FORUM_LIMITED_POLLS', 'f_mention']],
85            ]],
86        ];
87    }
88}