OStatusSub should use inherent attributes

No need to make several common_current_user calls and then getProfile
directly after that, since we have stuff like $this->scoped.
This commit is contained in:
Mikael Nordfeldth 2015-01-27 13:23:49 +01:00
parent d140e135c0
commit 482f61ac15

View File

@ -58,10 +58,6 @@ class OStatusGroupAction extends OStatusSubAction
*/ */
function showInputForm() function showInputForm()
{ {
$user = common_current_user();
$profile = $user->getProfile();
$this->elementStart('form', array('method' => 'post', $this->elementStart('form', array('method' => 'post',
'id' => 'form_ostatus_sub', 'id' => 'form_ostatus_sub',
'class' => 'form_settings', 'class' => 'form_settings',
@ -97,11 +93,9 @@ class OStatusGroupAction extends OStatusSubAction
*/ */
function preview() function preview()
{ {
$oprofile = $this->oprofile; $group = $this->oprofile->localGroup();
$group = $oprofile->localGroup();
$cur = common_current_user(); if ($this->scoped->isMember($group)) {
if ($cur->isMember($group)) {
$this->element('div', array('class' => 'error'), $this->element('div', array('class' => 'error'),
// TRANS: Error text displayed when trying to join a remote group the user is already a member of. // TRANS: Error text displayed when trying to join a remote group the user is already a member of.
_m('You are already a member of this group.')); _m('You are already a member of this group.'));
@ -122,8 +116,7 @@ class OStatusGroupAction extends OStatusSubAction
*/ */
function success() function success()
{ {
$cur = common_current_user(); $url = common_local_url('usergroups', array('nickname' => $this->scoped->getNickname()));
$url = common_local_url('usergroups', array('nickname' => $cur->nickname));
common_redirect($url, 303); common_redirect($url, 303);
} }
@ -135,16 +128,15 @@ class OStatusGroupAction extends OStatusSubAction
*/ */
function saveFeed() function saveFeed()
{ {
$user = common_current_user();
$group = $this->oprofile->localGroup(); $group = $this->oprofile->localGroup();
if ($user->isMember($group)) { if ($this->scoped->isMember($group)) {
// TRANS: OStatus remote group subscription dialog error. // TRANS: OStatus remote group subscription dialog error.
$this->showForm(_m('Already a member!')); $this->showForm(_m('Already a member!'));
return; return;
} }
try { try {
$user->joinGroup($group); $this->scoped->joinGroup($group);
} catch (Exception $e) { } catch (Exception $e) {
common_log(LOG_ERR, "Exception on remote group join: " . $e->getMessage()); common_log(LOG_ERR, "Exception on remote group join: " . $e->getMessage());
common_log(LOG_ERR, $e->getTraceAsString()); common_log(LOG_ERR, $e->getTraceAsString());