/** * Listen to the creation of an annotation, if Like check auto subscribe * * @param string $event the name of the event * @param string $type the type of the event * @param \ElggAnnotation $annotation the created annotation * * @return void */ public static function create($event, $type, $annotation) { if (!self::autoSubscribe()) { // auto subscribe isn't enabled return; } if (empty($annotation) || !$annotation instanceof \ElggAnnotation) { // not an annotation return; } if ($annotation->name !== 'likes') { // not likes return; } $entity = $annotation->getEntity(); if (empty($entity) || !$entity instanceof \ElggEntity) { return; } $user = $annotation->getOwnerEntity(); if (empty($user) || !$user instanceof \ElggUser) { return; } if (!content_subscriptions_can_subscribe($entity, $user->getGUID())) { // subscribing isn't allowed for this entity type/subtype return; } // auto subscribe to this entity content_subscriptions_autosubscribe($entity->getGUID(), $user->getGUID()); }
/** * Catch reply to discussion topic and generate notifications * * @todo this will be replaced in Elgg 1.9 and is a clone of object_notifications() * * @param string $event * @param string $type * @param ElggAnnotation $annotation * @return void */ function discussion_reply_notifications($event, $type, $annotation) { global $CONFIG, $NOTIFICATION_HANDLERS; if ($annotation->name !== 'group_topic_post') { return; } // Have we registered notifications for this type of entity? $object_type = 'object'; $object_subtype = 'groupforumtopic'; $topic = $annotation->getEntity(); if (!$topic) { return; } $poster = $annotation->getOwnerEntity(); if (!$poster) { return; } if (isset($CONFIG->register_objects[$object_type][$object_subtype])) { $subject = $CONFIG->register_objects[$object_type][$object_subtype]; $string = $subject . ": " . $topic->getURL(); // Get users interested in content from this person and notify them // (Person defined by container_guid so we can also subscribe to groups if we want) foreach ($NOTIFICATION_HANDLERS as $method => $foo) { $interested_users = elgg_get_entities_from_relationship(array('relationship' => 'notify' . $method, 'relationship_guid' => $topic->getContainerGUID(), 'inverse_relationship' => true, 'type' => 'user', 'limit' => 0)); if ($interested_users && is_array($interested_users)) { foreach ($interested_users as $user) { if ($user instanceof ElggUser && !$user->isBanned()) { if ($user->guid != $poster->guid && has_access_to_entity($topic, $user) && $topic->access_id != ACCESS_PRIVATE) { $body = elgg_trigger_plugin_hook('notify:annotation:message', $annotation->getSubtype(), array('annotation' => $annotation, 'to_entity' => $user, 'method' => $method), $string); if (empty($body) && $body !== false) { $body = $string; } if ($body !== false) { notify_user($user->guid, $topic->getContainerGUID(), $subject, $body, null, array($method)); } } } } } } } }
/** * Return the URL for a comment * * @param ElggAnnotation $comment The comment object * @return string * @access private */ function elgg_comment_url_handler(ElggAnnotation $comment) { $entity = $comment->getEntity(); if ($entity) { return $entity->getURL() . '#item-annotation-' . $comment->id; } }
/** * Update annotation event * * @param string $event "create"|"update" * @param string $type "annotation" * @param ElggAnnotation $annotation Annotation * @return void */ function elgg_solr_annotation_update($event, $type, $annotation) { $entity = $annotation->getEntity(); if ($GLOBALS['shutdown_flag']) { elgg_solr_add_update_entity(null, null, $entity); elgg_solr_index_annotation($annotation); } else { elgg_solr_defer_index_update($entity->guid); elgg_solr_defer_annotation_update($annotation->id); } }