aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget/Conversations.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-15 20:56:12 -0700
committerMario Vavti <mario@mariovavti.com>2017-03-29 11:50:52 +0200
commit6e101e458268c0f9b7bf461cea3c31c37b5e3791 (patch)
tree2a641a76607431a2661b0d3b6c46babbd34b6c0d /Zotlabs/Widget/Conversations.php
parentf60309efa12be3b8d4f5b2c565ebdf7f051a987d (diff)
downloadvolse-hubzilla-6e101e458268c0f9b7bf461cea3c31c37b5e3791.tar.gz
volse-hubzilla-6e101e458268c0f9b7bf461cea3c31c37b5e3791.tar.bz2
volse-hubzilla-6e101e458268c0f9b7bf461cea3c31c37b5e3791.zip
widgets cont.
Diffstat (limited to 'Zotlabs/Widget/Conversations.php')
-rw-r--r--Zotlabs/Widget/Conversations.php74
1 files changed, 74 insertions, 0 deletions
diff --git a/Zotlabs/Widget/Conversations.php b/Zotlabs/Widget/Conversations.php
new file mode 100644
index 000000000..fa59ce20c
--- /dev/null
+++ b/Zotlabs/Widget/Conversations.php
@@ -0,0 +1,74 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Conversations {
+
+ function widget($arr) {
+
+ if (! local_channel())
+ return;
+
+ if(argc() > 1) {
+
+ switch(argv(1)) {
+ case 'combined':
+ $mailbox = 'combined';
+ $header = t('Conversations');
+ break;
+ case 'inbox':
+ $mailbox = 'inbox';
+ $header = t('Received Messages');
+ break;
+ case 'outbox':
+ $mailbox = 'outbox';
+ $header = t('Sent Messages');
+ break;
+ default:
+ $mailbox = 'combined';
+ $header = t('Conversations');
+ break;
+ }
+
+ require_once('include/message.php');
+
+ // private_messages_list() can do other more complicated stuff, for now keep it simple
+ $r = private_messages_list(local_channel(), $mailbox, App::$pager['start'], App::$pager['itemspage']);
+
+ if(! $r) {
+ info( t('No messages.') . EOL);
+ return $o;
+ }
+
+ $messages = array();
+
+ foreach($r as $rr) {
+
+ $messages[] = array(
+ 'mailbox' => $mailbox,
+ 'id' => $rr['id'],
+ 'from_name' => $rr['from']['xchan_name'],
+ 'from_url' => chanlink_hash($rr['from_xchan']),
+ 'from_photo' => $rr['from']['xchan_photo_s'],
+ 'to_name' => $rr['to']['xchan_name'],
+ 'to_url' => chanlink_hash($rr['to_xchan']),
+ 'to_photo' => $rr['to']['xchan_photo_s'],
+ 'subject' => (($rr['seen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'),
+ 'delete' => t('Delete conversation'),
+ 'body' => $rr['body'],
+ 'date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], 'c'),
+ 'seen' => $rr['seen'],
+ 'selected' => ((argv(2)) ? (argv(2) == $rr['id']) : ($r[0]['id'] == $rr['id']))
+ );
+ }
+
+ $tpl = get_markup_template('mail_head.tpl');
+ $o .= replace_macros($tpl, array(
+ '$header' => $header,
+ '$messages' => $messages
+ ));
+
+ }
+ return $o;
+ }
+} \ No newline at end of file