Issues (2473)

Branch: master

Security Analysis    no vulnerabilities found

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

engine/lib/deprecated-1.8.php (27 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

Code
1
<?php
2
3
/**
4
 * Lists entities from an access collection
5
 *
6
 * @deprecated 1.8 Use elgg_list_entities_from_access_id()
7
 *
8
 * @return str
9
 */
10
function list_entities_from_access_id($access_id, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
11
12
	elgg_deprecated_notice("All list_entities* functions were deprecated in 1.8.  Use elgg_list_entities* instead.", 1.8);
13
14
	echo elgg_list_entities_from_access_id(array('access_id' => $access_id,
15
		'type' => $entity_type, 'subtype' => $entity_subtype, 'owner_guids' => $owner_guid,
16
		'limit' => $limit, 'full_view' => $fullview, 'list_type_toggle' => $listtypetoggle,
17
		'pagination' => $pagination,));
18
}
19
20
/**
21
 * Registers a particular action in memory
22
 *
23
 * @deprecated 1.8 Use {@link elgg_register_action()} instead
24
 *
25
 * @param string $action The name of the action (eg "register", "account/settings/save")
26
 * @param boolean $public Can this action be accessed by people not logged into the system?
27
 * @param string $filename Optionally, the filename where this action is located
28
 * @param boolean $admin_only Whether this action is only available to admin users.
29
 */
30
function register_action($action, $public = false, $filename = "", $admin_only = false) {
31
	elgg_deprecated_notice("register_action() was deprecated by elgg_register_action()", 1.8);
32
33
	if ($admin_only) {
34
		$access = 'admin';
35
	} elseif ($public) {
36
		$access = 'public';
37
	} else {
38
		$access = 'logged_in';
39
	}
40
41
	return elgg_register_action($action, $filename, $access);
42
}
43
44
/**
45
 * Register an admin page with the admin panel.
46
 * This function extends the view "admin/main" with the provided view.
47
 * This view should provide a description and either a control or a link to.
48
 *
49
 * @deprecated 1.8 Extend admin views manually
50
 *
51
 * Usage:
52
 * 	- To add a control to the main admin panel then extend admin/main
53
 *  - To add a control to a new page create a page which renders a view admin/subpage
54
 *    (where subpage is your new page -
55
 *    nb. some pages already exist that you can extend), extend the main view to point to it,
56
 *    and add controls to your new view.
57
 *
58
 * At the moment this is essentially a wrapper around elgg_extend_view().
59
 *
60
 * @param string $new_admin_view The view associated with the control you're adding
61
 * @param string $view           The view to extend, by default this is 'admin/main'.
62
 * @param int    $priority       Optional priority to govern the appearance in the list.
63
 *
64
 * @return void
65
 */
66
function extend_elgg_admin_page($new_admin_view, $view = 'admin/main', $priority = 500) {
67
	elgg_deprecated_notice('extend_elgg_admin_page() does nothing. Extend admin views manually.', 1.8);
68
}
69
70
/**
71
 * Get entities ordered by a mathematical calculation
72
 *
73
 * @deprecated 1.8 Use elgg_get_entities_from_annotation_calculation()
74
 *
75
 * @param string $sum            What sort of calculation to perform
76
 * @param string $entity_type    Type of Entity
77
 * @param string $entity_subtype Subtype of Entity
78
 * @param string $name           Name of annotation
79
 * @param string $mdname         Metadata name
80
 * @param string $mdvalue        Metadata value
81
 * @param int    $owner_guid     GUID of owner of annotation
82
 * @param int    $limit          Limit of results
83
 * @param int    $offset         Offset of results
84
 * @param string $orderdir       Order of results
85
 * @param bool   $count          Return count or entities
86
 *
87
 * @return mixed
88
 */
89 View Code Duplication
function get_entities_from_annotations_calculate_x($sum = "sum", $entity_type = "", $entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
90
91
	$msg = 'get_entities_from_annotations_calculate_x() is deprecated by elgg_get_entities_from_annotation_calculation().';
92
93
	elgg_deprecated_notice($msg, 1.8);
94
95
	$options = array();
96
97
	$options['calculation'] = $sum;
98
99
	if ($entity_type) {
100
		$options['types'] = $entity_type;
101
	}
102
103
	if ($entity_subtype) {
104
		$options['subtypes'] = $entity_subtype;
105
	}
106
107
	$options['annotation_names'] = $name;
108
109
	if ($mdname) {
110
		$options['metadata_names'] = $mdname;
111
	}
112
113
	if ($mdvalue) {
114
		$options['metadata_values'] = $mdvalue;
115
	}
116
117
	// original function rewrote this to container guid.
118
	if ($owner_guid) {
119
		if (is_array($owner_guid)) {
120
			$options['container_guids'] = $owner_guid;
121
		} else {
122
			$options['container_guid'] = $owner_guid;
123
		}
124
	}
125
126
	$options['limit'] = $limit;
127
	$options['offset'] = $offset;
128
129
	$options['order_by'] = "annotation_calculation $orderdir";
130
131
	$options['count'] = $count;
132
133
	return elgg_get_entities_from_annotation_calculation($options);
134
}
135
136
/**
137
 * Returns entities ordered by the sum of an annotation
138
 *
139
 * @warning This is function uses sum instead of count. THIS IS SLOW. See #3366.
140
 *          This should be used when you have annotations with different values and you
141
 *          want a list of entities ordered by the sum of all of those values.
142
 *          If you want a list of entities ordered by the number of annotations on each entity,
143
 *          use __get_entities_from_annotations_calculate_x() and pass 'count' as the first param.
144
 *
145
 * @deprecated 1.8 Use elgg_get_entities_from_annotation_calculation()
146
 *
147
 * @param string $entity_type    Type of Entity
148
 * @param string $entity_subtype Subtype of Entity
149
 * @param string $name           Name of annotation
150
 * @param string $mdname         Metadata name
151
 * @param string $mdvalue        Metadata value
152
 * @param int    $owner_guid     GUID of owner of annotation
153
 * @param int    $limit          Limit of results
154
 * @param int    $offset         Offset of results
155
 * @param string $orderdir       Order of results
156
 * @param bool   $count          Return count or entities
157
 *
158
 * @return ElggEntity[]|int
159
 */
160 View Code Duplication
function get_entities_from_annotation_count($entity_type = "", $entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
161
162
	$msg = 'get_entities_from_annotation_count() is deprecated by elgg_get_entities_from_annotation_calculation().';
163
164
	elgg_deprecated_notice($msg, 1.8);
165
166
	$options = array();
167
168
	$options['calculation'] = 'sum';
169
170
	if ($entity_type) {
171
		$options['types'] = $entity_type;
172
	}
173
174
	if ($entity_subtype) {
175
		$options['subtypes'] = $entity_subtype;
176
	}
177
178
	$options['annotation_names'] = $name;
179
180
	if ($mdname) {
181
		$options['metadata_names'] = $mdname;
182
	}
183
184
	if ($mdvalue) {
185
		$options['metadata_values'] = $mdvalue;
186
	}
187
188
	if ($owner_guid) {
189
		if (is_array($owner_guid)) {
190
			$options['owner_guids'] = $owner_guid;
191
		} else {
192
			$options['owner_guid'] = $owner_guid;
193
		}
194
	}
195
196
	$options['limit'] = $limit;
197
	$options['offset'] = $offset;
198
199
	$options['order_by'] = "annotation_calculation $orderdir";
200
201
	$options['count'] = $count;
202
203
	return elgg_get_entities_from_annotation_calculation($options);
204
}
205
206
/**
207
 * Lists entities by the totals of a particular kind of annotation
208
 *
209
 * @deprecated 1.8 Use elgg_list_entities_from_annotation_calculation()
210
 *
211
 * @param string  $entity_type    Type of entity.
212
 * @param string  $entity_subtype Subtype of entity.
213
 * @param string  $name           Name of annotation.
214
 * @param int     $limit          Maximum number of results to return.
215
 * @param int     $owner_guid     Owner.
216
 * @param int     $group_guid     Group container. Currently only supported if entity_type is object
217
 * @param boolean $asc            Whether to list in ascending or descending order (default: desc)
218
 * @param boolean $fullview       Whether to display the entities in full
219
 * @param boolean $listtypetoggle Can the 'gallery' view can be displayed (default: no)
220
 * @param boolean $pagination     Add pagination
221
 * @param string  $orderdir       Order desc or asc
222
 *
223
 * @return string Formatted entity list
224
 */
225
function list_entities_from_annotation_count($entity_type = "", $entity_subtype = "", $name = "", $limit = 10, $owner_guid = 0, $group_guid = 0, $asc = false, $fullview = true, $listtypetoggle = false, $pagination = true, $orderdir = 'desc') {
226
227
	$msg = 'list_entities_from_annotation_count() is deprecated by elgg_list_entities_from_annotation_calculation().';
228
229
	elgg_deprecated_notice($msg, 1.8);
230
231
	$options = array();
232
233
	$options['calculation'] = 'sum';
234
235
	if ($entity_type) {
236
		$options['types'] = $entity_type;
237
	}
238
239
	if ($entity_subtype) {
240
		$options['subtypes'] = $entity_subtype;
241
	}
242
243
	$options['annotation_names'] = $name;
244
245
	if ($owner_guid) {
246
		if (is_array($owner_guid)) {
247
			$options['owner_guids'] = $owner_guid;
248
		} else {
249
			$options['owner_guid'] = $owner_guid;
250
		}
251
	}
252
253
	$options['full_view'] = $fullview;
254
255
	$options['list_type_toggle'] = $listtypetoggle;
256
257
	$options['pagination'] = $pagination;
258
259
	$options['limit'] = $limit;
260
261
	$options['order_by'] = "annotation_calculation $orderdir";
262
263
	return elgg_get_entities_from_annotation_calculation($options);
264
}
265
266
/**
267
 * Adds an entry in $CONFIG[$register_name][$subregister_name].
268
 *
269
 * @deprecated 1.8 Use the new menu system.
270
 * 
271
 * This is only used for the site-wide menu.  See {@link add_menu()}.
272
 *
273
 * @param string $register_name     The name of the top-level register
274
 * @param string $subregister_name  The name of the subregister
275
 * @param mixed  $subregister_value The value of the subregister
276
 * @param array  $children_array    Optionally, an array of children
277
 *
278
 * @return true|false Depending on success
279
 */
280
function add_to_register($register_name, $subregister_name, $subregister_value, $children_array = array()) {
281
	elgg_deprecated_notice("add_to_register() has been deprecated", 1.8);
282
	global $CONFIG;
283
284
	if (empty($register_name) || empty($subregister_name)) {
285
		return false;
286
	}
287
288
	if (!isset($CONFIG->registers)) {
289
		$CONFIG->registers = array();
290
	}
291
292
	if (!isset($CONFIG->registers[$register_name])) {
293
		$CONFIG->registers[$register_name] = array();
294
	}
295
296
	$subregister = new \stdClass;
297
	$subregister->name = $subregister_name;
298
	$subregister->value = $subregister_value;
299
300
	if (is_array($children_array)) {
301
		$subregister->children = $children_array;
302
	}
303
304
	$CONFIG->registers[$register_name][$subregister_name] = $subregister;
305
	return true;
306
}
307
308
/**
309
 * Removes a register entry from $CONFIG[register_name][subregister_name]
310
 *
311
 * @deprecated 1.8 Use the new menu system.
312
 *
313
 * This is used to by {@link remove_menu()} to remove site-wide menu items.
314
 *
315
 * @param string $register_name    The name of the top-level register
316
 * @param string $subregister_name The name of the subregister
317
 *
318
 * @return true|false Depending on success
319
 * @since 1.7.0
320
 */
321
function remove_from_register($register_name, $subregister_name) {
322
	elgg_deprecated_notice("remove_from_register() has been deprecated", 1.8);
323
	global $CONFIG;
324
325
	if (empty($register_name) || empty($subregister_name)) {
326
		return false;
327
	}
328
329
	if (!isset($CONFIG->registers)) {
330
		return false;
331
	}
332
333
	if (!isset($CONFIG->registers[$register_name])) {
334
		return false;
335
	}
336
337
	if (isset($CONFIG->registers[$register_name][$subregister_name])) {
338
		unset($CONFIG->registers[$register_name][$subregister_name]);
339
		return true;
340
	}
341
342
	return false;
343
}
344
345
/**
346
 * If it exists, returns a particular register as an array
347
 *
348
 * @deprecated 1.8 Use the new menu system
349
 *
350
 * @param string $register_name The name of the register
351
 *
352
 * @return array|false Depending on success
353
 */
354
function get_register($register_name) {
355
	elgg_deprecated_notice("get_register() has been deprecated", 1.8);
356
	global $CONFIG;
357
358
	if ($register_name == 'menu') {
359
		// backward compatible code for site menu
360
		$menu = $CONFIG->menus['site'];
361
		$builder = new \ElggMenuBuilder($menu);
362
		$menu_items = $builder->getMenu('text');
363
		$menu_items = $menu_items['default'];
364
365
		$menu = array();
366
		foreach ($menu_items as $item) {
0 ignored issues
show
The expression $menu_items of type object<ElggMenuItem> is not traversable.
Loading history...
367
			$subregister = new \stdClass;
368
			$subregister->name = $item->getText();
369
			$subregister->value = $item->getHref();
370
			$menu[$subregister->name] = $subregister;
371
		}
372
		return $menu;
373
	}
374
375
	if (isset($CONFIG->registers[$register_name])) {
376
		return $CONFIG->registers[$register_name];
377
	}
378
379
	return false;
380
}
381
382
/**
383
 * Deprecated events core function. Code divided between elgg_register_event_handler()
384
 * and trigger_elgg_event().
385
 *
386
 * @deprecated 1.8 Use explicit register/trigger event functions
387
 *
388
 * @param string  $event       The type of event (eg 'init', 'update', 'delete')
389
 * @param string  $object_type The type of object (eg 'system', 'blog', 'user')
390
 * @param string  $function    The name of the function that will handle the event
391
 * @param int     $priority    Priority to call handler. Lower numbers called first (default 500)
392
 * @param boolean $call        Set to true to call the event rather than add to it (default false)
393
 * @param mixed   $object      Optionally, the object the event is being performed on (eg a user)
394
 *
395
 * @return true|false Depending on success
396
 */
397
function events($event = "", $object_type = "", $function = "", $priority = 500, $call = false, $object = null) {
398
399
	elgg_deprecated_notice('events() has been deprecated.', 1.8);
400
401
	// leaving this here just in case someone was directly calling this internal function
402
	if (!$call) {
403
		return elgg_register_event_handler($event, $object_type, $function, $priority);
404
	} else {
405
		return trigger_elgg_event($event, $object_type, $object);
406
	}
407
}
408
409
/**
410
 * Alias function for events, that registers a function to a particular kind of event
411
 *
412
 * @deprecated 1.8 Use elgg_register_event_handler() instead
413
 * 
414
 * @param string $event The event type
415
 * @param string $object_type The object type
416
 * @param string $function The function name
0 ignored issues
show
There is no parameter named $function. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
417
 * @return true|false Depending on success
418
 */
419
function register_elgg_event_handler($event, $object_type, $callback, $priority = 500) {
420
	elgg_deprecated_notice("register_elgg_event_handler() was deprecated by elgg_register_event_handler()", 1.8);
421
	return elgg_register_event_handler($event, $object_type, $callback, $priority);
422
}
423
424
/**
425
 * Unregisters a function to a particular kind of event
426
 * 
427
 * @deprecated 1.8 Use elgg_unregister_event_handler instead
428
 *
429
 * @param string $event The event type
430
 * @param string $object_type The object type
431
 * @param string $function The function name
0 ignored issues
show
There is no parameter named $function. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
432
 * @since 1.7.0
433
 */
434
function unregister_elgg_event_handler($event, $object_type, $callback) {
435
	elgg_deprecated_notice('unregister_elgg_event_handler => elgg_unregister_event_handler', 1.8);
436
	elgg_unregister_event_handler($event, $object_type, $callback);
437
}
438
439
/**
440
 * Alias function for events, that triggers a particular kind of event
441
 *
442
 * @deprecated 1.8 Use elgg_trigger_event() instead
443
 * 
444
 * @param string $event The event type
445
 * @param string $object_type The object type
446
 * @param string $function The function name
0 ignored issues
show
There is no parameter named $function. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
447
 * @return true|false Depending on success
448
 */
449
function trigger_elgg_event($event, $object_type, $object = null) {
450
	elgg_deprecated_notice('trigger_elgg_event() was deprecated by elgg_trigger_event()', 1.8);
451
	return elgg_trigger_event($event, $object_type, $object);
452
}
453
454
/**
455
 * Register a function to a plugin hook for a particular entity type, with a given priority.
456
 *
457
 * @deprecated 1.8 Use elgg_register_plugin_hook_handler() instead
458
 * 
459
 * eg if you want the function "export_user" to be called when the hook "export" for "user" entities
460
 * is run, use:
461
 *
462
 * 		register_plugin_hook("export", "user", "export_user");
463
 *
464
 * "all" is a valid value for both $hook and $entity_type. "none" is a valid value for $entity_type.
465
 *
466
 * The export_user function would then be defined as:
467
 *
468
 * 		function export_user($hook, $entity_type, $returnvalue, $params);
469
 *
470
 * Where $returnvalue is the return value returned by the last function returned by the hook, and
471
 * $params is an array containing a set of parameters (or nothing).
472
 *
473
 * @param string $hook The name of the hook
474
 * @param string $entity_type The name of the type of entity (eg "user", "object" etc)
0 ignored issues
show
There is no parameter named $entity_type. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
475
 * @param string $function The name of a valid function to be run
0 ignored issues
show
There is no parameter named $function. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
476
 * @param string $priority The priority - 0 is first, 1000 last, default is 500
477
 * @return true|false Depending on success
478
 */
479
function register_plugin_hook($hook, $type, $callback, $priority = 500) {
480
	elgg_deprecated_notice("register_plugin_hook() was deprecated by elgg_register_plugin_hook_handler()", 1.8);
481
	return elgg_register_plugin_hook_handler($hook, $type, $callback, $priority);
482
}
483
484
/**
485
 * Unregister a function to a plugin hook for a particular entity type
486
 *
487
 * @deprecated 1.8 Use elgg_unregister_plugin_hook_handler() instead
488
 * 
489
 * @param string $hook The name of the hook
490
 * @param string $entity_type The name of the type of entity (eg "user", "object" etc)
491
 * @param string $function The name of a valid function to be run
0 ignored issues
show
There is no parameter named $function. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
492
 * @since 1.7.0
493
 */
494
function unregister_plugin_hook($hook, $entity_type, $callback) {
495
	elgg_deprecated_notice("unregister_plugin_hook() was deprecated by elgg_unregister_plugin_hook_handler()", 1.8);
496
	elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback);
497
}
498
499
/**
500
 * Triggers a plugin hook, with various parameters as an array. For example, to provide
501
 * a 'foo' hook that concerns an entity of type 'bar', with a parameter called 'param1'
502
 * with value 'value1', that by default returns true, you'd call:
503
 *
504
 * @deprecated 1.8 Use elgg_trigger_plugin_hook() instead
505
 *
506
 * trigger_plugin_hook('foo', 'bar', array('param1' => 'value1'), true);
507
 *
508
 * @see register_plugin_hook
509
 * @param string $hook The name of the hook to trigger
510
 * @param string $entity_type The name of the entity type to trigger it for (or "all", or "none")
0 ignored issues
show
There is no parameter named $entity_type. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
511
 * @param array $params Any parameters. It's good practice to name the keys, i.e. by using array('name' => 'value', 'name2' => 'value2')
512
 * @param mixed $returnvalue An initial return value
513
 * @return mixed|null The cumulative return value for the plugin hook functions
514
 */
515
function trigger_plugin_hook($hook, $type, $params = null, $returnvalue = null) {
516
	elgg_deprecated_notice("trigger_plugin_hook() was deprecated by elgg_trigger_plugin_hook()", 1.8);
517
	return elgg_trigger_plugin_hook($hook, $type, $params, $returnvalue);
518
}
519
520
/**
521
 * Checks if code is being called from a certain function.
522
 *
523
 * To use, call this function with the function name (and optional
524
 * file location) that it has to be called from, it will either
525
 * return true or false.
526
 *
527
 * e.g.
528
 *
529
 * function my_secure_function()
530
 * {
531
 * 		if (!call_gatekeeper("my_call_function"))
532
 * 			return false;
533
 *
534
 * 		... do secure stuff ...
535
 * }
536
 *
537
 * function my_call_function()
538
 * {
539
 * 		// will work
540
 * 		my_secure_function();
541
 * }
542
 *
543
 * function bad_function()
544
 * {
545
 * 		// Will not work
546
 * 		my_secure_function();
547
 * }
548
 *
549
 * @param mixed  $function The function that this function must have in its call stack,
550
 * 		                   to test against a method pass an array containing a class and
551
 *                         method name.
552
 * @param string $file     Optional file that the function must reside in.
553
 *
554
 * @return bool
555
 *
556
 * @deprecated 1.8 A neat but pointless function
557
 */
558
function call_gatekeeper($function, $file = "") {
559
	elgg_deprecated_notice("call_gatekeeper() is neat but pointless", 1.8);
560
	// Sanity check
561
	if (!$function) {
562
		return false;
563
	}
564
565
	// Check against call stack to see if this is being called from the correct location
566
	$callstack = debug_backtrace();
567
	$stack_element = false;
568
569
	foreach ($callstack as $call) {
570
		if (is_array($function)) {
571
			if ((strcmp($call['class'], $function[0]) == 0) && (strcmp($call['function'], $function[1]) == 0)) {
572
				$stack_element = $call;
573
			}
574
		} else {
575
			if (strcmp($call['function'], $function) == 0) {
576
				$stack_element = $call;
577
			}
578
		}
579
	}
580
581
	if (!$stack_element) {
582
		return false;
583
	}
584
585
	// If file then check that this it is being called from this function
586
	if ($file) {
587
		$mirror = null;
588
589
		if (is_array($function)) {
590
			$mirror = new ReflectionMethod($function[0], $function[1]);
591
		} else {
592
			$mirror = new ReflectionFunction($function);
593
		}
594
595
		if ((!$mirror) || (strcmp($file, $mirror->getFileName()) != 0)) {
596
			return false;
597
		}
598
	}
599
600
	return true;
601
}
602
603
/**
604
 * This function checks to see if it is being called at somepoint by a function defined somewhere
605
 * on a given path (optionally including subdirectories).
606
 *
607
 * This function is similar to call_gatekeeper() but returns true if it is being called
608
 * by a method or function which has been defined on a given path or by a specified file.
609
 *
610
 * @param string $path            The full path and filename that this function must have
611
 *                                in its call stack If a partial path is given and
612
 *                                $include_subdirs is true, then the function will return
613
 *                                true if called by any function in or below the specified path.
614
 * @param bool   $include_subdirs Are subdirectories of the path ok, or must you specify an
615
 *                                absolute path and filename.
616
 * @param bool   $strict_mode     If true then the calling method or function must be directly
617
 *                                called by something on $path, if false the whole call stack is
618
 *                                searched.
619
 *
620
 * @return void
621
 *
622
 * @deprecated 1.8 A neat but pointless function
623
 */
