I have completed a port of this module to Drupal 6 with proper comments, coding standards and page handlers to optimise the code and the PHP memory usage is around 11550 bytes. CSS attribute also added to the message to hide the value when javascript is not enabled.

Comments

timmillwood’s picture

I'm just installing, let you know how it goes!

timmillwood’s picture

Works, although I think the check button should be next to the username checkbox and the message should come back as a drupal_set_message()

atuyo60’s picture

Hi, thanks for your suggestions and testing. The button issue was discussed previously in the Drupal 5 version and apparently there is no real solution to that as it seems to be a limitation of the core. You can still check out the discussions and see what solution suits your needs. My implementation here is just a slight improvement on the original. I was personally trying to do what you suggested as well but it seemed too much work for such a small cosmetic issue so in the end I abandoned that.

As for the message, what do you wish to achieve with using drupal_set_message? This is an AJAX checker and it is not meant to be submitted so if you are using drupal_set_message, the user cannot know the error until the page is refreshed or submitted.

timmillwood’s picture

I was thinking drupal_set_message puts the message in a place users should be familiar with, themed in a way they are familiar with. If drupal_set_messages can't be set / displayed via ajax then I guess its not an option.

burgs’s picture

I think there needs to be some javascript to do this checking automagically whilst the user is typing - but all in good time.
For now, to get the button into a better position the username_check_path_form function in username_check.module needs to be changed. The change below works:

function username_check_path_form(&$form) {
  foreach($form['account'] as $key => $value){
  	$_form['account'][$key] = $value;
  	if ($key == 'name'){
  		$_form['account']['username_button'] = array(
				'#type' => 'button',
				'#value' => t('Check username'),
			);
			$_form['account']['username_message'] = array(
				'#value' => TRUE,
				'#prefix' => '<div id="username-message" class="username-message">',
				'#suffix' => '</div>'
			);

  	}
  }
  $form['account'] = $_form['account'];
}
burgs’s picture

StatusFileSize
new8.43 KB

Ok, here is an update zip of the module, for Drupal 6, with keypress checking (no button to click), and a proper checking for invalid usernames.
Also, some re-placement of the text to sit just below the username textbox.

Thanks to atuyo60 for doing the hard yards.

sdsheridan’s picture

@burgs: Thanks for this! Much better positioning. I also added a '#weight' array element so that I could get it above the eMail and confirmation eMail boxes that logintoboggan provide, and adjusted the weight values in logintoboggan's hook_form_alter function for the 'user_registration' case so that the button appears just below the username field (in case this applies to anyone else).

shawn

timmillwood’s picture

This should be core!

One idea would be to outline the textbox if unavailable, like drupal does with required fields.

Flying Drupalist’s picture

awesome, am trying this. Thank you.

andreBerlin’s picture

StatusFileSize
new8.39 KB

Changes in d6 form handling seems to cause issues with the provided patch. The array keys are wrong.
Furthermore it is quite expensive to check the username every time on key up. I changed it a bit and now the check is performed only onblur, e.g on clicking in the mail-input.

Hope, that helps :)
André

Flying Drupalist’s picture

Thank you!

This version doesn't work outside of user/register though. So in my panel which combines the user login and register page, it doesn't work.

Can this module also check for usernames in the access denied section?

atuyo60’s picture

Changes in d6 form handling seems to cause issues with the provided patch. The array keys are wrong.
Furthermore it is quite expensive to check the username every time on key up. I changed it a bit and now the check is performed only onblur, e.g on clicking in the mail-input.

Hope, that helps :)
André

hi, regarding the wrong array keys issue, are u referring to the version i first posted ? cos I do not seem to be having problems with it yet...

ardas’s picture

Status: Active » Fixed

Thank you guys for all work you did. We have ported this module to Drupal 6 and added features you proposed. The release will be ready soon. Please download it and test.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.