Completed
Push — master ( e72c23...de047a )
by Jeroen
25:41
created

deprecated-3.0.php ➔ elgg_set_user_validation_status()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 3
dl 0
loc 11
ccs 0
cts 6
cp 0
crap 6
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
189
/**
190
 * Ban a user
191
 *
192
 * @param int    $user_guid The user guid
193
 * @param string $reason    A reason
194
 *
195
 * @return bool
196
 *
197
 * @deprecated Use \ElggUser->ban()
198
 */
199 View Code Duplication
function ban_user($user_guid, $reason = "") {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
200
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::ban()', '3.0');
201
    
202
	$user = get_user($user_guid);
203
	if (!$user) {
204
		return false;
205
	}
206
	
207
	return $user->ban($reason);
208
}
209
210
/**
211
 * Unban a user.
212
 *
213
 * @param int $user_guid Unban a user.
214
 *
215
 * @return bool
216
 *
217
 * @deprecated Use \ElggUser->unban()
218
 */
219 View Code Duplication
function unban_user($user_guid) {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
220
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::unban()', '3.0');
221
    
222
	$user = get_user($user_guid);
223
	if (!$user) {
224
		return false;
225
	}
226
	
227
	return $user->unban();
228
}
229
230
/**
231
 * Makes user $guid an admin.
232
 *
233
 * @param int $user_guid User guid
234
 *
235
 * @return bool
236
 *
237
 * @deprecated Use \ElggUser->makeAdmin()
238
 */
239 View Code Duplication
function make_user_admin($user_guid) {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
240
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::makeAdmin()', '3.0');
241
    
242
	$user = get_user($user_guid);
243
	if (!$user) {
244
		return false;
245
	}
246
	
247
	return $user->makeAdmin();
248
}
249
250
/**
251
 * Removes user $guid's admin flag.
252
 *
253
 * @param int $user_guid User GUID
254
 *
255
 * @return bool
256
 *
257
 * @deprecated Use \ElggUser->removeAdmin()
258
 */
259 View Code Duplication
function remove_user_admin($user_guid) {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
260
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::removeAdmin()', '3.0');
261
    
262
	$user = get_user($user_guid);
263
	if (!$user) {
264
		return false;
265
	}
266
	
267
	return $user->removeAdmin();
268
}
269
270
/**
271
 * Gets the validation status of a user.
272
 *
273
 * @param int $user_guid The user's GUID
274
 * @return bool|null Null means status was not set for this user.
275
 * @since 1.8.0
276
 *
277
 * @deprecated Use \ElggUser->isValidated()
278
 */
279 View Code Duplication
function elgg_get_user_validation_status($user_guid) {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
280
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::isValidated()', '3.0');
281
	
282
	$user = get_user($user_guid);
283
	if (!$user) {
284
		return false;
285
	}
286
	
287
	return $user->isValidated();
288
}
289
290
/**
291
 * Set the validation status for a user.
292
 *
293
 * @param int    $user_guid The user's GUID
294
 * @param bool   $status    Validated (true) or unvalidated (false)
295
 * @param string $method    Optional method to say how a user was validated
296
 * @return bool
297
 * @since 1.8.0
298
 *
299
 * @deprecated Use \ElggUser->setValidationStatus()
300
 */
301
function elgg_set_user_validation_status($user_guid, $status, $method = '') {
302
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::setValidationStatus()', '3.0');
303
	
304
	$user = get_user($user_guid);
305
	if (!$user) {
306
		return false;
307
	}
308
	
309
	$user->setValidationStatus($status, $method);
310
	return true;
311
}
312
313
/**
314
 * Sets the last action time of the given user to right now.
315
 *
316
 * @param ElggUser|int $user The user or GUID
317
 * @return void
318
 *
319
 * @deprecated Use \ElggUser->setLastAction()
320
 */
321
function set_last_action($user) {
322
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::setLastAction()', '3.0');
323
	
324
	if (!$user instanceof ElggUser) {
325
		$user = get_user($user);
326
	}
327
	if (!$user) {
328
		return;
329
	}
330
	
331
	$user->setLastAction();
332
}
333
334
/**
335
 * Sets the last logon time of the given user to right now.
336
 *
337
 * @param int $user_guid The user GUID
338
 * @return void
339
 *
340
 * @deprecated Use \ElggUser->setLastLogin()
341
 */
342
function set_last_login($user_guid) {
343
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::setLastLogin()', '3.0');
344
	
345
	$user = get_user($user_guid);
346
	if (!$user) {
347
		return;
348
	}
349
	
350
	$user->setLastLogin();
351
}
352