aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/items.php88
-rw-r--r--include/main.js25
-rw-r--r--include/notifier.php18
-rw-r--r--include/poller.php5
4 files changed, 116 insertions, 20 deletions
diff --git a/include/items.php b/include/items.php
index f85a0e64b..8ca0eeb16 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1,9 +1,9 @@
<?php
+require_once('bbcode.php');
-function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update) {
+function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update, $direction = 0) {
- require_once('bbcode.php');
// default permissions - anonymous user
@@ -32,13 +32,31 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update) {
else
killme();
- if($dfrn_id != '*') {
+ if($dfrn_id && $dfrn_id != '*') {
+
+ $sql_extra = '';
+ switch($direction) {
+ case (-1):
+ $sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id));
+ $my_id = $dfrn_id;
+ break;
+ case 0:
+ $sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
+ $my_id = '1:' . $dfrn_id;
+ break;
+ case 1:
+ $sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
+ $my_id = '0:' . $dfrn_id;
+ break;
+ default:
+ return false;
+ break; // NOTREACHED
+ }
- $r = q("SELECT * FROM `contact` WHERE ( `issued-id` = '%s' OR ( `duplex` = 1 AND `dfrn-id` = '%s' )) AND `uid` = %d LIMIT 1",
- dbesc($dfrn_id),
- dbesc($dfrn_id),
+ $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `contact`.`uid` = %d $sql_extra LIMIT 1",
intval($owner_id)
);
+
if(! count($r))
return false;
@@ -82,7 +100,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update) {
`contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1
- AND NOT `item`.`type` IN ( 'remote', 'net-comment' ) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ AND `item`.`wall` = 1 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' )
$sql_extra
ORDER BY `parent` %s, `created` ASC LIMIT 0, 300",
@@ -193,10 +211,23 @@ function construct_verb($item) {
function construct_activity($item) {
- if($item['type'] == 'activity') {
-
-
+ if($item['object']) {
+ $o = '<as:object>' . "\r\n";
+ $r = @simplexml_load_string($item['object']);
+ if($r->type)
+ $o .= '<as:object-type>' . $r->type . '</as:object-type>' . "\r\n";
+ if($r->id)
+ $o .= '<id>' . $r->id . '</id>' . "\r\n";
+ if($r->link)
+ $o .= '<link rel="alternate" type="text/html" href="' . $r->link . '" />' . "\r\n";
+ if($r->title)
+ $o .= '<title>' . $r->title . '</title>' . "\r\n";
+ if($r->content)
+ $o .= '<content type="html" >' . bbcode($r->content) . '</content>' . "\r\n";
+ $o .= '</as:object>' . "\r\n";
+ return $o;
}
+
return '';
}
@@ -300,9 +331,42 @@ function get_atom_elements($item) {
$res['verb'] = unxmlify($rawverb[0]['data']);
$rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'object');
+
+
if($rawobj) {
- $res['object-type'] = $rawobj[0]['object-type'][0]['data'];
- $res['object'] = $rawobj[0];
+ $res['object'] = '<object>' . "\n";
+ if($rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
+ $res['object-type'] = $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'];
+ $res['object'] .= '<type>' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
+ }
+ if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
+ $res['object'] .= '<id>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
+
+ if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'][0]['attribs']['']['rel'] == 'alternate')
+ $res['object'] .= '<link>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'][0]['attribs']['']['href'] . '</link>' . "\n";
+ if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
+ $res['object'] .= '<title>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
+ if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
+ $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
+ if(! $body)
+ $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data'];
+ if(strpos($body,'<')) {
+
+ $body = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
+ '[youtube]$1[/youtube]', $body);
+
+ $config = HTMLPurifier_Config::createDefault();
+ $config->set('Core.DefinitionCache', null);
+
+ $purifier = new HTMLPurifier($config);
+ $body = $purifier->purify($body);
+ }
+
+ $body = html2bbcode($body);
+ $res['object'] .= '<content>' . $body . '</content>' . "\n";
+ }
+
+ $res['object'] .= '</object>' . "\n";
}
return $res;
diff --git a/include/main.js b/include/main.js
index ca6d56d8b..cc44db5d4 100644
--- a/include/main.js
+++ b/include/main.js
@@ -36,6 +36,7 @@
var livetime = null;
var msie = false;
var stopped = false;
+ var timer = null;
$(document).ready(function() {
$.ajaxSetup({cache: false});
@@ -77,12 +78,12 @@
});
}) ;
}
- setTimeout(NavUpdate,30000);
+ timer = setTimeout(NavUpdate,30000);
}
function liveUpdate() {
- if((src == null) || (stopped)) { return; }
+ if((src == null) || (stopped)) { $('.like-rotator').hide(); return; }
if($('.comment-edit-text-full').length) {
livetime = setTimeout(liveUpdate, 10000);
return;
@@ -102,6 +103,8 @@
$('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
$('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
+ $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
+ $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
$('#' + ident + ' ' + '.my-comment-photo').each(function() {
$(this).attr('src',$(this).attr('dst'));
});
@@ -110,6 +113,7 @@
}
prev = ident;
});
+ $('.like-rotator').hide();
});
}
@@ -129,3 +133,20 @@
$(node).css('width',16);
$(node).css('height',16);
}
+
+ // Since ajax is asynchronous, we will give a few seconds for
+ // the first ajax call (setting like/dislike), then run the
+ // updater to pick up any changes and display on the page.
+ // The updater will turn any rotators off when it's done.
+ // This function will have returned long before any of these
+ // events have completed and therefore there won't be any
+ // visible feedback that anything changed without all this
+ // trickery. This still could cause confusion if the "like" ajax call
+ // is delayed and NavUpdate runs before it completes.
+
+ function dolike(ident,verb) {
+ $('#like-rotator-' + ident.toString()).show();
+ $.get('like/' + ident.toString() + '?verb=' + verb );
+ if(timer) clearTimeout(timer);
+ timer = setTimeout(NavUpdate,3000);
+ }
diff --git a/include/notifier.php b/include/notifier.php
index cc2846735..5766747b8 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -13,6 +13,7 @@
require_once("session.php");
require_once("datetime.php");
+ require_once('include/items.php');
if($argc < 3)
exit;
@@ -114,6 +115,8 @@
$recipients = array_diff($recipients,$deny);
$conversant_str = dbesc(implode(', ',$conversants));
+
+
}
$r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 AND `pending` = 0");
@@ -161,14 +164,13 @@
}
else {
- require_once('include/items.php');
-
- $verb = construct_verb($item);
- $actobj = construct_activity($item);
-
if($followup) {
foreach($items as $item) {
+
+ $verb = construct_verb($item);
+ $actobj = construct_activity($item);
+
if($item['id'] == $item_id) {
$atom .= replace_macros($cmnt_template, array(
'$name' => xmlify($owner['name']),
@@ -203,6 +205,10 @@
else {
foreach($contacts as $contact) {
if($item['contact-id'] == $contact['id']) {
+
+ $verb = construct_verb($item);
+ $actobj = construct_activity($item);
+
if($item['parent'] == $item['id']) {
$atom .= replace_macros($item_template, array(
'$name' => xmlify($contact['name']),
@@ -220,7 +226,7 @@
'$verb' => xmlify($verb),
'$actobj' => $actobj,
'$content' => xmlify($item['body']),
- '$comment_allow' => (($item['last-child'] && ($contact['rel']) && ($contact['rel'] != REL_FAN)) ? 1 : 0)
+ '$comment_allow' => (($item['last-child']) ? 1 : 0)
));
}
else {
diff --git a/include/poller.php b/include/poller.php
index 6024b1844..f116a5622 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -348,6 +348,11 @@
$datarray['parent-uri'] = $parent_uri;
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
+ if(($datarray['verb'] == ACTIVITY_LIKE) || ($datarray['verb'] == ACTIVITY_DISLIKE)) {
+ $datarray['type'] = 'activity';
+ $datarray['gravity'] = GRAVITY_LIKE;
+ }
+
$r = item_store($datarray);
continue;
}