From 6274c3977d25a1ca9313cc851230b9b520bd4197 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 8 Apr 2010 13:12:14 -0700 Subject: [PATCH 1/8] In single-user mode, link #hashtags to the user's tagged stream rather than the global tag action, which isn't registered. Previously they would end up pointing to the home URL. --- lib/util.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/util.php b/lib/util.php index 7959978683..e37df63484 100644 --- a/lib/util.php +++ b/lib/util.php @@ -862,7 +862,14 @@ function common_xml_safe_str($str) function common_tag_link($tag) { $canonical = common_canonical_tag($tag); - $url = common_local_url('tag', array('tag' => $canonical)); + if (common_config('singleuser', 'enabled')) { + // regular TagAction isn't set up in 1user mode + $url = common_local_url('showstream', + array('nickname' => common_config('singleuser', 'nickname'), + 'tag' => $canonical)); + } else { + $url = common_local_url('tag', array('tag' => $canonical)); + } $xs = new XMLStringer(); $xs->elementStart('span', 'tag'); $xs->element('a', array('href' => $url, From 05e373d29b91cf929d0ac2ad74a90dce264df022 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 8 Apr 2010 17:05:02 -0700 Subject: [PATCH 2/8] scripts/strip_geo.php to remove geodata from notices by a given user/profile. May be slow or run out of memory if run on particularly prolific posters -- not yet optimized for that case. Note that geodata that has already been sent out to other services (via ostatus, omb, twitter, etc) will not be removed from them. (fixed version -- previous had accidentally undone another commit) --- scripts/strip_geo.php | 116 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100755 scripts/strip_geo.php diff --git a/scripts/strip_geo.php b/scripts/strip_geo.php new file mode 100755 index 0000000000..010fb31f54 --- /dev/null +++ b/scripts/strip_geo.php @@ -0,0 +1,116 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'i::n::y'; +$longoptions = array('id=', 'nickname=', 'yes', 'dry-run'); + +$helptext = <<getProfile(); +} else { + print "You must provide either an ID or a nickname.\n\n"; + show_help(); + exit(1); +} + +if (!have_option('y', 'yes') && !have_option('--dry-run')) { + print "About to PERMANENTLY remove geolocation data from user '{$profile->nickname}' ({$profile->id})'s notices. Are you sure? [y/N] "; + $response = fgets(STDIN); + if (strtolower(trim($response)) != 'y') { + print "Aborting.\n"; + exit(0); + } +} + +// @fixme for a very prolific poster this could be too many. +print "Finding notices with geolocation data..."; +$notice = new Notice(); +$notice->profile_id = $profile->id; +$notice->whereAdd("lat != ''"); +$notice->find(); + +if ($notice->N) { + print " $notice->N found.\n"; + while ($notice->fetch()) { + print "notice id $notice->id "; + if (have_option('v') || have_option('--verbose')) { + print "({$notice->lat},{$notice->lon}) "; + if ($notice->location_ns) { + print "ns {$notice->location_ns} id {$notice->location_id} "; + } + } + if (have_option('--dry-run')) { + // sucka + echo "(skipped)"; + } else { + // note: setting fields to null and calling update() doesn't save the nulled fields + $orig = clone($notice); + $update = clone($notice); + + // In theory we could hit a chunk of notices at once in the UPDATE, + // but we're going to have to decache them individually anyway and + // it doesn't hurt to make sure we don't hold up replication with + // what might be a very slow single UPDATE. + $query = sprintf('UPDATE notice ' . + 'SET lat=NULL,lon=NULL,location_ns=NULL,location_id=NULL ' . + 'WHERE id=%d', $notice->id); + $ok = $update->query($query); + if ($ok) { + // And now we decache him manually, as query() doesn't know what we're doing... + $orig->blow(); + echo "(removed)"; + } else { + echo "(failed?)"; + } + } + print "\n"; + } +} else { + print " none found.\n"; +} + +print "DONE.\n"; From a93d0dc16af0438af59d14f8413dabb80c13b707 Mon Sep 17 00:00:00 2001 From: Christopher Vollick Date: Fri, 9 Apr 2010 06:03:53 -0400 Subject: [PATCH 3/8] Undefined Variable in foafgroup.php Probably just left over from the past. --- actions/foafgroup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/foafgroup.php b/actions/foafgroup.php index d685554ac4..07cca31811 100644 --- a/actions/foafgroup.php +++ b/actions/foafgroup.php @@ -56,7 +56,7 @@ class FoafGroupAction extends Action return false; } - $local = Local_group::staticGet('nickname', $nickname); + $local = Local_group::staticGet('nickname', $this->nickname); if (!$local) { $this->clientError(_('No such group.'), 404); From 7baf671570b1190c54c9b7e763fdaf0ab454b6a7 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 9 Apr 2010 08:36:13 -0700 Subject: [PATCH 4/8] Avoid E_NOTICE spew when listing group members who aren't admins --- actions/foafgroup.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/actions/foafgroup.php b/actions/foafgroup.php index 07cca31811..4db40c28be 100644 --- a/actions/foafgroup.php +++ b/actions/foafgroup.php @@ -126,7 +126,8 @@ class FoafGroupAction extends Action while ($members->fetch()) { $member_uri = common_local_url('userbyid', array('id'=>$members->id)); $member_details[$member_uri] = array( - 'nickname' => $members->nickname + 'nickname' => $members->nickname, + 'is_admin' => false, ); $this->element('member', array('rdf:resource' => $member_uri)); } From 41062d387f2e163fd023bbafadfcb10072c068ec Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 9 Apr 2010 08:56:43 -0700 Subject: [PATCH 5/8] Fix localization for license notice in page footer (for ticket #2274: i18n cleanup) --- lib/action.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/action.php b/lib/action.php index 09113a598e..0fc3a0dc43 100644 --- a/lib/action.php +++ b/lib/action.php @@ -845,14 +845,16 @@ class Action extends HTMLOutputter // lawsuit 'width' => '80', 'height' => '15')); $this->text(' '); - //TODO: This is dirty: i18n - $this->text(_('All '.common_config('site', 'name').' content and data are available under the ')); - $this->element('a', array('class' => 'license', - 'rel' => 'external license', - 'href' => common_config('license', 'url')), - common_config('license', 'title')); - $this->text(' '); - $this->text(_('license.')); + // TRANS: license message in footer. %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration. + $notice = _('All %1$s content and data are available under the %2$s license.'); + $link = "" . + htmlspecialchars(common_config('license', 'title')) . + ""; + $this->raw(sprintf(htmlspecialchars($notice), + htmlspecialchars(common_config('site', 'name')), + $link)); $this->elementEnd('p'); break; } From 9cb0dab27036b237f9f325dc14c417e23fd475f7 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 9 Apr 2010 10:46:18 -0700 Subject: [PATCH 6/8] Run block checks on remote OStatus replies --- classes/Notice.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/classes/Notice.php b/classes/Notice.php index be3e9ca2a6..b416e2ff28 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -964,11 +964,19 @@ class Notice extends Memcached_DataObject */ function saveKnownReplies($uris) { + if (empty($uris)) { + return; + } + $sender = Profile::staticGet($this->profile_id); + foreach ($uris as $uri) { $user = User::staticGet('uri', $uri); if (!empty($user)) { + if ($user->hasBlocked($sender)) { + continue; + } $reply = new Reply(); From 4e3fad4f0d20e843cf42c07026ecbdb5a566562a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 9 Apr 2010 14:11:18 -0400 Subject: [PATCH 7/8] fix attributes on homepage output --- actions/groupmembers.php | 4 ++++ actions/peopletag.php | 4 ++++ actions/subscribers.php | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/actions/groupmembers.php b/actions/groupmembers.php index fb4e46dbc0..e72ef371ac 100644 --- a/actions/groupmembers.php +++ b/actions/groupmembers.php @@ -240,9 +240,13 @@ class GroupMemberListItem extends ProfileListItem function homepageAttributes() { + $aAttrs = parent::linkAttributes(); + if (common_config('nofollow', 'members')) { $aAttrs['rel'] = 'nofollow'; } + + return $aAttrs; } } diff --git a/actions/peopletag.php b/actions/peopletag.php index 456cc21c4c..32652f7551 100644 --- a/actions/peopletag.php +++ b/actions/peopletag.php @@ -168,9 +168,13 @@ class PeopleTagListItem extends ProfileListItem function homepageAttributes() { + $aAttrs = parent::linkAttributes(); + if (common_config('nofollow', 'peopletag')) { $aAttrs['rel'] = 'nofollow'; } + + return $aAttrs; } } diff --git a/actions/subscribers.php b/actions/subscribers.php index 6dda7312d6..6f1520b3f4 100644 --- a/actions/subscribers.php +++ b/actions/subscribers.php @@ -177,8 +177,12 @@ class SubscribersListItem extends SubscriptionListItem function homepageAttributes() { + $aAttrs = parent::linkAttributes(); + if (common_config('nofollow', 'subscribers')) { $aAttrs['rel'] = 'nofollow'; } + + return $aAttrs; } } From b47fc9c0bcd9f37438d2aaeb7b5bc98183b554ea Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 9 Apr 2010 11:36:02 -0700 Subject: [PATCH 8/8] Fix for strip_geo's decaching; also added --all option to run over all notices by given profile to help in fixing up cache inconsistencies --- scripts/strip_geo.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/strip_geo.php b/scripts/strip_geo.php index 010fb31f54..b3f27be616 100755 --- a/scripts/strip_geo.php +++ b/scripts/strip_geo.php @@ -21,7 +21,7 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); $shortoptions = 'i::n::y'; -$longoptions = array('id=', 'nickname=', 'yes', 'dry-run'); +$longoptions = array('id=', 'nickname=', 'yes', 'dry-run', 'all'); $helptext = <<profile_id = $profile->id; -$notice->whereAdd("lat != ''"); +if (have_option('--all')) { + print "Finding all notices by $profile->nickname..."; +} else { + print "Finding notices by $profile->nickname with geolocation data..."; + $notice->whereAdd("lat != ''"); +} $notice->find(); if ($notice->N) { @@ -101,10 +107,10 @@ if ($notice->N) { $ok = $update->query($query); if ($ok) { // And now we decache him manually, as query() doesn't know what we're doing... - $orig->blow(); + $orig->decache(); echo "(removed)"; } else { - echo "(failed?)"; + echo "(unchanged?)"; } } print "\n";