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.7.php (7 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
 * Get entities with the specified access collection id.
4
 *
5
 * @deprecated 1.7. Use elgg_get_entities_from_access_id()
6
 *
7
 * @param int    $collection_id  ID of collection
8
 * @param string $entity_type    Type of entities
9
 * @param string $entity_subtype Subtype of entities
10
 * @param int    $owner_guid     Guid of owner
11
 * @param int    $limit          Limit of number of entities to return
12
 * @param int    $offset         Skip this many entities
13
 * @param string $order_by       Column to order by
14
 * @param int    $site_guid      The site guid
15
 * @param bool   $count          Return a count or entities
16
 *
17
 * @return array
18
 */
19
function get_entities_from_access_id($collection_id, $entity_type = "", $entity_subtype = "",
20
	$owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
21
	// log deprecated warning
22
	elgg_deprecated_notice('get_entities_from_access_id() was deprecated by elgg_get_entities()', 1.7);
23
24
	if (!$collection_id) {
25
		return FALSE;
26
	}
27
28
	// build the options using given parameters
29
	$options = array();
30
	$options['limit'] = $limit;
31
	$options['offset'] = $offset;
32
	$options['count'] = $count;
33
34
	if ($entity_type) {
35
		$options['type'] = sanitise_string($entity_type);
36
	}
37
38
	if ($entity_subtype) {
39
		$options['subtype'] = $entity_subtype;
40
	}
41
42
	if ($site_guid) {
43
		$options['site_guid'] = $site_guid;
44
	}
45
46
	if ($order_by) {
47
		$options['order_by'] = sanitise_string("e.time_created, $order_by");
48
	}
49
50
	if ($owner_guid) {
51
		if (is_array($owner_guid)) {
52
			$options['owner_guids'] = $owner_guid;
53
		} else {
54
			$options['owner_guid'] = $owner_guid;
55
		}
56
	}
57
58
	if ($site_guid) {
59
		$options['site_guid'] = $site_guid;
60
	}
61
62
	$options['access_id'] = $collection_id;
63
64
	return elgg_get_entities_from_access_id($options);
65
}
66
67
/**
68
 * @deprecated 1.7
69
 */
70
function get_entities_from_access_collection($collection_id, $entity_type = "", $entity_subtype = "",
71
	$owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
72
73
	elgg_deprecated_notice('get_entities_from_access_collection() was deprecated by elgg_get_entities()', 1.7);
74
75
	return get_entities_from_access_id($collection_id, $entity_type, $entity_subtype,
76
			$owner_guid, $limit, $offset, $order_by, $site_guid, $count);
77
}
78
79
/**
80
 * Get entities from annotations
81
 *
82
 * No longer used.
83
 *
84
 * @deprecated 1.7 Use elgg_get_entities_from_annotations()
85
 *
86
 * @param mixed  $entity_type    Type of entity
87
 * @param mixed  $entity_subtype Subtype of entity
88
 * @param string $name           Name of annotation
89
 * @param string $value          Value of annotation
90
 * @param int    $owner_guid     Guid of owner of annotation
91
 * @param int    $group_guid     Guid of group
92
 * @param int    $limit          Limit
93
 * @param int    $offset         Offset
94
 * @param string $order_by       SQL order by string
95
 * @param bool   $count          Count or return entities
96
 * @param int    $timelower      Lower time limit
97
 * @param int    $timeupper      Upper time limit
98
 *
99
 * @return ElggEntity[]|int
100
 */
101
function get_entities_from_annotations($entity_type = "", $entity_subtype = "", $name = "",
102
$value = "", $owner_guid = 0, $group_guid = 0, $limit = 10, $offset = 0, $order_by = "asc",
103
$count = false, $timelower = 0, $timeupper = 0) {
104
	$msg = 'get_entities_from_annotations() is deprecated by elgg_get_entities_from_annotations().';
105
	elgg_deprecated_notice($msg, 1.7);
106
107
	$options = array();
108
109
	if ($entity_type) {
110
		$options['types'] = $entity_type;
111
	}
112
113
	if ($entity_subtype) {
114
		$options['subtypes'] = $entity_subtype;
115
	}
116
117
	$options['annotation_names'] = $name;
118
119
	if ($value) {
120
		$options['annotation_values'] = $value;
121
	}
122
123
	if ($owner_guid) {
124
		if (is_array($owner_guid)) {
125
			$options['annotation_owner_guids'] = $owner_guid;
126
		} else {
127
			$options['annotation_owner_guid'] = $owner_guid;
128
		}
129
	}
130
131
	if ($group_guid) {
132
		$options['container_guid'] = $group_guid;
133
	}
134
135
	if ($limit) {
136
		$options['limit'] = $limit;
137
	}
138
139
	if ($offset) {
140
		$options['offset'] = $offset;
141
	}
142
143
	if ($order_by) {
144
		$options['order_by'] = "maxtime $order_by";
145
	}
146
147
	if ($count) {
148
		$options['count'] = $count;
149
	}
150
151
	if ($timelower) {
152
		$options['annotation_created_time_lower'] = $timelower;
153
	}
154
155
	if ($timeupper) {
156
		$options['annotation_created_time_upper'] = $timeupper;
157
	}
158
159
	return elgg_get_entities_from_annotations($options);
160
}
161
162
/**
163
 * Lists entities
164
 *
165
 * @see elgg_view_entity_list
166
 *
167
 * @param string  $entity_type    Type of entity.
168
 * @param string  $entity_subtype Subtype of entity.
169
 * @param string  $name           Name of annotation.
170
 * @param string  $value          Value of annotation.
171
 * @param int     $limit          Maximum number of results to return.
172
 * @param int     $owner_guid     Owner.
173
 * @param int     $group_guid     Group container. Currently only supported if entity_type is object
174
 * @param boolean $asc            Whether to list in ascending or descending order (default: desc)
175
 * @param boolean $fullview       Whether to display the entities in full
176
 * @param boolean $listtypetoggle Can 'gallery' view can be displayed (default: no)
177
 *
178
 * @deprecated 1.7 Use elgg_list_entities_from_annotations()
179
 * @return string Formatted entity list
180
 */
181
function list_entities_from_annotations($entity_type = "", $entity_subtype = "", $name = "",
182
$value = "", $limit = 10, $owner_guid = 0, $group_guid = 0, $asc = false, $fullview = true,
183
$listtypetoggle = false) {
184
185
	$msg = 'list_entities_from_annotations is deprecated by elgg_list_entities_from_annotations';
186
	elgg_deprecated_notice($msg, 1.8);
187
188
	$options = array();
189
190
	if ($entity_type) {
191
		$options['types'] = $entity_type;
192
	}
193
194
	if ($entity_subtype) {
195
		$options['subtypes'] = $entity_subtype;
196
	}
197
198
	if ($name) {
199
		$options['annotation_names'] = $name;
200
	}
201
202
	if ($value) {
203
		$options['annotation_values'] = $value;
204
	}
205
206
	if ($limit) {
207
		$options['limit'] = $limit;
208
	}
209
210
	if ($owner_guid) {
211
		$options['annotation_owner_guid'] = $owner_guid;
212
	}
213
214
	if ($group_guid) {
215
		$options['container_guid'] = $group_guid;
216
	}
217
218
	if ($asc) {
219
		$options['order_by'] = 'maxtime desc';
220
	}
221
222
	if ($offset = sanitise_int(get_input('offset', null))) {
223
		$options['offset'] = $offset;
224
	}
225
226
	$options['full_view'] = $fullview;
227
	$options['list_type_toggle'] = $listtypetoggle;
228
	$options['pagination'] = true;
229
230
	return elgg_list_entities_from_annotations($options);
231
}
232
233
/**
234
 * Returns all php files in a directory.
235
 *
236
 * @deprecated 1.7 Use elgg_get_file_list() instead
237
 *
238
 * @param string $directory  Directory to look in
239
 * @param array  $exceptions Array of extensions (with .!) to ignore
240
 * @param array  $list       A list files to include in the return
241
 *
242
 * @return array
243
 */
244
function get_library_files($directory, $exceptions = array(), $list = array()) {
245
	elgg_deprecated_notice('get_library_files() deprecated by elgg_get_file_list()', 1.7);
246
	return elgg_get_file_list($directory, $exceptions, $list, array('.php'));
247
}
248
249
/**
250
 * Add action tokens to URL.
251
 *
252
 * @param string $url URL
253
 *
254
 * @return string
255
 *
256
 * @deprecated 1.7 final
257
 */
258
function elgg_validate_action_url($url) {
259
	elgg_deprecated_notice('elgg_validate_action_url() deprecated by elgg_add_action_tokens_to_url().',
260
		1.7);
261
262
	return elgg_add_action_tokens_to_url($url);
263
}
264
265
/**
266
 * Does nothing.
267
 *
268
 * @deprecated 1.7
269
 * @return 0
0 ignored issues
show
The doc-type 0 could not be parsed: Unknown type name "0" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
270
 */
271
function test_ip() {
272
	elgg_deprecated_notice('test_ip() was removed because of licensing issues.', 1.7);
273
274
	return 0;
275
}
276
277
/**
278
 * Does nothing.
279
 *
280
 * @return bool
281
 * @deprecated 1.7
282
 */
283
function is_ip_in_array() {
284
	elgg_deprecated_notice('is_ip_in_array() was removed because of licensing issues.', 1.7);
285
286
	return false;
287
}
288
289
/**
290
 * Returns entities.
291
 *
292
 * @deprecated 1.7.  Use elgg_get_entities().
293
 *
294
 * @param string $type           Entity type
295
 * @param string $subtype        Entity subtype
296
 * @param int    $owner_guid     Owner GUID
297
 * @param string $order_by       Order by clause
298
 * @param int    $limit          Limit
299
 * @param int    $offset         Offset
300
 * @param bool   $count          Return a count or an array of entities
301
 * @param int    $site_guid      Site GUID
302
 * @param int    $container_guid Container GUID
303
 * @param int    $timelower      Lower time limit
304
 * @param int    $timeupper      Upper time limit
305
 *
306
 * @return array
307
 */
308
function get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10,
309
$offset = 0, $count = false, $site_guid = 0, $container_guid = null, $timelower = 0,
310
$timeupper = 0) {
311
312
	elgg_deprecated_notice('get_entities() was deprecated by elgg_get_entities().', 1.7);
313
314
	// rewrite owner_guid to container_guid to emulate old functionality
315
	if ($owner_guid != "") {
316
		if (is_null($container_guid)) {
317
			$container_guid = $owner_guid;
318
			$owner_guid = NULL;
319
		}
320
	}
321
322
	$options = array();
323
	if ($type) {
324
		if (is_array($type)) {
325
			$options['types'] = $type;
326
		} else {
327
			$options['type'] = $type;
328
		}
329
	}
330
331 View Code Duplication
	if ($subtype) {
332
		if (is_array($subtype)) {
333
			$options['subtypes'] = $subtype;
334
		} else {
335
			$options['subtype'] = $subtype;
336
		}
337
	}
338
339
	if ($owner_guid) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $owner_guid of type null|integer is loosely compared to true; this is ambiguous if the integer can be zero. 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 integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
340
		if (is_array($owner_guid)) {
341
			$options['owner_guids'] = $owner_guid;
342
		} else {
343
			$options['owner_guid'] = $owner_guid;
344
		}
345
	}
