aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/deliver.php8
-rw-r--r--include/deliver_hooks.php29
-rw-r--r--include/event.php5
-rw-r--r--include/message.php34
-rw-r--r--include/nav.php8
-rw-r--r--include/notifier.php37
-rw-r--r--include/widgets.php97
7 files changed, 185 insertions, 33 deletions
diff --git a/include/deliver.php b/include/deliver.php
index 7a43e3d47..82a1ac6df 100644
--- a/include/deliver.php
+++ b/include/deliver.php
@@ -62,9 +62,17 @@ function deliver_run($argv, $argc) {
$result = z_post_url($r[0]['outq_posturl'],$r[0]['outq_msg']);
if($result['success'] && $result['return_code'] < 300) {
logger('deliver: queue post success to ' . $r[0]['outq_posturl'], LOGGER_DEBUG);
+
+ q("update dreport set status = '%s', dreport_time = '%s' where dreport_queue = '%s' limit 1",
+ dbesc('accepted for delivery'),
+ dbesc(datetime_convert()),
+ dbesc($argv[$x])
+ );
+
$y = q("delete from outq where outq_hash = '%s'",
dbesc($argv[$x])
);
+
}
else {
logger('deliver: queue post returned ' . $result['return_code'] . ' from ' . $r[0]['outq_posturl'],LOGGER_DEBUG);
diff --git a/include/deliver_hooks.php b/include/deliver_hooks.php
new file mode 100644
index 000000000..f0d6ba1b1
--- /dev/null
+++ b/include/deliver_hooks.php
@@ -0,0 +1,29 @@
+<?php
+
+
+require_once('include/cli_startup.php');
+require_once('include/zot.php');
+
+
+function deliver_hooks_run($argv, $argc) {
+
+ cli_startup();
+
+ $a = get_app();
+
+ if($argc < 2)
+ return;
+
+
+ $r = q("select * from item where id = '%d'",
+ intval($argv[1])
+ );
+ if($r)
+ call_hooks('notifier_normal',$r[0]);
+
+}
+
+if (array_search(__file__,get_included_files())===0){
+ deliver_hooks_run($argv,$argc);
+ killme();
+}
diff --git a/include/event.php b/include/event.php
index f0a806dfa..e303ad232 100644
--- a/include/event.php
+++ b/include/event.php
@@ -755,12 +755,15 @@ function event_store_item($arr, $event) {
}
}
+
+
$item_arr = array();
$prefix = '';
// $birthday = false;
if($event['type'] === 'birthday') {
- $prefix = t('This event has been added to your calendar.');
+ if(! is_sys_channel($arr['uid']))
+ $prefix = t('This event has been added to your calendar.');
// $birthday = true;
// The event is created on your own site by the system, but appears to belong
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/notifier.php b/include/notifier.php
index fd95d53e2..3b29229cf 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -579,7 +579,7 @@ function notifier_run($argv, $argc){
if($deliveries_per_process <= 0)
$deliveries_per_process = 1;
- $deliver = array();
+ $deliveries = array();
foreach($dhubs as $hub) {
@@ -675,27 +675,38 @@ function notifier_run($argv, $argc){
);
}
}
- $deliver[] = $hash;
- if(count($deliver) >= $deliveries_per_process) {
- proc_run('php','include/deliver.php',$deliver);
- $deliver = array();
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
+ $deliveries[] = $hash;
+ }
+
+ if($normal_mode) {
+ $x = q("select * from hook where hook = 'notifier_normal'");
+ if($x)
+ proc_run('php','deliver_hooks.php', $target_item['id']);
+ }
+
+ if($deliveries) {
+ $deliver = array();
+
+ foreach($deliveries as $d) {
+
+ $deliver[] = $d;
+
+ if(count($deliver) >= $deliveries_per_process) {
+ proc_run('php','include/deliver.php',$deliver);
+ $deliver = array();
+ if($interval)
+ @time_sleep_until(microtime(true) + (float) $interval);
+ }
}
}
// catch any stragglers
- if(count($deliver)) {
+ if($deliver)
proc_run('php','include/deliver.php',$deliver);
- }
logger('notifier: basic loop complete.', LOGGER_DEBUG);
-
- if($normal_mode)
- call_hooks('notifier_normal',$target_item);
-
call_hooks('notifier_end',$target_item);
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
+}