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

mod/dashboard/start.php (1 issue)

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');
0 ignored issues
show
Deprecated Code introduced by
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

12
	/** @scrutinizer ignore-deprecated */ elgg_register_page_handler('dashboard', 'dashboard_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...
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) {
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