346
347
	if ($order_by) {
348
		$options['order_by'] = $order_by;
349
	}
350
351
	// need to pass 0 for all option
352
	$options['limit'] = $limit;
353
354
	if ($offset) {
355
		$options['offset'] = $offset;
356
	}
357
358
	if ($count) {
359
		$options['count'] = $count;
360
	}
361
362
	if ($site_guid) {
363
		$options['site_guids'] = $site_guid;
364
	}
365
366
	if ($container_guid) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $container_guid of type integer|null is loosely compared to true; this is ambiguous if the integer can be zero. 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 integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
367
		$options['container_guids'] = $container_guid;
368
	}
369
370
	if ($timeupper) {
371
		$options['created_time_upper'] = $timeupper;
372
	}
373
374
	if ($timelower) {
375
		$options['created_time_lower'] = $timelower;
376
	}
377
378
	$r = elgg_get_entities($options);
379
	return $r;
380
}
381
382
/**
383
 * Delete multiple entities that match a given query.
384
 * This function iterates through and calls delete_entity on
385
 * each one, this is somewhat inefficient but lets
386
 * the 'delete' event be called for each entity.
387
 *
388
 * @deprecated 1.7. This is a dangerous function as it defaults to deleting everything.
389
 *
390
 * @param string $type       The type of entity (eg "user", "object" etc)
391
 * @param string $subtype    The arbitrary subtype of the entity
392
 * @param int    $owner_guid The GUID of the owning user
393
 *
394
 * @return false
395
 */
