From c583d1620955b8d170b8cbf7a106cefeecad56c8 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Jan 2012 14:27:00 -0800 Subject: fix reference variable effects on sorting --- include/conversation.php | 10 +++++++--- include/items.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index f4432bfd9..1b1d09d6b 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -911,9 +911,13 @@ function conv_sort($arr,$order) { $parents[$p]['children'][] = $x; } } - foreach($parents as $x) - if(count($x['children'])) - usort($x['children'],'sort_thr_created_rev'); + 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) { diff --git a/include/items.php b/include/items.php index 9becb9ffb..7f003ab57 100644 --- a/include/items.php +++ b/include/items.php @@ -945,7 +945,7 @@ 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); + $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])) { -- cgit v1.2.3 From 969cd145ce0e717399dbfff6cbc1a45342206e1a Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Jan 2012 17:29:07 -0800 Subject: suggestion notifications --- include/conversation.php | 35 +++++++++++++++++++++-------------- include/enotify.php | 13 +++++++++++++ include/items.php | 13 ++++++++++++- 3 files changed, 46 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 1b1d09d6b..a30a78271 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -902,29 +902,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 $k => $v) { - if(count($parents[$k]['children'])) { - $y = $parents[$k]['children']; - usort($y,'sort_thr_created_rev'); - $parents[$k]['children'] = $y; - } + 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; @@ -947,4 +953,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/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, '' . $sitename . ''); + $itemlink = $params['link']; + } + if($params['type'] == NOTIFY_CONFIRM) { } diff --git a/include/items.php b/include/items.php index 7f003ab57..9f006306f 100644 --- a/include/items.php +++ b/include/items.php @@ -1788,7 +1788,18 @@ 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'] + )); return 0; } -- cgit v1.2.3 From fc7d0360bb059bf87c5c531a2bfd5bcee3aef3f6 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Jan 2012 20:26:20 -0800 Subject: add verb and item to notifications to aid in localisation --- include/diaspora.php | 2 ++ include/items.php | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index 2d139c77c..25ca11ed0 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1235,6 +1235,8 @@ function diaspora_conversation($importer,$xml,$msg) { 'source_name' => $person['name'], 'source_link' => $person['url'], 'source_photo' => $person['thumb'], + 'verb' => ACTIVITY_POST, + 'otype' => 'mail' )); } diff --git a/include/items.php b/include/items.php index 9f006306f..a63468d92 100644 --- a/include/items.php +++ b/include/items.php @@ -1798,7 +1798,9 @@ function local_delivery($importer,$data) { 'link' => $a->get_baseurl() . '/notifications/intros', 'source_name' => $importer['name'], 'source_link' => $importer['url'], - 'source_photo' => $importer['photo'] + 'source_photo' => $importer['photo'], + 'verb' => ACTIVITY_REQ_FRIEND, + 'otype' => 'intro' )); return 0; @@ -1847,6 +1849,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); @@ -2118,7 +2122,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' + )); } @@ -2234,7 +2241,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; -- cgit v1.2.3 From 48a5a2484e762a9804237ae28c24dafe5db7f953 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Jan 2012 00:04:19 -0800 Subject: new smiley --- include/text.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') 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( '<3', '</3', '<\\3', ':-)', ':)', ';-)', ':-(', ':(', ':-P', ':P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O', '\\o/', + array( '<3', '</3', '<\\3', ':-)', ':)', ';-)', ':-(', ':(', ':-P', ':P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O', '\\o/', 'o.O', 'O.o', '~friendika', '~friendica', 'Diaspora*' ), array( '<3', @@ -698,6 +698,8 @@ function smilies($s) { '8-|', '8-O', '\\o/', + 'o.O', + 'O.o', '~friendika ~friendika', '~friendica ~friendica', 'DiasporaDiaspora*', -- cgit v1.2.3 From c1cf6e48c225725c380472e1f730f6dc02917ecd Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Jan 2012 13:50:12 -0800 Subject: Allow Diaspora to post to forums --- include/items.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index a63468d92..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']); + // 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]); } -- cgit v1.2.3 From d0b743529d5f0034e08456473fe32e38c7144f74 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Jan 2012 14:30:25 -0800 Subject: support auto-friend page types for Diaspora --- include/diaspora.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index 25ca11ed0..f32113668 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,45 @@ 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']) + ); + } return; } -- cgit v1.2.3 From 47edaf9ad79b59d96f908b4501d564e5e63cc210 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Jan 2012 18:03:09 -0800 Subject: dynamic title input box - via fabrixxm --- include/conversation.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index a30a78271..ec1fd4152 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -812,7 +812,8 @@ function status_editor($a,$x, $notes_cid = 0) { '$audurl' => t("Please enter an audio link/URL:"), '$term' => t('Tag term:'), '$whereareu' => t('Where are you right now?'), - '$title' => t('Enter a title for this item') + '$title' => t('Enter a title for this item'), + '$addtitle' => t('click here to add a title') )); @@ -880,6 +881,8 @@ function status_editor($a,$x, $notes_cid = 0) { '$acl' => $x['acl'], '$bang' => $x['bang'], '$profile_uid' => $x['profile_uid'], + '$addtitle' => t('click here to add a title') + )); return $o; -- cgit v1.2.3 From 5b809328af800e73990e7a056d2a6d883a67bd25 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Jan 2012 13:25:43 -0800 Subject: send diaspora share notification back to originator for auto friending --- include/diaspora.php | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index f32113668..5a19400da 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -610,6 +610,10 @@ function diaspora_request($importer,$xml) { 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; @@ -1781,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); -- cgit v1.2.3