Passed
Push — master ( ec4793...16b990 )
by Jeroen
16:54
created

deprecated-3.0.php ➔ elgg_get_entities_from_attributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 11
ccs 0
cts 6
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Removes a config setting.
5
 *
6
 * @param string $name The name of the field.
7
 *
8
 * @return bool Success or failure
9
 *
10
 * @see get_config()
11
 * @see set_config()
12
 *
13
 * @deprecated Use elgg_remove_config()
14
 */
15
function unset_config($name) {
16
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_remove_config().', '3.0');
17
	return elgg_remove_config($name);
18
}
19
20
/**
21
 * Add or update a config setting.
22
 *
23
 * Plugin authors should use elgg_set_config().
24
 *
25
 * If the config name already exists, it will be updated to the new value.
26
 *
27
 * @param string $name      The name of the configuration value
28
 * @param mixed  $value     Its value
29
 *
30
 * @return bool
31
 * @see unset_config()
32
 * @see get_config()
33
 * @access private
34
 *
35
 * @deprecated Use elgg_save_config()
36
 */
37
function set_config($name, $value) {
38
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_save_config().', '3.0');
39
	return elgg_save_config($name, $value);
40
}
41
42
/**
43
 * Gets a configuration value
44
 *
45
 * Plugin authors should use elgg_get_config().
46
 *
47
 * @param string $name      The name of the config value
48
 *
49
 * @return mixed|null
50
 * @see set_config()
51
 * @see unset_config()
52
 * @access private
53
 *
54
 * @deprecated Use elgg_get_config()
55
 */
56
function get_config($name) {
57
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_config().', '3.0');
58
	return elgg_get_config($name);
59
}
60
61
/**
62
 * Add an admin area section or child section.
63
 * This is a wrapper for elgg_register_menu_item().
64
 *
65
 * Used in conjuction with http://elgg.org/admin/section_id/child_section style
66
 * page handler. See the documentation at the top of this file for more details
67
 * on that.
68
 *
69
 * The text of the menu item is obtained from elgg_echo(admin:$parent_id:$menu_id)
70
 *
71
 * This function handles registering the parent if it has not been registered.
72
 *
73
 * @param string $section   The menu section to add to
74
 * @param string $menu_id   The unique ID of section
75
 * @param string $parent_id If a child section, the parent section id
76
 * @param int    $priority  The menu item priority
77
 *
78
 * @return bool
79
 * @since 1.8.0
80
 *
81
 * @deprecated Use elgg_remove_config()
82
 */
83
function elgg_register_admin_menu_item($section, $menu_id, $parent_id = null, $priority = 100) {
84
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_register_menu_item().', '3.0');
85
	// make sure parent is registered
86
	if ($parent_id && !elgg_is_menu_item_registered('page', $parent_id)) {
1 ignored issue
show
Bug Best Practice introduced by
The expression $parent_id of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
87
		elgg_register_admin_menu_item($section, $parent_id);
0 ignored issues
show
Deprecated Code introduced by
The function elgg_register_admin_menu_item() has been deprecated with message: Use elgg_remove_config()

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
88
	}
89
90
	// in the admin section parents never have links
91
	if ($parent_id) {
1 ignored issue
show
Bug Best Practice introduced by
The expression $parent_id of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
92
		$href = "admin/$parent_id/$menu_id";
93
	} else {
94
		$href = "admin/$menu_id";
95
	}
96
97
	$name = $menu_id;
98
	if ($parent_id) {
1 ignored issue
show
Bug Best Practice introduced by
The expression $parent_id of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
99
		$name = "$parent_id:$name";
100
	}
101
102
	return elgg_register_menu_item('page', [
103
		'name' => $name,
104
		'href' => $href,
105
		'text' => elgg_echo("admin:$name"),
106
		'context' => 'admin',
107
		'parent_name' => $parent_id,
108
		'priority' => $priority,
109
		'section' => $section
110
	]);
111
}
112
113
/**
114
 * Mark entities with a particular type and subtype as having access permissions
115
 * that can be changed independently from their parent entity
116
 *
117
 * @param string $type    The type - object, user, etc
118
 * @param string $subtype The subtype; all subtypes by default
119
 *
120
 * @return void
121
 *
122
 * @deprecated
123
 */
124
function register_metadata_as_independent($type, $subtype = '*') {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $subtype is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
125
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Metadata no longer is access bound.', '3.0');
126
}
127
128
/**
129
 * Determines whether entities of a given type and subtype should not change
130
 * their metadata in line with their parent entity
131
 *
132
 * @param string $type    The type - object, user, etc
133
 * @param string $subtype The entity subtype
134
 *
135
 * @return bool
136
 *
137
 * @deprecated
138
 */
139
function is_metadata_independent($type, $subtype) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $subtype is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
140
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Metadata no longer is access bound.', '3.0');
141
	
142
	return false;
143
}
144
145
/**
146
 * Gets entities based upon attributes in secondary tables.
147
 * Also accepts all options available to elgg_get_entities(),
148
 * elgg_get_entities_from_metadata(), and elgg_get_entities_from_relationship().
149
 *
150
 * @warning requires that the entity type be specified and there can only be one
151
 * type.
152
 *
153
 * @see elgg_get_entities
154
 * @see elgg_get_entities_from_metadata
155
 * @see elgg_get_entities_from_relationship
156
 *
157
 * @param array $options Array in format:
158
 *
159
 * 	attribute_name_value_pairs => ARR (
160
 *                                   'name' => 'name',
161
 *                                   'value' => 'value',
162
 *                                   'operand' => '=', (optional)
163
 *                                   'case_sensitive' => false (optional)
164
 *                                  )
165
 * 	                             If multiple values are sent via
166
 *                               an array ('value' => array('value1', 'value2')
167
 *                               the pair's operand will be forced to "IN".
168
 *
169
 * 	attribute_name_value_pairs_operator => null|STR The operator to use for combining
170
 *                                        (name = value) OPERATOR (name = value); default is AND
171
 *
172
 * @return \ElggEntity[]|mixed If count, int. If not count, array. false on errors.
173
 * @since 1.9.0
174
 * @throws InvalidArgumentException
175
 * @deprecated Use elgg_get_entities_from_metadata
176
 */
177
function elgg_get_entities_from_attributes(array $options = []) {
178
    elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_entities_from_metadata.', '3.0');
179
    
180
    $options['metadata_name_value_pairs'] = elgg_extract('attribute_name_value_pairs', $options, []);
181
    $options['metadata_name_value_pairs_operator'] = elgg_extract('attribute_name_value_pairs_operator', $options, []);
182
    
183
    unset($options['attribute_name_value_pairs']);
184
    unset($options['attribute_name_value_pairs_operator']);
185
    
186
    return elgg_get_entities_from_relationship($options);
187
}
188