diff options
author | redmatrix <redmatrix@redmatrix.me> | 2015-09-24 16:58:32 -0700 |
---|---|---|
committer | redmatrix <redmatrix@redmatrix.me> | 2015-09-24 16:58:32 -0700 |
commit | 2fe3d16bbed892b2c1287ba876ae54ff502edbad (patch) | |
tree | 2732d7fd9e57760665815c770a9bf5e4d4812726 /include | |
parent | 2844f276b9af6154e36706b7fe53438352493d58 (diff) | |
parent | c42dcd5ac9c63cd42c7af1b2765dd33e7e9f5d6d (diff) | |
download | volse-hubzilla-2fe3d16bbed892b2c1287ba876ae54ff502edbad.tar.gz volse-hubzilla-2fe3d16bbed892b2c1287ba876ae54ff502edbad.tar.bz2 volse-hubzilla-2fe3d16bbed892b2c1287ba876ae54ff502edbad.zip |
Merge https://github.com/redmatrix/hubzilla into pending_merge
Diffstat (limited to 'include')
-rw-r--r-- | include/message.php | 34 | ||||
-rw-r--r-- | include/nav.php | 8 | ||||
-rw-r--r-- | include/widgets.php | 97 |
3 files changed, 120 insertions, 19 deletions
diff --git a/include/message.php b/include/message.php index efe1a7710..4b0236db8 100644 --- a/include/message.php +++ b/include/message.php @@ -262,18 +262,30 @@ function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) { ); if(! $x) return array(); - if($mailbox === 'inbox') - $where = " and sender_xchan != '" . dbesc($x[0]['channel_hash']) . "' "; - elseif($mailbox === 'outbox') - $where = " and sender_xchan = '" . dbesc($x[0]['channel_hash']) . "' "; + + $channel_hash = dbesc($x[0]['channel_hash']); + $local_channel = intval(local_channel()); + + switch($mailbox) { + + case 'inbox': + $sql = "SELECT * FROM mail WHERE channel_id = $local_channel AND from_xchan != '$channel_hash' ORDER BY created DESC $limit"; + break; + + case 'outbox': + $sql = "SELECT * FROM mail WHERE channel_id = $local_channel AND from_xchan = '$channel_hash' ORDER BY created DESC $limit"; + break; + + case 'combined': + $sql = "SELECT * FROM ( SELECT * FROM mail WHERE channel_id = $local_channel ORDER BY created DESC $limit ) AS temp_table GROUP BY parent_mid ORDER BY created DESC"; + break; + + } + } - // For different orderings, consider applying usort on the results. We thought of doing that - // inside this function or having some preset sorts, but don't wish to limit app developers. - - $r = q("SELECT * from mail WHERE channel_id = %d $where order by created desc $limit", - intval(local_channel()) - ); + $r = q($sql); + if(! $r) { return array(); } @@ -437,4 +449,4 @@ function private_messages_fetch_conversation($channel_id, $messageitem_id, $upda return $messages; -}
\ No newline at end of file +} diff --git a/include/nav.php b/include/nav.php index 972795e83..1630c4731 100644 --- a/include/nav.php +++ b/include/nav.php @@ -185,11 +185,11 @@ EOT; $nav['notifications']['all']=array('notifications/system', t('See all notifications'), "", ""); $nav['notifications']['mark'] = array('', t('Mark all system notifications seen'), '',''); - $nav['messages'] = array('message', t('Mail'), "", t('Private mail'),'mail_nav_btn'); - $nav['messages']['all']=array('message', t('See all private messages'), "", ""); + $nav['messages'] = array('mail/combined', t('Mail'), "", t('Private mail'),'mail_nav_btn'); + $nav['messages']['all']=array('mail/combined', t('See all private messages'), "", ""); $nav['messages']['mark'] = array('', t('Mark all private messages seen'), '',''); - $nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox')); - $nav['messages']['outbox']= array('message/sent', t('Outbox'), "", t('Outbox')); + $nav['messages']['inbox'] = array('mail/inbox', t('Inbox'), "", t('Inbox')); + $nav['messages']['outbox']= array('mail/outbox', t('Outbox'), "", t('Outbox')); $nav['messages']['new'] = array('mail/new', t('New Message'), "", t('New Message')); diff --git a/include/widgets.php b/include/widgets.php index 5e40bf54a..9f8b88d54 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -562,14 +562,30 @@ function widget_mailmenu($arr) { return; $a = get_app(); + return replace_macros(get_markup_template('message_side.tpl'), array( - '$title' => t('Messages'), - '$tabs'=> array(), + '$title' => t('Private Mail Menu'), '$check'=>array( 'label' => t('Check Mail'), - 'url' => $a->get_baseurl(true) . '/message', + 'url' => $a->get_baseurl(true) . '/mail/combined', 'sel' => (argv(1) == ''), ), + + '$combined'=>array( + 'label' => t('Combined View'), + 'url' => $a->get_baseurl(true) . '/mail/combined', + 'sel' => (argv(1) == 'combined'), + ), + '$inbox'=>array( + 'label' => t('Inbox'), + 'url' => $a->get_baseurl(true) . '/mail/inbox', + 'sel' => (argv(1) == 'inbox'), + ), + '$outbox'=>array( + 'label' => t('Outbox'), + 'url' => $a->get_baseurl(true) . '/mail/outbox', + 'sel' => (argv(1) == 'outbox'), + ), '$new'=>array( 'label' => t('New Message'), 'url' => $a->get_baseurl(true) . '/mail/new', @@ -578,6 +594,78 @@ function widget_mailmenu($arr) { )); } + +function widget_conversations($arr) { + if (! local_channel()) + return; + + $a = get_app(); + + 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, $a->pager['start'], $a->pager['itemspage']); + + if(! $r) { + info( t('No messages.') . EOL); + return $o; + } + + $messages = array(); + + foreach($r as $rr) { + + $messages[] = array( + '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'], t('D, d M Y - g:i A')), + 'seen' => $rr['seen'] + ); + } + + $tpl = get_markup_template('mail_head.tpl'); + $o .= replace_macros($tpl, array( + '$header' => $header, + '$messages' => $messages + )); + + $o .= alt_pager($a,count($r)); + + } + + return $o; +} + + function widget_design_tools($arr) { $a = get_app(); @@ -594,6 +682,7 @@ function widget_design_tools($arr) { return design_tools(); } + function widget_findpeople($arr) { return findpeople_widget(); } @@ -1135,4 +1224,4 @@ function widget_admin($arr) { return $o; -}
\ No newline at end of file +} |