Elgg  Version master
CreateCommentEventHandler.php
Go to the documentation of this file.
1 <?php
2 
4 
11 
20  return $this->getEventEntity()?->getContainerEntity()?->owner_guid === $recipient->guid;
21  }
22 
26  protected function getNotificationSubject(\ElggUser $recipient, string $method): string {
27  return elgg_echo('generic_comment:notification:subject', [$this->getEventEntity()?->getContainerEntity()?->getDisplayName()]);
28  }
29 
33  protected function getNotificationSummary(\ElggUser $recipient, string $method): string {
34  if ($this->recipientIsCommentContainerOwner($recipient)) {
35  return elgg_echo('generic_comment:notification:owner:summary', [$this->getEventEntity()?->getContainerEntity()?->getDisplayName()]);
36  } else {
37  return elgg_echo('generic_comment:notification:user:summary', [$this->getEventEntity()?->getContainerEntity()?->getDisplayName()]);
38  }
39  }
40 
44  protected function getNotificationBody(\ElggUser $recipient, string $method): string {
45  $entity = $this->getEventEntity();
46 
47  $key = $this->recipientIsCommentContainerOwner($recipient) ? 'generic_comment:notification:owner:body' : 'generic_comment:notification:user:body';
48 
49  return elgg_echo($key, [
50  elgg_get_excerpt((string) $entity?->description, 1000),
51  $entity?->getURL(),
52  ]);
53  }
54 
60  public static function isConfigurableByUser(): bool {
61  return false;
62  }
63 
67  protected function excludeOwnerSubscribers(): bool {
68  return true;
69  }
70 }
$site description
Definition: settings.php:14
$entity
Definition: reset.php:8
$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 for 'object' 'comment' 'create' action.
recipientIsCommentContainerOwner(\ElggUser $recipient)
Tells if the recipient is the owner of the entity commented on.
getNotificationBody(\ElggUser $recipient, string $method)
{Get body for the notification.Plugin can define a subtype specific body simply by providing a transl...
static isConfigurableByUser()
Is this event configurable by the user on the notification settings page.
excludeOwnerSubscribers()
{Exclude the NotificationEvent object owner_guid when fetching the subscription records for this noti...
getNotificationSubject(\ElggUser $recipient, string $method)
{Get subject for the notification.Plugins can define a subtype specific subject simply by providing a...
getNotificationSummary(\ElggUser $recipient, string $method)
{Return the summary for a notification.Notification recipient Methodstring}
Notification Event Handler handles preparation of a notification.
getEventEntity()
Get the entity from the notification event.
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_get_excerpt(string $text, int $num_chars=250)
Returns an excerpt.
Definition: output.php:83
if($container instanceof ElggGroup && $container->guid !=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
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