From 81e7b47b76e6cc72995e910190e4164d28ec5664 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Feb 2015 00:11:37 -0800 Subject: more progress on event confirmations --- mod/like.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'mod/like.php') diff --git a/mod/like.php b/mod/like.php index b3afd910f..7c328367b 100755 --- a/mod/like.php +++ b/mod/like.php @@ -49,6 +49,18 @@ function like_content(&$a) { case 'unabstain': $activity = ACTIVITY_ABSTAIN; break; + case 'attendyes': + case 'unattendyes': + $activity = ACTIVITY_ATTEND; + break; + case 'attendno': + case 'unattendno': + $activity = ACTIVITY_ATTENDNO; + break; + case 'attendmaybe': + case 'unattendmaybe': + $activity = ACTIVITY_ATTENDMAYBE; + break; default: return; break; @@ -300,6 +312,8 @@ function like_content(&$a) { } else { $post_type = (($item['resource_type'] === 'photo') ? t('photo') : t('status')); + if($item['resource_type'] === 'event') + $post_type = t('event'); $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $item['plink'])); $objtype = (($item['resource_type'] === 'photo') ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); @@ -354,8 +368,12 @@ function like_content(&$a) { $bodyverb = t('%1$s doesn\'t agree with %2$s\'s %3$s'); if($verb === 'abstain') $bodyverb = t('%1$s abstains from a decision on %2$s\'s %3$s'); - - + if($verb === 'attendyes') + $bodyverb = t('%1$s is attending %2$s\'s %3$s'); + if($verb === 'attendno') + $bodyverb = t('%1$s is not attending %2$s\'s %3$s'); + if($verb === 'attendmaybe') + $bodyverb = t('%1$s may attend %2$s\'s %3$s'); if(! isset($bodyverb)) killme(); -- cgit v1.2.3 From 268691ffb460e7d0a53dec858ee9658e20660755 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Feb 2015 01:05:49 -0800 Subject: correct the object type if it isn't stored/linked to an item yet --- mod/like.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/like.php') diff --git a/mod/like.php b/mod/like.php index 7c328367b..725551d6d 100755 --- a/mod/like.php +++ b/mod/like.php @@ -312,7 +312,7 @@ function like_content(&$a) { } else { $post_type = (($item['resource_type'] === 'photo') ? t('photo') : t('status')); - if($item['resource_type'] === 'event') + if($item['obj_type'] === ACTIVITY_OBJ_EVENT) $post_type = t('event'); $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $item['plink'])); -- cgit v1.2.3 From 79da33dafdac1427ac07b4414a5da5f9f3a2b03d Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Feb 2015 17:49:46 -0800 Subject: improvements in duplicate like detection, especially w/r/t event participation --- mod/like.php | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'mod/like.php') 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(); -- cgit v1.2.3 From c62d605608ea3cfa0430e007fe6bc7df5fa0d25f Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 11 Feb 2015 16:11:21 -0800 Subject: well that was certainly fun. And the reason why likes and other acitivity deletions weren't propagating. Hopefully this is the last reason and there aren't more lurking further down the chain. --- mod/like.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/like.php') diff --git a/mod/like.php b/mod/like.php index 79c746825..47251935a 100755 --- a/mod/like.php +++ b/mod/like.php @@ -316,7 +316,7 @@ function like_content(&$a) { // already liked it. Drop that item. require_once('include/items.php'); foreach($r as $rr) { - drop_item($rr['id'],false,DROPITEM_PHASE1); + drop_item($rr['id'],true,DROPITEM_PHASE1); } if($interactive) return; -- cgit v1.2.3 From 1b17b0193ec08936b5485216ba6bbe9a46ede187 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 21 Mar 2015 17:14:12 -0700 Subject: fix multiple vote issues --- mod/like.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mod/like.php') diff --git a/mod/like.php b/mod/like.php index 47251935a..dc4531fbb 100755 --- a/mod/like.php +++ b/mod/like.php @@ -303,7 +303,6 @@ function like_content(&$a) { $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']), @@ -316,10 +315,12 @@ function like_content(&$a) { // already liked it. Drop that item. require_once('include/items.php'); foreach($r as $rr) { - drop_item($rr['id'],true,DROPITEM_PHASE1); + drop_item($rr['id'],false,DROPITEM_PHASE1); } + if($interactive) return; + if(! $multi_undo) killme(); } -- cgit v1.2.3 From 6631540d20068d3c4ee221518e8f430507662e27 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Mar 2015 12:55:13 -0700 Subject: provide visual feedback when deleting a like by liking it again. --- mod/like.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'mod/like.php') diff --git a/mod/like.php b/mod/like.php index dc4531fbb..cfd848636 100755 --- a/mod/like.php +++ b/mod/like.php @@ -303,7 +303,7 @@ function like_content(&$a) { $multi_undo = 1; } - $r = q("SELECT id FROM item WHERE verb in ( $verbs ) AND item_restrict = 0 + $r = q("SELECT id, parent, uid 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), @@ -316,6 +316,12 @@ function like_content(&$a) { require_once('include/items.php'); foreach($r as $rr) { drop_item($rr['id'],false,DROPITEM_PHASE1); + // set the changed timestamp on the parent so we'll see the update without a page reload + $z = q("update item set changed = '%s' where id = %d and uid = %d", + dbesc(datetime_convert()), + intval($rr['parent']), + intval($rr['uid']) + ); } if($interactive) -- cgit v1.2.3 From f5f194c92bf0992b3a24e7b62cf6f9556a6335c4 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Mar 2015 14:55:41 -0700 Subject: allow complete undo of a vote, not just a change of vote --- mod/like.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'mod/like.php') diff --git a/mod/like.php b/mod/like.php index cfd848636..d3b6f3ecf 100755 --- a/mod/like.php +++ b/mod/like.php @@ -303,7 +303,7 @@ function like_content(&$a) { $multi_undo = 1; } - $r = q("SELECT id, parent, uid FROM item WHERE verb in ( $verbs ) AND item_restrict = 0 + $r = q("SELECT id, parent, uid, verb 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), @@ -322,6 +322,10 @@ function like_content(&$a) { intval($rr['parent']), intval($rr['uid']) ); + // Prior activity was a duplicate of the one we're submitting, just undo it; + // don't fall through and create another + if(activity_match($rr['verb'],$activity)) + $multi_undo = false; } if($interactive) -- cgit v1.2.3