diff --git a/actions/hcard.php b/actions/hcard.php deleted file mode 100644 index 6db2972b9d..0000000000 --- a/actions/hcard.php +++ /dev/null @@ -1,121 +0,0 @@ -. - * - * @category Personal - * @package StatusNet - * @author Evan Prodromou - * @copyright 2010 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 - * @link http://status.net/ - */ - -if (!defined('STATUSNET')) { - exit(1); -} - -/** - * User profile page - * - * @category Personal - * @package StatusNet - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 - * @link http://status.net/ - */ -class HcardAction extends Action -{ - var $user; - var $profile; - - function prepare($args) - { - parent::prepare($args); - - $nickname_arg = $this->arg('nickname'); - $nickname = common_canonical_nickname($nickname_arg); - - // Permanent redirect on non-canonical nickname - - if ($nickname_arg != $nickname) { - $args = array('nickname' => $nickname); - common_redirect(common_local_url('hcard', $args), 301); - return false; - } - - $this->user = User::staticGet('nickname', $nickname); - - if (!$this->user) { - // TRANS: Client error displayed when trying to get a user hCard for a non-existing user. - $this->clientError(_('No such user.'), 404); - return false; - } - - $this->profile = $this->user->getProfile(); - - if (!$this->profile) { - // TRANS: Error message displayed when referring to a user without a profile. - $this->serverError(_('User has no profile.')); - return false; - } - - return true; - } - - function handle($args) - { - parent::handle($args); - $this->showPage(); - } - - function title() - { - return $this->profile->getBestName(); - } - - function showContent() - { - $up = new ShortUserProfile($this, $this->user, $this->profile); - $up->show(); - } - - function showHeader() - { - return; - } - - function showAside() - { - return; - } - - function showSecondaryNav() - { - return; - } -} - -class ShortUserProfile extends UserProfile -{ - function showEntityActions() - { - return; - } -} diff --git a/actions/publicpeopletagcloud.php b/actions/publicpeopletagcloud.php deleted file mode 100644 index cb65bbb163..0000000000 --- a/actions/publicpeopletagcloud.php +++ /dev/null @@ -1,182 +0,0 @@ -. - * - * @category Public - * @package StatusNet - * @author Mike Cochrane - * @author Evan Prodromou - * @copyright 2008 Mike Cochrane - * @copyright 2008-2009 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } - -define('TAGS_PER_PAGE', 100); - -/** - * Public tag cloud for notices - * - * @category Personal - * @package StatusNet - * @author Mike Cochrane - * @author Evan Prodromou - * @copyright 2008 Mike Cochrane - * @copyright 2008-2009 StatusNet, Inc. - * @link http://status.net/ - */ -class PublicpeopletagcloudAction extends Action -{ - function isReadOnly($args) - { - return true; - } - - function title() - { - // TRANS: Title for page with public list cloud. - return _('Public list cloud'); - } - - function showPageNotice() - { - $this->element('p', 'instructions', - // TRANS: Page notice for page with public list cloud. - // TRANS: %s is a StatusNet sitename. - sprintf(_('These are largest lists on %s'), - common_config('site', 'name'))); - } - - function showEmptyList() - { - // TRANS: Empty list message on page with public list cloud. - // TRANS: This message contains Markdown links in the form [description](link). - $message = _('No one has [listed](%%doc.tags%%) anyone yet.') . ' '; - - if (common_logged_in()) { - // TRANS: Additional empty list message on page with public list cloud for logged in users. - $message .= _('Be the first to list someone!'); - } - else { - // TRANS: Additional empty list message on page with public list cloud for anonymous users. - // TRANS: This message contains Markdown links in the form [description](link). - $message .= _('Why not [register an account](%%action.register%%) and be the first to list someone!'); - } - - $this->elementStart('div', 'guide'); - $this->raw(common_markup_to_html($message)); - $this->elementEnd('div'); - } - - function showLocalNav() - { - $nav = new PublicGroupNav($this); - $nav->show(); - } - - function handle($args) - { - parent::handle($args); - $this->showPage(); - } - - function showContent() - { - // XXX: cache this - - $tags = new Profile_tag(); - $plist = new Profile_list(); - $plist->private = false; - - $tags->joinAdd($plist); - $tags->selectAdd(); - $tags->selectAdd('profile_tag.tag'); - $tags->selectAdd('count(profile_tag.tag) as weight'); - $tags->groupBy('profile_tag.tag'); - $tags->orderBy('weight DESC'); - - $tags->limit(TAGS_PER_PAGE); - - $cnt = $tags->find(); - - if ($cnt > 0) { - $this->elementStart('div', array('id' => 'tagcloud', - 'class' => 'section')); - - $tw = array(); - $sum = 0; - while ($tags->fetch()) { - $tw[$tags->tag] = $tags->weight; - $sum += $tags->weight; - } - - ksort($tw); - - $this->elementStart('dl'); - // TRANS: DT element on on page with public list cloud. - $this->element('dt', null, _('List cloud')); - $this->elementStart('dd'); - $this->elementStart('ul', 'tags xoxo tag-cloud'); - foreach ($tw as $tag => $weight) { - if ($sum) { - $weightedSum = $weight/$sum; - } else { - $weightedSum = 0.5; - } - $this->showTag($tag, $weight, $weightedSum); - } - $this->elementEnd('ul'); - $this->elementEnd('dd'); - $this->elementEnd('dl'); - $this->elementEnd('div'); - } else { - $this->showEmptyList(); - } - } - - function showTag($tag, $weight, $relative) - { - if ($relative > 0.1) { - $rel = 'tag-cloud-7'; - } else if ($relative > 0.05) { - $rel = 'tag-cloud-6'; - } else if ($relative > 0.02) { - $rel = 'tag-cloud-5'; - } else if ($relative > 0.01) { - $rel = 'tag-cloud-4'; - } else if ($relative > 0.005) { - $rel = 'tag-cloud-3'; - } else if ($relative > 0.002) { - $rel = 'tag-cloud-2'; - } else { - $rel = 'tag-cloud-1'; - } - - $this->elementStart('li', $rel); - - // TRANS: Link title for number of listed people. %d is the number of listed people. - $title = sprintf(_m('1 person listed','%d people listed',$weight),$weight); - $this->element('a', array('href' => common_local_url('peopletag', array('tag' => $tag)), - 'title' => $title), $tag); - $this->elementEnd('li'); - } -} diff --git a/classes/Profile.php b/classes/Profile.php index 7f45031f66..f983225fd5 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -436,42 +436,55 @@ class Profile extends Managed_DataObject return new ArrayWrapper($lists); } + /** + * Get tags that other people put on this profile, in reverse-chron order + * + * @param (Profile|User) $auth_user Authorized user (used for privacy) + * @param int $offset Offset from latest + * @param int $limit Max number to get + * @param datetime $since_id max date + * @param datetime $max_id min date + * + * @return Profile_list resulting lists + */ + function getOtherTags($auth_user=null, $offset=0, $limit=null, $since_id=0, $max_id=0) { - $lists = new Profile_list(); + $list = new Profile_list(); - $tags = new Profile_tag(); - $tags->tagged = $this->id; + $qry = sprintf('select profile_list.*, unix_timestamp(profile_tag.modified) as "cursor" ' . + 'from profile_tag join profile_list '. + 'on (profile_tag.tagger = profile_list.tagger ' . + ' and profile_tag.tag = profile_list.tag) ' . + 'where profile_tag.tagged = %d ', + $this->id); - $lists->joinAdd($tags); - - #@fixme: postgres (round(date_part('epoch', my_date))) - $lists->selectAdd('unix_timestamp(profile_tag.modified) as "cursor"'); if ($auth_user instanceof User || $auth_user instanceof Profile) { - $lists->whereAdd('( ( profile_list.private = false ) ' . - 'OR ( profile_list.tagger = ' . $auth_user->id . ' AND ' . - 'profile_list.private = true ) )'); + $qry .= sprintf('AND ( ( profile_list.private = false ) ' . + 'OR ( profile_list.tagger = %d AND ' . + 'profile_list.private = true ) )', + $auth_user->id); } else { - $lists->private = false; + $qry .= 'AND profile_list.private = 0 '; } - if ($since_id>0) { - $lists->whereAdd('cursor > '.$since_id); + if ($since_id > 0) { + $qry .= sprintf('AND (cursor > %d) ', $since_id); } - if ($max_id>0) { - $lists->whereAdd('cursor <= '.$max_id); + if ($max_id > 0) { + $qry .= sprintf('AND (cursor < %d) ', $max_id); } - if($offset>=0 && !is_null($limit)) { - $lists->limit($offset, $limit); + $qry .= 'ORDER BY profile_tag.modified DESC '; + + if ($offset >= 0 && !is_null($limit)) { + $qry .= sprintf('LIMIT %d OFFSET %d ', $limit, $offset); } - $lists->orderBy('profile_tag.modified DESC'); - $lists->find(); - - return $lists; + $list->query($qry); + return $list; } function getPrivateTags($offset=0, $limit=null, $since_id=0, $max_id=0) diff --git a/classes/Profile_list.php b/classes/Profile_list.php index c433a53fee..27001978b6 100644 --- a/classes/Profile_list.php +++ b/classes/Profile_list.php @@ -221,7 +221,10 @@ class Profile_list extends Managed_DataObject { $subs = new Profile(); - $subs->joinAdd(array('id', 'profile_tag_subscription:profile_tag_id')); + $subs->joinAdd( + array('id', 'profile_tag_subscription:profile_id') + ); + $subs->whereAdd('profile_tag_subscription.profile_tag_id = ' . $this->id); $subs->selectAdd('unix_timestamp(profile_tag_subscription.' . 'created) as "cursor"'); diff --git a/classes/Profile_tag.php b/classes/Profile_tag.php index d9b094182f..07ed160d19 100644 --- a/classes/Profile_tag.php +++ b/classes/Profile_tag.php @@ -79,20 +79,17 @@ class Profile_tag extends Managed_DataObject return $tags; } - $profile_tag = new Profile_tag(); - $profile_list->tagger = $tagger; - $profile_tag->tagged = $tagged; + $qry = 'select profile_list.* from profile_list left join '. + 'profile_tag on (profile_list.tag = profile_tag.tag and '. + 'profile_list.tagger = profile_tag.tagger) where '. + 'profile_tag.tagger = %d and profile_tag.tagged = %d '; + $qry = sprintf($qry, $tagger, $tagged); - $profile_list->selectAdd(); + if (!$include_priv) { + $qry .= ' and profile_list.private = 0'; + } - // only fetch id, tag, mainpage and - // private hoping this will be faster - $profile_list->selectAdd('profile_list.id, ' . - 'profile_list.tag, ' . - 'profile_list.mainpage, ' . - 'profile_list.private'); - $profile_list->joinAdd($profile_tag); - $profile_list->find(); + $profile_list->query($qry); Profile_list::setCache($key, $profile_list); @@ -102,23 +99,26 @@ class Profile_tag extends Managed_DataObject static function getTagsArray($tagger, $tagged, $auth_user_id=null) { $ptag = new Profile_tag(); - $ptag->tagger = $tagger; - $ptag->tagged = $tagged; - if ($tagger != $auth_user_id) { - $list = new Profile_list(); - $list->private = false; - $ptag->joinAdd($list); - $ptag->selectAdd(); - $ptag->selectAdd('profile_tag.tag'); + $qry = sprintf('select profile_tag.tag '. + 'from profile_tag join profile_list '. + ' on (profile_tag.tagger = profile_list.tagger ' . + ' and profile_tag.tag = profile_list.tag) ' . + 'where profile_tag.tagger = %d ' . + 'and profile_tag.tagged = %d ', + $tagger, $tagged); + + if ($auth_user_id != $tagger) { + $qry .= 'and profile_list.private = 0'; } $tags = array(); - $ptag->find(); + + $ptag->query($qry); + while ($ptag->fetch()) { $tags[] = $ptag->tag; } - $ptag->free(); return $tags; } diff --git a/db/core.php b/db/core.php index b7881a7dc0..bf8cae3c4b 100644 --- a/db/core.php +++ b/db/core.php @@ -29,7 +29,8 @@ * double-check what we've been doing on postgres? */ -$classes = array('Profile', +$classes = array('Schema_version', + 'Profile', 'Avatar', 'Sms_carrier', 'User', @@ -85,7 +86,6 @@ $classes = array('Profile', 'Conversation', 'Local_group', 'User_urlshortener_prefs', - 'Schema_version', 'Old_school_prefs', ); diff --git a/doc-src/lists b/doc-src/lists index b2e93aa853..01c5d3b65f 100644 --- a/doc-src/lists +++ b/doc-src/lists @@ -56,10 +56,6 @@ private prepend a '.' to the tag in the tags editing box. To set an existing public tag as private or vice-versa, go to the tag's edit page. -The most used public tags are displayed in the -[public people tag cloud](%%action.publicpeopletagcloud%%). Their -size shows their frequency of use. - Remote people tags ------------------ diff --git a/doc-src/tags b/doc-src/tags index b2e93aa853..3e9065a100 100644 --- a/doc-src/tags +++ b/doc-src/tags @@ -17,10 +17,6 @@ latin characters are not supported, and non-roman scripts are right out. The HTML for the notice will link to a stream of all the other notices with that tag. This can be a great way to keep track of a conversation. -The most popular current tags on the site can be found in the [public -tag cloud](%%action.publictagcloud%%). Their size shows their -popularity and recency. - Tagging yourself ---------------- diff --git a/lib/peopletagnoticestream.php b/lib/peopletagnoticestream.php index e82d754e8d..4422261ae9 100644 --- a/lib/peopletagnoticestream.php +++ b/lib/peopletagnoticestream.php @@ -96,10 +96,12 @@ class RawPeopletagNoticeStream extends NoticeStream $notice->selectAdd(); $notice->selectAdd('notice.id'); + $ptag = new Profile_tag(); + $ptag->tag = $this->profile_list->tag; + $ptag->tagger = $this->profile_list->tagger; $notice->joinAdd(array('profile_id', 'profile_tag:tagged')); - + $notice->whereAdd('profile_tag.tagger = ' . $this->profile_list->tagger); $notice->whereAdd(sprintf('profile_tag.tag = "%s"', $this->profile_list->tag)); - $notice->whereAdd(sprintf('profile_tag.tagger = %d', $this->profile_list->tagger)); if ($since_id != 0) { $notice->whereAdd('notice.id > ' . $since_id); diff --git a/lib/router.php b/lib/router.php index b0124375de..c9b12ac8e7 100644 --- a/lib/router.php +++ b/lib/router.php @@ -825,7 +825,7 @@ class Router foreach (array('subscriptions', 'subscribers', 'all', 'foaf', 'replies', - 'microsummary', 'hcard') as $a) { + 'microsummary') as $a) { $m->connect($a, array('action' => $a, 'nickname' => $nickname)); @@ -893,7 +893,7 @@ class Router foreach (array('subscriptions', 'subscribers', 'nudge', 'all', 'foaf', 'replies', - 'inbox', 'outbox', 'microsummary', 'hcard') as $a) { + 'inbox', 'outbox', 'microsummary') as $a) { $m->connect(':nickname/'.$a, array('action' => $a), array('nickname' => Nickname::DISPLAY_FMT)); @@ -904,10 +904,6 @@ class Router // people tags - if (!common_config('performance', 'high')) { - $m->connect('peopletags', array('action' => 'publicpeopletagcloud')); - } - $m->connect('peopletag/:tag', array('action' => 'peopletag', 'tag' => self::REGEX_TAG)); diff --git a/lib/theme.php b/lib/theme.php index 1239e317f4..fbcbbe052a 100644 --- a/lib/theme.php +++ b/lib/theme.php @@ -106,9 +106,9 @@ class Theme // Ruh roh. Fall back to default, then. - common_log(LOG_WARN, sprintf("Unable to find theme '%s', falling back to default theme '%s'", - $name, - Theme::FALLBACK)); + common_log(LOG_WARNING, sprintf("Unable to find theme '%s', falling back to default theme '%s'", + $name, + Theme::FALLBACK)); $this->name = Theme::FALLBACK; $this->dir = $instroot.'/'.Theme::FALLBACK; diff --git a/lib/util.php b/lib/util.php index 75037625d0..99be56daeb 100644 --- a/lib/util.php +++ b/lib/util.php @@ -2163,7 +2163,11 @@ function common_shorten_url($long_url, User $user=null, $force = false) } else { $shortenedUrl = common_local_url('redirecturl', array('id' => $f->id)); - return $shortenedUrl; + if ((mb_strlen($shortenedUrl) < mb_strlen($long_url)) || $force) { + return $shortenedUrl; + } else { + return $long_url; + } } } else { return $long_url; diff --git a/lib/xrdaction.php b/lib/xrdaction.php index 3d55204f41..6cca80d93e 100644 --- a/lib/xrdaction.php +++ b/lib/xrdaction.php @@ -82,11 +82,6 @@ class XrdAction extends Action 'type' => 'text/html', 'href' => $profile->profileurl); - // hCard - $xrd->links[] = array('rel' => self::HCARD, - 'type' => 'text/html', - 'href' => common_local_url('hcard', array('nickname' => $nick))); - // XFN $xrd->links[] = array('rel' => 'http://gmpg.org/xfn/11', 'type' => 'text/html', diff --git a/plugins/OStatus/lib/xrdaction.php b/plugins/OStatus/lib/xrdaction.php index 1ac4d40a50..2ba158a3e6 100644 --- a/plugins/OStatus/lib/xrdaction.php +++ b/plugins/OStatus/lib/xrdaction.php @@ -77,11 +77,6 @@ class XrdAction extends Action 'format' => 'atom')), 'type' => 'application/atom+xml'); - // hCard - $xrd->links[] = array('rel' => Discovery::HCARD, - 'type' => 'text/html', - 'href' => common_local_url('hcard', array('nickname' => $nick))); - // XFN $xrd->links[] = array('rel' => 'http://gmpg.org/xfn/11', 'type' => 'text/html', diff --git a/scripts/upgrade.php b/scripts/upgrade.php index 1bf444267c..7d81c19835 100644 --- a/scripts/upgrade.php +++ b/scripts/upgrade.php @@ -52,6 +52,8 @@ function main() initSubscriptionURI(); initGroupMemberURI(); + initProfileLists(); + Event::handle('EndUpgrade'); } } @@ -374,4 +376,47 @@ function initGroupMemberURI() printfnq("DONE.\n"); } +function initProfileLists() +{ + printfnq("Ensuring all profile tags have a corresponding list..."); + + $ptag = new Profile_tag(); + $ptag->selectAdd(); + $ptag->selectAdd('tagger, tag, count(*) as tagged_count'); + $ptag->whereAdd('NOT EXISTS (SELECT tagger, tagged from profile_list '. + 'where profile_tag.tagger = profile_list.tagger '. + 'and profile_tag.tag = profile_list.tag)'); + $ptag->groupBy('tagger, tag'); + $ptag->orderBy('tagger, tag'); + + if ($ptag->find()) { + while ($ptag->fetch()) { + $plist = new Profile_list(); + + $plist->tagger = $ptag->tagger; + $plist->tag = $ptag->tag; + $plist->private = 0; + $plist->created = common_sql_now(); + $plist->modified = $plist->created; + $plist->mainpage = common_local_url('showprofiletag', + array('tagger' => $plist->getTagger()->nickname, + 'tag' => $plist->tag));; + + $plist->tagged_count = $ptag->tagged_count; + $plist->subscriber_count = 0; + + $plist->insert(); + + $orig = clone($plist); + // After insert since it uses auto-generated ID + $plist->uri = common_local_url('profiletagbyid', + array('id' => $plist->id, 'tagger_id' => $plist->tagger)); + + $plist->update($orig); + } + } + + printfnq("DONE.\n"); +} + main();