From 4c677d75bef1f2e6c99e040ed79c712adf4262eb Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 17 Dec 2011 15:02:00 -0500 Subject: added a possible UI for logging in --- start.php | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'start.php') diff --git a/start.php b/start.php index 34f3e136f..bd80dde48 100644 --- a/start.php +++ b/start.php @@ -12,7 +12,10 @@ elgg_register_event_handler('init', 'system', 'openid_client_init'); * OpenID client initialization */ function openid_client_init() { + elgg_extend_view('css/elgg', 'openid_client/css'); + 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'; elgg_register_action('openid_client/login', "$base/login.php", 'public'); @@ -23,7 +26,7 @@ function openid_client_init() { elgg_register_event_handler('create', 'user', 'openid_client_set_subtype', 1); - elgg_register_page_handler('openid_client', 'openid_client_page_handler'); + //elgg_register_page_handler('openid_client', 'openid_client_page_handler'); } /** @@ -42,6 +45,43 @@ function openid_client_set_subtype($event, $type, $user) { update_data($query); } +/** + * 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', 'wordpress'), + ); + $items = elgg_trigger_plugin_hook('register', 'openid_login', null, $items); + + $priority = 100; + foreach ($items as $type => $servers) { + foreach ($servers as $server) { + $server_name = elgg_echo("openid_client:server:$server"); + $menu[] = ElggMenuItem::factory(array( + 'name' => $server, + 'text' => '', + 'title' => elgg_echo('openid_client:login:instructs', array($server_name)), + 'href' => "action/openid_client/login?server=$server", + 'is_action' => true, + 'section' => $type, + 'priority' => $priority, + )); + $priority += 10; + } + } + + return $menu; +} + /** * OpenID client page handler * -- cgit v1.2.3