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

engine/lib/users.php (4 issues)

1
<?php
2
/**
3
 * Elgg users
4
 * Functions to manage multiple or single users in an Elgg install
5
 *
6
 * @package Elgg.Core
7
 * @subpackage DataModel.User
8
 */
9
10
/**
11
 * Disables all of a user's entities
12
 *
13
 * @param int $owner_guid The owner GUID
14
 *
15
 * @return bool Depending on success
16
 */
17
function disable_user_entities($owner_guid) {
18
	try {
19 1
		$entity = get_entity($owner_guid);
20 1
		if (!$entity) {
21
			return false;
22
		}
23 1
		return _elgg_services()->entityTable->disableEntities($entity);
24
	} catch (DatabaseException $ex) {
25
		elgg_log($ex->getMessage(), 'ERROR');
26
27
		return false;
28
	}
29
}
30
31
/**
32
 * Get a user object from a GUID.
33
 *
34
 * This function returns an \ElggUser from a given GUID.
35
 *
36
 * @param int $guid The GUID
37
 *
38
 * @return \ElggUser|false
39
 */
40
function get_user($guid) {
41
	try {
42 162
		return _elgg_services()->entityTable->get($guid, 'user');
43
	} catch (InvalidParameterException $ex) {
44
		elgg_log($ex->getMessage(), 'ERROR');
45
46
		return false;
47
	} catch (ClassException $ex) {
48
		elgg_log($ex->getMessage(), 'ERROR');
49
50
		return false;
51
	}
52
}
53
54
/**
55
 * Get user by username
56
 *
57
 * @param string $username The user's username
58
 *
59
 * @return \ElggUser|false Depending on success
60
 */
61
function get_user_by_username($username) {
62 459
	return _elgg_services()->usersTable->getByUsername($username);
63
}
64
65
/**
66
 * Get user by persistent login password
67
 *
68
 * @param string $hash Hash of the persistent login password
69
 *
70
 * @return \ElggUser
71
 */
72
function get_user_by_code($hash) {
73
	return _elgg_services()->persistentLogin->getUserFromHash($hash);
74
}
75
76
/**
77
 * Get an array of users from an email address
78
 *
79
 * @param string $email Email address.
80
 *
81
 * @return array
82
 */
83
function get_user_by_email($email) {
84 162
	return _elgg_services()->usersTable->getByEmail($email);
85
}
86
87
/**
88
 * Return users (or the number of them) who have been active within a recent period.
89
 *
90
 * @param array $options Array of options with keys:
91
 *
92
 *   seconds (int)  => Length of period (default 600 = 10min)
93
 *   limit   (int)  => Limit (default from settings)
94
 *   offset  (int)  => Offset (default 0)
95
 *   count   (bool) => Return a count instead of users? (default false)
96
 *
97
 * @return \ElggUser[]|int
98
 */
99
function find_active_users(array $options = []) {
100 1
	return _elgg_services()->usersTable->findActive($options);
101
}
102
103
/**
104
 * Generate and send a password request email to a given user's registered email address.
105
 *
106
 * @param int $user_guid User GUID
107
 *
108
 * @return bool
109
 */
110
function send_new_password_request($user_guid) {
111
	return _elgg_services()->passwords->sendNewPasswordRequest($user_guid);
112
}
113
114
/**
115
 * Low level function to reset a given user's password.
116
 *
117
 * This can only be called from execute_new_password_request().
118
 *
119
 * @param int    $user_guid The user.
120
 * @param string $password  Text (which will then be converted into a hash and stored)
121
 *
122
 * @return bool
123
 */
124
function force_user_password_reset($user_guid, $password) {
125
	return _elgg_services()->passwords->forcePasswordReset($user_guid, $password);
126
}
127
128
/**
129
 * Validate and change password for a user.
130
 *
131
 * @param int    $user_guid The user id
132
 * @param string $conf_code Confirmation code as sent in the request email.
133
 * @param string $password  Optional new password, if not randomly generated.
134
 *
135
 * @return bool True on success
136
 */
