diff options
author | zotlabs <mike@macgirvin.com> | 2020-03-12 17:55:35 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2020-03-12 17:55:35 -0700 |
commit | 8f5cb0c45a4aa2011933087f86333c60a77c3e0f (patch) | |
tree | b9c99fd39711509f7d2e2a459414d819622ac68d /Zotlabs/Lib/Activity.php | |
parent | 938d26ba3e9c6566d00f7393daa3e1b36f2e5479 (diff) | |
parent | 720d3dcedc96c7aaf6c4444c8b45acd46b8718b0 (diff) | |
download | volse-hubzilla-8f5cb0c45a4aa2011933087f86333c60a77c3e0f.tar.gz volse-hubzilla-8f5cb0c45a4aa2011933087f86333c60a77c3e0f.tar.bz2 volse-hubzilla-8f5cb0c45a4aa2011933087f86333c60a77c3e0f.zip |
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
Diffstat (limited to 'Zotlabs/Lib/Activity.php')
-rw-r--r-- | Zotlabs/Lib/Activity.php | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 0d8dab95c..02ec7614e 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1673,8 +1673,11 @@ class Activity { - static function update_poll($item,$mid,$content) { + static function update_poll($item,$post) { $multi = false; + $mid = $post['mid']; + $content = $post['title']; + if (! $item) { return false; } @@ -1683,6 +1686,31 @@ class Activity { if ($o && array_key_exists('anyOf',$o)) { $multi = true; } + + $r = q("select mid, title from item where parent_mid = '%s' and author_xchan = '%s'", + dbesc($item['mid']), + dbesc($post['author_xchan']) + ); + + // prevent any duplicate votes by same author for oneOf and duplicate votes with same author and same answer for anyOf + + if ($r) { + if ($multi) { + foreach ($r as $rv) { + if ($rv['title'] === $content && $rv['mid'] !== $mid) { + return false; + } + } + } + else { + foreach ($r as $rv) { + if ($rv['mid'] !== $mid) { + return false; + } + } + } + } + $answer_found = false; $found = false; if ($multi) { @@ -1691,7 +1719,7 @@ class Activity { $answer_found = true; if (is_array($o['anyOf'][$c]['replies'])) { foreach($o['anyOf'][$c]['replies'] as $reply) { - if(array_key_exists('id',$reply) && $reply['id'] === $mid) { + if(is_array($reply) && array_key_exists('id',$reply) && $reply['id'] === $mid) { $found = true; } } @@ -1710,7 +1738,7 @@ class Activity { $answer_found = true; if (is_array($o['oneOf'][$c]['replies'])) { foreach($o['oneOf'][$c]['replies'] as $reply) { - if(array_key_exists('id',$reply) && $reply['id'] === $mid) { + if(is_array($reply) && array_key_exists('id',$reply) && $reply['id'] === $mid) { $found = true; } } |