parent::prepare($args);
$this->code = $this->trimmed('code');
+ // @todo this check should really be in index.php for all sensitive actions
+ $ssl = common_config('site', 'ssl');
+ if (empty($_SERVER['HTTPS']) && ($ssl == 'always' || $ssl == 'sometimes')) {
+ common_redirect(common_local_url('register'));
+ // exit
+ }
+
if (empty($this->code)) {
common_ensure_session();
if (array_key_exists('invitecode', $_SESSION)) {
} else {
$instr =
common_markup_to_html(_('With this form you can create '.
- ' a new account. ' .
+ 'a new account. ' .
'You can then post notices and '.
'link up to friends and colleagues. '));
$err->showPage();
}
+ /**
+ * This should only be used at setup; processes switching languages
+ * to send text to other users should use common_switch_locale().
+ *
+ * @param string $language Locale language code (optional; empty uses
+ * current user's preference or site default)
+ * @return mixed success
+ */
function common_init_locale($language=null)
{
if(!$language) {
return $ok;
}
+ /**
+ * Initialize locale and charset settings and gettext with our message catalog,
+ * using the current user's language preference or the site default.
+ *
+ * This should generally only be run at framework initialization; code switching
+ * languages at runtime should call common_switch_language().
+ *
+ * @access private
+ */
function common_init_language()
{
mb_internal_encoding('UTF-8');
}
if (!empty($f)) {
- if ($f->getEnclosure()) {
+ if ($f->getEnclosure() || File_oembed::staticGet('file_id',$f->id)) {
$is_attachment = true;
$attachment_id = $f->id;
return XMLStringer::estring('a', $attrs, $url);
}
-function common_shorten_links($text)
+function common_shorten_links($text, $always = false)
{
$maxLength = Notice::maxContent();
- if ($maxLength == 0 || mb_strlen($text) <= $maxLength) return $text;
+ if (!$always && ($maxLength == 0 || mb_strlen($text) <= $maxLength)) return $text;
return common_replace_urls_callback($text, array('File_redirection', 'makeShort'));
}
if ($now < $t) { // that shouldn't happen!
return common_exact_date($dt);
} else if ($diff < 60) {
+ // TRANS: Used in notices to indicate when the notice was made compared to now.
return _('a few seconds ago');
} else if ($diff < 92) {
+ // TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a minute ago');
} else if ($diff < 3300) {
+ // XXX: should support plural.
+ // TRANS: Used in notices to indicate when the notice was made compared to now.
return sprintf(_('about %d minutes ago'), round($diff/60));
} else if ($diff < 5400) {
+ // TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about an hour ago');
} else if ($diff < 22 * 3600) {
+ // XXX: should support plural.
+ // TRANS: Used in notices to indicate when the notice was made compared to now.
return sprintf(_('about %d hours ago'), round($diff/3600));
} else if ($diff < 37 * 3600) {
+ // TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a day ago');
} else if ($diff < 24 * 24 * 3600) {
+ // XXX: should support plural.
+ // TRANS: Used in notices to indicate when the notice was made compared to now.
return sprintf(_('about %d days ago'), round($diff/(24*3600)));
} else if ($diff < 46 * 24 * 3600) {
+ // TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a month ago');
} else if ($diff < 330 * 24 * 3600) {
+ // XXX: should support plural.
+ // TRANS: Used in notices to indicate when the notice was made compared to now.
return sprintf(_('about %d months ago'), round($diff/(30*24*3600)));
} else if ($diff < 480 * 24 * 3600) {
+ // TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a year ago');
} else {
return common_exact_date($dt);
msgstr ""
"Project-Id-Version: StatusNet\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-04-24 14:16+0000\n"
-"PO-Revision-Date: 2010-05-03 19:17:42+0000\n"
+"POT-Creation-Date: 2010-05-16 15:39+0000\n"
+"PO-Revision-Date: 2010-05-16 15:39:44+0000\n"
"Language-Team: British English\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: MediaWiki 1.17alpha (r65870); Translate extension (2010-05-01)\n"
+"X-Generator: MediaWiki 1.17alpha (r66533); Translate extension (2010-05-15)\n"
"X-Translation-Project: translatewiki.net at http://translatewiki.net\n"
"X-Language-Code: en-gb\n"
"X-Message-Group: out-statusnet\n"
#: actions/apiaccountupdateprofilebackgroundimage.php:116
#: actions/apiaccountupdateprofileimage.php:105 actions/apiblockcreate.php:97
#: actions/apiblockdestroy.php:96 actions/apidirectmessage.php:77
-#: actions/apidirectmessagenew.php:75 actions/apigroupcreate.php:112
+#: actions/apidirectmessagenew.php:74 actions/apigroupcreate.php:112
#: actions/apigroupismember.php:90 actions/apigroupjoin.php:99
#: actions/apigroupleave.php:99 actions/apigrouplist.php:72
-#: actions/apistatusesupdate.php:239 actions/apisubscriptions.php:87
+#: actions/apistatusesupdate.php:227 actions/apisubscriptions.php:87
#: actions/apitimelinefavorites.php:71 actions/apitimelinefriends.php:173
#: actions/apitimelinehome.php:79 actions/apitimelinementions.php:79
#: actions/apitimelineuser.php:81 actions/avatarbynickname.php:75
#: actions/apiaccountupdateprofilebackgroundimage.php:86
#: actions/apiaccountupdateprofilecolors.php:110
#: actions/apiaccountupdateprofileimage.php:84 actions/apiblockcreate.php:89
-#: actions/apiblockdestroy.php:88 actions/apidirectmessagenew.php:117
+#: actions/apiblockdestroy.php:88 actions/apidirectmessagenew.php:109
#: actions/apifavoritecreate.php:90 actions/apifavoritedestroy.php:91
#: actions/apifriendshipscreate.php:91 actions/apifriendshipsdestroy.php:91
#: actions/apigroupcreate.php:104 actions/apigroupjoin.php:91
#: actions/apigroupleave.php:91 actions/apimediaupload.php:67
-#: actions/apistatusesretweet.php:65 actions/apistatusesupdate.php:209
+#: actions/apistatusesretweet.php:65 actions/apistatusesupdate.php:197
msgid "This method requires a POST."
msgstr "This method requires a POST."
#: actions/apiaccountupdateprofilebackgroundimage.php:108
#: actions/apiaccountupdateprofileimage.php:97 actions/apimediaupload.php:80
-#: actions/apistatusesupdate.php:222 actions/avatarsettings.php:257
+#: actions/apistatusesupdate.php:210 actions/avatarsettings.php:257
#: actions/designadminpanel.php:123 actions/editapplication.php:118
#: actions/newapplication.php:101 actions/newnotice.php:94
#: lib/designsettings.php:283
msgid "All the direct messages sent to %s"
msgstr "All the direct messages sent to %s"
-#: actions/apidirectmessagenew.php:126
+#: actions/apidirectmessagenew.php:118
msgid "No message text!"
msgstr "No message text!"
-#: actions/apidirectmessagenew.php:135 actions/newmessage.php:150
+#: actions/apidirectmessagenew.php:127 actions/newmessage.php:150
#, php-format
msgid "That's too long. Max message size is %d chars."
msgstr "That's too long. Max message size is %d chars."
-#: actions/apidirectmessagenew.php:146
+#: actions/apidirectmessagenew.php:138
msgid "Recipient user not found."
msgstr "Recipient user not found."
-#: actions/apidirectmessagenew.php:150
+#: actions/apidirectmessagenew.php:142
msgid "Can't send direct messages to users who aren't your friend."
msgstr "Can't send direct messages to users who aren't your friend."
msgid "No status with that ID found."
msgstr "No status with that ID found."
-#: actions/apistatusesupdate.php:252 actions/newnotice.php:155
+#: actions/apistatusesupdate.php:240 actions/newnotice.php:155
#: lib/mailhandler.php:60
#, php-format
msgid "That's too long. Max notice size is %d chars."
msgstr "That's too long. Max notice size is %d chars."
-#: actions/apistatusesupdate.php:293 actions/apiusershow.php:96
+#: actions/apistatusesupdate.php:281 actions/apiusershow.php:96
msgid "Not found."
msgstr "Not found."
-#: actions/apistatusesupdate.php:316 actions/newnotice.php:178
+#: actions/apistatusesupdate.php:304 actions/newnotice.php:178
#, php-format
msgid "Max notice size is %d chars, including attachment URL."
msgstr "Max notice size is %d chars, including attachment URL."
msgstr "Preview"
#: actions/avatarsettings.php:149 actions/showapplication.php:252
-#: lib/deleteuserform.php:66 lib/noticelist.php:656
+#: lib/deleteuserform.php:66 lib/noticelist.php:648
msgid "Delete"
msgstr "Delete"
msgstr "Do not delete this notice"
#. TRANS: Submit button title for 'Yes' when deleting a notice.
-#: actions/deletenotice.php:158 lib/noticelist.php:656
+#: actions/deletenotice.php:158 lib/noticelist.php:648
msgid "Delete this notice"
msgstr "Delete this notice"
#: actions/grantrole.php:66 actions/revokerole.php:66
msgid "This role is reserved and cannot be set."
-msgstr ""
+msgstr "This role is reserved and cannot be set."
#: actions/grantrole.php:75
msgid "You cannot grant user roles on this site."
"If you can't find the group you're looking for, you can [create it](%%action."
"newgroup%%) yourself."
msgstr ""
+"If you can't find the group you're looking for, you can [create it](%%action."
+"newgroup%%) yourself."
#: actions/groupsearch.php:85
#, php-format
"Why not [register an account](%%action.register%%) and [create the group](%%"
"action.newgroup%%) yourself!"
msgstr ""
+"Why not [register an account](%%action.register%%) and [create the group](%%"
+"action.newgroup%%) yourself!"
#: actions/groupunblock.php:91
msgid "Only an admin can unblock group members."
-msgstr ""
+msgstr "Only an admin can unblock group members."
#: actions/groupunblock.php:95
msgid "User is not blocked from group."
"changing your settings."
#: actions/login.php:270
-#, fuzzy
msgid "Login with your username and password."
-msgstr "Login with a username and password"
+msgstr "Login with your username and password."
#: actions/login.php:273
-#, fuzzy, php-format
+#, php-format
msgid ""
"Don't have a username yet? [Register](%%action.register%%) a new account."
msgstr ""
-"Login with your username and password. Don't have a username yet? [Register]"
-"(%%action.register%%) a new account."
+"Don't have a username yet? [Register](%%action.register%%) a new account."
#: actions/makeadmin.php:92
msgid "Only an admin can make another user an admin."
-msgstr ""
+msgstr "Only and admin can make another user an admin."
#: actions/makeadmin.php:96
#, php-format
#: actions/oauthappssettings.php:85
msgid "Applications you have registered"
-msgstr ""
+msgstr "Applications you have registered"
#: actions/oauthappssettings.php:135
#, php-format
msgid "You have not registered any applications yet."
-msgstr ""
+msgstr "You have not registered any applications yet."
#: actions/oauthconnectionssettings.php:72
msgid "Connected applications"
-msgstr ""
+msgstr "Connected applications"
#: actions/oauthconnectionssettings.php:83
msgid "You have allowed the following applications to access you account."
msgstr ""
#. TRANS: Client error on an API request with an unsupported data format.
-#: actions/oembed.php:183 actions/oembed.php:202 lib/apiaction.php:1131
-#: lib/apiaction.php:1160 lib/apiaction.php:1277
+#: actions/oembed.php:183 actions/oembed.php:202 lib/apiaction.php:1156
+#: lib/apiaction.php:1185 lib/apiaction.php:1302
msgid "Not a supported data format."
msgstr "Not a supported data format."
msgid "Registration successful"
msgstr "Registration successful"
-#: actions/register.php:114 actions/register.php:507 lib/logingroupnav.php:85
+#: actions/register.php:114 actions/register.php:499 lib/logingroupnav.php:85
msgid "Register"
msgstr "Register"
msgid "Longer name, preferably your \"real\" name"
msgstr "Longer name, preferably your \"real\" name"
-#: actions/register.php:494
+#: actions/register.php:511
+#, php-format
+msgid ""
+"I understand that content and data of %1$s are private and confidential."
+msgstr ""
+
+#: actions/register.php:521
+#, php-format
+msgid "My text and files are copyright by %1$s."
+msgstr ""
+
+#. TRANS: Copyright checkbox label in registration dialog, for all rights reserved with ownership left to contributors.
+#: actions/register.php:525
+msgid "My text and files remain under my own copyright."
+msgstr ""
+
+#. TRANS: Copyright checkbox label in registration dialog, for all rights reserved.
+#: actions/register.php:528
+msgid "All rights reserved."
+msgstr ""
+
+#. TRANS: Copyright checkbox label in registration dialog, for Creative Commons-style licenses.
+#: actions/register.php:533
#, php-format
msgid ""
"My text and files are available under %s except this private data: password, "
"My text and files are available under %s except this private data: password, "
"email address, IM address, and phone number."
-#: actions/register.php:542
+#: actions/register.php:576
#, php-format
msgid ""
"Congratulations, %1$s! And welcome to %%%%site.name%%%%. From here, you may "
"\n"
"Thanks for signing up and we hope you enjoy using this service."
-#: actions/register.php:566
+#: actions/register.php:600
msgid ""
"(You should receive a message by email momentarily, with instructions on how "
"to confirm your email address.)"
msgid "You already repeated that notice."
msgstr "You already repeated that notice."
-#: actions/repeat.php:114 lib/noticelist.php:675
+#: actions/repeat.php:114 lib/noticelist.php:667
msgid "Repeated"
msgstr "Repeated"
"You have no subscribers. Try subscribing to people you know and they might "
"return the favor"
msgstr ""
+"You have no subscribers. Try subscribing to people you know and they might "
+"return the favour"
#: actions/subscribers.php:110
#, php-format
#. TRANS: Message used to repeat a notice. RT is the abbreviation of 'retweet'.
#. TRANS: %1$s is the repeated user's name, %2$s is the repeated notice.
-#: classes/Notice.php:1533
+#: classes/Notice.php:1552
#, php-format
msgid "RT @%1$s %2$s"
msgstr "RT @%1$s %2$s"
#: lib/action.php:432
msgctxt "TOOLTIP"
msgid "Personal profile and friends timeline"
- msgstr "ersonal profile and friends timeline"
+ msgstr "Personal profile and friends timeline"
#. TRANS: Main menu option when logged in for access to personal profile and friends timeline
#: lib/action.php:435
#: lib/action.php:871
#, php-format
msgid "All %1$s content and data are available under the %2$s license."
-msgstr ""
+msgstr "All %1$s content and data are available under the %2$s licence."
#. TRANS: DT element for pagination (previous/next, etc.).
#: lib/action.php:1182
msgstr "Snapshots configuration"
#. TRANS: Client error 401.
-#: lib/apiauth.php:113
+#: lib/apiauth.php:112
msgid "API resource requires read-write access, but you only have read access."
msgstr ""
"tracks - not yet implemented.\n"
"tracking - not yet implemented.\n"
msgstr ""
+"Commands:\n"
+"on - turn on notifications\n"
+"off - turn off notifications\n"
+"help - show this help\n"
+"follow <nickname> - subscribe to user\n"
+"groups - lists the groups you have joined\n"
+"subscriptions - list the people you follow\n"
+"subscribers - list the people that follow you\n"
+"leave <nickname> - unsubscribe from user\n"
+"d <nickname> <text> - direct message to user\n"
+"get <nickname> - get last notice from user\n"
+"whois <nickname> - get profile info on user\n"
+"lose <nickname> - force user to stop following you\n"
+"fav <nickname> - add user's last notice as a 'fave'\n"
+"fav #<notice_id> - add notice with the given id as a 'fave'\n"
+"repeat #<notice_id> - repeat a notice with a given id\n"
+"repeat <nickname> - repeat the last notice from user\n"
+"reply #<notice_id> - reply to notice with a given id\n"
+"reply <nickname> - reply to the last notice from user\n"
+"join <group> - join group\n"
+"login - Get a link to login to the web interface\n"
+"drop <group> - leave group\n"
+"stats - get your stats\n"
+"stop - same as 'off'\n"
+"quit - same as 'off'\n"
+"sub <nickname> - same as 'follow'\n"
+"unsub <nickname> - same as 'leave'\n"
+"last <nickname> - same as 'get'\n"
+"on <nickname> - not yet implemented.\n"
+"off <nickname> - not yet implemented.\n"
+"nudge <nickname> - remind a user to update.\n"
+"invite <phone number> - not yet implemented.\n"
+"track <word> - not yet implemented.\n"
+"untrack <word> - not yet implemented.\n"
+"track off - not yet implemented.\n"
+"untrack all - not yet implemented.\n"
+"tracks - not yet implemented.\n"
+"tracking - not yet implemented.\n"
#: lib/common.php:135
msgid "No configuration file found. "
#: lib/connectsettingsaction.php:121
msgid "Authorized connected applications"
-msgstr ""
+msgstr "Authorised connected applications"
#: lib/dberroraction.php:60
msgid "Database error"
"users in conversation. People can send you messages for your eyes only."
msgstr ""
-#: lib/mailbox.php:227 lib/noticelist.php:494
+#: lib/mailbox.php:227 lib/noticelist.php:497
msgid "from"
msgstr "from"
msgid "at"
msgstr ""
-#: lib/noticelist.php:567
+#: lib/noticelist.php:559
msgid "in context"
msgstr "in context"
-#: lib/noticelist.php:602
+#: lib/noticelist.php:594
msgid "Repeated by"
msgstr "Repeated by"
-#: lib/noticelist.php:629
+#: lib/noticelist.php:621
msgid "Reply to this notice"
msgstr "Reply to this notice"
-#: lib/noticelist.php:630
+#: lib/noticelist.php:622
msgid "Reply"
msgstr "Reply"
-#: lib/noticelist.php:674
+#: lib/noticelist.php:666
msgid "Notice repeated"
msgstr "Notice repeated"
#: lib/userprofile.php:264
msgid "Edit"
-msgstr ""
+msgstr "Edit"
#: lib/userprofile.php:287
msgid "Send a direct message to this user"
#: lib/userprofile.php:326
msgid "Moderate"
-msgstr ""
+msgstr "Moderate"
#: lib/userprofile.php:364
msgid "User role"
#: lib/userprofile.php:367
msgctxt "role"
msgid "Moderator"
-msgstr ""
+msgstr "Moderator"
#. TRANS: Used in notices to indicate when the notice was made compared to now.
#: lib/util.php:1083
* @category Plugin
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
- * @copyright 2009 StatusNet, Inc.
+ * @copyright 2009-2010 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
class OpenIDPlugin extends Plugin
{
- public $openidOnly = false;
+ // Plugin parameter: set true to disallow non-OpenID logins
+ // If set, overrides the setting in database or $config['site']['openidonly']
+ public $openidOnly = null;
+
+ function initialize()
+ {
+ parent::initialize();
+ if ($this->openidOnly !== null) {
+ global $config;
+ $config['site']['openidonly'] = (bool)$this->openidOnly;
+ }
+
+ }
/**
* Add OpenID-related paths to the router table
$m->connect('index.php?action=finishaddopenid',
array('action' => 'finishaddopenid'));
$m->connect('main/openidserver', array('action' => 'openidserver'));
+ $m->connect('admin/openid', array('action' => 'openidadminpanel'));
return true;
}
function onStartConnectPath(&$path, &$defaults, &$rules, &$result)
{
- if ($this->openidOnly) {
+ if (common_config('site', 'openidonly')) {
static $block = array('main/login',
'main/register',
'main/recoverpassword',
function onArgsInitialize($args)
{
- if ($this->openidOnly) {
+ if (common_config('site', 'openidonly')) {
if (array_key_exists('action', $args)) {
$action = trim($args['action']);
if (in_array($action, array('login', 'register'))) {
function onStartPrimaryNav($action)
{
- if ($this->openidOnly && !common_logged_in()) {
+ if (common_config('site', 'openidonly') && !common_logged_in()) {
// TRANS: Tooltip for main menu option "Login"
$tooltip = _m('TOOLTIP', 'Login to the site');
- // TRANS: Main menu option when not logged in to log in
$action->menuItem(common_local_url('openidlogin'),
+ // TRANS: Main menu option when not logged in to log in
_m('MENU', 'Login'),
$tooltip,
false,
'nav_login');
// TRANS: Tooltip for main menu option "Help"
$tooltip = _m('TOOLTIP', 'Help me!');
- // TRANS: Main menu option for help on the StatusNet site
$action->menuItem(common_local_url('doc', array('title' => 'help')),
+ // TRANS: Main menu option for help on the StatusNet site
_m('MENU', 'Help'),
$tooltip,
false,
if (!common_config('site', 'private')) {
// TRANS: Tooltip for main menu option "Search"
$tooltip = _m('TOOLTIP', 'Search for people or text');
- // TRANS: Main menu option when logged in or when the StatusNet instance is not private
$action->menuItem(common_local_url('peoplesearch'),
+ // TRANS: Main menu option when logged in or when the StatusNet instance is not private
_m('MENU', 'Search'), $tooltip, false, 'nav_search');
}
Event::handle('EndPrimaryNav', array($action));
function onStartLoginGroupNav(&$action)
{
- if ($this->openidOnly) {
+ if (common_config('site', 'openidonly')) {
$this->showOpenIDLoginTab($action);
// Even though we replace this code, we
// DON'T run the End* hook, to keep others from
$action_name = $action->trimmed('action');
$action->menuItem(common_local_url('openidlogin'),
- _m('OpenID'),
+ // TRANS: OpenID plugin menu item on site logon page.
+ _m('MENU', 'OpenID'),
+ // TRANS: OpenID plugin tooltip for logon menu item.
_m('Login or register with OpenID'),
$action_name === 'openidlogin');
}
*/
function onStartAccountSettingsPasswordMenuItem($menu, &$unused) {
- if ($this->openidOnly) {
+ if (common_config('site', 'openidonly')) {
return false;
}
return true;
$action_name = $action->trimmed('action');
$action->menuItem(common_local_url('openidsettings'),
- _m('OpenID'),
+ // TRANS: OpenID plugin menu item on user settings page.
+ _m('MENU', 'OpenID'),
+ // TRANS: OpenID plugin tooltip for user settings menu item.
_m('Add or remove OpenIDs'),
$action_name === 'openidsettings');
case 'OpenidsettingsAction':
case 'OpenidserverAction':
case 'OpenidtrustAction':
- require_once INSTALLDIR.'/plugins/OpenID/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
+ case 'OpenidadminpanelAction':
+ require_once dirname(__FILE__) . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
return false;
case 'User_openid':
- require_once INSTALLDIR.'/plugins/OpenID/User_openid.php';
+ require_once dirname(__FILE__) . '/User_openid.php';
return false;
case 'User_openid_trustroot':
- require_once INSTALLDIR.'/plugins/OpenID/User_openid_trustroot.php';
+ require_once dirname(__FILE__) . '/User_openid_trustroot.php';
+ return false;
+ case 'Auth_OpenID_TeamsExtension':
+ case 'Auth_OpenID_TeamsRequest':
+ case 'Auth_OpenID_TeamsResponse':
+ require_once dirname(__FILE__) . '/extlib/teams-extension.php';
return false;
default:
return true;
function onRedirectToLogin($action, $user)
{
- if ($this->openidOnly || (!empty($user) && User_openid::hasOpenID($user->id))) {
+ if (common_config('site', 'openid_only') || (!empty($user) && User_openid::hasOpenID($user->id))) {
common_redirect(common_local_url('openidlogin'), 303);
return false;
}
return true;
}
+ /**
+ * Add an OpenID tab to the admin panel
+ *
+ * @param Widget $nav Admin panel nav
+ *
+ * @return boolean hook value
+ */
+
+ function onEndAdminPanelNav($nav)
+ {
+ if (AdminPanelAction::canAdmin('openid')) {
+
+ $action_name = $nav->action->trimmed('action');
+
+ $nav->out->menuItem(
+ common_local_url('openidadminpanel'),
+ _m('OpenID'),
+ _m('OpenID configuration'),
+ $action_name == 'openidadminpanel',
+ 'nav_openid_admin_panel'
+ );
+ }
+
+ return true;
+ }
+
/**
* Add our version information to output
*
'author' => 'Evan Prodromou, Craig Andrews',
'homepage' => 'http://status.net/wiki/Plugin:OpenID',
'rawdescription' =>
+ // TRANS: OpenID plugin description.
_m('Use <a href="http://openid.net/">OpenID</a> to login to the site.'));
return true;
}
{
parent::handle($args);
if (!common_logged_in()) {
+ // TRANS: Client error message
$this->clientError(_m('Not logged in.'));
} else {
$this->tryLogin();
$response = $consumer->complete(common_local_url('finishaddopenid'));
if ($response->status == Auth_OpenID_CANCEL) {
+ // TRANS: Status message in case the response from the OpenID provider is that the logon attempt was cancelled.
$this->message(_m('OpenID authentication cancelled.'));
return;
} else if ($response->status == Auth_OpenID_FAILURE) {
- // Authentication failed; display the error message.
+ // TRANS: OpenID authentication failed; display the error message.
+ // TRANS: %s is the error message.
$this->message(sprintf(_m('OpenID authentication failed: %s'),
$response->message));
} else if ($response->status == Auth_OpenID_SUCCESS) {
$sreg = $sreg_resp->contents();
}
+ // Launchpad teams extension
+ if (!oid_check_teams($response)) {
+ $this->message(_m('OpenID authentication aborted: you are not allowed to login to this site.'));
+ return;
+ }
+
$cur = common_current_user();
$other = oid_get_user($canonical);
if ($other) {
if ($other->id == $cur->id) {
+ // TRANS: message in case a user tries to add an OpenID that is already connected to them.
$this->message(_m('You already have this OpenID!'));
} else {
+ // TRANS: message in case a user tries to add an OpenID that is already used by another user.
$this->message(_m('Someone else already has this OpenID.'));
}
return;
$result = oid_link_user($cur->id, $canonical, $display);
if (!$result) {
+ // TRANS: message in case the OpenID object cannot be connected to the user.
$this->message(_m('Error connecting user.'));
return;
}
if ($sreg) {
if (!oid_update_user($cur, $sreg)) {
+ // TRANS: message in case the user or the user profile cannot be saved in StatusNet.
$this->message(_m('Error updating profile'));
return;
}
function title()
{
+ // TRANS: Title after getting the status of the OpenID authorisation request.
return _m('OpenID Login');
}
{
parent::handle($args);
if (common_is_real_login()) {
+ // TRANS: Client error message trying to log on with OpenID while already logged on.
$this->clientError(_m('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
+ // TRANS: Message given when there is a problem with the user's session token.
$this->showForm(_m('There was a problem with your session token. Try again, please.'));
return;
}
if ($this->arg('create')) {
if (!$this->boolean('license')) {
+ // TRANS: Message given if user does not agree with the site's license.
$this->showForm(_m('You can\'t register if you don\'t agree to the license.'),
$this->trimmed('newname'));
return;
} else if ($this->arg('connect')) {
$this->connectUser();
} else {
- $this->showForm(_m('Something weird happened.'),
+ // TRANS: Messag given on an unknown error.
+ $this->showForm(_m('An unknown error has occured.'),
$this->trimmed('newname'));
}
} else {
$this->element('div', array('class' => 'error'), $this->error);
} else {
$this->element('div', 'instructions',
+ // TRANS: Instructions given after a first successful logon using OpenID.
+ // TRANS: %s is the site name.
sprintf(_m('This is the first time you\'ve logged into %s so we must connect your OpenID to a local account. You can either create a new account, or connect with your existing account, if you have one.'), common_config('site', 'name')));
}
}
function title()
{
+ // TRANS: Title
return _m('OpenID Account Setup');
}
'value' => 'true'));
$this->elementStart('label', array('for' => 'license',
'class' => 'checkbox'));
+ // TRANS: OpenID plugin link text.
+ // TRANS: %s is a link to a licese with the license name as link text.
$message = _('My text and files are available under %s ' .
'except this private data: password, ' .
'email address, IM address, and phone number.');
$this->elementEnd('label');
$this->elementEnd('li');
$this->elementEnd('ul');
- $this->submit('create', _m('Create'));
+ // TRANS: Button label in form in which to create a new user on the site for an OpenID.
+ $this->submit('create', _m('BUTTON', 'Create'));
$this->elementEnd('fieldset');
$this->elementStart('fieldset', array('id' => 'form_openid_createaccount'));
$this->element('legend', null,
+ // TRANS: Used as form legend for form in which to connect an OpenID to an existing user on the site.
_m('Connect existing account'));
$this->element('p', null,
+ // TRANS: User instructions for form in which to connect an OpenID to an existing user on the site.
_m('If you already have an account, login with your username and password to connect it to your OpenID.'));
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
+ // TRANS: Field label in form in which to connect an OpenID to an existing user on the site.
$this->input('nickname', _m('Existing nickname'));
$this->elementEnd('li');
$this->elementStart('li');
+ // TRANS: Field label in form in which to connect an OpenID to an existing user on the site.
$this->password('password', _m('Password'));
$this->elementEnd('li');
$this->elementEnd('ul');
- $this->submit('connect', _m('Connect'));
+ // TRANS: Button label in form in which to connect an OpenID to an existing user on the site.
+ $this->submit('connect', _m('BUTTON', 'Connect'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}
$response = $consumer->complete(common_local_url('finishopenidlogin'));
if ($response->status == Auth_OpenID_CANCEL) {
+ // TRANS: Status message in case the response from the OpenID provider is that the logon attempt was cancelled.
$this->message(_m('OpenID authentication cancelled.'));
return;
} else if ($response->status == Auth_OpenID_FAILURE) {
- // Authentication failed; display the error message.
+ // TRANS: OpenID authentication failed; display the error message. %s is the error message.
$this->message(sprintf(_m('OpenID authentication failed: %s'), $response->message));
} else if ($response->status == Auth_OpenID_SUCCESS) {
// This means the authentication succeeded; extract the
$sreg = $sreg_resp->contents();
}
+ // Launchpad teams extension
+ if (!oid_check_teams($response)) {
+ $this->message(_m('OpenID authentication aborted: you are not allowed to login to this site.'));
+ return;
+ }
+
$user = oid_get_user($canonical);
if ($user) {
# FIXME: save invite code before redirect, and check here
if (common_config('site', 'closed')) {
+ // TRANS: OpenID plugin message. No new user registration is allowed on the site.
$this->clientError(_m('Registration not allowed.'));
return;
}
if (common_config('site', 'inviteonly')) {
$code = $_SESSION['invitecode'];
if (empty($code)) {
+ // TRANS: OpenID plugin message. No new user registration is allowed on the site without an invitation code, and none was provided.
$this->clientError(_m('Registration not allowed.'));
return;
}
$invite = Invitation::staticGet($code);
if (empty($invite)) {
+ // TRANS: OpenID plugin message. No new user registration is allowed on the site without an invitation code, and the one provided was not valid.
$this->clientError(_m('Not a valid invitation code.'));
return;
}
if (!Validate::string($nickname, array('min_length' => 1,
'max_length' => 64,
'format' => NICKNAME_FMT))) {
+ // TRANS: OpenID plugin message. The entered new user name did not conform to the requirements.
$this->showForm(_m('Nickname must have only lowercase letters and numbers and no spaces.'));
return;
}
if (!User::allowed_nickname($nickname)) {
+ // TRANS: OpenID plugin message. The entered new user name is blacklisted.
$this->showForm(_m('Nickname not allowed.'));
return;
}
if (User::staticGet('nickname', $nickname)) {
+ // TRANS: OpenID plugin message. The entered new user name is already used.
$this->showForm(_m('Nickname already in use. Try another one.'));
return;
}
list($display, $canonical, $sreg) = $this->getSavedValues();
if (!$display || !$canonical) {
+ // TRANS: OpenID plugin server error. A stored OpenID cannot be retrieved.
$this->serverError(_m('Stored OpenID not found.'));
return;
}
$other = oid_get_user($canonical);
if ($other) {
+ // TRANS: OpenID plugin server error.
$this->serverError(_m('Creating new account for OpenID that already has a user.'));
return;
}
$password = $this->trimmed('password');
if (!common_check_user($nickname, $password)) {
+ // TRANS: OpenID plugin message.
$this->showForm(_m('Invalid username or password.'));
return;
}
list($display, $canonical, $sreg) = $this->getSavedValues();
if (!$display || !$canonical) {
+ // TRANS: OpenID plugin server error. A stored OpenID cannot be found.
$this->serverError(_m('Stored OpenID not found.'));
return;
}
$result = oid_link_user($user->id, $canonical, $display);
if (!$result) {
+ // TRANS: OpenID plugin server error. The user or user profile could not be saved.
$this->serverError(_m('Error connecting user to OpenID.'));
return;
}
$consumer = oid_consumer();
if (!$consumer) {
+ // TRANS: OpenID plugin server error.
common_server_error(_m('Cannot instantiate OpenID consumer object.'));
return false;
}
// Handle failure status return values.
if (!$auth_request) {
+ // TRANS: OpenID plugin message. Given when an OpenID is not valid.
return _m('Not a valid OpenID.');
} else if (Auth_OpenID::isFailure($auth_request)) {
+ // TRANS: OpenID plugin server error. Given when the OpenID authentication request fails.
+ // TRANS: %s is the failure message.
return sprintf(_m('OpenID failure: %s'), $auth_request->message);
}
$auth_request->addExtension($sreg_request);
}
+ $requiredTeam = common_config('openid', 'required_team');
+ if ($requiredTeam) {
+ // LaunchPad OpenID extension
+ $team_request = new Auth_OpenID_TeamsRequest(array($requiredTeam));
+ if ($team_request) {
+ $auth_request->addExtension($team_request);
+ }
+ }
+
$trust_root = common_root_url(true);
$process_url = common_local_url($returnto);
$immediate);
if (!$redirect_url) {
} else if (Auth_OpenID::isFailure($redirect_url)) {
+ // TRANS: OpenID plugin server error. Given when the OpenID authentication request cannot be redirected.
+ // TRANS: %s is the failure message.
return sprintf(_m('Could not redirect to server: %s'), $redirect_url->message);
} else {
common_redirect($redirect_url, 303);
// Display an error if the form markup couldn't be generated;
// otherwise, render the HTML.
if (Auth_OpenID::isFailure($form_html)) {
+ // TRANS: OpenID plugin server error if the form markup could not be generated.
+ // TRANS: %s is the failure message.
common_server_error(sprintf(_m('Could not create OpenID form: %s'), $form_html->message));
} else {
$action = new AutosubmitAction(); // see below
function _oid_print_instructions()
{
common_element('div', 'instructions',
+ // TRANS: OpenID plugin user instructions.
_m('This form should automatically submit itself. '.
'If not, click the submit button to go to your '.
'OpenID provider.'));
# XXX save timezone if it's passed
if (!$profile->update($orig_profile)) {
+ // TRANS: OpenID plugin server error.
common_server_error(_m('Error saving the profile.'));
return false;
}
}
if (!$user->update($orig_user)) {
+ // TRANS: OpenID plugin server error.
common_server_error(_m('Error saving the user.'));
return false;
}
return;
}
}
+ // TRANS: OpenID plugin client exception (403).
throw new ClientException(_m("Unauthorized URL used for OpenID login."), 403);
}
}
return;
}
+ /**
+ * Check the teams available in the given OpenID response
+ * Using Launchpad's OpenID teams extension
+ *
+ * @return boolean whether this user is acceptable
+ */
+ function oid_check_teams($response)
+ {
+ $requiredTeam = common_config('openid', 'required_team');
+ if ($requiredTeam) {
+ $team_resp = new Auth_OpenID_TeamsResponse($response);
+ if ($team_resp) {
+ $teams = $team_resp->getTeams();
+ } else {
+ $teams = array();
+ }
+
+ $match = in_array($requiredTeam, $teams);
+ $is = $match ? 'is' : 'is not';
+ common_log(LOG_DEBUG, "Remote user $is in required team $requiredTeam: [" . implode(', ', $teams) . "]");
+
+ return $match;
+ }
+
+ return true;
+ }
+
class AutosubmitAction extends Action
{
var $form_html = null;
function title()
{
+ // TRANS: Title
return _m('OpenID Login Submission');
}
$this->element('img', array('src' => Theme::path('images/icons/icon_processing.gif', 'base'),
// for some reason the base CSS sets <img>s as block display?!
'style' => 'display: inline'));
+ // TRANS: OpenID plugin message used while requesting authorization user's OpenID login provider.
$this->text(_m('Requesting authorization from your login provider...'));
$this->raw('</p>');
$this->raw('<p style="margin-top: 60px; font-style: italic">');
+ // TRANS: OpenID plugin message. User instruction while requesting authorization user's OpenID login provider.
$this->text(_m('If you are not redirected to your login provider in a few seconds, try pushing the button below.'));
$this->raw('</p>');
$this->raw($this->form_html);
{
parent::handle($args);
if (common_is_real_login()) {
+ // TRANS: Client error message trying to log on with OpenID while already logged on.
$this->clientError(_m('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- $openid_url = $this->trimmed('openid_url');
+ $provider = common_config('openid', 'trusted_provider');
+ if ($provider) {
+ $openid_url = $provider;
+ } else {
+ $openid_url = $this->trimmed('openid_url');
+ }
oid_assert_allowed($openid_url);
# CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
+ // TRANS: Message given when there is a problem with the user's session token.
$this->showForm(_m('There was a problem with your session token. Try again, please.'), $openid_url);
return;
}
common_get_returnto()) {
// rememberme logins have to reauthenticate before
// changing any profile settings (cookie-stealing protection)
+ // TRANS: OpenID plugin message. Rememberme logins have to reauthenticate before changing any profile settings.
+ // TRANS: "OpenID" is the display text for a link with URL "(%%doc.openid%%)".
return _m('For security reasons, please re-login with your ' .
'[OpenID](%%doc.openid%%) ' .
'before changing your settings.');
} else {
+ // TRANS: OpenID plugin message.
+ // TRANS: "OpenID" is the display text for a link with URL "(%%doc.openid%%)".
return _m('Login with an [OpenID](%%doc.openid%%) account.');
}
}
function title()
{
+ // TRANS: OpenID plugin message. Title.
return _m('OpenID Login');
}
'class' => 'form_settings',
'action' => $formaction));
$this->elementStart('fieldset');
+ // TRANS: OpenID plugin logon form legend.
$this->element('legend', null, _m('OpenID login'));
$this->hidden('token', common_session_token());
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
- // TRANS: OpenID plugin logon form field label.
- $this->input('openid_url', _m('OpenID URL'),
- $this->openid_url,
- // TRANS: OpenID plugin logon form field instructions.
- _m('Your OpenID URL'));
+ $provider = common_config('openid', 'trusted_provider');
+ if ($provider) {
+ $this->element('label', array(), _m('OpenID provider'));
+ $this->element('span', array(), $provider);
+ $this->element('p', 'form_guide',
+ _m('You will be sent to the provider\'s site for authentication.'));
+ $this->hidden('openid_url', $provider);
+ } else {
++ // TRANS: OpenID plugin logon form field label.
+ $this->input('openid_url', _m('OpenID URL'),
+ $this->openid_url,
++ // TRANS: OpenID plugin logon form field instructions.
+ _m('Your OpenID URL'));
+ }
$this->elementEnd('li');
$this->elementStart('li', array('id' => 'settings_rememberme'));
+ // TRANS: OpenID plugin logon form checkbox label for setting to put the OpenID information in a cookie.
$this->checkbox('rememberme', _m('Remember me'), false,
+ // TRANS: OpenID plugin logon form field instructions.
_m('Automatically login in the future; ' .
'not for shared computers!'));
$this->elementEnd('li');
$this->elementEnd('ul');
- $this->submit('submit', _m('Login'));
+ // TRANS: OpenID plugin logon form button label to start logon with the data provided in the logon form.
+ $this->submit('submit', _m('BUTTON', 'Login'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}