aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/features.php13
-rw-r--r--include/notify.php60
-rw-r--r--mod/ping.php29
3 files changed, 94 insertions, 8 deletions
diff --git a/include/features.php b/include/features.php
index 2bb874095..d74718540 100644
--- a/include/features.php
+++ b/include/features.php
@@ -16,13 +16,12 @@ function get_features() {
$arr = array(
-'multi_delete' => t('Multiple Deletion'),
-'expire' => t('Content Expiration'),
-'commtag' => t('Community Tagging'),
-'categories' => t('Post Categories'),
-'filing' => t('Saved Folders'),
-'archives' => t('Archives'),
-
+'multi_delete' => t('Multiple Deletion'),
+'expire' => t('Content Expiration'),
+'commtag' => t('Community Tagging'),
+'categories' => t('Post Categories'),
+'filing' => t('Saved Folders'),
+'archives' => t('Search by Date'),
);
diff --git a/include/notify.php b/include/notify.php
new file mode 100644
index 000000000..33ea5843c
--- /dev/null
+++ b/include/notify.php
@@ -0,0 +1,60 @@
+<?php
+
+
+function format_notification($item) {
+
+
+return;
+
+// convert this logic into a json array just like the system notifications
+
+ switch($item['verb']){
+ case ACTIVITY_LIKE:
+
+
+ $notif_content .= replace_macros($tpl_item_likes,array(
+ '$itemem_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$item['parent'],
+ '$itemem_image' => $item['author-avatar'],
+ '$itemem_text' => sprintf( t("%s liked %s's post"), $item['author-name'], $item['pname']),
+ '$itemem_when' => relative_date($item['created'])
+ ));
+ break;
+
+ case ACTIVITY_DISLIKE:
+ $notif_content .= replace_macros($tpl_item_dislikes,array(
+ '$itemem_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$item['parent'],
+ '$itemem_image' => $item['author-avatar'],
+ '$itemem_text' => sprintf( t("%s disliked %s's post"), $item['author-name'], $item['pname']),
+ '$itemem_when' => relative_date($item['created'])
+ ));
+ break;
+
+ case ACTIVITY_FRIEND:
+
+ $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
+ $obj = parse_xml_string($xmlhead.$item['object']);
+ $item['fname'] = $obj->title;
+
+ $notif_content .= replace_macros($tpl_item_friends,array(
+ '$itemem_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$item['parent'],
+ '$itemem_image' => $item['author-avatar'],
+ '$itemem_text' => sprintf( t("%s is now friends with %s"), $item['author-name'], $item['fname']),
+ '$itemem_when' => relative_date($item['created'])
+ ));
+ break;
+
+ default:
+ $itemem_text = (($item['id'] == $item['parent'])
+ ? sprintf( t("%s created a new post"), $item['author-name'])
+ : sprintf( t("%s commented on %s's post"), $item['author-name'], $item['pname']));
+ $tpl = (($item['id'] == $item['parent']) ? $tpl_item_posts : $tpl_item_comments);
+
+ $notif_content .= replace_macros($tpl,array(
+ '$itemem_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$item['parent'],
+ '$itemem_image' => $item['author-avatar'],
+ '$itemem_text' => $itemem_text,
+ '$itemem_when' => relative_date($it['created'])
+ ));
+ }
+}
+
diff --git a/mod/ping.php b/mod/ping.php
index ff8d977dc..60ca7f734 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -2,6 +2,7 @@
require_once('include/bbcode.php');
+require_once('include/notify.php');
function ping_init(&$a) {
@@ -88,7 +89,33 @@ function ping_init(&$a) {
killme();
}
-
+
+ if(argc() > 1 && (argv(1) === 'network' || argv(1) === 'home')) {
+
+ $result = array();
+
+ $r = q("SELECT id, item_restrict, item_flags FROM item
+ WHERE item_restrict = %d and item_flags & %d and `item`.`uid` = %d",
+ intval(ITEM_VISIBLE),
+ intval(ITEM_UNSEEN),
+ intval(local_user())
+ );
+
+ if($r) {
+ foreach($r as $item) {
+ if((argv(1) === 'home') && (! ($item['item_flags'] & ITEM_HOME)))
+ continue;
+ $result[] = format_notification($item);
+ }
+ }
+
+ echo json_encode(array( argv(1) => $result));
+ killme();
+
+ }
+
+
+ // Normal ping - just the counts
$t = q("select count(*) as total from notify where uid = %d and seen = 0",
intval(local_user())