Elgg  Version master
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->getEventEntity()?->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()]);
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  ]);
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->getEventEntity()?->guid] = ['email'];
67  }
68 
69  return $result;
70  }
71 
75  public static function isConfigurableByUser(): bool {
76  return false;
77  }
78 }
$site
Definition: icons.php:5
$recipient
Definition: mute.php:8
return[ 'admin/delete_admin_notices'=>['access'=> 'admin'], 'admin/menu/save'=>['access'=> 'admin'], 'admin/plugins/activate'=>['access'=> 'admin'], 'admin/plugins/activate_all'=>['access'=> 'admin'], 'admin/plugins/deactivate'=>['access'=> 'admin'], 'admin/plugins/deactivate_all'=>['access'=> 'admin'], 'admin/plugins/set_priority'=>['access'=> 'admin'], 'admin/security/security_txt'=>['access'=> 'admin'], 'admin/security/settings'=>['access'=> 'admin'], 'admin/security/regenerate_site_secret'=>['access'=> 'admin'], 'admin/site/cache/invalidate'=>['access'=> 'admin'], 'admin/site/flush_cache'=>['access'=> 'admin'], 'admin/site/icons'=>['access'=> 'admin'], 'admin/site/set_maintenance_mode'=>['access'=> 'admin'], 'admin/site/set_robots'=>['access'=> 'admin'], 'admin/site/theme'=>['access'=> 'admin'], 'admin/site/unlock_upgrade'=>['access'=> 'admin'], 'admin/site/settings'=>['access'=> 'admin'], 'admin/upgrade'=>['access'=> 'admin'], 'admin/upgrade/reset'=>['access'=> 'admin'], 'admin/user/ban'=>['access'=> 'admin'], 'admin/user/bulk/ban'=>['access'=> 'admin'], 'admin/user/bulk/delete'=>['access'=> 'admin'], 'admin/user/bulk/unban'=>['access'=> 'admin'], 'admin/user/bulk/validate'=>['access'=> 'admin'], 'admin/user/change_email'=>['access'=> 'admin'], 'admin/user/delete'=>['access'=> 'admin'], 'admin/user/login_as'=>['access'=> 'admin'], 'admin/user/logout_as'=>[], 'admin/user/makeadmin'=>['access'=> 'admin'], 'admin/user/resetpassword'=>['access'=> 'admin'], 'admin/user/removeadmin'=>['access'=> 'admin'], 'admin/user/unban'=>['access'=> 'admin'], 'admin/user/validate'=>['access'=> 'admin'], 'annotation/delete'=>[], 'avatar/upload'=>[], 'comment/save'=>[], 'diagnostics/download'=>['access'=> 'admin'], 'entity/chooserestoredestination'=>[], 'entity/delete'=>[], 'entity/mute'=>[], 'entity/restore'=>[], 'entity/subscribe'=>[], 'entity/trash'=>[], 'entity/unmute'=>[], 'entity/unsubscribe'=>[], 'login'=>['access'=> 'logged_out'], 'logout'=>[], 'notifications/mute'=>['access'=> 'public'], 'plugins/settings/remove'=>['access'=> 'admin'], 'plugins/settings/save'=>['access'=> 'admin'], 'plugins/usersettings/save'=>[], 'register'=>['access'=> 'logged_out', 'middleware'=>[\Elgg\Router\Middleware\RegistrationAllowedGatekeeper::class,],], 'river/delete'=>[], 'settings/notifications'=>[], 'settings/notifications/subscriptions'=>[], 'user/changepassword'=>['access'=> 'public'], 'user/requestnewpassword'=>['access'=> 'public'], 'useradd'=>['access'=> 'admin'], 'usersettings/save'=>[], 'widgets/add'=>[], 'widgets/delete'=>[], 'widgets/move'=>[], 'widgets/save'=>[],]
Definition: actions.php:73
Notification Event Handler handles preparation of a notification.
getEventEntity()
Get the entity from the notification event.
Notification Event Handler for 'user' 'user' 'unban' action.
static isConfigurableByUser()
{Is this event configurable by the user on the notification settings page.bool}
getSubscriptions()
Add the user to the subscribers when (un)banning the account.
getNotificationBody(\ElggUser $recipient, string $method)
{Get body for the notification.Plugin can define a subtype specific body simply by providing a transl...
getNotificationSubject(\ElggUser $recipient, string $method)
{Get subject for the notification.Plugins can define a subtype specific subject simply by providing a...
recipientIsBannedUser(\ElggUser $recipient)
Tells if the recipient is the user being unbanned.
addMuteLink()
{Add a mute link in the email notification.bool}
_elgg_services()
Get the global service provider.
Definition: elgglib.php:353
elgg_get_site_entity()
Get the current site entity.
Definition: entities.php:101
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.
Definition: robots.php:10