624
function callpath_gatekeeper($path, $include_subdirs = true, $strict_mode = false) {
625
	elgg_deprecated_notice("callpath_gatekeeper() is neat but pointless", 1.8);
626
627
	global $CONFIG;
628
629
	$path = sanitise_string($path);
630
631
	if ($path) {
632
		$callstack = debug_backtrace();
633
634
		foreach ($callstack as $call) {
635
			$call['file'] = str_replace("\\", "/", $call['file']);
636
637
			if ($include_subdirs) {
638
				if (strpos($call['file'], $path) === 0) {
639
640
					if ($strict_mode) {
641
						$callstack[1]['file'] = str_replace("\\", "/", $callstack[1]['file']);
642
						if ($callstack[1] === $call) {
643
							return true;
644
						}
645
					} else {
646
						return true;
647
					}
648
				}
649
			} else {
650
				if (strcmp($path, $call['file']) == 0) {
651
					if ($strict_mode) {
652
						if ($callstack[1] === $call) {
653
							return true;
654
						}
655
					} else {
656
						return true;
657
					}
658
				}
659
			}
660
661
		}
662
		return false;
663
	}
664
665
	if (isset($CONFIG->debug)) {
666
		system_message("Gatekeeper'd function called from {$callstack[1]['file']}:" . "{$callstack[1]['line']}\n\nStack trace:\n\n" . print_r($callstack, true));
0 ignored issues
show
The variable $callstack seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
667
	}
668
669
	return false;
670
}
671
672
/**
673
 * Returns SQL where clause for owner and containers.
674
 *
675
 * @deprecated 1.8 Use elgg_get_guid_based_where_sql();
676
 *
677
 * @param string     $table       Entity table prefix as defined in SELECT...FROM entities $table
678
 * @param NULL|array $owner_guids Owner GUIDs
679
 *
680
 * @return string|false
681
 * @since 1.7.0
682
 * @access private
683
 */
684
function elgg_get_entity_owner_where_sql($table, $owner_guids) {
685
	elgg_deprecated_notice('elgg_get_entity_owner_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
686
687
	return _elgg_get_guid_based_where_sql("{$table}.owner_guid", $owner_guids);
688
}
689
690
/**
691
 * Returns SQL where clause for containers.
692
 *
693
 * @deprecated 1.8 Use elgg_get_guid_based_where_sql();
694
 *
695
 * @param string     $table           Entity table prefix as defined in
696
 *                                    SELECT...FROM entities $table
697
 * @param NULL|array $container_guids Array of container guids
698
 *
699
 * @return FALSE|string
700
 * @since 1.7.0
701
 * @access private
702
 */
703
function elgg_get_entity_container_where_sql($table, $container_guids) {
704
	elgg_deprecated_notice('elgg_get_entity_container_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
705
706
	return _elgg_get_guid_based_where_sql("{$table}.container_guid", $container_guids);
707
}
708
709
/**
710
 * Returns SQL where clause for site entities
711
 *
712
 * @deprecated 1.8 Use elgg_get_guid_based_where_sql()
713
 *
714
 * @param string     $table      Entity table prefix as defined in SELECT...FROM entities $table
715
 * @param NULL|array $site_guids Array of site guids
716
 *
717
 * @return FALSE|string
718
 * @since 1.7.0
719
 * @access private
720
 */
721
function elgg_get_entity_site_where_sql($table, $site_guids) {
722
	elgg_deprecated_notice('elgg_get_entity_site_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
723
724
	return _elgg_get_guid_based_where_sql("{$table}.site_guid", $site_guids);
725
}
726
727
/**
728
 * Return an array of objects in a given container.
729
 *
730
 * @see get_entities()
731
 *
732
 * @param int    $group_guid The container (defaults to current page owner)
733
 * @param string $subtype    The subtype
734
 * @param int    $owner_guid Owner
735
 * @param int    $site_guid  The site
736
 * @param string $order_by   Order
737
 * @param int    $limit      Limit on number of elements to return, by default 10.
738
 * @param int    $offset     Where to start, by default 0.
739
 * @param bool   $count      Whether to return the entities or a count of them.
740
 *
741
 * @return array|false
742
 * @deprecated 1.8 Use elgg_get_entities() instead
743
 */
744
function get_objects_in_group($group_guid, $subtype = "", $owner_guid = 0, $site_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = FALSE) {
745
	elgg_deprecated_notice("get_objects_in_group was deprected in 1.8.  Use elgg_get_entities() instead", 1.8);
746
747
	global $CONFIG;
748
749 View Code Duplication
	if ($subtype === FALSE || $subtype === null || $subtype === 0) {
0 ignored issues
show
Unused Code Bug introduced by
The strict comparison === seems to always evaluate to false as the types of $subtype (string) and 0 (integer) can never be identical. Maybe you want to use a loose comparison == instead?
Loading history...
750
		return FALSE;
751
	}
752
753
	if ($order_by == "") {
754
		$order_by = "e.time_created desc";
755
	}
756
	$order_by = sanitise_string($order_by);
757
	$limit = (int)$limit;
758
	$offset = (int)$offset;
759
	$site_guid = (int)$site_guid;
760
	if ($site_guid == 0) {
761
		$site_guid = $CONFIG->site_guid;
762
	}
763
764
	$container_guid = (int)$group_guid;
765
	if ($container_guid == 0) {
766
		$container_guid = elgg_get_page_owner_guid();
767
	}
768
769
	$where = array();
770
771
	$where[] = "e.type='object'";
772
773
	if (!empty($subtype)) {
774
		if (!$subtype = get_subtype_id('object', $subtype)) {
775
			return FALSE;
776
		}
777
		$where[] = "e.subtype=$subtype";
778
	}
779 View Code Duplication
	if ($owner_guid != "") {
780
		if (!is_array($owner_guid)) {
781
			$owner_guid = (int)$owner_guid;
782
			$where[] = "e.container_guid = '$owner_guid'";
783
		} else if (sizeof($owner_guid) > 0) {
784
			// Cast every element to the owner_guid array to int
785
			$owner_guid = array_map("sanitise_int", $owner_guid);
786
			$owner_guid = implode(",", $owner_guid);
787
			$where[] = "e.container_guid in ({$owner_guid})";
788
		}
789
	}
790
	if ($site_guid > 0) {
791
		$where[] = "e.site_guid = {$site_guid}";
792
	}
793
794
	if ($container_guid > 0) {
795
		$where[] = "e.container_guid = {$container_guid}";
796
	}
797
798
	if (!$count) {
799
		$query = "SELECT * from {$CONFIG->dbprefix}entities e" . " join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid where ";
800
	} else {
801
		$query = "SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e" . " join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid where ";
802
	}
803
	foreach ($where as $w) {
804
		$query .= " $w and ";
805
	}
806
807
	// Add access controls
808
	$query .= _elgg_get_access_where_sql();
809 View Code Duplication
	if (!$count) {
810
		$query .= " order by $order_by";
811
812
		// Add order and limit
813
		if ($limit) {
814
			$query .= " limit $offset, $limit";
815
		}
816
817
		$dt = get_data($query, "entity_row_to_elggstar");
818
		return $dt;
819
	} else {
820
		$total = get_data_row($query);
821
		return $total->total;
822
	}
823
}
824
825
/**
826
 * Lists entities that belong to a group.
827
 *
828
 * @param string $subtype        The arbitrary subtype of the entity
829
 * @param int    $owner_guid     The GUID of the owning user
830
 * @param int    $container_guid The GUID of the containing group
831
 * @param int    $limit          The number of entities to display per page (default: 10)
832
 * @param bool   $fullview       Whether or not to display the full view (default: true)
833
 * @param bool   $listtypetoggle Whether or not to allow gallery view (default: true)
834
 * @param bool   $pagination     Whether to display pagination (default: true)
835
 *
836
 * @return string List of parsed entities
837
 *
838
 * @see elgg_list_entities()
839
 * @deprecated 1.8 Use elgg_list_entities() instead
840
 */
841
function list_entities_groups($subtype = "", $owner_guid = 0, $container_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
842
	elgg_deprecated_notice("list_entities_groups was deprecated in 1.8.  Use elgg_list_entities() instead.", 1.8);
843
	$offset = (int)get_input('offset');
844
	$count = get_objects_in_group($container_guid, $subtype, $owner_guid, 0, "", $limit, $offset, true);
845
	$entities = get_objects_in_group($container_guid, $subtype, $owner_guid, 0, "", $limit, $offset);
846
847
	return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle, $pagination);
0 ignored issues
show
It seems like $entities defined by get_objects_in_group($co...0, '', $limit, $offset) on line 845 can also be of type false; however, elgg_view_entity_list() does only seem to accept array, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
It seems like $count defined by get_objects_in_group($co... $limit, $offset, true) on line 844 can also be of type false; however, elgg_view_entity_list() does only seem to accept array, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
848
}
849
850
/**
851
 * Get all the entities from metadata from a group.
852
 *
853
 * @param int    $group_guid     The ID of the group.
854
 * @param mixed  $meta_name      Metadata name
855
 * @param mixed  $meta_value     Metadata value
856
 * @param string $entity_type    The type of entity to look for, eg 'site' or 'object'
857
 * @param string $entity_subtype The subtype of the entity.
858
 * @param int    $owner_guid     Owner guid
859
 * @param int    $limit          Limit
860
 * @param int    $offset         Offset
861
 * @param string $order_by       Optional ordering.
862
 * @param int    $site_guid      Site GUID. 0 for current, -1 for any
863
 * @param bool   $count          Return count instead of entities
864
 *
865
 * @return array|false
866
 * @deprecated 1.8 Use elgg_get_entities_from_metadata()
867
 */
868
function get_entities_from_metadata_groups($group_guid, $meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
869
	elgg_deprecated_notice("get_entities_from_metadata_groups was deprecated in 1.8.", 1.8);
870
	global $CONFIG;
871
872
	$meta_n = get_metastring_id($meta_name);
873
	$meta_v = get_metastring_id($meta_value);
874
875
	$entity_type = sanitise_string($entity_type);
876
	$entity_subtype = get_subtype_id($entity_type, $entity_subtype);
877
	$limit = (int)$limit;
878
	$offset = (int)$offset;
879
	if ($order_by == "") {
880
		$order_by = "e.time_created desc";
881
	}
882
	$order_by = sanitise_string($order_by);
883
	$site_guid = (int)$site_guid;
884
	if (is_array($owner_guid)) {
885
		foreach ($owner_guid as $key => $guid) {
886
			$owner_guid[$key] = (int)$guid;
887
		}
888
	} else {
889
		$owner_guid = (int)$owner_guid;
890
	}
891
	if ($site_guid == 0) {
892
		$site_guid = $CONFIG->site_guid;
893
	}
894
895
	$container_guid = (int)$group_guid;
896
	if ($container_guid == 0) {
897
		$container_guid = elgg_get_page_owner_guid();
898
	}
899
900
	$where = array();
901
902
	if ($entity_type != "") {
903
		$where[] = "e.type='$entity_type'";
904
	}
905
	if ($entity_subtype) {
906
		$where[] = "e.subtype=$entity_subtype";
907
	}
908
	if ($meta_name != "") {
909
		$where[] = "m.name_id='$meta_n'";
910
	}
911
	if ($meta_value != "") {
912
		$where[] = "m.value_id='$meta_v'";
913
	}
914
	if ($site_guid > 0) {
915
		$where[] = "e.site_guid = {$site_guid}";
916
	}
917
	if ($container_guid > 0) {
918
		$where[] = "e.container_guid = {$container_guid}";
919
	}
920
921 View Code Duplication
	if (is_array($owner_guid)) {
922
		$where[] = "e.container_guid in (" . implode(",", $owner_guid) . ")";
923
	} else if ($owner_guid > 0) {
924
		$where[] = "e.container_guid = {$owner_guid}";
925
	}
926
927
	if (!$count) {
928
		$query = "SELECT distinct e.* ";
929
	} else {
930
		$query = "SELECT count(e.guid) as total ";
931
	}
932
933
	$query .= "from {$CONFIG->dbprefix}entities e" . " JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid " . " JOIN {$CONFIG->dbprefix}objects_entity o on e.guid = o.guid where";
934
935
	foreach ($where as $w) {
936
		$query .= " $w and ";
937
	}
938
939
	// Add access controls
940
	$query .= _elgg_get_access_where_sql();
941
942
	if (!$count) {
943
		$query .= " order by $order_by limit $offset, $limit"; // Add order and limit
944
		return get_data($query, "entity_row_to_elggstar");
945
	} else {
946
		if ($row = get_data_row($query)) {
947
			return $row->total;
948
		}
949
	}
950
	return false;
951
}
952
953
/**
954
 * As get_entities_from_metadata_groups() but with multiple entities.
955
 *
956
 * @param int    $group_guid     The ID of the group.
957
 * @param array  $meta_array     Array of 'name' => 'value' pairs
958
 * @param string $entity_type    The type of entity to look for, eg 'site' or 'object'
959
 * @param string $entity_subtype The subtype of the entity.
960
 * @param int    $owner_guid     Owner GUID
961
 * @param int    $limit          Limit
962
 * @param int    $offset         Offset
963
 * @param string $order_by       Optional ordering.
964
 * @param int    $site_guid      Site GUID. 0 for current, -1 for any
965
 * @param bool   $count          Return count of entities instead of entities
966
 *
967
 * @return int|array List of \ElggEntities, or the total number if count is set to false
968
 * @deprecated 1.8 Use elgg_get_entities_from_metadata()
969
 */
970
function get_entities_from_metadata_groups_multi($group_guid, $meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
971
	elgg_deprecated_notice("get_entities_from_metadata_groups_multi was deprecated in 1.8.", 1.8);
972
973
	global $CONFIG;
974
975
	if (!is_array($meta_array) || sizeof($meta_array) == 0) {
976
		return false;
977
	}
978
979
	$where = array();
980
981
	$mindex = 1;
982
	$join = "";
983
	foreach ($meta_array as $meta_name => $meta_value) {
984
		$meta_n = get_metastring_id($meta_name);
985
		$meta_v = get_metastring_id($meta_value);
986
		$join .= " JOIN {$CONFIG->dbprefix}metadata m{$mindex} on e.guid = m{$mindex}.entity_guid" . " JOIN {$CONFIG->dbprefix}objects_entity o on e.guid = o.guid ";
987
988
		if ($meta_name != "") {
989
			$where[] = "m{$mindex}.name_id='$meta_n'";
990
		}
991
992
		if ($meta_value != "") {
993
			$where[] = "m{$mindex}.value_id='$meta_v'";
994
		}
995
996
		$mindex++;
997
	}
998
999
	$entity_type = sanitise_string($entity_type);
1000
	$entity_subtype = get_subtype_id($entity_type, $entity_subtype);
1001
	$limit = (int)$limit;
1002
	$offset = (int)$offset;
1003
	if ($order_by == "") {
1004
		$order_by = "e.time_created desc";
1005
	}
1006
	$order_by = sanitise_string($order_by);
1007
	$owner_guid = (int)$owner_guid;
1008
1009
	$site_guid = (int)$site_guid;
1010
	if ($site_guid == 0) {
1011
		$site_guid = $CONFIG->site_guid;
1012
	}
1013
1014
	//$access = get_access_list();
1015
1016
	if ($entity_type != "") {
1017
		$where[] = "e.type = '{$entity_type}'";
1018
	}
1019
1020
	if ($entity_subtype) {
1021
		$where[] = "e.subtype = {$entity_subtype}";
1022
	}
1023
1024
	if ($site_guid > 0) {
1025
		$where[] = "e.site_guid = {$site_guid}";
1026
	}
1027
1028
	if ($owner_guid > 0) {
1029
		$where[] = "e.owner_guid = {$owner_guid}";
1030
	}
1031
1032
	if ($group_guid > 0) {
1033
		$where[] = "e.container_guid = {$group_guid}";
1034
	}
1035
1036
	if ($count) {
1037
		$query = "SELECT count(e.guid) as total ";
1038
	} else {
1039
		$query = "SELECT distinct e.* ";
1040
	}
1041
1042
	$query .= " from {$CONFIG->dbprefix}entities e {$join} where";
1043
	foreach ($where as $w) {
1044
		$query .= " $w and ";
1045
	}
1046
	$query .= _elgg_get_access_where_sql();
1047
1048
	if (!$count) {
1049
		$query .= " order by $order_by limit $offset, $limit"; // Add order and limit
1050
		return get_data($query, "entity_row_to_elggstar");
1051
	} else {
1052
		if ($count = get_data_row($query)) {
1053
			return $count->total;
1054
		}
1055
	}
1056
	return false;
1057
}
1058
1059
/**
1060
 * List items within a given geographic area.
1061
 *
1062
 * @param float  $lat            Latitude
1063
 * @param float  $long           Longitude
1064
 * @param float  $radius         The radius
1065
 * @param string $type           The type of entity (eg "user", "object" etc)
1066
 * @param string $subtype        The arbitrary subtype of the entity
1067
 * @param int    $owner_guid     The GUID of the owning user
1068
 * @param int    $limit          The number of entities to display per page (default: 10)
1069
 * @param bool   $fullview       Whether or not to display the full view (default: true)
1070
 * @param bool   $listtypetoggle Whether or not to allow gallery view
1071
 * @param bool   $navigation     Display pagination? Default: true
1072
 *
1073
 * @return string A viewable list of entities
1074
 * @deprecated 1.8 Use elgg_get_entities_from_location()
1075
 */
1076
function list_entities_in_area($lat, $long, $radius, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
1077
	elgg_deprecated_notice('list_entities_in_area() was deprecated. Use elgg_list_entities_from_location()', 1.8);
1078
1079
	$options = array();
1080
1081
	$options['latitude'] = $lat;
1082
	$options['longitude'] = $long;
1083
	$options['distance'] = $radius;
1084
1085
	if ($type) {
1086
		$options['types'] = $type;
1087
	}
1088
1089
	if ($subtype) {
1090
		$options['subtypes'] = $subtype;
1091
	}
1092
1093
	if ($owner_guid) {
1094
		if (is_array($owner_guid)) {
1095
			$options['owner_guids'] = $owner_guid;
1096
		} else {
1097
			$options['owner_guid'] = $owner_guid;
1098
		}
1099
	}
1100
1101
	$options['limit'] = $limit;
1102
1103
	$options['full_view'] = $fullview;
1104
	$options['list_type_toggle'] = $listtypetoggle;
1105
	$options['pagination'] = true;
1106
1107
	return elgg_list_entities_from_location($options);
1108
}
1109
1110
/**
1111
 * List entities in a given location
1112
 *
1113
 * @param string $location       Location
1114
 * @param string $type           The type of entity (eg "user", "object" etc)
1115
 * @param string $subtype        The arbitrary subtype of the entity
1116
 * @param int    $owner_guid     The GUID of the owning user
1117
 * @param int    $limit          The number of entities to display per page (default: 10)
1118
 * @param bool   $fullview       Whether or not to display the full view (default: true)
1119
 * @param bool   $listtypetoggle Whether or not to allow gallery view
1120
 * @param bool   $navigation     Display pagination? Default: true
1121
 *
1122
 * @return string A viewable list of entities
1123
 * @deprecated 1.8 Use elgg_list_entities_from_location()
1124
 */
1125
function list_entities_location($location, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
1126
	elgg_deprecated_notice('list_entities_location() was deprecated. Use elgg_list_entities_from_metadata()', 1.8);
1127
1128
	return list_entities_from_metadata('location', $location, $type, $subtype, $owner_guid, $limit, $fullview, $listtypetoggle, $navigation);
1129
}
1130
1131
/**
1132
 * Return entities within a given geographic area.
1133
 *
1134
 * @param float     $lat            Latitude
1135
 * @param float     $long           Longitude
1136
 * @param float     $radius         The radius
1137
 * @param string    $type           The type of entity (eg "user", "object" etc)
1138
 * @param string    $subtype        The arbitrary subtype of the entity
1139
 * @param int       $owner_guid     The GUID of the owning user
1140
 * @param string    $order_by       The field to order by; by default, time_created desc
1141
 * @param int       $limit          The number of entities to return; 10 by default
1142
 * @param int       $offset         The indexing offset, 0 by default
1143
 * @param boolean   $count          Count entities
1144
 * @param int       $site_guid      Site GUID. 0 for current, -1 for any
1145
 * @param int|array $container_guid Container GUID
1146
 *
1147
 * @return array A list of entities.
1148
 * @deprecated 1.8 Use elgg_get_entities_from_location()
1149
 */
1150 View Code Duplication
function get_entities_in_area($lat, $long, $radius, $type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = NULL) {
1151
	elgg_deprecated_notice('get_entities_in_area() was deprecated by elgg_get_entities_from_location()!', 1.8);
1152
1153
	$options = array();
1154
1155
	$options['latitude'] = $lat;
1156
	$options['longitude'] = $long;
1157
	$options['distance'] = $radius;
1158
1159
	// set container_guid to owner_guid to emulate old functionality
1160
	if ($owner_guid != "") {
1161
		if (is_null($container_guid)) {
1162
			$container_guid = $owner_guid;
1163
		}
1164
	}
1165
1166
	if ($type) {
1167
		$options['types'] = $type;
1168
	}
1169
1170
	if ($subtype) {
1171
		$options['subtypes'] = $subtype;
1172
	}
1173
1174
	if ($owner_guid) {
1175
		if (is_array($owner_guid)) {
1176
			$options['owner_guids'] = $owner_guid;
1177
		} else {
1178
			$options['owner_guid'] = $owner_guid;
1179
		}
1180
	}
1181
1182
	if ($container_guid) {
1183
		if (is_array($container_guid)) {
1184
			$options['container_guids'] = $container_guid;
1185
		} else {
1186
			$options['container_guid'] = $container_guid;
1187
		}
1188
	}
1189
1190
	$options['limit'] = $limit;
1191
1192
	if ($offset) {
1193
		$options['offset'] = $offset;
1194
	}
1195
1196
	if ($order_by) {
1197
		$options['order_by'];
1198
	}
1199
1200
	if ($site_guid) {
1201
		$options['site_guid'];
1202
	}
1203
1204
	if ($count) {
1205
		$options['count'] = $count;
1206
	}
1207
1208
	return elgg_get_entities_from_location($options);
1209
}
1210
1211
/**
1212
 * Return a list of entities suitable for display based on the given search criteria.
1213
 *
1214
 * @see elgg_view_entity_list
1215
 *
1216
 * @deprecated 1.8 Use elgg_list_entities_from_metadata
1217
 *
1218
 * @param mixed  $meta_name      Metadata name to search on
1219
 * @param mixed  $meta_value     The value to match, optionally
1220
 * @param string $entity_type    The type of entity to look for, eg 'site' or 'object'
1221
 * @param string $entity_subtype The subtype of the entity
1222
 * @param int    $owner_guid     Owner GUID
1223
 * @param int    $limit          Number of entities to display per page
1224
 * @param bool   $fullview       WDisplay the full view (default: true)
1225
 * @param bool   $listtypetoggle Allow users to toggle to the gallery view. Default: true
1226
 * @param bool   $pagination     Display pagination? Default: true
1227
 * @param bool   $case_sensitive Case sensitive metadata names?
1228
 *
1229
 * @return string
1230
 *
1231
 * @return string A list of entities suitable for display
1232
 */
1233
function list_entities_from_metadata($meta_name, $meta_value = "", $entity_type = ELGG_ENTITIES_ANY_VALUE, $entity_subtype = ELGG_ENTITIES_ANY_VALUE, $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true, $case_sensitive = true) {
1234
1235
	elgg_deprecated_notice('list_entities_from_metadata() was deprecated by elgg_list_entities_from_metadata()!', 1.8);
1236
1237
	$offset = (int)get_input('offset');
1238
	$limit = (int)$limit;
1239
	$options = array(
1240
		'metadata_name' => $meta_name,
1241
		'metadata_value' => $meta_value,
1242
		'type' => $entity_type,
1243
		'subtype' => $entity_subtype,
1244
		'limit' => $limit,
1245
		'offset' => $offset,
1246
		'count' => TRUE,
1247
		'metadata_case_sensitive' => $case_sensitive
1248
	);
1249
1250
	// previous function allowed falsy $owner_guid for anything
1251
	if ($owner_guid) {
1252
		$options['owner_guid'] = $owner_guid;
1253
	}
1254
1255
	$count = elgg_get_entities_from_metadata($options);
1256
1257
	$options['count'] = FALSE;
1258
	$entities = elgg_get_entities_from_metadata($options);
1259
1260
	return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle, $pagination);
1261
}
1262
1263
/**
1264
 * Returns a viewable list of entities based on the given search criteria.
1265
 *
1266
 * @see elgg_view_entity_list
1267
 *
1268
 * @param array  $meta_array     Array of 'name' => 'value' pairs
1269
 * @param string $entity_type    The type of entity to look for, eg 'site' or 'object'
1270
 * @param string $entity_subtype The subtype of the entity.
1271
 * @param int    $owner_guid     Owner GUID
1272
 * @param int    $limit          Limit
1273
 * @param bool   $fullview       WDisplay the full view (default: true)
1274
 * @param bool   $listtypetoggle Allow users to toggle to the gallery view. Default: true
1275
 * @param bool   $pagination     Display pagination? Default: true
1276
 *
1277
 * @return string List of \ElggEntities suitable for display
1278
 *
1279
 * @deprecated 1.8 Use elgg_list_entities_from_metadata() instead
1280
 */
1281
function list_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
1282
	elgg_deprecated_notice(elgg_echo('deprecated:function', array(
1283
		'list_entities_from_metadata_multi', 'elgg_get_entities_from_metadata')), 1.8);
1284
1285
	$offset = (int)get_input('offset');
1286
	$limit = (int)$limit;
1287
	$count = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", 0, true);
1288
	$entities = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", 0, false);
1289
1290
	return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle, $pagination);
