passwd_only-8.x-1.x-dev/passwd_only_logintoboggan/passwd_only_logintoboggan.module
passwd_only_logintoboggan/passwd_only_logintoboggan.module
<?php
/**
* @file
* Integrates Password Only Login with logintoboggan.
*/
/**
* @addtogroup drupal_hooks
* @{
*/
/**
* Implements hook_menu().
*/
function passwd_only_logintoboggan_menu() {
$items['admin/config/system/passwd-only/logintoboggan'] = array(
'title' => 'LoginToboggan integration',
'type' => MENU_LOCAL_TASK,
'description' => 'Manage LoginToboggan integration.',
'page callback' => 'drupal_get_form',
'page arguments' => array('passwd_only_logintoboggan_admin'),
'access arguments' => array('admin Password Only Login'),
'file' => 'passwd_only_logintoboggan.pages.inc',
);
return $items;
}
/**
* Implements hook_js_alter().
*/
function passwd_only_logintoboggan_js_alter(&$javascript) {
$path = 'sites/all/modules/logintoboggan/logintoboggan.unifiedlogin.js';
if (!empty($javascript[$path])) {
$javascript[$path]['data'] = drupal_get_path('module', 'passwd_only_logintoboggan') . '/logintoboggan.unifiedlogin.js';
}
}
/**
* Implements hook_theme_registry_alter().
*/
function passwd_only_logintoboggan_theme_registry_alter(&$theme_registry) {
if (!empty($theme_registry['lt_unified_login_page']['function'])) {
$theme_registry['lt_unified_login_page']['function'] = 'passwd_only_logintoboggan_lt_unified_login_page';
$theme_registry['lt_unified_login_page']['variables']['passwd_only_form'] = NULL;
}
}
/**
* @} End of "addtogroup drupal_hooks".
*/
/**
* Preprocess function for passwd_only_logintoboggan_lt_unified_login_page().
*
* @see passwd_only_logintoboggan_theme_registry_alter()
* @see passwd_only_logintoboggan_lt_unified_login_page()
*/
function passwd_only_logintoboggan_preprocess_lt_unified_login_page(&$variables) {
$variables['passwd_only_form'] = \Drupal::service('renderer')->render(drupal_get_form('passwd_only_login_form'));
}
/**
* Theme function for unified login page.
*
* @see passwd_only_logintoboggan_preprocess_lt_unified_login_page()
*
* @ingroup themable
*/
function passwd_only_logintoboggan_lt_unified_login_page($variables) {
$login_form = $variables['login_form'];
$register_form = $variables['register_form'];
$active_form = $variables['active_form'];
$passwd_only_form = $variables['passwd_only_form'];
$output = '';
$output .= '<div class="toboggan-unified ' . $active_form . '">';
// Create the initial message and links that people can click on.
$output .= '<div id="login-message">' . t('You are not logged in.') . '</div>';
$output .= '<div id="login-links">';
$output .= l(t('I have an account'), 'user/login', array('attributes' => array('class' => array('login-link'), 'id' => 'login-link')));
$output .= ' ';
$output .= l(t('I want to create an account'), 'user/register', array('attributes' => array('class' => array('login-link'), 'id' => 'register-link')));
$output .= ' ';
$output .= l(variable_get('passwd_only_logintoboggan_link_text', t('Log in with Password Only Login')), 'passwd-only/login', array('attributes' => array('class' => array('login-link'), 'id' => 'passwd-only-link')));
$output .= '</div>';
// Add the login and registration forms in.
$output .= '<div id="login-form">' . $login_form . '</div>';
$output .= '<div id="register-form">' . $register_form . '</div>';
$output .= '<div id="passwd-only-form">' . $passwd_only_form . '</div>';
$output .= '</div>';
return $output;
}
