m4_permissions::update_data()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 23
c 2
b 0
f 1
nc 1
nop 0
dl 0
loc 34
rs 9.552
1
<?php
2
/**
3
 *
4
 * phpBB Media Embed PlugIn extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2018 phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\mediaembed\migrations;
12
13
/**
14
 * Migration 4: Add permissions
15
 */
16
class m4_permissions extends \phpbb\db\migration\migration
0 ignored issues
show
Bug introduced by
The type phpbb\db\migration\migration was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
{
18
	/**
19
	 * {@inheritdoc
20
	 */
21
	public function effectively_installed()
22
	{
23
		$sql = 'SELECT * FROM ' . $this->table_prefix . "acl_options
24
			WHERE auth_option = 'f_mediaembed'";
25
		$result = $this->db->sql_query_limit($sql, 1);
26
		$row = $this->db->sql_fetchrow($result);
27
		$this->db->sql_freeresult($result);
28
29
		return $row !== false;
30
	}
31
32
	/**
33
	 * {@inheritdoc
34
	 */
35
	public static function depends_on()
36
	{
37
		return [
38
			'\phpbb\mediaembed\migrations\m1_install_data',
39
			'\phpbb\mediaembed\migrations\m3_plain_urls_config',
40
		];
41
	}
42
43
	/**
44
	 * {@inheritdoc
45
	 */
46
	public function update_data()
47
	{
48
		return [
49
			// Add forum permission
50
			['permission.add', ['f_mediaembed', false]],
51
			['if', [
52
				['permission.role_exists', ['ROLE_FORUM_FULL']],
53
				['permission.permission_set', ['ROLE_FORUM_FULL', 'f_mediaembed']],
54
			]],
55
			['if', [
56
				['permission.role_exists', ['ROLE_FORUM_POLLS']],
57
				['permission.permission_set', ['ROLE_FORUM_POLLS', 'f_mediaembed']],
58
			]],
59
			['if', [
60
				['permission.role_exists', ['ROLE_FORUM_ONQUEUE']],
61
				['permission.permission_set', ['ROLE_FORUM_ONQUEUE', 'f_mediaembed']],
62
			]],
63
			['if', [
64
				['permission.role_exists', ['ROLE_FORUM_STANDARD']],
65
				['permission.permission_set', ['ROLE_FORUM_STANDARD', 'f_mediaembed']],
66
			]],
67
68
			// Add PM permission
69
			['permission.add', ['u_pm_mediaembed']],
70
			['if', [
71
				['permission.role_exists', ['ROLE_USER_FULL']],
72
				['permission.permission_set', ['ROLE_USER_FULL', 'u_pm_mediaembed']],
73
			]],
74
			['if', [
75
				['permission.role_exists', ['ROLE_USER_STANDARD']],
76
				['permission.permission_set', ['ROLE_USER_STANDARD', 'u_pm_mediaembed']],
77
			]],
78
			['permission.permission_set', ['REGISTERED', 'u_pm_mediaembed', 'group']],
79
			['permission.permission_set', ['REGISTERED_COPPA', 'u_pm_mediaembed', 'group']],
80
		];
81
	}
82
}
83