0 ignored issues
show
It seems like $entities defined by get_entities_from_metada... $offset, '', 0, false) on line 1288 can also be of type integer; however, elgg_view_entity_list() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
It seems like $count defined by get_entities_from_metada..., $offset, '', 0, true) on line 1287 can also be of type integer; however, elgg_view_entity_list() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
1291
}
1292
1293
/**
1294
 * Deprecated by elgg_register_menu_item(). Set $menu_name to 'page'.
1295
 *
1296
 * @see elgg_register_menu_item()
1297
 * @deprecated 1.8 Use the new menu system
1298
 *
1299
 * @param string  $label    The label
1300
 * @param string  $link     The link
1301
 * @param string  $group    The group to store item in
1302
 * @param boolean $onclick  Add a confirmation when clicked?
1303
 * @param boolean $selected Is menu item selected
1304
 *
1305
 * @return bool
1306
 */
1307
function add_submenu_item($label, $link, $group = 'default', $onclick = false, $selected = NULL) {
1308
	elgg_deprecated_notice('add_submenu_item was deprecated by elgg_register_menu_item', 1.8);
1309
1310
	// submenu items were added in the page setup hook usually by checking
1311
	// the context.  We'll pass in the current context here, which will
1312
	// emulate that effect.
1313
	// if context == 'main' (default) it probably means they always wanted
1314
	// the menu item to show up everywhere.
1315
	$context = elgg_get_context();
1316
1317
	if ($context == 'main') {
1318
		$context = 'all';
1319
	}
1320
1321
	$item = array('name' => $label, 'text' => $label, 'href' => $link, 'context' => $context,
1322
		'section' => $group,);
1323
1324
	if ($selected) {
1325
		$item['selected'] = true;
1326
	}
1327
1328
	if ($onclick) {
1329
		$js = "onclick=\"javascript:return confirm('" . elgg_echo('deleteconfirm') . "')\"";
1330
		$item['vars'] = array('js' => $js);
1331
	}
1332
1333
	return elgg_register_menu_item('page', $item);
1334
}
1335
1336
/**
1337
 * Remove an item from submenu by label
1338
 *
1339
 * @deprecated 1.8 Use the new menu system
1340
 * @see elgg_unregister_menu_item()
1341
 *
1342
 * @param string $label The item label
1343
 * @param string $group The submenu group (default "a")
1344
 * @return bool whether the item was removed or not
1345
 * @since 1.7.8
1346
 */
1347
function remove_submenu_item($label, $group = 'a') {
1348
	elgg_deprecated_notice('remove_submenu_item was deprecated by elgg_unregister_menu_item', 1.8);
1349
1350
	return elgg_unregister_menu_item('page', $label);
1351
}
1352
1353
/**
1354
 * Use elgg_view_menu(). Set $menu_name to 'owner_block'.
1355
 *
1356
 * @see elgg_view_menu()
1357
 * @deprecated 1.8 Use the new menu system. elgg_view_menu()
1358
 *
1359
 * @return string
1360
 */
1361
function get_submenu() {
1362
	elgg_deprecated_notice("get_submenu() has been deprecated by elgg_view_menu()", 1.8);
1363
	$owner = elgg_get_page_owner_entity();
1364
	return elgg_view_menu('owner_block', array('entity' => $owner,
1365
		'class' => 'elgg-menu-owner-block',));
1366
}
1367
1368
/**
1369
 * Adds an item to the site-wide menu.
1370
 *
1371
 * You can obtain the menu array by calling {@link get_register('menu')}
1372
 *
1373
 * @param string $menu_name     The name of the menu item
1374
 * @param string $menu_url      The URL of the page
1375
 * @param array  $menu_children Optionally, an array of submenu items (not used)
1376
 * @param string $context       (not used)
1377
 *
1378
 * @return true|false Depending on success
1379
 * @deprecated 1.8 use elgg_register_menu_item() for the menu 'site'
1380
 */
1381
function add_menu($menu_name, $menu_url, $menu_children = array(), $context = "") {
1382
	elgg_deprecated_notice('add_menu() deprecated by elgg_register_menu_item()', 1.8);
1383
1384
	return elgg_register_menu_item('site', array('name' => $menu_name, 'text' => $menu_name,
1385
		'href' => $menu_url,));
1386
}
1387
1388
/**
1389
 * Removes an item from the menu register
1390
 *
1391
 * @param string $menu_name The name of the menu item
1392
 *
1393
 * @return true|false Depending on success
1394
 * @deprecated 1.8 Use the new menu system
1395
 */
1396
function remove_menu($menu_name) {
1397
	elgg_deprecated_notice("remove_menu() deprecated by elgg_unregister_menu_item()", 1.8);
1398
	return elgg_unregister_menu_item('site', $menu_name);
1399
}
1400
1401
/**
1402
 * When given a title, returns a version suitable for inclusion in a URL
1403
 *
1404
 * @param string $title The title
1405
 *
1406
 * @return string The optimised title
1407
 * @deprecated 1.8 Use elgg_get_friendly_title()
1408
 */
1409
function friendly_title($title) {
1410
	elgg_deprecated_notice('friendly_title was deprecated by elgg_get_friendly_title', 1.8);
1411
	return elgg_get_friendly_title($title);
1412
}
1413
1414
/**
1415
 * Displays a UNIX timestamp in a friendly way (eg "less than a minute ago")
1416
 *
1417
 * @param int $time A UNIX epoch timestamp
1418
 *
1419
 * @return string The friendly time
1420
 * @deprecated 1.8 Use elgg_view_friendly_time()
1421
 */
1422
function friendly_time($time) {
1423
	elgg_deprecated_notice('friendly_time was deprecated by elgg_view_friendly_time', 1.8);
1424
	return elgg_view_friendly_time($time);
1425
}
1426
1427
/**
1428
 * Filters a string into an array of significant words
1429
 *
1430
 * @deprecated 1.8 Don't use this.
1431
 *
1432
 * @param string $string A string
1433
 *
1434
 * @return array
1435
 */
1436
function filter_string($string) {
1437
	elgg_deprecated_notice('filter_string() was deprecated!', 1.8);
1438
1439
	// Convert it to lower and trim
1440
	$string = strtolower($string);
1441
	$string = trim($string);
1442
1443
	// Remove links and email addresses
1444
	// match protocol://address/path/file.extension?some=variable&another=asf%
1445
	$string = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}" . "[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu", " ", $string);
1446
1447
	// match www.something.domain/path/file.extension?some=variable&another=asf%
1448
	$string = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}" . "[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu", " ", $string);
1449
1450
	// match name@address
1451
	$string = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]" . "*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/iu", " ", $string);
1452
1453
	// Sanitise the string; remove unwanted characters
1454
	$string = preg_replace('/\W/ui', ' ', $string);
1455
1456
	// Explode it into an array
1457
	$terms = explode(' ', $string);
1458
1459
	// Remove any blacklist terms
1460
	//$terms = array_filter($terms, 'remove_blacklist');
1461
1462
	return $terms;
1463
}
1464
1465
/**
1466
 * Returns true if the word in $input is considered significant
1467
 *
1468
 * @deprecated 1.8 Don't use this.
1469
 *
1470
 * @param string $input A word
1471
 *
1472
 * @return true|false
1473
 */
1474
function remove_blacklist($input) {
1475
	elgg_deprecated_notice('remove_blacklist() was deprecated!', 1.8);
1476
1477
	global $CONFIG;
1478
1479
	if (!is_array($CONFIG->wordblacklist)) {
1480
		return $input;
1481
	}
1482
1483
	if (strlen($input) < 3 || in_array($input, $CONFIG->wordblacklist)) {
1484
		return false;
1485
	}
1486
1487
	return true;
1488
}
1489
1490
/**
1491
 * Gets the guid of the entity that owns the current page.
1492
 *
1493
 * @deprecated 1.8  Use elgg_get_page_owner_guid()
1494
 *
1495
 * @return int The current page owner guid (0 if none).
1496
 */
1497
function page_owner() {
1498
	elgg_deprecated_notice('page_owner() was deprecated by elgg_get_page_owner_guid().', 1.8);
1499
	return elgg_get_page_owner_guid();
1500
}
1501
1502
/**
1503
 * Gets the owner entity for the current page.
1504
 *
1505
 * @deprecated 1.8  Use elgg_get_page_owner_entity()
1506
 * @return \ElggEntity|false The current page owner or false if none.
1507
 */
1508
function page_owner_entity() {
1509
	elgg_deprecated_notice('page_owner_entity() was deprecated by elgg_get_page_owner_entity().', 1.8);
1510
	return elgg_get_page_owner_entity();
1511
}
1512
1513
/**
1514
 * Registers a page owner handler function
1515
 *
1516
 * @param string $functionname The callback function
1517
 *
1518
 * @deprecated 1.8  Use the 'page_owner', 'system' plugin hook
1519
 * @return void
1520
 */
1521
function add_page_owner_handler($functionname) {
1522
	elgg_deprecated_notice("add_page_owner_handler() was deprecated by the plugin hook 'page_owner', 'system'.", 1.8);
1523
}
1524
1525
/**
1526
 * Set a page owner entity
1527
 *
1528
 * @param int $entitytoset The GUID of the entity
1529
 *
1530
 * @deprecated 1.8  Use elgg_set_page_owner_guid()
1531
 * @return void
1532
 */
1533
function set_page_owner($entitytoset = -1) {
1534
	elgg_deprecated_notice('set_page_owner() was deprecated by elgg_set_page_owner_guid().', 1.8);
1535
	elgg_set_page_owner_guid($entitytoset);
1536
}
1537
1538
/**
1539
 * Sets the functional context of a page
1540
 *
1541
 * @deprecated 1.8  Use elgg_set_context()
1542
 *
1543
 * @param string $context The context of the page
1544
 *
1545
 * @return mixed Either the context string, or false on failure
1546
 */
1547
function set_context($context) {
1548
	elgg_deprecated_notice('set_context() was deprecated by elgg_set_context().', 1.8);
1549
	elgg_set_context($context);
1550
	if (empty($context)) {
1551
		return false;
1552
	}
1553
	return $context;
1554
}
1555
1556
/**
1557
 * Returns the functional context of a page
1558
 *
1559
 * @deprecated 1.8  Use elgg_get_context()
1560
 *
1561
 * @return string The context, or 'main' if no context has been provided
1562
 */
1563
function get_context() {
1564
	elgg_deprecated_notice('get_context() was deprecated by elgg_get_context().', 1.8);
1565
	return elgg_get_context();
1566
1567
	// @todo - used to set context based on calling script
1568
	// $context = get_plugin_name(true)
1569
}
1570
1571
/**
1572
 * Returns a list of plugins to load, in the order that they should be loaded.
1573
 *
1574
 * @deprecated 1.8 Use elgg_get_plugin_ids_in_dir() or elgg_get_plugins()
1575
 *
1576
 * @return array List of plugins
1577
 */
1578
function get_plugin_list() {
1579
	elgg_deprecated_notice('get_plugin_list() is deprecated by elgg_get_plugin_ids_in_dir() or elgg_get_plugins()', 1.8);
1580
1581
	$plugins = elgg_get_plugins('any');
1582
1583
	$list = array();
1584
	if ($plugins) {
1585
		foreach ($plugins as $i => $plugin) {
1586
			// in <=1.7 this returned indexed by multiples of 10.
1587
			// uh...sure...why not.
1588
			$index = ($i + 1) * 10;
1589
			$list[$index] = $plugin->getID();
1590
		}
1591
	}
1592
1593
	return $list;
1594
}
1595
1596
/**
1597
 * Regenerates the list of known plugins and saves it to the current site
1598
 *
1599
 * Important: You should regenerate simplecache and the viewpath cache after executing this function
1600
 * otherwise you may experience view display artifacts. Do this with the following code:
1601
 *
1602
 * 		elgg_regenerate_simplecache();
1603
 *		elgg_reset_system_cache();
1604
 *
1605
 * @deprecated 1.8 Use elgg_generate_plugin_entities() and elgg_set_plugin_priorities()
1606
 *
1607
 * @param array $pluginorder Optionally, a list of existing plugins and their orders
1608
 *
1609
 * @return array The new list of plugins and their orders
1610
 */
1611
function regenerate_plugin_list($pluginorder = FALSE) {
1612
	$msg = 'regenerate_plugin_list() is (sorta) deprecated by elgg_generate_plugin_entities() and'
1613
			. ' elgg_set_plugin_priorities().';
1614
	elgg_deprecated_notice($msg, 1.8);
1615
1616
	// they're probably trying to set it?
1617
	if ($pluginorder) {
1618
		if (_elgg_generate_plugin_entities()) {
1619
			// sort the plugins by the index numerically since we used
1620
			// weird indexes in the old system.
1621
			ksort($pluginorder, SORT_NUMERIC);
1622
			return _elgg_set_plugin_priorities($pluginorder);
1623
		}
1624
		return false;
1625
	} else {
1626
		// they're probably trying to regenerate from disk?
1627
		return _elgg_generate_plugin_entities();
1628
	}
1629
}
1630
1631
/**
1632
 * Get the name of the most recent plugin to be called in the
1633
 * call stack (or the plugin that owns the current page, if any).
1634
 *
1635
 * i.e., if the last plugin was in /mod/foobar/, get_plugin_name would return foo_bar.
1636
 *
1637
 * @deprecated 1.8 Use elgg_get_calling_plugin_id()
1638
 *
1639
 * @param boolean $mainfilename If set to true, this will instead determine the
1640
 *                              context from the main script filename called by
1641
 *                              the browser. Default = false.
1642
 *
1643
 * @return string|false Plugin name, or false if no plugin name was called
1644
 */
1645
function get_plugin_name($mainfilename = false) {
1646
	elgg_deprecated_notice('get_plugin_name() is deprecated by elgg_get_calling_plugin_id()', 1.8);
1647
1648
	return elgg_get_calling_plugin_id($mainfilename);
1649
}
1650
1651
/**
1652
 * Load and parse a plugin manifest from a plugin XML file.
1653
 *
1654
 * @deprecated 1.8 Use \ElggPlugin->getManifest()
1655
 *
1656
 * @param string $plugin Plugin name.
1657
 * @return array of values
1658
 */
1659
function load_plugin_manifest($plugin) {
1660
	elgg_deprecated_notice('load_plugin_manifest() is deprecated by \ElggPlugin->getManifest()', 1.8);
1661
1662
	$xml_file = elgg_get_plugins_path() . "$plugin/manifest.xml";
1663
1664
	try {
1665
		$manifest = new \ElggPluginManifest($xml_file, $plugin);
1666
	} catch(Exception $e) {
1667
		return false;
1668
	}
1669
1670
	return $manifest->getManifest();
1671
}
1672
1673
/**
1674
 * This function checks a plugin manifest 'elgg_version' value against the current install
1675
 * returning TRUE if the elgg_version is >= the current install's version.
1676
 *
1677
 * @deprecated 1.8 Use \ElggPlugin->canActivate()
1678
 *
1679
 * @param string $manifest_elgg_version_string The build version (eg 2009010201).
1680
 * @return bool
1681
 */
1682
function check_plugin_compatibility($manifest_elgg_version_string) {
1683
	elgg_deprecated_notice('check_plugin_compatibility() is deprecated by \ElggPlugin->canActivate()', 1.8);
1684
1685
	$version = elgg_get_version();
1686
1687
	if (strpos($manifest_elgg_version_string, '.') === false) {
1688
		// Using version
1689
		$req_version = (int)$manifest_elgg_version_string;
1690
1691
		return ($version >= $req_version);
1692
	}
1693
1694
	return false;
1695
}
1696
1697
/**
1698
 * Shorthand function for finding the plugin settings.
1699
 *
1700
 * @deprecated 1.8 Use elgg_get_calling_plugin_entity() or elgg_get_plugin_from_id()
1701
 *
1702
 * @param string $plugin_id Optional plugin id, if not specified
1703
 *                          then it is detected from where you are calling.
1704
 *
1705
 * @return mixed
1706
 */
1707 View Code Duplication
function find_plugin_settings($plugin_id = null) {
1708
	elgg_deprecated_notice('find_plugin_setting() is deprecated by elgg_get_calling_plugin_entity() or elgg_get_plugin_from_id()', 1.8);
1709
	if ($plugin_id) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $plugin_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...
1710
		return elgg_get_plugin_from_id($plugin_id);
1711
	} else {
1712
		return elgg_get_calling_plugin_entity();
1713
	}
1714
}
1715
1716
/**
1717
 * Return an array of installed plugins.
1718
 *
1719
 * @deprecated 1.8 use elgg_get_plugins()
1720
 *
1721
 * @param string $status any|enabled|disabled
1722
 * @return array
1723
 */
1724
function get_installed_plugins($status = 'all') {
1725
	global $CONFIG;
1726
1727
	elgg_deprecated_notice('get_installed_plugins() was deprecated by elgg_get_plugins()', 1.8);
1728
1729
	$plugins = elgg_get_plugins($status);
1730
1731
	if (!$plugins) {
1732
		return array();
1733
	}
1734
1735
	$installed_plugins = array();
1736
1737
	foreach ($plugins as $plugin) {
1738
		if (!$plugin->isValid()) {
1739
			continue;
1740
		}
1741
1742
		$include = true;
1743
1744
		if ($status == 'enabled' && !$plugin->isActive()) {
1745
			$include = false;
1746
		} elseif ($status == 'disabled' && $plugin->isActive()) {
1747
			$include = true;
1748
		}
1749
1750
		if ($include) {
1751
			$installed_plugins[$plugin->getID()] = array(
1752
				'active' => $plugin->isActive(),
1753
				'manifest' => $plugin->getManifest()->getManifest()
1754
			);
1755
		}
1756
	}
1757
1758
	return $installed_plugins;
1759
}
1760
1761
/**
1762
 * Enable a plugin for a site (default current site)
1763
 *
1764
 * Important: You should regenerate simplecache and the viewpath cache after executing this function
1765
 * otherwise you may experience view display artifacts. Do this with the following code:
1766
 *
1767
 * 		elgg_regenerate_simplecache();
1768
 *		elgg_reset_system_cache();
1769
 *
1770
 * @deprecated 1.8 Use \ElggPlugin->activate()
1771
 *
1772
 * @param string $plugin    The plugin name.
1773
 * @param int    $site_guid The site id, if not specified then this is detected.
1774
 *
1775
 * @return array
1776
 * @throws InvalidClassException
1777
 */
1778
function enable_plugin($plugin, $site_guid = null) {
1779
	elgg_deprecated_notice('enable_plugin() was deprecated by \ElggPlugin->activate()', 1.8);
1780
1781
	$plugin = sanitise_string($plugin);
1782
1783
	$site_guid = (int) $site_guid;
1784
	if (!$site_guid) {
1785
		$site = get_config('site');
1786
		$site_guid = $site->guid;
1787
	}
1788
1789
	try {
1790
		$plugin = new \ElggPlugin($plugin);
1791
	} catch(Exception $e) {
1792
		return false;
1793
	}
1794
1795
	if (!$plugin->canActivate($site_guid)) {
1796
		return false;
1797
	}
1798
1799
	return $plugin->activate($site_guid);
1800
}
1801
1802
/**
1803
 * Disable a plugin for a site (default current site)
1804
 *
1805
 * Important: You should regenerate simplecache and the viewpath cache after executing this function
1806
 * otherwise you may experience view display artifacts. Do this with the following code:
1807
 *
1808
 * 		elgg_regenerate_simplecache();
1809
 *		elgg_reset_system_cache();
1810
 *
1811
 * @deprecated 1.8 Use \ElggPlugin->deactivate()
1812
 *
1813
 * @param string $plugin    The plugin name.
1814
 * @param int    $site_guid The site id, if not specified then this is detected.
1815
 *
1816
 * @return bool
1817
 * @throws InvalidClassException
1818
 */
