1 | <?php |
||
2 | |||
3 | elgg_gatekeeper(); |
||
4 | |||
5 | $limit = get_input('limit', elgg_get_config('default_limit')); |
||
6 | $query = get_input('term', get_input('q')); |
||
7 | $input_name = get_input('name'); |
||
8 | |||
9 | elgg_set_http_header("Content-Type: application/json;charset=utf-8"); |
||
10 | |||
11 | $options = [ |
||
12 | 'query' => $query, |
||
13 | 'type' => 'user', |
||
14 | 'limit' => $limit, |
||
15 | 'sort' => 'name', |
||
16 | 'order' => 'ASC', |
||
17 | 'fields' => ['metadata' => ['name', 'username']], |
||
18 | 'item_view' => 'search/entity', |
||
19 | 'input_name' => $input_name, |
||
20 | ]; |
||
21 | |||
22 | if (get_input('friends_only', false)) { |
||
23 | $target_guid = get_input('match_target'); |
||
24 | if ($target_guid) { |
||
25 | $target = get_entity($target_guid); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
26 | } else { |
||
27 | $target = elgg_get_logged_in_user_entity(); |
||
28 | } |
||
29 | |||
30 | if (!$target || !$target->canEdit()) { |
||
31 | throw new \Elgg\EntityPermissionsException(); |
||
32 | } |
||
33 | |||
34 | $dbprefix = elgg_get_config('dbprefix'); |
||
35 | $options['wheres'][] = function(QueryBuilder $qb) use ($target) { |
||
0 ignored issues
–
show
The type
QueryBuilder was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths
Loading history...
|
|||
36 | $subquery = $qb->subquery('entity_relationships', 'er'); |
||
37 | $subquery->select('1') |
||
38 | ->where($qb->compare('er.guid_two', '=', 'e.guid')) |
||
39 | ->andWhere($qb->compare('er.relationship', '=', 'friend', ELGG_VALUE_STRING)) |
||
40 | ->andWhere($qb->compare('er.guid_one', '=', $target->guid, ELGG_VALUE_INTEGER)); |
||
41 | |||
42 | return "EXISTS ({$subquery->getSQL()})"; |
||
43 | }; |
||
44 | } |
||
45 | |||
46 | echo elgg_list_entities($options, 'elgg_search'); |
||
47 |