aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/event.php16
-rw-r--r--include/identity.php4
-rw-r--r--include/message.php34
-rw-r--r--include/nav.php8
-rw-r--r--include/widgets.php97
-rw-r--r--include/zot.php2
6 files changed, 136 insertions, 25 deletions
diff --git a/include/event.php b/include/event.php
index 44c172e98..f0a806dfa 100644
--- a/include/event.php
+++ b/include/event.php
@@ -526,13 +526,17 @@ function event_import_ical($ical, $uid) {
// logger('dtstart: ' . var_export($dtstart,true));
- if(($dtstart->timezone_type == 2) || (($dtstart->timezone_type == 3) && ($dtstart->timezone === 'UTC'))) {
- $ev['adjust'] = 1;
- }
- else {
- $ev['adjust'] = 0;
+
+ switch($dtstart->timezone_type) {
+ case VObject\Property\DateTime::UTC :
+ $ev['adjust'] = 0;
+ break;
+ case VObject\Property\DateTime::LOCALTZ :
+ default:
+ $ev['adjust'] = 1;
+ break;
}
-
+
$ev['start'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
$dtstart->format(\DateTime::W3C));
diff --git a/include/identity.php b/include/identity.php
index b5235e7ff..47738a8fa 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -616,6 +616,10 @@ function identity_basic_export($channel_id, $items = false) {
}
}
+ $addon = array('channel_id' => $channel_id,'data' => $ret);
+ call_hooks('identity_basic_export',$addon);
+ $ret = $addon['data'];
+
if(! $items)
return $ret;
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
+}
diff --git a/include/zot.php b/include/zot.php
index 288493b07..9bddb520d 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -3319,6 +3319,8 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
if(array_key_exists('item_id',$arr) && $arr['item_id'])
sync_items($channel,$arr['item_id']);
+ $addon = array('channel' => $channel,'data' => $arr);
+ call_hooks('process_channel_sync_delivery',$addon);
// we should probably do this for all items, but usually we only send one.