1819
function disable_plugin($plugin, $site_guid = 0) {
1820
	elgg_deprecated_notice('disable_plugin() was deprecated by \ElggPlugin->deactivate()', 1.8);
1821
1822
	$plugin = sanitise_string($plugin);
1823
1824
	$site_guid = (int) $site_guid;
1825
	if (!$site_guid) {
1826
		$site = get_config('site');
1827
		$site_guid = $site->guid;
1828
	}
1829
1830
	try {
1831
		$plugin = new \ElggPlugin($plugin);
1832
	} catch(Exception $e) {
1833
		return false;
1834
	}
1835
1836
	return $plugin->deactivate($site_guid);
1837
}
1838
1839
/**
1840
 * Return whether a plugin is enabled or not.
1841
 *
1842
 * @deprecated 1.8 Use elgg_is_active_plugin()
1843
 *
1844
 * @param string $plugin    The plugin name.
1845
 * @param int    $site_guid The site id, if not specified then this is detected.
1846
 *
1847
 * @return bool
1848
 */
1849
function is_plugin_enabled($plugin, $site_guid = 0) {
1850
	elgg_deprecated_notice('is_plugin_enabled() was deprecated by elgg_is_active_plugin()', 1.8);
1851
	return elgg_is_active_plugin($plugin, $site_guid);
1852
}
1853
1854
/**
1855
 * Get entities based on their private data.
1856
 *
1857
 * @param string  $name           The name of the setting
1858
 * @param string  $value          The value of the setting
1859
 * @param string  $type           The type of entity (eg "user", "object" etc)
1860
 * @param string  $subtype        The arbitrary subtype of the entity
1861
 * @param int     $owner_guid     The GUID of the owning user
1862
 * @param string  $order_by       The field to order by; by default, time_created desc
1863
 * @param int     $limit          The number of entities to return; 10 by default
1864
 * @param int     $offset         The indexing offset, 0 by default
1865
 * @param boolean $count          Return a count of entities
1866
 * @param int     $site_guid      The site to get entities for. 0 for current, -1 for any
1867
 * @param mixed   $container_guid The container(s) GUIDs
1868
 *
1869
 * @return array A list of entities.
1870
 * @deprecated 1.8 Use elgg_get_entities_from_private_settings()
1871
 */
1872 View Code Duplication
function get_entities_from_private_setting($name = "", $value = "", $type = "", $subtype = "",
1873
$owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0,
1874
$container_guid = null) {
1875
	elgg_deprecated_notice('get_entities_from_private_setting() was deprecated by elgg_get_entities_from_private_setting()!', 1.8);
1876
1877
	$options = array();
1878
1879
	$options['private_setting_name'] = $name;
1880
	$options['private_setting_value'] = $value;
1881
1882
	// set container_guid to owner_guid to emulate old functionality
1883
	if ($owner_guid != "") {
1884
		if (is_null($container_guid)) {
1885
			$container_guid = $owner_guid;
1886
		}
1887
	}
1888
1889
	if ($type) {
1890
		$options['types'] = $type;
1891
	}
1892
1893
	if ($subtype) {
1894
		$options['subtypes'] = $subtype;
1895
	}
1896
1897
	if ($owner_guid) {
1898
		if (is_array($owner_guid)) {
1899
			$options['owner_guids'] = $owner_guid;
1900
		} else {
1901
			$options['owner_guid'] = $owner_guid;
1902
		}
1903
	}
1904
1905
	if ($container_guid) {
1906
		if (is_array($container_guid)) {
1907
			$options['container_guids'] = $container_guid;
1908
		} else {
1909
			$options['container_guid'] = $container_guid;
1910
		}
1911
	}
1912
1913
	$options['limit'] = $limit;
1914
1915
	if ($offset) {
1916
		$options['offset'] = $offset;
1917
	}
1918
1919
	if ($order_by) {
1920
		$options['order_by'];
1921
	}
1922
1923
	if ($site_guid) {
1924
		$options['site_guid'];
1925
	}
1926
1927
	if ($count) {
1928
		$options['count'] = $count;
1929
	}
1930
1931
	return elgg_get_entities_from_private_settings($options);
1932
}
1933
1934
/**
1935
 * Get entities based on their private data by multiple keys.
1936
 *
1937
 * @param string $name           The name of the setting
1938
 * @param mixed  $type           Entity type
1939
 * @param string $subtype        Entity subtype
1940
 * @param int    $owner_guid     The GUID of the owning user
1941
 * @param string $order_by       The field to order by; by default, time_created desc
1942
 * @param int    $limit          The number of entities to return; 10 by default
1943
 * @param int    $offset         The indexing offset, 0 by default
1944
 * @param bool   $count          Count entities
1945
 * @param int    $site_guid      Site GUID. 0 for current, -1 for any.
1946
 * @param mixed  $container_guid Container GUID
1947
 *
1948
 * @return array A list of entities.
1949
 * @deprecated 1.8 Use elgg_get_entities_from_private_settings()
1950
 */
1951
function get_entities_from_private_setting_multi(array $name, $type = "", $subtype = "",
1952
$owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false,
1953
$site_guid = 0, $container_guid = null) {
1954
1955
	elgg_deprecated_notice('get_entities_from_private_setting_multi() was deprecated by elgg_get_entities_from_private_settings()!', 1.8);
1956
1957
	$options = array();
1958
1959
	$pairs = array();
1960
	foreach ($name as $setting_name => $setting_value) {
1961
		$pairs[] = array('name' => $setting_name, 'value' => $setting_value);
1962
	}
1963
	$options['private_setting_name_value_pairs'] = $pairs;
1964
1965
	// set container_guid to owner_guid to emulate old functionality
1966
	if ($owner_guid != "") {
1967
		if (is_null($container_guid)) {
1968
			$container_guid = $owner_guid;
1969
		}
1970
	}
1971
1972
	if ($type) {
1973
		$options['types'] = $type;
1974
	}
1975
1976
	if ($subtype) {
1977
		$options['subtypes'] = $subtype;
1978
	}
1979
1980
	if ($owner_guid) {
1981
		if (is_array($owner_guid)) {
1982
			$options['owner_guids'] = $owner_guid;
1983
		} else {
1984
			$options['owner_guid'] = $owner_guid;
1985
		}
1986
	}
1987
1988
	if ($container_guid) {
1989
		if (is_array($container_guid)) {
1990
			$options['container_guids'] = $container_guid;
1991
		} else {
1992
			$options['container_guid'] = $container_guid;
1993
		}
1994
	}
1995
1996
	$options['limit'] = $limit;
1997
1998
	if ($offset) {
1999
		$options['offset'] = $offset;
2000
	}
2001
2002
	if ($order_by) {
2003
		$options['order_by'];
2004
	}
2005
2006
	if ($site_guid) {
2007
		$options['site_guid'];
2008
	}
2009
2010
	if ($count) {
2011
		$options['count'] = $count;
2012
	}
2013
2014
	return elgg_get_entities_from_private_settings($options);
2015
}
2016
2017
/**
2018
 * Returns a viewable list of entities by relationship
2019
 *
2020
 * @see elgg_view_entity_list
2021
 *
2022
 * @deprecated 1.8 Use elgg_list_entities_from_relationship()
2023
 *
2024
 * @param string $relationship The relationship eg "friends_of"
2025
 * @param int $relationship_guid The guid of the entity to use query
2026
 * @param bool $inverse_relationship Reverse the normal function of the query to instead say "give me all entities for whome $relationship_guid is a $relationship of"
2027
 * @param string $type The type of entity (eg 'object')
2028
 * @param string $subtype The entity subtype
2029
 * @param int $owner_guid The owner (default: all)
2030
 * @param int $limit The number of entities to display on a page
2031
 * @param true|false $fullview Whether or not to display the full view (default: true)
2032
 * @param true|false $viewtypetoggle Whether or not to allow gallery view
0 ignored issues
show
There is no parameter named $viewtypetoggle. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
2033
 * @param true|false $pagination Whether to display pagination (default: true)
2034
 * @param bool $order_by SQL order by clause
2035
 * @return string The viewable list of entities
2036
 */
2037
function list_entities_from_relationship($relationship, $relationship_guid,
2038
$inverse_relationship = false, $type = ELGG_ENTITIES_ANY_VALUE,
2039
$subtype = ELGG_ENTITIES_ANY_VALUE, $owner_guid = 0, $limit = 10,
2040
$fullview = true, $listtypetoggle = false, $pagination = true, $order_by = '') {
2041
2042
	elgg_deprecated_notice("list_entities_from_relationship was deprecated by elgg_list_entities_from_relationship()!", 1.8);
2043
	return elgg_list_entities_from_relationship(array(
2044
		'relationship' => $relationship,
2045
		'relationship_guid' => $relationship_guid,
2046
		'inverse_relationship' => $inverse_relationship,
2047
		'type' => $type,
2048
		'subtype' => $subtype,
2049
		'owner_guid' => $owner_guid,
2050
		'order_by' => $order_by,
2051
		'limit' => $limit,
2052
		'full_view' => $fullview,
2053
		'list_type_toggle' => $listtypetoggle,
2054
		'pagination' => $pagination,
2055
	));
2056
}
2057
2058
/**
2059
 * Gets the number of entities by a the number of entities related to them in a particular way.
2060
 * This is a good way to get out the users with the most friends, or the groups with the
2061
 * most members.
2062
 *
2063
 * @deprecated 1.8 Use elgg_get_entities_from_relationship_count()
2064
 *
2065
 * @param string $relationship         The relationship eg "friends_of"
2066
 * @param bool   $inverse_relationship Inverse relationship owners
2067
 * @param string $type                 The type of entity (default: all)
2068
 * @param string $subtype              The entity subtype (default: all)
2069
 * @param int    $owner_guid           The owner of the entities (default: none)
2070
 * @param int    $limit                Limit
2071
 * @param int    $offset               Offset
2072
 * @param bool   $count                Return a count instead of entities
2073
 * @param int    $site_guid            Site GUID
2074
 *
2075
 * @return array|int|false An array of entities, or the number of entities, or false on failure
2076
 */
2077
function get_entities_by_relationship_count($relationship, $inverse_relationship = true, $type = "",
2078
$subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
2079
	elgg_deprecated_notice('get_entities_by_relationship_count() is deprecated by elgg_get_entities_from_relationship_count()', 1.8);
2080
2081
	$options = array();
2082
2083
	$options['relationship'] = $relationship;
2084
2085
	// this used to default to true, which is wrong.
2086
	// flip it for the new function
2087
	$options['inverse_relationship'] = !$inverse_relationship;
2088
2089
	if ($type) {
2090
		$options['types'] = $type;
2091
	}
2092
2093
	if ($subtype) {
2094
		$options['subtypes'] = $subtype;
2095
	}
2096
2097
	if ($owner_guid) {
2098
		$options['owner_guid'] = $owner_guid;
2099
	}
2100
2101
	$options['limit'] = $limit;
2102
2103
	if ($offset) {
2104
		$options['offset'] = $offset;
2105
	}
2106
2107
	if ($site_guid) {
2108
		$options['site_guid'];
2109
	}
2110
2111
	if ($count) {
2112
		$options['count'] = $count;
2113
	}
2114
2115
	return elgg_get_entities_from_relationship_count($options);
2116
}
2117
2118
/**
2119
 * Displays a human-readable list of entities
2120
 *
2121
 * @deprecated 1.8 Use elgg_list_entities_from_relationship_count()
2122
 *
2123
 * @param string $relationship         The relationship eg "friends_of"
2124
 * @param bool   $inverse_relationship Inverse relationship owners
2125
 * @param string $type                 The type of entity (eg 'object')
2126
 * @param string $subtype              The entity subtype
2127
 * @param int    $owner_guid           The owner (default: all)
2128
 * @param int    $limit                The number of entities to display on a page
2129
 * @param bool   $fullview             Whether or not to display the full view (default: true)
2130
 * @param bool   $listtypetoggle       Whether or not to allow gallery view
2131
 * @param bool   $pagination           Whether to display pagination (default: true)
2132
 *
2133
 * @return string The viewable list of entities
2134
 */
2135
function list_entities_by_relationship_count($relationship, $inverse_relationship = true,
2136
$type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true,
2137
$listtypetoggle = false, $pagination = true) {
2138
2139
	elgg_deprecated_notice('list_entities_by_relationship_count() was deprecated by elgg_list_entities_from_relationship_count()', 1.8);
2140
2141
	$options = array();
2142
2143
	$options['relationship'] = $relationship;
2144
2145
	// this used to default to true, which is wrong.
2146
	// flip it for the new function
2147
	$options['inverse_relationship'] = !$inverse_relationship;
2148
2149
	if ($type) {
2150
		$options['types'] = $type;
2151
	}
2152
2153
	if ($subtype) {
2154
		$options['subtypes'] = $subtype;
2155
	}
2156
2157
	if ($owner_guid) {
2158
		$options['owner_guid'] = $owner_guid;
2159
	}
2160
2161
	$options['limit'] = $limit;
2162
2163
	$options['full_view'] = $fullview;
2164
2165
	return elgg_list_entities_from_relationship_count($options);
2166
}
2167
2168
/**
2169
 * Gets the number of entities by a the number of entities related to
2170
 * them in a particular way also constrained by metadata.
2171
 *
2172
 * @deprecated 1.8 Use elgg_get_entities_from_relationship()
2173
 *
2174
 * @param string $relationship         The relationship eg "friends_of"
2175
 * @param int    $relationship_guid    The guid of the entity to use query
2176
 * @param bool   $inverse_relationship Inverse relationship owner
2177
 * @param String $meta_name            The metadata name
2178
 * @param String $meta_value           The metadata value
2179
 * @param string $type                 The type of entity (default: all)
2180
 * @param string $subtype              The entity subtype (default: all)
2181
 * @param int    $owner_guid           The owner of the entities (default: none)
2182
 * @param int    $limit                Limit
2183
 * @param int    $offset               Offset
2184
 * @param bool   $count                Return a count instead of entities
2185
 * @param int    $site_guid            Site GUID
2186
 *
2187
 * @return array|int|false An array of entities, or the number of entities, or false on failure
2188
 */
2189
function get_entities_from_relationships_and_meta($relationship, $relationship_guid,
2190
$inverse_relationship = false, $meta_name = "", $meta_value = "", $type = "",
2191
$subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
2192
2193
	elgg_deprecated_notice('get_entities_from_relationship_and_meta() was deprecated by elgg_get_entities_from_relationship()!', 1.7);
2194
2195
	$options = array();
2196
2197
	$options['relationship'] = $relationship;
2198
	$options['relationship_guid'] = $relationship_guid;
2199
	$options['inverse_relationship'] = $inverse_relationship;
2200
2201
	if ($meta_value) {
2202
		$options['values'] = $meta_value;
2203
	}
2204
2205
	if ($type) {
2206
		$options['types'] = $type;
2207
	}
2208
2209
	if ($subtype) {
2210
		$options['subtypes'] = $subtype;
2211
	}
2212
2213
	if ($owner_guid) {
2214
		$options['owner_guid'] = $owner_guid;
2215
	}
2216
2217
	if ($limit) {
2218
		$options['limit'] = $limit;
2219
	}
2220
2221
	if ($offset) {
2222
		$options['offset'] = $offset;
2223
	}
2224
2225
	if ($site_guid) {
2226
		$options['site_guid'] = $site_guid;
2227
	}
2228
2229
	if ($count) {
2230
		$options['count'] = $count;
2231
	}
2232
2233
	return elgg_get_entities_from_relationship($options);
2234
}
2235
2236
2237
/**
2238
 * Retrieves items from the river. All parameters are optional.
2239
 *
2240
 * @param int|array $subject_guid         Acting entity to restrict to. Default: all
2241
 * @param int|array $object_guid          Entity being acted on to restrict to. Default: all
2242
 * @param string    $subject_relationship If set to a relationship type, this will use
2243
 * 	                                      $subject_guid as the starting point and set the
2244
 *                                        subjects to be all users this
2245
 *                                        entity has this relationship with (eg 'friend').
2246
 *                                        Default: blank
2247
 * @param string    $type                 The type of entity to restrict to. Default: all
2248
 * @param string    $subtype              The subtype of entity to restrict to. Default: all
2249
 * @param string    $action_type          The type of river action to restrict to. Default: all
2250
 * @param int       $limit                The number of items to retrieve. Default: 20
2251
 * @param int       $offset               The page offset. Default: 0
2252
 * @param int       $posted_min           The minimum time period to look at. Default: none
2253
 * @param int       $posted_max           The maximum time period to look at. Default: none
2254
 *
2255
 * @return array|false Depending on success
2256
 * @deprecated 1.8 Use elgg_get_river()
2257
 */
2258
function get_river_items($subject_guid = 0, $object_guid = 0, $subject_relationship = '',
2259
$type = '',	$subtype = '', $action_type = '', $limit = 20, $offset = 0, $posted_min = 0,
2260
$posted_max = 0) {
2261
	elgg_deprecated_notice("get_river_items deprecated by elgg_get_river", 1.8);
2262
2263
	$options = array();
2264
2265
	if ($subject_guid) {
2266
		$options['subject_guid'] = $subject_guid;
2267
	}
2268
2269
	if ($object_guid) {
2270
		$options['object_guid'] = $object_guid;
2271
	}
2272
2273
	if ($subject_relationship) {
2274
		$options['relationship'] = $subject_relationship;
2275
		unset($options['subject_guid']);
2276
		$options['relationship_guid'] = $subject_guid;
2277
	}
2278
2279
	if ($type) {
2280
		$options['type'] = $type;
2281
	}
2282
2283
	if ($subtype) {
2284
		$options['subtype'] = $subtype;
2285
	}
2286
2287
	if ($action_type) {
2288
		$options['action_type'] = $action_type;
2289
	}
2290
2291
	$options['limit'] = $limit;
2292
	$options['offset'] = $offset;
2293
2294
	if ($posted_min) {
2295
		$options['posted_time_lower'] = $posted_min;
2296
	}
2297
2298
	if ($posted_max) {
2299
		$options['posted_time_upper'] = $posted_max;
2300
	}
2301
2302
	return elgg_get_river($options);
2303
}
2304
2305
/**
2306
 * Returns a human-readable version of the river.
2307
 *
2308
 * @param int|array $subject_guid         Acting entity to restrict to. Default: all
2309
 * @param int|array $object_guid          Entity being acted on to restrict to. Default: all
2310
 * @param string    $subject_relationship If set to a relationship type, this will use
2311
 * 	                                      $subject_guid as the starting point and set
2312
 *                                        the subjects to be all users this entity has this
2313
 *                                        relationship with (eg 'friend'). Default: blank
2314
 * @param string    $type                 The type of entity to restrict to. Default: all
2315
 * @param string    $subtype              The subtype of entity to restrict to. Default: all
2316
 * @param string    $action_type          The type of river action to restrict to. Default: all
2317
 * @param int       $limit                The number of items to retrieve. Default: 20
2318
 * @param int       $posted_min           The minimum time period to look at. Default: none
2319
 * @param int       $posted_max           The maximum time period to look at. Default: none
2320
 * @param bool      $pagination           Show pagination?
2321
 *
2322
 * @return string Human-readable river.
2323
 * @deprecated 1.8 Use elgg_list_river()
2324
 */
2325
function elgg_view_river_items($subject_guid = 0, $object_guid = 0, $subject_relationship = '',
2326
$type = '', $subtype = '', $action_type = '', $limit = 20, $posted_min = 0,
2327
$posted_max = 0, $pagination = true) {
2328
	elgg_deprecated_notice("elgg_view_river_items deprecated for elgg_list_river", 1.8);
2329
2330
	$river_items = get_river_items($subject_guid, $object_guid, $subject_relationship,
2331
			$type, $subtype, $action_type, $limit + 1, $posted_min, $posted_max);
2332
2333
	// Get input from outside world and sanitise it
2334
	$offset = (int) get_input('offset', 0);
2335
2336
	// view them
2337
	$params = array(
2338
		'items' => $river_items,
2339
		'count' => count($river_items),
2340
		'offset' => $offset,
2341
		'limit' => $limit,
2342
		'pagination' => $pagination,
2343
		'list-class' => 'elgg-list-river',
2344
	);
2345
2346
	return elgg_view('page/components/list', $params);
2347
}
2348
2349
/**
2350
 * Construct and execute the query required for the activity stream.
2351
 *
2352
 * @deprecated 1.8 This is outdated and uses the systemlog table instead of the river table.
2353
 *                 Don't use it.
2354
 */
