View source
<?php
function luxe_menu_local_tasks_alter(&$data, $router_item, $root_path) {
if (count($data['tabs']) == 0) {
return;
}
foreach ($data['tabs'][0]['output'] as $id => $tab) {
switch ($tab['#link']['path']) {
case 'user/register':
case 'user/login':
case 'user/password':
unset($data['tabs'][0]['output'][$id]);
break;
}
}
}
function luxe_menu_alter(&$item) {
$item['user/login']['type'] = MENU_NORMAL_ITEM;
$item['user/login']['page callback'] = 'luxe_login_page';
$item['user']['page callback'] = 'luxe_login_page';
$item['user/register']['page callback'] = 'luxe_register_page';
$item['user/register']['page arguments'] = array(
2,
);
}
function luxe_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'user_login':
drupal_set_title('');
$form['lost_password'] = array(
'#markup' => '<div class="login-forgot">' . l(variable_get('luxe_recover_text', 'Forgot your password?'), 'user/password') . '</div>',
);
break;
case 'user_pass':
drupal_set_title(variable_get('luxe_recover_title', 'Forgot your password?'));
$form['lost_password'] = array(
'#markup' => '<div class="login-forgot">' . l(t('No? Go log in then.'), 'user') . '</div>',
);
break;
case 'user_register_form':
$user_desc = variable_get('luxe_register_username_description', '');
if (!empty($user_desc)) {
$form['account']['name']['#description'] = variable_get('luxe_register_username_description', '');
}
$mail_desc = variable_get('luxe_register_mail_description', '');
if (!empty($mail_desc)) {
$form['account']['mail']['#description'] = variable_get('luxe_register_mail_description', '');
}
break;
}
}
function luxe_login_page() {
global $user;
if ($user->uid) {
drupal_goto('user/' . $user->uid);
}
$login_form = drupal_get_form('user_login');
$login_form = drupal_render($login_form);
if (variable_get('luxe_login_register_form', 0)) {
$register_form = drupal_get_form('user_register_form');
}
else {
$register_form = array(
'#method' => 'post',
'#action' => url('user/register/'),
'#form_id' => 'user_login_register',
'#type' => 'form',
'username' => array(
'#type' => 'hidden',
'#attributes' => array(
'id' => array(
'luxe-regname',
),
),
),
'submit' => array(
'#value' => t('Create an account'),
'#type' => 'submit',
),
);
}
$vars = array(
'login_form' => $login_form,
'login_title' => variable_get('luxe_login_title', 'Login'),
'login_register_title' => variable_get('luxe_login_register_title', 'Don\'t have an Account?'),
'login_register_form' => drupal_render($register_form),
'login_register_intro' => check_plain(variable_get('luxe_login_register_intro', '')),
'register_title' => variable_get('luxe_register_title', 'Sign up'),
);
return theme('luxe_login', $vars);
}
function luxe_register_page($username = null) {
global $user;
if ($user->uid) {
drupal_goto('user/' . $user->uid);
}
drupal_set_title(variable_get('luxe_register_title', 'Sign up'));
$form = drupal_get_form('user_register_form');
if (!empty($username) && empty($form['account']['name']['#value'])) {
$form['account']['name']['#value'] = $username;
}
return drupal_render($form);
}
function luxe_theme() {
return array(
'luxe_login' => array(
'template' => 'templates/login',
'variables' => array(
'login_form' => NULL,
'login_title' => NULL,
'login_register_title' => NULL,
'login_register_form' => NULL,
'login_register_intro' => NULL,
'register_title' => NULL,
),
),
);
}
function luxe_admin_settings() {
$form['luxe_login'] = array(
'#type' => 'fieldset',
'#title' => t('Login page settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['luxe_login']['luxe_login']['luxe_login_title'] = array(
'#type' => 'textfield',
'#multiple' => true,
'#title' => t('Login Form Title'),
'#default_value' => variable_get('luxe_login_title', 'Login'),
);
$form['luxe_login']['luxe_recover_text'] = array(
'#type' => 'textfield',
'#multiple' => true,
'#title' => t('Text for the login form\'s "recover password" link.'),
'#default_value' => variable_get('luxe_recover_text', 'Forgot your password?'),
);
$form['luxe_login']['luxe_login_register_title'] = array(
'#type' => 'textfield',
'#multiple' => true,
'#title' => t('Title for login form registration block'),
'#default_value' => variable_get('luxe_login_register_title', 'Don\'t have an Account?'),
);
$form['luxe_login']['luxe_login_register_intro'] = array(
'#type' => 'textarea',
'#multiple' => true,
'#title' => t('Registration block text for login form'),
'#default_value' => variable_get('luxe_login_register_intro', ''),
);
$form['luxe_login']['luxe_login_register_form'] = array(
'#type' => 'checkbox',
'#return_value' => 1,
'#default_value' => variable_get('luxe_login_register_form', 0),
'#title' => t('Show full registration form on login page'),
'#description' => t("Instead of just a link to the registration page, embed the whole registration form in the login page."),
);
$form['luxe_register'] = array(
'#type' => 'fieldset',
'#title' => t('Registration page settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['luxe_register']['luxe_register_title'] = array(
'#type' => 'textfield',
'#multiple' => true,
'#title' => t('Registration Form Title'),
'#default_value' => variable_get('luxe_register_title', 'Sign up'),
);
$form['luxe_register']['luxe_register_username_description'] = array(
'#type' => 'textfield',
'#multiple' => true,
'#title' => t('Registration Form Username Field Description'),
'#description' => t('The help text that appears under the username field in the registration form. Leave blank to use Drupal\'s build-in value.'),
'#default_value' => variable_get('luxe_register_username_description', ''),
);
$form['luxe_register']['luxe_register_mail_description'] = array(
'#type' => 'textfield',
'#multiple' => true,
'#title' => t('Registration Form Email Field Description'),
'#description' => t('The help text that appears under the email field in the registration form. Leave blank to use Drupal\'s build-in value.'),
'#default_value' => variable_get('luxe_register_mail_description', ''),
);
$form['luxe_recover_title'] = array(
'#type' => 'textfield',
'#multiple' => true,
'#title' => t('Password Recovery Form Title'),
'#default_value' => variable_get('luxe_recover_title', 'Forgot your password?'),
);
return system_settings_form($form);
}
function luxe_menu() {
$items['admin/config/user-interface/luxe'] = array(
'title' => t('Luxe'),
'description' => t('Headlines and content for your login and registration pages'),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'luxe_admin_settings',
),
'access arguments' => array(
'administer site configuration',
),
);
return $items;
}