Skip to content

Commit

Permalink
Finishing site display.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhahn committed Mar 2, 2010
1 parent 330a890 commit c6165b3
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 1 deletion.
38 changes: 38 additions & 0 deletions osso_provider.defaults.inc
Expand Up @@ -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',
),
Expand All @@ -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;
}

Expand Down
12 changes: 12 additions & 0 deletions osso_provider.features.views.inc
Expand Up @@ -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' => '',
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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' => '',
Expand Down
1 change: 1 addition & 0 deletions osso_provider.info
Expand Up @@ -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"
Expand Down
42 changes: 41 additions & 1 deletion osso_provider.module
Expand Up @@ -107,12 +107,13 @@ function osso_hub_bar() {
function osso_provider_block_login_message() {
$output = '<div class="sso-message">';
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 .= '<p>'. t('<strong>@relying_party</strong> is part of <strong>@site_name</strong>. ', array('@site_name' => variable_get('site_name', 'Drupal'), '@relying_party' => $relying_party['name'])) .'</p>';
}
$output .= '<p>'. 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'))) .'</p>';
$output .= '</div>';
return array(
'subject' => t('User login'),
'content' => $output,
);
}
Expand Down Expand Up @@ -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();
}
}
27 changes: 27 additions & 0 deletions plugins/osso_provider_context_condition_user_page.inc
@@ -0,0 +1,27 @@
<?php

class osso_provider_context_condition_user_page extends context_condition {
function condition_values() {
return array(
'current' => 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');
}
}
}
}
}

0 comments on commit c6165b3

Please sign in to comment.