396
function delete_entities($type = "", $subtype = "", $owner_guid = 0) {
397
	elgg_deprecated_notice('delete_entities() was deprecated because no one should use it.', 1.7);
398
	return false;
399
}
400
401
/**
402
 * Lists entities.
403
 *
404
 * @param int  $owner_guid     Owner GUID
405
 * @param int  $limit          Limit
406
 * @param bool $fullview       Show entity full views
407
 * @param bool $listtypetoggle Show list type toggle
408
 * @param bool $allowedtypes   A string of the allowed types
409
 *
410
 * @return string
411
 * @deprecated 1.7.  Use elgg_list_registered_entities().
412
 */
413
function list_registered_entities($owner_guid = 0, $limit = 10, $fullview = true,
414
$listtypetoggle = false, $allowedtypes = true) {
415
416
	elgg_deprecated_notice('list_registered_entities() was deprecated by elgg_list_registered_entities().', 1.7);
417
418
	$options = array();
419
420
	// don't want to send anything if not being used.
421
	if ($owner_guid) {
422
		$options['owner_guid'] = $owner_guid;
423
	}
424
425
	if ($limit) {
426
		$options['limit'] = $limit;
427
	}
428
429
	if ($allowedtypes) {
430
		$options['allowed_types'] = $allowedtypes;
431
	}
432
433
	// need to send because might be BOOL
434
	$options['full_view'] = $fullview;
435
	$options['list_type_toggle'] = $listtypetoggle;
436
437
	$options['offset'] = get_input('offset', 0);
438
439
	return elgg_list_registered_entities($options);
440
}
441
442
/**
443
 * Lists entities
444
 *
445
 * @deprecated 1.7.  Use elgg_list_entities().
446
 *
447
 * @param string $type           Entity type
448
 * @param string $subtype        Entity subtype
449
 * @param int    $owner_guid     Owner GUID
450
 * @param int    $limit          Limit
451
 * @param bool   $fullview       Display entity full views?
452
 * @param bool   $listtypetoggle Allow switching to gallery mode?
453
 * @param bool   $pagination     Show pagination?
454
 *
455
 * @return string
456
 */
