From: Mikael Nordfeldth Date: Fri, 17 Jul 2015 13:27:47 +0000 (+0200) Subject: Early return in FacebookBridge settings action X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8d2504a809605e6bef61c13fc614dc0a57207385;p=quix0rs-gnu-social.git Early return in FacebookBridge settings action --- diff --git a/plugins/FacebookBridge/actions/facebooksettings.php b/plugins/FacebookBridge/actions/facebooksettings.php index d6e4c14c4c..67dd20e036 100644 --- a/plugins/FacebookBridge/actions/facebooksettings.php +++ b/plugins/FacebookBridge/actions/facebooksettings.php @@ -41,7 +41,8 @@ if (!defined('GNUSOCIAL')) { exit(1); } */ class FacebooksettingsAction extends SettingsAction { private $facebook; // Facebook PHP-SDK client obj - private $flink; + + protected $flink; protected function doPreparation() { @@ -57,8 +58,6 @@ class FacebooksettingsAction extends SettingsAction { $this->scoped->getID(), FACEBOOK_SERVICE ); - - return true; } protected function doPost() @@ -98,109 +97,110 @@ class FacebooksettingsAction extends SettingsAction { * @return void */ function showContent() { - if (!empty($this->flink)) { - - $this->elementStart( - 'form', - array( - 'method' => 'post', - 'id' => 'form_settings_facebook', - 'class' => 'form_settings', - 'action' => common_local_url('facebooksettings') - ) - ); + if (!$this->flink instanceof Foreign_link) { + throw new ServerException(_m('You have not linked this account to Facebook.')); + } - $this->hidden('token', common_session_token()); + $this->elementStart( + 'form', + array( + 'method' => 'post', + 'id' => 'form_settings_facebook', + 'class' => 'form_settings', + 'action' => common_local_url('facebooksettings') + ) + ); - // TRANS: Form note. User is connected to facebook. - $this->element('p', 'form_note', _m('Connected Facebook user')); + $this->hidden('token', common_session_token()); - $this->elementStart('p', array('class' => 'facebook-user-display')); + // TRANS: Form note. User is connected to facebook. + $this->element('p', 'form_note', _m('Connected Facebook user')); - $this->element( - 'fb:profile-pic', - array( - 'uid' => $this->flink->foreign_id, - 'size' => 'small', - 'linked' => 'true', - 'facebook-logo' => 'true' - ) - ); + $this->elementStart('p', array('class' => 'facebook-user-display')); - $this->element( - 'fb:name', - array('uid' => $this->flink->foreign_id, 'useyou' => 'false') - ); + $this->element( + 'fb:profile-pic', + array( + 'uid' => $this->flink->foreign_id, + 'size' => 'small', + 'linked' => 'true', + 'facebook-logo' => 'true' + ) + ); - $this->elementEnd('p'); + $this->element( + 'fb:name', + array('uid' => $this->flink->foreign_id, 'useyou' => 'false') + ); - $this->elementStart('ul', 'form_data'); + $this->elementEnd('p'); - $this->elementStart('li'); + $this->elementStart('ul', 'form_data'); - $this->checkbox( - 'noticesync', - // TRANS: Checkbox label in Facebook settings. - _m('Publish my notices to Facebook.'), - $this->flink->noticesync & FOREIGN_NOTICE_SEND - ); + $this->elementStart('li'); - $this->elementEnd('li'); + $this->checkbox( + 'noticesync', + // TRANS: Checkbox label in Facebook settings. + _m('Publish my notices to Facebook.'), + $this->flink->noticesync & FOREIGN_NOTICE_SEND + ); - $this->elementStart('li'); + $this->elementEnd('li'); - $this->checkbox( - 'replysync', - // TRANS: Checkbox label in Facebook settings. - _m('Send "@" replies to Facebook.'), - $this->flink->noticesync & FOREIGN_NOTICE_SEND_REPLY - ); + $this->elementStart('li'); + + $this->checkbox( + 'replysync', + // TRANS: Checkbox label in Facebook settings. + _m('Send "@" replies to Facebook.'), + $this->flink->noticesync & FOREIGN_NOTICE_SEND_REPLY + ); - $this->elementEnd('li'); + $this->elementEnd('li'); - $this->elementStart('li'); + $this->elementStart('li'); - // TRANS: Submit button to save synchronisation settings. - $this->submit('save', _m('BUTTON', 'Save')); + // TRANS: Submit button to save synchronisation settings. + $this->submit('save', _m('BUTTON', 'Save')); - $this->elementEnd('li'); + $this->elementEnd('li'); - $this->elementEnd('ul'); + $this->elementEnd('ul'); - $this->elementStart('fieldset'); + $this->elementStart('fieldset'); - // TRANS: Fieldset legend for form to disconnect from Facebook. - $this->element('legend', null, _m('Disconnect my account from Facebook')); + // TRANS: Fieldset legend for form to disconnect from Facebook. + $this->element('legend', null, _m('Disconnect my account from Facebook')); - if (!$this->scoped->hasPassword()) { - $this->elementStart('p', array('class' => 'form_guide')); + if (!$this->scoped->hasPassword()) { + $this->elementStart('p', array('class' => 'form_guide')); - $msg = sprintf( - // TRANS: Notice in disconnect from Facebook form if user has no local StatusNet password. - _m('Disconnecting your Faceboook would make it impossible to '. - 'log in! Please [set a password](%s) first.'), - common_local_url('passwordsettings') - ); + $msg = sprintf( + // TRANS: Notice in disconnect from Facebook form if user has no local StatusNet password. + _m('Disconnecting your Faceboook would make it impossible to '. + 'log in! Please [set a password](%s) first.'), + common_local_url('passwordsettings') + ); - $this->raw(common_markup_to_html($msg)); - $this->elementEnd('p'); - } else { - // @todo FIXME: i18n: This message is not being used. - // TRANS: Message displayed when initiating disconnect of a StatusNet user - // TRANS: from a Facebook account. %1$s is the StatusNet site name. - $msg = sprintf(_m('Keep your %1$s account but disconnect from Facebook. ' . - 'You\'ll use your %1$s password to log in.'), - common_config('site', 'name') - ); + $this->raw(common_markup_to_html($msg)); + $this->elementEnd('p'); + } else { + // @todo FIXME: i18n: This message is not being used. + // TRANS: Message displayed when initiating disconnect of a StatusNet user + // TRANS: from a Facebook account. %1$s is the StatusNet site name. + $msg = sprintf(_m('Keep your %1$s account but disconnect from Facebook. ' . + 'You\'ll use your %1$s password to log in.'), + common_config('site', 'name') + ); - // TRANS: Submit button. - $this->submit('disconnect', _m('BUTTON', 'Disconnect')); - } + // TRANS: Submit button. + $this->submit('disconnect', _m('BUTTON', 'Disconnect')); + } - $this->elementEnd('fieldset'); + $this->elementEnd('fieldset'); - $this->elementEnd('form'); - } + $this->elementEnd('form'); } /*