Elgg  Version 5.1
UnbanUserEventHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Notifications;
4 
11 
19  protected function recipientIsBannedUser(\ElggUser $recipient): bool {
20  return $this->event->getObject()->guid === $recipient->guid;
21  }
22 
26  protected function getNotificationSubject(\ElggUser $recipient, string $method): string {
27  if (!$this->recipientIsBannedUser($recipient)) {
28  return parent::getNotificationSubject($recipient, $method);
29  }
30 
31  return elgg_echo('user:notification:unban:subject', [elgg_get_site_entity()->getDisplayName()], $recipient->getLanguage());
32  }
33 
37  protected function getNotificationBody(\ElggUser $recipient, string $method): string {
38  if (!$this->recipientIsBannedUser($recipient)) {
39  return parent::getNotificationBody($recipient, $method);
40  }
41 
43 
44  return elgg_echo('user:notification:unban:body', [
45  $site->getDisplayName(),
46  $site->getURL(),
47  ], $recipient->getLanguage());
48  }
49 
53  protected function addMuteLink(): bool {
54  return false;
55  }
56 
62  public function getSubscriptions(): array {
63  $result = parent::getSubscriptions();
64 
65  if (_elgg_services()->config->security_notify_user_ban) {
66  $result[$this->event->getObject()->guid] = ['email'];
67  }
68 
69  return $result;
70  }
71 
75  public static function isConfigurableByUser(): bool {
76  return false;
77  }
78 }
recipientIsBannedUser(\ElggUser $recipient)
Tells if the recipient is the user being unbanned.
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
Notification Event Handler for &#39;user&#39; &#39;user&#39; &#39;unban&#39; action.
Notification Event Handler handles preparation of a notification.
getNotificationBody(\ElggUser $recipient, string $method)
getLanguage(string $fallback=null)
Get user language or default to site language.
Definition: ElggUser.php:71
getNotificationSubject(\ElggUser $recipient, string $method)
elgg_get_site_entity()
Get the current site entity.
Definition: entities.php:98
_elgg_services()
Get the global service provider.
Definition: elgglib.php:346
getSubscriptions()
Add the user to the subscribers when (un)banning the account.
$recipient
Definition: mute.php:8