3 namespace Elgg\Notifications;
92 foreach ($records as $record) {
93 if (empty($record->guid)) {
102 $deliveryMethods = explode(
',', $record->methods);
140 foreach ($records as $record) {
141 if (empty($record->guid)) {
150 $deliveryMethods = explode(
',', $record->methods);
179 if (!
_elgg_services()->notifications->isRegisteredMethod($method)) {
215 return implode(
':', $rel);
259 $select = Select::fromTable(RelationshipsTable::TABLE_NAME);
260 $select->select(
'count(*) as total')
266 $ors[] = $select->compare(
'relationship',
'=', self::RELATIONSHIP_PREFIX .
':' . $method,
ELGG_VALUE_STRING);
267 $ors[] = $select->compare(
'relationship',
'like', self::RELATIONSHIP_PREFIX .
':%:' . $method,
ELGG_VALUE_STRING);
270 $select->andWhere($select->merge($ors,
'OR'));
272 $result = $this->db->getDataRow($select);
329 return (
bool) $this->db->deleteData(
$delete);
345 $rel =
$qb->joinRelationshipTable($main_alias,
'guid',
null,
true);
350 $rel =
$qb->joinRelationshipTable($main_alias,
'guid',
null,
true);
353 return $qb->compare(
"{$rel}.relationship",
'like', self::RELATIONSHIP_PREFIX .
':%',
ELGG_VALUE_STRING);
358 $ors[] =
$qb->compare(
"{$rel}.relationship",
'=', self::RELATIONSHIP_PREFIX .
':' . $method,
ELGG_VALUE_STRING);
359 $ors[] =
$qb->compare(
"{$rel}.relationship",
'like', self::RELATIONSHIP_PREFIX .
':%:' . $method,
ELGG_VALUE_STRING);
362 return $qb->merge($ors,
'OR');
411 return $qb->compare(
"{$main_alias}.relationship",
'like', self::RELATIONSHIP_PREFIX .
':%',
ELGG_VALUE_STRING);
419 $ors[] =
$qb->compare(
"{$main_alias}.relationship",
'=', self::RELATIONSHIP_PREFIX .
':' . $method,
ELGG_VALUE_STRING);
420 $ors[] =
$qb->compare(
"{$main_alias}.relationship",
'like', self::RELATIONSHIP_PREFIX .
':%:' . $method,
ELGG_VALUE_STRING);
423 return $qb->merge($ors,
'OR');
431 return $qb->compare(
"{$main_alias}.relationship",
'like', self::RELATIONSHIP_PREFIX .
":{$type}:{$subtype}:{$action}:%",
ELGG_VALUE_STRING);
449 $rel = new \ElggRelationship();
451 $rel->relationship = self::MUTE_NOTIFICATIONS_RELATIONSHIP;
494 return array_values(array_filter(array_unique($user_methods)));
522 $guids_to_check = [];
537 $guids_to_check[] =
$entity->guid;
538 $guids_to_check[] =
$entity->owner_guid;
539 $guids_to_check[] =
$entity->container_guid;
543 $guids_to_check = array_filter($guids_to_check);
544 if (empty($guids_to_check)) {
549 $select = Select::fromTable(RelationshipsTable::TABLE_NAME);
550 $select->select(
'guid_one')
551 ->where($select->compare(
'relationship',
'=', self::MUTE_NOTIFICATIONS_RELATIONSHIP,
ELGG_VALUE_STRING))
552 ->andWhere($select->compare(
'guid_two',
'in', $guids_to_check,
ELGG_VALUE_GUID));
554 $muted = $this->db->getData($select,
function($row) {
555 return (
int) $row->guid_one;
570 return array_map(function ($user_methods) {
571 if (!in_array(
'delayed_email', $user_methods) || !in_array(
'email', $user_methods)) {
572 return $user_methods;
575 $pos = array_search(
'delayed_email', $user_methods);
576 unset($user_methods[$pos]);
578 return array_values($user_methods);
594 'callback' => function ($row) {
595 return (
int) $row->guid;
597 'metadata_name_value_pairs' => [
599 'name' =>
'timed_muting_start',
604 'name' =>
'timed_muting_end',
641 $select = Select::fromTable(RelationshipsTable::TABLE_NAME);
642 $select->select(
'guid_one AS guid')
643 ->addSelect(
"GROUP_CONCAT(relationship SEPARATOR ',') AS methods")
646 ->groupBy(
'guid_one');
652 return $this->db->getData($select);
666 $prefix = self::RELATIONSHIP_PREFIX;
670 $names[] =
"{$prefix}:{$method}";
673 $names[] =
"{$prefix}:{$type}:{$subtype}:{$action}:{$method}";
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/clear'=>['access'=> 'admin'], 'admin/site/cache/invalidate'=>['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', 'controller'=> \Elgg\Diagnostics\DownloadController::class,], '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'=>[],]
$guids
Activates all specified installed and inactive plugins.
A generic class that contains shared code among \ElggExtender, \ElggEntity, and \ElggRelationship.
Query builder for updating data in the database.
Entities repository contains methods for fetching entities from database or performing calculations o...
Database abstraction query builder.
Relationships table database service.
Query builder for fetching data from the database.
Exception thrown if an argument is not of the expected type.
removeSubscription(int $user_guid, string $method, int $target_guid, ?string $type=null, ?string $subtype=null, ?string $action=null)
Unsubscribe a user to notifications about a target entity.
getEntitySubscriptions(int $target_guid=0, int $user_guid=0, array $methods=[], ?string $type=null, ?string $subtype=null, ?string $action=null)
Get the current subscriptions for the given entity.
addSubscription(int $user_guid, string $method, int $target_guid, ?string $type=null, ?string $subtype=null, ?string $action=null)
Subscribe a user to notifications about a target entity.
getMethodRelationships(array $methods, ?string $type=null, ?string $subtype=null, ?string $action=null)
Get the relationship names for notifications.
assertValidTypeSubtypeActionForSubscription($type, $subtype, $action)
Validate subscription input for type, subtype and action.
removeSubscriptions(int $user_guid, int $target_guid, array $methods=[])
Unsubscribe a user from all notifications about the target entity.
const RELATIONSHIP_PREFIX
getSubscriptionRecords(array $container_guid, array $methods, ?string $type=null, ?string $subtype=null, ?string $action=null, int $actor_guid=0)
Get subscription records from the database.
filterTimedMutedSubscribers(array $subscriptions)
Filter users who have set a period in which not to receive notifications.
muteNotifications(int $user_guid, int $target_guid)
Mute notifications about events affecting the target.
hasMutedNotifications(int $user_guid, int $target_guid)
Check if the user has notifications muted about events affecting the target.
getNotificationEventSubscriptions(NotificationEvent $event, array $methods, array $exclude_guids_for_records=[])
Get the subscriptions for this notification event.
filterMutedNotifications(array $subscriptions, NotificationEvent $event)
Filter subscriptions based on muted notification settings related to the notification event.
const MUTE_NOTIFICATIONS_RELATIONSHIP
hasSubscription(int $user_guid, string $method, int $target_guid, ?string $type=null, ?string $subtype=null, ?string $action=null)
Check if a subscription exists.
hasSubscriptions(int $user_guid, int $target_guid, array $methods=[])
Check if any subscription exists.
getSubscribers(int $target_guid, array $methods=[])
Get all subscribers of the target guid.
__construct(protected Database $db, protected RelationshipsTable $relationshipsTable, protected EventsService $events)
Constructor.
getSubscriptionsForContainer(int $container_guid, array $methods, ?string $type=null, ?string $subtype=null, ?string $action=null, int $actor_guid=0)
Get the subscriptions for the content created inside this container.
filterDelayedEmailSubscribers(array $subscriptions)
When a user has both 'email' and 'delayed_email' subscription remove the delayed email as it would be...
unmuteNotifications(int $user_guid, int $target_guid)
No longer nute notifications about events affecting the target.
getSubscriptionRelationshipName(string $method, ?string $type=null, ?string $subtype=null, ?string $action=null)
filterSubscriptions(array $subscriptions, NotificationEvent $event, bool $filter_muted=true)
Apply filtering to subscriptions, like muted notifications etc.
const ELGG_ENTITIES_ANY_VALUE
Constant to request the value of a parameter be ignored in elgg_get_*() functions.
foreach($recommendedExtensions as $extension) if(empty(ini_get('session.gc_probability'))||empty(ini_get('session.gc_divisor'))) $db
if($email instanceof \Elgg\Email) $object
if($item instanceof \ElggEntity) elseif($item instanceof \ElggRiverItem) elseif($item instanceof \ElggRelationship) elseif(is_callable([ $item, 'getType']))
$relationship
Elgg default relationship view.
_elgg_services()
Get the global service provider.
Notification event interface.
getActorGUID()
Get the GUID of the actor.
getAction()
Get the name of the action.
getObject()
Get the object of the event.
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
elgg_get_relationships(array $options=[])
Fetch relationships or perform a calculation on them.
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.
if(empty($methods)) $subscriptions