From 3174847de80600be5e0bf32864edca79388d6433 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 10 Oct 2011 01:03:34 -0700 Subject: bug #177 - birthday month on profile incorrect if October or later and no year --- include/profile_advanced.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/profile_advanced.php b/include/profile_advanced.php index 22e035fe6..41ad322b2 100644 --- a/include/profile_advanced.php +++ b/include/profile_advanced.php @@ -48,7 +48,7 @@ $short_bd_format = t('j F'); $o .= '
' . ((intval($a->profile['dob'])) ? day_translate(datetime_convert('UTC','UTC',$a->profile['dob'] . ' 00:00 +00:00',$year_bd_format)) - : day_translate(datetime_convert('UTC','UTC','2001-' . substr($a->profile['dob'],6) . ' 00:00 +00:00',$short_bd_format))) + : day_translate(datetime_convert('UTC','UTC','2001-' . substr($a->profile['dob'],5) . ' 00:00 +00:00',$short_bd_format))) . "
\r\n"; $o .= '
'; -- cgit v1.2.3 From 557a7d0cec31a36d12898429c479c71671833dfd Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 11 Oct 2011 18:24:37 -0700 Subject: stuff - background the external network notifications (Facebook, Twitter, Statusnet) - add vimeo support - consolidate editor video options (insert video, regardless of source) - add "Connector Settings" page purely for configuring connectors - moved mailbox settings to Connectors - Move the "Connect/Follow" dialogue out of "find people" and move to top. - Add "Find People" dialogue - minor theme edits on duepuntozero and testbubble to make all this stuff work - A bit of theming on duepunto notifications to eliminate the gigantic Diaspora profile photos. --- include/api.php | 6 +----- include/bbcode.php | 3 +++ include/conversation.php | 10 ++++------ include/items.php | 19 +++---------------- include/notifier.php | 6 ++++++ include/text.php | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 51 insertions(+), 27 deletions(-) (limited to 'include') diff --git a/include/api.php b/include/api.php index 74b4aaf6e..1334d8eae 100644 --- a/include/api.php +++ b/include/api.php @@ -483,11 +483,7 @@ $txt = requestdata('htmlstatus'); if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) { - $txt = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', - '[youtube]$1[/youtube]', $txt); - - $txt = preg_replace('#].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?#s', - '[youtube]$1[/youtube]', $txt); + $txt = html2bb_video($txt); $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); diff --git a/include/bbcode.php b/include/bbcode.php index 9abc7c439..b33be686e 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -141,6 +141,9 @@ function bbcode($Text,$preserve_nl = false) { $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $Text); } + $Text = preg_replace("/\[vimeo\]https?:\/\/player.vimeo.com\/video\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text); + $Text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text); + $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $Text); // $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '', $Text); diff --git a/include/conversation.php b/include/conversation.php index 18f6d080b..29fa77902 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -745,9 +745,8 @@ function status_editor($a,$x, $notes_cid = 0) { '$nickname' => $x['nickname'], '$ispublic' => t('Visible to everybody'), '$linkurl' => t('Please enter a link URL:'), - '$utubeurl' => t('Please enter a YouTube link:'), - '$vidurl' => t("Please enter a video\x28.ogg\x29 link/URL:"), - '$audurl' => t("Please enter an audio\x28.ogg\x29 link/URL:"), + '$vidurl' => t("Please enter a video link/URL:"), + '$audurl' => t("Please enter an audio link/URL:"), '$whereareu' => t('Where are you right now?'), '$title' => t('Enter a title for this item') )); @@ -795,9 +794,8 @@ function status_editor($a,$x, $notes_cid = 0) { '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$weblink' => t('Insert web link'), - '$youtube' => t('Insert YouTube video'), - '$video' => t('Insert Vorbis [.ogg] video'), - '$audio' => t('Insert Vorbis [.ogg] audio'), + '$video' => t('Insert video link'), + '$audio' => t('Insert audio link'), '$setloc' => t('Set your location'), '$noloc' => t('Clear browser location'), '$title' => t('Set title'), diff --git a/include/items.php b/include/items.php index 8360a42ec..4862ca578 100644 --- a/include/items.php +++ b/include/items.php @@ -414,11 +414,7 @@ function get_atom_elements($feed,$item) { if((strpos($res['body'],'<') !== false) || (strpos($res['body'],'>') !== false)) { - $res['body'] = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', - '[youtube]$1[/youtube]', $res['body']); - - $res['body'] = preg_replace('#].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?#s', - '[youtube]$1[/youtube]', $res['body']); + $res['body'] = html2bb_video($res['body']); $res['body'] = oembed_html2bbcode($res['body']); @@ -586,12 +582,7 @@ function get_atom_elements($feed,$item) { $res['object'] .= '' . xmlify($body) . '' . "\n"; if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) { - $body = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', - '[youtube]$1[/youtube]', $body); - - $res['body'] = preg_replace('#].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?#s', - '[youtube]$1[/youtube]', $res['body']); - + $body = html2bb_video($body); $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); @@ -629,11 +620,7 @@ function get_atom_elements($feed,$item) { $res['object'] .= '' . xmlify($body) . '' . "\n"; if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) { - $body = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', - '[youtube]$1[/youtube]', $body); - - $res['body'] = preg_replace('#].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?#s', - '[youtube]$1[/youtube]', $res['body']); + $body = html2bb_video($body); $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); diff --git a/include/notifier.php b/include/notifier.php index 90111600a..9dc524585 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -779,6 +779,12 @@ function notifier_run($argv, $argc){ } + if($normal_mode) + call_hooks('notifier_normal',$target_item); + + call_hooks('notifier_end',$target_item); + + return; } diff --git a/include/text.php b/include/text.php index fd413b7d6..299410a63 100644 --- a/include/text.php +++ b/include/text.php @@ -1003,3 +1003,37 @@ if (!function_exists('str_getcsv')) { } } } + +function cleardiv() { + return '
'; +} + + +function bb_translate_video($s) { + + $matches = null; + $r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER); + if($r) { + foreach($matches as $mtch) { + if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be'))) + $s = str_replace($mtch[0],'[youtube]' . $mtch[1] . '[/youtube]',$s); + elseif(stristr($mtch[1],'vimeo')) + $s = str_replace($mtch[0],'[vimeo]' . $mtch[1] . '[/vimeo]',$s); + } + } + return $s; +} + +function html2bb_video($s) { + + $s = preg_replace('#]+>(.*?)https+://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+)(.*?)#ism', + '[youtube]$2[/youtube]', $s); + + $s = preg_replace('#](.*?)https+://www.youtube.com/embed/([A-Za-z0-9\-_=]+)(.*?)#ism', + '[youtube]$2[/youtube]', $s); + + $s = preg_replace('#](.*?)https+://player.vimeo.com/video/([0-9]+)(.*?)#ism', + '[vimeo]$2[/vimeo]', $s); + + return $s; +} \ No newline at end of file -- cgit v1.2.3 From 2206d894b3fec7064b91e0420bcc2b16e9e7009b Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 11 Oct 2011 19:27:58 -0700 Subject: add contact_widgets and provide widgets on appropriate pages, fix the saved search widget fix directory page on testbubble, don't use system theme for community, directory, and search if the viewer is logged in. --- include/contact_widgets.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 include/contact_widgets.php (limited to 'include') diff --git a/include/contact_widgets.php b/include/contact_widgets.php new file mode 100644 index 000000000..efb833aaf --- /dev/null +++ b/include/contact_widgets.php @@ -0,0 +1,40 @@ + t('Add New Contact'), + '$desc' => t('Enter address or web location'), + '$hint' => t('Example: bob@example.com, http://example.com/barbara'), + '$follow' => t('Connect') + )); + +} + +function findpeople_widget() { + + $a = get_app(); + + $inv = (($a->config['register_policy'] != REGISTER_CLOSED) ? t('Invite Friends') : ''); + + if(get_config('system','invitation_only')) { + $x = get_pconfig(local_user(),'system','invites_remaining'); + if($x || is_site_admin()) { + $a->page['aside'] .= '' . $inv; + } + } + + return replace_macros(get_markup_template('peoplefind.tpl'),array( + '$findpeople' => t('Find People'), + '$desc' => t('Enter name or interest'), + '$label' => t('Connect/Follow'), + '$hint' => t('Examples: Robert Morgenstein, Fishing'), + '$findthem' => t('Find'), + '$similar' => t('Similar Interests'), + '$inv' => $inv + )); + +} + -- cgit v1.2.3 From 3ef7dcac4b84f6f78dcba5cd768fc08f9cfc1067 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 11 Oct 2011 20:38:09 -0700 Subject: solve intro/notify naming issue by providing both or either, theme decides what to do --- include/nav.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index 600043ee5..5c24df51e 100644 --- a/include/nav.php +++ b/include/nav.php @@ -114,7 +114,9 @@ function nav(&$a) { /* only show friend requests for normal pages. Other page types have automatic friendship. */ if($_SESSION['page_flags'] == PAGE_NORMAL) { - $nav['notifications'] = array('notifications/network', t('Notifications'), "", t('Notifications')); + $nav['introductions'] = array('notifications/intros', t('Introductions'), "", t('Friend Requests')); + $nav['notifications'] = array('notifications', t('Notifications'), "", t('Notifications')); + } $nav['messages'] = array('message', t('Messages'), "", t('Private mail')); @@ -175,6 +177,7 @@ function nav_set_selected($item){ 'network' => null, 'home' => null, 'profiles' => null, + 'introductions' => null, 'notifications' => null, 'messages' => null, 'directory' => null, -- cgit v1.2.3 From 3db43d5a39813f852bad8f4fe90e4c27400b7fae Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 12 Oct 2011 02:21:18 -0700 Subject: storage race condition --- include/items.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 4862ca578..2c23c6f1b 100644 --- a/include/items.php +++ b/include/items.php @@ -677,7 +677,7 @@ function item_store($arr,$force_parent = false) { if($arr['gravity']) $arr['gravity'] = intval($arr['gravity']); - elseif($arr['parent-uri'] == $arr['uri']) + elseif($arr['parent-uri'] === $arr['uri']) $arr['gravity'] = 0; elseif(activity_match($arr['verb'],ACTIVITY_POST)) $arr['gravity'] = 6; @@ -744,7 +744,7 @@ function item_store($arr,$force_parent = false) { // find the parent and snarf the item id and ACL's // and anything else we need to inherit - $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC LIMIT 1", dbesc($arr['parent-uri']), intval($arr['uid']) ); @@ -758,7 +758,8 @@ function item_store($arr,$force_parent = false) { if($r[0]['uri'] != $r[0]['parent-uri']) { $arr['thr-parent'] = $arr['parent-uri']; $arr['parent-uri'] = $r[0]['parent-uri']; - $z = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `parent-uri` = '%s' AND `uid` = %d LIMIT 1", + $z = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `parent-uri` = '%s' AND `uid` = %d + ORDER BY `id` ASC LIMIT 1", dbesc($r[0]['parent-uri']), dbesc($r[0]['parent-uri']), intval($arr['uid']) @@ -796,7 +797,7 @@ function item_store($arr,$force_parent = false) { $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($arr['uri']), - dbesc($arr['uid']) + intval($arr['uid']) ); if($r && count($r)) { logger('item-store: duplicate item ignored. ' . print_r($arr,true)); @@ -817,14 +818,14 @@ function item_store($arr,$force_parent = false) { // find the item we just created - $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1 ORDER BY `id` ASC", $arr['uri'], // already dbesc'd intval($arr['uid']) ); if(! count($r)) { // This is not good, but perhaps we encountered a rare race/cache condition, so back off and try again. sleep(3); - $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1 ORDER BY `id` ASC", $arr['uri'], // already dbesc'd intval($arr['uid']) ); @@ -838,6 +839,14 @@ function item_store($arr,$force_parent = false) { logger('item_store: could not locate created item'); return 0; } + if(count($r) > 1) { + logger('item_store: duplicated post occurred. Removing duplicates.'); + q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `id` != %d ", + $arr['uri'], + intval($arr['uid']), + intval($current_post) + ); + } if((! $parent_id) || ($arr['parent-uri'] === $arr['uri'])) $parent_id = $current_post; @@ -2398,8 +2407,8 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { if(strlen($item['owner-name'])) $o .= atom_author('dfrn:owner',$item['owner-name'],$item['owner-link'],80,80,$item['owner-avatar']); - if($item['parent'] != $item['id']) - $o .= '' . "\r\n"; + if(($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri'])) + $o .= '' . "\r\n"; $o .= '' . xmlify($item['uri']) . '' . "\r\n"; $o .= '' . xmlify($item['title']) . '' . "\r\n"; -- cgit v1.2.3 From 2911bf9434cb1a061ff32d41894ee0dd09ed3993 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 13 Oct 2011 01:00:06 -0700 Subject: sql issue item_store --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 2c23c6f1b..36851b01f 100644 --- a/include/items.php +++ b/include/items.php @@ -818,14 +818,14 @@ function item_store($arr,$force_parent = false) { // find the item we just created - $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1 ORDER BY `id` ASC", + $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC LIMIT 1", $arr['uri'], // already dbesc'd intval($arr['uid']) ); if(! count($r)) { // This is not good, but perhaps we encountered a rare race/cache condition, so back off and try again. sleep(3); - $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1 ORDER BY `id` ASC", + $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC LIMIT 1", $arr['uri'], // already dbesc'd intval($arr['uid']) ); -- cgit v1.2.3 From 4eae1e5d8a37f206177c8eeb379c0f32aa84d5ab Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 13 Oct 2011 15:32:43 -0700 Subject: don't propagate deletions for other people's stuff --- include/notifier.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/notifier.php b/include/notifier.php index 9dc524585..bbddee109 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -192,6 +192,8 @@ function notifier_run($argv, $argc){ // be notified during this run. // Other DFRN conversation members will be alerted during polled updates. + + // Diaspora members currently are not notified of expirations, and other networks have // either limited or no ability to process deletions. We should at least fix Diaspora // by stringing togther an array of retractions and sending them onward. @@ -210,6 +212,7 @@ function notifier_run($argv, $argc){ */ if((! $top_level) && ($parent['wall'] == 0) && (! $expire) && (stristr($target_item['uri'],$localhost))) { + logger('notifier: followup', LOGGER_DEBUG); // local followup to remote post $followup = true; $public_message = false; // not public @@ -218,6 +221,13 @@ function notifier_run($argv, $argc){ else { $followup = false; + // don't send deletions onward for other people's stuff + + if($target_item['deleted'] && (! intval($target_item['wall']))) { + logger('notifier: ignoring delete notification for non-wall item'); + return; + } + if((strlen($parent['allow_cid'])) || (strlen($parent['allow_gid'])) || (strlen($parent['deny_cid'])) @@ -357,6 +367,7 @@ function notifier_run($argv, $argc){ if(($public_message) && $item['private']) continue; + $contact = get_item_contact($item,$contacts); if(! $contact) -- cgit v1.2.3 From 89c771a26e2eca3af8de82a5d57ce05d663ff6d5 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 13 Oct 2011 15:39:05 -0700 Subject: remove queued items for contact when removing contact --- include/Contact.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 45920041e..45fd368d8 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -46,6 +46,10 @@ function contact_remove($id) { q("DELETE FROM `event` WHERE `cid` = %d ", intval($id) ); + q("DELETE FROM `queue` WHERE `cid` = %d ", + intval($id) + ); + } -- cgit v1.2.3 From 05e26e489580c82d0db237771d159aed287c5f9b Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 13 Oct 2011 18:32:02 -0700 Subject: handle diaspora profile update message --- include/diaspora.php | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index 968aa2fd2..7207daf0c 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -38,6 +38,9 @@ function diaspora_dispatch($importer,$msg) { elseif($xmlbase->status_message) { $ret = diaspora_post($importer,$xmlbase->status_message); } + elseif($xmlbase->profile) { + $ret = diaspora_profile($importer,$xmlbase->profile); + } elseif($xmlbase->comment) { $ret = diaspora_comment($importer,$xmlbase->comment,$msg); } @@ -994,6 +997,81 @@ function diaspora_retraction($importer,$xml) { return 202; // NOTREACHED } + +function diaspora_profile($importer,$xml) { + + $a = get_app(); + $diaspora_handle = notags(unxmlify($xml->diaspora_handle)); + + $contact = diaspora_get_contact_by_handle($importer['uid'],$diaspora_handle); + if(! $contact) + return; + + if($contact['blocked']) { + logger('diaspora_post: Ignoring this author.'); + return 202; + } + + $name = unxmlify($xml->first_name) . ((strlen($xml->last_name)) ? ' ' . unxmlify($xml->last_name) : ''); + $image_url = unxmlify($xml->image_url); + $birthday = unxmlify($xml->birthday); + + $r = q("SELECT DISTINCT ( `resource-id` ) FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `album` = 'Contact Photos' ", + intval($importer['uid']), + intval($contact['id']) + ); + $oldphotos = ((count($r)) ? $r : null); + + $images = import_profile_photo($image_url,$importer['uid'],$contact['id']); + + // TODO handle birthdays - even though we don't know the original timezone (grrr.) + + $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", + dbesc($name), + dbesc(datetime_convert()), + dbesc($images[0]), + dbesc($images[1]), + dbesc($images[2]), + dbesc(datetime_convert()), + intval($contact['id']), + intval($importer['uid']) + ); + if($r) { + if($oldphotos) { + foreach($oldphotos as $ph) { + q("DELETE FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `album` = 'Contact Photos' AND `resource-id` = '%s' ", + intval($importer['uid']), + intval($contact['id']), + dbesc($ph['resource-id']) + ); + } + } + } + + return; + +} + + + + + + + + + + + + + + + + + + + + + function diaspora_share($me,$contact) { $a = get_app(); -- cgit v1.2.3 From af6ab381000346f487d1b5b07623510640dd7ee5 Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 14 Oct 2011 00:20:37 -0700 Subject: diaspora birthday notifications --- include/datetime.php | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/diaspora.php | 9 ++++++--- include/poller.php | 5 ++++- 3 files changed, 64 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/datetime.php b/include/datetime.php index 3033b88af..087e6cb20 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -393,3 +393,57 @@ function cal($y = 0,$m = 0, $links = false, $class='') { return $o; }} + + +function update_contact_birthdays() { + + // This only handles foreign or alien networks where a birthday has been provided. + // In-network birthdays are handled within local_delivery + + $r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` "); + if(count($r)) { + foreach($r as $rr) { + + logger('update_contact_birthday: ' . $rr['bd']); + + $nextbd = datetime_convert('UTC','UTC','now','Y') . substr($rr['bd'],4); + + /** + * + * Add new birthday event for this person + * + * $bdtext is just a readable placeholder in case the event is shared + * with others. We will replace it during presentation to our $importer + * to contain a sparkle link and perhaps a photo. + * + */ + + $bdtext = t('Birthday:') . ' [url=' . $rr['url'] . ']' . $rr['name'] . '[/url]' ; + + + $r = q("INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`desc`,`type`,`adjust`) + VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%d' ) ", + intval($rr['uid']), + intval($rr['id']), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc(datetime_convert('UTC','UTC', $nextbd)), + dbesc(datetime_convert('UTC','UTC', $nextbd . ' + 1 day ')), + dbesc($bdtext), + dbesc('birthday'), + intval(0) + ); + + + // update bdyear + + q("UPDATE `contact` SET `bdyear` = '%s', `bd` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", + dbesc(substr($nextbd,0,4)), + dbesc($nextbd), + intval($rr['uid']), + intval($rr['id']) + ); + + } + } +} \ No newline at end of file diff --git a/include/diaspora.php b/include/diaspora.php index 7207daf0c..2d9e2883d 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1024,9 +1024,11 @@ function diaspora_profile($importer,$xml) { $images = import_profile_photo($image_url,$importer['uid'],$contact['id']); - // TODO handle birthdays - even though we don't know the original timezone (grrr.) + // Generic birthday. We don't know the timezone. The year is irrelevant. - $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", + $birthday = datetime_convert('UTC','UTC',$birthday,'Y-m-d'); + + $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", dbesc($name), dbesc(datetime_convert()), dbesc($images[0]), @@ -1034,7 +1036,8 @@ function diaspora_profile($importer,$xml) { dbesc($images[2]), dbesc(datetime_convert()), intval($contact['id']), - intval($importer['uid']) + intval($importer['uid']), + dbesc($birthday) ); if($r) { if($oldphotos) { diff --git a/include/poller.php b/include/poller.php index 427f8887c..cef0647b5 100644 --- a/include/poller.php +++ b/include/poller.php @@ -50,12 +50,15 @@ function poller_run($argv, $argc){ - // once daily run expire in background + // once daily run birthday_updates and then expire in background $d1 = get_config('system','last_expire_day'); $d2 = intval(datetime_convert('UTC','UTC','now','d')); if($d2 != intval($d1)) { + + update_contact_birthdays(); + set_config('system','last_expire_day',$d2); proc_run('php','include/expire.php'); } -- cgit v1.2.3 From 5dcc10a5d9d2be79070716fbcaf5c054f7ed9efa Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 15 Oct 2011 03:26:37 -0700 Subject: working on long-term solution to relay issue --- include/items.php | 18 +++++++----------- include/notifier.php | 11 +++++++++-- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 36851b01f..0c3c8b1d7 100644 --- a/include/items.php +++ b/include/items.php @@ -818,18 +818,10 @@ function item_store($arr,$force_parent = false) { // find the item we just created - $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC LIMIT 1", + $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC ", $arr['uri'], // already dbesc'd intval($arr['uid']) ); - if(! count($r)) { - // This is not good, but perhaps we encountered a rare race/cache condition, so back off and try again. - sleep(3); - $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC LIMIT 1", - $arr['uri'], // already dbesc'd - intval($arr['uid']) - ); - } if(count($r)) { $current_post = $r[0]['id']; @@ -1873,13 +1865,14 @@ function local_delivery($importer,$data) { $r = q("select `item`.`id`, `contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - WHERE `contact`.`self` = 1 AND `item`.`wall` = 1 AND `item`.`uri` = '%s' AND `item`.`uid` = %d LIMIT 1", + WHERE `contact`.`self` = 1 AND `item`.`wall` = 1 AND `item`.`uri` = '%s' AND `item`.`parent-uri` = '%s' + AND `item`.`uid` = %d LIMIT 1", + dbesc($parent_uri), dbesc($parent_uri), intval($importer['importer_uid']) ); if($r && count($r)) { - logger('local_delivery: received remote comment'); $is_like = false; // remote reply to our post. Import and then notify everybody else. @@ -2388,6 +2381,9 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { $a = get_app(); + if(! $item['parent']) + return; + if($item['deleted']) return '' . "\r\n"; diff --git a/include/notifier.php b/include/notifier.php index bbddee109..18ad07012 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -142,7 +142,7 @@ function notifier_run($argv, $argc){ $item['deleted'] = 1; } - if((count($items) == 1) && ($items[0]['uri'] === $items[0]['parent-uri'])) { + if((count($items) == 1) && ($items[0]['id'] === $target_item['id']) && ($items[0]['uri'] === $items[0]['parent-uri'])) { logger('notifier: top level post'); $top_level = true; } @@ -205,13 +205,20 @@ function notifier_run($argv, $argc){ /** * - * Be VERY CAREFUL if you make any changes to the following line. Seemingly innocuous changes + * Be VERY CAREFUL if you make any changes to the following lines. Seemingly innocuous changes * have been known to cause runaway conditions which affected several servers, along with * permissions issues. * */ + $relay_to_owner = false; + if((! $top_level) && ($parent['wall'] == 0) && (! $expire) && (stristr($target_item['uri'],$localhost))) { + $relay_to_owner = true; + } + + + if($relay_to_owner) { logger('notifier: followup', LOGGER_DEBUG); // local followup to remote post $followup = true; -- cgit v1.2.3