aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/conversation.php35
-rw-r--r--include/diaspora.php80
-rw-r--r--include/enotify.php13
-rw-r--r--include/items.php36
-rw-r--r--include/text.php4
5 files changed, 126 insertions, 42 deletions
diff --git a/include/conversation.php b/include/conversation.php
index 26430d645..37fe32de1 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -910,25 +910,35 @@ function conv_sort($arr,$order) {
elseif(stristr($order,'commented'))
usort($parents,'sort_thr_commented');
- foreach($parents as $x)
- $x['children'] = array();
+ if(count($parents))
+ foreach($parents as $x)
+ $x['children'] = array();
foreach($arr as $x) {
if($x['id'] != $x['parent']) {
$p = find_thread_parent_index($parents,$x);
- $parents[$p]['children'][] = $x;
+ if($p !== false)
+ $parents[$p]['children'][] = $x;
}
}
- foreach($parents as $x)
- if(count($x['children']))
- usort($x['children'],'sort_thr_created_rev');
+ if(count($parents)) {
+ foreach($parents as $k => $v) {
+ if(count($parents[$k]['children'])) {
+ $y = $parents[$k]['children'];
+ usort($y,'sort_thr_created_rev');
+ $parents[$k]['children'] = $y;
+ }
+ }
+ }
$ret = array();
- foreach($parents as $x) {
- $ret[] = $x;
- if(count($x['children']))
- foreach($x['children'] as $y)
- $ret[] = $y;
+ if(count($parents)) {
+ foreach($parents as $x) {
+ $ret[] = $x;
+ if(count($x['children']))
+ foreach($x['children'] as $y)
+ $ret[] = $y;
+ }
}
return $ret;
@@ -951,4 +961,5 @@ function find_thread_parent_index($arr,$x) {
foreach($arr as $k => $v)
if($v['id'] == $x['parent'])
return $k;
-}
+ return false;
+} \ No newline at end of file
diff --git a/include/diaspora.php b/include/diaspora.php
index 2d139c77c..5a19400da 100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -464,7 +464,7 @@ function diaspora_request($importer,$xml) {
intval($importer['uid'])
);
- if((count($r)) && ($r[0]['hide-friends'] == 0)) {
+ if((count($r)) && (! $r[0]['hide-friends']) && (! $contact['hidden'])) {
require_once('include/items.php');
$self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
@@ -527,6 +527,8 @@ function diaspora_request($importer,$xml) {
$batch = (($ret['batch']) ? $ret['batch'] : implode('/', array_slice(explode('/',$ret['url']),0,3)) . '/receive/public');
+
+
$r = q("INSERT INTO `contact` (`uid`, `network`,`addr`,`created`,`url`,`nurl`,`batch`,`name`,`nick`,`photo`,`pubkey`,`notify`,`poll`,`blocked`,`priority`)
VALUES ( %d, '%s', '%s', '%s', '%s','%s','%s','%s','%s','%s','%s','%s','%s',%d,%d) ",
intval($importer['uid']),
@@ -550,9 +552,15 @@ function diaspora_request($importer,$xml) {
$contact_record = diaspora_get_contact_by_handle($importer['uid'],$sender_handle);
- $hash = random_string() . (string) time(); // Generate a confirm_key
+ if(! $contact_record) {
+ logger('diaspora_request: unable to locate newly created contact record.');
+ return;
+ }
+
+ if($importer['page-flags'] == PAGE_NORMAL) {
+
+ $hash = random_string() . (string) time(); // Generate a confirm_key
- if($contact_record) {
$ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime` )
VALUES ( %d, %d, %d, %d, '%s', '%s', '%s' )",
intval($importer['uid']),
@@ -564,6 +572,49 @@ function diaspora_request($importer,$xml) {
dbesc(datetime_convert())
);
}
+ else {
+
+ // automatic friend approval
+
+ require_once('include/Photo.php');
+
+ $photos = import_profile_photo($contact_record['photo'],$importer['uid'],$contact_record['id']);
+
+ // technically they are sharing with us (CONTACT_IS_SHARING),
+ // but if our page-type is PAGE_COMMUNITY or PAGE_SOAPBOX
+ // we are going to change the relationship and make them a follower.
+
+ if($importer['page-flags'] == PAGE_FREELOVE)
+ $new_relation = CONTACT_IS_FRIEND;
+ else
+ $new_relation = CONTACT_IS_FOLLOWER;
+
+ $r = q("UPDATE `contact` SET
+ `photo` = '%s',
+ `thumb` = '%s',
+ `micro` = '%s',
+ `rel` = %d,
+ `name-date` = '%s',
+ `uri-date` = '%s',
+ `avatar-date` = '%s',
+ `blocked` = 0,
+ `pending` = 0,
+ WHERE `id` = %d LIMIT 1
+ ",
+ dbesc($photos[0]),
+ dbesc($photos[1]),
+ dbesc($photos[2]),
+ intval($new_relation),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ intval($contact_record['id'])
+ );
+
+ $u = q("select * from user where id = %d limit 1",intval($importer['uid']));
+ if($u)
+ $ret = diaspora_share($u[0],$contact_record);
+ }
return;
}
@@ -1235,6 +1286,8 @@ function diaspora_conversation($importer,$xml,$msg) {
'source_name' => $person['name'],
'source_link' => $person['url'],
'source_photo' => $person['thumb'],
+ 'verb' => ACTIVITY_POST,
+ 'otype' => 'mail'
));
}
@@ -1732,27 +1785,6 @@ function diaspora_profile($importer,$xml) {
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function diaspora_share($me,$contact) {
$a = get_app();
$myaddr = $me['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
diff --git a/include/enotify.php b/include/enotify.php
index f6f291e5d..9df9b57e5 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -65,6 +65,19 @@ function notification($params) {
$itemlink = $params['link'];
}
+ if($params['type'] == NOTIFY_SUGGEST) {
+ $subject = sprintf( t('Friend suggestion received at %s'), $sitename);
+ $preamble = sprintf( t('You\'ve received a friend suggestion from \'%s\' at %s'), $params['source_name'], $sitename);
+ $body = t('Name:') . ' ' . $params['item']['name'] . "\n";
+ $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n";
+ $body .= sprintf( t('You may visit their profile at %s'),$params['item']['url']);
+
+ $sitelink = t('Please visit %s to approve or reject the suggestion.');
+ $tsitelink = sprintf( $sitelink, $siteurl );
+ $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
+ $itemlink = $params['link'];
+ }
+
if($params['type'] == NOTIFY_CONFIRM) {
}
diff --git a/include/items.php b/include/items.php
index 9becb9ffb..0bd77582a 100644
--- a/include/items.php
+++ b/include/items.php
@@ -945,10 +945,15 @@ function tgroup_deliver($uid,$item_id) {
$link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
- $cnt = preg_match_all('/\@\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
+ // Diaspora uses their own hardwired link URL in @-tags
+ // instead of the one we supply with webfinger
+
+ $dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']);
+
+ $cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
- if(link_compare($link,$mtch[1])) {
+ if(link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) {
$deliver_to_tgroup = true;
logger('tgroup_deliver: local group mention found: ' . $mtch[2]);
}
@@ -1788,7 +1793,20 @@ function local_delivery($importer,$data) {
intval(0)
);
- // TODO - send email notify (which may require a new notification preference)
+ notification(array(
+ 'type' => NOTIFY_SUGGEST,
+ 'notify_flags' => $importer['notify-flags'],
+ 'language' => $importer['language'],
+ 'to_name' => $importer['username'],
+ 'to_email' => $importer['email'],
+ 'item' => $fsugg,
+ 'link' => $a->get_baseurl() . '/notifications/intros',
+ 'source_name' => $importer['name'],
+ 'source_link' => $importer['url'],
+ 'source_photo' => $importer['photo'],
+ 'verb' => ACTIVITY_REQ_FRIEND,
+ 'otype' => 'intro'
+ ));
return 0;
}
@@ -1836,6 +1854,8 @@ function local_delivery($importer,$data) {
'source_name' => $msg['from-name'],
'source_link' => $importer['url'],
'source_photo' => $importer['thumb'],
+ 'verb' => ACTIVITY_POST,
+ 'otype' => 'mail'
);
notification($notif_params);
@@ -2107,7 +2127,10 @@ function local_delivery($importer,$data) {
'source_name' => stripslashes($datarray['author-name']),
'source_link' => $datarray['author-link'],
'source_photo' => ((link_compare($datarray['author-link'],$importer['url']))
- ? $importer['thumb'] : $datarray['author-avatar'])
+ ? $importer['thumb'] : $datarray['author-avatar']),
+ 'verb' => ACTIVITY_POST,
+ 'otype' => 'item'
+
));
}
@@ -2223,7 +2246,10 @@ function local_delivery($importer,$data) {
'source_name' => stripslashes($datarray['author-name']),
'source_link' => $datarray['author-link'],
'source_photo' => ((link_compare($datarray['author-link'],$importer['url']))
- ? $importer['thumb'] : $datarray['author-avatar'])
+ ? $importer['thumb'] : $datarray['author-avatar']),
+ 'verb' => ACTIVITY_POST,
+ 'otype' => 'item'
+
));
break;
diff --git a/include/text.php b/include/text.php
index f32aaad07..1db88ca2c 100644
--- a/include/text.php
+++ b/include/text.php
@@ -678,7 +678,7 @@ function smilies($s) {
$a = get_app();
$s = str_replace(
- array( '&lt;3', '&lt;/3', '&lt;\\3', ':-)', ':)', ';-)', ':-(', ':(', ':-P', ':P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O', '\\o/',
+ array( '&lt;3', '&lt;/3', '&lt;\\3', ':-)', ':)', ';-)', ':-(', ':(', ':-P', ':P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O', '\\o/', 'o.O', 'O.o',
'~friendika', '~friendica', 'Diaspora*' ),
array(
'<img src="' . $a->get_baseurl() . '/images/smiley-heart.gif" alt="<3" />',
@@ -698,6 +698,8 @@ function smilies($s) {
'<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-|" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-O" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-thumbsup.gif" alt="\\o/" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="o.O" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="O.o" />',
'<a href="http://project.friendika.com">~friendika <img src="' . $a->get_baseurl() . '/images/friendika-16.png" alt="~friendika" /></a>',
'<a href="http://friendica.com">~friendica <img src="' . $a->get_baseurl() . '/images/friendika-16.png" alt="~friendica" /></a>',
'<a href="http://diasporafoundation.org">Diaspora<img src="' . $a->get_baseurl() . '/images/diaspora.png" alt="Diaspora*" /></a>',