457
function list_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true,
458
$listtypetoggle = false, $pagination = true) {
459
460
	elgg_deprecated_notice('list_entities() was deprecated by elgg_list_entities()!', 1.7);
461
462
	$options = array();
463
464
	// rewrite owner_guid to container_guid to emulate old functionality
465
	if ($owner_guid) {
466
		$options['container_guids'] = $owner_guid;
467
	}
468
469
	if ($type) {
470
		$options['types'] = $type;
471
	}
472
473
	if ($subtype) {
474
		$options['subtypes'] = $subtype;
475
	}
476
477
	if ($limit) {
478
		$options['limit'] = $limit;
479
	}
480
481
	if ($offset = sanitise_int(get_input('offset', null))) {
482
		$options['offset'] = $offset;
483
	}
484
485
	$options['full_view'] = $fullview;
486
	$options['list_type_toggle'] = $listtypetoggle;
487
	$options['pagination'] = $pagination;
488
489
	return elgg_list_entities($options);
490
}
491
492
/**
493
 * Searches for a group based on a complete or partial name or description
494
 *
495
 * @param string  $criteria The partial or full name or description
496
 * @param int     $limit    Limit of the search.
497
 * @param int     $offset   Offset.
498
 * @param string  $order_by The order.
499
 * @param boolean $count    Whether to return the count of results or just the results.
500
 *
501
 * @return mixed
502
 * @deprecated 1.7
503
 */
504 View Code Duplication
function search_for_group($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
505
	elgg_deprecated_notice('search_for_group() was deprecated by new search plugin.', 1.7);
506
	global $CONFIG;
507
508
	$criteria = sanitise_string($criteria);
509
	$limit = (int)$limit;
510
	$offset = (int)$offset;
511
	$order_by = sanitise_string($order_by);
512
513
	$access = _elgg_get_access_where_sql();
514
515
	if ($order_by == "") {
516
		$order_by = "e.time_created desc";
517
	}
518
519
	if ($count) {
520
		$query = "SELECT count(e.guid) as total ";
521
	} else {
522
		$query = "SELECT e.* ";
523
	}
524
	$query .= "from {$CONFIG->dbprefix}entities e"
525
		. " JOIN {$CONFIG->dbprefix}groups_entity g on e.guid=g.guid where ";
526
527
	$query .= "(g.name like \"%{$criteria}%\" or g.description like \"%{$criteria}%\")";
528
	$query .= " and $access";
529
530
	if (!$count) {
531
		$query .= " order by $order_by limit $offset, $limit"; // Add order and limit
532
		return get_data($query, "entity_row_to_elggstar");
533
	} else {
534
		if ($count = get_data_row($query)) {
535
			return $count->total;
536
		}
537
	}
538
	return false;
539
}
540
541
/**
542
 * Returns a formatted list of groups suitable for injecting into search.
543
 *
544
 * @deprecated 1.7
545
 *
546
 * @param string $hook        Hook name
547
 * @param string $user        User
548
 * @param mixed  $returnvalue Previous hook's return value
549
 * @param string $tag         Tag to search on
550
 *
551
 * @return string
552
 */
553 View Code Duplication
function search_list_groups_by_name($hook, $user, $returnvalue, $tag) {
554
	elgg_deprecated_notice('search_list_groups_by_name() was deprecated by new search plugin', 1.7);
555
	// Change this to set the number of groups that display on the search page
556
	$threshold = 4;
557
558
	$object = get_input('object');
559
560
	if (!get_input('offset') && (empty($object) || $object == 'group')) {
561
		if ($groups = search_for_group($tag, $threshold)) {
562
			$countgroups = search_for_group($tag, 0, 0, "", true);
563
564
			$return = elgg_view('group/search/startblurb', array('count' => $countgroups, 'tag' => $tag));
565
			foreach ($groups as $group) {
566
				$return .= elgg_view_entity($group);
567
			}
568
			$vars = array('count' => $countgroups, 'threshold' => $threshold, 'tag' => $tag);
569
			$return .= elgg_view('group/search/finishblurb', $vars);
570
			return $return;
571
		}
572
	}
573
}
574
575
/**
576
 * Displays a list of group objects that have been searched for.
577
 *
578
 * @see elgg_view_entity_list
579
 *
580
 * @param string $tag   Search criteria
581
 * @param int    $limit The number of entities to display on a page
582
 *
583
 * @return string The list in a form suitable to display
584
 * @deprecated 1.7
585
 */
