diff options
author | Brion Vibber <brion@pobox.com> | 2010-03-03 11:42:02 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-03-03 11:42:02 -0800 |
commit | 13521cb510f2377e9b865b0506f92ada9ef9b3cd (patch) | |
tree | 253eb64f09ecc821ba273cee88514775495b5f97 | |
parent | e793b5661c2344371a14dfb87b0302a95da5ea48 (diff) | |
parent | ccd0db1e0a928fe914c894966ecf2260964a68f0 (diff) |
Merge branch 'testing' of git@gitorious.org:statusnet/mainline
-rw-r--r-- | EVENTS.txt | 6 | ||||
-rw-r--r-- | classes/Notice.php | 2 | ||||
-rw-r--r-- | classes/Profile.php | 26 | ||||
-rw-r--r-- | classes/User.php | 24 | ||||
-rw-r--r-- | classes/User_group.php | 20 | ||||
-rw-r--r-- | lib/action.php | 13 | ||||
-rw-r--r-- | lib/profileaction.php | 35 | ||||
-rw-r--r-- | lib/profilelist.php | 12 | ||||
-rw-r--r-- | lib/util.php | 2 | ||||
-rw-r--r-- | plugins/Facebook/FacebookPlugin.php | 10 | ||||
-rw-r--r-- | plugins/MobileProfile/MobileProfilePlugin.php | 11 | ||||
-rw-r--r-- | plugins/OStatus/OStatusPlugin.php | 39 | ||||
-rw-r--r-- | plugins/OStatus/theme/base/css/ostatus.css | 3 |
13 files changed, 114 insertions, 89 deletions
diff --git a/EVENTS.txt b/EVENTS.txt index 2c3863f22..47c67512a 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -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 diff --git a/classes/Notice.php b/classes/Notice.php index c1263c782..97cb3b8fb 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -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; diff --git a/classes/Profile.php b/classes/Profile.php index 470ef3320..9c2fa7a0c 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -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); diff --git a/classes/User.php b/classes/User.php index 57d76731b..aa9fbf948 100644 --- a/classes/User.php +++ b/classes/User.php @@ -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) diff --git a/classes/User_group.php b/classes/User_group.php index 64fe024b3..1a5ddf253 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -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)) { diff --git a/lib/action.php b/lib/action.php index 0918c6858..816086d20 100644 --- a/lib/action.php +++ b/lib/action.php @@ -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'); diff --git a/lib/profileaction.php b/lib/profileaction.php index 2bda8b07c..029c21845 100644 --- a/lib/profileaction.php +++ b/lib/profileaction.php @@ -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'); + Event::handle('EndShowGroupsMiniList', array($this)); } - - $this->elementEnd('div'); + $this->elementEnd('div'); } } diff --git a/lib/profilelist.php b/lib/profilelist.php index 4f1e84a6a..d970e605a 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -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'); } diff --git a/lib/util.php b/lib/util.php index add1b0ae6..46be920fa 100644 --- a/lib/util.php +++ b/lib/util.php @@ -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'); diff --git a/plugins/Facebook/FacebookPlugin.php b/plugins/Facebook/FacebookPlugin.php index 90ed7351f..65d4409b5 100644 --- a/plugins/Facebook/FacebookPlugin.php +++ b/plugins/Facebook/FacebookPlugin.php @@ -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'); - } } } diff --git a/plugins/MobileProfile/MobileProfilePlugin.php b/plugins/MobileProfile/MobileProfilePlugin.php index f788639ae..0b37734b7 100644 --- a/plugins/MobileProfile/MobileProfilePlugin.php +++ b/plugins/MobileProfile/MobileProfilePlugin.php @@ -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'); diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 95414e517..da7ca2fe2 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -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; + } } diff --git a/plugins/OStatus/theme/base/css/ostatus.css b/plugins/OStatus/theme/base/css/ostatus.css index 40cdfcef1..d1c60cc0d 100644 --- a/plugins/OStatus/theme/base/css/ostatus.css +++ b/plugins/OStatus/theme/base/css/ostatus.css @@ -41,6 +41,9 @@ min-width:96px; #entity_remote_subscribe { padding:0; float:right; +} + +.section #entity_remote_subscribe { position:relative; } |