You are here

tokenauth_context.module in Token authentication 6.2

Code for the Token Authentication Context Integration module.

File

modules/tokenauth_context/tokenauth_context.module
View source
<?php

/**
 * @file
 * Code for the Token Authentication Context Integration module.
 */

/**
 * Implementation of hook_init().
 */
function tokenauth_context_init() {

  // Trigger tokenauth context condition.
  if ($plugin = context_get_plugin('condition', 'tokenauth_auth')) {
    $plugin
      ->execute((int) tokenauth_is_token_authenticated());
  }
}

/**
 * Implementation of hook_ctools_plugin_api().
 */
function tokenauth_context_ctools_plugin_api($module, $api) {
  if ($module == 'context' && $api == 'plugins') {
    return array(
      'version' => 3,
    );
  }
}

/**
 * Implementation of hook_context_registry().
 */
function tokenauth_context_context_registry() {
  $registry = array();
  $registry['conditions'] = array(
    'tokenauth_auth' => array(
      'title' => t('Token Authentication'),
      'description' => t('Set this context based on whether or not the user is logged in via the Token Authentication module.'),
      'plugin' => 'tokenauth_context_condition_tokenauth',
    ),
  );
  return $registry;
}

/**
 * Implementation of hook_context_plugins().
 */
function tokenauth_context_context_plugins() {
  $plugins = array();
  $plugins['tokenauth_context_condition_tokenauth'] = array(
    'handler' => array(
      'path' => drupal_get_path('module', 'tokenauth_context') . '/plugins',
      'file' => 'tokenauth_context_condition_tokenauth.inc',
      'class' => 'tokenauth_context_condition_tokenauth',
      'parent' => 'context_condition',
    ),
  );
  return $plugins;
}