aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget/Pinned.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-09-04 08:18:41 +0000
committerMario <mario@mariovavti.com>2021-09-04 08:18:41 +0000
commit529824d010cf88c409d5ce894b72060caccae580 (patch)
tree034260ebb84edef72f87a450ab3915e4726e3368 /Zotlabs/Widget/Pinned.php
parentc47e21f3a74e4290bd206c1f7edb377e809d7e42 (diff)
downloadvolse-hubzilla-529824d010cf88c409d5ce894b72060caccae580.tar.gz
volse-hubzilla-529824d010cf88c409d5ce894b72060caccae580.tar.bz2
volse-hubzilla-529824d010cf88c409d5ce894b72060caccae580.zip
more unpack_link_id()
Diffstat (limited to 'Zotlabs/Widget/Pinned.php')
-rw-r--r--Zotlabs/Widget/Pinned.php58
1 files changed, 29 insertions, 29 deletions
diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php
index cad139a91..66d06bbd3 100644
--- a/Zotlabs/Widget/Pinned.php
+++ b/Zotlabs/Widget/Pinned.php
@@ -40,15 +40,15 @@ class Pinned {
$observer = \App::get_observer();
foreach($items as $item) {
-
- $midb64 = 'b64.' . base64url_encode($item['mid']);
-
+
+ $midb64 = gen_link_id($item['mid']);
+
if(isset($observer['xchan_hash']) && in_array($observer['xchan_hash'], get_pconfig($item['uid'], 'pinned_hide', $midb64, [])))
continue;
-
+
$author = channelx_by_hash($item['author_xchan']);
$owner = channelx_by_hash($item['owner_xchan']);
-
+
$profile_avatar = $author['xchan_photo_m'];
$profile_link = chanlink_hash($item['author_xchan']);
$profile_name = $author['xchan_name'];
@@ -71,7 +71,7 @@ class Pinned {
$isevent = true;
}
}
-
+
$consensus = (intval($item['item_consensus']) ? true : false);
if($consensus) {
$conv_responses['agree'] = [ 'title' => t('Agree','title') ];
@@ -87,7 +87,7 @@ class Pinned {
$verified = (intval($item['item_verified']) ? t('Message signature validated') : '');
$forged = ((! intval($item['item_verified']) && $item['sig']) ? t('Message signature incorrect') : '');
-
+
$shareable = ((local_channel() && \App::$profile_uid == local_channel() && $item['item_private'] != 1) ? true : false);
if ($shareable) {
// This actually turns out not to be possible in some protocol stacks without opening up hundreds of new issues.
@@ -102,9 +102,9 @@ class Pinned {
$is_new = boolval(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0);
$body = prepare_body($item,true);
-
+
$str = [
- 'item_type' => intval($item['item_type']),
+ 'item_type' => intval($item['item_type']),
'body' => $body['html'],
'tags' => $body['tags'],
'categories' => $body['categories'],
@@ -115,7 +115,7 @@ class Pinned {
'id' => $item['id'],
'mids' => json_encode([ $midb64 ]),
'isevent' => $isevent,
- 'attend' => $attend,
+ 'attend' => $attend,
'consensus' => $consensus,
'conlabels' => ($canvote ? $conlabels : []),
'canvote' => $canvote,
@@ -158,55 +158,55 @@ class Pinned {
'modal_dismiss' => t('Close'),
'responses' => $conv_responses
];
-
- $tpl = get_markup_template('pinned_item.tpl');
+
+ $tpl = get_markup_template('pinned_item.tpl');
$ret['html'] .= replace_macros($tpl, $str);
}
return $ret;
}
-
+
/*
* @brief List pinned items depend on type
*
* @param $types
* @return array of pinned items
*
- */
+ */
private function list($types) {
if(empty($types) || (! is_array($types)))
return [];
-
+
$item_types = array_intersect($this->allowed_types, $types);
if(empty($item_types))
return [];
-
+
$mids_list = [];
-
+
foreach($item_types as $type) {
-
+
$mids = get_pconfig($this->uid, 'pinned', $type, []);
foreach($mids as $mid) {
- if(! empty($mid) && strpos($mid,'b64.') === 0)
- $mids_list[] = @base64url_decode(substr($mid,4));
+ if(!empty($mid))
+ $mids_list[] = unpack_link_id($mid);
}
}
if(empty($mids_list))
return [];
-
+
$r = q("SELECT * FROM item WHERE mid 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 [];
}
-
+
/*
* @brief List activities on item
*
@@ -214,7 +214,7 @@ class Pinned {
* @param array $conv_responses
* @return array
*
- */
+ */
private function activity($item, &$conv_responses) {
foreach(array_keys($conv_responses) as $verb) {
@@ -256,23 +256,23 @@ class Pinned {
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="' . 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);
}
}