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)) {
224 self::RELATIONSHIP_PREFIX,
235 return $this->relationshipsTable->check($user_guid,
implode(
':', $rel), $target_guid) instanceof \ElggRelationship;
260 $select->select(
'count(*) as total')
261 ->where($select->compare(
'guid_one',
'=', $user_guid,
ELGG_VALUE_GUID))
262 ->andWhere($select->compare(
'guid_two',
'=', $target_guid,
ELGG_VALUE_GUID));
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);
294 self::RELATIONSHIP_PREFIX,
305 if (!$this->relationshipsTable->check($user_guid,
implode(
':', $rel), $target_guid)) {
310 return $this->relationshipsTable->remove($user_guid,
implode(
':', $rel), $target_guid);
340 return (
bool) $this->db->deleteData(
$delete);
370 $ors[] = $qb->
compare(
"{$rel}.relationship",
'like', self::RELATIONSHIP_PREFIX .
':%:' . $method,
ELGG_VALUE_STRING);
373 return $qb->
merge($ors,
'OR');
430 $ors[] = $qb->
compare(
"{$main_alias}.relationship",
'=', self::RELATIONSHIP_PREFIX .
':' . $method,
ELGG_VALUE_STRING);
431 $ors[] = $qb->
compare(
"{$main_alias}.relationship",
'like', self::RELATIONSHIP_PREFIX .
':%:' . $method,
ELGG_VALUE_STRING);
434 return $qb->
merge($ors,
'OR');
442 return $qb->
compare(
"{$main_alias}.relationship",
'like', self::RELATIONSHIP_PREFIX .
":{$type}:{$subtype}:{$action}:%",
ELGG_VALUE_STRING);
460 $rel = new \ElggRelationship();
462 $rel->relationship = self::MUTE_NOTIFICATIONS_RELATIONSHIP;
477 return $this->relationshipsTable->remove($user_guid, self::MUTE_NOTIFICATIONS_RELATIONSHIP, $target_guid);
489 return $this->relationshipsTable->check($user_guid, self::MUTE_NOTIFICATIONS_RELATIONSHIP, $target_guid) instanceof \ElggRelationship;
504 $subscriptions = array_map(
function($user_methods) {
505 return array_values(array_filter(array_unique($user_methods)));
533 $guids_to_check = [];
547 if (
$entity instanceof \ElggEntity) {
548 $guids_to_check[] =
$entity->guid;
549 $guids_to_check[] =
$entity->owner_guid;
550 $guids_to_check[] =
$entity->container_guid;
554 $guids_to_check = array_filter($guids_to_check);
555 if (empty($guids_to_check)) {
561 $select->select(
'guid_one')
562 ->where($select->compare(
'relationship',
'=', self::MUTE_NOTIFICATIONS_RELATIONSHIP,
ELGG_VALUE_STRING))
563 ->andWhere($select->compare(
'guid_two',
'in', $guids_to_check,
ELGG_VALUE_GUID));
565 $muted = $this->db->getData($select,
function($row) {
566 return (
int) $row->guid_one;
570 return array_diff_key($subscriptions, array_flip($muted));
581 return array_map(
function ($user_methods) {
582 if (!in_array(
'delayed_email', $user_methods) || !in_array(
'email', $user_methods)) {
583 return $user_methods;
586 $pos = array_search(
'delayed_email', $user_methods);
587 unset($user_methods[$pos]);
589 return array_values($user_methods);
603 'guids' => array_keys($subscriptions),
605 'callback' =>
function ($row) {
606 return (
int) $row->guid;
608 'metadata_name_value_pairs' => [
610 'name' =>
'timed_muting_start',
615 'name' =>
'timed_muting_end',
622 return array_diff_key($subscriptions, array_flip($muted));
647 $container_guid = array_unique(array_filter($container_guid));
648 if (empty($container_guid)) {
653 $select->select(
'guid_one AS guid')
654 ->addSelect(
"GROUP_CONCAT(relationship SEPARATOR ',') AS methods")
655 ->where($select->compare(
'guid_two',
'in', $container_guid,
ELGG_VALUE_GUID))
657 ->groupBy(
'guid_one');
663 return $this->db->getData($select);
677 $prefix = self::RELATIONSHIP_PREFIX;
680 foreach ($methods as $method) {
681 $names[] =
"{$prefix}:{$method}";
684 $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