aboutsummaryrefslogtreecommitdiffstats
path: root/mod/like.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/like.php')
-rwxr-xr-xmod/like.php75
1 files changed, 48 insertions, 27 deletions
diff --git a/mod/like.php b/mod/like.php
index 63524823b..6e9df7ede 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -117,8 +117,7 @@ function like_content(&$a) {
}
elseif($obj_type == 'thing') {
- $r = q("select * from obj left join term on obj_obj = term_hash where term_hash != ''
- and obj_type = %d and term_hash = '%s' limit 1",
+ $r = q("select * from obj where obj_type = %d and obj_obj = '%s' limit 1",
intval(TERM_OBJ_THING),
dbesc(argv(2))
);
@@ -146,18 +145,18 @@ function like_content(&$a) {
$links = array();
$links[] = array('rel' => 'alternate', 'type' => 'text/html',
- 'href' => z_root() . '/thing/' . $r[0]['term_hash']);
+ 'href' => z_root() . '/thing/' . $r[0]['obj_obj']);
if($r[0]['imgurl'])
- $links[] = array('rel' => 'photo', 'href' => $r[0]['imgurl']);
+ $links[] = array('rel' => 'photo', 'href' => $r[0]['obj_imgurl']);
$target = json_encode(array(
'type' => $tgttype,
- 'title' => $r[0]['term'],
- 'id' => z_root() . '/thing/' . $r[0]['term_hash'],
+ 'title' => $r[0]['obj_term'],
+ 'id' => z_root() . '/thing/' . $r[0]['obj_obj'],
'link' => $links
));
- $plink = '[zrl=' . z_root() . '/thing/' . $r[0]['term_hash'] . ']' . $r[0]['term'] . '[/zrl]';
+ $plink = '[zrl=' . z_root() . '/thing/' . $r[0]['obj_obj'] . ']' . $r[0]['obj_term'] . '[/zrl]';
}
@@ -226,10 +225,17 @@ function like_content(&$a) {
q("delete from likes where id = %d limit 1",
intval($z[0]['id'])
);
- drop_item($z[0]['iid'],false);
- if($interactive) {
- notice( t('Previous action reversed.') . EOL);
- return $o;
+ if($z[0]['i_mid']) {
+ $r = q("select id from item where mid = '%s' and uid = %d limit 1",
+ dbesc($z[0]['i_mid']),
+ intval($ch[0]['channel_id'])
+ );
+ if($r)
+ drop_item($r[0]['id'],false);
+ if($interactive) {
+ notice( t('Previous action reversed.') . EOL);
+ return $o;
+ }
}
killme();
}
@@ -244,9 +250,10 @@ function like_content(&$a) {
// get the item. Allow linked photos (which are normally hidden) to be liked
- $r = q("SELECT * FROM item WHERE id = %d and (item_restrict = 0 or item_restrict = %d) LIMIT 1",
- intval($item_id),
- intval(ITEM_HIDDEN)
+ $r = q("SELECT * FROM item WHERE id = %d
+ and item_type = 0 and item_deleted = 0 and item_unpublished = 0
+ and item_delayed = 0 and item_pending_remove = 0 and item_blocked = 0 LIMIT 1",
+ intval($item_id)
);
if(! $item_id || (! $r)) {
@@ -306,7 +313,9 @@ function like_content(&$a) {
$multi_undo = 1;
}
- $r = q("SELECT id, parent, uid, verb FROM item WHERE verb in ( $verbs ) AND item_restrict = 0
+ $item_normal = item_normal();
+
+ $r = q("SELECT id, parent, uid, verb FROM item WHERE verb in ( $verbs ) $item_normal
AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') and uid = %d ",
dbesc($observer['xchan_hash']),
intval($item_id),
@@ -341,9 +350,12 @@ function like_content(&$a) {
$mid = item_message_id();
- if($extended_like) {
- $item_flags = ITEM_THREAD_TOP|ITEM_ORIGIN|ITEM_WALL;
+ $arr = array();
+ if($extended_like) {
+ $arr['item_thread_top'] = 1;
+ $arr['item_origin'] = 1;
+ $arr['item_wall'] = 1;
}
else {
$post_type = (($item['resource_type'] === 'photo') ? t('photo') : t('status'));
@@ -375,18 +387,19 @@ function like_content(&$a) {
),
));
- if(! ($item['item_flags'] & ITEM_THREAD_TOP))
+ if(! intval($item['item_thread_top']))
$post_type = 'comment';
- $item_flags = ITEM_ORIGIN | ITEM_NOTSHOWN;
- if($item['item_flags'] & ITEM_WALL)
- $item_flags |= ITEM_WALL;
+ $arr['item_origin'] = 1;
+ $arr['item_notshown'] = 1;
+
+ if(intval($item['item_wall']))
+ $arr['item_wall'] = 1;
// if this was a linked photo and was hidden, unhide it.
- if($item['item_restrict'] & ITEM_HIDDEN) {
- $r = q("update item set item_restrict = (item_restrict ^ %d) where id = %d",
- intval(ITEM_HIDDEN),
+ if(intval($item['item_hidden'])) {
+ $r = q("update item set item_hidden = 0 where id = %d",
intval($item['id'])
);
}
@@ -414,7 +427,6 @@ function like_content(&$a) {
killme();
- $arr = array();
if($extended_like) {
$ulink = '[zrl=' . $ch[0]['xchan_url'] . ']' . $ch[0]['xchan_name'] . '[/zrl]';
@@ -440,6 +452,7 @@ function like_content(&$a) {
$arr['aid'] = (($extended_like) ? $ch[0]['channel_account_id'] : $owner_aid);
$arr['uid'] = $owner_uid;
$arr['item_flags'] = $item_flags;
+ $arr['item_wall'] = $item_wall;
$arr['parent_mid'] = (($extended_like) ? $mid : $item['mid']);
$arr['owner_xchan'] = (($extended_like) ? $ch[0]['xchan_hash'] : $thread_owner['xchan_hash']);
$arr['author_xchan'] = $observer['xchan_hash'];
@@ -483,9 +496,17 @@ function like_content(&$a) {
intval($post_id),
dbesc($mid),
dbesc($activity),
- dbesc(($tgttype)?$tgttype:$objtype),
+ dbesc(($tgttype)? $tgttype : $objtype),
dbesc($obj_id),
- dbesc(json_encode(($target)?$target:$object))
+ dbesc(($target) ? $target : $object)
+ );
+ $r = q("select * from likes where liker = '%s' and likee = '%s' and i_mid = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s' ",
+ dbesc($observer['xchan_hash']),
+ dbesc($ch[0]['channel_hash']),
+ dbesc($mid),
+ dbesc($activity),
+ dbesc(($tgttype)? $tgttype : $objtype),
+ dbesc($obj_id)
);
$r = q("select * from likes where liker = '%s' and likee = '%s' and i_mid = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s' ",
dbesc($observer['xchan_hash']),