Conditions | 5 |
Paths | 1 |
Total Lines | 25 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | public function __invoke(\Elgg\Event $event) { |
||
20 | $user = $event->getObject(); |
||
21 | |||
22 | elgg_call(ELGG_IGNORE_ACCESS, function() use ($user) { |
||
23 | // check if the user already has widgets |
||
24 | if (elgg_get_widgets($user->guid, 'admin')) { |
||
25 | return; |
||
26 | } |
||
27 | |||
28 | // In the form column => array of handlers in order, top to bottom |
||
29 | $adminWidgets = [ |
||
30 | 1 => ['control_panel', 'admin_welcome'], |
||
31 | 2 => ['online_users', 'new_users', 'content_stats'], |
||
32 | ]; |
||
33 | |||
34 | foreach ($adminWidgets as $column => $handlers) { |
||
35 | foreach ($handlers as $position => $handler) { |
||
36 | $guid = elgg_create_widget($user->guid, $handler, 'admin'); |
||
37 | if ($guid === false) { |
||
38 | continue; |
||
39 | } |
||
40 | |||
41 | /* @var \ElggWidget $widget */ |
||
42 | $widget = get_entity($guid); |
||
43 | $widget->move($column, $position); |
||
44 | } |
||
49 |