Elgg  Version 3.0
admin.php
Go to the documentation of this file.
1 <?php
25 
34 function elgg_get_admins(array $options = []) {
35  $options['type'] = 'user';
36  $options['metadata_name_value_pairs'] = elgg_extract('metadata_name_value_pairs', $options, []);
37 
38  $options['metadata_name_value_pairs']['admin'] = 'yes';
39 
41 }
42 
60  return _elgg_services()->adminNotices->add($id, $message);
61 }
62 
72  return _elgg_services()->adminNotices->delete($id);
73 }
74 
83 function elgg_get_admin_notices(array $options = []) {
84  return _elgg_services()->adminNotices->find($options);
85 }
86 
96  return _elgg_services()->adminNotices->exists($id);
97 }
98 
111  if (!$object instanceof \ElggUpgrade) {
112  return;
113  }
114 
115  // Link to the Upgrades section
116  $link = elgg_view('output/url', [
117  'href' => 'admin/upgrades',
118  'text' => elgg_echo('admin:view_upgrades'),
119  ]);
120 
121  $message = elgg_echo('admin:pending_upgrades');
122 
123  elgg_add_admin_notice('pending_upgrades', "$message $link");
124 }
125 
131 function _elgg_admin_init() {
132 
133  elgg_register_css('elgg.admin', elgg_get_simplecache_url('admin.css'));
134  elgg_register_css('admin/users/unvalidated', elgg_get_simplecache_url('admin/users/unvalidated.css'));
135 
136  elgg_define_js('admin/users/unvalidated', [
137  'src' => elgg_get_simplecache_url('admin/users/unvalidated.js'),
138  ]);
139 
140  elgg_extend_view('admin.css', 'lightbox/elgg-colorbox-theme/colorbox.css');
141 
142  elgg_register_plugin_hook_handler('register', 'menu:admin_header', '_elgg_admin_header_menu');
143  elgg_register_plugin_hook_handler('register', 'menu:admin_footer', '_elgg_admin_footer_menu');
144  elgg_register_plugin_hook_handler('register', 'menu:filter:admin/upgrades', '_elgg_admin_upgrades_menu');
145  elgg_register_plugin_hook_handler('register', 'menu:page', '_elgg_admin_page_menu');
146  elgg_register_plugin_hook_handler('register', 'menu:page', '_elgg_admin_page_menu_plugin_settings');
147  elgg_register_plugin_hook_handler('register', 'menu:user:unvalidated:bulk', '_elgg_admin_user_unvalidated_bulk_menu');
148 
149  // maintenance mode
150  if (elgg_get_config('elgg_maintenance_mode', null)) {
151  elgg_register_plugin_hook_handler('route', 'all', '_elgg_admin_maintenance_handler', 600);
152  elgg_register_plugin_hook_handler('action', 'all', '_elgg_admin_maintenance_action_check', 600);
153  elgg_register_css('maintenance', elgg_get_simplecache_url('maintenance.css'));
154 
155  elgg_register_menu_item('topbar', [
156  'name' => 'maintenance_mode',
157  'href' => 'admin/configure_utilities/maintenance',
158  'text' => elgg_echo('admin:maintenance_mode:indicator_menu_item'),
159  'icon' => 'wrench',
160  'priority' => 900,
161  ]);
162  }
163 
164  elgg_register_simplecache_view('admin.css');
165 
166  // widgets
167  $widgets = ['online_users', 'new_users', 'content_stats', 'banned_users', 'admin_welcome', 'control_panel', 'cron_status'];
168  foreach ($widgets as $widget) {
170  $widget,
171  elgg_echo("admin:widget:$widget"),
172  elgg_echo("admin:widget:$widget:help"),
173  ['admin']
174  );
175  }
176 
177  // automatic adding of widgets for admin
178  elgg_register_event_handler('make_admin', 'user', '_elgg_add_admin_widgets');
179 
180  elgg_register_notification_event('user', 'user', ['make_admin', 'remove_admin']);
181  elgg_register_plugin_hook_handler('get', 'subscriptions', '_elgg_admin_get_admin_subscribers_admin_action');
182  elgg_register_plugin_hook_handler('get', 'subscriptions', '_elgg_admin_get_user_subscriber_admin_action');
183  elgg_register_plugin_hook_handler('prepare', 'notification:make_admin:user:user', '_elgg_admin_prepare_admin_notification_make_admin');
184  elgg_register_plugin_hook_handler('prepare', 'notification:make_admin:user:user', '_elgg_admin_prepare_user_notification_make_admin');
185  elgg_register_plugin_hook_handler('prepare', 'notification:remove_admin:user:user', '_elgg_admin_prepare_admin_notification_remove_admin');
186  elgg_register_plugin_hook_handler('prepare', 'notification:remove_admin:user:user', '_elgg_admin_prepare_user_notification_remove_admin');
187 
188  // Add notice about pending upgrades
189  elgg_register_event_handler('create', 'object', '_elgg_create_notice_of_pending_upgrade');
190 }
191 
200  elgg_set_context('admin');
201 
202  return elgg_ok_response([
203  'list' => elgg_view('admin/plugins', ['list_only' => true]),
204  'sidebar' => elgg_view('admin/sidebar'),
205  ]);
206 }
207 
221 function _elgg_admin_header_menu($hook, $type, $return, $params) {
222  if (!elgg_in_context('admin') || !elgg_is_admin_logged_in()) {
223  return;
224  }
225 
227 
228  $return[] = \ElggMenuItem::factory([
229  'name' => 'account',
230  'text' => $admin->getDisplayName(),
231  'href' => $admin->getURL(),
232  'icon' => elgg_view('output/img', [
233  'src' => $admin->getIconURL('small'),
234  'alt' => $admin->getDisplayName(),
235  ]),
236  'link_class' => 'elgg-avatar-small',
237  'priority' => 1000,
238  ]);
239 
240  $return[] = \ElggMenuItem::factory([
241  'name' => 'admin_logout',
242  'href' => 'action/logout',
243  'text' => elgg_echo('logout'),
244  'priority' => 900,
245  ]);
246 
247  $return[] = \ElggMenuItem::factory([
248  'name' => 'view_site',
249  'href' => elgg_get_site_url(),
250  'text' => elgg_echo('admin:view_site'),
251  'priority' => 800,
252  ]);
253 
254  if (elgg_get_config('elgg_maintenance_mode')) {
255  $return[] = \ElggMenuItem::factory([
256  'name' => 'maintenance',
257  'href' => 'admin/configure_utilities/maintenance',
258  'text' => elgg_echo('admin:configure_utilities:maintenance'),
259  'link_class' => 'elgg-maintenance-mode-warning',
260  'priority' => 700,
261  ]);
262  }
263 
264  return $return;
265 }
266 
280 function _elgg_admin_footer_menu($hook, $type, $return, $params) {
281  if (!elgg_in_context('admin') || !elgg_is_admin_logged_in()) {
282  return;
283  }
284 
285  $return[] = \ElggMenuItem::factory([
286  'name' => 'faq',
287  'text' => elgg_echo('admin:footer:faq'),
288  'href' => 'http://learn.elgg.org/en/stable/appendix/faqs.html',
289  ]);
290 
291  $return[] = \ElggMenuItem::factory([
292  'name' => 'manual',
293  'text' => elgg_echo('admin:footer:manual'),
294  'href' => 'http://learn.elgg.org/en/stable/admin/index.html',
295  ]);
296 
297  $return[] = \ElggMenuItem::factory([
298  'name' => 'community_forums',
299  'text' => elgg_echo('admin:footer:community_forums'),
300  'href' => 'http://elgg.org/groups/all/',
301  ]);
302 
303  $return[] = \ElggMenuItem::factory([
304  'name' => 'blog',
305  'text' => elgg_echo('admin:footer:blog'),
306  'href' => 'https://elgg.org/blog/all',
307  ]);
308 
309  return $return;
310 }
311 
322 function _elgg_admin_page_menu(\Elgg\Hook $hook) {
323  if (!elgg_in_context('admin') || !elgg_is_admin_logged_in()) {
324  return;
325  }
326 
327  $return = $hook->getValue();
328 
329  // administer
330  $return[] = \ElggMenuItem::factory([
331  'name' => 'dashboard',
332  'href' => 'admin',
333  'text' => elgg_echo('admin:dashboard'),
334  'priority' => 10,
335  'section' => 'administer',
336  ]);
337 
338  $return[] = \ElggMenuItem::factory([
339  'name' => 'plugins',
340  'href' => 'admin/plugins',
341  'text' => elgg_echo('admin:plugins'),
342  'priority' => 30,
343  'section' => 'administer',
344  ]);
345 
346  $return[] = \ElggMenuItem::factory([
347  'name' => 'users',
348  'text' => elgg_echo('admin:users'),
349  'priority' => 40,
350  'section' => 'administer',
351  ]);
352  $return[] = \ElggMenuItem::factory([
353  'name' => 'users:online',
354  'text' => elgg_echo('admin:users:online'),
355  'href' => 'admin/users/online',
356  'priority' => 10,
357  'section' => 'administer',
358  'parent_name' => 'users',
359  ]);
360  $return[] = \ElggMenuItem::factory([
361  'name' => 'users:admins',
362  'text' => elgg_echo('admin:users:admins'),
363  'href' => 'admin/users/admins',
364  'priority' => 20,
365  'section' => 'administer',
366  'parent_name' => 'users',
367  ]);
368  $return[] = \ElggMenuItem::factory([
369  'name' => 'users:newest',
370  'text' => elgg_echo('admin:users:newest'),
371  'href' => 'admin/users/newest',
372  'priority' => 30,
373  'section' => 'administer',
374  'parent_name' => 'users',
375  ]);
376  $return[] = \ElggMenuItem::factory([
377  'name' => 'users:add',
378  'text' => elgg_echo('admin:users:add'),
379  'href' => 'admin/users/add',
380  'priority' => 40,
381  'section' => 'administer',
382  'parent_name' => 'users',
383  ]);
384 
385  $return[] = \ElggMenuItem::factory([
386  'name' => 'users:unvalidated',
387  'text' => elgg_echo('admin:users:unvalidated'),
388  'href' => 'admin/users/unvalidated',
389  'priority' => 50,
390  'section' => 'administer',
391  'parent_name' => 'users',
392  ]);
393  $return[] = \ElggMenuItem::factory([
394  'name' => 'upgrades',
395  'href' => 'admin/upgrades',
396  'text' => elgg_echo('admin:upgrades'),
397  'priority' => 600,
398  'section' => 'administer',
399  ]);
400 
401  $return[] = \ElggMenuItem::factory([
402  'name' => 'administer_utilities',
403  'text' => elgg_echo('admin:administer_utilities'),
404  'priority' => 50,
405  'section' => 'administer',
406  ]);
407 
408  // configure
409  $return[] = \ElggMenuItem::factory([
410  'name' => 'settings:basic',
411  'href' => 'admin/settings/basic',
412  'text' => elgg_echo('admin:settings:basic'),
413  'priority' => 10,
414  'section' => 'configure',
415  ]);
416  $return[] = \ElggMenuItem::factory([
417  'name' => 'settings:advanced',
418  'href' => 'admin/settings/advanced',
419  'text' => elgg_echo('admin:settings:advanced'),
420  'priority' => 20,
421  'section' => 'configure',
422  ]);
423  $return[] = \ElggMenuItem::factory([
424  'name' => 'security',
425  'href' => 'admin/security',
426  'text' => elgg_echo('admin:security'),
427  'priority' => 30,
428  'section' => 'configure',
429  ]);
430 
431  $return[] = \ElggMenuItem::factory([
432  'name' => 'configure_utilities',
433  'text' => elgg_echo('admin:configure_utilities'),
434  'priority' => 600,
435  'section' => 'configure',
436  ]);
437  $return[] = \ElggMenuItem::factory([
438  'name' => 'configure_utilities:maintenance',
439  'text' => elgg_echo('admin:configure_utilities:maintenance'),
440  'href' => 'admin/configure_utilities/maintenance',
441  'section' => 'configure',
442  'parent_name' => 'configure_utilities',
443  ]);
444  $return[] = \ElggMenuItem::factory([
445  'name' => 'configure_utilities:menu_items',
446  'text' => elgg_echo('admin:configure_utilities:menu_items'),
447  'href' => 'admin/configure_utilities/menu_items',
448  'section' => 'configure',
449  'parent_name' => 'configure_utilities',
450  ]);
451  $return[] = \ElggMenuItem::factory([
452  'name' => 'configure_utilities:robots',
453  'text' => elgg_echo('admin:configure_utilities:robots'),
454  'href' => 'admin/configure_utilities/robots',
455  'section' => 'configure',
456  'parent_name' => 'configure_utilities',
457  ]);
458 
459  // information
460  $return[] = \ElggMenuItem::factory([
461  'name' => 'statistics',
462  'href' => 'admin/statistics',
463  'text' => elgg_echo('admin:statistics'),
464  'section' => 'information',
465  ]);
466  $return[] = \ElggMenuItem::factory([
467  'name' => 'server',
468  'href' => 'admin/server',
469  'text' => elgg_echo('admin:server'),
470  'section' => 'information',
471  ]);
472 
473  return $return;
474 }
475 
488  if (!elgg_in_context('admin') || !elgg_is_admin_logged_in()) {
489  return;
490  }
491 
492  // plugin settings
493  $active_plugins = elgg_get_plugins('active');
494  if (empty($active_plugins)) {
495  // nothing added because no items
496  return;
497  }
498 
499  $plugins_with_settings = [];
500 
501  foreach ($active_plugins as $plugin) {
502  $plugin_id = $plugin->getID();
503 
504  if (!elgg_view_exists("plugins/{$plugin_id}/settings") ) {
505  continue;
506  }
507  $plugin_name = $plugin->getDisplayName();
508  $plugins_with_settings[$plugin_name] = [
509  'name' => $plugin_id,
510  'href' => "admin/plugin_settings/$plugin_id",
511  'text' => $plugin_name,
512  'parent_name' => 'plugin_settings',
513  'section' => 'configure',
514  ];
515  }
516 
517  if (empty($plugins_with_settings)) {
518  return;
519  }
520 
521  $return = $hook->getValue();
522 
523  $return[] = \ElggMenuItem::factory([
524  'name' => 'plugin_settings',
525  'text' => elgg_echo('admin:plugin_settings'),
526  'section' => 'configure',
527  ]);
528 
529  ksort($plugins_with_settings);
530  $priority = 0;
531  foreach ($plugins_with_settings as $plugin_item) {
532  $priority += 10;
533  $plugin_item['priority'] = $priority;
534  $return[] = \ElggMenuItem::factory($plugin_item);
535  }
536 
537  return $return;
538 }
539 
553 
554  if (!elgg_is_admin_logged_in()) {
555  return;
556  }
557 
558  $return = $hook->getValue();
559 
560  $return[] = ElggMenuItem::factory([
561  'name' => 'select_all',
562  'text' => elgg_view('input/checkbox', [
563  'name' => 'select_all',
564  'label' => elgg_echo('all'),
565  'id' => 'admin-users-unvalidated-bulk-select',
566  ]),
567  'href' => false,
568  'priority' => 100,
569  'deps' => 'admin/users/unvalidated',
570  ]);
571 
572  $return[] = ElggMenuItem::factory([
573  'id' => 'admin-users-unvalidated-bulk-validate',
574  'name' => 'bulk_validate',
575  'text' => elgg_echo('validate'),
576  'href' => 'action/admin/user/bulk/validate',
577  'confirm' => true,
578  'priority' => 400,
579  'section' => 'right',
580  'deps' => 'admin/users/unvalidated',
581  ]);
582 
583  $return[] = ElggMenuItem::factory([
584  'id' => 'admin-users-unvalidated-bulk-delete',
585  'name' => 'bulk_delete',
586  'text' => elgg_echo('delete'),
587  'href' => 'action/admin/user/bulk/delete',
588  'confirm' => elgg_echo('deleteconfirm:plural'),
589  'priority' => 500,
590  'section' => 'right',
591  'deps' => 'admin/users/unvalidated',
592  ]);
593 
594  return $return;
595 }
596 
607  elgg_set_context('admin');
608 
609  elgg_unregister_css('elgg');
610  elgg_require_js('elgg/admin');
611 
612  // default to dashboard
613  if (!isset($page[0]) || empty($page[0])) {
614  $page = ['dashboard'];
615  }
616 
617  // was going to fix this in the page_handler() function but
618  // it's commented to explicitly return a string if there's a trailing /
619  if (empty($page[count($page) - 1])) {
620  array_pop($page);
621  }
622 
623  $vars = ['page' => $page];
624 
625  // special page for plugin settings since we create the form for them
626  if ($page[0] == 'plugin_settings') {
627  if (isset($page[1]) && (elgg_view_exists("plugins/{$page[1]}/settings"))) {
628  $view = 'admin/plugin_settings';
630  $vars['plugin'] = $plugin; // required for plugin settings backward compatibility
631  $vars['entity'] = $plugin;
632 
633  $title = elgg_echo("admin:{$page[0]}") . ': ' . $plugin->getDisplayName();
634  } else {
635  forward('', '404');
636  }
637  } else {
638  $view = 'admin/' . implode('/', $page);
639  $title = elgg_echo("admin:{$page[0]}");
640  if (count($page) > 1) {
641  $title .= ' : ' . elgg_echo('admin:' . implode(':', $page));
642  }
643  }
644 
645  // gets content and prevents direct access to 'components' views
646  if ($page[0] == 'components' || !($content = elgg_view($view, $vars))) {
647  $title = elgg_echo('admin:unknown_section');
648  $content = elgg_echo('admin:unknown_section');
649  }
650 
651  $body = elgg_view_layout('admin', ['content' => $content, 'title' => $title]);
652  echo elgg_view_page($title, $body, 'admin');
653  return true;
654 }
655 
664 function _elgg_admin_maintenance_allow_url($current_url) {
665  $site_path = preg_replace('~^https?~', '', elgg_get_site_url());
666  $current_path = preg_replace('~^https?~', '', $current_url);
667  if (0 === strpos($current_path, $site_path)) {
668  $current_path = ($current_path === $site_path) ? '' : substr($current_path, strlen($site_path));
669  } else {
670  $current_path = false;
671  }
672 
673  // allow plugins to control access for specific URLs/paths
674  $params = [
675  'current_path' => $current_path,
676  'current_url' => $current_url,
677  ];
678  return (bool) elgg_trigger_plugin_hook('maintenance:allow', 'url', $params, false);
679 }
680 
693  if (elgg_is_admin_logged_in()) {
694  return;
695  }
696 
697  if ($info['identifier'] == 'action' && $info['segments'][0] == 'login') {
698  return;
699  }
700 
702  return;
703  }
704 
705  elgg_unregister_plugin_hook_handler('register', 'menu:login', '_elgg_login_menu_setup');
706 
707  echo elgg_view_resource('maintenance');
708 
709  return false;
710 }
711 
721  if (elgg_is_admin_logged_in()) {
722  return true;
723  }
724 
725  if ($type == 'login') {
726  $username = get_input('username');
727 
729 
730  if (!$user) {
731  $users = get_user_by_email($username);
732  if (!empty($users)) {
733  $user = $users[0];
734  }
735  }
736 
737  if ($user && $user->isAdmin()) {
738  return true;
739  }
740  }
741 
743  return true;
744  }
745 
746  register_error(elgg_echo('actionunauthorized'));
747 
748  return false;
749 }
750 
761 function _elgg_add_admin_widgets($event, $type, $user) {
762  $ia = elgg_set_ignore_access(true);
763 
764  // check if the user already has widgets
765  if (elgg_get_widgets($user->getGUID(), 'admin')) {
767  return;
768  }
769 
770  // In the form column => array of handlers in order, top to bottom
771  $adminWidgets = [
772  1 => ['control_panel', 'admin_welcome'],
773  2 => ['online_users', 'new_users', 'content_stats'],
774  ];
775 
776  foreach ($adminWidgets as $column => $handlers) {
777  foreach ($handlers as $position => $handler) {
778  $guid = elgg_create_widget($user->getGUID(), $handler, 'admin');
779  if ($guid !== false) {
781  /* @var \ElggWidget $widget */
782  $widget->move($column, $position);
783  }
784  }
785  }
786 
788 }
789 
801 
802  if (!_elgg_config()->security_notify_admins) {
803  return;
804  }
805 
806  $event = elgg_extract('event', $params);
807  if (!$event instanceof \Elgg\Notifications\SubscriptionNotificationEvent) {
808  return;
809  }
810 
811  if (!in_array($event->getAction(), ['make_admin', 'remove_admin'])) {
812  return;
813  }
814 
815  $user = $event->getObject();
816  if (!$user instanceof \ElggUser) {
817  return;
818  }
819 
820  /* @var $admin_batch \Elgg\BatchResult */
821  $admin_batch = elgg_get_admins([
822  'limit' => false,
823  'wheres' => [
824  function (QueryBuilder $qb, $main_alias) use ($user) {
825  return $qb->compare("{$main_alias}.guid", '!=', $user->guid, ELGG_VALUE_GUID);
826  },
827  ],
828  'batch' => true,
829  ]);
830 
831  /* @var $admin \ElggUser */
832  foreach ($admin_batch as $admin) {
833  $return_value[$admin->guid] = ['email'];
834  }
835 
836  return $return_value;
837 }
838 
850 
851  if (!($return_value instanceof \Elgg\Notifications\Notification)) {
852  return;
853  }
854 
855  $recipient = elgg_extract('recipient', $params);
856  $object = elgg_extract('object', $params);
857  $actor = elgg_extract('sender', $params);
858  $language = elgg_extract('language', $params);
859 
860  if (!($recipient instanceof ElggUser) || !($object instanceof ElggUser) || !($actor instanceof ElggUser)) {
861  return;
862  }
863 
864  if ($recipient->getGUID() === $object->getGUID()) {
865  // recipient is the user being acted on, this is handled elsewhere
866  return;
867  }
868 
870 
871  $return_value->subject = elgg_echo('admin:notification:make_admin:admin:subject', [$site->getDisplayName()], $language);
872  $return_value->body = elgg_echo('admin:notification:make_admin:admin:body', [
873  $recipient->getDisplayName(),
874  $actor->getDisplayName(),
875  $object->getDisplayName(),
876  $site->getDisplayName(),
877  $object->getURL(),
878  $site->getURL(),
879  ], $language);
880 
881  $return_value->url = elgg_normalize_url('admin/users/admins');
882 
883  return $return_value;
884 }
885 
897 
898  if (!($return_value instanceof \Elgg\Notifications\Notification)) {
899  return;
900  }
901 
902  $recipient = elgg_extract('recipient', $params);
903  $object = elgg_extract('object', $params);
904  $actor = elgg_extract('sender', $params);
905  $language = elgg_extract('language', $params);
906 
907  if (!($recipient instanceof ElggUser) || !($object instanceof ElggUser) || !($actor instanceof ElggUser)) {
908  return;
909  }
910 
911  if ($recipient->getGUID() === $object->getGUID()) {
912  // recipient is the user being acted on, this is handled elsewhere
913  return;
914  }
915 
917 
918  $return_value->subject = elgg_echo('admin:notification:remove_admin:admin:subject', [$site->getDisplayName()], $language);
919  $return_value->body = elgg_echo('admin:notification:remove_admin:admin:body', [
920  $recipient->getDisplayName(),
921  $actor->getDisplayName(),
922  $object->getDisplayName(),
923  $site->getDisplayName(),
924  $object->getURL(),
925  $site->getURL(),
926  ], $language);
927 
928  $return_value->url = elgg_normalize_url('admin/users/admins');
929 
930  return $return_value;
931 }
932 
944 
945  if (!_elgg_config()->security_notify_user_admin) {
946  return;
947  }
948 
949  $event = elgg_extract('event', $params);
950  if (!$event instanceof \Elgg\Notifications\SubscriptionNotificationEvent) {
951  return;
952  }
953 
954  if (!in_array($event->getAction(), ['make_admin', 'remove_admin'])) {
955  return;
956  }
957 
958  $user = $event->getObject();
959  if (!$user instanceof \ElggUser) {
960  return;
961  }
962 
963  $return_value[$user->guid] = ['email'];
964 
965  return $return_value;
966 }
967 
979 
980  if (!($return_value instanceof \Elgg\Notifications\Notification)) {
981  return;
982  }
983 
984  $recipient = elgg_extract('recipient', $params);
985  $object = elgg_extract('object', $params);
986  $actor = elgg_extract('sender', $params);
987  $language = elgg_extract('language', $params);
988 
989  if (!($recipient instanceof ElggUser) || !($object instanceof ElggUser) || !($actor instanceof ElggUser)) {
990  return;
991  }
992 
993  if ($recipient->getGUID() !== $object->getGUID()) {
994  // recipient is some other user, this is handled elsewhere
995  return;
996  }
997 
999 
1000  $return_value->subject = elgg_echo('admin:notification:make_admin:user:subject', [$site->getDisplayName()], $language);
1001  $return_value->body = elgg_echo('admin:notification:make_admin:user:body', [
1002  $recipient->getDisplayName(),
1003  $actor->getDisplayName(),
1004  $site->getDisplayName(),
1005  $site->getURL(),
1006  ], $language);
1007 
1008  $return_value->url = elgg_normalize_url('admin');
1009 
1010  return $return_value;
1011 }
1012 
1024 
1025  if (!($return_value instanceof \Elgg\Notifications\Notification)) {
1026  return;
1027  }
1028 
1029  $recipient = elgg_extract('recipient', $params);
1030  $object = elgg_extract('object', $params);
1031  $actor = elgg_extract('sender', $params);
1032  $language = elgg_extract('language', $params);
1033 
1034  if (!($recipient instanceof ElggUser) || !($object instanceof ElggUser) || !($actor instanceof ElggUser)) {
1035  return;
1036  }
1037 
1038  if ($recipient->getGUID() !== $object->getGUID()) {
1039  // recipient is some other user, this is handled elsewhere
1040  return;
1041  }
1042 
1044 
1045  $return_value->subject = elgg_echo('admin:notification:remove_admin:user:subject', [$site->getDisplayName()], $language);
1046  $return_value->body = elgg_echo('admin:notification:remove_admin:user:body', [
1047  $recipient->getDisplayName(),
1048  $actor->getDisplayName(),
1049  $site->getDisplayName(),
1050  $site->getURL(),
1051  ], $language);
1052 
1053  $return_value->url = '';
1054 
1055  return $return_value;
1056 }
1057 
1066 function _elgg_admin_upgrades_menu(\Elgg\Hook $hook) {
1067 
1068  $result = $hook->getValue();
1069 
1070  $selected = $hook->getParam('filter_value');
1071 
1073  'name' => 'pending',
1074  'text' => elgg_echo('admin:upgrades:menu:pending'),
1075  'href' => 'admin/upgrades',
1076  'priority' => 100,
1077  'selected' => $selected === 'pending',
1078  ]);
1079 
1081  'name' => 'completed',
1082  'text' => elgg_echo('admin:upgrades:menu:completed'),
1083  'href' => 'admin/upgrades/finished',
1084  'priority' => 200,
1085  'selected' => $selected === 'completed',
1086  ]);
1087 
1089  'name' => 'db',
1090  'text' => elgg_echo('admin:upgrades:menu:db'),
1091  'href' => 'admin/upgrades/db',
1092  'priority' => 300,
1093  'selected' => $selected === 'db',
1094  ]);
1095 
1096  return $result;
1097 }
1098 
1102 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
1103  $events->registerHandler('init', 'system', '_elgg_admin_init');
1104 };
_elgg_add_admin_widgets($event, $type, $user)
Adds default admin widgets to the admin dashboard.
Definition: admin.php:761
elgg_admin_notice_exists($id)
Check if an admin notice is currently active.
Definition: admin.php:95
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:205
elgg_delete_admin_notice($id)
Remove an admin notice by ID.
Definition: admin.php:71
$params
Definition: admin.php:46
$plugin
if(!$item instanceof ElggRiverItem) $object
Definition: responses.php:23
elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback)
Unregister a callback as a plugin hook.
Definition: elgglib.php:649
$body
Definition: admin.php:40
_elgg_admin_maintenance_allow_url($current_url)
When in maintenance mode, should the given URL be handled normally?
Definition: admin.php:664
$username
Definition: delete.php:23
_elgg_admin_header_menu($hook, $type, $return, $params)
Register menu items for the admin_header menu.
Definition: admin.php:221
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:57
elgg_normalize_url($url)
Definition: output.php:186
get_user_by_email($email)
Get an array of users from an email address.
Definition: users.php:83
elgg_define_js($name, $config)
Defines a JS lib as an AMD module.
Definition: elgglib.php:119
elgg_view_resource($name, array $vars=[])
Render a resource view.
Definition: views.php:423
$admin
Definition: useradd.php:19
_elgg_admin_prepare_admin_notification_make_admin($hook, $type, $return_value, $params)
Prepare the notification content for site admins about making a site admin.
Definition: admin.php:849
elgg_register_simplecache_view($view_name)
Registers a view to simple cache.
Definition: cache.php:113
elgg_get_simplecache_url($view, $subview= '')
Get the URL for the cached view.
Definition: cache.php:141
elgg_add_admin_notice($id, $message)
Write a persistent message to the admin view.
Definition: admin.php:59
_elgg_create_notice_of_pending_upgrade($event, $type, $object)
Add an admin notice when a new object is created.
Definition: admin.php:110
$column
Definition: add.php:10
const ELGG_VALUE_GUID
Definition: constants.php:140
Events service.
elgg_register_css($name, $url, $priority=null)
Register a CSS file for inclusion in the HTML head.
Definition: elgglib.php:207
_elgg_admin_page_handler($page)
Handle admin pages.
Definition: admin.php:605
Database abstraction query builder.
current_page_url()
Returns the current page&#39;s complete URL.
Definition: input.php:94
$guid
Removes an admin notice.
elgg_register_widget_type($handler, $name=null, $description=null, $context=[], $multiple=false)
Register a widget type.
Definition: widgets.php:72
elgg forward
Meant to mimic the php forward() function by simply redirecting the user to another page...
Definition: elgglib.js:417
$type
Definition: delete.php:21
$site_path
Definition: details.php:88
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Definition: elgglib.php:634
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$position
Definition: move.php:7
if(!$item instanceof ElggEntity) $link
Definition: container.php:16
$options
Elgg admin footer.
Definition: footer.php:6
elgg_view_page($title, $body, $page_shell= 'default', $vars=[])
Assembles and outputs a full page.
Definition: views.php:360
elgg_get_admin_notices(array $options=[])
Get admin notices.
Definition: admin.php:83
_elgg_admin_page_menu(\Elgg\Hook $hook)
Register menu items for the page menu.
Definition: admin.php:322
$page
Definition: admin.php:26
elgg_get_admins(array $options=[])
Get the admin users.
Definition: admin.php:34
get_user_by_username($username)
Get user by username.
Definition: users.php:61
_elgg_admin_prepare_admin_notification_remove_admin($hook, $type, $return_value, $params)
Prepare the notification content for site admins about removing a site admin.
Definition: admin.php:896
static factory($options)
Create an ElggMenuItem from an associative array.
$vars['breadcrumbs']
Definition: admin.php:21
elgg_unregister_css($name)
Unregister a CSS file.
Definition: elgglib.php:219
_elgg_admin_prepare_user_notification_make_admin($hook, $type, $return_value, $params)
Prepare the notification content for the user being made as a site admins.
Definition: admin.php:978
elgg_require_js($name)
Request that Elgg load an AMD module onto the page.
Definition: elgglib.php:168
_elgg_admin_footer_menu($hook, $type, $return, $params)
Register menu items for the admin_footer menu.
Definition: admin.php:280
Configuration exception.
_elgg_admin_maintenance_action_check($hook, $type)
Prevent non-admins from using actions.
Definition: admin.php:720
$id
River item delete action.
Definition: delete.php:6
if(!$owner||!$owner->canEdit()) if(!$owner->hasIcon('master')) if(!$owner->saveIconFromElggFile($owner->getIcon('master'), 'icon', $coords)) $view
Definition: crop.php:30
Base class for events and hooks.
$title
Definition: user.php:20
elgg_get_widgets($owner_guid, $context)
Get widgets for a particular context.
Definition: widgets.php:23
_elgg_admin_upgrades_menu(\Elgg\Hook $hook)
Add menu items to the filter menu on the admin upgrades page.
Definition: admin.php:1066
$language
Definition: useradd.php:17
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
Definition: entities.php:545
elgg_set_ignore_access($ignore=true)
Set if Elgg&#39;s access system should be ignored.
Definition: access.php:52
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
_elgg_admin_user_unvalidated_bulk_menu(\Elgg\Hook $hook)
Register menu items to the bulk actions for unvalidated users.
Definition: admin.php:552
$plugin_id
Definition: save.php:15
_elgg_admin_init()
Initialize the admin backend.
Definition: admin.php:131
elgg_set_context($context)
Sets the page context.
Definition: pageowner.php:189
_elgg_admin_get_admin_subscribers_admin_action($hook, $type, $return_value, $params)
Add the current site admins to the subscribers when making/removing an admin user.
Definition: admin.php:800
$user
Definition: ban.php:7
elgg_in_context($context)
Check if this context exists anywhere in the stack.
Definition: pageowner.php:238
compare($x, $comparison, $y=null, $type=null, $case_sensitive=null)
Build value comparison clause.
elgg echo
Translates a string.
Definition: languages.js:43
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:720
if(!empty($screenshots)) $info
Definition: details.php:59
elgg_get_site_url()
Get the URL for the current (or specified) site, ending with "/".
_elgg_admin_prepare_user_notification_remove_admin($hook, $type, $return_value, $params)
Prepare the notification content for the user being removed as a site admins.
Definition: admin.php:1023
elgg_register_menu_item($menu_name, $menu_item)
Register an item for an Elgg menu.
Definition: navigation.php:100
elgg_extend_view($view, $view_extension, $priority=501)
Extends a view with another view.
Definition: views.php:293
elgg_get_site_entity()
Get the current site entity.
Definition: entities.php:130
if($guid===false) $widget
Definition: add.php:30
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
$widgets
Definition: widgets.php:35
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
Definition: elgglib.php:449
elgg_get_plugins($status= 'active')
Returns an ordered list of plugins.
Definition: plugins.php:76
elgg_ok_response($content= '', $message= '', $forward_url=null, $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
_elgg_admin_get_user_subscriber_admin_action($hook, $type, $return_value, $params)
Add the user to the subscribers when making/removing the admin role.
Definition: admin.php:943
_elgg_config()
Get the Elgg config service.
elgg_admin_gatekeeper()
Used at the top of a page to mark it as admin only.
elgg_register_notification_event($object_type, $object_subtype, array $actions=[])
Register a notification event.
elgg register_error
Wrapper function for system_messages.
Definition: elgglib.js:391
elgg_view_layout($layout_name, $vars=[])
Displays a layout with optional parameters.
Definition: views.php:593
$content
Set robots.txt action.
Definition: set_robots.php:6
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292
if(!$plugin) $plugin_name
Definition: save.php:22
_elgg_admin_page_menu_plugin_settings(\Elgg\Hook $hook)
Register plugin settings menu items for the admin page menu.
Definition: admin.php:487
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:29
$handler
Definition: add.php:7
_elgg_admin_maintenance_handler($hook, $type, $info)
Handle requests when in maintenance mode.
Definition: admin.php:692
_elgg_ajax_plugins_update()
Returns plugin listing and admin menu to the client (used after plugin (de)activation) ...
Definition: admin.php:198
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
$priority
elgg_create_widget($owner_guid, $handler, $context, $access_id=null)
Create a new widget instance.
Definition: widgets.php:38
elgg_get_config($name, $default=null)
Get an Elgg configuration value.
elgg_get_plugin_from_id($plugin_id)
Returns an object with the path $path.
Definition: plugins.php:28
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:87