2355
function get_activity_stream_data($limit = 10, $offset = 0, $type = "", $subtype = "",
2356
$owner_guid = "", $owner_relationship = "") {
2357
	elgg_deprecated_notice("get_activity_stream_data was deprecated", 1.8);
2358
2359
	global $CONFIG;
2360
2361
	$limit = (int)$limit;
2362
	$offset = (int)$offset;
2363
2364 View Code Duplication
	if ($type) {
2365
		if (!is_array($type)) {
2366
			$type = array(sanitise_string($type));
2367
		} else {
2368
			foreach ($type as $k => $v) {
2369
				$type[$k] = sanitise_string($v);
2370
			}
2371
		}
2372
	}
2373
2374 View Code Duplication
	if ($subtype) {
2375
		if (!is_array($subtype)) {
2376
			$subtype = array(sanitise_string($subtype));
2377
		} else {
2378
			foreach ($subtype as $k => $v) {
2379
				$subtype[$k] = sanitise_string($v);
2380
			}
2381
		}
2382
	}
2383
2384 View Code Duplication
	if ($owner_guid) {
2385
		if (is_array($owner_guid)) {
2386
			foreach ($owner_guid as $k => $v) {
2387
				$owner_guid[$k] = (int)$v;
2388
			}
2389
		} else {
2390
			$owner_guid = array((int)$owner_guid);
2391
		}
2392
	}
2393
2394
	$owner_relationship = sanitise_string($owner_relationship);
2395
2396
	// Get a list of possible views
2397
	$activity_events = array();
2398
	$activity_views = array_merge(elgg_view_tree('activity', 'default'),
2399
		elgg_view_tree('river', 'default'));
2400
2401
	$done = array();
2402
2403
	foreach ($activity_views as $view) {
2404
		$fragments = explode('/', $view);
2405
		$tmp = explode('/', $view, 2);
2406
		$tmp = $tmp[1];
2407
2408
		if ((isset($fragments[0])) && (($fragments[0] == 'river') || ($fragments[0] == 'activity'))
2409
			&& (!in_array($tmp, $done))) {
2410
2411
			if (isset($fragments[1])) {
2412
				$f = array();
2413
				for ($n = 1; $n < count($fragments); $n++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
2414
					$val = sanitise_string($fragments[$n]);
2415
					switch($n) {
2416
						case 1: $key = 'type'; break;
2417
						case 2: $key = 'subtype'; break;
2418
						case 3: $key = 'event'; break;
2419
					}
2420
					$f[$key] = $val;
0 ignored issues
show
The variable $key does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
2421
				}
2422
2423
				// Filter result based on parameters
2424
				$add = true;
2425
				if ($type) {
2426
					if (!in_array($f['type'], $type)) {
2427
						$add = false;
2428
					}
2429
				}
2430
				if (($add) && ($subtype)) {
2431
					if (!in_array($f['subtype'], $subtype)) {
2432
						$add = false;
2433
					}
2434
				}
2435
2436
				if ($add) {
2437
					$activity_events[] = $f;
2438
				}
2439
			}
2440
2441
			$done[] = $tmp;
2442
		}
2443
	}
2444
2445
	$n = 0;
2446
	foreach ($activity_events as $details) {
2447
		// Get what we're talking about
2448
		if ($details['subtype'] == 'default') {
2449
			$details['subtype'] = '';
2450
		}
2451
2452
		if (($details['type']) && ($details['event'])) {
2453
			if ($n > 0) {
2454
				$obj_query .= " or ";
0 ignored issues
show
The variable $obj_query does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
2455
			}
2456
2457
			$access = "";
2458
			if ($details['type'] != 'relationship') {
2459
				$access = " and " . _elgg_get_access_where_sql(array('table_alias' => 'sl'));
2460
			}
2461
2462
			$obj_query .= "( sl.object_type='{$details['type']}'
2463
				AND sl.object_subtype='{$details['subtype']}'
2464
				AND sl.event='{$details['event']}' $access )";
2465
2466
			$n++;
2467
		}
2468
	}
2469
2470
	// User
2471
	if ((count($owner_guid)) &&  ($owner_guid[0] != 0)) {
2472
		$user = " and sl.performed_by_guid in (" . implode(',', $owner_guid) . ")";
2473
2474
		if ($owner_relationship) {
2475
			$friendsarray = "";
2476
			if ($friends = elgg_get_entities_from_relationship(array(
2477
				'relationship' => $owner_relationship,
2478
				'relationship_guid' => $owner_guid[0],
2479
				'inverse_relationship' => FALSE,
2480
				'type' => 'user',
2481
				'subtype' => $subtype,
2482
				'limit' => false))
2483
			) {
2484
2485
				$friendsarray = array();
2486
				foreach ($friends as $friend) {
2487
					$friendsarray[] = $friend->getGUID();
2488
				}
2489
2490
				$user = " and sl.performed_by_guid in (" . implode(',', $friendsarray) . ")";
2491
			}
2492
		}
2493
	}
2494
2495
	$query = "SELECT sl.* FROM {$CONFIG->dbprefix}system_log sl
2496
		WHERE 1 $user AND ($obj_query)
0 ignored issues
show
The variable $user does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
2497
		ORDER BY sl.time_created desc limit $offset, $limit";
2498
	return get_data($query);
2499
}
2500
2501
/**
2502
 * Perform standard authentication with a given username and password.
2503
 * Returns an \ElggUser object for use with login.
2504
 *
2505
 * @see login
2506
 *
2507
 * @param string $username The username, optionally (for standard logins)
2508
 * @param string $password The password, optionally (for standard logins)
2509
 *
2510
 * @return \ElggUser|false The authenticated user object, or false on failure.
2511
 *
2512
 * @deprecated 1.8 Use elgg_authenticate
2513
 */
2514
function authenticate($username, $password) {
2515
	elgg_deprecated_notice('authenticate() has been deprecated for elgg_authenticate()', 1.8);
2516
	$pam = new \ElggPAM('user');
2517
	$credentials = array('username' => $username, 'password' => $password);
2518
	$result = $pam->authenticate($credentials);
2519
	if ($result) {
2520
		return get_user_by_username($username);
2521
	}
2522
	return false;
2523
}
2524
2525
2526
/**
2527
 * Get the members of a site.
2528
 *
2529
 * @param int $site_guid Site GUID
2530
 * @param int $limit     User GUID
2531
 * @param int $offset    Offset
2532
 *
2533
 * @return mixed
2534
 * @deprecated 1.8 Use \ElggSite::getMembers()
2535
 */
