Welcome, Guest. Please login or register.
Login with username, password and session length


Need help or want to talk to other developers? Join the VirtueMart Chat! Read more...

  Advanced search

247031 Posts in 67504 Topics- by 258313 Members - Latest Member: Matej.iStraxx
Pages: 1 2 3 [4]   Go Down
Print
Author Topic: [SOLVED] ajax registration  (Read 26331 times)
Pyno
Newbie
*
Posts: 43


« Reply #45 on: December 15, 2010, 16:11:14 pm »

First big thanks to peetree21 for a shared hack.

Well, I think I fixed most problems.


So  Wink

* fixed: not showing name and password in the form to change user data.
* fixed: in form to change user data has also investigated the email and username.
* fixed: length of fields and characters for a username and email can now be adjusted as other fields in the admin panel.
(Tests were made with VirtueMart 1.1.4 and IE6, IE7, IE8 and Mozilla)


According to recent tests that have been made, everything works as it should be.

Noted problems: not detected




Here's what should be done:


1. FILE: /administrator/components/com_virtuemart/html/checkout_register_form.php

CHANGE THESE LINEs
Code:
$missing = vmGet( $_REQUEST, "missing", "" );

if (!empty( $missing )) {
echo "<script type=\"text/javascript\">alert('".$VM_LANG->_('CONTACT_FORM_NC',false)."'); </script>\n";
}

AND REPLACE IT WITH THIS CODE:
Code:
$missing = vmGet( $_REQUEST, "missing", "" );

?>

<script language="javascript" type="text/javascript">



function getUsername(){
var form = document.adminForm;
var uname = form.username.value;

if( !$('username_ticker') )
$('username_input').innerHTML = $('username_input').innerHTML + "<div id=\"username_ticker\" style=\"padding-top:10px;\"></div>";

$('username_field').value = uname;

if( form.username.value.length < 3 ) {
$('username_ticker').innerHTML = '<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">Username : This input value is not valid.</span>';
} else {
$('username_ticker').innerHTML = "<img src=\"<?php echo JURI::base()."images/wait.gif";?>\">&nbsp;Checking";
var url = 'index.php?option=com_virtuemart&tasked=chkuserinfo&format=raw&what=uname';
url = url + '&uname=' + form.username.value;

new Ajax(url, {
method: 'get',
onComplete: function(x){
if(x == 1) {
$('username_ticker').innerHTML = '<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">This username is already registered.</span>';
} else {
$('username_ticker').innerHTML = '<span style="border:1px none transparent;color:green;padding:5px 5px 5px 5px;">The username \''+ $('username_field').value +'\' is free for registration: you can proceed.</span>';
}
}
}).request();

}
}


function getEmail(){

var form = document.adminForm;
var eadd = form.email.value;

if( !$('email_ticker') )
$('email_input').innerHTML = $('email_input').innerHTML + "<div id=\"email_ticker\" style=\"padding-top:10px;\"></div>";

$('email_field').value = eadd;

if( !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value))) {
$('email_ticker').setHTML('<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">Email : This input value is not valid.</span>');
} else {
$('email_ticker').setHTML("<img src=\"<?php echo JURI::base()."images/wait.gif";?>\">&nbsp;Checking");
var url = 'index.php?option=com_virtuemart&tasked=chkuserinfo&format=raw&what=email';
url = url + '&email=' + form.email.value;

new Ajax(url, {
method: 'get',
onComplete: function(x){
if(x == 1) {
$('email_ticker').setHTML('<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">This email is already registered.</span>');
} else {
$('email_ticker').setHTML('<span style="border:1px none transparent;color:green;padding:5px 5px 5px 5px;">The email \''+ $('email_field').value +'\' is free for registration: you can proceed.</span>');
}
}
}).request();

}
}



</script>
<?php

if (!empty( $missing )) {
echo "<script type=\"text/javascript\">alert('".$VM_LANG->_('CONTACT_FORM_NC',false)."'); </script>\n";
}



2. FILE: /administrator/components/com_virtuemart/classes/ps_userfield.php

AFTER THESE LINES
Code:
case 'password':
case 'password2':
echo '<input type="password" id="'.$field->name.'_field" name="'.$field->name.'" size="30" class="inputbox" />'."\n";
    break;