586 View Code Duplication
function list_group_search($tag, $limit = 10) {
587
	elgg_deprecated_notice('list_group_search() was deprecated by new search plugin.', 1.7);
588
	$offset = (int) get_input('offset');
589
	$limit = (int) $limit;
590
	$count = (int) search_for_group($tag, 10, 0, '', true);
591
	$entities = search_for_group($tag, $limit, $offset);
592
593
	return elgg_view_entity_list($entities, $count, $offset, $limit, true, false);
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...
594
595
}
596
597
/**
598
 * Return a list of entities based on the given search criteria.
599
 *
600
 * @deprecated 1.7 use elgg_get_entities_from_metadata().
601
 *
602
 * @param mixed  $meta_name      Metadat name
603
 * @param mixed  $meta_value     Metadata value
604
 * @param string $entity_type    The type of entity to look for, eg 'site' or 'object'
605
 * @param string $entity_subtype The subtype of the entity.
606
 * @param int    $owner_guid     Owner GUID
607
 * @param int    $limit          Limit
608
 * @param int    $offset         Offset
609
 * @param string $order_by       Optional ordering.
610
 * @param int    $site_guid      Site GUID. 0 for current, -1 for any.
611
 * @param bool   $count          Return a count instead of entities
612
 * @param bool   $case_sensitive Metadata names case sensitivity
613
 *
614
 * @return int|array A list of entities, or a count if $count is set to true
615
 */
616
function get_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "",
617
$entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "",
618
$site_guid = 0, $count = FALSE, $case_sensitive = TRUE) {
619
620
	elgg_deprecated_notice('get_entities_from_metadata() was deprecated by elgg_get_entities_from_metadata()!', 1.7);
621
622
	$options = array();
623
624
	$options['metadata_names'] = $meta_name;
625
626
	if ($meta_value) {
627
		$options['metadata_values'] = $meta_value;
628
	}
629
630
	if ($entity_type) {
631
		$options['types'] = $entity_type;
632
	}
633
634
	if ($entity_subtype) {
635
		$options['subtypes'] = $entity_subtype;
636
	}
637
638
	if ($owner_guid) {
639
		if (is_array($owner_guid)) {
640
			$options['owner_guids'] = $owner_guid;
641
		} else {
642
			$options['owner_guid'] = $owner_guid;
643
		}
644
	}
645
646
	if ($limit) {
647
		$options['limit'] = $limit;
648
	}
649
650
	if ($offset) {
651
		$options['offset'] = $offset;
652
	}
653
654
	if ($order_by) {
655
		$options['order_by'];
656
	}
657
658
	if ($site_guid) {
659
		$options['site_guid'];
660
	}
661
662
	if ($count) {
663
		$options['count'] = $count;
664
	}
665
666
	// need to be able to pass false
667
	$options['metadata_case_sensitive'] = $case_sensitive;
668
669
	return elgg_get_entities_from_metadata($options);
670
}
671
672
/**
673
 * Return entities from metadata
674
 *
675
 * @deprecated 1.7.  Use elgg_get_entities_from_metadata().
676
 *
677
 * @param mixed  $meta_array          Metadata name
678
 * @param string $entity_type         The type of entity to look for, eg 'site' or 'object'
679
 * @param string $entity_subtype      The subtype of the entity.
680
 * @param int    $owner_guid          Owner GUID
681
 * @param int    $limit               Limit
682
 * @param int    $offset              Offset
683
 * @param string $order_by            Optional ordering.
684
 * @param int    $site_guid           Site GUID. 0 for current, -1 for any.
685
 * @param bool   $count               Return a count instead of entities
686
 * @param bool   $meta_array_operator Operator for metadata values
687
 *
688
 * @return int|array A list of entities, or a count if $count is set to true
689
 */
690
function get_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "",
691
$owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0,
692
$count = false, $meta_array_operator = 'and') {
693
694
	elgg_deprecated_notice('get_entities_from_metadata_multi() was deprecated by elgg_get_entities_from_metadata()!', 1.7);
695
696
	if (!is_array($meta_array) || sizeof($meta_array) == 0) {
697
		return false;
698
	}
699
700
	$options = array();
701
702
	$options['metadata_name_value_pairs'] = $meta_array;
703
704
	if ($entity_type) {
705
		$options['types'] = $entity_type;
706
	}
707
708
	if ($entity_subtype) {
709
		$options['subtypes'] = $entity_subtype;
710
	}
711
712
	if ($owner_guid) {
713
		if (is_array($owner_guid)) {
714
			$options['owner_guids'] = $owner_guid;
715
		} else {
716
			$options['owner_guid'] = $owner_guid;
717
		}
718
	}
719
720
	if ($limit) {
721
		$options['limit'] = $limit;
722
	}
723
724
	if ($offset) {
725
		$options['offset'] = $offset;
726
	}
727
728
	if ($order_by) {
729
		$options['order_by'];
730
	}
731
732
	if ($site_guid) {
733
		$options['site_guid'];
734
	}
735
736
	if ($count) {
737
		$options['count'] = $count;
738
	}
739
740
	$options['metadata_name_value_pairs_operator'] = $meta_array_operator;
741
742
	return elgg_get_entities_from_metadata($options);
743
}
744
745
/**
746
 * Returns a menu item for use in the children section of add_menu()
747
 * This is not currently used in the Elgg core.
748
 *
749
 * @param string $menu_name The name of the menu item
750
 * @param string $menu_url  Its URL
751
 *
752
 * @return \stdClass|false Depending on success
753
 * @deprecated 1.7
754
 */
