Elgg  Version 4.3
SystemEventHandlers.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Application;
4 
9 
16 
22  public static function init() {
23 
24  // searchable
25  elgg_entity_enable_capability('object', 'comment', 'searchable');
26  elgg_entity_enable_capability('user', 'user', 'searchable');
27 
28  // likable
29  elgg_entity_enable_capability('object', 'comment', 'likable');
30 
31  elgg_entity_enable_capability('object', 'comment', 'commentable');
32 
33  // commentable disabled for backwards compatibility. Can be removed in Elgg 5.0 if default behaviour for commentable has been changed
34  elgg_entity_disable_capability('object', 'admin_notice', 'commentable');
35  elgg_entity_disable_capability('object', 'elgg_upgrade', 'commentable');
36  elgg_entity_disable_capability('object', 'plugin', 'commentable');
37  elgg_entity_disable_capability('object', 'widget', 'commentable');
38  elgg_entity_disable_capability('site', 'site', 'commentable');
39  elgg_entity_disable_capability('user', 'user', 'commentable');
40 
42  if ((bool) elgg_get_config('enable_delayed_email')) {
43  elgg_register_notification_method('delayed_email');
44  }
45 
46  elgg_register_notification_event('object', 'comment', ['create'], CreateCommentEventHandler::class);
47  elgg_register_notification_event('user', 'user', ['make_admin'], MakeAdminUserEventHandler::class);
48  elgg_register_notification_event('user', 'user', ['remove_admin'], RemoveAdminUserEventHandler::class);
49  elgg_register_notification_event('user', 'user', ['unban'], UnbanUserEventHandler::class);
50 
51  // if mb functions are available, set internal encoding to UTF8
52  if (is_callable('mb_internal_encoding')) {
53  mb_internal_encoding("UTF-8");
54  }
55 
56  elgg_register_ajax_view('admin/users/listing/details');
57  elgg_register_ajax_view('core/ajax/edit_comment');
58  elgg_register_ajax_view('forms/admin/user/change_email');
59  elgg_register_ajax_view('navigation/menu/user_hover/contents');
60  elgg_register_ajax_view('notifications/subscriptions/details');
61  elgg_register_ajax_view('object/plugin/details');
62  elgg_register_ajax_view('page/elements/comments');
63  elgg_register_ajax_view('river/elements/responses');
64 
65  elgg_extend_view('admin.css', 'lightbox/elgg-colorbox-theme/colorbox.css');
66  elgg_extend_view('core/settings/statistics', 'core/settings/statistics/online');
67  elgg_extend_view('core/settings/statistics', 'core/settings/statistics/numentities');
68  elgg_extend_view('forms/usersettings/save', 'core/settings/account/username', 100);
69  elgg_extend_view('forms/usersettings/save', 'core/settings/account/name', 100);
70  elgg_extend_view('forms/usersettings/save', 'core/settings/account/password', 100);
71  elgg_extend_view('forms/usersettings/save', 'core/settings/account/email', 100);
72  elgg_extend_view('forms/usersettings/save', 'core/settings/account/language', 100);
73  elgg_extend_view('forms/usersettings/save', 'core/settings/account/default_access', 100);
74 
75  elgg_register_simplecache_view('admin.css');
76  elgg_register_simplecache_view('resources/manifest.json');
77 
78  elgg_register_external_file('css', 'elgg.admin', elgg_get_simplecache_url('admin.css'));
79  elgg_register_external_file('css', 'admin/users/unvalidated', elgg_get_simplecache_url('admin/users/unvalidated.css'));
80  elgg_register_external_file('css', 'maintenance', elgg_get_simplecache_url('maintenance.css'));
81 
82  elgg_register_plugin_hook_handler('registeruser:validate:password', 'all', [_elgg_services()->passwordGenerator, 'registerUserPasswordValidation']);
83  elgg_register_plugin_hook_handler('view_vars', 'input/password', [_elgg_services()->passwordGenerator, 'addInputRequirements']);
84 
85  $widgets = ['online_users', 'new_users', 'content_stats', 'banned_users', 'admin_welcome', 'cron_status'];
86  foreach ($widgets as $widget) {
88  $widget,
89  elgg_echo("admin:widget:{$widget}"),
90  elgg_echo("admin:widget:{$widget}:help"),
91  ['admin']
92  );
93  }
94  }
95 
101  public static function initEarly() {
102  elgg_register_pam_handler(\Elgg\PAM\User\Password::class);
103  }
104 
110  public static function initLate() {
111  self::initWalledGarden();
112  }
113 
119  public static function ready() {
120  _elgg_services()->systemCache->init();
121  }
122 
128  protected static function initWalledGarden() {
129  if (!_elgg_services()->config->walled_garden) {
130  return;
131  }
132 
133  elgg_register_external_file('css', 'elgg.walled_garden', elgg_get_simplecache_url('walled_garden.css'));
134 
135  if (_elgg_services()->config->default_access == ACCESS_PUBLIC) {
136  elgg_set_config('default_access', ACCESS_LOGGED_IN);
137  }
138 
139  if (!elgg_is_logged_in()) {
140  // override the front page
141  elgg_register_route('index', [
142  'path' => '/',
143  'resource' => 'walled_garden',
144  ]);
145  }
146  }
147 }
elgg_entity_disable_capability(string $type, string $subtype, string $capability)
Disables the capability for a specified type/subtype.
Definition: entities.php:766
static initEarly()
Initializes the system (contains actions that require to be executed early [priority: 0]) ...
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:43
elgg_register_notification_method($name)
Register a delivery method for notifications.
elgg_register_notification_event($object_type, $object_subtype, array $actions=[], string $handler=NotificationEventHandler::class)
Register a notification event.
elgg_register_simplecache_view($view_name)
Registers a view to simple cache.
Definition: cache.php:111
elgg_get_simplecache_url($view, $subview= '')
Get the URL for the cached view.
Definition: cache.php:139
elgg_register_widget_type($handler, $name=null, $description=null, $context=[], $multiple=false)
Register a widget type.
Definition: widgets.php:69
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Definition: elgglib.php:294
elgg_register_external_file(string $type, string $name, string $url, string $location= '')
Core registration function for external files.
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
elgg_entity_enable_capability(string $type, string $subtype, string $capability)
Enables the capability for a specified type/subtype.
Definition: entities.php:752
static ready()
Actions performed when the system is ready.
const ACCESS_LOGGED_IN
Definition: constants.php:13
elgg_set_config($name, $value)
Set an Elgg configuration value.
static initLate()
Initializes the system (contains actions that require to be executed after regular priority [priority...
static init()
Initializes the system.
elgg_register_ajax_view($view)
Register a view to be available for ajax calls.
Definition: views.php:107
elgg_extend_view($view, $view_extension, $priority=501)
Extends a view with another view.
Definition: views.php:210
if($guid===false) $widget
Definition: add.php:30
elgg_register_route($name, array $params=[])
Elgg page handler functions.
Definition: pagehandler.php:27
$widgets
Definition: widgets.php:37
static initWalledGarden()
Initializes the walled garden logic.
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638
const ACCESS_PUBLIC
Definition: constants.php:14
elgg_register_pam_handler($handler, string $importance= 'sufficient', string $policy= 'user')
Elgg Simple PAM library Contains functions for managing authentication.
Definition: pam.php:31
Contains the system event handlers.
elgg_get_config($name, $default=null)
Get an Elgg configuration value.