aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget/Messages.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-09-23 10:42:37 +0000
committerMario <mario@mariovavti.com>2021-09-23 10:42:37 +0000
commit989a4f3d49c4825a6826b9f28c36938b6a2979a9 (patch)
tree374c0f0eedf809acb75d7cb190f234a7408adacb /Zotlabs/Widget/Messages.php
parent2a2c4d3e9cf09f2ebe0bda68a8c761c23e802e95 (diff)
downloadvolse-hubzilla-989a4f3d49c4825a6826b9f28c36938b6a2979a9.tar.gz
volse-hubzilla-989a4f3d49c4825a6826b9f28c36938b6a2979a9.tar.bz2
volse-hubzilla-989a4f3d49c4825a6826b9f28c36938b6a2979a9.zip
add notices tab to HQ widget
Diffstat (limited to 'Zotlabs/Widget/Messages.php')
-rw-r--r--Zotlabs/Widget/Messages.php53
1 files changed, 52 insertions, 1 deletions
diff --git a/Zotlabs/Widget/Messages.php b/Zotlabs/Widget/Messages.php
index 21375b08f..99de57704 100644
--- a/Zotlabs/Widget/Messages.php
+++ b/Zotlabs/Widget/Messages.php
@@ -11,7 +11,7 @@ class Messages {
if (!local_channel())
return EMPTY_STR;
- $page = self::get_messages_page($options);
+ $page = self::get_messages_page([]);
$_SESSION['messages_loadtime'] = datetime_convert();
@@ -24,6 +24,7 @@ class Messages {
'messages_title' => t('Public and restricted messages'),
'direct_messages_title' => t('Direct messages'),
'starred_messages_title' => t('Starred messages'),
+ 'notice_messages_title' => t('Notices'),
'loading' => t('Loading'),
'empty' => t('No messages')
]
@@ -40,6 +41,10 @@ class Messages {
return;
}
+ if ($options['type'] == 'notification') {
+ return self::get_notices_page($options);
+ }
+
$channel = App::get_channel();
$item_normal = item_normal();
$entries = [];
@@ -181,4 +186,50 @@ class Messages {
return trim($recipients, ', ');
}
+ public static function get_notices_page($options) {
+
+ if (!local_channel())
+ return;
+
+ $limit = 30;
+
+ $offset = 0;
+ if ($options['offset']) {
+ $offset = intval($options['offset']);
+ }
+
+ $notices = q("SELECT * FROM notify WHERE uid = %d
+ ORDER BY created DESC LIMIT $limit OFFSET $offset",
+ intval(local_channel())
+ );
+
+ $i = 0;
+
+ foreach($notices as $notice) {
+
+ $summary = trim(strip_tags(bbcode($notice['msg'])));
+
+ if(strpos($summary, $notification['xname']) === 0) {
+ $summary = substr($summary, strlen($notice['xname']) + 1);
+ }
+
+ $entries[$i]['author_name'] = $notice['xname'];
+ $entries[$i]['author_addr'] = $notice['url'];
+ $entries[$i]['info'] = '';
+ $entries[$i]['created'] = datetime_convert('UTC', date_default_timezone_get(), $notice['created']);
+ $entries[$i]['summary'] = $summary;
+ $entries[$i]['b64mid'] = basename($notice['link']);
+ $entries[$i]['href'] = z_root() . '/hq/' . basename($notice['link']);
+ $entries[$i]['icon'] = '';
+
+ $i++;
+ }
+
+ $result = [
+ 'offset' => ((count($entries) < $limit) ? -1 : intval($offset + $limit)),
+ 'entries' => $entries
+ ];
+
+ return $result;
+ }
}