aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-02-10 17:49:46 -0800
committerfriendica <info@friendica.com>2015-02-10 17:49:46 -0800
commit79da33dafdac1427ac07b4414a5da5f9f3a2b03d (patch)
tree1934a32ffc2b7a3d1ada1afe4499e4e43561c370
parent9a773b45e498330cba20717d3f2d5c2e1a3683b0 (diff)
downloadvolse-hubzilla-79da33dafdac1427ac07b4414a5da5f9f3a2b03d.tar.gz
volse-hubzilla-79da33dafdac1427ac07b4414a5da5f9f3a2b03d.tar.bz2
volse-hubzilla-79da33dafdac1427ac07b4414a5da5f9f3a2b03d.zip
improvements in duplicate like detection, especially w/r/t event participation
-rw-r--r--include/Contact.php2
-rwxr-xr-xmod/like.php35
2 files changed, 29 insertions, 8 deletions
diff --git a/include/Contact.php b/include/Contact.php
index de3a75bb7..9490fd2da 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -374,7 +374,7 @@ function mark_orphan_hubsxchans() {
if($dirmode == DIRECTORY_MODE_NORMAL)
return;
- $r = q("update hubloc set hubloc_status = (hubloc_status | %d) where not (hubloc_status & %d)>0
+ $r = q("update hubloc set hubloc_status = (hubloc_status | %d) where (hubloc_status & %d) = 0
and hubloc_network = 'zot' and hubloc_connected < %s - interval %s",
intval(HUBLOC_OFFLINE),
intval(HUBLOC_OFFLINE),
diff --git a/mod/like.php b/mod/like.php
index 725551d6d..79c746825 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -287,21 +287,42 @@ function like_content(&$a) {
else
killme();
- $r = q("SELECT id FROM item WHERE verb = '%s' AND item_restrict = 0
- AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') LIMIT 1",
- dbesc($activity),
+
+ $verbs = " '".dbesc($activity)."' ";
+ $multi_undo = 0;
+
+ // event participation and consensus items are essentially radio toggles. If you make a subsequent choice,
+ // we need to eradicate your first choice.
+
+ if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
+ $verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
+ $multi_undo = 1;
+ }
+ if($activity === ACTIVITY_AGREE || $activity === ACTIVITY_DISAGREE || $activity === ACTIVITY_ABSTAIN) {
+ $verbs = " '" . dbesc(ACTIVITY_AGREE) . "','" . dbesc(ACTIVITY_DISAGREE) . "','" . dbesc(ACTIVITY_ABSTAIN) . "' ";
+ $multi_undo = 1;
+ }
+
+
+ $r = q("SELECT id FROM item WHERE verb in ( $verbs ) AND item_restrict = 0
+ AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') and uid = %d ",
dbesc($observer['xchan_hash']),
intval($item_id),
- dbesc($item['mid'])
+ dbesc($item['mid']),
+ intval($owner_uid)
);
if($r) {
// already liked it. Drop that item.
require_once('include/items.php');
- drop_item($r[0]['id'],false,DROPITEM_PHASE1);
- return;
+ foreach($r as $rr) {
+ drop_item($rr['id'],false,DROPITEM_PHASE1);
+ }
+ if($interactive)
+ return;
+ if(! $multi_undo)
+ killme();
}
-
}
$mid = item_message_id();