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

Commit 22e50ad7 authored by Shashi Gowda's avatar Shashi Gowda

Merge remote-tracking branch '1.0.x' into lists_fixes

parents 161b672d b78e5de4
......@@ -1375,3 +1375,9 @@ EndProfileGetAvatar: After getting an avatar for a profile
- $profile: profile
- $size: size of the avatar
- &$avatar: avatar
StartRegisterSuccess: Before showing the registration success message
- $action: the registration action
StartRegisterSuccess: After showing the registration success message
- $action: the registration action
......@@ -183,6 +183,16 @@ class AllAction extends ProfileAction
}
}
function showSections()
{
$this->showSubscriptions();
$ibs = new InviteButtonSection($this);
$ibs->show();
$this->showSubscribers();
$this->showGroups();
$this->showLists();
}
function showPageTitle()
{
$user = common_current_user();
......
......@@ -189,7 +189,7 @@ class ApiListsAction extends ApiBareAuthAction
// there is no argument named count
$count = 20;
$profile = $this->user->getProfile();
$fn = array($profile, 'getOwnedTags');
$fn = array($profile, 'getLists');
list($this->lists,
$this->next_cursor,
......
......@@ -296,10 +296,4 @@ class InviteAction extends CurrentUserDesignAction
mail_send($recipients, $headers, $body);
}
function showObjectNav()
{
$nav = new SubGroupNav($this, common_current_user());
$nav->show();
}
}
......@@ -70,7 +70,7 @@ class PeopletagautocompleteAction extends Action
}
$profile = $this->user->getProfile();
$tags = $profile->getOwnedTags(common_current_user());
$tags = $profile->getLists(common_current_user());
$this->tags = array();
while ($tags->fetch()) {
......@@ -88,7 +88,7 @@ class PeopletagautocompleteAction extends Action
$this->tags[] = $arr;
}
$tags->free();
$tags = NULL;
return true;
}
......
......@@ -114,7 +114,7 @@ class PeopletagsbyuserAction extends OwnerDesignAction
$user = common_current_user();
if ($this->arg('public')) {
$this->tags = $this->tagger->getOwnedTags(false, $offset, $limit);
$this->tags = $this->tagger->getLists(false, $offset, $limit);
} else if ($this->arg('private')) {
if (empty($user)) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
......@@ -128,7 +128,7 @@ class PeopletagsbyuserAction extends OwnerDesignAction
$this->clientError(_('You cannot view others\' private lists'), 403);
}
} else {
$this->tags = $this->tagger->getOwnedTags(common_current_user(), $offset, $limit);
$this->tags = $this->tagger->getLists(common_current_user(), $offset, $limit);
}
return true;
}
......
......@@ -222,14 +222,12 @@ class PublicAction extends Action
function showSections()
{
// $top = new TopPostersSection($this);
// $top->show();
$pop = new PopularNoticeSection($this);
$pop->show();
$ibs = new InviteButtonSection($this);
$ibs->show();
$gbp = new GroupsByMembersSection($this);
$gbp->show();
$ptp = new PeopletagsBySubsSection($this);
$ptp->show();
$feat = new FeaturedUsersSection($this);
$feat->show();
}
......
......@@ -605,48 +605,53 @@ class RegisterAction extends Action
*/
function showSuccessContent()
{
$nickname = $this->arg('nickname');
$profileurl = common_local_url('showstream',
array('nickname' => $nickname));
$this->elementStart('div', 'success');
// TRANS: Text displayed after successful account registration.
// TRANS: %1$s is the registered nickname, %2$s is the profile URL.
// TRANS: This message contains Markdown links in the form [link text](link)
// TRANS: and variables in the form %%%%variable%%%%. Please mind the syntax.
$instr = sprintf(_('Congratulations, %1$s! And welcome to %%%%site.name%%%%. '.
'From here, you may want to...'. "\n\n" .
'* Go to [your profile](%2$s) '.
'and post your first message.' . "\n" .
'* Add a [Jabber/GTalk address]'.
'(%%%%action.imsettings%%%%) '.
'so you can send notices '.
'through instant messages.' . "\n" .
'* [Search for people](%%%%action.peoplesearch%%%%) '.
'that you may know or '.
'that share your interests. ' . "\n" .
'* Update your [profile settings]'.
'(%%%%action.profilesettings%%%%)'.
' to tell others more about you. ' . "\n" .
'* Read over the [online docs](%%%%doc.help%%%%)'.
' for features you may have missed. ' . "\n\n" .
'Thanks for signing up and we hope '.
'you enjoy using this service.'),
$nickname, $profileurl);
$this->raw(common_markup_to_html($instr));
$have_email = $this->trimmed('email');
if ($have_email) {
// TRANS: Instruction text on how to deal with the e-mail address confirmation e-mail.
$emailinstr = _('(You should receive a message by email '.
'momentarily, with ' .
'instructions on how to confirm '.
'your email address.)');
$this->raw(common_markup_to_html($emailinstr));
if (Event::handle('onStartRegisterSuccess', array($this))) {
$nickname = $this->arg('nickname');
$profileurl = common_local_url('showstream',
array('nickname' => $nickname));
$this->elementStart('div', 'success');
// TRANS: Text displayed after successful account registration.
// TRANS: %1$s is the registered nickname, %2$s is the profile URL.
// TRANS: This message contains Markdown links in the form [link text](link)
// TRANS: and variables in the form %%%%variable%%%%. Please mind the syntax.
$instr = sprintf(_('Congratulations, %1$s! And welcome to %%%%site.name%%%%. '.
'From here, you may want to...'. "\n\n" .
'* Go to [your profile](%2$s) '.
'and post your first message.' . "\n" .
'* Add a [Jabber/GTalk address]'.
'(%%%%action.imsettings%%%%) '.
'so you can send notices '.
'through instant messages.' . "\n" .
'* [Search for people](%%%%action.peoplesearch%%%%) '.
'that you may know or '.
'that share your interests. ' . "\n" .
'* Update your [profile settings]'.
'(%%%%action.profilesettings%%%%)'.
' to tell others more about you. ' . "\n" .
'* Read over the [online docs](%%%%doc.help%%%%)'.
' for features you may have missed. ' . "\n\n" .
'Thanks for signing up and we hope '.
'you enjoy using this service.'),
$nickname, $profileurl);
$this->raw(common_markup_to_html($instr));
$have_email = $this->trimmed('email');
if ($have_email) {
// TRANS: Instruction text on how to deal with the e-mail address confirmation e-mail.
$emailinstr = _('(You should receive a message by email '.
'momentarily, with ' .
'instructions on how to confirm '.
'your email address.)');
$this->raw(common_markup_to_html($emailinstr));
}
$this->elementEnd('div');
Event::handle('onEndRegisterSuccess', array($this));
}
$this->elementEnd('div');
}
/**
......@@ -656,15 +661,23 @@ class RegisterAction extends Action
*/
function showLocalNav()
{
$nav = new LoginGroupNav($this);
$nav->show();
}
function showNoticeForm()
{
if (common_logged_in()) {
parent::showLocalNav();
} else {
$nav = new LoginGroupNav($this);
$nav->show();
}
}
/**
* Show a bit of login context
*
* @return nothing
*/
function showProfileBlock()
{
if (common_logged_in()) {
parent::showProfileBlock();
}
}
}
......@@ -321,36 +321,66 @@ class Profile extends Memcached_DataObject
return false;
}
function getOwnedTags($auth_user, $offset=0, $limit=null, $since_id=0, $max_id=0)
function getLists($auth_user, $offset=0, $limit=null, $since_id=0, $max_id=0)
{
$tags = new Profile_list();
$tags->tagger = $this->id;
$ids = array();
$keypart = sprintf('profile:lists:%d', $this->id);
if (($auth_user instanceof User || $auth_user instanceof Profile) &&
$auth_user->id === $this->id) {
// no condition, get both private and public tags
$idstr = self::cacheGet($keypart);
if ($idstr !== false) {
$ids = explode(',', $idstr);
} else {
$tags->private = false;
}
$list = new Profile_list();
$list->selectAdd();
$list->selectAdd('id');
$list->tagger = $this->id;
$list->selectAdd('id as "cursor"');
$tags->selectAdd('id as "cursor"');
if ($since_id>0) {
$list->whereAdd('id > '.$since_id);
}
if ($since_id>0) {
$tags->whereAdd('id > '.$since_id);
}
if ($max_id>0) {
$list->whereAdd('id <= '.$max_id);
}
if ($max_id>0) {
$tags->whereAdd('id <= '.$max_id);
}
if($offset>=0 && !is_null($limit)) {
$list->limit($offset, $limit);
}
if($offset>=0 && !is_null($limit)) {
$tags->limit($offset, $limit);
$list->orderBy('id DESC');
if ($list->find()) {
while ($list->fetch()) {
$ids[] = $list->id;
}
}
self::cacheSet($keypart, implode(',', $ids));
}
$tags->orderBy('id DESC');
$tags->find();
$showPrivate = (($auth_user instanceof User ||
$auth_user instanceof Profile) &&
$auth_user->id === $this->id);
return $tags;
$lists = array();
foreach ($ids as $id) {
$list = Profile_list::staticGet('id', $id);
if (!empty($list) &&
($showPrivate || !$list->private)) {
if (!isset($list->cursor)) {
$list->cursor = $list->id;
}
$lists[] = $list;
}
}
return new ArrayWrapper($lists);
}
function getOtherTags($auth_user=null, $offset=0, $limit=null, $since_id=0, $max_id=0)
......@@ -1323,38 +1353,4 @@ class Profile extends Memcached_DataObject
}
return $profile;
}
function getLists($offset, $limit)
{
$ids = array();
$keypart = sprintf('profile:lists:%d', $this->id);
$idstr = self::cacheGet($keypart);
if ($idstr !== false) {
$ids = explode(',', $idstr);
} else {
$list = new Profile_list();
$list->selectAdd();
$list->selectAdd('id');
$list->tagger = $this->id;
if ($list->find()) {
while ($list->fetch()) {
$ids[] = $list->id;
}
}
self::cacheSet($keypart, implode(',', $ids));
}
$lists = array();
foreach ($ids as $id) {
$lists[] = Profile_list::staticGet('id', $id);
}
return new ArrayWrapper($lists);
}
}
......@@ -68,7 +68,7 @@ class GroupsByMembersSection extends GroupSection
function title()
{
// TRANS: Title for groups with the most members section.
return _('Groups with most members');
return _('Popular groups');
}
function divId()
......
......@@ -68,7 +68,7 @@ class GroupsByPostsSection extends GroupSection
function title()
{
// TRANS: Title for groups with the most posts section.
return _('Groups with most posts');
return _('Active groups');
}
function divId()
......
<?php
/**
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2011, StatusNet, Inc.
*
* Section for an invite button
*
* PHP version 5
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Section
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2011 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
if (!defined('STATUSNET')) {
// This check helps protect against security problems;
// your code file can't be executed directly from the web.
exit(1);
}
/**
* Invite button
*
* @category Section
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2011 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
class InviteButtonSection extends Section
{
function showTitle()
{
return false;
}
function showContent()
{
$this->out->element('a',
array('href' => common_local_url('invite'),
'class' => 'invite_button'),
_('Invite more colleagues'));
return false;
}
}
\ No newline at end of file
......@@ -51,7 +51,7 @@ class ListsNav extends Menu
$user = common_current_user();
$this->lists = $profile->getOwnedTags($user);
$this->lists = $profile->getLists($user);
}
function show()
......
......@@ -271,13 +271,6 @@ class ProfileAction extends OwnerDesignAction
}
}
if ($cnt > GROUPS_PER_MINILIST) {
$this->elementStart('p');
// TRANS: Text for user group membership statistics if user has more subscriptions than displayed.
$this->statsSectionLink('usergroups', _('All groups'), 'more');
$this->elementEnd('p');
}
Event::handle('EndShowGroupsMiniList', array($this));
}
$this->elementEnd('div');
......@@ -285,7 +278,9 @@ class ProfileAction extends OwnerDesignAction
function showLists()
{
$lists = $this->profile->getLists();
$cur = common_current_user();
$lists = $this->profile->getLists($cur);
if ($lists->N > 0) {
$this->elementStart('div', array('id' => 'entity_lists',
......@@ -293,38 +288,39 @@ class ProfileAction extends OwnerDesignAction
if (Event::handle('StartShowListsMiniList', array($this))) {
$url = common_local_url('peopletagsbyuser',
array('nickname' => $this->profile->nickname));
$this->elementStart('h2');
// TRANS: H2 text for user list membership statistics.
$this->statsSectionLink('userlists', _('Lists'));
$this->element('a',
array('href' => $url),
_('Lists'));
$this->text(' ');
$this->text($lists->N);
$this->elementEnd('h2');
$this->elementStart('ul');
$cur = common_current_user();
$first = true;
while ($lists->fetch()) {
if (!$lists->private ||
($lists->private && !empty($cur) && $cur->id == $profile->id)) {
if (!empty($lists->mainpage)) {
$url = $lists->mainpage;
} else {
$url = common_local_url('showprofiletag',
array('tagger' => $this->profile->nickname,
'tag' => $lists->tag));
}
if (!$first) {
$this->text(', ');
} else {
$first = false;
}
$this->element('a', array('href' => $url),
$lists->tag);
if (!empty($lists->mainpage)) {
$url = $lists->mainpage;
} else {
$url = common_local_url('showprofiletag',
array('tagger' => $this->profile->nickname,
'tag' => $lists->tag));
}
if (!$first) {
$this->text(', ');
} else {
$first = false;
}
$this->element('a', array('href' => $url),
$lists->tag);
}
$this->elementEnd('ul');
......
......@@ -61,6 +61,19 @@ class Section extends Widget
array('id' => $this->divId(),
'class' => 'section'));
$this->showTitle();
$have_more = $this->showContent();
if ($have_more) {
$this->showMore();
}
$this->out->elementEnd('div');
}
function showTitle()
{
$link = $this->link();
if (!empty($link)) {
$this->out->elementStart('h2');
......@@ -70,18 +83,15 @@ class Section extends Widget
$this->out->element('h2', null,
$this->title());
}
}
$have_more = $this->showContent();
if ($have_more) {
$this->out->elementStart('p');
$this->out->element('a', array('href' => $this->moreUrl(),
'class' => 'more'),
$this->moreTitle());
$this->out->elementEnd('p');
}
$this->out->elementEnd('div');
function showMore()
{
$this->out->elementStart('p');
$this->out->element('a', array('href' => $this->moreUrl(),
'class' => 'more'),
$this->moreTitle());
$this->out->elementEnd('p');
}
function divId()
......
......@@ -145,7 +145,7 @@ class SubGroupNav extends Menu
// TRANS: Menu item in local navigation menu.
_m('MENU','Invite'),
// TRANS: Menu item title in local navigation menu.
// TRANS: %s is a user nickname.
// TRANS: %s is the StatusNet sitename.
sprintf(_('Invite friends and colleagues to join you on %s.'),
common_config('site', 'name')),
$action == 'invite',
......
......@@ -91,17 +91,23 @@ class GroupdirectoryAction extends Action
if ($this->filter == 'all') {
if ($this->page != 1) {
// TRANS: Title for group directory page. %d is a page number.
return(sprintf(_m('Group Directory, page %d'), $this->page));
}
// TRANS: Title for group directory page.
return _m('Group directory');
} else if ($this->page == 1) {
return sprintf(
// TRANS: Title for group directory page when it is filtered.
// TRANS: %s is the filter string.
_m('Group directory - %s'),
strtoupper($this->filter)
);
} else {
return sprintf(
_m('Group directory - %s, page %d'),