aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/openid_client/login.php15
-rw-r--r--classes/ElggOpenIDConsumer.php68
-rw-r--r--graphics/openid_providers.pngbin12400 -> 0 bytes
-rw-r--r--languages/en.php10
-rw-r--r--start.php60
-rw-r--r--views/default/forms/openid_client/login.php42
-rw-r--r--views/default/openid_client/css.php51
-rw-r--r--views/default/openid_client/js.php22
-rw-r--r--views/default/openid_client/login.php18
9 files changed, 82 insertions, 204 deletions
diff --git a/actions/openid_client/login.php b/actions/openid_client/login.php
index cf991ea0f..604374ced 100644
--- a/actions/openid_client/login.php
+++ b/actions/openid_client/login.php
@@ -6,11 +6,13 @@
elgg_load_library('openid_consumer');
$provider = get_input('openid_provider');
-$username = get_input('openid_username');
+
+if ($provider == 'others') {
+ $provider = get_input('openid_url');
+}
$consumer = new ElggOpenIDConsumer($store);
-$consumer->setProvider($provider);
-$consumer->setUsername($username);
+$consumer->setURL($provider);
$consumer->setReturnURL(elgg_get_site_url() . 'mod/openid_client/return.php');
$html = $consumer->requestAuthentication();
@@ -18,7 +20,12 @@ if ($html) {
echo $html;
exit;
} else {
- $provider_name = elgg_echo("openid_client:provider:$provider");
+ $flipped_providers = array_flip(elgg_get_config('openid_providers'));
+ if (isset($flipped_providers[$provider])) {
+ $provider_name = $flipped_providers[$provider];
+ } else {
+ $provider_name = $provider;
+ }
register_error(elgg_echo('openid_client:error:no_html', array($provider_name)));
forward();
}
diff --git a/classes/ElggOpenIDConsumer.php b/classes/ElggOpenIDConsumer.php
index 3918086ab..098201343 100644
--- a/classes/ElggOpenIDConsumer.php
+++ b/classes/ElggOpenIDConsumer.php
@@ -5,8 +5,7 @@
class ElggOpenIDConsumer {
- protected $provider;
- protected $username;
+ protected $openIdUrl;
protected $returnURL;
protected $store;
@@ -28,21 +27,12 @@ class ElggOpenIDConsumer {
}
/**
- * Set the name of the OpenID provider
- *
- * @param string $provider
- */
- public function setProvider($provider) {
- $this->provider = $provider;
- }
-
- /**
* Set the OpenID username
*
* @param string $username
*/
- public function setUsername($username) {
- $this->username = $username;
+ public function setURL($url) {
+ $this->openIdUrl = $url;
}
/**
@@ -70,7 +60,7 @@ class ElggOpenIDConsumer {
return false;
}
- $url = $this->getProviderURL();
+ $url = $this->openIdUrl;
if (!$url) {
return false;
}
@@ -123,56 +113,6 @@ class ElggOpenIDConsumer {
}
/**
- * Get the OpenID provider URL based on name
- *
- * @return string
- */
- protected function getProviderURL() {
- $url = null;
- $provider = $this->provider;
- $username = $this->username;
- switch ($provider) {
- case 'google':
- $url = 'https://www.google.com/accounts/o8/id';
- break;
- case 'yahoo':
- $url = 'https://me.yahoo.com/';
- break;
- case 'blogger':
- $url = "http://$username.blogspot.com/";
- break;
- case 'wordpress':
- // username is actually the blog name
- $url = "http://$username.wordpress.com/";
- break;
- case 'livejournal':
- $url = "http://$username.livejournal.com/";
- break;
- case 'aol':
- $url = "https://openid.aol.com/";
- break;
- case 'verisign':
- $url = "https://pip.verisignlabs.com/ ";
- break;
- case 'myopenid':
- $url = 'https://myopenid.com/';
- break;
- case 'myspace':
- $url = 'https://api.myspace.com/openid';
- break;
- default:
- $params = array(
- 'provider' => $provider,
- 'username' => $username,
- );
- $url = elgg_trigger_plugin_hook('set', 'openid_client:url', $params);
- break;
- }
-
- return $url;
- }
-
- /**
* Add attribute requests to the OpenID authentication request
*
* @return bool
diff --git a/graphics/openid_providers.png b/graphics/openid_providers.png
deleted file mode 100644
index 179e6d191..000000000
--- a/graphics/openid_providers.png
+++ /dev/null
Binary files differ
diff --git a/languages/en.php b/languages/en.php
index 34afb3700..4af3bf06a 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -5,13 +5,11 @@
$english = array(
+ 'openid_client' => 'OpenID',
'openid_client:login:header' => 'Log in with',
- 'openid_client:or:header' => 'or',
- 'openid_client:login:instructs' => 'Login in with %s',
- 'openid_client:provider:google' => 'Google',
- 'openid_client:provider:yahoo' => 'Yahoo',
- 'openid_client:provider:blogger' => 'Blogger',
- 'openid_client:provider:wordpress' => 'Wordpress',
+ 'openid_client:login' => 'Login in with OpenID',
+ 'openid_client:others' => 'Others...',
+ 'openid_client:url' => 'OpenID URL',
'openid_client:create' => 'Create an account',
'openid_client:create:instructs' => 'Your account has been approved. We just need you to confirm or set the below information.',
diff --git a/start.php b/start.php
index 82dcd5c11..1bf85eb74 100644
--- a/start.php
+++ b/start.php
@@ -15,7 +15,6 @@ function openid_client_init() {
elgg_extend_view('css/elgg', 'openid_client/css');
elgg_extend_view('js/elgg', 'openid_client/js');
- elgg_extend_view('core/account/login_box', 'openid_client/login');
elgg_register_plugin_hook_handler('register', 'menu:openid_login', 'openid_client_setup_menu');
$base = elgg_get_plugins_path() . 'openid_client/actions/openid_client';
@@ -24,6 +23,13 @@ function openid_client_init() {
$base = elgg_get_plugins_path() . 'openid_client/lib';
elgg_register_library('openid_client', "$base/helpers.php");
+
+ elgg_set_config('openid_providers', array(
+ 'N-1' => 'https://n-1.cc/openid/',
+ 'Ecoxarxes' => 'https://cooperativa.ecoxarxes.cat/openid/',
+ 'Anillosur' => 'https://anillosur.cc/openid/',
+ // ...
+ ));
// don't let OpenID users set their passwords
elgg_register_event_handler('pagesetup', 'system', 'openid_client_remove_password');
@@ -48,58 +54,6 @@ function openid_client_set_subtype($user) {
}
/**
- * Register login options
- *
- * @param string $hook
- * @param string $type
- * @param array $menu
- * @param array $params
- * @return array
- */
-function openid_client_setup_menu($hook, $type, $menu, $params) {
-
- $items = array(
- 'large' => array(
- 'google' => '',
- 'yahoo' => '',
- ),
- 'small' => array(
- 'blogger' => 'toggle',
- 'wordpress' => 'toggle',
- ),
- );
- $items = elgg_trigger_plugin_hook('register', 'openid_client:login', null, $items);
-
- $priority = 100;
- foreach ($items as $type => $providers) {
- foreach ($providers as $provider => $toggle) {
- $provider_name = elgg_echo("openid_client:provider:$provider");
-
- $options = array(
- 'name' => $provider,
- 'text' => '<span></span>',
- 'title' => elgg_echo('openid_client:login:instructs', array($provider_name)),
- 'href' => "action/openid_client/login?openid_provider=$provider",
- 'is_action' => true,
- 'section' => $type,
- 'priority' => $priority,
- );
-
- if ($toggle) {
- $options['link_class'] = 'openid-client-toggle';
- $options['rel'] = $provider;
- }
-
- $menu[] = ElggMenuItem::factory($options);
-
- $priority += 10;
- }
- }
-
- return $menu;
-}
-
-/**
* Remove the password view from the account settings form
*/
function openid_client_remove_password() {
diff --git a/views/default/forms/openid_client/login.php b/views/default/forms/openid_client/login.php
index eba6dbe4b..1f440dc49 100644
--- a/views/default/forms/openid_client/login.php
+++ b/views/default/forms/openid_client/login.php
@@ -3,11 +3,41 @@
* OpenID login if username or full url required
*/
-echo '<label>';
-echo elgg_echo('username');
-echo '</label>';
-echo elgg_view('input/text', array('name' => 'openid_username', 'class' => 'mbs'));
+$options_values = array_flip(elgg_get_config('openid_providers'));
+$options_values['others'] = elgg_echo('openid_client:others');
-echo elgg_view('input/hidden', array('name' => 'openid_provider'));
+?>
+<div>
+<label><?php echo elgg_echo('openid_client:login:header'); ?></label>
+<br />
+<?php
+echo elgg_view('input/dropdown', array(
+ 'name' => 'openid_provider',
+ 'options_values' => $options_values,
+));
+?>
+</div>
+
+<div class="openid-client-url hidden">
+<label><?php echo elgg_echo('openid_client:url'); ?> </label>
+
+<?php
+echo elgg_view('input/text', array('name' => 'openid_url', 'class' => 'mbs'));
+?>
+
+</div>
-echo elgg_view('input/submit', array('value' => elgg_echo('submit'))); \ No newline at end of file
+<div class="elgg-foot">
+ <label class="mtm float-alt">
+ <input type="checkbox" name="persistent" value="true" />
+ <?php echo elgg_echo('user:persistent'); ?>
+ </label>
+
+ <?php echo elgg_view('input/submit', array('value' => elgg_echo('login'))); ?>
+
+ <?php
+ if (isset($vars['returntoreferer'])) {
+ echo elgg_view('input/hidden', array('name' => 'returntoreferer', 'value' => 'true'));
+ }
+ ?>
+</div> \ No newline at end of file
diff --git a/views/default/openid_client/css.php b/views/default/openid_client/css.php
index 900de7e6e..d01fc6b5a 100644
--- a/views/default/openid_client/css.php
+++ b/views/default/openid_client/css.php
@@ -2,53 +2,12 @@
/**
* OpenID client CSS
*/
-
-$site_url = elgg_get_site_url();
-
?>
-.openid-client-login-or {
- margin-top: 5px;
- text-align: center;
- color: #333;
-}
-
-.elgg-menu-openid-login {
- text-align: center;
-}
-
-.elgg-menu-openid-login > li {
- margin: 3px;
-}
-
-.elgg-menu-openid-login span {
- display: block;
- background: url("<?php echo $site_url; ?>mod/openid_client/graphics/openid_providers.png") no-repeat left;
- border: 1px solid #ccc;
-}
-
-.elgg-menu-openid-login-large span {
- height: 32px;
- width: 92px;
+.elgg-icon-openid {
+ background-image: url(<?php echo elgg_get_site_url(); ?>mod/openid_client/graphics/openid_icon.png);
}
-.elgg-menu-openid-login-small span {
- height: 20px;
- width: 20px;
-}
-
-.elgg-menu-item-google span {
- background-position: -5px -14px;
-}
-
-.elgg-menu-openid-login-large > .elgg-menu-item-yahoo span {
- background-position: -105px -14px;
-}
-
-.elgg-menu-item-blogger span {
- background-position: -170px -62px;
-}
-
-.elgg-menu-item-wordpress span {
- background-position: -146px -62px;
-}
+.elgg-form-login {
+ margin-bottom: 10px;
+} \ No newline at end of file
diff --git a/views/default/openid_client/js.php b/views/default/openid_client/js.php
index 175577719..171215593 100644
--- a/views/default/openid_client/js.php
+++ b/views/default/openid_client/js.php
@@ -7,12 +7,20 @@
// OpenID toggle
elgg.register_hook_handler('init', 'system', function() {
- $(".openid-client-toggle").click(function(event) {
- $("#openid-client-login-form").slideDown();
-
- var provider_input = $("#openid-client-login-form input[name=openid_provider]");
- provider_input.attr('value', $(this).attr('rel'));
-
- event.preventDefault();
+ $('.openid-login-icon').click(function(e) {
+ var openid_box = $(this).prev('.elgg-form-openid-client-login');
+ var shown = openid_box.is(':visible') ? openid_box : openid_box.prev();
+ var hidden = !openid_box.is(':visible') ? openid_box : openid_box.prev();
+ shown.fadeOut(function() {
+ hidden.fadeIn();
+ });
+ e.preventDefault();
+ });
+ $(".elgg-form-openid-client-login [name='openid_provider']").change(function(event) {
+ if (this.value == 'others') {
+ $(".openid-client-url").slideDown().find('input').focus();
+ } else {
+ $(".openid-client-url").slideUp();
+ }
});
});
diff --git a/views/default/openid_client/login.php b/views/default/openid_client/login.php
deleted file mode 100644
index 30685fe51..000000000
--- a/views/default/openid_client/login.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-/**
- * OpenID client login choices
- */
-
-echo '<h3 class="openid-client-login-or">' . elgg_echo('openid_client:or:header') . '</h3>';
-echo '<h3>' . elgg_echo('openid_client:login:header') . '</h3>';
-
-echo elgg_view_menu('openid_login', array(
- 'class' => 'elgg-menu-hz',
- 'sort_by' => 'priority',
-));
-
-$form_vars = array(
- 'class' => 'hidden',
- 'id' => 'openid-client-login-form',
-);
-echo elgg_view_form('openid_client/login', $form_vars);