Elgg  Version 6.3
SystemEventHandlers.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Application;
4 
19 
26 
32  public static function init() {
33  // searchable
34  elgg_entity_enable_capability('object', 'comment', 'searchable');
35  elgg_entity_enable_capability('user', 'user', 'searchable');
36 
37  // likable
38  elgg_entity_enable_capability('object', 'comment', 'likable');
39 
40  elgg_entity_enable_capability('object', 'comment', 'commentable');
41 
43  if ((bool) elgg_get_config('enable_delayed_email')) {
44  elgg_register_notification_method('delayed_email');
45  }
46 
47  elgg_register_notification_event('object', 'comment', ['create'], CreateCommentEventHandler::class);
48  elgg_register_notification_event('object', 'comment', ['mentions'], MentionsEventHandler::class);
49  elgg_register_notification_event('user', 'user', ['admin_validation'], AdminValidation::class);
50  elgg_register_notification_event('user', 'user', ['ban'], BanUser::class);
51  elgg_register_notification_event('user', 'user', ['changepassword'], ChangeUserPassword::class);
52  elgg_register_notification_event('user', 'user', ['email_change'], ConfirmEmailChange::class);
53  elgg_register_notification_event('user', 'user', ['make_admin'], MakeAdminUserEventHandler::class);
54  elgg_register_notification_event('user', 'user', ['password_change'], ConfirmPasswordChange::class);
55  elgg_register_notification_event('user', 'user', ['remove_admin'], RemoveAdminUserEventHandler::class);
56  elgg_register_notification_event('user', 'user', ['requestnewpassword'], RequestUserPassword::class);
57  elgg_register_notification_event('user', 'user', ['resetpassword'], ResetUserPassword::class);
58  elgg_register_notification_event('user', 'user', ['unban'], UnbanUserEventHandler::class);
59  elgg_register_notification_event('user', 'user', ['useradd'], AddUser::class);
60  elgg_register_notification_event('user', 'user', ['validate'], ValidateUser::class);
61 
62  // if mb functions are available, set internal encoding to UTF8
63  if (is_callable('mb_internal_encoding')) {
64  mb_internal_encoding('UTF-8');
65  }
66 
67  elgg_register_ajax_view('admin/users/listing/details');
68  elgg_register_ajax_view('core/ajax/edit_comment');
69  elgg_register_ajax_view('forms/admin/user/change_email');
70  elgg_register_ajax_view('forms/comment/save');
71  elgg_register_ajax_view('forms/entity/chooserestoredestination');
72  elgg_register_ajax_view('navigation/menu/user_hover/contents');
73  elgg_register_ajax_view('notifications/subscriptions/details');
74  elgg_register_ajax_view('object/plugin/details');
75  elgg_register_ajax_view('object/widget/edit');
76  elgg_register_ajax_view('page/elements/comments');
77  elgg_register_ajax_view('river/elements/responses');
78 
79  elgg_extend_view('admin.css', 'lightbox/elgg-colorbox-theme/colorbox.css');
80  elgg_extend_view('core/settings/statistics', 'core/settings/statistics/online');
81  elgg_extend_view('core/settings/statistics', 'core/settings/statistics/numentities');
82  elgg_extend_view('forms/usersettings/save', 'core/settings/account/username', 100);
83  elgg_extend_view('forms/usersettings/save', 'core/settings/account/name', 100);
84  elgg_extend_view('forms/usersettings/save', 'core/settings/account/email', 100);
85  elgg_extend_view('forms/usersettings/save', 'core/settings/account/password', 100);
86  elgg_extend_view('forms/usersettings/save', 'core/settings/account/language', 100);
87  elgg_extend_view('forms/usersettings/save', 'core/settings/account/default_access', 100);
88 
89  elgg_register_simplecache_view('admin.css');
90  elgg_register_simplecache_view('resources/manifest.json');
91 
92  elgg_register_external_file('css', 'elgg.admin', elgg_get_simplecache_url('admin.css'));
93  elgg_register_external_file('css', 'admin/users/unvalidated', elgg_get_simplecache_url('admin/users/unvalidated.css'));
94  elgg_register_external_file('css', 'maintenance', elgg_get_simplecache_url('maintenance.css'));
95 
96  elgg_register_event_handler('registeruser:validate:password', 'all', [_elgg_services()->passwordGenerator, 'registerUserPasswordValidation']);
97  elgg_register_event_handler('view_vars', 'input/password', [_elgg_services()->passwordGenerator, 'addInputRequirements']);
98 
99  $widgets = ['online_users', 'new_users', 'content_stats', 'banned_users', 'admin_welcome', 'cron_status', 'elgg_blog'];
100  foreach ($widgets as $widget) {
102  'id' => $widget,
103  'name' => elgg_echo("admin:widget:{$widget}"),
104  'description' => elgg_echo("admin:widget:{$widget}:help"),
105  'context' => ['admin'],
106  ]);
107  }
108  }
109 
115  public static function initEarly() {
116  elgg_register_pam_handler(\Elgg\PAM\User\Password::class);
117  }
118 
124  public static function initLate() {
126  }
127 
133  public static function ready() {
134  _elgg_services()->views->cacheConfiguration();
135  }
136 
142  protected static function initWalledGarden() {
143  if (!_elgg_services()->config->walled_garden) {
144  return;
145  }
146 
147  elgg_register_external_file('css', 'elgg.walled_garden', elgg_get_simplecache_url('walled_garden.css'));
148 
149  if (_elgg_services()->config->default_access == ACCESS_PUBLIC) {
150  elgg_set_config('default_access', ACCESS_LOGGED_IN);
151  }
152 
153  if (!elgg_is_logged_in()) {
154  // override the front page
155  elgg_register_route('index', [
156  'path' => '/',
157  'resource' => 'walled_garden',
158  ]);
159  }
160  }
161 }
if($guid===false) $widget
Definition: add.php:31
elgg_register_simplecache_view(string $view_name)
Registers a view to simple cache.
Definition: cache.php:59
elgg_get_simplecache_url(string $view)
Get the URL for the cached view.
Definition: cache.php:78
Contains the system event handlers.
static initEarly()
Initializes the system (contains actions that require to be executed early [priority: 0])
static ready()
Actions performed when the system is ready.
static init()
Initializes the system.
static initLate()
Initializes the system (contains actions that require to be executed after regular priority [priority...
static initWalledGarden()
Initializes the walled garden logic.
Notification Event Handler for 'object' 'comment' 'create' action.
Notify the user about his/her new account.
Definition: AddUser.php:12
Send a notification to all (subscribed) site admins that there are unvalidated users.
E-mail the user that their account got banned.
Definition: BanUser.php:12
E-mail about the password change to the user.
Confirm a user e-mail change to the user.
Confirm a user password change to the user.
E-mail the password reset to the user.
E-mail about the password reset for a user by a site administrator.
E-mail the user that a site administrator validated their account.
Notification Event Handler for 'user' 'user' 'make_admin' action.
Notification Event Handler for 'user' 'user' 'remove_admin' action.
Notification Event Handler for 'user' 'user' 'unban' action.
elgg_set_config(string $name, $value)
Set an Elgg configuration value.
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
const ACCESS_LOGGED_IN
Definition: constants.php:11
const ACCESS_PUBLIC
Definition: constants.php:12
_elgg_services()
Get the global service provider.
Definition: elgglib.php:337
elgg_register_widget_type(array $options)
Register a widget type.
Definition: widgets.php:64
elgg_entity_enable_capability(string $type, string $subtype, string $capability)
Enables the capability for a specified type/subtype.
Definition: entities.php:731
elgg_register_external_file(string $type, string $name, string $url, string $location='')
Core registration function for external files.
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_register_event_handler(string $event, string $type, callable|string $callback, int $priority=500)
Helper functions for event handling.
Definition: events.php:48
elgg_extend_view(string $view, string $view_extension, int $priority=501)
Extends a view with another view.
Definition: views.php:183
elgg_register_ajax_view(string $view)
Register a view to be available for ajax calls.
Definition: views.php:104
elgg_register_notification_event(string $object_type, string $object_subtype, array $actions=[], string $handler=NotificationEventHandler::class)
Register a notification event.
elgg_register_notification_method(string $name)
Register a delivery method for notifications.
elgg_register_route(string $name, array $params=[])
Elgg page handler functions.
Definition: pagehandler.php:27
elgg_register_pam_handler($handler, string $importance='sufficient', string $policy='user')
Elgg Simple PAM library Contains functions for managing authentication.
Definition: pam.php:31
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:43
if(empty($page_owner)|| $owner->guid !==$page_owner->guid) $widgets
Definition: widgets.php:40