diff options
author | Mario <mario@mariovavti.com> | 2025-05-15 18:39:05 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2025-05-15 18:39:05 +0000 |
commit | 757237cbb4815f340df04d6bdb9af31bb892f263 (patch) | |
tree | c0e24b80a4234ddb22e9ddb08380ec9d7c39186e | |
parent | 869b047fde97fe4e9605177680768c584ad0a7c3 (diff) | |
download | volse-hubzilla-757237cbb4815f340df04d6bdb9af31bb892f263.tar.gz volse-hubzilla-757237cbb4815f340df04d6bdb9af31bb892f263.tar.bz2 volse-hubzilla-757237cbb4815f340df04d6bdb9af31bb892f263.zip |
Revert "make sure sql_extra is prepared for the c table"
This reverts commit 869b047fde97fe4e9605177680768c584ad0a7c3.
-rw-r--r-- | Zotlabs/Module/Pin.php | 5 | ||||
-rw-r--r-- | Zotlabs/Widget/Pinned.php | 95 | ||||
-rw-r--r-- | include/items.php | 4 | ||||
-rw-r--r-- | view/tpl/pinned_item.tpl | 6 |
4 files changed, 83 insertions, 27 deletions
diff --git a/Zotlabs/Module/Pin.php b/Zotlabs/Module/Pin.php index 14a45c10d..de3c75622 100644 --- a/Zotlabs/Module/Pin.php +++ b/Zotlabs/Module/Pin.php @@ -29,9 +29,8 @@ class Pin extends \Zotlabs\Web\Controller { if(! $observer) http_status_exit(403, 'Forbidden'); - $r = q("SELECT * FROM item WHERE id = %d AND uid = %d AND id = parent AND item_private = 0 LIMIT 1", - intval($item_id), - intval(local_channel()) + $r = q("SELECT * FROM item WHERE id = %d AND id = parent AND item_private = 0 LIMIT 1", + $item_id ); if(! $r) { notice(t('Unable to locate original post.')); diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index 9daf396b8..be6b98434 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -67,19 +67,19 @@ class Pinned { $attend = null; $canvote = false; - $response_verbs[] = 'like'; - - if(feature_enabled(\App::$profile['profile_uid'],'dislike')) { - $response_verbs[] = 'dislike'; - } - - $response_verbs[] = 'announce'; - - if ($item['obj_type'] === 'Question') { - $response_verbs[] = 'answer'; + $conv_responses = []; + + if(in_array($item['obj_type'], ['Event', ACTIVITY_OBJ_EVENT])) { + $conv_responses['attendyes'] = [ 'title' => t('Attending','title') ]; + $conv_responses['attendno'] = [ 'title' => t('Not attending','title') ]; + $conv_responses['attendmaybe'] = [ 'title' => t('Might attend','title') ]; + if($commentable && $observer) { + $attend = [ t('I will attend'), t('I will not attend'), t('I might attend') ]; + $isevent = true; + } } - $responses = get_responses($response_verbs, $item); + $this->activity($item, $conv_responses); $verified = (intval($item['item_verified']) ? t('Message signature validated') : ''); $forged = ((! intval($item['item_verified']) && $item['sig']) ? t('Message signature incorrect') : ''); @@ -110,9 +110,6 @@ class Pinned { 'text' => strip_tags($body['html']), 'id' => $item['id'], 'mids' => json_encode([ $midb64 ]), - 'mid' => $item['uuid'], - 'rawmid' => $item['mid'], - 'parent' => $item['parent'], 'isevent' => $isevent, 'attend' => $attend, 'conlabels' => [], @@ -154,7 +151,7 @@ class Pinned { 'hide' => (! $is_new && isset($observer['xchan_hash']) && $observer['xchan_hash'] != $owner['xchan_hash'] ? t("Don't show") : ''), // end toolbar buttons 'modal_dismiss' => t('Close'), - 'responses' => $responses, + 'responses' => $conv_responses, 'author_id' => (($author['xchan_addr']) ? $author['xchan_addr'] : $author['xchan_url']) ]; @@ -196,14 +193,74 @@ class Pinned { if(empty($mids_list)) return []; - - $r = q("SELECT parent FROM item WHERE uuid IN ( '%s' ) AND uid = %d AND id = parent AND item_private = 0", + $r = q("SELECT * FROM item WHERE uuid IN ( '%s' ) AND uid = %d AND id = parent AND item_private = 0 ORDER BY created DESC", dbesc(implode(",", $mids_list)), intval($this->uid) ); + if($r) + return $r; - return items_by_parent_ids($r[0]['parent'], blog_mode: true); - + return []; } + + /* + * @brief List activities on item + * + * @param array $item + * @param array $conv_responses + * @return array + * + */ + private function activity($item, &$conv_responses) { + + foreach(array_keys($conv_responses) as $verb) { + $verb_sql = ''; + + switch($verb) { + case 'like': + $verb_sql = " AND verb IN ('Like', '" . ACTIVITY_LIKE . "') "; + break; + case 'dislike': + $verb_sql = " AND verb IN ('Dislike', '" . ACTIVITY_DISLIKE . "') "; + break; + case 'attendyes': + $verb_sql = " AND verb IN ('Accept', '" . ACTIVITY_ATTEND . "') "; + break; + case 'attendno': + $verb_sql = " AND verb IN ('Reject', '" . ACTIVITY_ATTENDNO . "') "; + break; + case 'attendmaybe': + $verb_sql = " AND verb IN ('TentativeAccept', '" . ACTIVITY_ATTENDMAYBE . "') "; + break; + default: + break; + } + + $r = q("SELECT * FROM item WHERE parent = %d AND id <> parent $verb_sql AND item_deleted = 0", + intval($item['id']) + ); + if(! $r) { + unset($conv_responses[$verb]); + continue; + } + + $conv_responses[$verb]['count'] = count($r); + $conv_responses[$verb]['button'] = get_response_button_text($verb, $conv_responses[$verb]['count']); + + foreach($r as $rr) { + + $author = q("SELECT * FROM xchan WHERE xchan_hash = '%s' LIMIT 1", + dbesc($rr['author_xchan']) + ); + $name = (($author && $author[0]['xchan_name']) ? $author[0]['xchan_name'] : t('Unknown')); + $conv_responses[$verb]['list'][] = (($rr['author_xchan'] && $author && $author[0]['xchan_photo_s']) ? + '<a class="dropdown-item" href="' . chanlink_hash($rr['author_xchan']) . '">' . '<img class="menu-img-1" src="' . zid($author[0]['xchan_photo_s']) . '" alt="' . urlencode($name) . '" /> ' . $name . '</a>' : + '<a class="dropdown-item" href="#" class="disabled">' . $name . '</a>' + ); + } + } + + $conv_responses['count'] = count($conv_responses); + } } diff --git a/include/items.php b/include/items.php index 55381af6d..d71fccf80 100644 --- a/include/items.php +++ b/include/items.php @@ -5469,8 +5469,6 @@ function items_by_parent_ids(string $ids, string $thr_parents = '', string $sql_ $thr_parent_uuid_sql_join = "LEFT JOIN item tp ON item.thr_parent = tp.mid AND item.uid = tp.uid"; } - $sql_extra_c = str_replace('item.', 'c.', $sql_extra); - $ret = q( "SELECT item.*, $thr_parent_uuid_sql @@ -5481,7 +5479,7 @@ function items_by_parent_ids(string $ids, string $thr_parents = '', string $sql_ AND c.item_thread_top = 0 AND c.thr_parent = item.mid $item_normal_c - $sql_extra_c + $sql_extra $thr_parent_uuid_sql_join WHERE $blog_mode_sql in (%s) AND ( diff --git a/view/tpl/pinned_item.tpl b/view/tpl/pinned_item.tpl index b5b5c931e..927b5ef80 100644 --- a/view/tpl/pinned_item.tpl +++ b/view/tpl/pinned_item.tpl @@ -100,11 +100,13 @@ </div> {{/if}} <div class="p-2 wall-item-tools d-flex justify-content-between"> - <div class="wall-item-tools-left hstack gap-1" id="pinned-item-tools-left-{{$id}}"> + <div class="wall-item-tools-left hstack gap-1" id="wall-item-tools-left-{{$item.id}}"> {{foreach $responses as $verb=>$response}} - <button type="button" title="{{$response.count}} {{$response.button.label}}" class="btn btn-sm btn-link{{if !$observer_activity.$verb}} link-secondary{{/if}} wall-item-{{$response.button.class}}" onclick="request({{$id}}, '{{$rawmid}}', '{{$verb}}', {{$parent}}, '{{$mid}}'); return false;" id="pinned-item-{{$verb}}-{{$id}}"> + {{if !($verb == 'comment' && (($toplevel && !$blog_mode) || $response.count == 0))}} + <button type="button" title="{{$response.count}} {{$response.button.label}}" class="btn btn-sm btn-link{{if !$observer_activity.$verb}} link-secondary{{/if}} wall-item-{{$response.button.class}}" onclick="request({{$item.id}}, '{{$item.rawmid}}', '{{$verb}}', {{$item.parent}}, '{{$item.mid}}'); return false;" id="pinned-item-{{$verb}}-{{$id}}"> <i class="bi bi-{{$response.button.icon}} generic-icons"></i>{{if $response.count}}<span style="display: inline-block; margin-top: -.25rem;" class="align-top">{{$response.count}}</span>{{/if}} </button> + {{/if}} {{/foreach}} <div class=""> <div id="like-rotator-{{$id}}" class="spinner-wrapper"> |