Elgg  Version 4.3
UnbanUserEventHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Notifications;
4 
11 
17  protected function recipientIsBannedUser(\ElggUser $recipient): bool {
18  return $this->event->getObject()->guid === $recipient->guid;
19  }
20 
24  protected function getNotificationSubject(\ElggUser $recipient, string $method): string {
25  if (!$this->recipientIsBannedUser($recipient)) {
26  return parent::getNotificationSubject($recipient, $method);
27  }
28 
29  return elgg_echo('user:notification:unban:subject', [elgg_get_site_entity()->getDisplayName()], $recipient->getLanguage());
30  }
31 
35  protected function getNotificationBody(\ElggUser $recipient, string $method): string {
36  if (!$this->recipientIsBannedUser($recipient)) {
37  return parent::getNotificationBody($recipient, $method);
38  }
39 
41 
42  return elgg_echo('user:notification:unban:body', [
43  $site->getDisplayName(),
44  $site->getURL(),
45  ], $recipient->getLanguage());
46  }
47 
51  protected function addMuteLink(): bool {
52  return false;
53  }
54 
60  public function getSubscriptions(): array {
61  $result = parent::getSubscriptions();
62 
63  if (_elgg_services()->config->security_notify_user_ban) {
64  $result[$this->event->getObject()->guid] = ['email'];
65  }
66 
67  return $result;
68  }
69 
73  public static function isConfigurableByUser(): bool {
74  return false;
75  }
76 }
recipientIsBannedUser(\ElggUser $recipient)
Tells if the recipient is the user being unbanned.
getLanguage($fallback=null)
Get user language or default to site language.
Definition: ElggUser.php:73
$site
Definition: icons.php:5
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
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)
getNotificationSubject(\ElggUser $recipient, string $method)
elgg_get_site_entity()
Get the current site entity.
Definition: entities.php:99
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638
getSubscriptions()
Add the user to the subscribers when (un)banning the account.
$recipient
Definition: mute.php:8