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

mod/activity/start.php (2 issues)

1
<?php
2
3
/**
4
 * Page handler for activity
5
 *
6
 * @param array $segments URL segments
7
 * @return \Elgg\Http\ResponseBuilder
8
 * @access private
9
 */
10
function elgg_activity_page_handler($segments) {
11
	
12
	// make a URL segment available in page handler script
13
	$page_type = elgg_extract(0, $segments, 'all');
14
	$page_type = preg_replace('[\W]', '', $page_type);
15
16
	if ($page_type == 'owner') {
17
		elgg_gatekeeper();
18
		$page_username = elgg_extract(1, $segments, '');
19
		if ($page_username == elgg_get_logged_in_user_entity()->username) {
20
			$page_type = 'mine';
21
		} else {
22
			$vars['subject_username'] = $page_username;
0 ignored issues
show
Comprehensibility Best Practice introduced by Steve Clay
$vars was never initialized. Although not strictly required by PHP, it is generally a good practice to add $vars = array(); before regardless.
Loading history...
23
		}
24
	}
25
26
	$vars['page_type'] = $page_type;
27
28
	return elgg_ok_response(elgg_view_resource("river", $vars));
29
}
30
31
/**
32
 * Register menu items for the title menu
33
 *
34
 * @param string $hook   Hook
35
 * @param string $type   Type
36
 * @param array  $return Current return value
37
 * @param array  $params Hook parameters
38
 * @return array
39
 *
40
 * @access private
41
 *
42
 * @since 3.0
43
 */
44
function _elgg_activity_owner_block_menu($hook, $type, $return, $params) {
45
46
	$entity = elgg_extract('entity', $params);
47
	
48
	if ($entity instanceof \ElggUser) {
49
		$return[] = \ElggMenuItem::factory([
50
			'name' => 'activity:owner',
51
			'text' => elgg_echo('activity:owner'),
52
			'href' => "activity/owner/{$entity->username}",
53
		]);
54
	}
55
	
56
	return $return;
57
}
58
59
/**
60
 * Called during system init
61
 *
62
 * @return void
63
 */
64
function elgg_activity_init() {
65
	
66 31
	elgg_extend_view('css/elgg', 'river/filter.css');
67
	
68 31
	elgg_register_page_handler('activity', 'elgg_activity_page_handler');
0 ignored issues
show
Deprecated Code introduced by Steve Clay
The function elgg_register_page_handler() has been deprecated: 3.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

68
	/** @scrutinizer ignore-deprecated */ elgg_register_page_handler('activity', 'elgg_activity_page_handler');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
69
70 31
	elgg_register_menu_item('site', [
71 31
		'name' => 'activity',
72 31
		'text' => elgg_echo('activity'),
73 31
		'href' => 'activity',
74
	]);
75
	
76 31
	elgg_register_plugin_hook_handler('register', 'menu:owner_block', '_elgg_activity_owner_block_menu');
77 31
}
78
79
return function() {
80 18
	elgg_register_event_handler('init', 'system', 'elgg_activity_init');
81
};
82