2536
function get_site_members($site_guid, $limit = 10, $offset = 0) {
2537
	elgg_deprecated_notice("get_site_members() deprecated.
2538
		Use \ElggSite::getMembers()", 1.8);
2539
2540
	$site = get_entity($site_guid);
2541
	if ($site) {
2542
		return $site->getMembers($limit, $offset);
2543
	}
2544
2545
	return false;
2546
}
2547
2548
/**
2549
 * Display a list of site members
2550
 *
2551
 * @param int  $site_guid The GUID of the site
2552
 * @param int  $limit     The number of members to display on a page
2553
 * @param bool $fullview  Whether or not to display the full view (default: true)
2554
 *
2555
 * @return string A displayable list of members
2556
 * @deprecated 1.8 Use \ElggSite::listMembers()
2557
 */
2558
function list_site_members($site_guid, $limit = 10, $fullview = true) {
2559
	elgg_deprecated_notice("list_site_members() deprecated.
2560
		Use \ElggSite::listMembers()", 1.8);
2561
2562
	$options = array(
2563
		'limit' => $limit,
2564
		'full_view' => $fullview,
2565
	);
2566
2567
	$site = get_entity($site_guid);
2568
	if ($site) {
2569
		return $site->listMembers($options);
2570
	}
2571
2572
	return '';
2573
}
2574
2575
2576
/**
2577
 * Add a collection to a site.
2578
 *
2579
 * @param int $site_guid       Site GUID
2580
 * @param int $collection_guid Collection GUID
2581
 *
2582
 * @return mixed
2583
 * @deprecated 1.8 Don't use this.
2584
 */
2585
function add_site_collection($site_guid, $collection_guid) {
2586
	elgg_deprecated_notice("add_site_collection has been deprecated", 1.8);
2587
	global $CONFIG;
2588
2589
	$site_guid = (int)$site_guid;
2590
	$collection_guid = (int)$collection_guid;
2591
2592
	return add_entity_relationship($collection_guid, "member_of_site", $site_guid);
2593
}
2594
2595
/**
2596
 * Remove a collection from a site.
2597
 *
2598
 * @param int $site_guid       Site GUID
2599
 * @param int $collection_guid Collection GUID
2600
 *
2601
 * @return mixed
2602
 * @deprecated 1.8 Don't use this.
2603
 */
2604
function remove_site_collection($site_guid, $collection_guid) {
2605
	elgg_deprecated_notice("remove_site_collection has been deprecated", 1.8);
2606
	$site_guid = (int)$site_guid;
2607
	$collection_guid = (int)$collection_guid;
2608
2609
	return remove_entity_relationship($collection_guid, "member_of_site", $site_guid);
2610
}
2611
2612
/**
2613
 * Get the collections belonging to a site.
2614
 *
2615
 * @param int    $site_guid Site GUID
2616
 * @param string $subtype   Subtype
2617
 * @param int    $limit     Limit
2618
 * @param int    $offset    Offset
2619
 *
2620
 * @return mixed
2621
 * @deprecated 1.8 Don't use this.
2622
 */
2623
function get_site_collections($site_guid, $subtype = "", $limit = 10, $offset = 0) {
2624
	elgg_deprecated_notice("get_site_collections has been deprecated", 1.8);
2625
	$site_guid = (int)$site_guid;
2626
	$subtype = sanitise_string($subtype);
2627
	$limit = (int)$limit;
2628
	$offset = (int)$offset;
2629
2630
	// collection isn't a valid type.  This won't work.
2631
	return elgg_get_entities_from_relationship(array(
2632
		'relationship' => 'member_of_site',
2633
		'relationship_guid' => $site_guid,
2634
		'inverse_relationship' => TRUE,
2635
		'type' => 'collection',
2636
		'subtype' => $subtype,
2637
		'limit' => $limit,
2638
		'offset' => $offset
2639
	));
2640
}
2641
2642
/**
2643
 * Get an array of tags with weights for use with the output/tagcloud view.
2644
 *
2645
 * @deprecated 1.8  Use elgg_get_tags().
2646
 *
2647
 * @param int    $threshold      Get the threshold of minimum number of each tags to
2648
 *                               bother with (ie only show tags where there are more
2649
 *                               than $threshold occurances)
2650
 * @param int    $limit          Number of tags to return
2651
 * @param string $metadata_name  Optionally, the name of the field you want to grab for
2652
 * @param string $entity_type    Optionally, the entity type ('object' etc)
2653
 * @param string $entity_subtype The entity subtype, optionally
2654
 * @param int    $owner_guid     The GUID of the tags owner, optionally
2655
 * @param int    $site_guid      Optionally, the site to restrict to (default is the current site)
2656
 * @param int    $start_ts       Optionally specify a start timestamp for tags used to
2657
 *                               generate cloud.
2658
 * @param int    $end_ts         Optionally specify an end timestamp for tags used to generate cloud
2659
 *
2660
 * @return array|false Array of objects with ->tag and ->total values, or false on failure
2661
 */
2662
function get_tags($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object",
2663
$entity_subtype = "", $owner_guid = "", $site_guid = -1, $start_ts = "", $end_ts = "") {
2664
2665
	elgg_deprecated_notice('get_tags() has been replaced by elgg_get_tags()', 1.8);
2666
2667
	if (is_array($metadata_name)) {
2668
		return false;
2669
	}
2670
2671
	$options = array();
2672
	if ($metadata_name === '') {
2673
		$options['tag_names'] = array();
2674
	} else {
2675
		$options['tag_names'] = array($metadata_name);
2676
	}
2677
2678
	$options['threshold'] = $threshold;
2679
	$options['limit'] = $limit;
2680
2681
	// rewrite owner_guid to container_guid to emulate old functionality
2682
	$container_guid = $owner_guid;
2683
	if ($container_guid) {
2684
		$options['container_guids'] = $container_guid;
2685
	}
2686
2687
	if ($entity_type) {
2688
		$options['type'] = $entity_type;
2689
	}
2690
2691
	if ($entity_subtype) {
2692
		$options['subtype'] = $entity_subtype;
2693
	}
2694
2695
	if ($site_guid != -1) {
2696
		$options['site_guids'] = $site_guid;
2697
	}
2698
2699
	if ($end_ts) {
2700
		$options['created_time_upper'] = $end_ts;
2701
	}
2702
2703
	if ($start_ts) {
2704
		$options['created_time_lower'] = $start_ts;
2705
	}
2706
2707
	$r = elgg_get_tags($options);
2708
	return $r;
2709
}
2710
2711
/**
2712
 * Loads and displays a tagcloud given particular criteria.
2713
 *
2714
 * @deprecated 1.8 use elgg_view_tagcloud()
2715
 *
2716
 * @param int    $threshold      Get the threshold of minimum number of each tags
2717
 *                               to bother with (ie only show tags where there are
2718
 *                               more than $threshold occurances)
2719
 * @param int    $limit          Number of tags to return
2720
 * @param string $metadata_name  Optionally, the name of the field you want to grab for
2721
 * @param string $entity_type    Optionally, the entity type ('object' etc)
2722
 * @param string $entity_subtype The entity subtype, optionally
2723
 * @param int    $owner_guid     The GUID of the tags owner, optionally
2724
 * @param int    $site_guid      Optionally, the site to restrict to (default is the current site)
2725
 * @param int    $start_ts       Optionally specify a start timestamp for tags used to
2726
 *                               generate cloud.
2727
 * @param int    $end_ts         Optionally specify an end timestamp for tags used to generate
2728
 *                               cloud.
2729
 *
2730
 * @return string The HTML (or other, depending on view type) of the tagcloud.
2731
 */
2732
function display_tagcloud($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object",
2733
$entity_subtype = "", $owner_guid = "", $site_guid = -1, $start_ts = "", $end_ts = "") {
2734
2735
	elgg_deprecated_notice('display_tagcloud() was deprecated by elgg_view_tagcloud()!', 1.8);
2736
2737
	$tags = get_tags($threshold, $limit, $metadata_name, $entity_type,
2738
		$entity_subtype, $owner_guid, $site_guid, $start_ts, $end_ts);
2739
2740
	return elgg_view('output/tagcloud', array(
2741
		'value' => $tags,
2742
		'type' => $entity_type,
2743
		'subtype' => $entity_subtype,
2744
	));
2745
}
2746
2747
2748
/**
2749
 * Obtains a list of objects owned by a user
2750
 *
2751
 * @param int    $user_guid The GUID of the owning user
2752
 * @param string $subtype   Optionally, the subtype of objects
2753
 * @param int    $limit     The number of results to return (default 10)
2754
 * @param int    $offset    Indexing offset, if any
2755
 * @param int    $timelower The earliest time the entity can have been created. Default: all
2756
 * @param int    $timeupper The latest time the entity can have been created. Default: all
2757
 *
2758
 * @return false|array An array of \ElggObjects or false, depending on success
2759
 * @deprecated 1.8 Use elgg_get_entities() instead
2760
 */
2761
function get_user_objects($user_guid, $subtype = ELGG_ENTITIES_ANY_VALUE, $limit = 10,
2762
$offset = 0, $timelower = 0, $timeupper = 0) {
2763
	elgg_deprecated_notice("get_user_objects() was deprecated in favor of elgg_get_entities()", 1.8);
2764
	$ntt = elgg_get_entities(array(
2765
		'type' => 'object',
2766
		'subtype' => $subtype,
2767
		'owner_guid' => $user_guid,
2768
		'limit' => $limit,
2769
		'offset' => $offset,
2770
		'container_guid' => $user_guid,
2771
		'created_time_lower' => $timelower,
2772
		'created_time_upper' => $timeupper
2773
	));
2774
	return $ntt;
2775
}
2776
2777
/**
2778
 * Counts the objects (optionally of a particular subtype) owned by a user
2779
 *
2780
 * @param int    $user_guid The GUID of the owning user
2781
 * @param string $subtype   Optionally, the subtype of objects
2782
 * @param int    $timelower The earliest time the entity can have been created. Default: all
2783
 * @param int    $timeupper The latest time the entity can have been created. Default: all
2784
 *
2785
 * @return int The number of objects the user owns (of this subtype)
2786
 * @deprecated 1.8 Use elgg_get_entities() instead
2787
 */
2788
function count_user_objects($user_guid, $subtype = ELGG_ENTITIES_ANY_VALUE, $timelower = 0,
2789
$timeupper = 0) {
2790
	elgg_deprecated_notice("count_user_objects() was deprecated in favor of elgg_get_entities()", 1.8);
2791
	$total = elgg_get_entities(array(
2792
		'type' => 'object',
2793
		'subtype' => $subtype,
2794
		'owner_guid' => $user_guid,
2795
		'count' => TRUE,
2796
		'container_guid' => $user_guid,
2797
		'created_time_lower' => $timelower,
2798
		'created_time_upper' => $timeupper
2799
	));
2800
	return $total;
2801
}
2802
2803
/**
2804
 * Displays a list of user objects of a particular subtype, with navigation.
2805
 *
2806
 * @see elgg_view_entity_list
2807
 *
2808
 * @param int    $user_guid      The GUID of the user
2809
 * @param string $subtype        The object subtype
2810
 * @param int    $limit          The number of entities to display on a page
2811
 * @param bool   $fullview       Whether or not to display the full view (default: true)
2812
 * @param bool   $listtypetoggle Whether or not to allow gallery view (default: true)
2813
 * @param bool   $pagination     Whether to display pagination (default: true)
2814
 * @param int    $timelower      The earliest time the entity can have been created. Default: all
2815
 * @param int    $timeupper      The latest time the entity can have been created. Default: all
2816
 *
2817
 * @return string The list in a form suitable to display
2818
 * @deprecated 1.8 Use elgg_list_entities() instead
2819
 */
2820
function list_user_objects($user_guid, $subtype = ELGG_ENTITIES_ANY_VALUE, $limit = 10,
2821
$fullview = true, $listtypetoggle = true, $pagination = true, $timelower = 0, $timeupper = 0) {
2822
	elgg_deprecated_notice("list_user_objects() was deprecated in favor of elgg_list_entities()", 1.8);
2823
2824
	$offset = (int) get_input('offset');
2825
	$limit = (int) $limit;
2826
	$count = (int) count_user_objects($user_guid, $subtype, $timelower, $timeupper);
2827
	$entities = get_user_objects($user_guid, $subtype, $limit, $offset, $timelower, $timeupper);
2828
2829
	return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle,
0 ignored issues
show
$count is of type integer, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
2830
		$pagination);
2831
}
2832
2833
2834
/**
2835
 * Get user objects by an array of metadata
2836
 *
2837
 * @param int    $user_guid The GUID of the owning user
2838
 * @param string $subtype   Optionally, the subtype of objects
2839
 * @param array  $metadata  An array of metadata
2840
 * @param int    $limit     The number of results to return (default 10)
2841
 * @param int    $offset    Indexing offset, if any
2842
 *
2843
 * @return false|array An array of \ElggObjects or false, depending on success
2844
 * @deprecated 1.8 Use elgg_get_entities_from_metadata() instead
2845
 */
2846
function get_user_objects_by_metadata($user_guid, $subtype = "", $metadata = array(),
2847
$limit = 0, $offset = 0) {
2848
	elgg_deprecated_notice("get_user_objects_by_metadata() was deprecated in favor of elgg_get_entities_from_metadata()", 1.8);
2849
	return get_entities_from_metadata_multi($metadata, "object", $subtype, $user_guid,
2850
		$limit, $offset);
2851
}
2852
2853
/**
2854
 * Set the validation status for a user.
2855
 *
2856
 * @param bool   $status Validated (true) or false
2857
 * @param string $method Optional method to say how a user was validated
2858
 * @return bool
2859
 * @deprecated 1.8 Use elgg_set_user_validation_status()
2860
 */
2861
function set_user_validation_status($user_guid, $status, $method = '') {
2862
	elgg_deprecated_notice("set_user_validation_status() is deprecated", 1.8);
2863
	return elgg_set_user_validation_status($user_guid, $status, $method);
2864
}
2865
2866
/**
2867
 * Trigger an event requesting that a user guid be validated somehow - either by email address or some other way.
2868
 *
2869
 * This function invalidates any existing validation value.
2870
 *
2871
 * @param int $user_guid User's GUID
2872
 * @deprecated 1.8 Hook into the register, user plugin hook and request validation.
2873
 */
2874
function request_user_validation($user_guid) {
2875
	elgg_deprecated_notice("request_user_validation() is deprecated.
2876
		Plugins should register for the 'register, user' plugin hook", 1.8);
2877
	$user = get_entity($user_guid);
2878
2879
	if (($user) && ($user instanceof \ElggUser)) {
2880
		// invalidate any existing validations
2881
		set_user_validation_status($user_guid, false);
2882
2883
		// request validation
2884
		trigger_elgg_event('validate', 'user', $user);
2885
	}
2886
}
2887
2888
/**
2889
 * Register a user settings page with the admin panel.
2890
 * This function extends the view "usersettings/main" with the provided view.
2891
 * This view should provide a description and either a control or a link to.
2892
 *
2893
 * Usage:
2894
 * 	- To add a control to the main admin panel then extend usersettings/main
2895
 *  - To add a control to a new page create a page which renders a view
2896
 *    usersettings/subpage (where subpage is your new page -
2897
 *    nb. some pages already exist that you can extend), extend the main view
2898
 *    to point to it, and add controls to your new view.
2899
 *
2900
 * At the moment this is essentially a wrapper around elgg_extend_view().
2901
 *
2902
 * @param string $new_settings_view The view associated with the control you're adding
2903
 * @param string $view              The view to extend, by default this is 'usersettings/main'.
2904
 * @param int    $priority          Optional priority to govern the appearance in the list.
2905
 *
2906
 * @return bool
2907
 * @deprecated 1.8 Extend one of the views in core/settings
2908
 */
2909
function extend_elgg_settings_page($new_settings_view, $view = 'usersettings/main',
2910
$priority = 500) {
2911
	// see views: /core/settings
2912
	elgg_deprecated_notice("extend_elgg_settings_page has been deprecated. Extend one of the settings views instead", 1.8);
2913
2914
	return elgg_extend_view($view, $new_settings_view, $priority);
2915
}
2916
2917
/**
2918
 * Returns a representation of a full 'page' (which might be an HTML page,
2919
 * RSS file, etc, depending on the current viewtype)
2920
 *
2921
 * @param string $title
2922
 * @param string $body
2923
 * @return string
2924
 *
2925
 * @deprecated 1.8 Use elgg_view_page()
2926
 */
2927
function page_draw($title, $body, $sidebar = "") {
2928
	elgg_deprecated_notice("page_draw() was deprecated in favor of elgg_view_page() in 1.8.", 1.8);
2929
2930
	$vars = array(
2931
		'sidebar' => $sidebar
2932
	);
2933
	echo elgg_view_page($title, $body, 'default', $vars);
2934
}
2935
2936
/**
2937
 * Wrapper function to display search listings.
2938
 *
2939
 * @param string $icon The icon for the listing
2940
 * @param string $info Any information that needs to be displayed.
2941
 *
2942
 * @return string The HTML (etc) representing the listing
2943
 * @deprecated 1.8 use elgg_view_image_block()
2944
 */
2945
function elgg_view_listing($icon, $info) {
2946
	elgg_deprecated_notice('elgg_view_listing deprecated by elgg_view_image_block', 1.8);
2947
	return elgg_view('page/components/image_block', array('image' => $icon, 'body' => $info));
2948
}
2949
2950
/**
2951
 * Return the icon URL for an entity.
2952
 *
2953
 * @tip Can be overridden by registering a plugin hook for entity:icon:url, $entity_type.
2954
 *
2955
 * @internal This is passed an entity rather than a guid to handle non-created entities.
2956
 *
2957
 * @param \ElggEntity $entity The entity
2958
 * @param string     $size   Icon size
2959
 *
2960
 * @return string URL to the entity icon.
2961
 * @deprecated 1.8 Use $entity->getIconURL()
2962
 */
2963
function get_entity_icon_url(\ElggEntity $entity, $size = 'medium') {
2964
	elgg_deprecated_notice("get_entity_icon_url() deprecated for getIconURL()", 1.8);
2965
	global $CONFIG;
2966
2967
	$size = sanitise_string($size);
2968
	switch (strtolower($size)) {
2969
		case 'master':
2970
			$size = 'master';
2971
			break;
2972
2973
		case 'large' :
2974
			$size = 'large';
2975
			break;
2976
2977
		case 'topbar' :
2978
			$size = 'topbar';
2979
			break;
2980
2981
		case 'tiny' :
2982
			$size = 'tiny';
2983
			break;
2984
2985
		case 'small' :
2986
			$size = 'small';
2987
			break;
2988
2989
		case 'medium' :
2990
		default:
2991
			$size = 'medium';
2992
	}
2993
2994
	$url = false;
2995
2996
	$viewtype = elgg_get_viewtype();
2997
2998
	// Step one, see if anyone knows how to render this in the current view
2999
	$params = array('entity' => $entity, 'viewtype' => $viewtype, 'size' => $size);
3000
	$url = elgg_trigger_plugin_hook('entity:icon:url', $entity->getType(), $params, $url);
3001
3002
	// Fail, so use default
3003
	if (!$url) {
3004
		$type = $entity->getType();
3005
		$subtype = $entity->getSubtype();
3006
3007
		if (!empty($subtype)) {
3008
			$overrideurl = elgg_view("icon/{$type}/{$subtype}/{$size}", array('entity' => $entity));
3009
			if (!empty($overrideurl)) {
3010
				return $overrideurl;
3011
			}
3012
		}
3013
3014
		$overrideurl = elgg_view("icon/{$type}/default/{$size}", array('entity' => $entity));
3015
		if (!empty($overrideurl)) {
3016
			return $overrideurl;
3017
		}
3018
3019
		$url = "_graphics/icons/default/$size.png";
3020
	}
3021
3022
	return elgg_normalize_url($url);
3023
}
3024
3025
/**
3026
 * Return the current logged in user, or NULL if no user is logged in.
3027
 *
3028
 * If no user can be found in the current session, a plugin
3029
 * hook - 'session:get' 'user' to give plugin authors another
3030
 * way to provide user details to the ACL system without touching the session.
3031
 *
3032
 * @deprecated 1.8 Use elgg_get_logged_in_user_entity()
3033
 * @return \ElggUser|NULL
3034
 */
3035
function get_loggedin_user() {
3036
	elgg_deprecated_notice('get_loggedin_user() is deprecated by elgg_get_logged_in_user_entity()', 1.8);
3037
	return elgg_get_logged_in_user_entity();
3038
}
3039
3040
/**
3041
 * Return the current logged in user by id.
3042
 *
3043
 * @deprecated 1.8 Use elgg_get_logged_in_user_guid()
3044
 * @see elgg_get_logged_in_user_entity()
3045
 * @return int
3046
 */
3047
function get_loggedin_userid() {
3048
	elgg_deprecated_notice('get_loggedin_userid() is deprecated by elgg_get_logged_in_user_guid()', 1.8);
3049
	return elgg_get_logged_in_user_guid();
3050
}
3051
3052
3053
/**
3054
 * Returns whether or not the user is currently logged in
3055
 *
3056
 * @deprecated 1.8 Use elgg_is_logged_in();
3057
 * @return bool
3058
 */
3059
function isloggedin() {
3060
	elgg_deprecated_notice('isloggedin() is deprecated by elgg_is_logged_in()', 1.8);
3061
	return elgg_is_logged_in();
3062
}
3063
3064
/**
3065
 * Returns whether or not the user is currently logged in and that they are an admin user.
3066
 *
3067
 * @deprecated 1.8 Use elgg_is_admin_logged_in()
3068
 * @return bool
3069
 */
3070
function isadminloggedin() {
3071
	elgg_deprecated_notice('isadminloggedin() is deprecated by elgg_is_admin_logged_in()', 1.8);
3072
	return elgg_is_admin_logged_in();
3073
}
3074
3075
3076
/**
3077
 * Loads plugins
3078
 *
3079
 * @deprecated 1.8 Use elgg_load_plugins()
3080
 *
3081
 * @return bool
3082
 */
3083
function load_plugins() {
3084
	elgg_deprecated_notice('load_plugins() is deprecated by elgg_load_plugins()', 1.8);
3085
	return _elgg_load_plugins();
3086
}
3087
3088
/**
3089
 * Find the plugin settings for a user.
3090
 *
3091
 * @param string $plugin_id Plugin name.
3092
 * @param int    $user_guid The guid who's settings to retrieve.
3093
 *
3094
 * @deprecated 1.8 Use elgg_get_all_plugin_user_settings() or \ElggPlugin->getAllUserSettings()
3095
 * @return StdClass Object with all user settings.
3096
 */
3097
function find_plugin_usersettings($plugin_id = null, $user_guid = 0) {
3098
	elgg_deprecated_notice('find_plugin_usersettings() is deprecated by elgg_get_all_plugin_user_settings()', 1.8);
3099
	return elgg_get_all_plugin_user_settings($user_guid, $plugin_id, true);
3100
}
3101
3102
/**
3103
 * Set a user specific setting for a plugin.
3104
 *
3105
 * @param string $name      The name - note, can't be "title".
3106
 * @param mixed  $value     The value.
3107
 * @param int    $user_guid Optional user.
3108
 * @param string $plugin_id Optional plugin name, if not specified then it
3109
 *                          is detected from where you are calling from.
3110
 *
3111
 * @return bool
3112
 * @deprecated 1.8 Use elgg_set_plugin_user_setting() or \ElggPlugin->setUserSetting()
3113
 */
3114
function set_plugin_usersetting($name, $value, $user_guid = 0, $plugin_id = "") {
3115
	elgg_deprecated_notice('find_plugin_usersettings() is deprecated by elgg_get_all_plugin_user_settings()', 1.8);
3116
	return elgg_set_plugin_user_setting($name, $value, $user_guid, $plugin_id);
3117
}
3118
3119
/**
3120
 * Clears a user-specific plugin setting
3121
 *
3122
 * @param string $name      Name of the plugin setting
3123
 * @param int    $user_guid Defaults to logged in user
3124
 * @param string $plugin_id Defaults to contextual plugin name
3125
 *
3126
 * @deprecated 1.8 Use elgg_unset_plugin_user_setting or \ElggPlugin->unsetUserSetting().
3127
 * @return bool Success
3128
 */
3129
function clear_plugin_usersetting($name, $user_guid = 0, $plugin_id = '') {
3130
	elgg_deprecated_notice('clear_plugin_usersetting() is deprecated by elgg_unset_plugin_usersetting()', 1.8);
3131
	return elgg_unset_plugin_user_setting($name, $user_guid, $plugin_id);
3132
}
3133
3134
/**
3135
 * Get a user specific setting for a plugin.
3136
 *
3137
 * @param string $name      The name.
3138
 * @param int    $user_guid Guid of owning user
3139
 * @param string $plugin_id Optional plugin name, if not specified
3140
 *                          it is detected from where you are calling.
3141
 *
3142
 * @deprecated 1.8 Use elgg_get_plugin_user_setting() or \ElggPlugin->getUserSetting()
3143
 * @return mixed
3144
 */
3145
function get_plugin_usersetting($name, $user_guid = 0, $plugin_id = "") {
3146
	elgg_deprecated_notice('get_plugin_usersetting() is deprecated by elgg_get_plugin_user_setting()', 1.8);
3147
	return elgg_get_plugin_user_setting($name, $user_guid, $plugin_id);
3148
}
3149
3150
/**
3151
 * Set a setting for a plugin.
3152
 *
3153
 * @param string $name      The name - note, can't be "title".
3154
 * @param mixed  $value     The value.
3155
 * @param string $plugin_id Optional plugin name, if not specified
3156
 *                          then it is detected from where you are calling from.
3157
 *
3158
 * @deprecated 1.8 Use elgg_set_plugin_setting() or \ElggPlugin->setSetting()
3159
 * @return int|false
3160
 */
3161
function set_plugin_setting($name, $value, $plugin_id = null) {
3162
	elgg_deprecated_notice('set_plugin_setting() is deprecated by elgg_set_plugin_setting()', 1.8);
3163
	return elgg_set_plugin_setting($name, $value, $plugin_id);
3164
}
3165
3166
/**
3167
 * Get setting for a plugin.
3168
 *
3169
 * @param string $name      The name.
3170
 * @param string $plugin_id Optional plugin name, if not specified
3171
 *                          then it is detected from where you are calling from.
3172
 *
3173
 * @deprecated 1.8 Use elgg_get_plugin_setting() or \ElggPlugin->getSetting()
3174
 * @return mixed
3175
 */
3176
function get_plugin_setting($name, $plugin_id = "") {
3177
	elgg_deprecated_notice('get_plugin_setting() is deprecated by elgg_get_plugin_setting()', 1.8);
3178
	return elgg_get_plugin_setting($name, $plugin_id);
3179
}
3180
3181
/**
3182
 * Clear a plugin setting.
3183
 *
3184
 * @param string $name      The name.
3185
 * @param string $plugin_id Optional plugin name, if not specified
3186
 *                          then it is detected from where you are calling from.
3187
 *
3188
 * @deprecated 1.8 Use elgg_unset_plugin_setting() or \ElggPlugin->unsetSetting()
3189
 * @return bool
3190
 */
3191
function clear_plugin_setting($name, $plugin_id = "") {
3192
	elgg_deprecated_notice('clear_plugin_setting() is deprecated by elgg_unset_plugin_setting()', 1.8);
3193
	return elgg_unset_plugin_setting($name, $plugin_id);
3194
}
3195
3196
/**
3197
 * Unsets all plugin settings for a plugin.
3198
 *
3199
 * @param string $plugin_id Optional plugin name, if not specified
3200
 *                          then it is detected from where you are calling from.
3201
 *
3202
 * @return bool
3203
 * @deprecated 1.8 Use elgg_unset_all_plugin_settings() or \ElggPlugin->unsetAllSettings()
3204
 * @since 1.7.0
3205
 */
3206
function clear_all_plugin_settings($plugin_id = "") {
3207
	elgg_deprecated_notice('clear_all_plugin_settings() is deprecated by elgg_unset_all_plugin_setting()', 1.8);
3208
	return elgg_unset_all_plugin_settings($plugin_id);
3209
}
3210
3211
3212
/**
3213
 * Get a list of annotations for a given object/user/annotation type.
3214
 *
3215
 * @param int|array $entity_guid       GUID to return annotations of (falsey for any)
3216
 * @param string    $entity_type       Type of entity
3217
 * @param string    $entity_subtype    Subtype of entity
3218
 * @param string    $name              Name of annotation
3219
 * @param mixed     $value             Value of annotation
3220
 * @param int|array $owner_guid        Owner(s) of annotation
3221
 * @param int       $limit             Limit
3222
 * @param int       $offset            Offset
3223
 * @param string    $order_by          Order annotations by SQL
3224
 * @param int       $timelower         Lower time limit
3225
 * @param int       $timeupper         Upper time limit
3226
 * @param int       $entity_owner_guid Owner guid for the entity
3227
 *
3228
 * @return array
3229
 * @deprecated 1.8 Use elgg_get_annotations()
3230
 */
3231
function get_annotations($entity_guid = 0, $entity_type = "", $entity_subtype = "", $name = "",
3232
$value = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "asc", $timelower = 0,
3233
$timeupper = 0, $entity_owner_guid = 0) {
3234
3235
	elgg_deprecated_notice('get_annotations() is deprecated by elgg_get_annotations()', 1.8);
3236
	$options = array();
3237
3238
	if ($entity_guid) {
3239
		$options['guid'] = $entity_guid;
3240
	}
3241
3242
	if ($entity_type) {
3243
		$options['type'] = $entity_type;
3244
	}
3245
3246
	if ($entity_subtype) {
3247
		$options['subtype'] = $entity_subtype;
3248
	}
3249
3250
	if ($name) {
3251
		$options['annotation_name'] = $name;
3252
	}
3253
3254
	if ($value) {
3255
		$options['annotation_value'] = $value;
3256
	}
3257
3258
	if ($owner_guid) {
3259
		$options['annotation_owner_guid'] = $owner_guid;
3260
	}
3261
3262
	$options['limit'] = $limit;
3263
	$options['offset'] = $offset;
3264
3265
	if ($order_by == 'desc') {
3266
		$options['order_by'] = 'n_table.time_created desc';
3267
	}
3268
3269
	if ($timelower) {
3270
		$options['annotation_time_lower'] = $timelower;
3271
	}
3272
3273
	if ($timeupper) {
3274
		$options['annotation_time_upper'] = $timeupper;
3275
	}
3276
3277
	if ($entity_owner_guid) {
3278
		$options['owner_guid'] = $entity_owner_guid;
3279
	}
3280
3281
	return elgg_get_annotations($options);
3282
}
3283
3284
3285
/**
3286
 * Returns a human-readable list of annotations on a particular entity.
3287
 *
3288
 * @param int        $entity_guid The entity GUID
3289
 * @param string     $name        The name of the kind of annotation
3290
 * @param int        $limit       The number of annotations to display at once
3291
 * @param true|false $asc         Display annotations in ascending order. (Default: true)
3292
 *
3293
 * @return string HTML (etc) version of the annotation list
3294
 * @deprecated 1.8 Use elgg_list_annotations()
3295
 */
3296
function list_annotations($entity_guid, $name = "", $limit = 25, $asc = true) {
3297
	elgg_deprecated_notice('list_annotations() is deprecated by elgg_list_annotations()', 1.8);
3298
3299
	if ($asc) {
3300
		$asc = "asc";
3301
	} else {
3302
		$asc = "desc";
3303
	}
3304
3305
	$options = array(
3306
		'guid' => $entity_guid,
3307
		'limit' => $limit,
3308
		'order_by' => "n_table.time_created $asc"
3309
	);
3310
3311
	return elgg_list_annotations($options);
3312
}
3313
3314
/**
3315
 * Helper function to deprecate annotation calculation functions. Don't use.
3316
 *
3317
 * @param unknown_type $entity_guid
3318
 * @param unknown_type $entity_type
3319
 * @param unknown_type $entity_subtype
3320
 * @param unknown_type $name
3321
 * @param unknown_type $value
3322
 * @param unknown_type $value_type
3323
 * @param unknown_type $owner_guid
3324
 * @param unknown_type $timelower
3325
 * @param unknown_type $timeupper
3326
 * @param unknown_type $calculation
3327
 * @internal Don't use this at all.
3328
 * @deprecated 1.8 Use elgg_get_annotations()
3329
 */
3330
function elgg_deprecated_annotation_calculation($entity_guid = 0, $entity_type = "", $entity_subtype = "",
3331
$name = "", $value = "", $value_type = "", $owner_guid = 0, $timelower = 0,
3332
$timeupper = 0, $calculation = '') {
3333
3334
	$options = array('annotation_calculation' => $calculation);
3335
3336
	if ($entity_guid) {
3337
		$options['guid'] = $entity_guid;
3338
	}
3339
3340
	if ($entity_type) {
3341
		$options['type'] = $entity_type;
3342
	}
3343
3344
	if ($entity_subtype) {
3345
		$options['subtype'] = $entity_subtype;
3346
	}
3347
3348
	if ($name) {
3349
		$options['annotation_name'] = $name;
3350
	}
3351
3352
	if ($value) {
3353
		$options['annotation_value'] = $value;
3354
	}
3355
3356
	if ($owner_guid) {
3357
		$options['annotation_owner_guid'] = $owner_guid;
3358
	}
3359
3360
	if ($timelower) {
3361
		$options['annotation_time_lower'] = $timelower;
3362
	}
3363
3364
	if ($timeupper) {
3365
		$options['annotation_time_upper'] = $timeupper;
3366
	}
3367
3368
	return elgg_get_annotations($options);
3369
}
3370
3371
/**
3372
 * Count the number of annotations based on search parameters
3373
 *
3374
 * @param int    $entity_guid    Guid of Entity
3375
 * @param string $entity_type    Type of Entity
3376
 * @param string $entity_subtype Subtype of Entity
3377
 * @param string $name           Name of annotation
3378
 * @param string $value          Value of annotation
3379
 * @param string $value_type     Type of value
3380
 * @param int    $owner_guid     GUID of owner of annotation
3381
 * @param int    $timelower      Lower time limit
3382
 * @param int    $timeupper      Upper time limit
3383
 *
3384
 * @deprecated 1.8 Use elgg_get_annotations() and pass 'count' => true
3385
 * @return int
3386
 */
3387 View Code Duplication
function count_annotations($entity_guid = 0, $entity_type = "", $entity_subtype = "",
3388
$name = "", $value = "", $value_type = "", $owner_guid = 0, $timelower = 0,
3389
$timeupper = 0) {
3390
	elgg_deprecated_notice('count_annotations() is deprecated by elgg_get_annotations() and passing "count" => true', 1.8);
3391
	return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
3392
			$name, $value, $value_type, $owner_guid, $timelower, $timeupper, 'count');
3393
}
3394
3395
/**
3396
 * Return the sum of a given integer annotation.
3397
 *
3398
 * @param int    $entity_guid    Guid of Entity
3399
 * @param string $entity_type    Type of Entity
3400
 * @param string $entity_subtype Subtype of Entity
3401
 * @param string $name           Name of annotation
3402
 * @param string $value          Value of annotation
3403
 * @param string $value_type     Type of value
3404
 * @param int    $owner_guid     GUID of owner of annotation
3405
 *
3406
 * @deprecated 1.8 Use elgg_get_annotations() and pass 'annotation_calculation' => 'sum'
3407
 * @return int
3408
 */
3409 View Code Duplication
function get_annotations_sum($entity_guid, $entity_type = "", $entity_subtype = "", $name = "",
3410
$value = "", $value_type = "", $owner_guid = 0) {
3411
	elgg_deprecated_notice('get_annotations_sum() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "sum"', 1.8);
3412
3413
	return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
3414
			$name, $value, $value_type, $owner_guid, 0, 0, 'sum');
3415
}
3416
3417
/**
3418
 * Return the max of a given integer annotation.
3419
 *
3420
 * @param int    $entity_guid    Guid of Entity
3421
 * @param string $entity_type    Type of Entity
3422
 * @param string $entity_subtype Subtype of Entity
3423
 * @param string $name           Name of annotation
3424
 * @param string $value          Value of annotation
3425
 * @param string $value_type     Type of value
3426
 * @param int    $owner_guid     GUID of owner of annotation
3427
 *
3428
 * @deprecated 1.8 Use elgg_get_annotations() and pass 'annotation_calculation' => 'max'
3429
 * @return int
3430
 */
3431 View Code Duplication
function get_annotations_max($entity_guid, $entity_type = "", $entity_subtype = "", $name = "",
3432
$value = "", $value_type = "", $owner_guid = 0) {
3433
	elgg_deprecated_notice('get_annotations_max() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "max"', 1.8);
3434
3435
	return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
3436
			$name, $value, $value_type, $owner_guid, 0, 0, 'max');
3437
}
3438
3439
3440
/**
3441
 * Return the minumum of a given integer annotation.
3442
 *
3443
 * @param int    $entity_guid    Guid of Entity
3444
 * @param string $entity_type    Type of Entity
3445
 * @param string $entity_subtype Subtype of Entity
3446
 * @param string $name           Name of annotation
3447
 * @param string $value          Value of annotation
3448
 * @param string $value_type     Type of value
3449
 * @param int    $owner_guid     GUID of owner of annotation
3450
 *
3451
 * @deprecated 1.8 Use elgg_get_annotations() and pass 'annotation_calculation' => 'min'
3452
 * @return int
3453
 */
3454 View Code Duplication
function get_annotations_min($entity_guid, $entity_type = "", $entity_subtype = "", $name = "",
3455
$value = "", $value_type = "", $owner_guid = 0) {
3456
	elgg_deprecated_notice('get_annotations_min() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "min"', 1.8);
3457
3458
	return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
3459
			$name, $value, $value_type, $owner_guid, 0, 0, 'min');
3460
}
3461
3462
3463
/**
3464
 * Return the average of a given integer annotation.
3465
 *
3466
 * @param int    $entity_guid    Guid of Entity
3467
 * @param string $entity_type    Type of Entity
3468
 * @param string $entity_subtype Subtype of Entity
3469
 * @param string $name           Name of annotation
3470
 * @param string $value          Value of annotation
3471
 * @param string $value_type     Type of value
3472
 * @param int    $owner_guid     GUID of owner of annotation
3473
 *
3474
 * @deprecated 1.8 Use elgg_get_annotations() and pass 'annotation_calculation' => 'min'
3475
 *
3476
 * @return int
3477
 */
3478 View Code Duplication
function get_annotations_avg($entity_guid, $entity_type = "", $entity_subtype = "", $name = "",
3479
$value = "", $value_type = "", $owner_guid = 0) {
3480
	elgg_deprecated_notice('get_annotations_avg() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "avg"', 1.8);
3481
3482
	return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
3483
			$name, $value, $value_type, $owner_guid, 0, 0, 'avg');
3484
}
3485
3486
3487
/**
3488
 * Perform a mathmatical calculation on integer annotations.
3489
 *
3490
 * @param string $sum            What sort of calculation to perform
3491
 * @param int    $entity_guid    Guid of Entity
3492
 * @param string $entity_type    Type of Entity
3493
 * @param string $entity_subtype Subtype of Entity
3494
 * @param string $name           Name of annotation
3495
 * @param string $value          Value of annotation
3496
 * @param string $value_type     Type of value
3497
 * @param int    $owner_guid     GUID of owner of annotation
3498
 * @param int    $timelower      Lower time limit
3499
 * @param int    $timeupper      Upper time limit
3500
 *
3501
 * @return int
3502
 * @deprecated 1.8 Use elgg_get_annotations() and pass anntoation_calculation => <calculation>
3503
 */
3504 View Code Duplication
function get_annotations_calculate_x($sum = "avg", $entity_guid, $entity_type = "",
3505
$entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0,
3506
$timelower = 0, $timeupper = 0) {
3507
	elgg_deprecated_notice('get_annotations_calculate_x() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "calculation"', 1.8);
3508
3509
	return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
3510
			$name, $value, $value_type, $owner_guid, $timelower, $timeupper, $sum);
