Make ostatussub conform to coding standards a bit
This commit is contained in:
parent
f323f234d7
commit
e571e64e9e
@ -22,9 +22,7 @@
|
|||||||
* @maintainer Brion Vibber <brion@status.net>
|
* @maintainer Brion Vibber <brion@status.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key UI methods:
|
* Key UI methods:
|
||||||
@ -42,16 +40,44 @@ class OStatusSubAction extends Action
|
|||||||
protected $profile_uri; // provided acct: or URI of remote entity
|
protected $profile_uri; // provided acct: or URI of remote entity
|
||||||
protected $oprofile; // Ostatus_profile of remote entity, if valid
|
protected $oprofile; // Ostatus_profile of remote entity, if valid
|
||||||
|
|
||||||
|
protected function prepare(array $args=array())
|
||||||
|
{
|
||||||
|
parent::prepare($args);
|
||||||
|
|
||||||
|
if (!common_logged_in()) {
|
||||||
|
// XXX: selfURL() didn't work. :<
|
||||||
|
common_set_returnto($_SERVER['REQUEST_URI']);
|
||||||
|
if (Event::handle('RedirectToLogin', array($this, null))) {
|
||||||
|
common_redirect(common_local_url('login'), 303);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->pullRemoteProfile()) {
|
||||||
|
$this->validateRemoteProfile();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the submission.
|
||||||
|
*/
|
||||||
|
protected function handle()
|
||||||
|
{
|
||||||
|
parent::handle();
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
|
$this->handlePost();
|
||||||
|
} else {
|
||||||
|
$this->showForm();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the initial form, when we haven't yet been given a valid
|
* Show the initial form, when we haven't yet been given a valid
|
||||||
* remote profile.
|
* remote profile.
|
||||||
*/
|
*/
|
||||||
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',
|
||||||
@ -132,8 +158,7 @@ class OStatusSubAction extends Action
|
|||||||
$oprofile = $this->oprofile;
|
$oprofile = $this->oprofile;
|
||||||
$profile = $oprofile->localProfile();
|
$profile = $oprofile->localProfile();
|
||||||
|
|
||||||
$cur = common_current_user();
|
if ($this->scoped->isSubscribed($profile)) {
|
||||||
if ($cur->isSubscribed($profile)) {
|
|
||||||
$this->element('div', array('class' => 'error'),
|
$this->element('div', array('class' => 'error'),
|
||||||
// TRANS: Extra paragraph in remote profile view when already subscribed.
|
// TRANS: Extra paragraph in remote profile view when already subscribed.
|
||||||
_m('You are already subscribed to this user.'));
|
_m('You are already subscribed to this user.'));
|
||||||
@ -203,8 +228,7 @@ class OStatusSubAction extends Action
|
|||||||
*/
|
*/
|
||||||
function success()
|
function success()
|
||||||
{
|
{
|
||||||
$cur = common_current_user();
|
$url = common_local_url('subscriptions', array('nickname' => $this->scoped->nickname));
|
||||||
$url = common_local_url('subscriptions', array('nickname' => $cur->nickname));
|
|
||||||
common_redirect($url, 303);
|
common_redirect($url, 303);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,12 +312,11 @@ class OStatusSubAction extends Action
|
|||||||
function saveFeed()
|
function saveFeed()
|
||||||
{
|
{
|
||||||
// And subscribe the current user to the local profile
|
// And subscribe the current user to the local profile
|
||||||
$user = common_current_user();
|
|
||||||
$local = $this->oprofile->localProfile();
|
$local = $this->oprofile->localProfile();
|
||||||
if ($user->isSubscribed($local)) {
|
if ($this->scoped->isSubscribed($local)) {
|
||||||
// TRANS: OStatus remote subscription dialog error.
|
// TRANS: OStatus remote subscription dialog error.
|
||||||
$this->showForm(_m('Already subscribed!'));
|
$this->showForm(_m('Already subscribed!'));
|
||||||
} elseif (Subscription::start($user->getProfile(), $local)) {
|
} elseif (Subscription::start($this->scoped, $local)) {
|
||||||
$this->success();
|
$this->success();
|
||||||
} else {
|
} else {
|
||||||
// TRANS: OStatus remote subscription dialog error.
|
// TRANS: OStatus remote subscription dialog error.
|
||||||
@ -301,38 +324,6 @@ class OStatusSubAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepare($args)
|
|
||||||
{
|
|
||||||
parent::prepare($args);
|
|
||||||
|
|
||||||
if (!common_logged_in()) {
|
|
||||||
// XXX: selfURL() didn't work. :<
|
|
||||||
common_set_returnto($_SERVER['REQUEST_URI']);
|
|
||||||
if (Event::handle('RedirectToLogin', array($this, null))) {
|
|
||||||
common_redirect(common_local_url('login'), 303);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->pullRemoteProfile()) {
|
|
||||||
$this->validateRemoteProfile();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle the submission.
|
|
||||||
*/
|
|
||||||
function handle($args)
|
|
||||||
{
|
|
||||||
parent::handle($args);
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
||||||
$this->handlePost();
|
|
||||||
} else {
|
|
||||||
$this->showForm();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle posts to this form
|
* Handle posts to this form
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user