diff options
author | zotlabs <mike@macgirvin.com> | 2018-02-05 15:58:28 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2018-02-05 15:58:28 -0800 |
commit | b41c5f349715abc6ca7db563e3938336bc75974e (patch) | |
tree | 31a1ee5a74227c30239bb9d2a10341bbacb8ecec /Zotlabs/Module/Like.php | |
parent | 05de59d4ad174cb106c3a5b5890732af51730384 (diff) | |
parent | 930e1fdbdc798868760f8a4e03f32fc3f42e8bc9 (diff) | |
download | volse-hubzilla-b41c5f349715abc6ca7db563e3938336bc75974e.tar.gz volse-hubzilla-b41c5f349715abc6ca7db563e3938336bc75974e.tar.bz2 volse-hubzilla-b41c5f349715abc6ca7db563e3938336bc75974e.zip |
Merge branch 'master' into z6
Diffstat (limited to 'Zotlabs/Module/Like.php')
-rw-r--r-- | Zotlabs/Module/Like.php | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index b07824363..6d9fde17c 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -9,9 +9,41 @@ require_once('include/items.php'); class Like extends \Zotlabs\Web\Controller { - function get() { + + + private function reaction_to_activity($reaction) { + + $acts = [ + 'like' => ACTIVITY_LIKE , + 'dislike' => ACTIVITY_DISLIKE , + 'agree' => ACTIVITY_AGREE , + 'disagree' => ACTIVITY_DISAGREE , + 'abstain' => ACTIVITY_ABSTAIN , + 'attendyes' => ACTIVITY_ATTEND , + 'attendno' => ACTIVITY_ATTENDNO , + 'attendmaybe' => ACTIVITY_ATTENDMAYBE + ]; + + // unlike (etc.) reactions are an undo of positive reactions, rather than a negative action. + // The activity is the same in undo actions and will have the same activity mapping + + if(substr($reaction,0,2) === 'un') { + $reaction = substr($reaction,2); + } + + if(array_key_exists($reaction,$acts)) { + return $acts[$reaction]; + } + + return EMPTY_STR; + + } + + + + public function get() { - $o = ''; + $o = EMPTY_STR; $sys_channel = get_sys_channel(); $sys_channel_id = (($sys_channel) ? $sys_channel['channel_id'] : 0); @@ -35,48 +67,17 @@ class Like extends \Zotlabs\Web\Controller { if(! $verb) $verb = 'like'; - switch($verb) { - case 'like': - case 'unlike': - $activity = ACTIVITY_LIKE; - break; - case 'dislike': - case 'undislike': - $activity = ACTIVITY_DISLIKE; - break; - case 'agree': - case 'unagree': - $activity = ACTIVITY_AGREE; - break; - case 'disagree': - case 'undisagree': - $activity = ACTIVITY_DISAGREE; - break; - case 'abstain': - 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; + $activity = $this->reaction_to_activity($verb); + + if(! $activity) { + return EMPTY_STR; } + $extended_like = false; $object = $target = null; - $post_type = ''; - $objtype = ''; + $post_type = EMPTY_STR; + $objtype = EMPTY_STR; if(argc() == 3) { |