3511
}
3512
3513
3514
/**
3515
 * Lists entities by the totals of a particular kind of annotation AND
3516
 * the value of a piece of metadata
3517
 *
3518
 * @param string  $entity_type    Type of entity.
3519
 * @param string  $entity_subtype Subtype of entity.
3520
 * @param string  $name           Name of annotation.
3521
 * @param string  $mdname         Metadata name
3522
 * @param string  $mdvalue        Metadata value
3523
 * @param int     $limit          Maximum number of results to return.
3524
 * @param int     $owner_guid     Owner.
3525
 * @param int     $group_guid     Group container. Currently only supported if entity_type is object
3526
 * @param boolean $asc            Whether to list in ascending or descending order (default: desc)
3527
 * @param boolean $fullview       Whether to display the entities in full
3528
 * @param boolean $listtypetoggle Can the 'gallery' view can be displayed (default: no)
3529
 * @param boolean $pagination     Display pagination
3530
 * @param string  $orderdir       'desc' or 'asc'
3531
 *
3532
 * @deprecated 1.8 Use elgg_list_entities_from_annotation_calculation().
3533
 *
3534
 * @return string Formatted entity list
3535
 */
3536
function list_entities_from_annotation_count_by_metadata($entity_type = "", $entity_subtype = "",
3537
$name = "", $mdname = '', $mdvalue = '', $limit = 10, $owner_guid = 0, $group_guid = 0,
3538
$asc = false, $fullview = true, $listtypetoggle = false, $pagination = true, $orderdir = 'desc') {
3539
3540
	$msg = 'list_entities_from_annotation_count_by_metadata() is deprecated by elgg_list_entities_from_annotation_calculation().';
3541
3542
	elgg_deprecated_notice($msg, 1.8);
3543
3544
	$options = array();
3545
3546
	$options['calculation'] = 'sum';
3547
3548
	if ($entity_type) {
3549
		$options['types'] = $entity_type;
3550
	}
3551
3552
	if ($entity_subtype) {
3553
		$options['subtypes'] = $entity_subtype;
3554
	}
3555
3556
	$options['annotation_names'] = $name;
3557
3558
	if ($mdname) {
3559
		$options['metadata_name'] = $mdname;
3560
	}
3561
3562
	if ($mdvalue) {
3563
		$options['metadata_value'] = $mdvalue;
3564
	}
3565
3566
	if ($owner_guid) {
3567
		if (is_array($owner_guid)) {
3568
			$options['owner_guids'] = $owner_guid;
3569
		} else {
3570
			$options['owner_guid'] = $owner_guid;
3571
		}
3572
	}
3573
3574
	$options['full_view'] = $fullview;
3575
3576
	$options['list_type_toggle'] = $listtypetoggle;
3577
3578
	$options['pagination'] = $pagination;
3579
3580
	$options['limit'] = $limit;
3581
3582
	$options['order_by'] = "annotation_calculation $orderdir";
3583
3584
	return elgg_get_entities_from_annotation_calculation($options);
3585
}
3586
3587
/**
3588
 * Set an alternative base location for a view (as opposed to the default of $CONFIG->viewpath)
3589
 *
3590
 * @param string $view The name of the view
3591
 * @param string $location The base location path
3592
 *
3593
 * @deprecated 1.8 Use elgg_set_view_location()
3594
 */
3595
function set_view_location($view, $location, $viewtype = '') {
3596
	elgg_deprecated_notice("set_view_location() was deprecated by elgg_set_view_location()", 1.8);
3597
	return elgg_set_view_location($view, $location, $viewtype);
3598
}
3599
3600
/**
3601
 * Sets the URL handler for a particular entity type and subtype
3602
 *
3603
 * @param string $function_name The function to register
3604
 * @param string $entity_type The entity type
3605
 * @param string $entity_subtype The entity subtype
3606
 * @return true|false Depending on success
3607
 *
3608
 * @deprecated 1.8 Use elgg_register_entity_url_handler()
3609
 */
3610
function register_entity_url_handler($function_name, $entity_type = "all", $entity_subtype = "all") {
3611
	elgg_deprecated_notice("register_entity_url_handler() was deprecated by elgg_register_entity_url_handler()", 1.8);
3612
	return elgg_register_entity_url_handler($entity_type, $entity_subtype, $function_name);
3613
}
3614
3615
3616
/**
3617
 * Get the metadata where the entities they are referring to match a given criteria.
3618
 *
3619
 * @param mixed  $meta_name      Metadata name
3620
 * @param mixed  $meta_value     Metadata value
3621
 * @param string $entity_type    The type of entity to look for, eg 'site' or 'object'
3622
 * @param string $entity_subtype The subtype of the entity.
3623
 * @param int    $limit          Limit
3624
 * @param int    $offset         Offset
3625
 * @param string $order_by       Optional ordering.
3626
 * @param int    $site_guid      Site GUID. 0 for current, -1 for any
3627
 *
3628
 * @return mixed
3629
 * @deprecated 1.8 Use elgg_get_metadata()
3630
 */
3631
function find_metadata($meta_name = "", $meta_value = "", $entity_type = "", $entity_subtype = "",
3632
	$limit = 10, $offset = 0, $order_by = "", $site_guid = 0) {
3633
3634
	elgg_deprecated_notice('get_metadata() is deprecated by elgg_get_metadata()', 1.8);
3635
3636
	$options = array();
3637
3638
	if ($meta_name) {
3639
		$options['annotation_name'] = $meta_name;
3640
	}
3641
3642
	if ($meta_value) {
3643
		$options['annotation_value'] = $meta_value;
3644
	}
3645
3646
	if ($entity_type) {
3647
		$options['type'] = $entity_type;
3648
	}
3649
3650
	if ($entity_subtype) {
3651
		$options['subtype'] = $entity_subtype;
3652
	}
3653
3654
	$options['limit'] = $limit;
3655
	$options['offset'] = $offset;
3656
3657
	if ($order_by == 'desc') {
3658
		$options['order_by'] = 'n_table.time_created desc';
3659
	}
3660
3661
	if ($site_guid) {
3662
		$options['site_guid'] = $site_guid;
3663
	}
3664
3665
	return elgg_get_metadata($options);
3666
}
3667
3668
/**
3669
 * Get metadata objects by name.
3670
 *
3671
 * @param int    $entity_guid Entity GUID
3672
 * @param string $meta_name   Metadata name
3673
 *
3674
 * @return ElggMetadata|ElggMetadata[]|false object, an array of \ElggMetadata or false.
3675
 * @deprecated 1.8 Use elgg_get_metadata()
3676
 */
3677
function get_metadata_byname($entity_guid, $meta_name) {
3678
	elgg_deprecated_notice('get_metadata_byname() is deprecated by elgg_get_metadata()', 1.8);
3679
3680
	if (!$entity_guid || !$meta_name) {
3681
		return false;
3682
	}
3683
3684
	$options = array(
3685
		'guid' => $entity_guid,
3686
		'metadata_name' => $meta_name,
3687
		'limit' => 0
3688
	);
3689
3690
	$md = elgg_get_metadata($options);
3691
3692
	if ($md && count($md) == 1) {
3693
		return $md[0];
3694
	}
3695
3696
	return $md;
3697
}
3698
3699
/**
3700
 * Return all the metadata for a given GUID.
3701
 *
3702
 * @param int $entity_guid Entity GUID
3703
 *
3704
 * @return mixed
3705
 * @deprecated 1.8 Use elgg_get_metadata()
3706
 */
3707
function get_metadata_for_entity($entity_guid) {
3708
	elgg_deprecated_notice('get_metadata_for_entity() is deprecated by elgg_get_metadata()', 1.8);
3709
3710
	if (!$entity_guid) {
3711
		return false;
3712
	}
3713
3714
	$options = array(
3715
		'guid' => $entity_guid,
3716
		'limit' => 0
3717
	);
3718
3719
	return elgg_get_metadata($options);
3720
}
3721
3722
/**
3723
 * Get a specific metadata object.
3724
 *
3725
 * @param int $id The id of the metadata being retrieved.
3726
 *
3727
 * @return mixed False on failure or \ElggMetadata
3728
 * @deprecated 1.8 Use elgg_get_metadata_from_id()
3729
 */
3730
function get_metadata($id) {
3731
	elgg_deprecated_notice('get_metadata() is deprecated by elgg_get_metadata_from_id()', 1.8);
3732
	return elgg_get_metadata_from_id($id);
3733
}
3734
3735
/**
3736
 * Clear all the metadata for a given entity, assuming you have access to that entity.
3737
 *
3738
 * @param int $guid Entity GUID
3739
 *
3740
 * @return bool
3741
 * @deprecated 1.8 Use elgg_delete_metadata()
3742
 */
3743 View Code Duplication
function clear_metadata($guid) {
3744
	elgg_deprecated_notice('clear_metadata() is deprecated by elgg_delete_metadata()', 1.8);
3745
	if (!$guid) {
3746
		return false;
3747
	}
3748
	return elgg_delete_metadata(array('guid' => $guid, 'limit' => 0));
3749
}
3750
3751
/**
3752
 * Clear all metadata belonging to a given owner_guid
3753
 *
3754
 * @param int $owner_guid The owner
3755
 *
3756
 * @return bool
3757
 * @deprecated 1.8 Use elgg_delete_metadata()
3758
 */
3759 View Code Duplication
function clear_metadata_by_owner($owner_guid) {
3760
	elgg_deprecated_notice('clear_metadata() is deprecated by elgg_delete_metadata()', 1.8);
3761
	if (!$owner_guid) {
3762
		return false;
3763
	}
3764
	return elgg_delete_metadata(array('metadata_owner_guid' => $owner_guid, 'limit' => 0));
3765
}
3766
3767
/**
3768
 * Delete a piece of metadata, where the current user has access.
3769
 *
3770
 * @param int $id The id of metadata to delete.
3771
 *
3772
 * @return bool
3773
 * @deprecated 1.8 Use elgg_delete_metadata()
3774
 */
3775
function delete_metadata($id) {
3776
	elgg_deprecated_notice('delete_metadata() is deprecated by elgg_delete_metadata()', 1.8);
3777
	if (!$id) {
3778
		return false;
3779
	}
3780
	return elgg_delete_metadata(array('metadata_id' => $id));
3781
}
3782
3783
/**
3784
 * Removes metadata on an entity with a particular name, optionally with a given value.
3785
 *
3786
 * @param int    $guid  The entity GUID
3787
 * @param string $name  The name of the metadata
3788
 * @param string $value The value of the metadata (useful to remove a single item of a set)
3789
 *
3790
 * @return bool Depending on success
3791
 * @deprecated 1.8 Use elgg_delete_metadata()
3792
 */
3793 View Code Duplication
function remove_metadata($guid, $name, $value = "") {
3794
	elgg_deprecated_notice('delete_metadata() is deprecated by elgg_delete_metadata()', 1.8);
3795
3796
	// prevent them from deleting everything
3797
	if (!$guid) {
3798
		return false;
3799
	}
3800
3801
	$options = array(
3802
		'guid' => $guid,
3803
		'metadata_name' => $name,
3804
		'limit' => 0
3805
	);
3806
3807
	if ($value) {
3808
		$options['metadata_value'] = $value;
3809
	}
3810
3811
	return elgg_delete_metadata($options);
3812
}
3813
3814
/**
3815
 * Get a specific annotation.
3816
 *
3817
 * @param int $annotation_id Annotation ID
3818
 *
3819
 * @return \ElggAnnotation
3820
 * @deprecated 1.8 Use elgg_get_annotation_from_id()
3821
 */
3822
function get_annotation($annotation_id) {
3823
	elgg_deprecated_notice('get_annotation() is deprecated by elgg_get_annotation_from_id()', 1.8);
3824
	return elgg_get_annotation_from_id($annotation_id);
3825
}
3826
3827
/**
3828
 * Delete a given annotation.
3829
 *
3830
 * @param int $id The annotation id
3831
 *
3832
 * @return bool
3833
 * @deprecated 1.8 Use elgg_delete_annotations()
3834
 */
3835
function delete_annotation($id) {
3836
	elgg_deprecated_notice('delete_annotation() is deprecated by elgg_delete_annotations()', 1.8);
3837
	if (!$id) {
3838
		return false;
3839
	}
3840
	return elgg_delete_annotations(array('annotation_id' => $id));
3841
}
3842
3843
/**
3844
 * Clear all the annotations for a given entity, assuming you have access to that metadata.
3845
 *
3846
 * @param int    $guid The entity guid
3847
 * @param string $name The name of the annotation to delete.
3848
 *
3849
 * @return int Number of annotations deleted or false if an error
3850
 * @deprecated 1.8 Use elgg_delete_annotations()
3851
 */
3852
function clear_annotations($guid, $name = "") {
3853
	elgg_deprecated_notice('clear_annotations() is deprecated by elgg_delete_annotations()', 1.8);
3854
3855
	if (!$guid) {
3856
		return false;
3857
	}
3858
3859
	$options = array(
3860
		'guid' => $guid,
3861
		'limit' => 0
3862
	);
3863
3864
	if ($name) {
3865
		$options['annotation_name'] = $name;
3866
	}
3867
3868
	return elgg_delete_annotations($options);
3869
}
3870
3871
/**
3872
 * Clear all annotations belonging to a given owner_guid
3873
 *
3874
 * @param int $owner_guid The owner
3875
 *
3876
 * @return int Number of annotations deleted
3877
 * @deprecated 1.8 Use elgg_delete_annotations()
3878
 */
3879
function clear_annotations_by_owner($owner_guid) {
3880
	elgg_deprecated_notice('clear_annotations_by_owner() is deprecated by elgg_delete_annotations()', 1.8);
3881
3882
	if (!$owner_guid) {
3883
		return false;
3884
	}
3885
3886
	$options = array(
3887
		'annotation_owner_guid' => $owner_guid,
3888
		'limit' => 0
3889
	);
3890
3891
	return elgg_delete_annotations($options);
3892
}
3893
3894
/**
3895
 * Registers a page handler for a particular identifier
3896
 *
3897
 * For example, you can register a function called 'blog_page_handler' for handler type 'blog'
3898
 * Now for all URLs of type http://yoururl/pg/blog/*, the blog_page_handler() function will be called.
3899
 * The part of the URL marked with * above will be exploded on '/' characters and passed as an
3900
 * array to that function.
3901
 * For example, the URL http://yoururl/blog/username/friends/ would result in the call:
3902
 * blog_page_handler(array('username','friends'), blog);
3903
 *
3904
 * Page handler functions should return true or the default page handler will be called.
3905
 *
3906
 * A request to register a page handler with the same identifier as previously registered
3907
 * handler will replace the previous one.
3908
 *
3909
 * The context is set to the page handler identifier before the registered
3910
 * page handler function is called. For the above example, the context is set to 'blog'.
3911
 *
3912
 * @param string $handler The page type to handle
3913
 * @param string $function Your function name
3914
 * @return true|false Depending on success
3915
 *
3916
 * @deprecated 1.8 Use {@link elgg_register_page_handler()}
3917
 */
3918
function register_page_handler($handler, $function){
3919
	elgg_deprecated_notice("register_page_handler() was deprecated by elgg_register_page_handler()", 1.8);
3920
	return elgg_register_page_handler($handler, $function);
3921
}
3922
3923
/**
3924
 * Unregister a page handler for an identifier
3925
 *
3926
 * Note: to replace a page handler, call register_page_handler()
3927
 *
3928
 * @param string $handler The page type identifier
3929
 * @since 1.7.2
3930
 * 
3931
 * @deprecated 1.8 Use {@link elgg_unregister_page_handler()}
3932
 */
3933
function unregister_page_handler($handler) {
3934
	elgg_deprecated_notice("unregister_page_handler() was deprecated by elgg_unregister_page_handler()", 1.8);
3935
	return elgg_unregister_page_handler($handler);
3936
}
3937
3938
/**
3939
 * Register an annotation url handler.
3940
 *
3941
 * @param string $function_name The function.
0 ignored issues
show
There is no parameter named $function_name. Did you maybe mean $function?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
3942
 * @param string $extender_name The name, default 'all'.
3943
 *
3944
 * @deprecated 1.8 Use {@link elgg_register_annotation_url_handler()}
3945
 */
3946
function register_annotation_url_handler($function, $extender_name) {
3947
	elgg_deprecated_notice("register_annotation_url_handler() was deprecated by elgg_register_annotation_url_handler()", 1.8);
3948
	return elgg_register_annotation_url_handler($extender_name, $function);
3949
}
3950
3951
/**
3952
 * Sets the URL handler for a particular extender type and name.
3953
 * It is recommended that you do not call this directly, instead use one of the wrapper functions in the
3954
 * subtype files.
3955
 *
3956
 * @param string $function_name The function to register
0 ignored issues
show
There is no parameter named $function_name. Did you maybe mean $function?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
3957
 * @param string $extender_type Extender type
0 ignored issues
show
There is no parameter named $extender_type. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
3958
 * @param string $extender_name The name of the extender
0 ignored issues
show
There is no parameter named $extender_name. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
3959
 * @return true|false Depending on success
3960
 *
3961
 * @deprecated 1.8 Use {@link elgg_register_extender_url_handler()}
3962
 */
3963
function register_extender_url_handler($function, $type = "all", $name = "all") {
3964
	elgg_deprecated_notice("register_extender_url_handler() was deprecated by elgg_register_extender_url_handler()", 1.8);
3965
	return elgg_register_extender_url_handler($type, $name, $function);
3966
}
3967
3968
/**
3969
 * Registers and entity type and subtype to return in search and other places.
3970
 * A description in the elgg_echo languages file of the form item:type:subtype
3971
 * is also expected.
3972
 *
3973
 * @param string $type The type of entity (object, site, user, group)
3974
 * @param string $subtype The subtype to register (may be blank)
3975
 * @return true|false Depending on success
3976
 * 
3977
 * @deprecated 1.8 Use {@link elgg_register_entity_type()}
3978
 */
3979
function register_entity_type($type, $subtype = null) {
3980
	elgg_deprecated_notice("register_entity_type() was deprecated by elgg_register_entity_type()", 1.8);
3981
	return elgg_register_entity_type($type, $subtype);
3982
}
3983
3984
/**
3985
 * Register a metadata url handler.
3986
 *
3987
 * @param string $function_name The function.
0 ignored issues
show
There is no parameter named $function_name. Did you maybe mean $function?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
3988
 * @param string $extender_name The name, default 'all'.
3989
 * 
3990
 * @deprecated 1.8 Use {@link elgg_register_metadata_url_handler()}
3991
 */
3992
function register_metadata_url_handler($function, $extender_name = "all") {
3993
	return elgg_register_metadata_url_handler($extender_name, $function);
3994
}
3995
3996
/**
3997
 * Sets the URL handler for a particular relationship type
3998
 *
3999
 * @param string $function_name The function to register
4000
 * @param string $relationship_type The relationship type.
4001
 * @return true|false Depending on success
4002
 * 
4003
 * @deprecated 1.8 Use {@link elgg_register_relationship_url_handler()}
4004
 */
4005
function register_relationship_url_handler($function_name, $relationship_type = "all") {
4006
	elgg_deprecated_notice("register_relationship_url_handler() was deprecated by elgg_register_relationship_url_handler()", 1.8);
4007
	return elgg_register_relationship_url_handler($relationship_type, $function_name);
4008
}
4009
4010
/**
4011
 * Registers a view to be simply cached
4012
 *
4013
 * Views cached in this manner must take no parameters and be login agnostic -
4014
 * that is to say, they look the same no matter who is logged in (or logged out).
4015
 *
4016
 * CSS and the basic jS views are automatically cached like this.
4017
 *
4018
 * @param string $viewname View name
4019
 *
4020
 * @deprecated 1.8 Use {@link elgg_register_simplecache_view()}
4021
 */
4022
function elgg_view_register_simplecache($viewname) {
4023
	elgg_deprecated_notice("elgg_view_register_simplecache() was deprecated by elgg_register_simplecache_view()", 1.8);
4024
	return elgg_register_simplecache_view($viewname);
4025
}
4026
4027
/**
4028
 * Regenerates the simple cache.
4029
 *
4030
 * @param string $viewtype Optional viewtype to regenerate
4031
 * @see elgg_view_register_simplecache()
4032
 *
4033
 * @deprecated 1.8 Use {@link elgg_regenerate_simplecache()}
4034
 */
4035
function elgg_view_regenerate_simplecache($viewtype = NULL) {
4036
	elgg_deprecated_notice("elgg_view_regenerate_simplecache() was deprecated by elgg_regenerate_simplecache()", 1.8);
4037
	return elgg_regenerate_simplecache($viewtype);
4038
}
4039
4040
/**
4041
 * Enables the simple cache.
4042
 *
4043
 * @see elgg_view_register_simplecache()
4044
 * 
4045
 * @deprecated 1.8 Use {@link elgg_enable_simplecache()}
4046
 */
4047
function elgg_view_enable_simplecache() {
4048
	elgg_deprecated_notice("elgg_view_enable_simplecache() was deprecated by elgg_enable_simplecache()", 1.8);
4049
	return elgg_enable_simplecache();
4050
}
4051
4052
/**
4053
 * Disables the simple cache.
4054
 *
4055
 * @see elgg_view_register_simplecache()
4056
 * 
4057
 * @deprecated 1.8 Use {@link elgg_disable_simplecache()}
4058
 */
4059
function elgg_view_disable_simplecache() {
4060
	elgg_deprecated_notice("elgg_view_disable_simplecache() was deprecated by elgg_disable_simplecache()", 1.8);
4061
	return elgg_disable_simplecache();
4062
}
4063
4064
// these were internal functions that perhaps can be removed rather than deprecated
4065
/**
4066
 * @deprecated 1.8
4067
 */
4068
function is_db_installed() {
4069
	elgg_deprecated_notice('is_db_installed() has been deprecated', 1.8);
4070
	return true;
4071
}
4072
4073
/**
4074
 * @deprecated 1.8
4075
 */
4076
function is_installed() {
4077
	elgg_deprecated_notice('is_installed() has been deprecated', 1.8);
4078
	return true;
4079
}
4080
4081
/**
4082
 * Attempt to authenticate.
4083
 * This function will process all registered PAM handlers or stop when the first
4084
 * handler fails. A handler fails by either returning false or throwing an
4085
 * exception. The advantage of throwing an exception is that it returns a message
4086
 * through the global $_PAM_HANDLERS_MSG which can be used in communication with
4087
 * a user. The order that handlers are processed is determined by the order that
4088
 * they were registered.
4089
 *
4090
 * If $credentials are provided the PAM handler should authenticate using the
4091
 * provided credentials, if not then credentials should be prompted for or
4092
 * otherwise retrieved (eg from the HTTP header or $_SESSION).
4093
 *
4094
 * @param mixed $credentials Mixed PAM handler specific credentials (e.g. username, password)
4095
 * @param string $policy - the policy type, default is "user"
4096
 * @return bool true if authenticated, false if not.
4097
 *
4098
 * @deprecated 1.8 See {@link \ElggPAM}
4099
 */
