Merge branch 'testing' of git@gitorious.org:statusnet/mainline

This commit is contained in:
Brion Vibber 2010-03-03 11:42:02 -08:00
commit 13521cb510
13 changed files with 115 additions and 90 deletions

View File

@ -790,6 +790,12 @@ StartShowSubscriptionsMiniList: at the start of subscriptions mini list
EndShowSubscriptionsMiniList: at the end of subscriptions mini list
- $action: the current action
StartShowGroupsMiniList: at the start of groups mini list
- $action: the current action
EndShowGroupsMiniList: at the end of groups mini list
- $action: the current action
StartDeleteUserForm: starting the data in the form for deleting a user
- $action: action being shown
- $user: user being deleted

View File

@ -877,7 +877,7 @@ class Notice extends Memcached_DataObject
foreach (array_unique($match[1]) as $nickname) {
/* XXX: remote groups. */
$group = User_group::getForNickname($nickname);
$group = User_group::getForNickname($nickname, $profile);
if (empty($group)) {
continue;

View File

@ -282,6 +282,32 @@ class Profile extends Memcached_DataObject
}
}
function getGroups($offset=0, $limit=null)
{
$qry =
'SELECT user_group.* ' .
'FROM user_group JOIN group_member '.
'ON user_group.id = group_member.group_id ' .
'WHERE group_member.profile_id = %d ' .
'ORDER BY group_member.created DESC ';
if ($offset>0 && !is_null($limit)) {
if ($offset) {
if (common_config('db','type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
}
}
$groups = new User_group();
$cnt = $groups->query(sprintf($qry, $this->id));
return $groups;
}
function avatarUrl($size=AVATAR_PROFILE_SIZE)
{
$avatar = $this->getAvatar($size);

View File

@ -612,28 +612,8 @@ class User extends Memcached_DataObject
function getGroups($offset=0, $limit=null)
{
$qry =
'SELECT user_group.* ' .
'FROM user_group JOIN group_member '.
'ON user_group.id = group_member.group_id ' .
'WHERE group_member.profile_id = %d ' .
'ORDER BY group_member.created DESC ';
if ($offset>0 && !is_null($limit)) {
if ($offset) {
if (common_config('db','type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
}
}
$groups = new User_group();
$cnt = $groups->query(sprintf($qry, $this->id));
return $groups;
$profile = $this->getProfile();
return $profile->getGroups($offset, $limit);
}
function getSubscriptions($offset=0, $limit=null)

View File

@ -279,12 +279,26 @@ class User_group extends Memcached_DataObject
return true;
}
static function getForNickname($nickname)
static function getForNickname($nickname, $profile=null)
{
$nickname = common_canonical_nickname($nickname);
$group = User_group::staticGet('nickname', $nickname);
// Are there any matching remote groups this profile's in?
if ($profile) {
$group = $profile->getGroups();
while ($group->fetch()) {
if ($group->nickname == $nickname) {
// @fixme is this the best way?
return clone($group);
}
}
}
// If not, check local groups.
$group = Local_group::staticGet('nickname', $nickname);
if (!empty($group)) {
return $group;
return User_group::staticGet('id', $group->group_id);
}
$alias = Group_alias::staticGet('alias', $nickname);
if (!empty($alias)) {

View File

@ -420,13 +420,6 @@ class Action extends HTMLOutputter // lawsuit
function showPrimaryNav()
{
$user = common_current_user();
$connect = '';
if (common_config('xmpp', 'enabled')) {
$connect = 'imsettings';
} else if (common_config('sms', 'enabled')) {
$connect = 'smssettings';
}
$this->elementStart('dl', array('id' => 'site_nav_global_primary'));
$this->element('dt', null, _('Primary site navigation'));
$this->elementStart('dd');
@ -437,10 +430,8 @@ class Action extends HTMLOutputter // lawsuit
_('Home'), _('Personal profile and friends timeline'), false, 'nav_home');
$this->menuItem(common_local_url('profilesettings'),
_('Account'), _('Change your email, avatar, password, profile'), false, 'nav_account');
if ($connect) {
$this->menuItem(common_local_url($connect),
_('Connect'), _('Connect to services'), false, 'nav_connect');
}
$this->menuItem(common_local_url('oauthconnectionssettings'),
_('Connect'), _('Connect to services'), false, 'nav_connect');
if ($user->hasRight(Right::CONFIGURESITE)) {
$this->menuItem(common_local_url('siteadminpanel'),
_('Admin'), _('Change site configuration'), false, 'nav_admin');

View File

@ -105,7 +105,6 @@ class ProfileAction extends OwnerDesignAction
$this->elementStart('div', array('id' => 'entity_subscriptions',
'class' => 'section'));
if (Event::handle('StartShowSubscriptionsMiniList', array($this))) {
$this->element('h2', null, _('Subscriptions'));
@ -229,27 +228,29 @@ class ProfileAction extends OwnerDesignAction
$this->elementStart('div', array('id' => 'entity_groups',
'class' => 'section'));
if (Event::handle('StartShowGroupsMiniList', array($this))) {
$this->element('h2', null, _('Groups'));
$this->element('h2', null, _('Groups'));
if ($groups) {
$gml = new GroupMiniList($groups, $this->user, $this);
$cnt = $gml->show();
if ($cnt == 0) {
$this->element('p', null, _('(None)'));
if ($groups) {
$gml = new GroupMiniList($groups, $this->user, $this);
$cnt = $gml->show();
if ($cnt == 0) {
$this->element('p', null, _('(None)'));
}
}
}
if ($cnt > GROUPS_PER_MINILIST) {
$this->elementStart('p');
$this->element('a', array('href' => common_local_url('usergroups',
array('nickname' => $this->profile->nickname)),
'class' => 'more'),
_('All groups'));
$this->elementEnd('p');
}
if ($cnt > GROUPS_PER_MINILIST) {
$this->elementStart('p');
$this->element('a', array('href' => common_local_url('usergroups',
array('nickname' => $this->profile->nickname)),
'class' => 'more'),
_('All groups'));
$this->elementEnd('p');
}
$this->elementEnd('div');
Event::handle('EndShowGroupsMiniList', array($this));
}
$this->elementEnd('div');
}
}

View File

@ -273,18 +273,12 @@ class ProfileListItem extends Widget
$usf = new UnsubscribeForm($this->out, $this->profile);
$usf->show();
} else {
$other = User::staticGet('id', $this->profile->id);
if (!empty($other)) {
// We can't initiate sub for a remote OMB profile.
$remote = Remote_profile::staticGet('id', $this->profile->id);
if (empty($remote)) {
$sf = new SubscribeForm($this->out, $this->profile);
$sf->show();
}
else {
$url = common_local_url('remotesubscribe',
array('nickname' => $this->profile->nickname));
$this->out->element('a', array('href' => $url,
'class' => 'entity_remote_subscribe'),
_('Subscribe'));
}
}
$this->out->elementEnd('li');
}

View File

@ -853,7 +853,7 @@ function common_valid_profile_tag($str)
function common_group_link($sender_id, $nickname)
{
$sender = Profile::staticGet($sender_id);
$group = User_group::getForNickname($nickname);
$group = User_group::getForNickname($nickname, $sender);
if ($sender && $group && $sender->isMember($group)) {
$attrs = array('href' => $group->permalink(),
'class' => 'url');

View File

@ -436,16 +436,7 @@ class FacebookPlugin extends Plugin
function onStartPrimaryNav($action)
{
if (self::hasKeys()) {
$user = common_current_user();
$connect = 'FBConnectSettings';
if (common_config('xmpp', 'enabled')) {
$connect = 'imsettings';
} else if (common_config('sms', 'enabled')) {
$connect = 'smssettings';
}
if (!empty($user)) {
$fbuid = $this->loggedIn();
@ -472,7 +463,6 @@ class FacebookPlugin extends Plugin
'src' => $iconurl));
$action->elementEnd('li');
}
}
}

View File

@ -307,23 +307,14 @@ class MobileProfilePlugin extends WAP20Plugin
function _showPrimaryNav($action)
{
$user = common_current_user();
$connect = '';
if (common_config('xmpp', 'enabled')) {
$connect = 'imsettings';
} else if (common_config('sms', 'enabled')) {
$connect = 'smssettings';
}
$action->elementStart('ul', array('id' => 'site_nav_global_primary'));
if ($user) {
$action->menuItem(common_local_url('all', array('nickname' => $user->nickname)),
_('Home'));
$action->menuItem(common_local_url('profilesettings'),
_('Account'));
if ($connect) {
$action->menuItem(common_local_url($connect),
$action->menuItem(common_local_url('oauthconnectionssettings'),
_('Connect'));
}
if ($user->hasRight(Right::CONFIGURESITE)) {
$action->menuItem(common_local_url('siteadminpanel'),
_('Admin'), _('Change site configuration'), false, 'nav_admin');

View File

@ -111,11 +111,11 @@ class OStatusPlugin extends Plugin
$acct = 'acct:'. $action->profile->nickname .'@'. common_config('site', 'server');
$url = common_local_url('xrd');
$url.= '?uri='. $acct;
header('Link: <'.$url.'>; rel="'. Discovery::LRDD_REL.'"; type="application/xrd+xml"');
}
}
/**
* Set up a PuSH hub link to our internal link for canonical timeline
* Atom feeds for users and groups.
@ -229,7 +229,6 @@ class OStatusPlugin extends Plugin
return false;
}
/**
* Check if we've got remote replies to send via Salmon.
*
@ -587,7 +586,6 @@ class OStatusPlugin extends Plugin
// Drop the PuSH subscription if there are no other subscribers.
$oprofile->garbageCollect();
$member = Profile::staticGet($user->id);
$act = new Activity();
@ -738,6 +736,13 @@ class OStatusPlugin extends Plugin
return true;
}
function onEndShowGroupsMiniList($action)
{
$this->showEntityRemoteSubscribe($action);
return true;
}
function showEntityRemoteSubscribe($action)
{
$user = common_current_user();
@ -747,7 +752,7 @@ class OStatusPlugin extends Plugin
'class' => 'entity_subscribe'));
$action->element('a', array('href' => common_local_url('ostatussub'),
'class' => 'entity_remote_subscribe')
, _m('New'));
, _m('Remote'));
$action->elementEnd('p');
$action->elementEnd('div');
}
@ -799,4 +804,28 @@ class OStatusPlugin extends Plugin
return true;
}
function onStartProfileListItemActionElements($item)
{
if (!common_logged_in()) {
$profileUser = User::staticGet('id', $item->profile->id);
if (!empty($profileUser)) {
$output = $item->out;
// Add an OStatus subscribe
$output->elementStart('li', 'entity_subscribe');
$url = common_local_url('ostatusinit',
array('nickname' => $profileUser->nickname));
$output->element('a', array('href' => $url,
'class' => 'entity_remote_subscribe'),
_m('Subscribe'));
$output->elementEnd('li');
}
}
return true;
}
}

View File

@ -41,6 +41,9 @@ min-width:96px;
#entity_remote_subscribe {
padding:0;
float:right;
}
.section #entity_remote_subscribe {
position:relative;
}