137
function execute_new_password_request($user_guid, $conf_code, $password = null) {
138
	return _elgg_services()->passwords->executeNewPasswordReset($user_guid, $conf_code, $password);
139
}
140
141
/**
142
 * Generate a random 12 character clear text password.
143
 *
144
 * @return string
145
 */
146
function generate_random_cleartext_password() {
147 154
	return _elgg_services()->crypto->getRandomString(12, \ElggCrypto::CHARS_PASSWORD);
148
}
149
150
/**
151
 * Simple function which ensures that a username contains only valid characters.
152
 *
153
 * This should only permit chars that are valid on the file system as well.
154
 *
155
 * @param string $username Username
156
 *
157
 * @return bool
158
 * @throws RegistrationException on invalid
159
 */
160
function validate_username($username) {
161 459
	$config = _elgg_config();
162
163
	// Basic, check length
164 459
	if (!isset($config->minusername)) {
165 2
		$config->minusername = 4;
166
	}
167
168 459
	if (strlen($username) < $config->minusername) {
169
		$msg = elgg_echo('registration:usernametooshort', [$config->minusername]);
170
		throw new \RegistrationException($msg);
171
	}
172
173
	// username in the database has a limit of 128 characters
174 459
	if (strlen($username) > 128) {
175
		$msg = elgg_echo('registration:usernametoolong', [128]);
176
		throw new \RegistrationException($msg);
177
	}
178
179
	// Blacklist for bad characters (partially nicked from mediawiki)
180
	$blacklist = '/[' .
181
		'\x{0080}-\x{009f}' . // iso-8859-1 control chars
182
		'\x{00a0}' .          // non-breaking space
183
		'\x{2000}-\x{200f}' . // various whitespace
184
		'\x{2028}-\x{202f}' . // breaks and control chars
185
		'\x{3000}' .          // ideographic space
186
		'\x{e000}-\x{f8ff}' . // private use
187 459
		']/u';
188
189 459
	if (preg_match($blacklist, $username)) {
190
		// @todo error message needs work
191
		throw new \RegistrationException(elgg_echo('registration:invalidchars'));
192
	}
193
194
	// Belts and braces
195
	// @todo Tidy into main unicode
196 459
	$blacklist2 = '\'/\\"*& ?#%^(){}[]~?<>;|¬`@+=';
197
198 459
	$blacklist2 = elgg_trigger_plugin_hook('username:character_blacklist', 'user',
199 459
		['blacklist' => $blacklist2], $blacklist2);
200
201 459
	for ($n = 0; $n < strlen($blacklist2); $n++) {
202 459
		if (strpos($username, $blacklist2[$n]) !== false) {
203
			$msg = elgg_echo('registration:invalidchars', [$blacklist2[$n], $blacklist2]);
204
			$msg = htmlspecialchars($msg, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
205
			throw new \RegistrationException($msg);
206
		}
207
	}
208
209 459
	$result = true;
210
211 459
	return elgg_trigger_plugin_hook('registeruser:validate:username', 'all',
212 459
		['username' => $username], $result);
213
}
214
215
/**
216
 * Simple validation of a password.
217
 *
218
 * @param string $password Clear text password
219
 *
220
 * @return bool
221
 * @throws RegistrationException on invalid
222
 */
223
function validate_password($password) {
224 162
	$config = _elgg_config();
225
226 162
	if (!isset($config->min_password_length)) {
227 9
		$config->min_password_length = 6;
228
	}
229
230 162
	if (strlen($password) < $config->min_password_length) {
231
		$msg = elgg_echo('registration:passwordtooshort', [$config->min_password_length]);
232
		throw new \RegistrationException($msg);
233
	}
234
235 162
	$result = true;
236
237 162
	return elgg_trigger_plugin_hook('registeruser:validate:password', 'all',
238 162
		['password' => $password], $result);
239
}
240
241
/**
242
 * Simple validation of a email.
243
 *
244
 * @param string $address Email address
245
 *
246
 * @throws RegistrationException on invalid
247
 * @return bool
248
 */
249
function validate_email_address($address) {
250 447
	if (!is_email_address($address)) {
251
		throw new \RegistrationException(elgg_echo('registration:notemail'));
252
	}
253
254
	// Got here, so lets try a hook (defaulting to ok)
255 447
	$result = true;
256
257 447
	return elgg_trigger_plugin_hook('registeruser:validate:email', 'all',
258 447
		['email' => $address], $result);
259
}
260
261
/**
262
 * Registers a user, returning false if the username already exists
263
 *
264
 * @param string $username              The username of the new user
265
 * @param string $password              The password
266
 * @param string $name                  The user's display name
267
 * @param string $email                 The user's email address
268
 * @param bool   $allow_multiple_emails Allow the same email address to be
269
 *                                      registered multiple times?
270
 * @param string $subtype               Subtype of the user entity
271
 *
272
 * @return int|false The new user's GUID; false on failure
273
 * @throws RegistrationException
274
 */
275
function register_user($username, $password, $name, $email, $allow_multiple_emails = false, $subtype = null) {
276 162
	return _elgg_services()->usersTable->register($username, $password, $name, $email, $allow_multiple_emails, $subtype);
277
}
278
279
/**
280
 * Generates a unique invite code for a user
281
 *
282
 * @param string $username The username of the user sending the invitation
283
 *
284
 * @return string Invite code
285
 * @see elgg_validate_invite_code()
286
 */
287
function generate_invite_code($username) {
288
	return _elgg_services()->usersTable->generateInviteCode($username);
289
}
290
291
/**
292
 * Validate a user's invite code
293
 *
294
 * @param string $username The username
295
 * @param string $code     The invite code
296
 *
297
 * @return bool
298
 * @see   generate_invite_code()
299
 * @since 1.10
300
 */
301
function elgg_validate_invite_code($username, $code) {
302
	return _elgg_services()->usersTable->validateInviteCode($username, $code);
303
}
304
305
/**
306
 * Page handler for account related pages
307
 *
308
 * @param array  $page_elements Page elements
309
 * @param string $handler       The handler string
310
 *
311
 * @return bool
312
 * @access private
313
 */
314
function elgg_user_account_page_handler($page_elements, $handler) {
315
316
	switch ($handler) {
317
		case 'login':
318
			echo elgg_view_resource("account/login");
319
			break;
320
		case 'forgotpassword':
321
			echo elgg_view_resource("account/forgotten_password");
322
			break;
323
		case 'changepassword':
324
			echo elgg_view_resource("account/change_password");
325
			break;
326
		case 'register':
327
			echo elgg_view_resource("account/register");
328
			break;
329
		default:
330
			return false;
331
	}
332
333
	return true;
334
}
335
336
/**
337
 * Returns site's registration URL
338
 * Triggers a 'registration_url', 'site' plugin hook that can be used by
339
 * plugins to alter the default registration URL and append query elements, such as
340
 * an invitation code and inviting user's guid
341
 *
342
 * @param array  $query    An array of query elements
343
 * @param string $fragment Fragment identifier
344
 * @return string
345
 */
346
function elgg_get_registration_url(array $query = [], $fragment = '') {
347 1
	$url = elgg_normalize_url('register');
348 1
	$url = elgg_http_add_url_query_elements($url, $query) . $fragment;
349 1
	return elgg_trigger_plugin_hook('registration_url', 'site', $query, $url);
350
}
351
352
/**
353
 * Returns site's login URL
354
 * Triggers a 'login_url', 'site' plugin hook that can be used by
355
 * plugins to alter the default login URL
356
 *
357
 * @param array  $query    An array of query elements
358
 * @param string $fragment Fragment identifier (e.g. #login-dropdown-box)
359
 * @return string
360
 */
361
function elgg_get_login_url(array $query = [], $fragment = '') {
362
	$url = elgg_normalize_url('login');
363
	$url = elgg_http_add_url_query_elements($url, $query) . $fragment;
364
	return elgg_trigger_plugin_hook('login_url', 'site', $query, $url);
365
}
366
367
/**
368
 * Set user avatar URL
369
 * Replaces user avatar URL with a public URL when walled garden is disabled
370
 *
371
 * @param string $hook   "entity:icon:url"
372
 * @param string $type   "user"
373
 * @param string $return Icon URL
374
 * @param array  $params Hook params
375
 * @return string
376
 * @access private
377
 */
378
function user_avatar_hook($hook, $type, $return, $params) {
379 1
	$user = elgg_extract('entity', $params);
380 1
	$size = elgg_extract('size', $params, 'medium');
381
382 1
	if (!$user instanceof ElggUser) {
383
		return;
384
	}
385
386 1
	if (_elgg_config()->walled_garden) {
387
		return;
388
	}
389
390 1
	if (!$user->hasIcon($size, 'icon')) {
391 1
		return;
392
	}
393
394
	$icon = $user->getIcon($size, 'icon');
395
	return elgg_get_inline_url($icon, false);
396
}
397
398
/**
399
 * Setup the default user hover menu
400
 *
401
 * @param string         $hook   'register'
402
 * @param string         $type   'menu:user_hover'
403
 * @param ElggMenuItem[] $return current return value
404
 * @param array          $params supplied params
405
 *
406
 * @return void|ElggMenuItem[]
407
 *
408
 * @access private
409
 */
410
function elgg_user_hover_menu($hook, $type, $return, $params) {
411 1
	$user = elgg_extract('entity', $params);
412
	/* @var \ElggUser $user */
413
414 1
	if (!$user instanceof \ElggUser) {
415
		return;
416
	}
417
418 1
	if (!elgg_is_logged_in()) {
419 1
		return;
420
	}
421
422
	if ($user->canEdit()) {
423
		$return[] = ElggMenuItem::factory([
424
			'name' => 'avatar:edit',
425
			'text' => elgg_echo('avatar:edit'),
426
			'icon' => 'image',
427
			'href' => "avatar/edit/$user->username",
428
			'section' => (elgg_get_logged_in_user_guid() == $user->guid)? 'action' : 'admin',
429
		]);
430
	}
431
432
	// prevent admins from banning or deleting themselves
433
	if (elgg_get_logged_in_user_guid() == $user->guid) {
434
		return $return;
435
	}
436
437
	if (!elgg_is_admin_logged_in()) {
438
		return $return;
439
	}
440
441
	// following items are admin only
442
	if (!$user->isBanned()) {
443
		$return[] = ElggMenuItem::factory([
444
			'name' => 'ban',
445
			'text' => elgg_echo('ban'),
446
			'icon' => 'ban',
447
			'href' => "action/admin/user/ban?guid={$user->guid}",
448
			'confirm' => true,
449
			'section' => 'admin',
450
		]);
451
	} else {
452
		$return[] = ElggMenuItem::factory([
453
			'name' => 'unban',
454
			'text' => elgg_echo('unban'),
455
			'icon' => 'ban',
456
			'href' => "action/admin/user/unban?guid={$user->guid}",
457
			'confirm' => true,
458
			'section' => 'admin',
459
		]);
460
	}
461
462
	$return[] = ElggMenuItem::factory([
463
		'name' => 'delete',
464
		'text' => elgg_echo('delete'),
465
		'icon' => 'delete',
466
		'href' => "action/admin/user/delete?guid={$user->guid}",
467
		'confirm' => true,
468
		'section' => 'admin',
469
	]);
470
471
	$return[] = ElggMenuItem::factory([
472
		'name' => 'resetpassword',
473
		'text' => elgg_echo('resetpassword'),
474
		'icon' => 'refresh',
475
		'href' => "action/admin/user/resetpassword?guid={$user->guid}",
476
		'confirm' => true,
477
		'section' => 'admin',
478
	]);
479
480
	if (!$user->isAdmin()) {
481
		$return[] = ElggMenuItem::factory([
482
			'name' => 'makeadmin',
483
			'text' => elgg_echo('makeadmin'),
484
			'icon' => 'level-up',
485
			'href' => "action/admin/user/makeadmin?guid={$user->guid}",
486
			'confirm' => true,
487
			'section' => 'admin',
488
		]);
489
	} else {
490
		$return[] = ElggMenuItem::factory([
491
			'name' => 'removeadmin',
492
			'text' => elgg_echo('removeadmin'),
493
			'icon' => 'level-down',
494
			'href' => "action/admin/user/removeadmin?guid={$user->guid}",
495
			'confirm' => true,
496
			'section' => 'admin',
497
		]);
498
	}
499
500
	$return[] = ElggMenuItem::factory([
501
		'name' => 'settings:edit',
502
		'text' => elgg_echo('settings:edit'),
503
		'icon' => 'cogs',
504
		'href' => "settings/user/$user->username",
505
		'section' => 'admin',
506
	]);
507
508
	return $return;
509
}
510
511
/**
512
 * Avatar page handler
513
 *
514
 * /avatar/edit/<username>
515
 *
516
 * @param array $page URL segments
517
 * @return bool
518
 * @access private
519
 */
520
function elgg_avatar_page_handler($page) {
521
	$user = get_user_by_username(elgg_extract(1, $page));
522
	if ($user) {
523
		elgg_set_page_owner_guid($user->getGUID());
524
	}
525
526
	if ($page[0] == 'edit') {
527
		echo elgg_view_resource("avatar/edit");
528
		return true;
529
	}
530
}
531
532
/**
533
 * user page handler
534
 *
535
 * /user/view/<userguid>
536
 *
537
 * @param array $page url elements
538
 * @return bool
539
 * @access private
540
 */
541
function _elgg_user_page_handler($page) {
542
	echo elgg_view_resource('user/view', [
543
		'guid' => (int) elgg_extract(1, $page),
544
	]);
545
	return true;
546
}
547
548
/**
549
 * Register menu items for the page menu
550
 *
551
 * @param string         $hook   'register'
552
 * @param string         $type   'menu:page'
553
 * @param ElggMenuItem[] $return current return value
554
 * @param array          $params supplied params
555
 *
556
 * @return void|ElggMenuItem[]
557
 *
558
 * @access private
559
 * @since 3.0
560
 */
561
function _elgg_user_page_menu($hook, $type, $return, $params) {
562
563 1
	$owner = elgg_get_page_owner_entity();
564 1
	if (!$owner) {
565
		return;
566
	}
567
568 1
	$return[] = \ElggMenuItem::factory([
569 1
		'name' => 'edit_avatar',
570 1
		'href' => "avatar/edit/{$owner->username}",
571 1
		'text' => elgg_echo('avatar:edit'),
572 1
		'section' => '1_profile',
573
		'contexts' => ['settings'],
574
	]);
575
576 1
	return $return;
577
}
578
579
/**
580
 * Register menu items for the topbar menu
581
 *
582
 * @param string         $hook   'register'
583
 * @param string         $type   'menu:topbar'
584
 * @param ElggMenuItem[] $return current return value
585
 * @param array          $params supplied params
586
 *
587
 * @return void|ElggMenuItem[]
588
 *
589
 * @access private
590
 * @since 3.0
591
 */
592
function _elgg_user_topbar_menu($hook, $type, $return, $params) {
593
594 1
	$viewer = elgg_get_logged_in_user_entity();
595 1
	if (!$viewer) {
596 1
		return;
597
	}
598
599
	$return[] = \ElggMenuItem::factory([
600
		'name' => 'account',
601
		'text' => elgg_echo('account'),
602
		'href' => $viewer->getURL(),
603
		'icon' => elgg_view('output/img', [
604
			'src' => $viewer->getIconURL('small'),
605
			'alt' => $viewer->getDisplayName(),
606
		]),
607
		'icon_alt' => 'angle-down',
608
		'priority' => 800,
609
		'section' => 'alt',
610
	]);
611
612
	$return[] = \ElggMenuItem::factory([
613
		'name' => 'usersettings',
614
		'parent_name' => 'account',
615
		'href' => "settings/user/{$viewer->username}",
616
		'text' => elgg_echo('settings'),
617
		'icon' => 'sliders',
618
		'priority' => 300,
619
		'section' => 'alt',
620
	]);
621
622
	if ($viewer->isAdmin()) {
623
		$return[] = \ElggMenuItem::factory([
624
			'name' => 'administration',
625
			'parent_name' => 'account',
626
			'href' => 'admin',
627
			'text' => elgg_echo('admin'),
628
			'icon' => 'cogs',
629
			'priority' => 800,
630
			'section' => 'alt',
631
		]);
632
	}
633
634
	$return[] = \ElggMenuItem::factory([
635
		'name' => 'logout',
636
		'parent_name' => 'account',
637
		'href' => 'action/logout',
638
		'text' => elgg_echo('logout'),
639
		'icon' => 'sign-out',
640
		'is_action' => true,
641
		'priority' => 900,
642
		'section' => 'alt',
643
	]);
644
645
	return $return;
646
}
647
648
/**
649
 * Set user icon file
650
 *
651
 * @param string    $hook   "entity:icon:file"
652
 * @param string    $type   "user"
653
 * @param \ElggIcon $icon   Icon file
654
 * @param array     $params Hook params
655
 * @return \ElggIcon
656
 */
657
function _elgg_user_set_icon_file($hook, $type, $icon, $params) {
658
659 1
	$entity = elgg_extract('entity', $params);
660 1
	$size = elgg_extract('size', $params, 'medium');
661
662 1
	$icon->owner_guid = $entity->guid;
663 1
	$icon->setFilename("profile/{$entity->guid}{$size}.jpg");
664
665 1
	return $icon;
666
}
667
668
/**
669
 * Add the user to the subscribers when (un)banning the account
670
 *
671
 * @param string $hook         'get'
672
 * @param string $type         'subscribers'
673
 * @param array  $return_value current subscribers
674
 * @param array  $params       supplied params
675
 *
676
 * @return void|array
677
 */
678
function _elgg_user_get_subscriber_unban_action($hook, $type, $return_value, $params) {
679
680 2
	if (!_elgg_config()->security_notify_user_ban) {
681 2
		return;
682
	}
683
684
	$event = elgg_extract('event', $params);
685
	if (!($event instanceof \Elgg\Notifications\Event)) {
686
		return;
687
	}
688
689
	if ($event->getAction() !== 'unban') {
690
		return;
691
	}
692
693
	$user = $event->getObject();
694
	if (!($user instanceof \ElggUser)) {
695
		return;
696
	}
697
698
	$return_value[$user->getGUID()] = ['email'];
699
700
	return $return_value;
701
}
702
703
/**
704
 * Send a notification to the user that the account was banned
705
 *
706
 * Note: this can't be handled by the delayed notification system as it won't send notifications to banned users
707
 *
708
 * @param string    $event 'ban'
709
 * @param string    $type  'user'
710
 * @param \ElggUser $user  the user being banned
711
 *
712
 * @return void
713
 */
714
function _elgg_user_ban_notification($event, $type, $user) {
715
716 71
	if (!_elgg_config()->security_notify_user_ban) {
717 71
		return;
718
	}
719
720
	if (!($user instanceof \ElggUser)) {
721
		return;
722
	}
723
724
	$site = elgg_get_site_entity();
725
	$language = $user->getLanguage();
726
727
	$subject = elgg_echo('user:notification:ban:subject', [$site->name], $language);
728
	$body = elgg_echo('user:notification:ban:body', [
729
		$user->name,
730
		$site->name,
731
		$site->getURL(),
732
	], $language);
733
734
	$params = [
735
		'action' => 'ban',
736
		'object' => $user,
737
	];
738
739
	notify_user($user->getGUID(), $site->getGUID(), $subject, $body, $params, ['email']);
740
}
741
742
/**
743
 * Prepare the notification content for the user being unbanned
744
 *
745
 * @param string                           $hook         'prepare'
746
 * @param string                           $type         'notification:unban:user:'
747
 * @param \Elgg\Notifications\Notification $return_value current notification content
748
 * @param array                            $params       supplied params
749
 *
750
 * @return void|\Elgg\Notifications\Notification
751
 */
752
function _elgg_user_prepare_unban_notification($hook, $type, $return_value, $params) {
753
754
	if (!($return_value instanceof \Elgg\Notifications\Notification)) {
755
		return;
756
	}
757
758
	$recipient = elgg_extract('recipient', $params);
759
	$object = elgg_extract('object', $params);
760
	$language = elgg_extract('language', $params);
761
762
	if (!($recipient instanceof ElggUser) || !($object instanceof ElggUser)) {
763
		return;
764
	}
765
766
	if ($recipient->getGUID() !== $object->getGUID()) {
767
		return;
768
	}
769
770
	$site = elgg_get_site_entity();
771
772
	$return_value->subject = elgg_echo('user:notification:unban:subject', [$site->name], $language);
773
	$return_value->body = elgg_echo('user:notification:unban:body', [
774
		$recipient->name,
775
		$site->name,
776
		$site->getURL(),
777
	], $language);
778
779
	$return_value->url = $recipient->getURL();
780
781
	return $return_value;
782
}
783
784
/**
785
 * Users initialisation function, which establishes the page handler
786
 *
787
 * @return void
788
 * @access private
789
 */
790
function users_init() {
791
792 31
	elgg_register_page_handler('register', 'elgg_user_account_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

792
	/** @scrutinizer ignore-deprecated */ elgg_register_page_handler('register', 'elgg_user_account_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...
793 31
	elgg_register_page_handler('forgotpassword', 'elgg_user_account_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

793
	/** @scrutinizer ignore-deprecated */ elgg_register_page_handler('forgotpassword', 'elgg_user_account_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...
794 31
	elgg_register_page_handler('changepassword', 'elgg_user_account_page_handler');
795 31
	elgg_register_page_handler('login', 'elgg_user_account_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

795
	/** @scrutinizer ignore-deprecated */ elgg_register_page_handler('login', 'elgg_user_account_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...
796 31
	elgg_register_page_handler('avatar', 'elgg_avatar_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

796
	/** @scrutinizer ignore-deprecated */ elgg_register_page_handler('avatar', 'elgg_avatar_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...
797 31
	elgg_register_page_handler('user', '_elgg_user_page_handler');
798
799 31
	elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'elgg_user_hover_menu');
800 31
	elgg_register_plugin_hook_handler('register', 'menu:page', '_elgg_user_page_menu');
801 31
	elgg_register_plugin_hook_handler('register', 'menu:topbar', '_elgg_user_topbar_menu');
802
803 31
	elgg_register_action('login', '', 'public');
804 31
	elgg_register_action('logout');
805 31
	elgg_register_action('register', '', 'public');
806 31
	elgg_register_action('useradd', '', 'admin');
807 31
	elgg_register_action('avatar/upload');
808 31
	elgg_register_action('avatar/crop');
809 31
	elgg_register_action('avatar/remove');
810
811 31
	elgg_register_plugin_hook_handler('entity:icon:url', 'user', 'user_avatar_hook');
812
813 31
	elgg_register_action('user/changepassword', '', 'public');
814 31
	elgg_register_action('user/requestnewpassword', '', 'public');
815
816
	// Register the user type
817 31
	elgg_register_entity_type('user', '');
818
819 31
	elgg_register_plugin_hook_handler('entity:icon:file', 'user', '_elgg_user_set_icon_file');
820
821 31
	elgg_register_notification_event('user', '', ['unban']);
822 31
	elgg_register_plugin_hook_handler('get', 'subscriptions', '_elgg_user_get_subscriber_unban_action');
823 31
	elgg_register_event_handler('ban', 'user', '_elgg_user_ban_notification');
824 31
	elgg_register_plugin_hook_handler('prepare', 'notification:unban:user:', '_elgg_user_prepare_unban_notification');
825
826 31
}
827
828
/**
829
 * @see \Elgg\Application::loadCore Do not do work here. Just register for events.
830
 */
831
return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
832 18
	$events->registerHandler('init', 'system', 'users_init', 0);
833
};
834