755
function menu_item($menu_name, $menu_url) {
756
	elgg_deprecated_notice('menu_item() is deprecated by add_submenu_item', 1.7);
757
	return make_register_object($menu_name, $menu_url);
758
}
759
760
/**
761
 * Searches for an object based on a complete or partial title
762
 * or description using full text searching.
763
 *
764
 * IMPORTANT NOTE: With MySQL's default setup:
765
 * 1) $criteria must be 4 or more characters long
766
 * 2) If $criteria matches greater than 50% of results NO RESULTS ARE RETURNED!
767
 *
768
 * @param string  $criteria The partial or full name or username.
769
 * @param int     $limit    Limit of the search.
770
 * @param int     $offset   Offset.
771
 * @param string  $order_by The order.
772
 * @param boolean $count    Whether to return the count of results or just the results.
773
 *
774
 * @return int|false
775
 * @deprecated 1.7
776
 */
777 View Code Duplication
function search_for_object($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
778
	elgg_deprecated_notice('search_for_object() was deprecated by new search plugin.', 1.7);
779
	global $CONFIG;
780
781
	$criteria = sanitise_string($criteria);
782
	$limit = (int)$limit;
783
	$offset = (int)$offset;
784
	$order_by = sanitise_string($order_by);
785
786
	$access = _elgg_get_access_where_sql();
787
788
	if ($order_by == "") {
789
		$order_by = "e.time_created desc";
790
	}
791
792
	if ($count) {
793
		$query = "SELECT count(e.guid) as total ";
794
	} else {
795
		$query = "SELECT e.* ";
796
	}
797
	$query .= "from {$CONFIG->dbprefix}entities e
798
		join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid
799
		where match(o.title,o.description) against ('$criteria') and $access";
800
801
	if (!$count) {
802
		$query .= " order by $order_by limit $offset, $limit"; // Add order and limit
803
		return get_data($query, "entity_row_to_elggstar");
804
	} else {
805
		if ($count = get_data_row($query)) {
806
			return $count->total;
807
		}
808
	}
809
	return false;
810
}
811
812
/**
813
 * Returns a formatted list of objects suitable for injecting into search.
814
 *
815
 * @deprecated 1.7
816
 *
817
 * @param sting  $hook        Hook
818
 * @param string $user        user
819
 * @param mixed  $returnvalue Previous return value
820
 * @param mixed  $tag         Search term
821
 *
822
 * @return array
823
 */
824 View Code Duplication
function search_list_objects_by_name($hook, $user, $returnvalue, $tag) {
825
	elgg_deprecated_notice('search_list_objects_by_name was deprecated by new search plugin.', 1.7);
826
827
	// Change this to set the number of users that display on the search page
828
	$threshold = 4;
829
830
	$object = get_input('object');
831
832
	if (!get_input('offset') && (empty($object) || $object == 'user')) {
833
		if ($users = search_for_user($tag, $threshold)) {
834
			$countusers = search_for_user($tag, 0, 0, "", true);
835
836
			$return = elgg_view('user/search/startblurb', array('count' => $countusers, 'tag' => $tag));
837
			foreach ($users as $user) {
838
				$return .= elgg_view_entity($user);
839
			}
840
			$return .= elgg_view('user/search/finishblurb',
841
				array('count' => $countusers, 'threshold' => $threshold, 'tag' => $tag));
842
843
			return $return;
844
845
		}
846
	}
847
}
848
849
/**
850
 * Return entities from relationships
851
 *
852
 * @deprecated 1.7 Use elgg_get_entities_from_relationship()
853
 *
854
 * @param string $relationship         The relationship type
855
 * @param int    $relationship_guid    The GUID of the relationship owner
856
 * @param bool   $inverse_relationship Invert relationship?
857
 * @param string $type                 Entity type
858
 * @param string $subtype              Entity subtype
859
 * @param int    $owner_guid           Entity owner GUID
860
 * @param string $order_by             Order by clause
861
 * @param int    $limit                Limit
862
 * @param int    $offset               Offset
863
 * @param bool   $count                Return a count instead of entities?
864
 * @param int    $site_guid            Site GUID
865
 *
866
 * @return mixed
867
 */
