53 $subscriptions = array();
55 if (!$this->methods) {
56 return $subscriptions;
61 return $subscriptions;
64 $prefixLength = strlen(self::RELATIONSHIP_PREFIX);
66 foreach ($records as $record) {
67 $deliveryMethods = explode(
',', $record->methods);
68 $subscriptions[$record->guid] = substr_replace($deliveryMethods,
'', 0, $prefixLength);
71 $params = array(
'event' => $event);
89 $subscriptions = array();
91 if (!$this->methods) {
92 return $subscriptions;
95 $prefixLength = strlen(self::RELATIONSHIP_PREFIX);
97 foreach ($records as $record) {
98 $deliveryMethods = explode(
',', $record->methods);
99 $subscriptions[$record->guid] = substr_replace($deliveryMethods,
'', 0, $prefixLength);
102 return $subscriptions;
116 if (!in_array(
$method, $this->methods)) {
119 $prefix = self::RELATIONSHIP_PREFIX;
132 $prefix = self::RELATIONSHIP_PREFIX;
147 $container_guid = $this->db->sanitizeInt($container_guid);
154 array_walk($rels, array($this->db,
'sanitizeString'));
155 $methods_string =
"'" . implode(
"','", $rels) .
"'";
158 $query =
"SELECT guid_one AS guid, GROUP_CONCAT(relationship SEPARATOR ',') AS methods 159 FROM {$db_prefix}entity_relationships 160 WHERE guid_two = $container_guid AND 161 relationship IN ($methods_string) GROUP BY guid_one";
162 return $this->db->getData($query);
171 $prefix = self::RELATIONSHIP_PREFIX;
173 foreach ($this->methods as
$method) {
174 $names[] =
"$prefix$method";
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
remove_entity_relationship($guid_one, $relationship, $guid_two)
Delete a relationship between two entities.
removeSubscription($userGuid, $method, $targetGuid)
Unsubscribe a user to notifications about a target entity.
addSubscription($userGuid, $method, $targetGuid)
Subscribe a user to notifications about a target entity.
getSubscriptionRecords($container_guid)
Get subscription records from the database.
getMethodRelationships()
Get the relationship names for notifications.
getSubscriptions(Elgg_Notifications_Event $event)
Get the subscriptions for this notification event.
getObject()
Get the object of the event.
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Trigger a Plugin Hook and run all handler callbacks registered to that hook:type. ...
getSubscriptionsForContainer($container_guid)
Get the subscriptions for the content created inside this container.
const RELATIONSHIP_PREFIX
Elgg has historically stored subscriptions as relationships with the prefix 'notify'.
if(!$num_display) $db_prefix
__construct(Elgg_Database $db, array $methods=array())
Constructor.