63 if (empty($methods)) {
92 foreach ($records as $record) {
93 if (empty($record->guid)) {
102 $deliveryMethods = explode(
',', $record->methods);
104 $relationship_array = explode(
':', $relationship);
133 if (empty($methods)) {
140 foreach ($records as $record) {
141 if (empty($record->guid)) {
150 $deliveryMethods = explode(
',', $record->methods);
152 $relationship_array = explode(
':', $relationship);
180 self::RELATIONSHIP_PREFIX,
183 if (!
_elgg_services()->notifications->isRegisteredMethod($method)) {
198 return $this->relationshipsTable->add($user_guid,
implode(
':', $rel), $target_guid);
219 self::RELATIONSHIP_PREFIX,
230 return $this->relationshipsTable->check($user_guid,
implode(
':', $rel), $target_guid) instanceof \ElggRelationship;
255 $select->select(
'count(*) as total')
256 ->where($select->compare(
'guid_one',
'=', $user_guid,
ELGG_VALUE_GUID))
257 ->andWhere($select->compare(
'guid_two',
'=', $target_guid,
ELGG_VALUE_GUID));
261 $ors[] = $select->compare(
'relationship',
'=', self::RELATIONSHIP_PREFIX .
':' . $method,
ELGG_VALUE_STRING);
262 $ors[] = $select->compare(
'relationship',
'like', self::RELATIONSHIP_PREFIX .
':%:' . $method,
ELGG_VALUE_STRING);
265 $select->andWhere($select->merge($ors,
'OR'));
267 $result = $this->db->getDataRow($select);
289 self::RELATIONSHIP_PREFIX,
300 if (!$this->relationshipsTable->check($user_guid,
implode(
':', $rel), $target_guid)) {
305 return $this->relationshipsTable->remove($user_guid,
implode(
':', $rel), $target_guid);
335 return (
bool) $this->db->deleteData(
$delete);
365 $ors[] = $qb->
compare(
"{$rel}.relationship",
'like', self::RELATIONSHIP_PREFIX .
':%:' . $method,
ELGG_VALUE_STRING);
368 return $qb->
merge($ors,
'OR');
425 $ors[] = $qb->
compare(
"{$main_alias}.relationship",
'=', self::RELATIONSHIP_PREFIX .
':' . $method,
ELGG_VALUE_STRING);
426 $ors[] = $qb->
compare(
"{$main_alias}.relationship",
'like', self::RELATIONSHIP_PREFIX .
':%:' . $method,
ELGG_VALUE_STRING);
429 return $qb->
merge($ors,
'OR');
437 return $qb->
compare(
"{$main_alias}.relationship",
'like', self::RELATIONSHIP_PREFIX .
":{$type}:{$subtype}:{$action}:%",
ELGG_VALUE_STRING);
455 return $this->relationshipsTable->add($user_guid, self::MUTE_NOTIFICATIONS_RELATIONSHIP, $target_guid);
467 return $this->relationshipsTable->remove($user_guid, self::MUTE_NOTIFICATIONS_RELATIONSHIP, $target_guid);
479 return $this->relationshipsTable->check($user_guid, self::MUTE_NOTIFICATIONS_RELATIONSHIP, $target_guid) instanceof \ElggRelationship;
494 $subscriptions = array_map(
function($user_methods) {
495 return array_values(array_filter(array_unique($user_methods)));
523 $guids_to_check = [];
537 if (
$entity instanceof \ElggEntity) {
538 $guids_to_check[] =
$entity->guid;
539 $guids_to_check[] =
$entity->owner_guid;
540 $guids_to_check[] =
$entity->container_guid;
544 $guids_to_check = array_filter($guids_to_check);
545 if (empty($guids_to_check)) {
551 $select->select(
'guid_one')
552 ->where($select->compare(
'relationship',
'=', self::MUTE_NOTIFICATIONS_RELATIONSHIP,
ELGG_VALUE_STRING))
553 ->andWhere($select->compare(
'guid_two',
'in', $guids_to_check,
ELGG_VALUE_GUID));
555 $muted = $this->db->getData($select,
function($row) {
556 return (
int) $row->guid_one;
560 return array_diff_key($subscriptions, array_flip($muted));
571 return array_map(
function ($user_methods) {
572 if (!in_array(
'delayed_email', $user_methods) || !in_array(
'email', $user_methods)) {
573 return $user_methods;
576 $pos = array_search(
'delayed_email', $user_methods);
577 unset($user_methods[$pos]);
579 return array_values($user_methods);
593 'guids' => array_keys($subscriptions),
595 'callback' =>
function ($row) {
596 return (
int) $row->guid;
598 'metadata_name_value_pairs' => [
600 'name' =>
'timed_muting_start',
605 'name' =>
'timed_muting_end',
612 return array_diff_key($subscriptions, array_flip($muted));
637 $container_guid = array_unique(array_filter($container_guid));
638 if (empty($container_guid)) {
643 $select->select(
'guid_one AS guid')
644 ->addSelect(
"GROUP_CONCAT(relationship SEPARATOR ',') AS methods")
645 ->where($select->compare(
'guid_two',
'in', $container_guid,
ELGG_VALUE_GUID))
647 ->groupBy(
'guid_one');
653 return $this->db->getData($select);
667 $prefix = self::RELATIONSHIP_PREFIX;
670 foreach ($methods as $method) {
671 $names[] =
"{$prefix}:{$method}";
674 $names[] =
"{$prefix}:{$type}:{$subtype}:{$action}:{$method}";
filterTimedMutedSubscribers(array $subscriptions)
Filter users who have set a period in which not to receive notifications.
getObject()
Get the object of the event.
Exception thrown if an argument is not of the expected type.
getSubscribers(int $target_guid, array $methods=[])
Get all subscribers of the target guid.
static find(array $options=[])
Build and execute a new query from an array of legacy options.
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.
getActorGUID()
Get the GUID of the actor.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
getMethodRelationships(array $methods, string $type=null, string $subtype=null, string $action=null)
Get the relationship names for notifications.
$relationship
Elgg default relationship view.
hasSubscriptions(int $user_guid, int $target_guid, array $methods=[])
Check if any subscription exists.
Database abstraction query builder.
getAction()
Get the name of the action.
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof\ElggRelationship) elseif(is_callable([$item, 'getType']))
filterMutedNotifications(array $subscriptions, NotificationEvent $event)
Filter subscriptions based on muted notification settings related to the notification event...
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
foreach($recommendedExtensions as $extension) if(empty(ini_get('session.gc_probability'))||empty(ini_get('session.gc_divisor'))) $db
Relationships table database service.
compare(string $x, string $comparison, $y=null, string $type=null, bool $case_sensitive=null)
Build value comparison clause.
removeSubscriptions(int $user_guid, int $target_guid, array $methods=[])
Unsubscribe a user from all notifications about the target entity.
static fromTable(string $table)
Returns a QueryBuilder for deleting data from a given table.
const ELGG_ENTITIES_ANY_VALUE
Constant to request the value of a parameter be ignored in elgg_get_*() functions.
A generic class that contains shared code among , , and .
joinRelationshipTable(string $from_alias= '', string $from_column= 'guid', $name=null, bool $inverse=false,?string $join_type= 'inner', string $joined_alias=null)
Join relationship table from alias and return joined table alias.
const MUTE_NOTIFICATIONS_RELATIONSHIP
getNotificationEventSubscriptions(NotificationEvent $event, array $methods, array $exclude_guids_for_records=[])
Get the subscriptions for this notification event.
$guids
Activates all specified installed and inactive plugins.
if($email instanceof\Elgg\Email) $object
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.
merge($parts=null, $boolean= 'AND')
Merges multiple composite expressions with a boolean.
filterSubscriptions(array $subscriptions, NotificationEvent $event, bool $filter_muted=true)
Apply filtering to subscriptions, like muted notifications etc.
Notification event interface.
unmuteNotifications(int $user_guid, int $target_guid)
No longer nute notifications about events affecting the target.
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.
elgg_get_relationships(array $options=[])
Fetch relationships or perform a calculation on them.
hasSubscription(int $user_guid, string $method, int $target_guid, string $type=null, string $subtype=null, string $action=null)
Check if a subscription exists.
static fromTable(string $table, string $alias=null)
Returns a QueryBuilder for selecting data from a given table.
_elgg_services()
Get the global service provider.
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.
if(empty($methods)) $subscriptions
muteNotifications(int $user_guid, int $target_guid)
Mute notifications about events affecting the target.
assertValidTypeSubtypeActionForSubscription($type, $subtype, $action)
Validate subscription input for type, subtype and action.
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.
filterDelayedEmailSubscribers(array $subscriptions)
When a user has both 'email' and 'delayed_email' subscription remove the delayed email as it would be...
hasMutedNotifications(int $user_guid, int $target_guid)
Check if the user has notifications muted about events affecting the target.
__construct(protected Database $db, protected RelationshipsTable $relationshipsTable, protected EventsService $events)
Constructor.
const RELATIONSHIP_PREFIX