From b97102da01b2e81018e86c29092059704ee20da8 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 28 Sep 2015 17:40:38 +0200 Subject: private mail: bring additional inbox/outbox views and ajaxify single message drop --- include/widgets.php | 4 +++- mod/mail.php | 44 +++++++++++++++++++++++++++++--------------- mod/message.php | 4 ++-- view/tpl/mail_conv.tpl | 6 +++--- view/tpl/mail_display.tpl | 2 +- view/tpl/mail_list.tpl | 2 +- view/tpl/message_side.tpl | 9 --------- 7 files changed, 39 insertions(+), 32 deletions(-) diff --git a/include/widgets.php b/include/widgets.php index 9f8b88d54..9c8596a66 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -637,6 +637,7 @@ function widget_conversations($arr) { foreach($r as $rr) { $messages[] = array( + 'mailbox' => $mailbox, 'id' => $rr['id'], 'from_name' => $rr['from']['xchan_name'], 'from_url' => chanlink_hash($rr['from_xchan']), @@ -648,7 +649,8 @@ function widget_conversations($arr) { 'delete' => t('Delete conversation'), 'body' => $rr['body'], 'date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], t('D, d M Y - g:i A')), - 'seen' => $rr['seen'] + 'seen' => $rr['seen'], + 'selected' => ((argv(2)) ? (argv(2) == $rr['id']) : ($r[0]['id'] == $rr['id'])) ); } diff --git a/mod/mail.php b/mod/mail.php index 75e8f4dd5..e4a5ebafd 100644 --- a/mod/mail.php +++ b/mod/mail.php @@ -128,33 +128,45 @@ function mail_content(&$a) { '$header' => t('Messages'), )); - if((argc() == 3) && (argv(1) === 'drop')) { - if(! intval(argv(2))) + if((argc() == 4) && (argv(2) === 'drop')) { + if(! intval(argv(3))) return; - $cmd = argv(1); - - $r = private_messages_drop(local_channel(), argv(2)); + $cmd = argv(2); + $mailbox = argv(1); + $r = private_messages_drop(local_channel(), argv(3)); if($r) { - info( t('Message deleted.') . EOL ); + //info( t('Message deleted.') . EOL ); } - goaway($a->get_baseurl(true) . '/mail/combined' ); + goaway($a->get_baseurl(true) . '/mail/' . $mailbox); } - if((argc() == 3) && (argv(1) === 'recall')) { - if(! intval(argv(2))) + if((argc() == 4) && (argv(2) === 'recall')) { + if(! intval(argv(3))) return; - $cmd = argv(1); + $cmd = argv(2); + $mailbox = argv(1); $r = q("update mail set mail_recalled = 1 where id = %d and channel_id = %d", - intval(argv(2)), + intval(argv(3)), intval(local_channel()) ); - proc_run('php','include/notifier.php','mail',intval(argv(2))); + proc_run('php','include/notifier.php','mail',intval(argv(3))); if($r) { info( t('Message recalled.') . EOL ); } - goaway($a->get_baseurl(true) . '/mail/combined' ); + goaway($a->get_baseurl(true) . '/mail/' . $mailbox . '/' . argv(3)); + + } + if((argc() == 4) && (argv(2) === 'dropconv')) { + if(! intval(argv(3))) + return; + $cmd = argv(2); + $mailbox = argv(1); + $r = private_messages_drop(local_channel(), argv(3), true); + if($r) + info( t('Conversation removed.') . EOL ); + goaway($a->get_baseurl(true) . '/mail/' . $mailbox); } if((argc() > 1) && (argv(1) === 'new')) { @@ -266,7 +278,7 @@ function mail_content(&$a) { $last_message = private_messages_list(local_channel(), $mailbox, 0, 1); - $mid = ((argc() > 1) && (intval(argv(1)))) ? argv(1) : $last_message[0]['id']; + $mid = ((argc() > 2) && (intval(argv(2)))) ? argv(2) : $last_message[0]['id']; $plaintext = true; @@ -310,6 +322,7 @@ function mail_content(&$a) { $s = theme_attachments($message); $mails[] = array( + 'mailbox' => $mailbox, 'id' => $message['id'], 'from_name' => $message['from']['xchan_name'], 'from_url' => chanlink_hash($message['from_xchan']), @@ -338,7 +351,8 @@ function mail_content(&$a) { $parent = ''; $tpl = get_markup_template('mail_display.tpl'); $o = replace_macros($tpl, array( - '$prvmsg_header' => t('Subject:') . ' ' . $message['title'], + '$mailbox' => $mailbox, + '$prvmsg_header' => $message['title'], '$thread_id' => $mid, '$thread_subject' => $message['title'], '$thread_seen' => $seen, diff --git a/mod/message.php b/mod/message.php index f8d71aa44..73239d2cb 100644 --- a/mod/message.php +++ b/mod/message.php @@ -24,7 +24,7 @@ function message_content(&$a) { if(! $cipher) $cipher = 'aes256'; - +/* if((argc() == 3) && (argv(1) === 'dropconv')) { if(! intval(argv(2))) return; @@ -34,7 +34,7 @@ function message_content(&$a) { info( t('Conversation removed.') . EOL ); goaway($a->get_baseurl(true) . '/mail/combined' ); } -/* + if(argc() == 2) { switch(argv(1)) { diff --git a/view/tpl/mail_conv.tpl b/view/tpl/mail_conv.tpl index 0a5e5a2c5..2e64de7bc 100755 --- a/view/tpl/mail_conv.tpl +++ b/view/tpl/mail_conv.tpl @@ -1,4 +1,4 @@ -
+
{{$mail.from_name}}
@@ -9,9 +9,9 @@
{{$mail.body}}
{{if $mail.can_recall}} - + {{/if}} - +
diff --git a/view/tpl/mail_display.tpl b/view/tpl/mail_display.tpl index bb89c96ec..24a87fe4a 100755 --- a/view/tpl/mail_display.tpl +++ b/view/tpl/mail_display.tpl @@ -1,6 +1,6 @@
- {{$delete}} + {{$delete}}

{{$prvmsg_header}}

diff --git a/view/tpl/mail_list.tpl b/view/tpl/mail_list.tpl index ad042eb59..fc9b5afa8 100755 --- a/view/tpl/mail_list.tpl +++ b/view/tpl/mail_list.tpl @@ -1,5 +1,5 @@
  • - + {{$message.subject}}
    {{$message.from_name}} > {{$message.to_name}}
    {{$message.date}} diff --git a/view/tpl/message_side.tpl b/view/tpl/message_side.tpl index 954ada215..b3bb94d71 100755 --- a/view/tpl/message_side.tpl +++ b/view/tpl/message_side.tpl @@ -2,18 +2,9 @@

    {{$title}}

    - {{if $tabs}} - - {{/if}}
  • -- cgit v1.2.3