Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

mod/activity/views/default/resources/river.php (1 issue)

1
<?php
2
/**
3
 * Main activity stream list page
4
 */
5
6
$options = [
7
	'distinct' => false,
8
	'no_results' => elgg_echo('river:none'),
9
];
10
11
$type = preg_replace('[\W]', '', get_input('type', 'all'));
12
$subtype = preg_replace('[\W]', '', get_input('subtype', ''));
13
if ($subtype) {
14
	$selector = "type=$type&subtype=$subtype";
15
} else {
16
	$selector = "type=$type";
17
}
18
19
if ($type != 'all') {
20
	$options['type'] = $type;
21
	if ($subtype) {
22
		$options['subtype'] = $subtype;
23
	}
24
}
25
26
switch ($vars['_route']) {
27
	case 'collection:river:owner':
28
		elgg_gatekeeper();
29
		if ($vars['username'] === elgg_get_logged_in_user_entity()->username) {
30
			elgg_set_page_owner_guid(elgg_get_logged_in_user_guid());
31
32
			$title = elgg_echo('river:mine');
33
			$page_filter = 'mine';
34
			$options['subject_guid'] = elgg_get_logged_in_user_guid();
35
			break;
36
		} else {
37
			$subject_username = elgg_extract('username', $vars, '');
38
			$subject = get_user_by_username($subject_username);
39
			if (!$subject) {
40
				register_error(elgg_echo('river:subject:invalid_subject'));
41
				forward();
42
			}
43
			elgg_set_page_owner_guid($subject->guid);
44
			$title = elgg_echo('river:owner', [htmlspecialchars($subject->name, ENT_QUOTES, 'UTF-8', false)]);
45
			$page_filter = 'subject';
46
			$options['subject_guid'] = $subject->guid;
47
			break;
48
		}
49
	case 'collection:river:friends':
50
		if (elgg_is_active_plugin('friends')) {
1 ignored issue
show
Coding Style Comprehensibility introduced by
Consider adding a comment if this fall-through is intended.
Loading history...
51
			$title = elgg_echo('river:friends');
52
			$page_filter = 'friends';
53
			$options['relationship_guid'] = elgg_get_logged_in_user_guid();
54
			$options['relationship'] = 'friend';
55
			break;
56
		}
57
	default:
58
		$title = elgg_echo('river:all');
59
		$page_filter = 'all';
60
		break;
61
}
62
63
$activity = elgg_list_river($options);
64
65
$content = elgg_view('river/filter', ['selector' => $selector]);
66
67
$sidebar = elgg_view('river/sidebar');
68
69
$body = elgg_view_layout('default', [
70
	'title' => $title,
71
	'content' =>  $content . $activity,
72
	'sidebar' => $sidebar ? : false,
73
	'filter_context' => $page_filter,
74
	'class' => 'elgg-river-layout',
75
]);
76
77
echo elgg_view_page($title, $body);
78