diff options
author | Brion Vibber <brion@pobox.com> | 2010-02-23 11:56:17 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-02-23 11:56:17 -0800 |
commit | c79c70ea2c2dadafa72c65dc4593a66fecb070e3 (patch) | |
tree | 2cf510211ace54e6865664f90bcd69c36f493dce /plugins/OStatus/actions | |
parent | e070fcaaae3e6ac1fef1f9b066c5335fddb9376b (diff) |
OStatus subscription UI tweak: if we're already subscribed/joined, say so and don't offer a 'subscribe'/'join' button on the profile preview page.
Diffstat (limited to 'plugins/OStatus/actions')
-rw-r--r-- | plugins/OStatus/actions/ostatussub.php | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/plugins/OStatus/actions/ostatussub.php b/plugins/OStatus/actions/ostatussub.php index 0d786fac9..df9aa80b0 100644 --- a/plugins/OStatus/actions/ostatussub.php +++ b/plugins/OStatus/actions/ostatussub.php @@ -88,9 +88,13 @@ class OStatusSubAction extends Action function showPreviewForm() { if ($this->oprofile->isGroup()) { - $this->previewGroup(); + $ok = $this->previewGroup(); } else { - $this->previewUser(); + $ok = $this->previewUser(); + } + if (!$ok) { + // @fixme maybe provide a cancel button or link back? + return; } $this->elementStart('div', 'entity_actions'); @@ -120,12 +124,22 @@ class OStatusSubAction extends Action /** * Show a preview for a remote user's profile + * @return boolean true if we're ok to try subscribing */ function previewUser() { $oprofile = $this->oprofile; $profile = $oprofile->localProfile(); + $cur = common_current_user(); + if ($cur->isSubscribed($profile)) { + $this->element('div', array('class' => 'error'), + _m("You are already subscribed to this user.")); + $ok = false; + } else { + $ok = true; + } + $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); $avatarUrl = $avatar ? $avatar->displayUrl() : false; @@ -133,20 +147,32 @@ class OStatusSubAction extends Action $profile->profileurl, $avatarUrl, $profile->bio); + return $ok; } /** * Show a preview for a remote group's profile + * @return boolean true if we're ok to try joining */ function previewGroup() { $oprofile = $this->oprofile; $group = $oprofile->localGroup(); + $cur = common_current_user(); + if ($cur->isMember($group)) { + $this->element('div', array('class' => 'error'), + _m("You are already a member of this group.")); + $ok = false; + } else { + $ok = true; + } + $this->showEntity($group, $group->getProfileUrl(), $group->homepage_logo, $group->description); + return $ok; } |