We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 7a00be5c authored by Zach Copley's avatar Zach Copley

Merge branch 'people_tag_fixes' into 1.0.x

parents 603fc33e 45952ff1
......@@ -49,11 +49,11 @@ class EditpeopletagAction extends OwnerDesignAction
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $this->boolean('delete')) {
// TRANS: Title for edit people tag page after deleting a tag.
// TRANS: %s is a tag.
return sprintf(_('Delete %s people tag'), $this->peopletag->tag);
return sprintf(_('Delete %s list'), $this->peopletag->tag);
}
// TRANS: Title for edit people tag page.
// TRANS: %s is a tag.
return sprintf(_('Edit people tag %s'), $this->peopletag->tag);
return sprintf(_('Edit list %s'), $this->peopletag->tag);
}
/**
......@@ -106,7 +106,7 @@ class EditpeopletagAction extends OwnerDesignAction
if (!$this->peopletag) {
// TRANS: Client error displayed when referring to a non-exsting people tag.
$this->clientError(_('No such people tag.'), 404);
$this->clientError(_('No such list.'), 404);
return false;
}
......@@ -216,7 +216,7 @@ class EditpeopletagAction extends OwnerDesignAction
} else {
$this->element('p', 'instructions',
// TRANS: Form instruction for edit people tag form.
_('Use this form to edit the people tag.'));
_('Use this form to edit the list.'));
}
}
......@@ -294,7 +294,7 @@ class EditpeopletagAction extends OwnerDesignAction
if (!$result) {
common_log_db_error($this->group, 'UPDATE', __FILE__);
// TRANS: TRANS: Server error displayed when updating a people tag fails.
$this->serverError(_('Could not update people tag.'));
$this->serverError(_('Could not update list.'));
}
$this->peopletag->query('COMMIT');
......
......@@ -93,7 +93,7 @@ class PeopletaggedAction extends OwnerDesignAction
if (!$this->peopletag) {
// TRANS: Client error displayed when referring to non-existing people tag.
$this->clientError(_('No such people tag.'), 404);
$this->clientError(_('No such list.'), 404);
return false;
}
......@@ -105,12 +105,12 @@ class PeopletaggedAction extends OwnerDesignAction
if ($this->page == 1) {
// TRANS: Title for list of people tagged by the user with a tag.
// TRANS: %1$s is a tag, %2$s is a username.
return sprintf(_('People tagged %1$s by %2$s'),
return sprintf(_('People listed in %1$s by %2$s'),
$this->peopletag->tag, $this->tagger->nickname);
} else {
// TRANS: Title for list of people tagged by the user with a tag.
// TRANS: %1$s is a tag, %2$s is a username, %2$s is a page number.
return sprintf(_('People tagged %1$s by %2$s, page %3$d'),
return sprintf(_('People listed in %1$s by %2$s, page %3$d'),
$this->peopletag->tag, $this->user->nickname,
$this->page);
}
......
......@@ -2,7 +2,7 @@
/**
* StatusNet, the distributed open-source microblogging tool
*
* People tags by a user
* Lists by a user
*
* PHP version 5
*
......@@ -49,22 +49,22 @@ class PeopletagsbyuserAction extends OwnerDesignAction
if ($this->page == 1) {
if ($this->isOwner()) {
if ($this->arg('private')) {
// TRANS: Title for people tags by a user page for a private tag.
return _('Private people tags by you');
// TRANS: Title for lists by a user page for a private tag.
return _('Private lists by you');
} else if ($this->arg('public')) {
// TRANS: Title for people tags by a user page for a public tag.
return _('Public people tags by you');
// TRANS: Title for lists by a user page for a public tag.
return _('Public lists by you');
}
// TRANS: Title for people tags by a user page.
return _('People tags by you');
// TRANS: Title for lists by a user page.
return _('Lists by you');
}
// TRANS: Title for people tags by a user page.
// TRANS: Title for lists by a user page.
// TRANS: %s is a user nickname.
return sprintf(_('People tags by %s'), $this->tagger->nickname);
return sprintf(_('Lists by %s'), $this->tagger->nickname);
} else {
// TRANS: Title for people tags by a user page.
// TRANS: Title for lists by a user page.
// TRANS: %1$s is a user nickname, %2$d is a page number.
return sprintf(_('People tags by %1$s, page %2$d'), $this->tagger->nickname, $this->page);
return sprintf(_('Lists by %1$s, page %2$d'), $this->tagger->nickname, $this->page);
}
}
......@@ -124,8 +124,8 @@ class PeopletagsbyuserAction extends OwnerDesignAction
if ($this->isOwner()) {
$this->tags = $this->tagger->getPrivateTags($offset, $limit);
} else {
// TRANS: Client error displayed when trying view another user's private people tags.
$this->clientError(_('You cannot view others\' private people tags'), 403);
// TRANS: Client error displayed when trying view another user's private lists.
$this->clientError(_('You cannot view others\' private lists'), 403);
}
} else {
$this->tags = $this->tagger->getOwnedTags(common_current_user(), $offset, $limit);
......@@ -160,8 +160,8 @@ class PeopletagsbyuserAction extends OwnerDesignAction
array('href' =>
common_local_url('peopletagsforuser',
array('nickname' => $this->user->nickname))),
// TRANS: Link text to show people tags for user %s.
sprintf(_('People tags for %s'), $this->tagger->nickname));
// TRANS: Link text to show lists for user %s.
sprintf(_('Lists for %s'), $this->tagger->nickname));
$this->elementEnd('li');
if ($this->isOwner()) {
......@@ -204,11 +204,11 @@ class PeopletagsbyuserAction extends OwnerDesignAction
function showAnonymousMessage()
{
$notice =
// TRANS: Message displayed for anonymous users on page that displays people tags by a user.
// TRANS: Message displayed for anonymous users on page that displays lists by a user.
// TRANS: This message contains Markdown links in the form [description](links).
// TRANS: %s is a tagger nickname.
sprintf(_('These are people tags created by **%s**. ' .
'People tags are how you sort similar ' .
sprintf(_('These are lists created by **%s**. ' .
'Lists are how you sort similar ' .
'people on %%%%site.name%%%%, a [micro-blogging]' .
'(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
'based on the Free Software [StatusNet](http://status.net/) tool. ' .
......@@ -259,17 +259,29 @@ class PeopletagsbyuserAction extends OwnerDesignAction
return !empty($user) && $user->id == $this->tagger->id;
}
function showObjectNav()
{
$nav = new PeopletagNav($this, $this->tagger);
$nav->show();
}
function showEmptyListMessage()
{
// TRANS: Message displayed on page that displays people tags by a user when there are none.
// TRANS: Message displayed on page that displays lists by a user when there are none.
// TRANS: This message contains Markdown links in the form [description](links).
// TRANS: %s is a tagger nickname.
$message = sprintf(_('%s has not created any [people tags](%%%%doc.tags%%%%) yet.'), $this->tagger->nickname);
$message = sprintf(_('%s has not created any [lists](%%%%doc.lists%%%%) yet.'), $this->tagger->nickname);
$this->elementStart('div', 'guide');
$this->raw(common_markup_to_html($message));
$this->elementEnd('div');
}
function showProfileBlock()
{
$block = new AccountProfileBlock($this, $this->tagger);
$block->show();
}
function showSections()
{
#TODO: tags with most subscribers
......
......@@ -47,10 +47,10 @@ class PeopletagsforuserAction extends OwnerDesignAction
{
if ($this->page == 1) {
// Page title. %s is a tagged user's nickname.
return sprintf(_('People tags for %s'), $this->tagged->nickname);
return sprintf(_('Lists with %s in them'), $this->tagged->nickname);
} else {
// Page title. %1$s is a tagged user's nickname, %2$s is a page number.
return sprintf(_('People tags for %1$s, page %2$d'), $this->tagged->nickname, $this->page);
return sprintf(_('Lists with %1$s, page %2$d'), $this->tagged->nickname, $this->page);
}
}
......@@ -105,8 +105,8 @@ class PeopletagsforuserAction extends OwnerDesignAction
// TRANS: Message displayed for anonymous users on page that displays people tags for a user.
// TRANS: This message contains Markdown links in the form [description](links).
// TRANS: %s is a tagger nickname.
sprintf(_('These are people tags for **%s**. ' .
'People tags are how you sort similar ' .
sprintf(_('These are lists for **%s**. ' .
'lists are how you sort similar ' .
'people on %%%%site.name%%%%, a [micro-blogging]' .
'(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
'based on the Free Software [StatusNet](http://status.net/) tool. ' .
......@@ -117,27 +117,6 @@ class PeopletagsforuserAction extends OwnerDesignAction
$this->elementEnd('div');
}
function showPageNotice()
{
$this->elementStart('dl', 'filter_tags');
$this->elementStart('dd', array('id' => 'filter_tags_for',
'class' => 'child_1'));
$user = common_current_user();
// TRANS: Page notice.
$text = ($this->tagged->id == @$user->id) ? _('People tags by you') :
// TRANS: Page notice. %s is a tagger's nickname.
sprintf(_('People tags by %s'), $this->tagged->nickname);
$this->element('a',
array('href' =>
common_local_url('peopletagsbyuser',
array('nickname' => $this->tagged->nickname))),
$text);
$this->elementEnd('dd');
$this->elementEnd('dl');
}
function showContent()
{
#TODO: controls here.
......@@ -162,12 +141,24 @@ class PeopletagsforuserAction extends OwnerDesignAction
// TRANS: Message displayed on page that displays people tags for a user when there are none.
// TRANS: This message contains Markdown links in the form [description](links).
// TRANS: %s is a tagger nickname.
$message = sprintf(_('%s has not been [tagged](%%%%doc.tags%%%%) by anyone yet.'), $this->tagged->nickname);
$message = sprintf(_('%s has not been [listed](%%%%doc.lists%%%%) by anyone yet.'), $this->tagged->nickname);
$this->elementStart('div', 'guide');
$this->raw(common_markup_to_html($message));
$this->elementEnd('div');
}
function showObjectNav()
{
$nav = new PeopletagNav($this, $this->tagged);
$nav->show();
}
function showProfileBlock()
{
$block = new AccountProfileBlock($this, $this->tagged);
$block->show();
}
function showSections()
{
#TODO: tags with most subscribers
......
......@@ -48,11 +48,11 @@ class PeopletagsubscriptionsAction extends OwnerDesignAction
if ($this->page == 1) {
// TRANS: Title for page that displays people tags subscribed to by a user.
// TRANS: %s is a profile nickname.
return sprintf(_('People tags subscriptions by %s'), $this->profile->nickname);
return sprintf(_('Lists subscribed to by %s'), $this->profile->nickname);
} else {
// TRANS: Title for page that displays people tags subscribed to by a user.
// TRANS: %1$s is a profile nickname, %2$d is a page number.
return sprintf(_('People tags subscriptions by %1$s, page %2$d'), $this->profile->nickname, $this->page);
return sprintf(_('Lists subscribed to by %1$s, page %2$d'), $this->profile->nickname, $this->page);
}
}
......@@ -107,13 +107,13 @@ class PeopletagsubscriptionsAction extends OwnerDesignAction
// TRANS: Message displayed for anonymous users on page that displays people tags subscribed to by a user.
// TRANS: This message contains Markdown links in the form [description](links).
// TRANS: %s is a profile nickname.
sprintf(_('These are people tags subscribed to by **%s**. ' .
'People tags are how you sort similar ' .
sprintf(_('These are lists subscribed to by **%s**. ' .
'Lists are how you sort similar ' .
'people on %%%%site.name%%%%, a [micro-blogging]' .
'(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
'based on the Free Software [StatusNet](http://status.net/) tool. ' .
'You can easily keep track of what they ' .
'are doing by subscribing to the tag\'s timeline.' ), $this->profile->nickname);
'are doing by subscribing to the list\'s timeline.' ), $this->profile->nickname);
$this->elementStart('div', array('id' => 'anon_notice'));
$this->raw(common_markup_to_html($notice));
$this->elementEnd('div');
......@@ -133,6 +133,18 @@ class PeopletagsubscriptionsAction extends OwnerDesignAction
$this->page, 'peopletagsubscriptions', array('nickname' => $this->profile->id));
}
function showObjectNav()
{
$nav = new PeopletagNav($this, $this->profile);
$nav->show();
}
function showProfileBlock()
{
$block = new AccountProfileBlock($this, $this->profile);
$block->show();
}
function showSections()
{
#TODO: tags with most subscribers
......
......@@ -33,7 +33,7 @@ require_once INSTALLDIR.'/lib/feedlist.php';
class ShowprofiletagAction extends Action
{
var $notice, $tagger, $peopletag;
var $notice, $tagger, $peopletag, $userProfile;
function isReadOnly($args)
{
......@@ -88,7 +88,12 @@ class ShowprofiletagAction extends Action
}
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
$this->notice = $this->peopletag->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
$this->userProfile = Profile::current();
$stream = new PeopletagNoticeStream($this->peopletag, $this->userProfile);
$this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
NOTICES_PER_PAGE + 1);
if ($this->page > 1 && $this->notice->N == 0) {
// TRANS: Server error when page not found (404).
......@@ -117,7 +122,7 @@ class ShowprofiletagAction extends Action
if($this->peopletag->private) {
// TRANS: Title for private people tag timeline.
// TRANS: %1$s is a people tag, %2$s is a page number.
return sprintf(_('Private timeline for people tagged %1$s by you, page %2$d'),
return sprintf(_('Private timeline for %1$s list by you, page %2$d'),
$this->peopletag->tag, $this->page);
}
......@@ -125,13 +130,13 @@ class ShowprofiletagAction extends Action
if (!empty($current) && $current->id == $this->peopletag->tagger) {
// TRANS: Title for public people tag timeline where the viewer is the tagger.
// TRANS: %1$s is a people tag, %2$s is a page number.
return sprintf(_('Timeline for people tagged %1$s by you, page %2$d'),
return sprintf(_('Timeline for %1$s list by you, page %2$d'),
$this->peopletag->tag, $this->page);
}
// TRANS: Title for private people tag timeline.
// TRANS: %1$s is a people tag, %2$s is the tagger's nickname, %3$d is a page number.
return sprintf(_('Timeline for people tagged %1$s by %2$s, page %3$d'),
return sprintf(_('Timeline for %1$s list by %2$s, page %3$d'),
$this->peopletag->tag,
$this->tagger->nickname,
$this->page
......@@ -140,7 +145,7 @@ class ShowprofiletagAction extends Action
if($this->peopletag->private) {
// TRANS: Title for private people tag timeline.
// TRANS: %s is a people tag.
return sprintf(_('Private timeline of people tagged %s by you'),
return sprintf(_('Private timeline of %s list by you'),
$this->peopletag->tag);
}
......@@ -148,13 +153,13 @@ class ShowprofiletagAction extends Action
if (!empty($current) && $current->id == $this->peopletag->tagger) {
// TRANS: Title for public people tag timeline where the viewer is the tagger.
// TRANS: %s is a people tag.
return sprintf(_('Timeline for people tagged %s by you'),
return sprintf(_('Timeline for %s list by you'),
$this->peopletag->tag);
}
// TRANS: Title for private people tag timeline.
// TRANS: %1$s is a people tag, %2$s is the tagger's nickname.
return sprintf(_('Timeline for people tagged %1$s by %2$s'),
return sprintf(_('Timeline for %1$s list by %2$s'),
$this->peopletag->tag,
$this->tagger->nickname
);
......@@ -185,7 +190,7 @@ class ShowprofiletagAction extends Action
),
// TRANS: Feed title.
// TRANS: %1$s is a people tag, %2$s is tagger's nickname.
sprintf(_('Feed for people tagged %1$s by %2$s (Atom)'),
sprintf(_('Feed for %1$s list by %2$s (Atom)'),
$this->peopletag->tag, $this->tagger->nickname
)
)
......@@ -202,7 +207,7 @@ class ShowprofiletagAction extends Action
{
// TRANS: Empty list message for people tag timeline.
// TRANS: %1$s is a people tag, %2$s is a tagger's nickname.
$message = sprintf(_('This is the timeline for people tagged %1$s by %2$s but no one has posted anything yet.'),
$message = sprintf(_('This is the timeline for %1$s list by %2$s but no one has posted anything yet.'),
$this->peopletag->tag,
$this->tagger->nickname) . ' ';
......@@ -239,7 +244,7 @@ class ShowprofiletagAction extends Action
function showNotices()
{
if (Event::handle('StartShowProfileTagContent', array($this))) {
$nl = new NoticeList($this->notice, $this);
$nl = new ThreadedNoticeList($this->notice, $this, $this->userProfile);
$cnt = $nl->show();
......@@ -247,10 +252,12 @@ class ShowprofiletagAction extends Action
$this->showEmptyListMessage();
}
$this->pagination(
$this->page > 1, $cnt > NOTICES_PER_PAGE,
$this->page, 'showprofiletag', array('tag' => $this->peopletag->tag,
'tagger' => $this->tagger->nickname)
$this->pagination($this->page > 1,
$cnt > NOTICES_PER_PAGE,
$this->page,
'showprofiletag',
array('tag' => $this->peopletag->tag,
'tagger' => $this->tagger->nickname)
);
Event::handle('EndShowProfileTagContent', array($this));
......@@ -284,11 +291,11 @@ class ShowprofiletagAction extends Action
if(!empty($current) && $this->peopletag->tagger == $current->id) {
// TRANS: Header on show profile tag page.
// TRANS: %s is a people tag.
$title = sprintf(_('People tagged %s by you'), $this->peopletag->tag);
$title = sprintf(_('Listed'), $this->peopletag->tag);
} else {
// TRANS: Header on show profile tag page.
// TRANS: %1$s is a people tag, %2$s is a tagger's nickname.
$title = sprintf(_('People tagged %1$s by %2$s'),
$title = sprintf(_('Listed'),
$this->peopletag->tag,
$this->tagger->nickname);
}
......
......@@ -545,12 +545,6 @@ class Notice extends Memcached_DataObject
$notice->saveKnownGroups($groups);
if (isset($peopletags)) {
$notice->saveProfileTags($peopletags);
} else {
$notice->saveProfileTags();
}
if (isset($urls)) {
$notice->saveKnownUrls($urls);
} else {
......@@ -596,6 +590,11 @@ class Notice extends Memcached_DataObject
if (!empty($profile)) {
$profile->blowNoticeCount();
}
$ptags = $this->getProfileTags();
foreach ($ptags as $ptag) {
$ptag->blowNoticeStreamCache();
}
}
/**
......@@ -618,6 +617,11 @@ class Notice extends Memcached_DataObject
// In case we're the first, will need to calc a new root.
self::blow('notice:conversation_root:%d', $this->conversation);
}
$ptags = $this->getProfileTags();
foreach ($ptags as $ptag) {
$ptag->blowNoticeStreamCache(true);
}
}
/** save all urls in the notice to the db
......@@ -1030,34 +1034,14 @@ class Notice extends Memcached_DataObject
function getProfileTags()
{
// Don't save ptags for repeats, for now.
if (!empty($this->repeat_of)) {
return array();
}
// XXX: cache me
$ptags = array();
$ptagi = new Profile_tag_inbox();
$ptagi->selectAdd();
$ptagi->selectAdd('profile_tag_id');
$ptagi->notice_id = $this->id;
$profile = $this->getProfile();
$list = $profile->getOtherTags($profile);
$ptags = array();
if ($ptagi->find()) {
while ($ptagi->fetch()) {
$profile_list = Profile_list::staticGet('id', $ptagi->profile_tag_id);
if ($profile_list) {
$ptags[] = $profile_list;
}
}
while($list->fetch()) {
$ptags[] = clone($list);
}
$ptagi->free();
return $ptags;
}
......@@ -1173,72 +1157,6 @@ class Notice extends Memcached_DataObject
return true;
}
/**
* record targets into profile_tag_inbox.
* @return array of Profile_list objects
*/
function saveProfileTags($known=array())
{
// Don't save ptags for repeats, for now
if (!empty($this->repeat_of)) {
return array();
}
if (is_array($known)) {
$ptags = $known;
} else {
$ptags = array();
}
$ptag = new Profile_tag();
$ptag->tagged = $this->profile_id;
if($ptag->find()) {
while($ptag->fetch()) {
$plist = Profile_list::getByTaggerAndTag($ptag->tagger, $ptag->tag);
if (!empty($plist)) {
$ptags[] = clone($plist);
}
}
}
foreach ($ptags as $target) {
$this->addToProfileTagInbox($target);
}
return $ptags;
}
function addToProfileTagInbox($plist)
{
$ptagi = Profile_tag_inbox::pkeyGet(array('profile_tag_id' => $plist->id,
'notice_id' => $this->id));
if (empty($ptagi)) {
$ptagi = new Profile_tag_inbox();
$ptagi->query('BEGIN');
$ptagi->profile_tag_id = $plist->id;
$ptagi->notice_id = $this->id;
$ptagi->created = $this->created;
$result = $ptagi->insert();
if (!$result) {
common_log_db_error($ptagi, 'INSERT', __FILE__);
// TRANS: Server exception thrown when saving profile_tag inbox fails.
throw new ServerException(_('Problem saving profile_tag inbox.'));
}
$ptagi->query('COMMIT');
self::blow('profile_tag:notice_ids:%d', $ptagi->profile_tag_id);
}
return true;
}
/**
* Save reply records indicating that this notice needs to be
* delivered to the local users with the given URIs.
......
......@@ -170,51 +170,6 @@ class Profile_list extends Memcached_DataObject
return $stream->getNotices($offset, $limit, $since_id, $max_id);
}
/**
* Query notices by users associated with this tag from the database.
*
* @param integer $offset offset
* @param integer $limit maximum no of results
* @param integer $since_id=null since this id
* @param integer $max_id=null maximum id in result
*
* @return array array of notice ids.
*/
function _streamDirect($offset, $limit, $since_id, $max_id)
{
$inbox = new Profile_tag_inbox();
$inbox->profile_tag_id = $this->id;
$inbox->selectAdd();
$inbox->selectAdd('notice_id');
if ($since_id != 0) {
$inbox->whereAdd('notice_id > ' . $since_id);
}
if ($max_id != 0) {
$inbox->whereAdd('notice_id <= ' . $max_id);
}
$inbox->orderBy('notice_id DESC');
if (!is_null($offset)) {