Elgg  Version master
BanUserNotificationHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Users;
4 
11 
21  public function __invoke(\Elgg\Event $event) {
22  if (!_elgg_services()->config->security_notify_user_ban) {
23  return;
24  }
25 
26  $user = $event->getObject();
27  if (!$user instanceof \ElggUser) {
28  return;
29  }
30 
32  $language = $user->getLanguage();
33 
34  $subject = elgg_echo('user:notification:ban:subject', [$site->getDisplayName()], $language);
35  $body = elgg_echo('user:notification:ban:body', [
36  $site->getDisplayName(),
37  $site->getURL(),
38  ], $language);
39 
40  $params = [
41  'action' => 'ban',
42  'object' => $user,
43  'apply_muting' => false,
44  ];
45 
46  notify_user($user->guid, $site->guid, $subject, $body, $params, ['email']);
47  }
48 }
$params
Saves global plugin settings.
Definition: save.php:13
__invoke(\Elgg\Event $event)
Send a notification to the user that the account was banned.
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$site
Definition: icons.php:5
$language
Definition: useradd.php:17
$user
Definition: ban.php:7
$body
Definition: useradd.php:55
elgg_get_site_entity()
Get the current site entity.
Definition: entities.php:101
Sends notification to a banned user.
notify_user(int|array $to, int $from=0, string $subject= '', string $message= '', array $params=[], $methods_override=null)
Notify a user via their preferences.
_elgg_services()
Get the global service provider.
Definition: elgglib.php:351
$subject
Definition: useradd.php:54
Models an event passed to event handlers.
Definition: Event.php:11