ADD THE CODES BELOW:
Code:
case 'email':
$maxlength = $field->maxlength ? 'maxlength="'.$field->maxlength.'"' : '';
echo '<input type="text" id="'.$field->name.'_field" name="'.$field->name.'" size="'.$field->size.'" onchange="getEmail();" value="'. ($db->sf($field->name, true, false)?$db->sf($field->name, true, false):'') .'" class="inputbox" '.$maxlength . $readonly . ' />'."\n";
  break;
case 'username':
$maxlength = $field->maxlength ? 'maxlength="'.$field->maxlength.'"' : '';
echo '<input type="text" id="'.$field->name.'_field" name="'.$field->name.'" size="'.$field->size.'" onchange="getUsername();" value="'. ($db->sf($field->name, true, false)?$db->sf($field->name, true, false):'') .'" class="inputbox" '.$maxlength . $readonly . ' />'."\n";
  break;


3. In the same file (ps_userfield.php)

AFTER THESE LINES
Code:
      /**
      * This is the most important part of this file
      * Here we print the field & its contents!
      */

ADD THE CODES BELOW:
Code:
             ?>
             
             <script language="javascript" type="text/javascript">



function getUsername(){
var form = document.adminForm;
var uname = form.username.value;

if( !$('username_ticker') )
$('username_input').innerHTML = $('username_input').innerHTML + "<div id=\"username_ticker\" style=\"padding-top:10px;\"></div>";

$('username_field').value = uname;

if( form.username.value.length < 3 ) {
$('username_ticker').innerHTML = '<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">Username : This input value is not valid.</span>';
} else {
$('username_ticker').innerHTML = "<img src=\"<?php echo JURI::base()."images/wait.gif";?>\">&nbsp;Checking";
var url = 'index.php?option=com_virtuemart&tasked=chkuserinfo&format=raw&what=uname';
url = url + '&uname=' + form.username.value;

new Ajax(url, {
method: 'get',
onComplete: function(x){
if(x == 1) {
$('username_ticker').innerHTML = '<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">This username is already registered.</span>';
} else {
$('username_ticker').innerHTML = '<span style="border:1px none transparent;color:green;padding:5px 5px 5px 5px;">The username \''+ $('username_field').value +'\' is free for registration: you can proceed.</span>';
}
}
}).request();

}
}


function getEmail(){

var form = document.adminForm;
var eadd = form.email.value;

if( !$('email_ticker') )
$('email_input').innerHTML = $('email_input').innerHTML + "<div id=\"email_ticker\" style=\"padding-top:10px;\"></div>";

$('email_field').value = eadd;

if( !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value))) {
$('email_ticker').setHTML('<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">Email : This input value is not valid.</span>');
} else {
$('email_ticker').setHTML("<img src=\"<?php echo JURI::base()."images/wait.gif";?>\">&nbsp;Checking");
var url = 'index.php?option=com_virtuemart&tasked=chkuserinfo&format=raw&what=email';
url = url + '&email=' + form.email.value;

new Ajax(url, {
method: 'get',
onComplete: function(x){
if(x == 1) {
$('email_ticker').setHTML('<span style="background:#FFFFCC;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 5px;">This email is already registered.</span>');
} else {
$('email_ticker').setHTML('<span style="border:1px none transparent;color:green;padding:5px 5px 5px 5px;">The email \''+ $('email_field').value +'\' is free for registration: you can proceed.</span>');
}
}
}).request();

}
}



</script>
        <?php



4. FILE: /components/com_virtuemart/virtuemart.php

AFTER THESE LINE
Code:
global $mosConfig_absolute_path, $product_id, $vmInputFilter, $vmLogger;

ADD THE CODES BELOW:
Code:
$tasked = JRequest::getVar( 'tasked' );

if($tasked=="chkuserinfo"){
$database = & JFactory::getDBO();
$email = JRequest::getVar( 'email' );
$uname = JRequest::getVar( 'uname' );

$what = JRequest::getVar( 'what' );

$usercount = 0;
$emailcount = 0;


if($what == "uname"){
$database->setQuery("SELECT COUNT(*) FROM #__users WHERE username='$uname'");
$usercount = $database->loadResult();
if($usercount)
echo "1";
else
echo "0";

} else if ($what == "email") {
$database->setQuery("SELECT COUNT(*) FROM #__users WHERE email='$email'");
$emailcount = $database->loadResult();

if($emailcount)
echo "1";
else
echo "0";
}


die();
}


