Skip to content

Commit

Permalink
Update OssnLikes.php
Browse files Browse the repository at this point in the history
  • Loading branch information
lianglee committed Jul 22, 2021
1 parent a630887 commit 6bcc654
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions components/OssnLikes/classes/OssnLikes.php
Expand Up @@ -27,21 +27,35 @@ public function Like($subject_id, $guid, $type = 'post', $reaction_type = 'like'
$reaction_type = 'like';
}
if($type == 'annotation') {
$annotation = new OssnAnnotation;
$annotation->annotation_id = $subject_id;
$annotation = $annotation->getAnnotationById();
if(empty($annotation->id)) {
$annotation = ossn_get_annotation($subject_id);
if(!$annotation) {
return false;
}
ossn_trigger_callback('like', 'before:created', array(
'type' => 'annotation',
'annotation' => $annotation,
));
}
if($type == 'post') {
$post = new OssnObject;
$post->object_guid = $subject_id;
$post = $post->getObjectById();
if(empty($post->time_created)) {
if($type == 'post' || $type == 'object') {
$object = ossn_get_object($subject_id);
if(!$object) {
return false;
}
ossn_trigger_callback('like', 'before:created', array(
'type' => 'object',
'object' => $object,
));
}
if($type == 'entity') {
$entity = ossn_get_entity($subject_id);
if(!$entity) {
return false;
}
ossn_trigger_callback('like', 'before:created', array(
'type' => 'entity',
'entity' => $entity,
));
}
if(!$this->isLiked($subject_id, $guid, $type)) {
$this->statement("INSERT INTO ossn_likes (`subject_id`, `guid`, `type`, `subtype`)
VALUES('{$subject_id}', '{$guid}', '{$type}', '{$reaction_type}');");
Expand Down

0 comments on commit 6bcc654

Please sign in to comment.