aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2019-12-01 14:21:08 +0100
committerMax Kostikov <max@kostikov.co>2019-12-01 14:21:08 +0100
commit042cc9696856a86ae37487a2db3efbd510d09150 (patch)
tree8ff79a199d6dde0b1ac297baa8ae8bcc66849d3b /Zotlabs
parentd177043c9f4032c2241aac7afedbd6e7b6c1e596 (diff)
downloadvolse-hubzilla-042cc9696856a86ae37487a2db3efbd510d09150.tar.gz
volse-hubzilla-042cc9696856a86ae37487a2db3efbd510d09150.tar.bz2
volse-hubzilla-042cc9696856a86ae37487a2db3efbd510d09150.zip
Add pinning processing module
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Module/Pin.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/Zotlabs/Module/Pin.php b/Zotlabs/Module/Pin.php
new file mode 100644
index 000000000..65bb61a76
--- /dev/null
+++ b/Zotlabs/Module/Pin.php
@@ -0,0 +1,50 @@
+<?php
+namespace Zotlabs\Module;
+
+/*
+ * Pinned post processing
+ */
+
+use App;
+
+class Pin extends \Zotlabs\Web\Controller {
+
+
+ function init() {
+
+ if(argc() !== 1)
+ http_status_exit(400, 'Bad request');
+
+ if(! local_channel())
+ http_status_exit(403, 'Forbidden');
+ }
+
+
+ function post() {
+
+ $item_id = intval($_POST['id']);
+
+ if ($item_id <= 0)
+ http_status_exit(404, 'Not found');
+
+ $channel = \App::get_channel();
+
+ $r = q("SELECT * FROM item WHERE id = %d AND id = parent AND uid = %d AND owner_xchan = '%s' AND item_private = 0 LIMIT 1",
+ $item_id,
+ intval($channel['channel_id']),
+ dbesc($channel['xchan_hash'])
+ );
+ if(!$r) {
+ notice(t('Unable to locate original post.'));
+ http_status_exit(404, 'Not found');
+ }
+ else {
+ // Currently allow only one pinned item for each type
+ $midb64 = 'b64.' . base64url_encode($r[0]['mid']);
+ $pinned = (in_array($midb64, get_pconfig($channel['channel_id'], 'pinned', $r[0]['item_type'], [])) ? [] : [ $midb64 ]);
+ set_pconfig($channel['channel_id'], 'pinned', $r[0]['item_type'], $pinned);
+
+ build_sync_packet($channel['channel_id'], [ 'config' ]);
+ }
+ }
+}