From 15574c59def8160020d367bd441a55f2d0afe6b6 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 3 Mar 2010 12:55:01 -0500 Subject: Added event hooks at the start and end of groups mini list --- lib/profileaction.php | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'lib') 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'); } } -- cgit v1.2.3-54-g00ecf From 61ada4558d69901c71b6542c16d43b5ea75ea3b3 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 3 Mar 2010 10:19:14 -0800 Subject: Fix for disappearing 'connect' menu if xmpp and sms are disabled. All 'connect' menu panels used to be optional, so Action tried to figure out what the first item on the 'connect' menu should be. This is no longer necessary because we have the non-optional OAuth client connections panel now, which is not optional and can't be turned off. --- lib/action.php | 13 ++----------- plugins/Facebook/FacebookPlugin.php | 10 ---------- plugins/MobileProfile/MobileProfilePlugin.php | 11 +---------- 3 files changed, 3 insertions(+), 31 deletions(-) (limited to 'lib') 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/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'); -- cgit v1.2.3-54-g00ecf From 3bb42d117027ebf610481ca3b0733854e0127e56 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 3 Mar 2010 19:00:02 +0000 Subject: Use poster's subscribed groups to disambiguate group linking when a remote group and a local group exist with the same name. (If you're a member of two groups with the same name though, there's not a defined winner.) --- classes/Notice.php | 2 +- classes/Profile.php | 26 ++++++++++++++++++++++++++ classes/User.php | 24 ++---------------------- classes/User_group.php | 20 +++++++++++++++++--- lib/util.php | 2 +- 5 files changed, 47 insertions(+), 27 deletions(-) (limited to 'lib') 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/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'); -- cgit v1.2.3-54-g00ecf From 33af29b47cb4009dc89b5431597bfda14dccfe65 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 3 Mar 2010 19:22:22 +0000 Subject: Fix for 4113f2884113f288: show regular subscribe form for all non-OMB profiles. We can't initiate remote sub for an OMB from our end, so dropping there. --- lib/profilelist.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'lib') 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'); } -- cgit v1.2.3-54-g00ecf