Passed
Push — master ( f13f78...5c1b24 )
by Ismayil
04:22
created

groups/views/default/resources/groups/activity.php (1 issue)

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

1
<?php
2
3
$guid = elgg_extract('guid', $vars);
4
elgg_entity_gatekeeper($guid, 'group');
5
6
elgg_set_page_owner_guid($guid);
7
8
elgg_group_gatekeeper();
9
10
$group = get_entity($guid);
11
12
if (elgg_get_plugin_setting('allow_activity', 'groups') === 'no'
13
		|| $group->activity_enable !== 'yes') {
14
	forward($group->getURL(), '404');
15
}
16
17
$title = elgg_echo('groups:activity');
18
19
elgg_push_breadcrumb($group->name, $group->getURL());
20
elgg_push_breadcrumb($title);
21
22
$db_prefix = elgg_get_config('dbprefix');
23
24
$options = [
25
	'joins' => [
26
		"JOIN {$db_prefix}entities e1 ON e1.guid = rv.object_guid",
27
		"LEFT JOIN {$db_prefix}entities e2 ON e2.guid = rv.target_guid",
28
	],
29
	'wheres' => [
30
		"(e1.container_guid = $group->guid OR e2.container_guid = $group->guid)",
31
	],
32
	'no_results' => elgg_echo('groups:activity:none'),
33
];
34
35
$type = preg_replace('[\W]', '', get_input('type', 'all'));
36
$subtype = preg_replace('[\W]', '', get_input('subtype', ''));
37
if ($subtype) {
38
	$selector = "type=$type&subtype=$subtype";
39
} else {
40
	$selector = "type=$type";
41
}
42
43 View Code Duplication
if ($type != 'all') {
1 ignored issue
show
This code seems to be duplicated across your project.

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

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

Loading history...
44
	$options['type'] = $type;
45
	if ($subtype) {
46
		$options['subtype'] = $subtype;
47
	}
48
}
49
50
$content = elgg_view('core/river/filter', ['selector' => $selector]);
51
$content .= elgg_list_river($options);
52
53
$body = elgg_view_layout('content', [
54
	'content' => $content,
55
	'title' => $title,
56
	'filter' => '',
57
	'class' => 'elgg-river-layout',
58
]);
59
60
echo elgg_view_page($title, $body);
61