868
function get_entities_from_relationship($relationship, $relationship_guid,
869
$inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0,
870
$order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
871
872
	elgg_deprecated_notice('get_entities_from_relationship() was deprecated by elgg_get_entities_from_relationship()!', 1.7);
873
874
	$options = array();
875
876
	$options['relationship'] = $relationship;
877
	$options['relationship_guid'] = $relationship_guid;
878
	$options['inverse_relationship'] = $inverse_relationship;
879
880
	if ($type) {
881
		$options['types'] = $type;
882
	}
883
884
	if ($subtype) {
885
		$options['subtypes'] = $subtype;
886
	}
887
888
	if ($owner_guid) {
889
		$options['owner_guid'] = $owner_guid;
890
	}
891
892
	$options['limit'] = $limit;
893
894
	if ($offset) {
895
		$options['offset'] = $offset;
896
	}
897
898
	if ($order_by) {
899
		$options['order_by'];
900
	}
901
902
	if ($site_guid) {
903
		$options['site_guid'];
904
	}
905
906
	if ($count) {
907
		$options['count'] = $count;
908
	}
909
910
	return elgg_get_entities_from_relationship($options);
911
}
912
913
/**
914
 * Searches for a site based on a complete or partial name
915
 * or description or url using full text searching.
916
 *
917
 * IMPORTANT NOTE: With MySQL's default setup:
918
 * 1) $criteria must be 4 or more characters long
919
 * 2) If $criteria matches greater than 50% of results NO RESULTS ARE RETURNED!
920
 *
921
 * @param string  $criteria The partial or full name or username.
922
 * @param int     $limit    Limit of the search.
923
 * @param int     $offset   Offset.
924
 * @param string  $order_by The order.
925
 * @param boolean $count    Whether to return the count of results or just the results.
926
 *
927
 * @return mixed
928
 * @deprecated 1.7
929
 */
930 View Code Duplication
function search_for_site($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
931
	elgg_deprecated_notice('search_for_site() was deprecated by new search plugin.', 1.7);
932
	global $CONFIG;
933
934
	$criteria = sanitise_string($criteria);
935
	$limit = (int)$limit;
936
	$offset = (int)$offset;
937
	$order_by = sanitise_string($order_by);
938
939
	$access = _elgg_get_access_where_sql();
940
941
	if ($order_by == "") {
942
		$order_by = "e.time_created desc";
943
	}
944
945
	if ($count) {
946
		$query = "SELECT count(e.guid) as total ";
947
	} else {
948
		$query = "SELECT e.* ";
949
	}
950
	$query .= "from {$CONFIG->dbprefix}entities e
951
		join {$CONFIG->dbprefix}sites_entity s on e.guid=s.guid
952
		where match(s.name, s.description, s.url) against ('$criteria') and $access";
953
954
	if (!$count) {
955
		$query .= " order by $order_by limit $offset, $limit"; // Add order and limit
956
		return get_data($query, "entity_row_to_elggstar");
957
	} else {
958
		if ($count = get_data_row($query)) {
959
			return $count->total;
960
		}
961
	}
962
	return false;
963
}
964
965
/**
966
 * Searches for a user based on a complete or partial name or username.
967
 *
968
 * @param string  $criteria The partial or full name or username.
969
 * @param int     $limit    Limit of the search.
970
 * @param int     $offset   Offset.
971
 * @param string  $order_by The order.
972
 * @param boolean $count    Whether to return the count of results or just the results.
973
 *
974
 * @return mixed
975
 * @deprecated 1.7
976
 */
977 View Code Duplication
function search_for_user($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
978
	elgg_deprecated_notice('search_for_user() was deprecated by new search.', 1.7);
979
	global $CONFIG;
980
981
	$criteria = sanitise_string($criteria);
982
	$limit = (int)$limit;
983
	$offset = (int)$offset;
984
	$order_by = sanitise_string($order_by);
985
986
	$access = _elgg_get_access_where_sql();
987
988
	if ($order_by == "") {
989
		$order_by = "e.time_created desc";
990
	}
991
992
	if ($count) {
993
		$query = "SELECT count(e.guid) as total ";
994
	} else {
995
		$query = "SELECT e.* ";
996
	}
997
	$query .= "from {$CONFIG->dbprefix}entities e
998
		join {$CONFIG->dbprefix}users_entity u on e.guid=u.guid where ";
999
1000
	$query .= "(u.name like \"%{$criteria}%\" or u.username like \"%{$criteria}%\")";
1001
	$query .= " and $access";
1002
1003
	if (!$count) {
1004
		$query .= " order by $order_by limit $offset, $limit";
1005
		return get_data($query, "entity_row_to_elggstar");
1006
	} else {
1007
		if ($count = get_data_row($query)) {
1008
			return $count->total;
1009
		}
1010
	}
1011
	return false;
1012
}
1013
1014
/**
1015
 * Displays a list of user objects that have been searched for.
1016
 *
1017
 * @see elgg_view_entity_list
1018
 *
1019
 * @param string $tag   Search criteria
1020
 * @param int    $limit The number of entities to display on a page
1021
 *
1022
 * @return string The list in a form suitable to display
1023
 *
1024
 * @deprecated 1.7
1025
 */