ALSO MAKE SURE THE IMAGE BELOW IS UPLOADED INTO THE  /images DIRECTORY ON YOUR SERVER


I hope this will help. I expect feedback from your tests. Good luck to all.  Smiley

Is it possible to make this compatible with mootools 120? I must use mootools 120, but if I add this vmCommonHTML::loadMooTools(); they stop working!
Logged
Qzmarcia
Newbie
*
Posts: 7


« Reply #46 on: March 02, 2011, 21:10:11 pm »

VERY GOOD SOLUTIONS !!

I WANT NOW WHERE I CAN CHANGE THE TEXT: The username 'Qzkkkyan' is free for registration: you can proceed.

FOR MY NATIVE LANGUAGE.

TO REGARDS

QZ MARCIA
Logged
lindapowers
Full Member
***
Posts: 128


« Reply #47 on: March 03, 2011, 18:35:56 pm »

great... but I will wait until they add it officially.
Logged
cyran0
Newbie
*
Posts: 3


« Reply #48 on: March 16, 2011, 15:10:09 pm »

Hi

I successfully patch my 1.1.7 ver of VirtueMart ... thx a bunch, it is great : all the validations on the same page !

I have a related question which involve, I think, the same php pages.

With the email account activation in place, right after a successful registration why is the response page indicating a successful registration AND a login failure ?

Quote
Login denied! Your account has either been blocked or you have not activated it yet. Did you not get an activation e-mail and follow the validation link?

My guess is that there is some kind of auto-login which does not make sense for my setup since the new user must activate the account with the link inside the registration email first !

Lately, I applied another small patch which activates error messages, including the one above, through out the whole site, I added the line
    <jdoc:include type="message" />
into this file
    C:\xampp\htdocs\ecommerce\templates\ja_larix\index.php
ref: http://forum.virtuemart.net/index.php?topic=50465.0

I bet there is a simple way to deactivate the auto-login for this case. Somebody knows how ?

thx in advance
« Last Edit: March 16, 2011, 15:29:13 pm by cyran0 » Logged
lindapowers
Full Member
***
Posts: 128


« Reply #49 on: April 01, 2011, 19:41:50 pm »

Man this would be great, read the entire post but so many codes and corrections I don't know where to start from. Someone has this working correctly in VM 1.1.8?
Logged
maxxer
Newbie
*
Posts: 13


« Reply #50 on: April 13, 2011, 12:35:19 pm »

I'm attaching here a full patch for VM 1.1.7.
I'm trolling this!

Patch will apply with
patch -p1 < filename

* PATCH_verifica_utente.txt (9.24 KB - downloaded 166 times.)
Logged
lindapowers
Full Member
***
Posts: 128


« Reply #51 on: April 14, 2011, 10:30:29 am »

PATCH_verifica_utente.txt HuhHuhHuhHuhHuhHuh??

Where does that file go and what is the name of that file? Oo
Logged
didi235
Newbie
*
Posts: 1


« Reply #52 on: May 04, 2011, 04:48:33 am »

This patch is great but i am having a problem with SSL. It seems to get stuck on the waiting image. Does anyone have this working with SSL?
Logged
sirius
Newbie
*
Posts: 5


WWW
« Reply #53 on: May 12, 2011, 17:32:19 pm »

Hi,
implemented on virtuemart 1.1.8 (2nd method with all the corrections of the topic except mootools call)
joomla 1.5.23

All is ok, except that all username and all emails are always free to use...
Simple test with some already registered username, return always green/free to use.

Any same cases as my own ?

Thanks
Logged
Derf
Newbie
*
Posts: 8


« Reply #54 on: May 26, 2011, 13:18:41 pm »

This is awesome, thanks so much!

A few questions:

1) How do I use the same system to validate matching passwords?
2) How can I implement the same system for all the fields in the VM registration (first name, last name, address, etc.)

Thanks a ton!
Logged
Pages: 1 2 3 [4]   Go Up
Print
Jump to: