From c6165b34bd96aeb85dcb5f99ff55c8cbc9af89c1 Mon Sep 17 00:00:00 2001 From: Young Hahn Date: Tue, 2 Mar 2010 17:03:53 -0500 Subject: [PATCH] Finishing site display. --- osso_provider.defaults.inc | 38 +++++++++++++++++ osso_provider.features.views.inc | 12 ++++++ osso_provider.info | 1 + osso_provider.module | 42 ++++++++++++++++++- ...o_provider_context_condition_user_page.inc | 27 ++++++++++++ 5 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 plugins/osso_provider_context_condition_user_page.inc diff --git a/osso_provider.defaults.inc b/osso_provider.defaults.inc index 76a76b9..762ebfc 100644 --- a/osso_provider.defaults.inc +++ b/osso_provider.defaults.inc @@ -33,6 +33,12 @@ function _osso_provider_context_default_contexts() { 'region' => 'right', 'weight' => 0, ), + 'views-osso_provider_sites-block_1' => array( + 'module' => 'views', + 'delta' => 'osso_provider_sites-block_1', + 'region' => 'right', + 'weight' => 1, + ), ), 'layout' => 'default', ), @@ -44,6 +50,38 @@ function _osso_provider_context_default_contexts() { ); $export['osso_provider_login'] = $context; + $context = new stdClass; + $context->disabled = FALSE; /* Edit this to true to make a default context disabled initially */ + $context->api_version = 3; + $context->name = 'osso_provider_user'; + $context->description = ''; + $context->tag = 'OSSO Provider'; + $context->conditions = array( + 'user_page' => array( + 'values' => array( + 'current' => 'current', + ), + ), + ); + $context->reactions = array( + 'block' => array( + 'blocks' => array( + 'views-osso_provider_sites-block_2' => array( + 'module' => 'views', + 'delta' => 'osso_provider_sites-block_2', + 'region' => 'right', + 'weight' => 0, + ), + ), + ), + ); + $context->condition_mode = 0; + + $translatables['osso_provider_user'] = array( + t('OSSO Provider'), + ); + + $export['osso_provider_user'] = $context; return $export; } diff --git a/osso_provider.features.views.inc b/osso_provider.features.views.inc index fcf12db..a62363e 100644 --- a/osso_provider.features.views.inc +++ b/osso_provider.features.views.inc @@ -46,6 +46,9 @@ function _osso_provider_views_default_views() { 'table' => 'openid_provider_sso_rps', 'field' => 'name', 'relationship' => 'none', + 'override' => array( + 'button' => 'Override', + ), ), 'realm' => array( 'label' => '', @@ -101,12 +104,18 @@ function _osso_provider_views_default_views() { )); $handler->override_option('title', 'Affiliate sites'); $handler->override_option('use_ajax', TRUE); + $handler->override_option('items_per_page', 5); $handler->override_option('use_pager', 'mini'); $handler->override_option('style_plugin', 'list'); $handler->override_option('style_options', array( 'grouping' => '', 'type' => 'ul', )); + $handler->override_option('row_options', array( + 'inline' => array(), + 'separator' => '', + 'hide_empty' => 0, + )); $handler = $view->new_display('block', 'Affiliate sites', 'block_1'); $handler->override_option('block_description', 'Affiliate sites'); $handler->override_option('block_caching', -1); @@ -153,6 +162,9 @@ function _osso_provider_views_default_views() { 'table' => 'openid_provider_sso_rps', 'field' => 'name', 'relationship' => 'none', + 'override' => array( + 'button' => 'Use default', + ), ), 'realm' => array( 'label' => '', diff --git a/osso_provider.info b/osso_provider.info index b901714..1be69fd 100644 --- a/osso_provider.info +++ b/osso_provider.info @@ -5,6 +5,7 @@ dependencies[] = "strongarm" dependencies[] = "openid_provider_sso" description = "OpenID Single Sign-On configuration and customization." features[context][] = "osso_provider_login" +features[context][] = "osso_provider_user" features[ctools][] = "context" features[ctools][] = "variable" features[variable][] = "user_email_verification" diff --git a/osso_provider.module b/osso_provider.module index 073a9f0..1941cf5 100644 --- a/osso_provider.module +++ b/osso_provider.module @@ -107,12 +107,13 @@ function osso_hub_bar() { function osso_provider_block_login_message() { $output = '
'; if (isset($_SESSION['openid_provider']['request']['openid.realm']) && $relying_party = openid_provider_sso_relying_party($_SESSION['openid_provider']['request']['openid.realm'])) { - drupal_set_title(t('Sign in to @relying_party', array('@relying_party' => $relying_party['name']))); + drupal_set_title(t('Login to @relying_party', array('@relying_party' => $relying_party['name']))); $output .= '

'. t('@relying_party is part of @site_name. ', array('@site_name' => variable_get('site_name', 'Drupal'), '@relying_party' => $relying_party['name'])) .'

'; } $output .= '

'. t('An account on @site_name gives you easy access to a series of sites with a single username and password.', array('@site_name' => variable_get('site_name', 'Drupal'))) .'

'; $output .= '
'; return array( + 'subject' => t('User login'), 'content' => $output, ); } @@ -140,3 +141,42 @@ function osso_provider_block_welcome_message() { 'content' => $content, ); } + +/** + * Implementation of hook_context_plugins(). + * + * This is a ctools plugins hook. + */ +function osso_provider_context_plugins() { + return array( + 'osso_provider_context_condition_user_page' => array( + 'handler' => array( + 'path' => drupal_get_path('module', 'osso_provider') .'/plugins', + 'file' => 'osso_provider_context_condition_user_page.inc', + 'class' => 'osso_provider_context_condition_user_page', + 'parent' => 'context_condition', + ), + ), + ); +} + +/** + * Implementation of hook_context_registry(). + */ +function osso_provider_context_registry() { + $registry = array(); + $registry['conditions'] = array( + 'user_page' => array( + 'title' => t('User page'), + 'description' => t('Set this context when viewing a user page.'), + 'plugin' => 'osso_provider_context_condition_user_page', + ), + ); + return $registry; +} + +function osso_provider_context_page_condition() { + if ($plugin = context_get_plugin('condition', 'user_page')) { + $plugin->execute(); + } +} diff --git a/plugins/osso_provider_context_condition_user_page.inc b/plugins/osso_provider_context_condition_user_page.inc new file mode 100644 index 0000000..9d9ac28 --- /dev/null +++ b/plugins/osso_provider_context_condition_user_page.inc @@ -0,0 +1,27 @@ + t('Current user'), + 'other' => t('Other users'), + ); + } + + function execute() { + if (arg(0) === 'user' && is_numeric(arg(1)) && !arg(2)) { + global $user; + $uid = arg(1); + if ($uid === $user->uid) { + foreach ($this->get_contexts('current') as $context) { + $this->condition_met($context, 'current'); + } + } + else { + foreach ($this->get_contexts('other') as $context) { + $this->condition_met($context, 'other'); + } + } + } + } +}