aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Widget/Conversations.php175
-rw-r--r--Zotlabs/Widget/Mailmenu.php4
-rw-r--r--view/tpl/mail_conv.tpl6
-rw-r--r--view/tpl/message_side.tpl2
-rw-r--r--view/tpl/msg-header.tpl5
-rw-r--r--view/tpl/prv_message.tpl3
6 files changed, 146 insertions, 49 deletions
diff --git a/Zotlabs/Widget/Conversations.php b/Zotlabs/Widget/Conversations.php
index 267d50fa0..3dc260b50 100644
--- a/Zotlabs/Widget/Conversations.php
+++ b/Zotlabs/Widget/Conversations.php
@@ -9,67 +9,154 @@ class Conversations {
if (! local_channel())
return;
- if(argc() > 1) {
+ switch(argv(1)) {
+ 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;
+ }
+
+ $o = '';
+
+ // private_messages_list() can do other more complicated stuff, for now keep it simple
+ $r = self::private_messages_list(local_channel(), $mailbox, \App::$pager['start'], \App::$pager['itemspage']);
+
+ if(! $r) {
+ info( t('No messages.') . EOL);
+ return $o;
+ }
+
+ $messages = [];
+
+ foreach($r as $rr) {
+
+ $selected = ((argc() == 3) ? intval(argv(2)) == intval($rr['id']) : $r[0]['id'] == $rr['id']);
+
+ $messages[] = [
+ '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(1) != 'new') ? $selected : '')
+ ];
+ }
+
+ $tpl = get_markup_template('mail_head.tpl');
+ $o .= replace_macros($tpl, [
+ '$header' => $header,
+ '$messages' => $messages
+ ]);
+
+ return $o;
+ }
+
+ function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) {
+
+ $where = '';
+ $limit = '';
+
+ $t0 = dba_timer();
+
+ if($numitems)
+ $limit = " LIMIT " . intval($numitems) . " OFFSET " . intval($start);
+
+ if($mailbox !== '') {
+ $x = q("select channel_hash from channel where channel_id = %d limit 1",
+ intval($uid)
+ );
+
+ if(! $x)
+ return array();
+
+ $channel_hash = dbesc($x[0]['channel_hash']);
+ $local_channel = intval(local_channel());
+
+ switch($mailbox) {
- switch(argv(1)) {
case 'inbox':
- $mailbox = 'inbox';
- $header = t('Received Messages');
+ $sql = "SELECT * FROM mail WHERE channel_id = $local_channel AND from_xchan != '$channel_hash' ORDER BY created DESC $limit";
break;
+
case 'outbox':
- $mailbox = 'outbox';
- $header = t('Sent Messages');
+ $sql = "SELECT * FROM mail WHERE channel_id = $local_channel AND from_xchan = '$channel_hash' ORDER BY created DESC $limit";
break;
+
+ case 'combined':
default:
- $mailbox = 'combined';
- $header = t('Conversations');
+ $parents = q("SELECT mail.parent_mid FROM mail LEFT JOIN conv ON mail.conv_guid = conv.guid WHERE mail.mid = mail.parent_mid AND mail.channel_id = %d ORDER BY conv.updated DESC $limit",
+ intval($local_channel)
+ );
break;
}
- require_once('include/message.php');
+ }
- $o = '';
+ $r = null;
- // 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($parents) {
+ foreach($parents as $parent) {
+ $all = q("SELECT * FROM mail WHERE parent_mid = '%s' AND channel_id = %d ORDER BY created DESC limit 1",
+ dbesc($parent['parent_mid']),
+ intval($local_channel)
+ );
- if(! $r) {
- info( t('No messages.') . EOL);
- return $o;
+ if($all) {
+ foreach($all as $single) {
+ $r[] = $single;
+ }
+ }
}
+ }
+ elseif($sql) {
+ $r = q($sql);
+ }
- $messages = [];
-
- foreach($r as $rr) {
-
- $selected = ((argc() == 3) ? intval(argv(2)) == intval($rr['id']) : $r[0]['id'] == $rr['id']);
-
- $messages[] = [
- '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(1) != 'new') ? $selected : '')
- ];
- }
+ if(! $r) {
+ return array();
+ }
- $tpl = get_markup_template('mail_head.tpl');
- $o .= replace_macros($tpl, [
- '$header' => $header,
- '$messages' => $messages
- ]);
+ $chans = array();
+ foreach($r as $rr) {
+ $s = "'" . dbesc(trim($rr['from_xchan'])) . "'";
+ if(! in_array($s,$chans))
+ $chans[] = $s;
+ $s = "'" . dbesc(trim($rr['to_xchan'])) . "'";
+ if(! in_array($s,$chans))
+ $chans[] = $s;
+ }
+ $c = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$chans)) . ")");
+
+ foreach($r as $k => $rr) {
+ $r[$k]['from'] = find_xchan_in_array($rr['from_xchan'],$c);
+ $r[$k]['to'] = find_xchan_in_array($rr['to_xchan'],$c);
+ $r[$k]['seen'] = intval($rr['mail_seen']);
+ if(intval($r[$k]['mail_obscured'])) {
+ if($r[$k]['title'])
+ $r[$k]['title'] = base64url_decode(str_rot47($r[$k]['title']));
+ if($r[$k]['body'])
+ $r[$k]['body'] = base64url_decode(str_rot47($r[$k]['body']));
+ }
}
- return $o;
+
+ return $r;
}
}
diff --git a/Zotlabs/Widget/Mailmenu.php b/Zotlabs/Widget/Mailmenu.php
index 512f7d9c0..ca022c807 100644
--- a/Zotlabs/Widget/Mailmenu.php
+++ b/Zotlabs/Widget/Mailmenu.php
@@ -14,7 +14,7 @@ class Mailmenu {
'$combined' => array(
'label' => t('Combined View'),
'url' => z_root() . '/mail/combined',
- 'sel' => (argv(1) == 'combined'),
+ 'sel' => (argv(1) == 'combined' || argc() == 1),
),
'$inbox' => array(
'label' => t('Inbox'),
@@ -26,11 +26,13 @@ class Mailmenu {
'url' => z_root() . '/mail/outbox',
'sel' => (argv(1) == 'outbox'),
),
+/*
'$new' => array(
'label' => t('New Message'),
'url' => z_root() . '/mail/new',
'sel'=> (argv(1) == 'new'),
)
+*/
));
}
}
diff --git a/view/tpl/mail_conv.tpl b/view/tpl/mail_conv.tpl
index b0497fe99..adc7734ec 100644
--- a/view/tpl/mail_conv.tpl
+++ b/view/tpl/mail_conv.tpl
@@ -24,9 +24,11 @@
<i class="fa fa-cog"></i>
</button>
<div class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="mail-item-menu-{{$mail.id}}">
- {{if $mail.can_recall}}
+ {{** if $mail.can_recall}}
<a class="dropdown-item" href="mail/{{$mail.mailbox}}/recall/{{$mail.id}}" title="{{$mail.recall}}" id="mail-conv-recall-icon-{{$mail.id}}"><i class="fa fa-fw fa-undo"></i>&nbsp;{{$mail.recall}}</a>
- {{/if}}
+ {{/if **}}
+ <a class="dropdown-item" href="mail/{{$mail.id}}/download" id="mail-conv-download-icon-{{$mail.id}}"><i class="fa fa-fw fa-download"></i>&nbsp;{{$mail.download}}</a>
+ <div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" onclick="dropItem('mail/{{$mail.mailbox}}/drop/{{$mail.id}}', '#mail-{{$mail.id}}'); return false;" title="{{$mail.delete}}" id="mail-conv-delete-icon-{{$mail.id}}"><i class="fa fa-fw fa-trash-o"></i>&nbsp;{{$mail.delete}}</a>
{{if $mail.can_recall}}
<div class="dropdown-divider"></div>
diff --git a/view/tpl/message_side.tpl b/view/tpl/message_side.tpl
index 2ac61bf76..a45d1d177 100644
--- a/view/tpl/message_side.tpl
+++ b/view/tpl/message_side.tpl
@@ -4,6 +4,8 @@
<li class="nav-item"><a href="{{$combined.url}}" class="nav-link{{if $combined.sel}} active{{/if}}">{{$combined.label}}</a></li>
<li class="nav-item"><a href="{{$inbox.url}}" class="nav-link{{if $inbox.sel}} active{{/if}}">{{$inbox.label}}</a></li>
<li class="nav-item"><a href="{{$outbox.url}}" class="nav-link{{if $outbox.sel}} active{{/if}}">{{$outbox.label}}</a></li>
+{{**
<li class="nav-item"><a href="{{$new.url}}" class="nav-link{{if $new.sel}} active{{/if}}">{{$new.label}}</a></li>
+**}}
</ul>
</div>
diff --git a/view/tpl/msg-header.tpl b/view/tpl/msg-header.tpl
index e8542b087..d49303453 100644
--- a/view/tpl/msg-header.tpl
+++ b/view/tpl/msg-header.tpl
@@ -1,3 +1,4 @@
+{{**
<script src="vendor/blueimp/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script>
<script src="vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js"></script>
<script src="vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js"></script>
@@ -73,9 +74,9 @@
function addmailtext(data) {
var currentText = $("#prvmail-text").val();
$("#prvmail-text").val(currentText + data);
- }
+ }
</script>
-
+**}}
diff --git a/view/tpl/prv_message.tpl b/view/tpl/prv_message.tpl
index b8c81539d..ea7de0b4c 100644
--- a/view/tpl/prv_message.tpl
+++ b/view/tpl/prv_message.tpl
@@ -1,3 +1,5 @@
+{{**
+
{{if $new}}
<div class="generic-content-wrapper">
<div class="section-title-wrapper">
@@ -105,3 +107,4 @@
</div>
</div>
{{/if}}
+**}}