function om_user_alter in OM Tools 7
Same name and namespace in other branches
- 8.2 tools/user/user.inc \om_user_alter()
- 8 tools/user/user.inc \om_user_alter()
- 6 tools/user/user.inc \om_user_alter()
- 7.2 tools/user/user.inc \om_user_alter()
OM Tools User Form Alters
File
- tools/
user/ user.inc, line 415 - User form alters
Code
function om_user_alter(&$form, &$form_state, $form_id) {
// Make sure the js are added only once
static $user_login_block_js = 0;
static $user_login_js = 0;
static $user_register_js = 0;
static $user_pass_js = 0;
switch ($form_id) {
case "user_login_block":
if (variable_get('om_tools_user_login_block_alter_switch', 0)) {
$user_login_block_label = variable_get('om_tools_user_login_block_label', 1);
$user_login_block_name_label_text = variable_get('om_tools_user_login_block_name_label_text', 'User Name');
$user_login_block_pass_label_text = variable_get('om_tools_user_login_block_pass_label_text', 'Password');
$user_login_block_size = variable_get('om_tools_user_login_block_size', 15);
$user_login_block_name_hover = variable_get('om_tools_user_login_block_name_hover', 'Enter your user name.');
$user_login_block_pass_hover = variable_get('om_tools_user_login_block_pass_hover', 'Enter your password.');
$user_login_block_button = variable_get('om_tools_user_login_block_button', 'Login');
$user_login_block_register = variable_get('om_tools_user_login_block_register', 'Create new account');
$user_login_block_password = variable_get('om_tools_user_login_block_password', 'Request new password');
$user_login_block_links = '<div class="item-list"><ul><li class="first"><a href="' . base_path() . 'user/register" title="Create a new user account.">' . $user_login_block_register . '</a></li> <li class="last"><a href="' . base_path() . 'user/password" title="Request new password via e-mail.">' . $user_login_block_password . '</a></li> </ul></div>';
if ($user_login_block_label) {
unset($form['name']['#title']);
unset($form['pass']['#title']);
$form['name']['#default_value'] = $user_login_block_name_label_text;
$user_login_block_js++;
if ($user_login_block_js == 1) {
drupal_add_js(" \n jQuery(document).ready(function(\$){\n \$('#user-login-form input#edit-name').val('" . $user_login_block_name_label_text . "');\n \$('#user-login-form input#edit-name').click(function() {\n if (\$(this).val() == '" . $user_login_block_name_label_text . "') { \$(this).val(''); };\n });\n \$('#user-login-form input#edit-name').blur(function() {\n if ((\$(this).val() == '" . $user_login_block_name_label_text . "') || (\$(this).val() == '')) { \n \$(this).val('" . $user_login_block_name_label_text . "'); \n }\n });\n \n \$('#user-login-form input#edit-pass').before(\"<input type='text' class='form-text' size='" . $user_login_block_size . "' maxlength='60' id='dummy-pass' name='dummy-pass' value='" . $user_login_block_pass_label_text . "' title='" . t($user_login_block_pass_hover) . "'>\");\n \n \$('#user-login-form input#edit-pass').hide();\n \$('#user-login-form input#dummy-pass').show();\n \n \$('#user-login-form input#dummy-pass').focus(function() {\n \$('#user-login-form input#dummy-pass').hide();\n \$('#user-login-form input#edit-pass').show();\n \$('#user-login-form input#edit-pass').focus();\n });\n \$('#user-login-form input#edit-pass').blur(function() {\n if (\$('#user-login-form input#edit-pass').val() == '') {\n \$('#user-login-form input#dummy-pass').show();\n \$('#user-login-form input#edit-pass').hide();\n } \n });\n }); \n ", "inline");
}
}
else {
$form['name']['#title'] = $user_login_block_name_label_text;
$form['pass']['#title'] = $user_login_block_pass_label_text;
}
$form['name']['#size'] = $user_login_block_size;
$form['name']['#attributes'] = array(
'title' => t($user_login_block_name_hover),
);
$form['pass']['#size'] = $user_login_block_size;
$form['pass']['#attributes'] = array(
'title' => t($user_login_block_pass_hover),
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t($user_login_block_button),
);
$form['links']['#markup'] = $user_login_block_links;
break;
}
case "user_login":
if (variable_get('om_tools_user_login_alter_switch', 0)) {
drupal_set_title(t(variable_get('om_tools_user_login_title', 'Log In')));
$user_login_label = variable_get('om_tools_user_login_label', 1);
$user_login_name_label_text = variable_get('om_tools_user_login_name_label_text', 'User Name');
$user_login_name_description = variable_get('om_tools_user_login_name_description', 'Enter your username.');
$user_login_pass_label_text = variable_get('om_tools_user_login_pass_label_text', 'Password');
$user_login_pass_description = variable_get('om_tools_user_login_pass_description', 'Enter the password that accompanies your username.');
$user_login_size = variable_get('om_tools_user_login_size', 30);
$user_login_name_hover = variable_get('om_tools_user_login_name_hover', 'Enter your user name.');
$user_login_pass_hover = variable_get('om_tools_user_login_pass_hover', 'Enter your password.');
$user_login_button = variable_get('om_tools_user_login_button', 'Login');
if ($user_login_label) {
unset($form['name']['#title']);
unset($form['pass']['#title']);
$form['name']['#default_value'] = $user_login_name_label_text;
$user_login_js++;
if ($user_login_js == 1) {
drupal_add_js("\n jQuery(document).ready(function(\$){\n \$('#user-login input#edit-name').val('" . $user_login_name_label_text . "');\n \$('#user-login input#edit-name').click(function() {\n if (\$(this).val() == '" . $user_login_name_label_text . "') { \$(this).val(''); };\n });\n \$('#user-login input#edit-name').blur(function() {\n if ((\$(this).val() == '" . $user_login_name_label_text . "') || (\$(this).val() == '')) { \n \$(this).val('" . $user_login_name_label_text . "'); \n }\n });\n \n \$('#user-login input#edit-pass').before(\"<input type='text' class='form-text' size='" . $user_login_size . "' maxlength='60' id='dummy-pass' name='dummy-pass' value='" . $user_login_pass_label_text . "' title='" . t($user_login_pass_hover) . "'>\");\n \n \$('#user-login input#edit-pass').hide();\n \$('#user-login input#dummy-pass').show();\n \n \$('#user-login input#dummy-pass').focus(function() {\n \$('#user-login input#dummy-pass').hide();\n \$('#user-login input#edit-pass').show();\n \$('#user-login input#edit-pass').focus();\n });\n \$('#user-login input#edit-pass').blur(function() {\n if (\$('#user-login input#edit-pass').val() == '') {\n \$('#user-login input#dummy-pass').show();\n \$('#user-login input#edit-pass').hide();\n } \n });\n }); \n ", "inline");
}
}
else {
$form['name']['#title'] = $user_login_name_label_text;
$form['pass']['#title'] = $user_login_pass_label_text;
}
$form['name']['#description'] = $user_login_name_description;
$form['name']['#size'] = $user_login_size;
$form['name']['#attributes'] = array(
'title' => t($user_login_name_hover),
);
$form['pass']['#description'] = $user_login_pass_description;
$form['pass']['#size'] = $user_login_size;
$form['pass']['#attributes'] = array(
'title' => t($user_login_pass_hover),
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t($user_login_button),
);
break;
}
case "user_register_form":
if (variable_get('om_tools_user_register_alter_switch', 0)) {
drupal_set_title(t(variable_get('om_tools_user_register_title', 'Register')));
$user_register_label = variable_get('om_tools_user_register_label', 1);
$user_register_name_label_text = variable_get('om_tools_user_register_name_label_text', 'User Name');
$user_register_name_description = variable_get('om_tools_user_register_name_description', 'Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.');
$user_register_mail_label_text = variable_get('om_tools_user_register_mail_label_text', 'E-mail Address');
$user_register_mail_description = variable_get('om_tools_user_register_mail_description', 'A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.');
$user_register_size = variable_get('om_tools_user_register_size', 30);
$user_register_name_hover = variable_get('om_tools_user_register_name_hover', 'Enter your user name.');
$user_register_mail_hover = variable_get('om_tools_user_register_mail_hover', 'Enter your e-mail address.');
$user_register_button = variable_get('om_tools_user_register_button', 'Create new account');
if ($user_register_label) {
unset($form['account']['name']['#title']);
unset($form['account']['mail']['#title']);
$form['account']['name']['#default_value'] = $user_register_name_label_text;
$user_register_js++;
if ($user_register_js == 1) {
drupal_add_js("\n jQuery(document).ready(function(\$){\n \$('#user-register-form input#edit-name').val('" . $user_register_name_label_text . "');\n \$('#user-register-form input#edit-name').click(function() {\n if (\$(this).val() == '" . $user_register_name_label_text . "') { \$(this).val(''); };\n });\n \$('#user-register-form input#edit-name').blur(function() {\n if ((\$(this).val() == '" . $user_register_name_label_text . "') || (\$(this).val() == '')) { \n \$(this).val('" . $user_register_name_label_text . "'); \n }\n });\n\n \$('#user-register-form input#edit-name--2').val('" . $user_register_name_label_text . "');\n \$('#user-register-form input#edit-name--2').click(function() {\n if (\$(this).val() == '" . $user_register_name_label_text . "') { \$(this).val(''); };\n });\n \$('#user-register-form input#edit-name--2').blur(function() {\n if ((\$(this).val() == '" . $user_register_name_label_text . "') || (\$(this).val() == '')) { \n \$(this).val('" . $user_register_name_label_text . "'); \n }\n });\n\n \$('#user-register-form input#edit-mail').val('" . $user_register_mail_label_text . "');\n \$('#user-register-form input#edit-mail').click(function() {\n if (\$(this).val() == '" . $user_register_mail_label_text . "') { \$(this).val(''); };\n });\n \$('#user-register-form input#edit-mail').blur(function() {\n if ((\$(this).val() == '" . $user_register_mail_label_text . "') || (\$(this).val() == '')) { \n \$(this).val('" . $user_register_mail_label_text . "'); \n }\n });\n }); \n ", "inline");
}
}
else {
$form['account']['name']['#title'] = $user_register_name_label_text;
$form['account']['mail']['#title'] = $user_register_mail_label_text;
}
$form['account']['name']['#description'] = $user_register_name_description;
$form['account']['name']['#size'] = $user_register_size;
$form['account']['name']['#attributes'] = array(
'title' => t($user_register_name_hover),
);
$form['account']['mail']['#description'] = $user_register_mail_description;
$form['account']['mail']['#size'] = $user_register_size;
$form['account']['mail']['#attributes'] = array(
'title' => t($user_register_mail_hover),
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t($user_register_button),
);
break;
}
case "user_pass":
if (variable_get('om_tools_user_pass_alter_switch', 0)) {
drupal_set_title(t(variable_get('om_tools_user_pass_title', 'New Password Request')));
$user_pass_label = variable_get('om_tools_user_pass_label', 1);
$user_pass_name_label_text = variable_get('om_tools_user_pass_name_label_text', 'User Name or E-mail');
$user_pass_name_description = variable_get('om_tools_user_pass_name_description', '');
$user_pass_size = variable_get('om_tools_user_pass_size', 30);
$user_pass_name_hover = variable_get('om_tools_user_pass_name_hover', 'Enter your user name or e-mail.');
$user_pass_button = variable_get('om_tools_user_pass_button', 'E-mail new password');
if ($user_pass_label) {
unset($form['name']['#title']);
unset($form['mail']['#title']);
$form['name']['#default_value'] = $user_pass_name_label_text;
$user_pass_js++;
if ($user_pass_js == 1) {
drupal_add_js("\n jQuery(document).ready(function(\$){\n \$('#user-pass input#edit-name').val('" . $user_pass_name_label_text . "');\n \$('#user-pass input#edit-name').click(function() {\n if (\$(this).val() == '" . $user_pass_name_label_text . "') { \$(this).val(''); };\n });\n \$('#user-pass input#edit-name').blur(function() {\n if ((\$(this).val() == '" . $user_pass_name_label_text . "') || (\$(this).val() == '')) { \n \$(this).val('" . $user_pass_name_label_text . "'); \n }\n });\n }); \n ", "inline");
}
}
else {
$form['name']['#title'] = $user_pass_name_label_text;
}
$form['name']['#description'] = $user_pass_name_description;
$form['name']['#size'] = $user_pass_size;
$form['name']['#attributes'] = array(
'title' => t($user_pass_name_hover),
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t($user_pass_button),
);
break;
}
}
}