4100
function pam_authenticate($credentials = NULL, $policy = "user") {
4101
	elgg_deprecated_notice('pam_authenticate has been deprecated for \ElggPAM', 1.8);
4102
	global $_PAM_HANDLERS, $_PAM_HANDLERS_MSG;
4103
4104
	$_PAM_HANDLERS_MSG = array();
4105
4106
	$authenticated = false;
4107
4108
	foreach ($_PAM_HANDLERS[$policy] as $k => $v) {
4109
		$handler = $v->handler;
4110
		$importance = $v->importance;
4111
4112
		try {
4113
			// Execute the handler
4114
			if ($handler($credentials)) {
4115
				// Explicitly returned true
4116
				$_PAM_HANDLERS_MSG[$k] = "Authenticated!";
4117
4118
				$authenticated = true;
4119
			} else {
4120
				$_PAM_HANDLERS_MSG[$k] = "Not Authenticated.";
4121
4122
				// If this is required then abort.
4123
				if ($importance == 'required') {
4124
					return false;
4125
				}
4126
			}
4127
		} catch (Exception $e) {
4128
			$_PAM_HANDLERS_MSG[$k] = "$e";
4129
4130
			// If this is required then abort.
4131
			if ($importance == 'required') {
4132
				return false;
4133
			}
4134
		}
4135
	}
4136
4137
	return $authenticated;
4138
}
4139
4140
4141
/**
4142
 * When given a widget entity and a new requested location, saves the new location
4143
 * and also provides a sensible ordering for all widgets in that column
4144
 *
4145
 * @param \ElggObject $widget The widget entity
4146
 * @param int        $order  The order within the column
4147
 * @param int        $column The column (1, 2 or 3)
4148
 *
4149
 * @return bool Depending on success
4150
 * @deprecated 1.8 use \ElggWidget::move()
4151
 */
4152
function save_widget_location(\ElggObject $widget, $order, $column) {
4153
	elgg_deprecated_notice('save_widget_location() is deprecated', 1.8);
4154
	if ($widget instanceof \ElggObject) {
4155
		if ($widget->getSubtype() == "widget") {
4156
			// If you can't move the widget, don't save a new location
4157
			if (!$widget->draggable) {
4158
				return false;
4159
			}
4160
4161
			// Sanitise the column value
4162
			if ($column != 1 || $column != 2 || $column != 3) {
4163
				$column = 1;
4164
			}
4165
4166
			$widget->column = (int) $column;
4167
4168
			$ordertmp = array();
4169
			$params = array(
4170
				'context' => $widget->context,
4171
				'column' => $column,
4172
			);
4173
4174
			if ($entities = get_entities_from_metadata_multi($params, 'object', 'widget')) {
4175
				foreach ($entities as $entity) {
4176
					$entityorder = $entity->order;
4177
					if ($entityorder < $order) {
4178
						$ordertmp[$entityorder] = $entity;
4179
					}
4180
					if ($entityorder >= $order) {
4181
						$ordertmp[$entityorder + 10000] = $entity;
4182
					}
4183
				}
4184
			}
4185
4186
			$ordertmp[$order] = $widget;
4187
			ksort($ordertmp);
4188
4189
			$orderticker = 10;
4190
			foreach ($ordertmp as $orderval => $entity) {
4191
				$entity->order = $orderticker;
4192
				$orderticker += 10;
4193
			}
4194
4195
			return true;
4196
		} else {
4197
			register_error($widget->getSubtype());
4198
		}
4199
4200
	}
4201
4202
	return false;
4203
}
4204
4205
/**
4206
 * Get widgets for a particular context and column, in order of display
4207
 *
4208
 * @param int    $user_guid The owner user GUID
4209
 * @param string $context   The context (profile, dashboard etc)
4210
 * @param int    $column    The column (1 or 2)
4211
 *
4212
 * @return array|false An array of widget \ElggObjects, or false
4213
 * @deprecated 1.8 Use elgg_get_widgets()
4214
 */
4215
function get_widgets($user_guid, $context, $column) {
4216
	elgg_deprecated_notice('get_widgets is depecated for elgg_get_widgets', 1.8);
4217
	$params = array(
4218
		'column' => $column,
4219
		'context' => $context
4220
	);
4221
	$widgets = get_entities_from_private_setting_multi($params, "object",
4222
		"widget", $user_guid, "", 10000);
4223
4224
	if ($widgets) {
4225
		$widgetorder = array();
4226
		foreach ($widgets as $widget) {
4227
			$order = $widget->order;
4228
			while (isset($widgetorder[$order])) {
4229
				$order++;
4230
			}
4231
			$widgetorder[$order] = $widget;
4232
		}
4233
4234
		ksort($widgetorder);
4235
4236
		return $widgetorder;
4237
	}
4238
4239
	return false;
4240
}
4241
4242
/**
4243
 * Add a new widget instance
4244
 *
4245
 * @param int    $entity_guid GUID of entity that owns this widget
4246
 * @param string $handler     The handler for this widget
4247
 * @param string $context     The page context for this widget
4248
 * @param int    $order       The order to display this widget in
4249
 * @param int    $column      The column to display this widget in (1, 2 or 3)
4250
 * @param int    $access_id   If not specified, it is set to the default access level
4251
 *
4252
 * @return int|false Widget GUID or false on failure
4253
 * @deprecated 1.8 use elgg_create_widget()
4254
 */
4255
function add_widget($entity_guid, $handler, $context, $order = 0, $column = 1, $access_id = null) {
4256
	elgg_deprecated_notice('add_widget has been deprecated for elgg_create_widget', 1.8);
4257
	if (empty($entity_guid) || empty($context) || empty($handler) || !widget_type_exists($handler)) {
4258
		return false;
4259
	}
4260
4261
	if ($entity = get_entity($entity_guid)) {
4262
		$widget = new \ElggWidget;
4263
		$widget->owner_guid = $entity_guid;
4264
		$widget->container_guid = $entity_guid;
4265
		if (isset($access_id)) {
4266
			$widget->access_id = $access_id;
4267
		} else {
4268
			$widget->access_id = get_default_access();
4269
		}
4270
4271
		$guid = $widget->save();
4272
4273
		// private settings cannot be set until \ElggWidget saved
4274
		$widget->handler = $handler;
4275
		$widget->context = $context;
4276
		$widget->column = $column;
4277
		$widget->order = $order;
4278
4279
		return $guid;
4280
	}
4281
4282
	return false;
4283
}
4284
4285
/**
4286
 * Define a new widget type
4287
 *
4288
 * @param string $handler     The identifier for the widget handler
4289
 * @param string $name        The name of the widget type
4290
 * @param string $description A description for the widget type
4291
 * @param string $context     A comma-separated list of contexts where this
4292
 *                            widget is allowed (default: 'all')
4293
 * @param bool   $multiple    Whether or not multiple instances of this widget
4294
 *                            are allowed on a single dashboard (default: false)
4295
 * @param string $positions   A comma-separated list of positions on the page
4296
 *                            (side or main) where this widget is allowed (default: "side,main")
4297
 *
4298
 * @return bool Depending on success
4299
 * @deprecated 1.8 Use elgg_register_widget_type
4300
 */
4301
function add_widget_type($handler, $name, $description, $context = "all",
4302
$multiple = false, $positions = "side,main") {
4303
	elgg_deprecated_notice("add_widget_type deprecated for elgg_register_widget_type", 1.8);
4304
4305
	return elgg_register_widget_type($handler, $name, $description, $context, $multiple);
0 ignored issues
show
$context is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
4306
}
4307
4308
/**
4309
 * Remove a widget type
4310
 *
4311
 * @param string $handler The identifier for the widget handler
4312
 *
4313
 * @return void
4314
 * @since 1.7.1
4315
 * @deprecated 1.8 Use elgg_unregister_widget_type
4316
 */
4317
function remove_widget_type($handler) {
4318
	elgg_deprecated_notice("remove_widget_type deprecated for elgg_unregister_widget_type", 1.8);
4319
	return elgg_unregister_widget_type($handler);
4320
}
4321
4322
/**
4323
 * Determines whether or not widgets with the specified handler have been defined
4324
 *
4325
 * @param string $handler The widget handler identifying string
4326
 *
4327
 * @return bool Whether or not those widgets exist
4328
 * @deprecated 1.8 Use elgg_is_widget_type
4329
 */
4330
function widget_type_exists($handler) {
4331
	elgg_deprecated_notice("widget_type_exists deprecated for elgg_is_widget_type", 1.8);
4332
	return elgg_is_widget_type($handler);
4333
}
4334
4335
/**
4336
 * Returns an array of \stdClass objects representing the defined widget types
4337
 *
4338
 * @return array A list of types defined (if any)
4339
 * @deprecated 1.8 Use elgg_get_widget_types
4340
 */
4341
function get_widget_types() {
4342
	elgg_deprecated_notice("get_widget_types deprecrated for elgg_get_widget_types", 1.8);
4343
	return elgg_get_widget_types();
4344
}
4345
4346
/**
4347
 * Saves a widget's settings (by passing an array of
4348
 * (name => value) pairs to save_{$handler}_widget)
4349
 *
4350
 * @param int   $widget_guid The GUID of the widget we're saving to
4351
 * @param array $params      An array of name => value parameters
4352
 *
4353
 * @return bool
4354
 * @deprecated 1.8 Use elgg_save_widget_settings
4355
 */
4356
function save_widget_info($widget_guid, $params) {
4357
	elgg_deprecated_notice("save_widget_info() is deprecated for elgg_save_widget_settings", 1.8);
4358
	if ($widget = get_entity($widget_guid)) {
4359
4360
		$subtype = $widget->getSubtype();
4361
4362
		if ($subtype != "widget") {
4363
			return false;
4364
		}
4365
		$handler = $widget->handler;
4366
		if (empty($handler) || !widget_type_exists($handler)) {
4367
			return false;
4368
		}
4369
4370
		if (!$widget->canEdit()) {
4371
			return false;
4372
		}
4373
4374
		// Save the params to the widget
4375
		if (is_array($params) && sizeof($params) > 0) {
4376
			foreach ($params as $name => $value) {
4377
4378
				if (!empty($name) && !in_array($name, array(
4379
					'guid', 'owner_guid', 'site_guid'
4380
				))) {
4381
					if (is_array($value)) {
4382
						// @todo Handle arrays securely
4383
						$widget->setMetadata($name, $value, "", true);
4384
					} else {
4385
						$widget->$name = $value;
4386
					}
4387
				}
4388
			}
4389
			$widget->save();
4390
		}
4391
4392
		$function = "save_{$handler}_widget";
4393
		if (is_callable($function)) {
4394
			return $function($params);
4395
		}
4396
4397
		return true;
4398
	}
4399
4400
	return false;
4401
}
4402
4403
/**
4404
 * Reorders the widgets from a widget panel
4405
 *
4406
 * @param string $panelstring1 String of guids of \ElggWidget objects separated by ::
4407
 * @param string $panelstring2 String of guids of \ElggWidget objects separated by ::
4408
 * @param string $panelstring3 String of guids of \ElggWidget objects separated by ::
4409
 * @param string $context      Profile or dashboard
4410
 * @param int    $owner        Owner guid
4411
 *
4412
 * @return void
4413
 * @deprecated 1.8 Don't use.
4414
 */
4415
function reorder_widgets_from_panel($panelstring1, $panelstring2, $panelstring3, $context, $owner) {
4416
	elgg_deprecated_notice("reorder_widgets_from_panel() is deprecated", 1.8);
4417
	$return = true;
4418
4419
	$mainwidgets = explode('::', $panelstring1);
4420
	$sidewidgets = explode('::', $panelstring2);
4421
	$rightwidgets = explode('::', $panelstring3);
4422
4423
	$handlers = array();
4424
	$guids = array();
4425
4426 View Code Duplication
	if (is_array($mainwidgets) && sizeof($mainwidgets) > 0) {
4427
		foreach ($mainwidgets as $widget) {
4428
4429
			$guid = (int) $widget;
4430
4431
			if ("{$guid}" == "{$widget}") {
4432
				$guids[1][] = $widget;
4433
			} else {
4434
				$handlers[1][] = $widget;
4435
			}
4436
		}
4437
	}
4438 View Code Duplication
	if (is_array($sidewidgets) && sizeof($sidewidgets) > 0) {
4439
		foreach ($sidewidgets as $widget) {
4440
4441
			$guid = (int) $widget;
4442
4443
			if ("{$guid}" == "{$widget}") {
4444
				$guids[2][] = $widget;
4445
			} else {
4446
				$handlers[2][] = $widget;
4447
			}
4448
4449
		}
4450
	}
4451 View Code Duplication
	if (is_array($rightwidgets) && sizeof($rightwidgets) > 0) {
4452
		foreach ($rightwidgets as $widget) {
4453
4454
			$guid = (int) $widget;
4455
4456
			if ("{$guid}" == "{$widget}") {
4457
				$guids[3][] = $widget;
4458
			} else {
4459
				$handlers[3][] = $widget;
4460
			}
4461
4462
		}
4463
	}
4464
4465
	// Reorder existing widgets or delete ones that have vanished
4466
	foreach (array(1, 2, 3) as $column) {
4467
		if ($dbwidgets = get_widgets($owner, $context, $column)) {
4468
4469
			foreach ($dbwidgets as $dbwidget) {
4470
				if (in_array($dbwidget->getGUID(), $guids[1])
4471
				|| in_array($dbwidget->getGUID(), $guids[2]) || in_array($dbwidget->getGUID(), $guids[3])) {
4472
4473
					if (in_array($dbwidget->getGUID(), $guids[1])) {
4474
						$pos = array_search($dbwidget->getGUID(), $guids[1]);
4475
						$col = 1;
4476
					} else if (in_array($dbwidget->getGUID(), $guids[2])) {
4477
						$pos = array_search($dbwidget->getGUID(), $guids[2]);
4478
						$col = 2;
4479
					} else {
4480
						$pos = array_search($dbwidget->getGUID(), $guids[3]);
4481
						$col = 3;
4482
					}
4483
					$pos = ($pos + 1) * 10;
4484
					$dbwidget->column = $col;
4485
					$dbwidget->order = $pos;
4486
				} else {
4487
					$dbguid = $dbwidget->getGUID();
4488
					if (!$dbwidget->delete()) {
4489
						$return = false;
4490
					} else {
4491
						// Remove state cookie
4492
						$cookie = new \ElggCookie("widget$dbguid");
4493
						$cookie->value = NULL;
4494
						elgg_set_cookie($cookie);
4495
					}
4496
				}
4497
			}
4498
4499
		}
4500
		// Add new ones
4501
		if (sizeof($guids[$column]) > 0) {
4502
			foreach ($guids[$column] as $key => $guid) {
4503
				if ($guid == 0) {
4504
					$pos = ($key + 1) * 10;
4505
					$handler = $handlers[$column][$key];
4506
					if (!add_widget($owner, $handler, $context, $pos, $column)) {
4507
						$return = false;
4508
					}
4509
				}
4510
			}
4511
		}
4512
	}
4513
4514
	return $return;
4515
}
4516
4517
/**
4518
 * Register a particular context for use with widgets.
4519
 *
4520
 * @param string $context The context we wish to enable context for
4521
 *
4522
 * @return void
4523
 * @deprecated 1.8 Don't use.
4524
 */
4525
function use_widgets($context) {
4526
	elgg_deprecated_notice("use_widgets is deprecated", 1.8);
4527
	global $CONFIG;
4528
4529
	if (!isset($CONFIG->widgets)) {
4530
		$CONFIG->widgets = new \stdClass;
4531
	}
4532
4533
	if (!isset($CONFIG->widgets->contexts)) {
4534
		$CONFIG->widgets->contexts = array();
4535
	}
4536
4537
	if (!empty($context)) {
4538
		$CONFIG->widgets->contexts[] = $context;
4539
	}
4540
}
4541
4542
/**
4543
 * Determines whether or not the current context is using widgets
4544
 *
4545
 * @return bool Depending on widget status
4546
 * @deprecated 1.8 Don't use.
4547
 */
4548
function using_widgets() {
4549
	elgg_deprecated_notice("using_widgets is deprecated", 1.8);
4550
	global $CONFIG;
4551
4552
	$context = elgg_get_context();
4553
	if (isset($CONFIG->widgets->contexts) && is_array($CONFIG->widgets->contexts)) {
4554
		if (in_array($context, $CONFIG->widgets->contexts)) {
4555
			return true;
4556
		}
4557
	}
4558
4559
	return false;
4560
}
4561
4562
/**
4563
 * Displays a particular widget
4564
 *
4565
 * @param \ElggObject $widget The widget to display
4566
 * @return string The HTML for the widget, including JavaScript wrapper
4567
 * 
4568
 * @deprecated 1.8 Use elgg_view_entity()
4569
 */
4570
function display_widget(\ElggObject $widget) {
4571
	elgg_deprecated_notice("display_widget() was been deprecated. Use elgg_view_entity().", 1.8);
4572
	return elgg_view_entity($widget);
4573
}
4574
4575
/**
4576
 * Count the number of comments attached to an entity
4577
 *
4578
 * @param \ElggEntity $entity
4579
 * @return int Number of comments
4580
 * @deprecated 1.8 Use \ElggEntity->countComments()
4581
 */
4582
function elgg_count_comments($entity) {
4583
	elgg_deprecated_notice('elgg_count_comments() is deprecated by \ElggEntity->countComments()', 1.8);
4584
4585
	if ($entity instanceof \ElggEntity) {
4586
		return $entity->countComments();
4587
	}
4588
4589
	return 0;
4590
}
4591
4592
/**
4593
 * Removes all items relating to a particular acting entity from the river
4594
 *
4595
 * @param int $subject_guid The GUID of the entity
4596
 *
4597
 * @return bool Depending on success
4598
 * @deprecated 1.8 Use elgg_delete_river()
4599
 */
4600
function remove_from_river_by_subject($subject_guid) {
4601
	elgg_deprecated_notice("remove_from_river_by_subject() deprecated by elgg_delete_river()", 1.8);
4602
4603
	return elgg_delete_river(array('subject_guid' => $subject_guid));
4604
}
4605
4606
/**
4607
 * Removes all items relating to a particular entity being acted upon from the river
4608
 *
4609
 * @param int $object_guid The GUID of the entity
4610
 *
4611
 * @return bool Depending on success
4612
 * @deprecated 1.8 Use elgg_delete_river()
4613
 */
4614
function remove_from_river_by_object($object_guid) {
4615
	elgg_deprecated_notice("remove_from_river_by_object() deprecated by elgg_delete_river()", 1.8);
4616
4617
	return elgg_delete_river(array('object_guid' => $object_guid));
4618
}
4619
4620
/**
4621
 * Removes all items relating to a particular annotation being acted upon from the river
4622
 *
4623
 * @param int $annotation_id The ID of the annotation
4624
 *
4625
 * @return bool Depending on success
4626
 * @since 1.7.0
4627
 * @deprecated 1.8 Use elgg_delete_river()
4628
 */
4629
function remove_from_river_by_annotation($annotation_id) {
4630
	elgg_deprecated_notice("remove_from_river_by_annotation() deprecated by elgg_delete_river()", 1.8);
4631
4632
	return elgg_delete_river(array('annotation_id' => $annotation_id));
4633
}
4634
4635
/**
4636
 * Removes a single river entry
4637
 *
4638
 * @param int $id The ID of the river entry
4639
 *
4640
 * @return bool Depending on success
4641
 * @since 1.7.2
4642
 * @deprecated 1.8 Use elgg_delete_river()
4643
 */
4644
function remove_from_river_by_id($id) {
4645
	elgg_deprecated_notice("remove_from_river_by_id() deprecated by elgg_delete_river()", 1.8);
4646
4647
	return elgg_delete_river(array('id' => $id));
4648
}
4649
4650
/**
4651
 * A default page handler
4652
 * Tries to locate a suitable file to include. Only works for core pages, not plugins.
4653
 *
4654
 * @param array  $page    The page URL elements
4655
 * @param string $handler The base handler
4656
 *
4657
 * @return true|false Depending on success
4658
 * @deprecated 1.8
4659
 */
4660
function default_page_handler($page, $handler) {
4661
	global $CONFIG;
4662
4663
	elgg_deprecated_notice("default_page_handler is deprecated", "1.8");
4664
4665
	$page = implode('/', $page);
4666
4667
	// protect against including arbitary files
4668
	$page = str_replace("..", "", $page);
4669
4670
	$callpath = $CONFIG->path . $handler . "/" . $page;
4671
	if (is_dir($callpath)) {
4672
		$callpath = sanitise_filepath($callpath);
4673
		$callpath .= "index.php";
4674
		if (file_exists($callpath)) {
4675
			if (include($callpath)) {
4676
				return TRUE;
4677
			}
4678
		}
4679
	} else if (file_exists($callpath)) {
4680
		include($callpath);
4681
		return TRUE;
4682
	}
4683
4684
	return FALSE;
4685
}
4686
4687
/**
4688
 * Invalidate this class's entry in the cache.
4689
 *
4690
 * @param int $guid The entity guid
4691
 *
4692
 * @return void
4693
 * @access private
4694
 * @deprecated 1.8
4695
 */
4696
function invalidate_cache_for_entity($guid) {
4697
	elgg_deprecated_notice('invalidate_cache_for_entity() is a private function and should not be used.', 1.8);
4698
	_elgg_invalidate_cache_for_entity($guid);
4699
}
4700
4701
/**
4702
 * Cache an entity.
4703
 *
4704
 * Stores an entity in $ENTITY_CACHE;
4705
 *
4706
 * @param \ElggEntity $entity Entity to cache
4707
 *
4708
 * @return void
4709
 * @access private
4710
 * @deprecated 1.8
4711
 */
4712
function cache_entity(\ElggEntity $entity) {
4713
	elgg_deprecated_notice('cache_entity() is a private function and should not be used.', 1.8);
4714
	_elgg_cache_entity($entity);
4715
}
4716
4717
/**
4718
 * Retrieve a entity from the cache.
4719
 *
4720
 * @param int $guid The guid
4721
 *
4722
 * @return \ElggEntity|bool false if entity not cached, or not fully loaded
4723
 * @access private
4724
 * @deprecated 1.8
4725
 */
4726
function retrieve_cached_entity($guid) {
4727
	elgg_deprecated_notice('retrieve_cached_entity() is a private function and should not be used.', 1.8);
4728
	return _elgg_retrieve_cached_entity($guid);
4729
}
4730
4731
/**
4732
 * Returns the category of a file from its MIME type
4733
 *
4734
 * @param string $mime_type The MIME type
4735
 *
4736
 * @return string 'document', 'audio', 'video', or 'general' if the MIME type was unrecognized
4737
 * @deprecated 1.8 Use elgg_get_file_simple_type()
4738
 */
4739
function get_general_file_type($mime_type) {
4740
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_file_simple_type()', 1.8);
4741
	return elgg_get_file_simple_type($mime_type);
4742
}
4743