Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
release_3_0_12_rc1
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 5
56
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_data
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 disable_bots_from_receiving_pms
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
12
 update_module_auth
0.00% covered (danger)
0.00%
0 / 3
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\v30x;
15
16/** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 **/
17
18class release_3_0_12_rc1 extends \phpbb\db\migration\migration
19{
20    public function effectively_installed()
21    {
22        return phpbb_version_compare($this->config['version'], '3.0.12-RC1', '>=');
23    }
24
25    public static function depends_on()
26    {
27        return array('\phpbb\db\migration\data\v30x\release_3_0_11');
28    }
29
30    public function update_data()
31    {
32        return array(
33            array('custom', array(array(&$this, 'update_module_auth'))),
34            array('custom', array(array(&$this, 'disable_bots_from_receiving_pms'))),
35
36            array('config.update', array('version', '3.0.12-RC1')),
37        );
38    }
39
40    public function disable_bots_from_receiving_pms()
41    {
42        // Disable receiving pms for bots
43        $sql = 'SELECT user_id
44            FROM ' . BOTS_TABLE;
45        $result = $this->db->sql_query($sql);
46
47        $bot_user_ids = array();
48        while ($row = $this->db->sql_fetchrow($result))
49        {
50            $bot_user_ids[] = (int) $row['user_id'];
51        }
52        $this->db->sql_freeresult($result);
53
54        if (!empty($bot_user_ids))
55        {
56            $sql = 'UPDATE ' . USERS_TABLE . '
57                SET user_allow_pm = 0
58                WHERE ' . $this->db->sql_in_set('user_id', $bot_user_ids);
59            $this->sql_query($sql);
60        }
61    }
62
63    public function update_module_auth()
64    {
65        $sql = 'UPDATE ' . MODULES_TABLE . '
66            SET module_auth = \'acl_u_sig\'
67            WHERE module_class = \'ucp\'
68                AND module_basename = \'profile\'
69                AND module_mode = \'signature\'';
70        $this->sql_query($sql);
71    }
72}