1026 View Code Duplication
function list_user_search($tag, $limit = 10) {
1027
	elgg_deprecated_notice('list_user_search() deprecated by new search', 1.7);
1028
	$offset = (int) get_input('offset');
1029
	$limit = (int) $limit;
1030
	$count = (int) search_for_user($tag, 10, 0, '', true);
1031
	$entities = search_for_user($tag, $limit, $offset);
1032
1033
	return elgg_view_entity_list($entities, $count, $offset, $limit, true, false);
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...
1034
}
1035
1036
/**
1037
 * Returns a formatted list of users suitable for injecting into search.
1038
 *
1039
 * @deprecated 1.7
1040
 *
1041
 * @param string $hook        Hook name
1042
 * @param string $user        User?
1043
 * @param mixed  $returnvalue Previous hook's return value
1044
 * @param mixed  $tag         Tag to search against
1045
 *
1046
 * @return void
1047
 */
1048 View Code Duplication
function search_list_users_by_name($hook, $user, $returnvalue, $tag) {
1049
	elgg_deprecated_notice('search_list_users_by_name() was deprecated by new search', 1.7);
1050
	// Change this to set the number of users that display on the search page
1051
	$threshold = 4;
1052
1053
	$object = get_input('object');
1054
1055
	if (!get_input('offset') && (empty($object) || $object == 'user')) {
1056
		if ($users = search_for_user($tag, $threshold)) {
1057
			$countusers = search_for_user($tag, 0, 0, "", true);
1058
1059
			$return = elgg_view('user/search/startblurb', array('count' => $countusers, 'tag' => $tag));
1060
			foreach ($users as $user) {
1061
				$return .= elgg_view_entity($user);
1062
			}
1063
1064
			$vars = array('count' => $countusers, 'threshold' => $threshold, 'tag' => $tag);
1065
			$return .= elgg_view('user/search/finishblurb', $vars);
1066
			return $return;
1067
1068
		}
1069
	}
1070
}
1071
1072
/**
1073
 * Extend a view
1074
 *
1075
 * @deprecated 1.7.  Use elgg_extend_view().
1076
 *
1077
 * @param string $view      The view to extend.
1078
 * @param string $view_name This view is added to $view
1079
 * @param int    $priority  The priority, from 0 to 1000,
1080
 *                          to add at (lowest numbers displayed first)
1081
 * @param string $viewtype  Not used
1082
 *
1083
 * @return void
1084
 */
1085
function extend_view($view, $view_name, $priority = 501, $viewtype = '') {
1086
	elgg_deprecated_notice('extend_view() was deprecated by elgg_extend_view()!', 1.7);
1087
	elgg_extend_view($view, $view_name, $priority, $viewtype);
1088
}
1089
1090
/**
1091
 * Get views in a dir
1092
 *
1093
 * @deprecated 1.7.  Use elgg_get_views().
1094
 *
1095
 * @param string $dir  Dir
1096
 * @param string $base Base view
1097
 *
1098
 * @return array
1099
 */
1100
function get_views($dir, $base) {
1101
	elgg_deprecated_notice('get_views() was deprecated by elgg_get_views()!', 1.7);
1102
	elgg_get_views($dir, $base);
1103
}
1104
1105
/**
1106
 * Constructs and returns a register object.
1107
 *
1108
 * @param string $register_name  The name of the register
1109
 * @param mixed  $register_value The value of the register
1110
 * @param array  $children_array Optionally, an array of children
1111
 *
1112
 * @return false|\stdClass Depending on success
1113
 * @deprecated 1.7 Use {@link add_submenu_item()}
1114
 */
1115
function make_register_object($register_name, $register_value, $children_array = array()) {
1116
	elgg_deprecated_notice('make_register_object() is deprecated by add_submenu_item()', 1.7);
1117
	if (empty($register_name) || empty($register_value)) {
1118
		return false;
1119
	}
1120
1121
	$register = new \stdClass;
1122
	$register->name = $register_name;
1123
	$register->value = $register_value;
1124
	$register->children = $children_array;
1125
1126
	return $register;
1127
}
1128
1129
/**
1130
 * THIS FUNCTION IS DEPRECATED.
1131
 *
1132
 * Delete a object's extra data.
1133
 *
1134
 * @todo - this should be removed - was deprecated in 1.5 or earlier
1135
 *
1136
 * @param int $guid GUID
1137
 *
1138
 * @return 1
0 ignored issues
show
The doc-type 1 could not be parsed: Unknown type name "1" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
1139
 * @deprecated 1.7
1140
 */
1141
function delete_object_entity($guid) {
1142
	system_message(elgg_echo('deprecatedfunction', array('delete_user_entity')));
1143
1144
	return 1; // Always return that we have deleted one row in order to not break existing code.
1145
}
1146
1147
/**
1148
 * THIS FUNCTION IS DEPRECATED.
1149
 *
1150
 * Delete a user's extra data.
1151
 *
1152
 * @todo remove
1153
 *
1154
 * @param int $guid User GUID
1155
 *
1156
 * @return 1
0 ignored issues
show
The doc-type 1 could not be parsed: Unknown type name "1" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
1157
 * @deprecated 1.7
1158
 */
1159
function delete_user_entity($guid) {
1160
	system_message(elgg_echo('deprecatedfunction', array('delete_user_entity')));
1161
1162
	return 1; // Always return that we have deleted one row in order to not break existing code.
1163
}