L10n/i18n updates.
*/
function onAutoload($cls)
{
-
$dir = dirname(__FILE__);
//common_debug("class = " . $cls);
default:
return true;
}
-
}
/**
if ($this->hasApplication()) {
$action->menuItem(
+ // TRANS: Menu item for "Facebook" login.
common_local_url('facebooklogin'),
_m('MENU', 'Facebook'),
- // TRANS: Tooltip for menu item "Facebook".
- _m('Login or register using Facebook'),
+ // TRANS: Menu title for "Facebook" login.
+ _m('Login or register using Facebook.'),
'facebooklogin' === $action_name
);
}
$nav->out->menuItem(
common_local_url('facebookadminpanel'),
- // TRANS: Menu item.
+ // TRANS: Menu item for "Facebook" in administration panel.
_m('MENU','Facebook'),
- // TRANS: Tooltip for menu item "Facebook".
- _m('Facebook integration configuration'),
+ // TRANS: Menu title for "Facebook" in administration panel.
+ _m('Facebook integration configuration.'),
$action_name == 'facebookadminpanel',
'nav_facebook_admin_panel'
);
$action->menuItem(
common_local_url('facebooksettings'),
- // TRANS: Menu item tab.
+ // TRANS: Menu item for "Facebook" in user settings.
_m('MENU','Facebook'),
- // TRANS: Tooltip for menu item "Facebook".
- _m('Facebook settings'),
+ // TRANS: Menu title for "Facebook" in user settings.
+ _m('Facebook settings.'),
$action_name === 'facebooksettings'
);
-
}
}
-
}
/*
if (!empty($appId) && !empty($secret)) {
return true;
}
-
}
return false;
common_debug("LOGOUT URL = $logoutUrl");
common_redirect($logoutUrl, 303);
}
-
}
}
'author' => 'Craig Andrews, Zach Copley',
'homepage' => 'http://status.net/wiki/Plugin:FacebookBridge',
'rawdescription' =>
+ // TRANS: Plugin description.
_m('A plugin for integrating StatusNet with Facebook.')
);
*/
function title()
{
- return _m('Facebook');
+ // TRANS: Title for Facebook administration panel.
+ return _m('TITLE','Facebook integration settings');
}
/**
*/
function getInstructions()
{
+ // TRANS: Instruction for Facebook administration panel.
return _m('Facebook integration settings');
}
if (mb_strlen($values['facebook']['appid']) > 255) {
$this->clientError(
+ // TRANS: Client error displayed when providing too long a Facebook application ID.
_m("Invalid Facebook ID. Maximum length is 255 characters.")
);
}
if (mb_strlen($values['facebook']['secret']) > 255) {
$this->clientError(
+ // TRANS: Client error displayed when providing too long a Facebook secret key.
_m("Invalid Facebook secret. Maximum length is 255 characters.")
);
}
'fieldset',
array('id' => 'settings_facebook-application')
);
+ // TRANS: Fieldset legend.
$this->out->element('legend', null, _m('Facebook application settings'));
$this->out->elementStart('ul', 'form_data');
$this->li();
$this->input(
'appid',
+ // TRANS: Field label for Facebook application ID.
_m('Application ID'),
+ // TRANS: Field title for Facebook application ID.
_m('ID of your Facebook application.'),
'facebook'
);
$this->li();
$this->input(
'secret',
- _m('Secret'),
+ // TRANS: Field label for Facebook secret key.
+ _m('Secret'),
+ // TRANS: Field title for Facebook secret key.
_m('Application secret.'),
'facebook'
);
*/
function formActions()
{
- $this->out->submit('submit', _m('BUTTON','Save'), 'submit', null, _m('Save Facebook settings.'));
+ // TRANS: Button text to save Facebook integration settings.
+ $this->out->submit('submit', _m('BUTTON','Save'),
+ // TRANS: Button title to save Facebook integration settings.
+ 'submit', null, _m('Save Facebook settings.'));
}
}
}
}
}
-
-}
\ No newline at end of file
+}
private $fbuser = null; // Facebook user object (JSON)
function prepare($args) {
-
parent::prepare($args);
$this->facebook = new Facebook(
}
if (!empty($this->fbuser)) {
-
// OKAY, all is well... proceed to register
common_debug("Found a valid Facebook user.", __FILE__);
);
$this->clientError(
+ // TRANS: Client error displayed when trying to connect to Facebook while not logged in.
_m('You must be logged into Facebook to register a local account using Facebook.')
);
}
);
$this->clientError(
+ // TRANS: Client error displayed when trying to connect to a Facebook account that is already linked
+ // TRANS: in the same StatusNet site.
_m('There is already a local account linked with that Facebook account.')
);
if (!$token || $token != common_session_token()) {
$this->showForm(
+ // TRANS: Client error displayed when the session token does not match or is not given.
_m('There was a problem with your session token. Try again, please.')
);
return;
if (!$this->boolean('license')) {
$this->showForm(
+ // TRANS: Form validation error displayed when user has not agreed to the license.
_m('You cannot register if you do not agree to the license.'),
$this->trimmed('newname')
);
} else {
$this->showForm(
+ // TRANS: Form validation error displayed when an unhandled error occurs.
_m('An unknown error has occured.'),
$this->trimmed('newname')
);
$this->element(
'div', 'instructions',
- // TRANS: %s is the site name.
sprintf(
+ // TRANS: Form instructions for connecting to Facebook.
+ // TRANS: %s is the site name.
_m('This is the first time you have logged into %s so we must connect your Facebook to a local account. You can either create a new local account, or connect with an existing local account.'),
common_config('site', 'name')
)
}
/**
- * @fixme much of this duplicates core code, which is very fragile.
+ * @todo FIXME: Much of this duplicates core code, which is very fragile.
* Should probably be replaced with an extensible mini version of
* the core registration form.
*/
'class' => 'form_settings',
'action' => common_local_url('facebookfinishlogin')));
$this->elementStart('fieldset', array('id' => 'settings_facebook_connect_options'));
- // TRANS: Legend.
+ // TRANS: Fieldset legend.
$this->element('legend', null, _m('Connection options'));
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->elementStart('fieldset');
$this->hidden('token', common_session_token());
$this->element('legend', null,
- // TRANS: Legend.
+ // TRANS: Fieldset legend.
_m('Create new account'));
$this->element('p', null,
+ // TRANS: Form instructions.
_m('Create a new user with this nickname.'));
$this->elementStart('ul', 'form_data');
// TRANS: Field label.
$this->input('newname', _m('New nickname'),
($this->username) ? $this->username : '',
+ // TRANS: Field title.
_m('1-64 lowercase letters or numbers, no punctuation or spaces.'));
$this->elementEnd('li');
Event::handle('EndRegistrationFormData', array($this));
$this->elementEnd('ul');
- // TRANS: Submit button.
+ // TRANS: Submit button to create a new account.
$this->submit('create', _m('BUTTON','Create'));
$this->elementEnd('fieldset');
$this->elementStart('fieldset');
- // TRANS: Legend.
$this->element('legend', null,
+ // TRANS: Fieldset legend.
_m('Connect existing account'));
$this->element('p', null,
+ // TRANS: Form instructions.
_m('If you already have an account, login with your username and password to connect it to your Facebook.'));
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->input('nickname', _m('Existing nickname'));
$this->elementEnd('li');
$this->elementStart('li');
+ // TRANS: Field label.
$this->password('password', _m('Password'));
$this->elementEnd('li');
$this->elementEnd('ul');
- // TRANS: Submit button.
+ // TRANS: Submit button to connect a Facebook account to an existing StatusNet account.
$this->submit('connect', _m('BUTTON','Connect'));
$this->elementEnd('fieldset');
}
if (!User::allowed_nickname($nickname)) {
+ // TRANS: Form validation error displayed when picking a nickname that is not allowed.
$this->showForm(_m('Nickname not allowed.'));
return;
}
if (User::staticGet('nickname', $nickname)) {
+ // TRANS: Form validation error displayed when picking a nickname that is already in use.
$this->showForm(_m('Nickname already in use. Try another one.'));
return;
}
$result = $this->flinkUser($user->id, $this->fbuid);
if (!$result) {
+ // TRANS: Server error displayed when connecting to Facebook fails.
$this->serverError(_m('Error connecting user to Facebook.'));
return;
}
$password = $this->trimmed('password');
if (!common_check_user($nickname, $password)) {
+ // TRANS: Form validation error displayed when username/password combination is incorrect.
$this->showForm(_m('Invalid username or password.'));
return;
}
$result = $this->flinkUser($user->id, $this->fbuid);
if (empty($result)) {
+ // TRANS: Server error displayed when connecting to Facebook fails.
$this->serverError(_m('Error connecting user to Facebook.'));
return;
}
return false;
}
-
}
class FacebookloginAction extends Action
{
-
function handle($args)
{
parent::handle($args);
if (common_is_real_login()) {
+ // TRANS: Client error displayed when trying to login while already logged in.
$this->clientError(_m('Already logged in.'));
} else {
$this->showPage();
function getInstructions()
{
- // TRANS: Instructions.
+ // TRANS: Form instructions.
return _m('Login with your Facebook Account');
}
}
function showContent() {
-
$this->elementStart('fieldset');
$facebook = Facebookclient::getFacebook();
$attrs = array(
'src' => Plugin::staticPath('FacebookBridge', 'images/login-button.png'),
- 'alt' => 'Login with Facebook',
- 'title' => 'Login with Facebook'
+ // TRANS: Alt text for "Login with Facebook" image.
+ 'alt' => _m('Login with Facebook'),
+ // TRANS: Title for "Login with Facebook" image.
+ 'title' => _m('Login with Facebook.')
);
$this->element('img', $attrs);
$nav->show();
}
}
-
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->showForm(
+ // TRANS: Client error displayed when the session token does not match or is not given.
_m('There was a problem with your session token. Try again, please.')
);
return;
*/
function title() {
// TRANS: Page title for Facebook settings.
- return _m('Facebook settings');
+ return _m('TITLE','Facebook settings');
}
/**
* @return instructions for use
*/
function getInstructions() {
+ // TRANS: Instructions for Facebook settings.
return _m('Facebook settings');
}
$this->hidden('token', common_session_token());
+ // TRANS: Form note. User is connected to facebook.
$this->element('p', 'form_note', _m('Connected Facebook user'));
$this->elementStart('p', array('class' => 'facebook-user-display'));
$this->checkbox(
'noticesync',
+ // TRANS: Checkbox label in Facebook settings.
_m('Publish my notices to Facebook.'),
($this->flink) ? ($this->flink->noticesync & FOREIGN_NOTICE_SEND) : true
);
$this->checkbox(
'replysync',
+ // TRANS: Checkbox label in Facebook settings.
_m('Send "@" replies to Facebook.'),
($this->flink) ? ($this->flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true
);
$this->elementStart('fieldset');
- // TRANS: Legend.
+ // TRANS: Fieldset legend for form to disconnect from Facebook.
$this->element('legend', null, _m('Disconnect my account from Facebook'));
if (empty($this->user->password)) {
$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.'
$this->elementEnd('p');
} else {
// @todo FIXME: i18n: This message is not being used.
- $msg = sprintf(
- // TRANS: Message displayed when initiating disconnect of a StatusNet user
- // TRANS: from a Facebook account. %1$s is the StatusNet site name.
- _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: 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.
$result = $this->flink->update($original);
if ($result === false) {
+ // TRANS: Notice in case saving of synchronisation preferences fail.
$this->showForm(_m('There was a problem saving your sync preferences.'));
} else {
// TRANS: Confirmation that synchronisation settings have been saved into the system.
if ($result === false) {
common_log_db_error($user, 'DELETE', __FILE__);
+ // TRANS: Server error displayed when deleting the link to a Facebook account fails.
$this->serverError(_m('Could not delete link to Facebook.'));
return;
}
+ // TRANS: Confirmation message. StatusNet account was unlinked from Facebook.
$this->showForm(_m('You have disconnected from Facebook.'), true);
}
}
*
* @see DB_DataObject
*/
-
class Notice_to_item extends Memcached_DataObject
{
public $__table = 'notice_to_item'; // table name
* @return Notice_to_item object found, or null for no hits
*
*/
-
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Notice_to_item', $k, $v);
*
* @return array array of column definitions
*/
-
function table()
{
return array(
*
* @return array list of key field names
*/
-
function keys()
{
return array_keys($this->keyTypes());
* 'K' for primary key: for compound keys, add an entry for each component;
* 'U' for unique keys: compound keys are not well supported here.
*/
-
function keyTypes()
{
return array('notice_id' => 'K', 'item_id' => 'U');
*
* @return array magic three-false array that stops auto-incrementing.
*/
-
function sequenceKey()
{
return array(false, false, false);
*
* @return Notice_to_item new object for this value
*/
-
static function saveNew($notice_id, $item_id)
{
$n2i = Notice_to_item::staticGet('notice_id', $notice_id);
function checkPermission($permission)
{
if (!in_array($permission, array('publish_stream', 'status_update'))) {
- throw new ServerException("No such permission!");
+ // TRANS: Server exception thrown when permission check fails.
+ throw new ServerException(_('No such permission!'));
}
$fbuid = $this->flink->foreign_id;
);
return false;
-
}
}
),
__FILE__
);
- // @fixme: We want to rety at a later time when the throttling has expired
+ // @todo FIXME: We want to rety at a later time when the throttling has expired
// instead of just giving up.
return true;
break;
);
if (!empty($result)) { // result will contain the item ID
-
// Save a mapping
Notice_to_item::saveNew($this->notice->id, $result);
),
__FILE__
);
-
} else {
$msg = sprintf(
$result = $this->mailFacebookDisconnect();
if (!$result) {
-
$msg = 'Unable to send email to notify %s (%d), fbuid %d '
. 'about his/her Facebook link being removed.';
__FILE__
);
}
-
} else {
-
$msg = 'Unable to send email to notify %s (%d), fbuid %d '
. 'about his/her Facebook link being removed because the '
. 'user has not set an email address.';
common_switch_locale($this->user->language);
+ // TRANS: E-mail subject.
$subject = _m('Your Facebook connection has been removed');
- $msg = <<<BODY
-Hi %1$s,
-
-We're sorry to inform you we are unable to publish your notice to
-Facebook, and have removed the connection between your %2$s account and
-Facebook.
+ // TRANS: E-mail body. %1$s is a username, %2$s is the StatusNet sitename.
+ $msg = _m('Hi %1$s,\n\n'.
+ 'We are sorry to inform you we are unable to publish your notice to\n'.
+ 'Facebook, and have removed the connection between your %2$s account and\n'.
+ 'Facebook.\n\n'.
+ 'This may have happened because you have removed permission for %2$s\n'.
+ 'to post on your behalf, or perhaps you have deactivated your Facebook\n'.
+ 'account. You can reconnect your %2$s account to Facebook at any time by\n'.
+ 'logging in with Facebook again.\n\n'.
+ 'Sincerely,\n\n'.
+ '%2$s\n');
-This may have happened because you have removed permission for %2$s
-to post on your behalf, or perhaps you have deactivated your Facebook
-account. You can reconnect your %s account to Facebook at any time by
-logging in with Facebook again.
-
-Sincerely,
-
-%2$s
-BODY;
$body = sprintf(
- _m($msg),
+ $msg,
$this->user->nickname,
$siteName
);
common_switch_locale($user->language);
+ // TRANS: E-mail subject. %s is the StatusNet sitename.
$subject = _m('Contact the %s administrator to retrieve your account');
- $msg = <<<BODY
-Hi %1$s,
-
-We've noticed you have deauthorized the Facebook connection for your
-%2$s account. You have not set a password for your %2$s account yet, so
-you will not be able to login. If you wish to continue using your %2$s
-account, please contact the site administrator (%3$s) to set a password.
+ // TRANS: E-mail body. %1$s is a username,
+ // TRANS: %2$s is the StatusNet sitename, %3$s is the site contact e-mail address.
+ $msg = _m('Hi %1$s,\n\n'.
+ 'We have noticed you have deauthorized the Facebook connection for your\n'.
+ '%2$s account. You have not set a password for your %2$s account yet, so\n'.
+ 'you will not be able to login. If you wish to continue using your %2$s\n'.
+ 'account, please contact the site administrator (%3$s) to set a password.\n\n'.
+ 'Sincerely,\n\n'.
+ '%2$s\n');
-Sincerely,
-
-%2$s
-BODY;
$body = sprintf(
- _m($msg),
+ $msg,
$user->nickname,
$siteName,
$siteEmail
$n2i = Notice_to_item::staticGet('notice_id', $this->notice->id);
if (!empty($this->flink) && !empty($n2i)) {
-
try {
-
$result = $this->facebook->api(
array(
'method' => 'stream.remove',
);
if (!empty($result) && result == true) {
-
common_log(
LOG_INFO,
sprintf(
} else {
throw new FaceboookApiException(var_export($result, true));
}
-
} catch (FacebookApiException $e) {
common_log(
LOG_WARNING,
$n2i = Notice_to_item::staticGet('notice_id', $this->notice->id);
if (!empty($this->flink) && !empty($n2i)) {
-
try {
-
$result = $this->facebook->api(
array(
'method' => 'stream.addlike',
);
if (!empty($result) && result == true) {
-
common_log(
LOG_INFO,
sprintf(
),
__FILE__
);
-
} else {
throw new FacebookApiException(var_export($result, true));
}
-
} catch (FacebookApiException $e) {
common_log(
LOG_WARNING,
$n2i = Notice_to_item::staticGet('notice_id', $this->notice->id);
if (!empty($this->flink) && !empty($n2i)) {
-
try {
-
$result = $this->facebook->api(
array(
'method' => 'stream.removeLike',
);
if (!empty($result) && result == true) {
-
common_log(
LOG_INFO,
sprintf(
} else {
throw new FacebookApiException(var_export($result, true));
}
-
} catch (FacebookApiException $e) {
common_log(
LOG_WARNING,
}
}
}
-
}