77 if (empty($methods)) {
106 foreach ($records as $record) {
107 if (empty($record->guid)) {
116 $deliveryMethods = explode(
',', $record->methods);
118 $relationship_array = explode(
':', $relationship);
147 if (empty($methods)) {
154 foreach ($records as $record) {
155 if (empty($record->guid)) {
164 $deliveryMethods = explode(
',', $record->methods);
166 $relationship_array = explode(
':', $relationship);
194 self::RELATIONSHIP_PREFIX,
197 if (!
_elgg_services()->notifications->isRegisteredMethod($method)) {
212 return $this->relationshipsTable->add($user_guid,
implode(
':', $rel), $target_guid);
233 self::RELATIONSHIP_PREFIX,
244 return $this->relationshipsTable->check($user_guid,
implode(
':', $rel), $target_guid) instanceof \ElggRelationship;
269 $select->select(
'count(*) as total')
270 ->where($select->compare(
'guid_one',
'=', $user_guid,
ELGG_VALUE_GUID))
271 ->andWhere($select->compare(
'guid_two',
'=', $target_guid,
ELGG_VALUE_GUID));
275 $ors[] = $select->compare(
'relationship',
'=', self::RELATIONSHIP_PREFIX .
':' . $method,
ELGG_VALUE_STRING);
276 $ors[] = $select->compare(
'relationship',
'like', self::RELATIONSHIP_PREFIX .
':%:' . $method,
ELGG_VALUE_STRING);
279 $select->andWhere($select->merge($ors,
'OR'));
281 $result = $this->db->getDataRow($select);
303 self::RELATIONSHIP_PREFIX,
314 if (!$this->relationshipsTable->check($user_guid,
implode(
':', $rel), $target_guid)) {
319 return $this->relationshipsTable->remove($user_guid,
implode(
':', $rel), $target_guid);
349 return (
bool) $this->db->deleteData(
$delete);
379 $ors[] = $qb->
compare(
"{$rel}.relationship",
'like', self::RELATIONSHIP_PREFIX .
':%:' . $method,
ELGG_VALUE_STRING);
382 return $qb->
merge($ors,
'OR');
439 $ors[] = $qb->
compare(
"{$main_alias}.relationship",
'=', self::RELATIONSHIP_PREFIX .
':' . $method,
ELGG_VALUE_STRING);
440 $ors[] = $qb->
compare(
"{$main_alias}.relationship",
'like', self::RELATIONSHIP_PREFIX .
':%:' . $method,
ELGG_VALUE_STRING);
443 return $qb->
merge($ors,
'OR');
451 return $qb->
compare(
"{$main_alias}.relationship",
'like', self::RELATIONSHIP_PREFIX .
":{$type}:{$subtype}:{$action}:%",
ELGG_VALUE_STRING);
469 return $this->relationshipsTable->add($user_guid, self::MUTE_NOTIFICATIONS_RELATIONSHIP, $target_guid);
481 return $this->relationshipsTable->remove($user_guid, self::MUTE_NOTIFICATIONS_RELATIONSHIP, $target_guid);
493 return $this->relationshipsTable->check($user_guid, self::MUTE_NOTIFICATIONS_RELATIONSHIP, $target_guid) instanceof \ElggRelationship;
508 $subscriptions = array_map(
function($user_methods) {
509 return array_values(array_filter(array_unique($user_methods)));
537 $guids_to_check = [];
551 if (
$entity instanceof \ElggEntity) {
552 $guids_to_check[] =
$entity->guid;
553 $guids_to_check[] =
$entity->owner_guid;
554 $guids_to_check[] =
$entity->container_guid;
558 $guids_to_check = array_filter($guids_to_check);
559 if (empty($guids_to_check)) {
565 $select->select(
'guid_one')
566 ->where($select->compare(
'relationship',
'=', self::MUTE_NOTIFICATIONS_RELATIONSHIP,
ELGG_VALUE_STRING))
567 ->andWhere($select->compare(
'guid_two',
'in', $guids_to_check,
ELGG_VALUE_GUID));
569 $muted = $this->db->getData($select,
function($row) {
570 return (
int) $row->guid_one;
574 return array_diff_key($subscriptions, array_flip($muted));
585 return array_map(
function ($user_methods) {
586 if (!in_array(
'delayed_email', $user_methods) || !in_array(
'email', $user_methods)) {
587 return $user_methods;
590 $pos = array_search(
'delayed_email', $user_methods);
591 unset($user_methods[$pos]);
593 return array_values($user_methods);
607 'guids' => array_keys($subscriptions),
609 'callback' =>
function ($row) {
610 return (
int) $row->guid;
612 'metadata_name_value_pairs' => [
614 'name' =>
'timed_muting_start',
619 'name' =>
'timed_muting_end',
626 return array_diff_key($subscriptions, array_flip($muted));
651 $container_guid = array_unique(array_filter($container_guid));
652 if (empty($container_guid)) {
657 $select->select(
'guid_one AS guid')
658 ->addSelect(
"GROUP_CONCAT(relationship SEPARATOR ',') AS methods")
659 ->where($select->compare(
'guid_two',
'in', $container_guid,
ELGG_VALUE_GUID))
661 ->groupBy(
'guid_one');
667 return $this->db->getData($select);
681 $prefix = self::RELATIONSHIP_PREFIX;
684 foreach ($methods as $method) {
685 $names[] =
"{$prefix}:{$method}";
688 $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']))
__construct(Database $db, RelationshipsTable $relationshipsTable, EventsService $events)
Constructor.
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.
Relationships table database service.
removeSubscriptions(int $user_guid, int $target_guid, array $methods=[])
Unsubscribe a user from all notifications about the target entity.
compare($x, $comparison, $y=null, $type=null, $case_sensitive=null)
Build value comparison clause.
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 .
const MUTE_NOTIFICATIONS_RELATIONSHIP
static fromTable($table, $alias=null)
{}
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.
_elgg_services()
Get the global service provider.
joinRelationshipTable($from_alias= '', $from_column= 'guid', $name=null, $inverse=false, $join_type= 'inner', $joined_alias=null)
Join relationship table from alias and return joined table alias.
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...
static fromTable($table, $alias=null)
{}
hasMutedNotifications(int $user_guid, int $target_guid)
Check if the user has notifications muted about events affecting the target.
const RELATIONSHIP_PREFIX