diff --git a/serendipity_event_openid/ChangeLog b/serendipity_event_openid/ChangeLog
index 456a04ee..3a074f3f 100644
--- a/serendipity_event_openid/ChangeLog
+++ b/serendipity_event_openid/ChangeLog
@@ -1,3 +1,8 @@
+Version 1.0 (brockhaus)
+---------------------------------
+* Delegation: Configure what OpenID version the provider is supporting (Version 1 or 2 or both)
+* A little refactoring done to make code more readable.
+
Version 0.9 (brockhaus)
---------------------------------
* If no user has configured his OpenID yet, there will be no OpenID login but a info about that.
diff --git a/serendipity_event_openid/UTF-8/lang_de.inc.php b/serendipity_event_openid/UTF-8/lang_de.inc.php
index b335cbbb..b8eaf514 100644
--- a/serendipity_event_openid/UTF-8/lang_de.inc.php
+++ b/serendipity_event_openid/UTF-8/lang_de.inc.php
@@ -40,6 +40,12 @@ Wenn Du das aber nicht magst, kannst Du diese Auswahl ausschalten. Dann wird bei
@define('PLUGIN_OPENID_XRDS_LOC', 'OpenID XRDS Location');
@define('PLUGIN_OPENID_XRDS_LOC_DESC', 'URL des XRDS Dokumentes (wird meist nicht benötigt)');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED', 'OpenID Version');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED_DESC', 'Die OpenID Version, die Dein Provider unterstützt. Normaler Weise ist "Beide" die richtige Einstellung, aber wenn Du weißt, dass Dein Provider nur Version 1 oder nur Version 2 unterstützt, dann kannst Du das hier einstellen..');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED_V1', 'Nur OpenID Version 1');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED_V2', 'Nur OpenID Version 2');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED_BOTH', 'Beide OpenID Versionen');
+
@define('PLUGIN_OPENID_LOGIN_INPUT', 'Melde Dich mit Deiner OpenID an.');
@define('PLUGIN_OPENID_UPDATE_SUCCESS', 'Deine OpenID wurde erneuert.');
diff --git a/serendipity_event_openid/lang_de.inc.php b/serendipity_event_openid/lang_de.inc.php
index b3cd7ada..4af5879f 100644
--- a/serendipity_event_openid/lang_de.inc.php
+++ b/serendipity_event_openid/lang_de.inc.php
@@ -40,6 +40,12 @@ Wenn Du das aber nicht magst, kannst Du diese Auswahl ausschalten. Dann wird bei
@define('PLUGIN_OPENID_XRDS_LOC', 'OpenID XRDS Location');
@define('PLUGIN_OPENID_XRDS_LOC_DESC', 'URL des XRDS Dokumentes (wird meist nicht benötigt)');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED', 'OpenID Version');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED_DESC', 'Die OpenID Version, die Dein Provider unterstützt. Normaler Weise ist "Beide" die richtige Einstellung, aber wenn Du weißt, dass Dein Provider nur Version 1 oder nur Version 2 unterstützt, dann kannst Du das hier einstellen..');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED_V1', 'Nur OpenID Version 1');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED_V2', 'Nur OpenID Version 2');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED_BOTH', 'Beide OpenID Versionen');
+
@define('PLUGIN_OPENID_LOGIN_INPUT', 'Melde Dich mit Deiner OpenID an.');
@define('PLUGIN_OPENID_UPDATE_SUCCESS', 'Deine OpenID wurde erneuert.');
diff --git a/serendipity_event_openid/lang_en.inc.php b/serendipity_event_openid/lang_en.inc.php
index 9a19cc65..49c3f253 100644
--- a/serendipity_event_openid/lang_en.inc.php
+++ b/serendipity_event_openid/lang_en.inc.php
@@ -40,6 +40,12 @@ But if you don\'t like that you can switch this off and there will be a normal O
@define('PLUGIN_OPENID_XRDS_LOC', 'OpenID XRDS Location');
@define('PLUGIN_OPENID_XRDS_LOC_DESC', 'URL for XRDS Document Location (not needed normaly)');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED', 'OpenID Version');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED_DESC', 'The version your OpenID provider is supporting. Normaly "both" is okay, but if you know your provider does support only version 1 or only version 2 you can configure it here.');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED_V1', 'OpenID Version 1 only');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED_V2', 'OpenID Version 2 only');
+@define('PLUGIN_OPENID_VERSION_SUPPORTED_BOTH', 'Both OpenID Versions');
+
@define('PLUGIN_OPENID_LOGIN_INPUT', 'Logon using your OpenID.');
@define('PLUGIN_OPENID_UPDATE_SUCCESS', 'Your OpenID has been updated');
diff --git a/serendipity_event_openid/serendipity_event_openid.php b/serendipity_event_openid/serendipity_event_openid.php
index 7998b523..ba9f7d16 100644
--- a/serendipity_event_openid/serendipity_event_openid.php
+++ b/serendipity_event_openid/serendipity_event_openid.php
@@ -13,7 +13,7 @@ class serendipity_event_openid extends serendipity_event
$propbag->add('description', PLUGIN_OPENID_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Grischa Brockhaus, Rob Richards');
- $propbag->add('version', '0.9');
+ $propbag->add('version', '1.0');
$propbag->add('requirements', array(
'serendipity' => '1.2',
'smarty' => '2.6.7',
@@ -34,7 +34,8 @@ class serendipity_event_openid extends serendipity_event
'delegation_desc',
'server',
'delegate',
- 'xrds_location'
+ 'xrds_location',
+ 'openid_version'
));
}
@@ -73,6 +74,18 @@ class serendipity_event_openid extends serendipity_event
$propbag->add('description', PLUGIN_OPENID_XRDS_LOC_DESC);
$propbag->add('default', '');
break;
+ case 'openid_version':
+ $id_services = array(
+ 'both' => PLUGIN_OPENID_VERSION_SUPPORTED_BOTH,
+ 'v2' => PLUGIN_OPENID_VERSION_SUPPORTED_V2,
+ 'v1' => PLUGIN_OPENID_VERSION_SUPPORTED_V1,
+ );
+ $propbag->add('type', 'select');
+ $propbag->add('name', PLUGIN_OPENID_VERSION_SUPPORTED);
+ $propbag->add('description', PLUGIN_OPENID_VERSION_SUPPORTED_DESC);
+ $propbag->add('select_values', $id_services);
+ $propbag->add('default', 'both');
+ break;
default:
return false;
}
@@ -127,20 +140,7 @@ class serendipity_event_openid extends serendipity_event
}
break;
case 'frontend_header':
- $server = $this->get_config('server');
- $openidurl = $this->get_config('delegate');
- $xrdsloc = $this->get_config('xrds_location');
- if (! empty($server) && (! empty($openidurl) || ! empty($xrdsloc))) {
- /* Make sure linefeeds exist otherwise OpenID does not always work correctly */
- echo "\n";
- echo ' '."\n";
- if (! empty($openidurl)) {
- echo ' '."\n";
- }
- if (! empty($xrdsloc)) {
- echo ' '."\n";
- }
- }
+ $this->print_header();
break;
case 'backend_login_page':
@@ -152,91 +152,10 @@ class serendipity_event_openid extends serendipity_event
break;
case 'backend_login':
- $inOpenIdChange = !empty($serendipity['POST']['openidflag']) && ($serendipity['POST']['openidflag']==3);
- if ($eventData && !$inOpenIdChange) { // Eventdata holds "isAuthentificated". So if she is, let her in.
- return true;
- }
-
- $openidurl = NULL;
- if (!empty($serendipity['POST']['openid_url'])) {
- $openidurl = $serendipity['POST']['openid_url'];
- }
- elseif (isset($_POST['openIDLoginGoogle_x']) || isset($_POST['openIDLoginGoogle_y'])) { // If the Google Button was pressed
- $openidurl = "https://www.google.com/accounts/o8/id";
- }
- elseif (isset($_POST['openIDLoginYahoo_x']) || isset($_POST['openIDLoginYahoo_y'])) { // If the Google Button was pressed
- $openidurl = "https://me.yahoo.com";
- }
- elseif (isset($_POST['openIDLoginAol_x']) || isset($_POST['openIDLoginAol_y'])) { // If the Google Button was pressed
- $openidurl = "https://www.aol.com";
- }
-
- if ($_SESSION['serendipityAuthedUser'] == true) {
- $eventData = serendipity_common_openid::reauth_openid();
- if (!empty($openidurl) && !empty($serendipity['POST']['openidflag'])) {
- /* Check that openid isn't already associated with another login */
- $tmpRet = serendipity_common_openid::redir_openidserver($openidurl, $this->get_consumertest_path(), 3);
-
- /* If updating an OpenID it is not a real login attempt */
- if (($tmpRet === false) && (($serendipity['GET']['openidflag']==3) || ($serendipity['POST']['openidflag']==3))) {
- return;
- }
- $eventData = $tmpRet;
- } elseif (!empty($serendipity['POST']['openidflag'])) {
- $eventData = serendipity_common_openid::reauth_openid();
- }
- } else if (! empty($serendipity['GET']['openidflag']) && ($serendipity['GET']['openidflag']==1)) {
- $eventData = serendipity_common_openid::authenticate_openid($_GET, $this->get_consumertest_path());
- } else if (! empty($openidurl) && ! empty($serendipity['POST']['action'])) {
- $eventData = serendipity_common_openid::redir_openidserver($openidurl, $this->get_consumertest_path(), 1);
- }
- return $eventData;
+ return $this->do_login($eventData);
case 'backend_sidebar_entries_event_display_profiles':
- if (($_SESSION['serendipityAuthedUser'] == true)) {
- if (! empty($serendipity['GET']['openidflag']) && ($serendipity['GET']['openidflag']==3)) {
- if ($checkRet = serendipity_common_openid::authenticate_openid($_GET, $this->get_consumertest_path(), true)) {
- if (serendipity_common_openid::updateOpenID($checkRet['openID'], $serendipity['authorid'])) {
- echo '' . htmlspecialchars(PLUGIN_OPENID_UPDATE_SUCCESS) . '
';
- } else {
- echo '' . htmlspecialchars(PLUGIN_OPENID_UPDATE_FAIL) . '
';
- }
- } else {
- echo '' . htmlspecialchars(PLUGIN_OPENID_INVALID_RESPONSE) . '
';
- }
- // Job done.
- unset($serendipity['GET']['openidflag']);
- } elseif (! empty($serendipity['POST']['openidflag']) && ($serendipity['POST']['openidflag']==3)) {
- echo '' . htmlspecialchars(PLUGIN_OPENID_INVALID_RESPONSE) . '
';
- }
- }
- $imgopenid = $serendipity['baseURL'] . 'index.php?/plugin/openid.png';
- $imggoogle = $serendipity['baseURL'] . 'index.php?/plugin/oids_google.png';
- $imgyahoo = $serendipity['baseURL'] . 'index.php?/plugin/oids_yahoo.png';
- $imgaol = $serendipity['baseURL'] . 'index.php?/plugin/oids_aol.png';
-
- echo '