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

mod/dashboard/start.php (3 issues)

1
<?php
2
/**
3
 * A user dashboard
4
 */
5
6
/**
7
 * Dashboard init
8
 *
9
 * @return void
10
 */
11
function dashboard_init() {
12 31
	elgg_register_page_handler('dashboard', 'dashboard_page_handler');
13
14 31
	if (elgg_is_logged_in()) {
15
		elgg_register_menu_item('topbar', [
16
			'name' => 'dashboard',
17
			'href' => 'dashboard',
18
			'text' => elgg_echo('dashboard'),
19
			'icon' => 'th-large',
20
			'priority' => 100,
21
			'section' => 'alt',
22
			'parent_name' => 'account',
23
		]);
24
	}
25
	
26 31
	elgg_register_plugin_hook_handler('get_list', 'default_widgets', 'dashboard_default_widgets');
27 31
}
28
29
/**
30
 * Dashboard page handler
31
 *
32
 * @return bool
33
 */
34
function dashboard_page_handler() {
35
	echo elgg_view_resource('dashboard');
36
	return true;
37
}
38
39
/**
40
 * Register user dashboard with default widgets
41
 *
42
 * @param string $hook   'get_list',
43
 * @param string $type   'default_widgets'
44
 * @param array  $return current return value
45
 * @param mixed  $params supplied params
46
 *
47
 * @return array
48
 */
49
function dashboard_default_widgets($hook, $type, $return, $params) {
3 ignored issues
show
The parameter $params is not used and could be removed. ( Ignorable by Annotation )

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

49
function dashboard_default_widgets($hook, $type, $return, /** @scrutinizer ignore-unused */ $params) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $hook is not used and could be removed. ( Ignorable by Annotation )

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

49
function dashboard_default_widgets(/** @scrutinizer ignore-unused */ $hook, $type, $return, $params) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

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

49
function dashboard_default_widgets($hook, /** @scrutinizer ignore-unused */ $type, $return, $params) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
50 18
	$return[] = [
51 18
		'name' => elgg_echo('dashboard'),
52 18
		'widget_context' => 'dashboard',
53 18
		'widget_columns' => 3,
54
55 18
		'event' => 'create',
56 18
		'entity_type' => 'user',
57
		'entity_subtype' => ELGG_ENTITIES_ANY_VALUE,
58
	];
59
60 18
	return $return;
61
}
62
63
return function() {
64 18
	elgg_register_event_handler('init', 'system', 'dashboard_init');
65
};
66